summaryrefslogtreecommitdiffstats
path: root/Objects/object.c
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>2001-08-16 08:17:26 (GMT)
committerGuido van Rossum <guido@python.org>2001-08-16 08:17:26 (GMT)
commitba21a49f9d55edf699d40b9a6a5a5499a4b233b4 (patch)
treedefe36d9e397cf0398d1303f835679053b3c2c02 /Objects/object.c
parent82fc51c19c90ea7a9aab0aac8db278a84cefe2b1 (diff)
downloadcpython-ba21a49f9d55edf699d40b9a6a5a5499a4b233b4.zip
cpython-ba21a49f9d55edf699d40b9a6a5a5499a4b233b4.tar.gz
cpython-ba21a49f9d55edf699d40b9a6a5a5499a4b233b4.tar.bz2
Add a function _Py_ReadyTypes() which initializes various and sundry
types -- currently Type, List, None and NotImplemented. To be called from Py_Initialize() instead of accumulating calls there. Also rename type(None) to NoneType and type(NotImplemented) to NotImplementedType -- naming the type identical to the object was confusing.
Diffstat (limited to 'Objects/object.c')
-rw-r--r--Objects/object.c25
1 files changed, 21 insertions, 4 deletions
diff --git a/Objects/object.c b/Objects/object.c
index e602159..fea9ee5 100644
--- a/Objects/object.c
+++ b/Objects/object.c
@@ -1373,6 +1373,7 @@ PyCallable_Check(PyObject *x)
NoObject is usable as a non-NULL undefined value, used by the macro None.
There is (and should be!) no way to create other objects of this type,
so there is exactly one (which is indestructible, by the way).
+(XXX This type and the type of NotImplemented below should be unified.)
*/
/* ARGSUSED */
@@ -1393,10 +1394,10 @@ none_dealloc(PyObject* ignore)
}
-static PyTypeObject PyNothing_Type = {
+static PyTypeObject PyNone_Type = {
PyObject_HEAD_INIT(&PyType_Type)
0,
- "None",
+ "NoneType",
0,
0,
(destructor)none_dealloc, /*tp_dealloc*/ /*never called*/
@@ -1412,7 +1413,7 @@ static PyTypeObject PyNothing_Type = {
};
PyObject _Py_NoneStruct = {
- PyObject_HEAD_INIT(&PyNothing_Type)
+ PyObject_HEAD_INIT(&PyNone_Type)
};
/* NotImplemented is an object that can be used to signal that an
@@ -1427,7 +1428,7 @@ NotImplemented_repr(PyObject *op)
static PyTypeObject PyNotImplemented_Type = {
PyObject_HEAD_INIT(&PyType_Type)
0,
- "NotImplemented",
+ "NotImplementedType",
0,
0,
(destructor)none_dealloc, /*tp_dealloc*/ /*never called*/
@@ -1446,6 +1447,22 @@ PyObject _Py_NotImplementedStruct = {
PyObject_HEAD_INIT(&PyNotImplemented_Type)
};
+void
+_Py_ReadyTypes(void)
+{
+ if (PyType_Ready(&PyType_Type) < 0)
+ Py_FatalError("Can't initialize 'type'");
+
+ if (PyType_Ready(&PyList_Type) < 0)
+ Py_FatalError("Can't initialize 'list'");
+
+ if (PyType_Ready(&PyNone_Type) < 0)
+ Py_FatalError("Can't initialize type(None)");
+
+ if (PyType_Ready(&PyNotImplemented_Type) < 0)
+ Py_FatalError("Can't initialize type(NotImplemented)");
+}
+
#ifdef Py_TRACE_REFS