Kaydet (Commit) 528b7eb0 authored tarafından Guido van Rossum's avatar Guido van Rossum

- 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).
üst c5943b1c
...@@ -297,7 +297,7 @@ extern DL_IMPORT(PyTypeObject) PyBaseObject_Type; /* Most base object type */ ...@@ -297,7 +297,7 @@ extern DL_IMPORT(PyTypeObject) PyBaseObject_Type; /* Most base object type */
#define PyType_Check(op) PyObject_TypeCheck(op, &PyType_Type) #define PyType_Check(op) PyObject_TypeCheck(op, &PyType_Type)
extern DL_IMPORT(int) PyType_InitDict(PyTypeObject *); extern DL_IMPORT(int) PyType_Ready(PyTypeObject *);
extern DL_IMPORT(PyObject *) PyType_GenericAlloc(PyTypeObject *, int); extern DL_IMPORT(PyObject *) PyType_GenericAlloc(PyTypeObject *, int);
extern DL_IMPORT(PyObject *) PyType_GenericNew(PyTypeObject *, extern DL_IMPORT(PyObject *) PyType_GenericNew(PyTypeObject *,
PyObject *, PyObject *); PyObject *, PyObject *);
......
...@@ -212,9 +212,9 @@ initxxsubtype(void) ...@@ -212,9 +212,9 @@ initxxsubtype(void)
if (m == NULL) if (m == NULL)
return; return;
if (PyType_InitDict(&spamlist_type) < 0) if (PyType_Ready(&spamlist_type) < 0)
return; return;
if (PyType_InitDict(&spamdict_type) < 0) if (PyType_Ready(&spamdict_type) < 0)
return; return;
d = PyModule_GetDict(m); d = PyModule_GetDict(m);
......
...@@ -1160,7 +1160,7 @@ PyObject_GenericGetAttr(PyObject *obj, PyObject *name) ...@@ -1160,7 +1160,7 @@ PyObject_GenericGetAttr(PyObject *obj, PyObject *name)
PyObject **dictptr; PyObject **dictptr;
if (tp->tp_dict == NULL) { if (tp->tp_dict == NULL) {
if (PyType_InitDict(tp) < 0) if (PyType_Ready(tp) < 0)
return NULL; return NULL;
} }
...@@ -1207,7 +1207,7 @@ PyObject_GenericSetAttr(PyObject *obj, PyObject *name, PyObject *value) ...@@ -1207,7 +1207,7 @@ PyObject_GenericSetAttr(PyObject *obj, PyObject *name, PyObject *value)
PyObject **dictptr; PyObject **dictptr;
if (tp->tp_dict == NULL) { if (tp->tp_dict == NULL) {
if (PyType_InitDict(tp) < 0) if (PyType_Ready(tp) < 0)
return -1; return -1;
} }
......
...@@ -387,7 +387,7 @@ best_base(PyObject *bases) ...@@ -387,7 +387,7 @@ best_base(PyObject *bases)
return NULL; return NULL;
} }
if (base_i->tp_dict == NULL) { if (base_i->tp_dict == NULL) {
if (PyType_InitDict(base_i) < 0) if (PyType_Ready(base_i) < 0)
return NULL; return NULL;
} }
candidate = solid_base(base_i); candidate = solid_base(base_i);
...@@ -656,7 +656,7 @@ type_new(PyTypeObject *metatype, PyObject *args, PyObject *kwds) ...@@ -656,7 +656,7 @@ type_new(PyTypeObject *metatype, PyObject *args, PyObject *kwds)
type->tp_free = _PyObject_Del; type->tp_free = _PyObject_Del;
/* Initialize the rest */ /* Initialize the rest */
if (PyType_InitDict(type) < 0) { if (PyType_Ready(type) < 0) {
Py_DECREF(type); Py_DECREF(type);
return NULL; return NULL;
} }
...@@ -719,7 +719,7 @@ type_getattro(PyTypeObject *type, PyObject *name) ...@@ -719,7 +719,7 @@ type_getattro(PyTypeObject *type, PyObject *name)
/* Initialize this type (we'll assume the metatype is initialized) */ /* Initialize this type (we'll assume the metatype is initialized) */
if (type->tp_dict == NULL) { if (type->tp_dict == NULL) {
if (PyType_InitDict(type) < 0) if (PyType_Ready(type) < 0)
return NULL; return NULL;
} }
...@@ -1157,7 +1157,7 @@ inherit_slots(PyTypeObject *type, PyTypeObject *base) ...@@ -1157,7 +1157,7 @@ inherit_slots(PyTypeObject *type, PyTypeObject *base)
} }
int int
PyType_InitDict(PyTypeObject *type) PyType_Ready(PyTypeObject *type)
{ {
PyObject *dict, *bases, *x; PyObject *dict, *bases, *x;
PyTypeObject *base; PyTypeObject *base;
...@@ -1185,7 +1185,7 @@ PyType_InitDict(PyTypeObject *type) ...@@ -1185,7 +1185,7 @@ PyType_InitDict(PyTypeObject *type)
/* Initialize the base class */ /* Initialize the base class */
if (base && base->tp_dict == NULL) { if (base && base->tp_dict == NULL) {
if (PyType_InitDict(base) < 0) if (PyType_Ready(base) < 0)
return -1; return -1;
} }
...@@ -1892,7 +1892,7 @@ add_tp_new_wrapper(PyTypeObject *type) ...@@ -1892,7 +1892,7 @@ add_tp_new_wrapper(PyTypeObject *type)
return PyDict_SetItemString(type->tp_defined, "__new__", func); return PyDict_SetItemString(type->tp_defined, "__new__", func);
} }
/* This function is called by PyType_InitDict() to populate the type's /* This function is called by PyType_Ready() to populate the type's
dictionary with method descriptors for function slots. For each dictionary with method descriptors for function slots. For each
function slot (like tp_repr) that's defined in the type, one or function slot (like tp_repr) that's defined in the type, one or
more corresponding descriptors are added in the type's tp_defined more corresponding descriptors are added in the type's tp_defined
...@@ -2335,7 +2335,7 @@ slot_tp_new(PyTypeObject *type, PyObject *args, PyObject *kwds) ...@@ -2335,7 +2335,7 @@ slot_tp_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
} }
/* This is called at the very end of type_new() (even after /* This is called at the very end of type_new() (even after
PyType_InitDict()) to complete the initialization of dynamic types. PyType_Ready()) to complete the initialization of dynamic types.
The dict argument is the dictionary argument passed to type_new(), The dict argument is the dictionary argument passed to type_new(),
which is the local namespace of the class statement, in other which is the local namespace of the class statement, in other
words, it contains the methods. For each special method (like words, it contains the methods. For each special method (like
......
...@@ -115,9 +115,12 @@ Py_Initialize(void) ...@@ -115,9 +115,12 @@ Py_Initialize(void)
Py_FatalError("Py_Initialize: can't make first thread"); Py_FatalError("Py_Initialize: can't make first thread");
(void) PyThreadState_Swap(tstate); (void) PyThreadState_Swap(tstate);
if (PyType_InitDict(&PyType_Type) < 0) if (PyType_Ready(&PyType_Type) < 0)
Py_FatalError("Py_Initialize: can't initialize 'type'"); Py_FatalError("Py_Initialize: can't initialize 'type'");
if (PyType_Ready(&PyList_Type) < 0)
Py_FatalError("Py_Initialize: can't initialize 'list'");
interp->modules = PyDict_New(); interp->modules = PyDict_New();
if (interp->modules == NULL) if (interp->modules == NULL)
Py_FatalError("Py_Initialize: can't make modules dictionary"); Py_FatalError("Py_Initialize: can't make modules dictionary");
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment