-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Unladen error_already_set
#3964
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
Conversation
@rwgk what() is called quite a bit in big projects like PyTorch. I strongly oppose removing the what() method. |
Currently the price we are paying for pytorch is included in our global testing. I'll learn the hard way how bad it is :-) But first thing, I have to get the CI green here. |
I need to correct myself: computing the Still trying to get everything green. It's too early to make a judgement. |
This is the behavior that one might expect based on the name
|
…ists already on master (see PR pybind#3965).
e13f29a
to
6010f5b
Compare
…verlooked before).
… failed: ` to not trigger a failure in test_embed/test_interpreter.cpp. Patch the test itself to not expect a chained error.
…&)` and add `PyErr_Clear()`
The last commit (0a4d0c0) is what I used for exploratory global testing. Based on that, a quick estimate of what it would take to adapt to this change Google-internally:
Very rough estimation: some of the 100 will probably not need to be touched, but a few changes may be needed elsewhere. Net files that need changes will be around 100, i.e. about 5% of pybind11 user code. |
I'll close this PR for now. For future reference, the CI @ 0a4d0c0 was all green: All checks have passed This commit also passed testing with ASAN, MSAN, TSAN using the Google-internal toolchain. |
* Add missing error handling to module_::def_submodule * Add test_def_submodule_failures * PyPy only: Skip test with trigger for PyModule_GetName() failure. * Reapply minor fix that accidentally got lost in transfer from PR #3964
Description
Adopts the Boost.Python approach for
error_already_set
.Motivations (see PR #1895):
error_already_set
copy constructor: it is very unlikely to trigger Python reference count corruption, but that is a possibility in the general case.what()
, which is very rarely actually used.This is a breaking change.
Based on the changes to the unit tests, I believe most required adjustments in user code are backward compatible:
PyErr_Clear();
are no-ops with released pybind11 versions.It seems to be very rare that
what()
is called.#ifdef
s (in user code) will be needed to replace those calls in a backward-compatible way.More work is needed to be sure that there are no bigger obstacles.
See also:
Suggested changelog entry: