Improve Python <-> .NET exception integration by lostmsu · Pull Request #1134 · pythonnet/pythonnet

added 10 commits

May 13, 2020 14:03
…ET interop

New method ThrowLastAsClrException should be used everywhere instead of obsolete PythonException constructor. It automatically restores .NET exceptions, and applies codecs for Python exceptions.

Traceback, PyVal and PyType are now stored and returned as PyObjects.

PythonException now has InnerException set from its cause (e.g. __cause__ in Python, if any).

PythonException.Restore no longer clears the exception instance.

All helper methods were removed from public API surface.
…chInfo masking exception object
The new type indicates parameters of C API functions,
that steal references to passed objects.

@lostmsu

@lostmsu

@lostmsu

@lostmsu

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.

@lostmsu

@lostmsu

@lostmsu

@lostmsu

@lostmsu

@lostmsu

@lostmsu

@lostmsu

@lostmsu

- no longer leaking iterator object on failure
- when iteration stops due to error, propagates the error

@lostmsu

@lostmsu

@lostmsu

@lostmsu

@lostmsu

@lostmsu

@lostmsu

@lostmsu

@lostmsu lostmsu marked this pull request as ready for review

May 23, 2021 09:01

@lostmsu

@lostmsu

@lostmsu

@lostmsu

…tp_dealloc and don't override Dealloc

@SDEII @lostmsu

@lostmsu