gh-90501: Add PyErr_GetHandledException and PyErr_SetHandledException#30531
gh-90501: Add PyErr_GetHandledException and PyErr_SetHandledException#30531iritkatriel merged 21 commits intopython:mainfrom
Conversation
a562251 to
e76ac6a
Compare
3fce147 to
20fa421
Compare
Co-authored-by: Victor Stinner <[email protected]>
Co-authored-by: Kumar Aditya <[email protected]>
Co-authored-by: Kumar Aditya <[email protected]>
|
Cython defines |
Is it clear (judging by name only) which exception is the "active" one? Raised/in-flight or caught? :) |
vstinner
left a comment
There was a problem hiding this comment.
Since this function is an unusal use case, maybe give it an even more explicit name? PyErr_GetCaughtException()?
|
Would it be possible to use the same wording in the documentation of functions added by this PR, in PyErr_GetExcInfo() and in sys.exception() documentation? My remark is about "the exception instance that is currently being handled" in sys.exception() doc: Maybe add also a link from PyErr_GetExcInfo() to PyErr_GetActiveException() in the doc. |
Co-authored-by: Victor Stinner <[email protected]>
How about GetHandledException()? (I'm not sure Caught accurately describes the timeframe in which an exception is "active"). |
sys.exception is in python space, where you don't have access to any other exception so I think the c-level wording might just add confusion. I agree though that the current wording is not great, in particular I'm not sure we need to talk about the frame stack. How about I reword the sys.exception() doc like this:
Sure. |
…leak in test_set_exception. Use METH_O in test_set_exception
|
I made all the changes suggested in reviews so far (thanks!) except the name change. I propose SetHandledException/GetHandledException. Does this sound good? |
IMO , that's easier to understand. +1 |
|
@vstinner @encukou @markshannon Any last thoughts on this? Should we include this in 3.11? @pablogsal FYI. |
1 similar comment
|
@vstinner @encukou @markshannon Any last thoughts on this? Should we include this in 3.11? @pablogsal FYI. |
I'm fine including this into 3.11, but please merge it at least one week before the beta to allow to test it a bit. |
Now that exc_info was replace by just the exception, we can have simpler versions of the get/set c-api functions.
https://bugs.python.org/issue46343