@@ -287,6 +287,7 @@ functions is running.
287287void
288288_PyFunction_SetVersion (PyFunctionObject * func , uint32_t version )
289289{
290+ #ifndef Py_GIL_DISABLED
290291 PyInterpreterState * interp = _PyInterpreterState_GET ();
291292 if (func -> func_version != 0 ) {
292293 struct _func_version_cache_item * slot =
@@ -297,19 +298,23 @@ _PyFunction_SetVersion(PyFunctionObject *func, uint32_t version)
297298 // Leave slot->code alone, there may be use for it.
298299 }
299300 }
301+ #endif
300302 func -> func_version = version ;
303+ #ifndef Py_GIL_DISABLED
301304 if (version != 0 ) {
302305 struct _func_version_cache_item * slot =
303306 interp -> func_state .func_version_cache
304307 + (version % FUNC_VERSION_CACHE_SIZE );
305308 slot -> func = func ;
306309 slot -> code = func -> func_code ;
307310 }
311+ #endif
308312}
309313
310314void
311315_PyFunction_ClearCodeByVersion (uint32_t version )
312316{
317+ #ifndef Py_GIL_DISABLED
313318 PyInterpreterState * interp = _PyInterpreterState_GET ();
314319 struct _func_version_cache_item * slot =
315320 interp -> func_state .func_version_cache
@@ -322,11 +327,15 @@ _PyFunction_ClearCodeByVersion(uint32_t version)
322327 slot -> func = NULL ;
323328 }
324329 }
330+ #endif
325331}
326332
327333PyFunctionObject *
328334_PyFunction_LookupByVersion (uint32_t version , PyObject * * p_code )
329335{
336+ #ifdef Py_GIL_DISABLED
337+ return NULL ;
338+ #else
330339 PyInterpreterState * interp = _PyInterpreterState_GET ();
331340 struct _func_version_cache_item * slot =
332341 interp -> func_state .func_version_cache
@@ -346,6 +355,7 @@ _PyFunction_LookupByVersion(uint32_t version, PyObject **p_code)
346355 return slot -> func ;
347356 }
348357 return NULL ;
358+ #endif
349359}
350360
351361uint32_t
0 commit comments