[Python-checkins] CVS: python/dist/src/Objects object.c,2.137,2.138
Guido van Rossum
gvanrossum@users.sourceforge.net
2001年8月16日 01:17:28 -0700
Update of /cvsroot/python/python/dist/src/Objects
In directory usw-pr-cvs1:/tmp/cvs-serv32685
Modified Files:
object.c
Log Message:
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.
Index: object.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Objects/object.c,v
retrieving revision 2.137
retrieving revision 2.138
diff -C2 -d -r2.137 -r2.138
*** object.c 2001年08月16日 08:02:45 2.137
--- object.c 2001年08月16日 08:17:26 2.138
***************
*** 1374,1377 ****
--- 1374,1378 ----
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.)
*/
***************
*** 1394,1401 ****
! static PyTypeObject PyNothing_Type = {
PyObject_HEAD_INIT(&PyType_Type)
0,
! "None",
0,
0,
--- 1395,1402 ----
! static PyTypeObject PyNone_Type = {
PyObject_HEAD_INIT(&PyType_Type)
0,
! "NoneType",
0,
0,
***************
*** 1413,1417 ****
PyObject _Py_NoneStruct = {
! PyObject_HEAD_INIT(&PyNothing_Type)
};
--- 1414,1418 ----
PyObject _Py_NoneStruct = {
! PyObject_HEAD_INIT(&PyNone_Type)
};
***************
*** 1428,1432 ****
PyObject_HEAD_INIT(&PyType_Type)
0,
! "NotImplemented",
0,
0,
--- 1429,1433 ----
PyObject_HEAD_INIT(&PyType_Type)
0,
! "NotImplementedType",
0,
0,
***************
*** 1446,1449 ****
--- 1447,1466 ----
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)");
+ }