-
-
Notifications
You must be signed in to change notification settings - Fork 34.7k
Suspected PyErr_Fetch() behavior change #102594
Copy link
Copy link
Closed
Labels
3.12only security fixesonly security fixesinterpreter-core(Objects, Python, Grammar, and Parser dirs)(Objects, Python, Grammar, and Parser dirs)type-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error
Metadata
Metadata
Assignees
Labels
3.12only security fixesonly security fixesinterpreter-core(Objects, Python, Grammar, and Parser dirs)(Objects, Python, Grammar, and Parser dirs)type-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error
Fields
Give feedbackNo fields configured for issues without a type.
Bug report
While testing pybind11 with Python 3.12alpha6 I ran into what looks like a
PyErr_Fetch()behavior change. I also tried with the main branch @ c6858d1.I think the issue reduces to:
PyErr_SetObject()as e.g. here: https://github.com/pybind/pybind11/blob/442261da585536521ff459b1457b2904895f23b4/tests/test_exceptions.cpp#L309Followed more-or-less immediately by a
PyErr_Fetch()as e.g. here: https://github.com/pybind/pybind11/blob/442261da585536521ff459b1457b2904895f23b4/include/pybind11/pytypes.h#L482The special twist is that the exception type involved raises a
ValueErrorin its__init__:For easy reference the same code copy-pasted here:
Up to and including 3.12alpha3:
PyErr_Fetch()produces theFlakyExceptiontype (this here).With 3.12alpha6:
PyErr_Fetch()produces theValueErrortype instead.Additional detail:
Up to and including 3.12alpha3: only
PyErr_NormalizeException()hits theValueErrorinFlakyException._init__, but notPyErr_Fetch().Your environment
Linked PRs