Author vstinner
Recipients serhiy.storchaka, sfreilich, vstinner
Date 2019-01-11.10:38:06
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <>
I added _Py_CheckFunctionResult() to every C calls. This function calls PyErr_Occurred() after a function call. This change has been made in Python 3.5: bpo-23571. I made this change because it was very difficult to identify bugs when an exception was raised but the bug was only spotted "later". Some exceptions were ignored by mistakes.

I also added a *lot* of assertions like the following one, but only when Python is built in debug mode:

#ifdef Py_DEBUG
    /* type_call() must not be called with an exception set,
       because it may clear it (directly or indirectly) and so the
       caller loses its exception */

commit 4a7cc8847276df27c8f52987cda619ca279687c2
Author: Victor Stinner <>
Date:   Fri Mar 6 23:35:27 2015 +0100

    Issue #23571: PyObject_Call(), PyCFunction_Call() and call_function() now
    raise a SystemError if a function returns a result and raises an exception.
    The SystemError is chained to the previous exception.
    Refactor also PyObject_Call() and PyCFunction_Call() to make them more readable.
    Remove some checks which became useless (duplicate checks).
    Change reviewed by Serhiy Storchaka.

commit efde146b0c42f2643f96d00896c99a90d501fb69
Author: Victor Stinner <>
Date:   Sat Mar 21 15:04:43 2015 +0100

    Issue #23571: _Py_CheckFunctionResult() now gives the name of the function
    which returned an invalid result (result+error or no result without error) in
    the exception message.
    Add also unit test to check that the exception contains the name of the
    Special case: the final _PyEval_EvalFrameEx() check doesn't mention the
    function since it didn't execute a single function but a whole frame.
Date User Action Args
2019-01-11 10:38:08vstinnersetrecipients: + vstinner, serhiy.storchaka, sfreilich
2019-01-11 10:38:07vstinnersetmessageid: <>
2019-01-11 10:38:07vstinnerlinkissue35711 messages
2019-01-11 10:38:06vstinnercreate