[Python-checkins] bpo-44525: Add recursive checks for `CALL_FUNCTION_BUILTIN_O` (GH-29271)
markshannon
webhook-mailer at python.org
Thu Oct 28 11:02:57 EDT 2021
https://github.com/python/cpython/commit/0a1a36b74bdf8da286924a1c9652853b1c46f536
commit: 0a1a36b74bdf8da286924a1c9652853b1c46f536
branch: main
author: Ken Jin <28750310+Fidget-Spinner at users.noreply.github.com>
committer: markshannon <mark at hotpy.org>
date: 2021-10-28T16:02:34+01:00
summary:
bpo-44525: Add recursive checks for `CALL_FUNCTION_BUILTIN_O` (GH-29271)
files:
M Python/ceval.c
diff --git a/Python/ceval.c b/Python/ceval.c
index 4ac0b53dd6e46..d52ca9c65db22 100644
--- a/Python/ceval.c
+++ b/Python/ceval.c
@@ -4742,8 +4742,14 @@ _PyEval_EvalFrameDefault(PyThreadState *tstate, InterpreterFrame *frame, int thr
STAT_INC(CALL_FUNCTION, hit);
PyCFunction cfunc = PyCFunction_GET_FUNCTION(callable);
+ // This is slower but CPython promises to check all non-vectorcall
+ // function calls.
+ if (_Py_EnterRecursiveCall(tstate, " while calling a Python object")) {
+ goto error;
+ }
PyObject *arg = POP();
PyObject *res = cfunc(PyCFunction_GET_SELF(callable), arg);
+ _Py_LeaveRecursiveCall(tstate);
assert((res != NULL) ^ (_PyErr_Occurred(tstate) != NULL));
/* Clear the stack of the function object. */
More information about the Python-checkins
mailing list