mirror of
https://github.com/python/cpython.git
synced 2025-11-02 03:01:58 +00:00
gh-94673: Hide Objects in PyTypeObject Behind Accessors (gh-104074)
This makes it much cleaner to move more PyTypeObject fields to PyInterpreterState.
This commit is contained in:
parent
fdd878650d
commit
f73abf8e03
6 changed files with 352 additions and 244 deletions
|
|
@ -452,7 +452,8 @@ _abc__abc_init(PyObject *module, PyObject *self)
|
|||
* their special status w.r.t. pattern matching. */
|
||||
if (PyType_Check(self)) {
|
||||
PyTypeObject *cls = (PyTypeObject *)self;
|
||||
PyObject *flags = PyDict_GetItemWithError(cls->tp_dict,
|
||||
PyObject *dict = _PyType_GetDict(cls);
|
||||
PyObject *flags = PyDict_GetItemWithError(dict,
|
||||
&_Py_ID(__abc_tpflags__));
|
||||
if (flags == NULL) {
|
||||
if (PyErr_Occurred()) {
|
||||
|
|
@ -471,7 +472,7 @@ _abc__abc_init(PyObject *module, PyObject *self)
|
|||
}
|
||||
((PyTypeObject *)self)->tp_flags |= (val & COLLECTION_FLAGS);
|
||||
}
|
||||
if (PyDict_DelItem(cls->tp_dict, &_Py_ID(__abc_tpflags__)) < 0) {
|
||||
if (PyDict_DelItem(dict, &_Py_ID(__abc_tpflags__)) < 0) {
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
|
@ -742,7 +743,7 @@ _abc__abc_subclasscheck_impl(PyObject *module, PyObject *self,
|
|||
Py_DECREF(ok);
|
||||
|
||||
/* 4. Check if it's a direct subclass. */
|
||||
PyObject *mro = ((PyTypeObject *)subclass)->tp_mro;
|
||||
PyObject *mro = _PyType_GetMRO((PyTypeObject *)subclass);
|
||||
assert(PyTuple_Check(mro));
|
||||
for (pos = 0; pos < PyTuple_GET_SIZE(mro); pos++) {
|
||||
PyObject *mro_item = PyTuple_GET_ITEM(mro, pos);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue