diff options
author | Victor Stinner <vstinner@python.org> | 2021-01-29 16:53:03 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-01-29 16:53:03 +0100 |
commit | a6192635f1e62af2bb8a435487ebb51800edd671 (patch) | |
tree | a1c012c74a7d78b53300300c217428710da5477b /Misc | |
parent | bpo-42990: Introduce 'frame constructor' struct to simplify API for PyEval_Co... (diff) | |
download | cpython-a6192635f1e62af2bb8a435487ebb51800edd671.tar.gz cpython-a6192635f1e62af2bb8a435487ebb51800edd671.tar.bz2 cpython-a6192635f1e62af2bb8a435487ebb51800edd671.zip |
bpo-42979: Use _Py_CheckSlotResult() to check slots result (GH-24356)
When Python is built in debug mode (with C assertions), calling a
type slot like sq_length (__len__() in Python) now fails with a fatal
error if the slot succeeded with an exception set, or failed with no
exception set. The error message contains the slot, the type name,
and the current exception (if an exception is set).
* Check the result of all slots using _Py_CheckSlotResult().
* No longer pass op_name to ternary_op() in release mode.
* Replace operator with dunder Python method name in error messages.
For example, replace "*" with "__mul__".
* Fix compiler_exit_scope() when an exception is set.
* Fix bytearray.extend() when an exception is set: don't call
bytearray_setslice() with an exception set.
Diffstat (limited to 'Misc')
-rw-r--r-- | Misc/NEWS.d/next/C API/2021-01-28-01-11-59.bpo-42979.JrGkrm.rst | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/Misc/NEWS.d/next/C API/2021-01-28-01-11-59.bpo-42979.JrGkrm.rst b/Misc/NEWS.d/next/C API/2021-01-28-01-11-59.bpo-42979.JrGkrm.rst new file mode 100644 index 00000000000..15fd86bee9d --- /dev/null +++ b/Misc/NEWS.d/next/C API/2021-01-28-01-11-59.bpo-42979.JrGkrm.rst @@ -0,0 +1,5 @@ +When Python is built in debug mode (with C assertions), calling a type slot +like ``sq_length`` (``__len__()`` in Python) now fails with a fatal error if +the slot succeeded with an exception set, or failed with no exception set. The +error message contains the slot, the type name, and the current exception (if +an exception is set). Patch by Victor Stinner. |