This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author vstinner
Recipients serhiy.storchaka, vstinner
Date 2015-03-03.11:58:41
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1425383921.42.0.283584513916.issue23571@psf.upfronthosting.co.za>
In-reply-to
Content
Attached patch changes PyObject_Call() and PyCFunction_Call() to raise a SystemError and destroy the result (Py_DECREF) if a function returns a result with an exception set.

I also refactored PyCFunction_Call() and added "assert(!PyErr_Occurred());" at the beginning of PyCFunction_Call().

I removed duplicate checks in ceval.c.

--

I didn't check the impact on performances.

If the patch has a significant overhead: _Py_CheckFunctionResult() may be marked to be inlined, and PyCFunction_Call() and PyObject_Call() checks may be marked as unlikely using GCC __builtin_expect(), something like:

#ifdef __GNUC__
#  define Py_likely(x)       __builtin_expect((x),1)
#  define Py_unlikely(x)     __builtin_expect((x),0)
#else
#  define Py_likely(x)       x
#  define Py_unlikely(x)     x
#endif

Be careful of __builtin_expect(), misused it can make the code slower! (benchmark, benchmark, benchmark!)
History
Date User Action Args
2015-03-03 11:58:41vstinnersetrecipients: + vstinner, serhiy.storchaka
2015-03-03 11:58:41vstinnersetmessageid: <1425383921.42.0.283584513916.issue23571@psf.upfronthosting.co.za>
2015-03-03 11:58:41vstinnerlinkissue23571 messages
2015-03-03 11:58:41vstinnercreate