Added additional __sizeof__ implementations and addressed comments made in

Issue3122.
This commit is contained in:
Robert Schuppenies 2008-07-10 15:24:04 +00:00
parent cc3f2b1d16
commit 9be2ec109b
6 changed files with 105 additions and 35 deletions

View file

@ -7898,20 +7898,8 @@ PyDoc_STRVAR(p_format__doc__,
static PyObject *
unicode__sizeof__(PyUnicodeObject *v)
{
PyObject *res = NULL, *defsize = NULL;
res = PyInt_FromSsize_t(sizeof(PyUnicodeObject) +
sizeof(Py_UNICODE) * (v->length + 1));
if (v->defenc) {
defsize = PyObject_CallMethod(v->defenc, "__sizeof__", NULL);
if (defsize == NULL) {
Py_DECREF(res);
return NULL;
}
res = PyNumber_Add(res, defsize);
Py_DECREF(defsize);
}
return res;
return PyInt_FromSsize_t(sizeof(PyUnicodeObject) +
sizeof(Py_UNICODE) * (v->length + 1));
}
PyDoc_STRVAR(sizeof__doc__,