- Notifications
You must be signed in to change notification settings - Fork749
Improve Python <-> .NET exception integration#1134
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Conversation
…ET interopNew 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
4fe0548
to0961c94
CompareThe new type indicates parameters of C API functions,that steal references to passed objects.
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.
Damn CI failures do not reproduce locally :/ |
- no longer leaking iterator object on failure- when iteration stops due to error, propagates the error
4c76f15
to4877fe7
Compare1512a55
to87dd9fd
Compare87dd9fd
to6679d1c
Comparef812ec7
to651d145
Compare…tp_dealloc and don't override Dealloc
651d145
toc500a39
CompareFelk commentedJun 13, 2021
Hello, given that catch(PythonExceptionex)when(ex.PyType==Exceptions.KeyError) |
lostmsu commentedJun 14, 2021 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
@Felk You can get |
Felk commentedJun 14, 2021
Thank you, this is how I got it to work now: dynamicbuiltins=Py.Import("builtins");try{// ...}catch(PythonExceptionex)when(ex.Type.Equals(builtins.KeyError)){// ...} |
@Felk comparing type handles will be slightly faster |
Felk commentedJun 14, 2021
@lostmsu can you give me an example of what you mean? |
lostmsu commentedJun 14, 2021 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
@Felk If you really cared, you'd also cache |
Uh oh!
There was an error while loading.Please reload this page.
What does this implement/fix? Explain your changes.
PythonException
was thrown instead).InnerException
property is populated from Python's__cause__
attribute.PythonException
class. Instead of working with raw pointers, usesPyObject
instances.Breaking
Traceback
,PyVal
andPyType
are now stored and returned asPyObject
s.PythonException.Restore
no longer nulls outPythonException
instance.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.Does this close any currently open issues?
#893,#1098
Checklist
Check all those that are applicable and complete.
AUTHORS
CHANGELOG