Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 528b7eb

Browse files
committed
- Rename PyType_InitDict() to PyType_Ready().
- Add an explicit call to PyType_Ready(&PyList_Type) to pythonrun.c (just for the heck of it, really -- we should either explicitly ready all types, or none).
1 parent c5943b1 commit 528b7eb

5 files changed

Lines changed: 16 additions & 13 deletions

File tree

Include/object.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -297,7 +297,7 @@ extern DL_IMPORT(PyTypeObject) PyBaseObject_Type; /* Most base object type */
297297

298298
#define PyType_Check(op) PyObject_TypeCheck(op, &PyType_Type)
299299

300-
extern DL_IMPORT(int) PyType_InitDict(PyTypeObject *);
300+
extern DL_IMPORT(int) PyType_Ready(PyTypeObject *);
301301
extern DL_IMPORT(PyObject *) PyType_GenericAlloc(PyTypeObject *, int);
302302
extern DL_IMPORT(PyObject *) PyType_GenericNew(PyTypeObject *,
303303
PyObject *, PyObject *);

Modules/xxsubtype.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -212,9 +212,9 @@ initxxsubtype(void)
212212
if (m == NULL)
213213
return;
214214

215-
if (PyType_InitDict(&spamlist_type) < 0)
215+
if (PyType_Ready(&spamlist_type) < 0)
216216
return;
217-
if (PyType_InitDict(&spamdict_type) < 0)
217+
if (PyType_Ready(&spamdict_type) < 0)
218218
return;
219219

220220
d = PyModule_GetDict(m);

Objects/object.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1160,7 +1160,7 @@ PyObject_GenericGetAttr(PyObject *obj, PyObject *name)
11601160
PyObject **dictptr;
11611161

11621162
if (tp->tp_dict == NULL) {
1163-
if (PyType_InitDict(tp) < 0)
1163+
if (PyType_Ready(tp) < 0)
11641164
return NULL;
11651165
}
11661166

@@ -1207,7 +1207,7 @@ PyObject_GenericSetAttr(PyObject *obj, PyObject *name, PyObject *value)
12071207
PyObject **dictptr;
12081208

12091209
if (tp->tp_dict == NULL) {
1210-
if (PyType_InitDict(tp) < 0)
1210+
if (PyType_Ready(tp) < 0)
12111211
return -1;
12121212
}
12131213

Objects/typeobject.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -387,7 +387,7 @@ best_base(PyObject *bases)
387387
return NULL;
388388
}
389389
if (base_i->tp_dict == NULL) {
390-
if (PyType_InitDict(base_i) < 0)
390+
if (PyType_Ready(base_i) < 0)
391391
return NULL;
392392
}
393393
candidate = solid_base(base_i);
@@ -656,7 +656,7 @@ type_new(PyTypeObject *metatype, PyObject *args, PyObject *kwds)
656656
type->tp_free = _PyObject_Del;
657657

658658
/* Initialize the rest */
659-
if (PyType_InitDict(type) < 0) {
659+
if (PyType_Ready(type) < 0) {
660660
Py_DECREF(type);
661661
return NULL;
662662
}
@@ -719,7 +719,7 @@ type_getattro(PyTypeObject *type, PyObject *name)
719719

720720
/* Initialize this type (we'll assume the metatype is initialized) */
721721
if (type->tp_dict == NULL) {
722-
if (PyType_InitDict(type) < 0)
722+
if (PyType_Ready(type) < 0)
723723
return NULL;
724724
}
725725

@@ -1157,7 +1157,7 @@ inherit_slots(PyTypeObject *type, PyTypeObject *base)
11571157
}
11581158

11591159
int
1160-
PyType_InitDict(PyTypeObject *type)
1160+
PyType_Ready(PyTypeObject *type)
11611161
{
11621162
PyObject *dict, *bases, *x;
11631163
PyTypeObject *base;
@@ -1185,7 +1185,7 @@ PyType_InitDict(PyTypeObject *type)
11851185

11861186
/* Initialize the base class */
11871187
if (base && base->tp_dict == NULL) {
1188-
if (PyType_InitDict(base) < 0)
1188+
if (PyType_Ready(base) < 0)
11891189
return -1;
11901190
}
11911191

@@ -1892,7 +1892,7 @@ add_tp_new_wrapper(PyTypeObject *type)
18921892
return PyDict_SetItemString(type->tp_defined, "__new__", func);
18931893
}
18941894

1895-
/* This function is called by PyType_InitDict() to populate the type's
1895+
/* This function is called by PyType_Ready() to populate the type's
18961896
dictionary with method descriptors for function slots. For each
18971897
function slot (like tp_repr) that's defined in the type, one or
18981898
more corresponding descriptors are added in the type's tp_defined
@@ -2335,7 +2335,7 @@ slot_tp_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
23352335
}
23362336

23372337
/* This is called at the very end of type_new() (even after
2338-
PyType_InitDict()) to complete the initialization of dynamic types.
2338+
PyType_Ready()) to complete the initialization of dynamic types.
23392339
The dict argument is the dictionary argument passed to type_new(),
23402340
which is the local namespace of the class statement, in other
23412341
words, it contains the methods. For each special method (like

Python/pythonrun.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,9 +115,12 @@ Py_Initialize(void)
115115
Py_FatalError("Py_Initialize: can't make first thread");
116116
(void) PyThreadState_Swap(tstate);
117117

118-
if (PyType_InitDict(&PyType_Type) < 0)
118+
if (PyType_Ready(&PyType_Type) < 0)
119119
Py_FatalError("Py_Initialize: can't initialize 'type'");
120120

121+
if (PyType_Ready(&PyList_Type) < 0)
122+
Py_FatalError("Py_Initialize: can't initialize 'list'");
123+
121124
interp->modules = PyDict_New();
122125
if (interp->modules == NULL)
123126
Py_FatalError("Py_Initialize: can't make modules dictionary");

0 commit comments

Comments
 (0)