bpo-29587: _PyErr_ChainExceptions() checks exception (GH-19902)

_PyErr_ChainExceptions() now ensures that the first parameter is an
exception type, as done by _PyErr_SetObject().

* The following function now check PyExceptionInstance_Check() in an
  assertion using a new _PyBaseExceptionObject_cast() helper
  function:

  * PyException_GetTraceback(), PyException_SetTraceback()
  * PyException_GetCause(), PyException_SetCause()
  * PyException_GetContext(), PyException_SetContext()

* PyExceptionClass_Name() now checks PyExceptionClass_Check() with an
  assertion.

* Remove XXX comment and add gi_exc_state variable to _gen_throw().

* Remove comment from test_generators
This commit is contained in:
Victor Stinner 2020-05-05 17:07:41 +02:00 committed by GitHub
parent 4e30ed3af0
commit b0be6b3b94
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 45 additions and 24 deletions

View file

@ -342,9 +342,6 @@ class GeneratorThrowTest(unittest.TestCase):
try:
yield
except Exception:
# Without the `gi_exc_state.exc_type != Py_None` in
# _gen_throw(), this line was causing a crash ("Segmentation
# fault (core dumped)") on e.g. Fedora 32.
raise RuntimeError
gen = g()