Mercurial > cpython-lru_cache-weakref
diff Python/sysmodule.c @ 47918:68c7964d2534 legacy-trunk
Fixed Issue3122 and extended sys.getsizeof tests for built-in types.
| author | Robert Schuppenies <okkotonushi@googlemail.com> |
|---|---|
| date | Thu, 10 Jul 2008 13:43:26 +0000 |
| parents | 0738119c1ef8 |
| children | fd054e73e2f2 |
line wrap: on
line diff
--- a/Python/sysmodule.c Thu Jul 10 10:28:41 2008 +0000 +++ b/Python/sysmodule.c Thu Jul 10 13:43:26 2008 +0000 @@ -651,8 +651,15 @@ return NULL; } - /* Type objects */ - if (PyType_Check(args)){ + /* Make sure the type is initialized. float gets initialized late */ + if (PyType_Ready(Py_TYPE(args)) < 0) + return NULL; + + /* Instance of old-style class */ + if (PyInstance_Check(args)) + return PyInt_FromSsize_t(PyInstance_Type.tp_basicsize); + /* all other objects */ + else { PyObject *method = _PyType_Lookup(Py_TYPE(args), str__sizeof__); if (method == NULL) { @@ -662,15 +669,7 @@ return NULL; } return PyObject_CallFunctionObjArgs(method, args, NULL); - } - /* Instance of old-style classes */ - else if (PyInstance_Check(args)) - return PyInt_FromSsize_t(PyInstance_Type.tp_basicsize); - /* Old-style classes */ - else if (PyClass_Check(args)) - return PyInt_FromSsize_t(PyClass_Type.tp_basicsize); - else - return PyObject_CallMethod(args, "__sizeof__", NULL); + } } PyDoc_STRVAR(getsizeof_doc,
