@@ -2328,17 +2328,22 @@ dummy_func(
23282328 PyObject * name = GETITEM (FRAME_CO_NAMES , oparg >> 1 );
23292329 if (oparg & 1 ) {
23302330 /* Designed to work in tandem with CALL, pushes two values. */
2331- _PyStackRef method = PyStackRef_NULL ;
2332- int is_meth = _PyObject_GetMethodStackRef (tstate , PyStackRef_AsPyObjectBorrow (owner ), name , & method );
2331+ _PyCStackRef method ;
2332+ _PyThreadState_PushCStackRef (tstate , & method );
2333+ int is_meth = _PyObject_GetMethodStackRef (tstate , PyStackRef_AsPyObjectBorrow (owner ), name , & method .ref );
23332334 if (is_meth ) {
23342335 /* We can bypass temporary bound method object.
23352336 meth is unbound method and obj is self.
23362337 meth | self | arg1 | ... | argN
23372338 */
2338- assert (!PyStackRef_IsNull (method )); // No errors on this branch
2339+ assert (!PyStackRef_IsNull (method . ref )); // No errors on this branch
23392340 self_or_null [0 ] = owner ; // Transfer ownership
23402341 DEAD (owner );
2341- attr = method ;
2342+ attr = method .ref ;
2343+ #ifdef Py_GIL_DISABLED
2344+ method_ref .ref = PyStackRef_NULL ;
2345+ _PyThreadState_PopCStackRef (tstate , & method_ref );
2346+ #endif
23422347 }
23432348 else {
23442349 /* meth is not an unbound method (but a regular attr, or
@@ -2347,10 +2352,14 @@ dummy_func(
23472352 CALL that it's not a method call.
23482353 meth | NULL | arg1 | ... | argN
23492354 */
2350- attr = method ;
2351- self_or_null [0 ] = PyStackRef_NULL ;
23522355 PyStackRef_CLOSE (owner );
2353- ERROR_IF (PyStackRef_IsNull (method ));
2356+ self_or_null [0 ] = PyStackRef_NULL ;
2357+ attr = method .ref ;
2358+ #ifdef Py_GIL_DISABLED
2359+ method_ref .ref = PyStackRef_NULL ;
2360+ _PyThreadState_PopCStackRef (tstate , & method_ref );
2361+ #endif
2362+ ERROR_IF (PyStackRef_IsNull (attr ));
23542363 }
23552364 }
23562365 else {
0 commit comments