summaryrefslogtreecommitdiffstats
path: root/Objects/codeobject.c
diff options
context:
space:
mode:
Diffstat (limited to 'Objects/codeobject.c')
-rw-r--r--Objects/codeobject.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/Objects/codeobject.c b/Objects/codeobject.c
index 810f847..7d02b03 100644
--- a/Objects/codeobject.c
+++ b/Objects/codeobject.c
@@ -416,10 +416,16 @@ init_code(PyCodeObject *co, struct _PyCodeConstructor *con)
co->co_ncellvars = ncellvars;
co->co_nfreevars = nfreevars;
PyInterpreterState *interp = _PyInterpreterState_GET();
+#ifdef Py_GIL_DISABLED
+ PyMutex_Lock(&interp->func_state.mutex);
+#endif
co->co_version = interp->func_state.next_version;
if (interp->func_state.next_version != 0) {
interp->func_state.next_version++;
}
+#ifdef Py_GIL_DISABLED
+ PyMutex_Unlock(&interp->func_state.mutex);
+#endif
co->_co_monitoring = NULL;
co->_co_instrumentation_version = 0;
/* not set */