@@ -1445,7 +1445,7 @@ lookup_method(PyObject *self, _Py_Identifier *attrid, int *unbound)
14451445
14461446
14471447static inline PyObject *
1448- vectorcall_unbound (int unbound , PyObject * func ,
1448+ vectorcall_unbound (PyThreadState * tstate , int unbound , PyObject * func ,
14491449 PyObject * const * args , Py_ssize_t nargs )
14501450{
14511451 size_t nargsf = nargs ;
@@ -1455,7 +1455,7 @@ vectorcall_unbound(int unbound, PyObject *func,
14551455 args ++ ;
14561456 nargsf = nargsf - 1 + PY_VECTORCALL_ARGUMENTS_OFFSET ;
14571457 }
1458- return _PyObject_Vectorcall ( func , args , nargsf , NULL );
1458+ return _PyObject_VectorcallTstate ( tstate , func , args , nargsf , NULL );
14591459}
14601460
14611461static PyObject *
@@ -1479,24 +1479,27 @@ vectorcall_method(_Py_Identifier *name,
14791479 PyObject * const * args , Py_ssize_t nargs )
14801480{
14811481 assert (nargs >= 1 );
1482+
1483+ PyThreadState * tstate = _PyThreadState_GET ();
14821484 int unbound ;
14831485 PyObject * self = args [0 ];
14841486 PyObject * func = lookup_method (self , name , & unbound );
14851487 if (func == NULL ) {
14861488 return NULL ;
14871489 }
1488- PyObject * retval = vectorcall_unbound (unbound , func , args , nargs );
1490+ PyObject * retval = vectorcall_unbound (tstate , unbound , func , args , nargs );
14891491 Py_DECREF (func );
14901492 return retval ;
14911493}
14921494
14931495/* Clone of vectorcall_method() that returns NotImplemented
14941496 * when the lookup fails. */
14951497static PyObject *
1496- vectorcall_maybe (_Py_Identifier * name ,
1498+ vectorcall_maybe (PyThreadState * tstate , _Py_Identifier * name ,
14971499 PyObject * const * args , Py_ssize_t nargs )
14981500{
14991501 assert (nargs >= 1 );
1502+
15001503 int unbound ;
15011504 PyObject * self = args [0 ];
15021505 PyObject * func = lookup_maybe_method (self , name , & unbound );
@@ -1505,7 +1508,7 @@ vectorcall_maybe(_Py_Identifier *name,
15051508 Py_RETURN_NOTIMPLEMENTED ;
15061509 return NULL ;
15071510 }
1508- PyObject * retval = vectorcall_unbound (unbound , func , args , nargs );
1511+ PyObject * retval = vectorcall_unbound (tstate , unbound , func , args , nargs );
15091512 Py_DECREF (func );
15101513 return retval ;
15111514}
@@ -6177,6 +6180,7 @@ static PyObject * \
61776180FUNCNAME(PyObject *self, PyObject *other) \
61786181{ \
61796182 PyObject* stack[2]; \
6183+ PyThreadState *tstate = _PyThreadState_GET(); \
61806184 _Py_static_string(op_id, OPSTR); \
61816185 _Py_static_string(rop_id, ROPSTR); \
61826186 int do_other = Py_TYPE(self) != Py_TYPE(other) && \
@@ -6193,7 +6197,7 @@ FUNCNAME(PyObject *self, PyObject *other) \
61936197 if (ok) { \
61946198 stack[0] = other; \
61956199 stack[1] = self; \
6196- r = vectorcall_maybe(&rop_id, stack, 2); \
6200+ r = vectorcall_maybe(tstate, &rop_id, stack, 2); \
61976201 if (r != Py_NotImplemented) \
61986202 return r; \
61996203 Py_DECREF(r); \
@@ -6202,7 +6206,7 @@ FUNCNAME(PyObject *self, PyObject *other) \
62026206 } \
62036207 stack[0] = self; \
62046208 stack[1] = other; \
6205- r = vectorcall_maybe(&op_id, stack, 2); \
6209+ r = vectorcall_maybe(tstate, &op_id, stack, 2); \
62066210 if (r != Py_NotImplemented || \
62076211 Py_TYPE(other) == Py_TYPE(self)) \
62086212 return r; \
@@ -6211,7 +6215,7 @@ FUNCNAME(PyObject *self, PyObject *other) \
62116215 if (do_other) { \
62126216 stack[0] = other; \
62136217 stack[1] = self; \
6214- return vectorcall_maybe(&rop_id, stack, 2); \
6218+ return vectorcall_maybe(tstate, &rop_id, stack, 2); \
62156219 } \
62166220 Py_RETURN_NOTIMPLEMENTED; \
62176221}
@@ -6293,6 +6297,7 @@ slot_sq_ass_item(PyObject *self, Py_ssize_t index, PyObject *value)
62936297static int
62946298slot_sq_contains (PyObject * self , PyObject * value )
62956299{
6300+ PyThreadState * tstate = _PyThreadState_GET ();
62966301 PyObject * func , * res ;
62976302 int result = -1 , unbound ;
62986303 _Py_IDENTIFIER (__contains__ );
@@ -6307,7 +6312,7 @@ slot_sq_contains(PyObject *self, PyObject *value)
63076312 }
63086313 if (func != NULL ) {
63096314 PyObject * args [2 ] = {self , value };
6310- res = vectorcall_unbound (unbound , func , args , 2 );
6315+ res = vectorcall_unbound (tstate , unbound , func , args , 2 );
63116316 Py_DECREF (func );
63126317 if (res != NULL ) {
63136318 result = PyObject_IsTrue (res );
@@ -6682,6 +6687,7 @@ static _Py_Identifier name_op[] = {
66826687static PyObject *
66836688slot_tp_richcompare (PyObject * self , PyObject * other , int op )
66846689{
6690+ PyThreadState * tstate = _PyThreadState_GET ();
66856691 int unbound ;
66866692 PyObject * func , * res ;
66876693
@@ -6692,7 +6698,7 @@ slot_tp_richcompare(PyObject *self, PyObject *other, int op)
66926698 }
66936699
66946700 PyObject * stack [2 ] = {self , other };
6695- res = vectorcall_unbound (unbound , func , stack , 2 );
6701+ res = vectorcall_unbound (tstate , unbound , func , stack , 2 );
66966702 Py_DECREF (func );
66976703 return res ;
66986704}
0 commit comments