mirror of
https://github.com/python/cpython.git
synced 2025-08-04 08:59:19 +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
|
@ -26,7 +26,7 @@ const char * const PyStructSequence_UnnamedField = "unnamed field";
|
|||
static Py_ssize_t
|
||||
get_type_attr_as_size(PyTypeObject *tp, PyObject *name)
|
||||
{
|
||||
PyObject *v = PyDict_GetItemWithError(tp->tp_dict, name);
|
||||
PyObject *v = PyDict_GetItemWithError(_PyType_GetDict(tp), name);
|
||||
if (v == NULL && !PyErr_Occurred()) {
|
||||
PyErr_Format(PyExc_TypeError,
|
||||
"Missed attribute '%U' of type %s",
|
||||
|
@ -493,7 +493,7 @@ initialize_static_type(PyTypeObject *type, PyStructSequence_Desc *desc,
|
|||
Py_INCREF(type);
|
||||
|
||||
if (initialize_structseq_dict(
|
||||
desc, type->tp_dict, n_members, n_unnamed_members) < 0) {
|
||||
desc, _PyType_GetDict(type), n_members, n_unnamed_members) < 0) {
|
||||
Py_DECREF(type);
|
||||
return -1;
|
||||
}
|
||||
|
@ -549,7 +549,7 @@ _PyStructSequence_InitBuiltinWithFlags(PyInterpreterState *interp,
|
|||
}
|
||||
|
||||
if (initialize_structseq_dict(
|
||||
desc, type->tp_dict, n_members, n_unnamed_members) < 0) {
|
||||
desc, _PyType_GetDict(type), n_members, n_unnamed_members) < 0) {
|
||||
goto error;
|
||||
}
|
||||
|
||||
|
@ -675,7 +675,7 @@ _PyStructSequence_NewType(PyStructSequence_Desc *desc, unsigned long tp_flags)
|
|||
}
|
||||
|
||||
if (initialize_structseq_dict(
|
||||
desc, type->tp_dict, n_members, n_unnamed_members) < 0) {
|
||||
desc, _PyType_GetDict(type), n_members, n_unnamed_members) < 0) {
|
||||
Py_DECREF(type);
|
||||
return NULL;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue