-
-
Notifications
You must be signed in to change notification settings - Fork 30.7k
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
gh-102192: deprecate _PyErr_ChainExceptions #102935
Conversation
iritkatriel
commented
Mar 22, 2023
•
edited by bedevere-bot
Loading
edited by bedevere-bot
- Issue: Replace Fetch/Restore etc by the new exception APIs #102192
I'm not sure we can simply remove this from the C API, as it is unfortunately exposed via Python.h: $ echo '#include "Python.h"' | gcc -E $(./python.exe ./python-config.py --includes) - | grep _PyErr_ChainExceptions
__attribute__ ((visibility ("default"))) void _PyErr_ChainExceptions(PyObject *, PyObject *, PyObject *);
__attribute__ ((visibility ("default"))) void _PyErr_ChainExceptions1(PyObject *); cc. @encukou |
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.
The code looks fine, but it will need documenting.
@@ -98,7 +98,6 @@ PyAPI_FUNC(void) _PyErr_GetExcInfo(PyThreadState *, PyObject **, PyObject **, Py | |||
|
|||
/* Context manipulation (PEP 3134) */ | |||
|
|||
PyAPI_FUNC(void) _PyErr_ChainExceptions(PyObject *, PyObject *, PyObject *); |
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.
This is marked as an API function, so it will need to be added to the "porting to 3.12" section and any other relevant sections in the "what's new".
When you're done making the requested changes, leave the comment: |
It is prefixed with an underscore so we can, in theory, remove it. But we will need to document how to upgrade to 3.12. |
Currently it normalises the exception so just calling _PyErr_ChainExceptions1 with the second arg would be a change in semantics. |
This reverts commit de98c08.
Since it is exposed via Python.h, someone is bound to be using it, so we cannot just remove it. I'd say we mark it as deprecated using the BTW, we should consider unexposing the new API ( |
I searched on GitHub and found quite a few usages. So I agree with just deprecating it for now. Not sure it's reasonable to not expose the alternative though, given people are using it. |
Since people are using it, we should consider dropping the underscore, IMO. |
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.
LGTM.
We should consider making the new API official and documenting it, in a follow-up PR.
Doc/whatsnew/3.12.rst
Outdated
@@ -971,6 +971,10 @@ New Features | |||
This is less error prone and a bit more efficient. | |||
(Contributed by Mark Shannon in :gh:`101578`.) | |||
|
|||
* Add ``_PyErr_ChainExceptions1``, which takes an exception instance, | |||
to replace the legacy-api ``_PyErr_ChainExceptions``, which is now |
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.
Nit: api => API