mirror of
https://github.com/python/cpython.git
synced 2025-09-14 20:56:06 +00:00
Added additional __sizeof__ implementations and addressed comments made in
Issue3122.
This commit is contained in:
parent
cc3f2b1d16
commit
9be2ec109b
6 changed files with 105 additions and 35 deletions
|
@ -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__,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue