Граф коммитов

1907 Коммитов

Автор SHA1 Сообщение Дата
Félix Bourbonnais e469a8a73c fixups, add docs 2021-06-02 10:56:48 -04:00
Félix Bourbonnais d821c0f709 Further refinements to setattr logic on ModuleObjects 2021-06-02 10:56:48 -04:00
Félix Bourbonnais afffc18751 Fix a bug where clr wasn't in sys.modules after reload 2021-06-02 10:56:48 -04:00
Félix Bourbonnais f92e95b39d cleanup and changelog entry 2021-06-02 10:56:47 -04:00
Félix Bourbonnais 279b53546d Add the loaded namespaces tracking 2021-06-02 10:56:28 -04:00
Félix Bourbonnais a321daa014 (WIP) modernize the import hook
Implement a meta path loader instead
2021-06-02 10:55:30 -04:00
Victor 7d8f754ff6
Merge pull request #1134 from losttech/PR/ExceptionsImprovement
Improve Python <-> .NET exception integration
2021-06-01 15:36:18 -07:00
Victor Nova c500a3929f fixup! reworked `PythonException`: 2021-05-29 16:46:05 -07:00
Victor Milovanov 4f3f648d6a fixup! merge latest master 2021-05-29 16:46:05 -07:00
Victor Nova 7271d88fae all Dealloc overrides simply duplicate Clear, so just call both from tp_dealloc and don't override Dealloc 2021-05-29 16:45:48 -07:00
Victor Nova 5bca333897 refactored tp_clear in ExtensionType and descendants into a virtual C# function Clear 2021-05-29 16:45:48 -07:00
Victor Nova 25e38640c6 refactored tp_dealloc in ExtensionType and descendants 2021-05-29 16:45:48 -07:00
Victor Nova 539ce815de added OverloadMapper to ManagedTypes class diagram 2021-05-29 16:45:48 -07:00
Victor Nova 2e57b0419b + class diagram for ManagedType and subclasses 2021-05-29 16:45:48 -07:00
Victor Nova 7eac886833 handle ProcessExit event to avoid Python crash when CLR (in particular Mono) is unloaded before Python stops 2021-05-29 16:43:29 -07:00
Victor Nova 993707efba all Dealloc overrides simply duplicate Clear, so just call both from tp_dealloc and don't override Dealloc 2021-05-23 00:41:33 -07:00
Victor Nova 786b450fd4 refactored tp_clear in ExtensionType and descendants into a virtual C# function Clear 2021-05-23 00:41:33 -07:00
Victor Nova 88b19cf1ad refactored tp_dealloc in ExtensionType and descendants 2021-05-22 20:42:41 -07:00
Victor Nova 91e98a2d96 added OverloadMapper to ManagedTypes class diagram 2021-05-22 20:42:41 -07:00
Victor Nova 2c6202863d + class diagram for ManagedType and subclasses 2021-05-22 18:09:39 -07:00
Victor Nova 67bd1c2429 merge latest master 2021-05-14 20:05:18 -07:00
Victor Nova 21169db26e use PyType instances instead of raw pointers in TypeManager type cache and ConstructorBinding instances 2021-05-14 19:48:20 -07:00
Victor Nova 5ded48dd37 dispose all temporary objects in PyCheck_Iter_PyObject_IsIterable_ThreadingLock_Test 2021-05-14 05:06:40 -07:00
Félix Bourbonnais 33d771c280
Re-enable the domain reload tests (#1404)
Add `domain_tests` to `testpaths` in pyproject.toml
Run domain tests only if domains are supported
Move the domain reload tests to the `tests` directory, merge the `conftest.py` files

* Don't run domain reload tests in soft mode, increase timeout
2021-05-03 00:08:43 -07:00
Victor Milovanov db746aa86a detect Py_TRACE_REFS at runtime and calculate object offsets accordingly 2021-04-27 00:42:24 -07:00
Victor Nova daccc43c32 Replaced magic offsets with per-type calculation
removed some macro-like method copy-pastes from CPython and bits of dead code

All Python types created to represent CLR concepts derive from `CLR MetaType` (as before), which now has two new fields:

- `tp_clr_inst_offset`, which is similar to `tp_dictoffset` in that it tells where to find `GCHandle` in instances of this type (e.g. where to find `GCHandle` pointing to `System.Uri` in corresponding Python object)
- `tp_clr_inst`, which holds an optional instance of `ManagedType`, that implements the behavior of the type itself (e.g. `GCHandle` pointing to `ClassObject(type = System.Uri)`)

So the layout of all Python types created by Python.NET is
  PyType type;
  nint tp_clr_inst_offset;
  GCHandel tp_clr_inst; (points, for example, to an instance of `ClassObject`)

When a Python type, that reflects CLR type is created, the layout of instances will be:
  BaseTypeFields base;
  optional (if not in base): IntPtr dict;
  optional (if not in base): IntPtr weaklist;
  GCHandle gcHandle; (points to `CLRObject` instance, which in turn, for example, points to the actual instance of `System.Uri`)

The offset to GC handle is recorded in the Python type's `tp_clr_inst_offset`, and can be found as `PyObject_Type(inst).tp_clr_inst_offset`. Or, preferably, accessor functions in `ManagedType` should be used.
2021-04-23 17:21:08 -07:00
Victor Nova 16f04e9c02 fixed __cause__ on overload bind failure and array conversion
also: added debug check
2021-04-13 17:38:30 -07:00
Benedikt Reinartz 07754583d8
Merge pull request #1440 from losttech/PR/No_find_libpyton_for_import_clr
Do not call `find_libpython` during `import clr` as Python.Runtime can find it on its own
2021-04-12 13:14:52 +02:00
Victor Nova dff75d2092 do not call find_libpython as Python.Runtime can find it on its own 2021-04-11 14:07:36 -07:00
Victor Nova 6679d1ce59 added a few debug checks 2021-04-11 13:36:21 -07:00
Victor Nova 6819e7b5ea improved handling of dict offset in object instances 2021-04-11 13:36:13 -07:00
Victor Nova e5bce06b48 minor code cleanup 2021-04-11 12:37:27 -07:00
Victor Nova ed594c1cf4 cache PythonException message 2021-04-11 12:35:37 -07:00
Victor Nova 4877fe7d3f fixed __cause__ on overload bind failure and array conversion 2021-04-11 03:33:00 -07:00
Victor Nova d068f365b9 XDecref now checks, that refcount is positive in debug builds 2021-04-11 01:05:26 -07:00
Victor Nova e79f041f3a method binding failure now supports non-Python exception causes 2021-04-11 01:03:49 -07:00
Victor Nova 2cd3f6189d added a few debug checks to Exceptions.SetError 2021-04-11 01:02:27 -07:00
Victor Nova 272687bfdb minor fixes to Converter.ToArray:
- no longer leaking iterator object on failure
- when iteration stops due to error, propagates the error
2021-04-11 01:01:20 -07:00
Victor Nova 146ebf3f3d fixed type of reference in PyException_SetCause 2021-04-10 20:06:24 -07:00
Victor Nova d976acf44d simplified code of PythonException and added a lot more checks 2021-04-10 19:37:37 -07:00
Victor Nova dfc70f6822 minor change in PythonEngine.With 2021-04-10 19:33:49 -07:00
Victor Nova faec7fc163 Point users to Message property of PythonException 2021-04-10 17:36:13 -07:00
Victor Nova 63ad42ce7e PythonException: dispose intermediate values used in stack trace generation 2021-04-10 17:35:50 -07:00
Victor Nova 95cc52fdb2 can't test exception type when runtime is down 2021-04-10 17:34:52 -07:00
Victor Nova 343320139f separate .Steal() and .StealNullable() 2021-04-10 17:34:30 -07:00
Victor Nova 00653dcf9a PythonException.StackTrace is GIL-safe 2021-04-09 12:40:58 -07:00
Victor Nova e58411d905 rum embedding tests before Python tests 2021-04-09 12:08:05 -07:00
Victor Nova c0fe430e5a reworked `PythonException`:
Removed private fields, apart from ones returned by `PyErr_Fetch`.
Corresponding property values are now generated on demand.

Added FetchCurrent*Raw for internal consumption.

`PythonException.Type` is now of type `PyType`.

Use C API functions `PyException_GetCause` and `PyException_GetTraceback` instead of trying to read via attributes by name.

`PythonException` instances are no longer disposable. You can still dispose `.Type`, `.Value` and `.Traceback`, but it is not recommended, as they may be shared with other instances.
2021-04-08 23:32:25 -07:00
Victor Nova 257a765521 merge latest master 2021-04-08 22:57:31 -07:00
Victor Nova 23527d1137 disabled PythonRegisteredDecoder_NoStackOverflowOnSystemType test due to known issue with custom codes + engine restarts
https://github.com/pythonnet/pythonnet/issues/1256
2021-03-30 21:10:07 -07:00