Skip to content

Commit a9d6917

Browse files
fix _PyTypeCache_Invalidate wrapper
1 parent 7696234 commit a9d6917

2 files changed

Lines changed: 4 additions & 1 deletion

File tree

Modules/_testinternalcapi/typecache.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55

66
#include "parts.h"
77

8+
#include "pycore_critical_section.h"
9+
#include "pycore_pystate.h" // _PyInterpreterState_GET()
810
#include "pycore_stackref.h" // PyStackRef_AsPyObjectSteal()
911
#include "pycore_typecache.h" // _PyTypeCache_Lookup()
1012

@@ -67,7 +69,9 @@ type_cache_invalidate(PyObject *Py_UNUSED(self), PyObject *type_obj)
6769
if (require_type(type_obj) < 0) {
6870
return NULL;
6971
}
72+
Py_BEGIN_CRITICAL_SECTION_MUTEX(&_PyInterpreterState_GET()->types.mutex);
7073
_PyTypeCache_Invalidate((PyTypeObject *)type_obj);
74+
Py_END_CRITICAL_SECTION();
7175
Py_RETURN_NONE;
7276
}
7377

Objects/typeobject.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6837,7 +6837,6 @@ type_dealloc(PyObject *self)
68376837
Py_XDECREF(type->tp_bases);
68386838
Py_XDECREF(type->tp_mro);
68396839
Py_XDECREF(type->tp_cache);
6840-
_PyTypeCache_Invalidate(type);
68416840
clear_tp_subclasses(type);
68426841

68436842
/* A type's tp_doc is heap allocated, unlike the tp_doc slots

0 commit comments

Comments
 (0)