Skip to content

Commit 52c7d2b

Browse files
committed
restrict to heap types
1 parent b9fb155 commit 52c7d2b

1 file changed

Lines changed: 4 additions & 0 deletions

File tree

Python/sysmodule.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2661,6 +2661,10 @@ sys__clear_type_descriptors(PyObject *module, PyObject *type)
26612661
return NULL;
26622662
}
26632663
PyTypeObject *typeobj = (PyTypeObject *)(type);
2664+
if (!_PyType_HasFeature(typeobj, Py_TPFLAGS_HEAPTYPE)) {
2665+
PyErr_SetString(PyExc_TypeError, "argument must be a heap type");
2666+
return NULL;
2667+
}
26642668
PyObject *dict = _PyType_GetDict(typeobj);
26652669
if (PyDict_PopString(dict, "__dict__", NULL) < 0) {
26662670
return NULL;

0 commit comments

Comments
 (0)