diff options
author | Benjamin Peterson <benjamin@python.org> | 2009-05-09 18:15:04 (GMT) |
---|---|---|
committer | Benjamin Peterson <benjamin@python.org> | 2009-05-09 18:15:04 (GMT) |
commit | a5758c012001b1044d4a109b736c0406cdf8c9ec (patch) | |
tree | 562f1c9b048ce5812de50b67cee59707d5625fbb /Python/sysmodule.c | |
parent | 8bc5b681599b66887f69ca54631d6e1ce4894252 (diff) | |
download | cpython-a5758c012001b1044d4a109b736c0406cdf8c9ec.zip cpython-a5758c012001b1044d4a109b736c0406cdf8c9ec.tar.gz cpython-a5758c012001b1044d4a109b736c0406cdf8c9ec.tar.bz2 |
Merged revisions 72508 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r72508 | benjamin.peterson | 2009-05-09 11:36:39 -0500 (Sat, 09 May 2009) | 1 line
convert some more special methods to use _PyObject_LookupSpecial
........
Diffstat (limited to 'Python/sysmodule.c')
-rw-r--r-- | Python/sysmodule.c | 20 |
1 files changed, 8 insertions, 12 deletions
diff --git a/Python/sysmodule.c b/Python/sysmodule.c index 262f5a1..b9d5dba 100644 --- a/Python/sysmodule.c +++ b/Python/sysmodule.c @@ -630,7 +630,7 @@ static PyObject * sys_getsizeof(PyObject *self, PyObject *args, PyObject *kwds) { PyObject *res = NULL; - static PyObject *str__sizeof__, *gc_head_size = NULL; + static PyObject *str__sizeof__ = NULL, *gc_head_size = NULL; static char *kwlist[] = {"object", "default", 0}; PyObject *o, *dflt = NULL; PyObject *method; @@ -639,13 +639,6 @@ sys_getsizeof(PyObject *self, PyObject *args, PyObject *kwds) kwlist, &o, &dflt)) return NULL; - /* Initialize static variable needed by _PyType_Lookup */ - if (str__sizeof__ == NULL) { - str__sizeof__ = PyUnicode_InternFromString("__sizeof__"); - if (str__sizeof__ == NULL) - return NULL; - } - /* Initialize static variable for GC head size */ if (gc_head_size == NULL) { gc_head_size = PyLong_FromSsize_t(sizeof(PyGC_Head)); @@ -656,14 +649,17 @@ sys_getsizeof(PyObject *self, PyObject *args, PyObject *kwds) /* Make sure the type is initialized. float gets initialized late */ if (PyType_Ready(Py_TYPE(o)) < 0) return NULL; - - method = _PyType_Lookup(Py_TYPE(o), str__sizeof__); + + method = _PyObject_LookupSpecial(o, "__sizeof__", + &str__sizeof__); if (method == NULL) PyErr_Format(PyExc_TypeError, "Type %.100s doesn't define __sizeof__", Py_TYPE(o)->tp_name); - else - res = PyObject_CallFunctionObjArgs(method, o, NULL); + else { + res = PyObject_CallFunctionObjArgs(method, NULL); + Py_DECREF(method); + } /* Has a default value been given */ if ((res == NULL) && (dflt != NULL) && |