mirror of
https://github.com/python/cpython.git
synced 2025-12-08 06:10:17 +00:00
gh-134786: raise error if Py_TPFLAGS_MANAGED_WEAKREF or Py_TPFLAGS_MANAGED_DICT is used without Py_TPFLAGS_HAVE_GC set (#135863)
This commit is contained in:
parent
d12cbf2865
commit
da65f38a94
8 changed files with 72 additions and 2 deletions
|
|
@ -8898,6 +8898,13 @@ type_ready_preheader(PyTypeObject *type)
|
|||
type->tp_name);
|
||||
return -1;
|
||||
}
|
||||
if (!(type->tp_flags & Py_TPFLAGS_HAVE_GC)) {
|
||||
PyErr_Format(PyExc_SystemError,
|
||||
"type %s has the Py_TPFLAGS_MANAGED_DICT flag "
|
||||
"but not Py_TPFLAGS_HAVE_GC flag",
|
||||
type->tp_name);
|
||||
return -1;
|
||||
}
|
||||
type->tp_dictoffset = -1;
|
||||
}
|
||||
if (type->tp_flags & Py_TPFLAGS_MANAGED_WEAKREF) {
|
||||
|
|
@ -8910,6 +8917,13 @@ type_ready_preheader(PyTypeObject *type)
|
|||
type->tp_name);
|
||||
return -1;
|
||||
}
|
||||
if (!(type->tp_flags & Py_TPFLAGS_HAVE_GC)) {
|
||||
PyErr_Format(PyExc_SystemError,
|
||||
"type %s has the Py_TPFLAGS_MANAGED_WEAKREF flag "
|
||||
"but not Py_TPFLAGS_HAVE_GC flag",
|
||||
type->tp_name);
|
||||
return -1;
|
||||
}
|
||||
type->tp_weaklistoffset = MANAGED_WEAKREF_OFFSET;
|
||||
}
|
||||
return 0;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue