-
Notifications
You must be signed in to change notification settings - Fork 4
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix backtrace formatting in YPython::PyErrorHandler() [Merge SLE-15-SP3 into master] #40
Conversation
An exception value returned by PyErr_Fetch() can be in certain situations "unnormalized", which means the value does not have to be an instance of the returned exception type. This typically happens when an exception is set from a native library. For instance: > PyObject *w = Py_BuildValue("(i,i)", 123, 456); > PyErr_SetObject(NativeError, w); The exception value is in this case a tuple object and not an instance of NativeError, until the exception gets normalized. Code in YPython::PyErrorHandler() passes an obtained exception value directly to traceback.format_exception(). This method however expects that the value is already a valid exception object and fails quickly with an AttributeError when that is not the case. This subsequently results in an unhandled error in YPython::PyErrorHandler() and in a SystemError when other Python/C API functions are invoked. The patch fixes the problem by calling PyErr_NormalizeException() in YPython::PyErrorHandler() to normalize the value to be an exception object.
PyImport_ImportModule("traceback") in YPython::PyErrorHandler() returns a new reference. Add a call to Py_XDECREF() once the code is done with the module to avoid leaking its reference.
Fix backtrace formatting in YPython::PyErrorHandler()
Fix backtrace formatting in YPython::PyErrorHandler() (Merge SLE-15-SP2 into SLE-15-SP3)
This reverts commit b023478.
To have changes in sequence.
@petrpavlu I have created this one and closed #39 as commented at #39 (comment) Hope you don't mind. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not a Python expert, but compared with #39 the changes look good to me. Thanks!
✔️ Public Jenkins job #24 successfully finished |
✔️ Internal Jenkins job #8 successfully finished |
This PR replaces #39 after #38 was merged. It basically