diff options
author | Ezio Melotti <ezio.melotti@gmail.com> | 2015-09-06 21:44:45 +0300 |
---|---|---|
committer | Ezio Melotti <ezio.melotti@gmail.com> | 2015-09-06 21:44:45 +0300 |
commit | f352202977fc53197bd38198b1ac26ed4008a9ba (patch) | |
tree | 34246df426e6f7d82794886be98c613903a5655e /Objects/object.c | |
parent | d68070857ae58758849446f5ae162ff3bffb7d6e (diff) | |
parent | 2936930f6c8fc1d8992b680181c30f417d74b7c2 (diff) | |
download | cpython-f352202977fc53197bd38198b1ac26ed4008a9ba.tar.gz |
#23144: merge with 3.4.
Diffstat (limited to 'Objects/object.c')
-rw-r--r-- | Objects/object.c | 52 |
1 files changed, 43 insertions, 9 deletions
diff --git a/Objects/object.c b/Objects/object.c index a1a69fa123..11b7bff43a 100644 --- a/Objects/object.c +++ b/Objects/object.c @@ -33,6 +33,22 @@ _Py_GetRefTotal(void) total -= o->ob_refcnt; return total; } + +void +_PyDebug_PrintTotalRefs(void) { + PyObject *xoptions, *value; + _Py_IDENTIFIER(showrefcount); + + xoptions = PySys_GetXOptions(); + if (xoptions == NULL) + return; + value = _PyDict_GetItemId(xoptions, &PyId_showrefcount); + if (value == Py_True) + fprintf(stderr, + "[%" PY_FORMAT_SIZE_T "d refs, " + "%" PY_FORMAT_SIZE_T "d blocks]\n", + _Py_GetRefTotal(), _Py_GetAllocatedBlocks()); +} #endif /* Py_REF_DEBUG */ /* Object allocation routines used by NEWOBJ and NEWVAROBJ macros. @@ -1543,6 +1559,9 @@ PyObject _Py_NotImplementedStruct = { void _Py_ReadyTypes(void) { + if (PyType_Ready(&PyBaseObject_Type) < 0) + Py_FatalError("Can't initialize object type"); + if (PyType_Ready(&PyType_Type) < 0) Py_FatalError("Can't initialize type type"); @@ -1555,6 +1574,9 @@ _Py_ReadyTypes(void) if (PyType_Ready(&_PyWeakref_ProxyType) < 0) Py_FatalError("Can't initialize weakref proxy type"); + if (PyType_Ready(&PyLong_Type) < 0) + Py_FatalError("Can't initialize int type"); + if (PyType_Ready(&PyBool_Type) < 0) Py_FatalError("Can't initialize bool type"); @@ -1579,15 +1601,27 @@ _Py_ReadyTypes(void) if (PyType_Ready(&PySuper_Type) < 0) Py_FatalError("Can't initialize super type"); - if (PyType_Ready(&PyBaseObject_Type) < 0) - Py_FatalError("Can't initialize object type"); - if (PyType_Ready(&PyRange_Type) < 0) Py_FatalError("Can't initialize range type"); if (PyType_Ready(&PyDict_Type) < 0) Py_FatalError("Can't initialize dict type"); + if (PyType_Ready(&PyODict_Type) < 0) + Py_FatalError("Can't initialize OrderedDict type"); + + if (PyType_Ready(&PyODictKeys_Type) < 0) + Py_FatalError("Can't initialize odict_keys type"); + + if (PyType_Ready(&PyODictItems_Type) < 0) + Py_FatalError("Can't initialize odict_items type"); + + if (PyType_Ready(&PyODictValues_Type) < 0) + Py_FatalError("Can't initialize odict_values type"); + + if (PyType_Ready(&PyODictIter_Type) < 0) + Py_FatalError("Can't initialize odict_keyiterator type"); + if (PyType_Ready(&PySet_Type) < 0) Py_FatalError("Can't initialize set type"); @@ -1606,9 +1640,6 @@ _Py_ReadyTypes(void) if (PyType_Ready(&PyFloat_Type) < 0) Py_FatalError("Can't initialize float type"); - if (PyType_Ready(&PyLong_Type) < 0) - Py_FatalError("Can't initialize int type"); - if (PyType_Ready(&PyFrozenSet_Type) < 0) Py_FatalError("Can't initialize frozenset type"); @@ -1695,6 +1726,12 @@ _Py_ReadyTypes(void) if (PyType_Ready(&PySeqIter_Type) < 0) Py_FatalError("Can't initialize sequence iterator type"); + + if (PyType_Ready(&PyCoro_Type) < 0) + Py_FatalError("Can't initialize coroutine type"); + + if (PyType_Ready(&_PyCoroWrapper_Type) < 0) + Py_FatalError("Can't initialize coroutine wrapper type"); } @@ -1809,9 +1846,6 @@ _Py_GetObjects(PyObject *self, PyObject *args) #endif -/* Hack to force loading of pycapsule.o */ -PyTypeObject *_PyCapsule_hack = &PyCapsule_Type; - /* Hack to force loading of abstract.o */ Py_ssize_t (*_Py_abstract_hack)(PyObject *) = PyObject_Size; |