mirror of
https://github.com/pybind/pybind11.git
synced 2024-12-03 02:17:12 +00:00
For Python < 3.8: PyErr_NormalizeException
before PyErr_WriteUnraisable
This commit is contained in:
parent
7578de9c48
commit
bab6f668e1
@ -472,7 +472,15 @@ public:
|
||||
/// this call, the current object no longer stores the error variables, and neither does
|
||||
/// Python.
|
||||
void discard_as_unraisable(object err_context) {
|
||||
#if PY_VERSION_HEX >= 0x03080000
|
||||
restore();
|
||||
#else
|
||||
auto exc_type_loc = m_type;
|
||||
auto exc_value_loc = m_value;
|
||||
auto exc_trace_loc = m_trace;
|
||||
PyErr_NormalizeException(&exc_type_loc.ptr(), &exc_value_loc.ptr(), &exc_trace_loc.ptr());
|
||||
PyErr_Restore(exc_type_loc.ptr(), exc_value_loc.ptr(), exc_trace_loc.ptr());
|
||||
#endif
|
||||
PyErr_WriteUnraisable(err_context.ptr());
|
||||
}
|
||||
/// An alternate version of `discard_as_unraisable()`, where a string provides information on
|
||||
|
Loading…
Reference in New Issue
Block a user