Skip to content

Commit

Permalink
bpo-42979: Use _Py_CheckSlotResult() to check slots result (GH-24356)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
vstinner authored Jan 29, 2021
1 parent d6c33fb commit a619263
Show file tree
Hide file tree
Showing 4 changed files with 304 additions and 198 deletions.
Original file line number Diff line number Diff line change
@@ -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.
Loading

0 comments on commit a619263

Please sign in to comment.