Message237123
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!) |
|
Date |
User |
Action |
Args |
2015-03-03 11:58:41 | vstinner | set | recipients:
+ vstinner, serhiy.storchaka |
2015-03-03 11:58:41 | vstinner | set | messageid: <1425383921.42.0.283584513916.issue23571@psf.upfronthosting.co.za> |
2015-03-03 11:58:41 | vstinner | link | issue23571 messages |
2015-03-03 11:58:41 | vstinner | create | |
|