summaryrefslogtreecommitdiffstats
path: root/Objects/tupleobject.c
diff options
context:
space:
mode:
Diffstat (limited to 'Objects/tupleobject.c')
-rw-r--r--Objects/tupleobject.c11
1 files changed, 8 insertions, 3 deletions
diff --git a/Objects/tupleobject.c b/Objects/tupleobject.c
index 6b1ab74..a401bf9 100644
--- a/Objects/tupleobject.c
+++ b/Objects/tupleobject.c
@@ -1115,11 +1115,16 @@ static PyObject *
tupleiter_reduce(tupleiterobject *it, PyObject *Py_UNUSED(ignored))
{
_Py_IDENTIFIER(iter);
+ PyObject *iter = _PyEval_GetBuiltinId(&PyId_iter);
+
+ /* _PyEval_GetBuiltinId can invoke arbitrary code,
+ * call must be before access of iterator pointers.
+ * see issue #101765 */
+
if (it->it_seq)
- return Py_BuildValue("N(O)n", _PyEval_GetBuiltinId(&PyId_iter),
- it->it_seq, it->it_index);
+ return Py_BuildValue("N(O)n", iter, it->it_seq, it->it_index);
else
- return Py_BuildValue("N(())", _PyEval_GetBuiltinId(&PyId_iter));
+ return Py_BuildValue("N(())", iter);
}
static PyObject *