From: Serhiy Storchaka Date: Sat, 19 Dec 2015 18:07:11 +0000 (+0200) Subject: Issue #25421: __sizeof__ methods of builtin types now use dynamic basic size. X-Git-Tag: v3.6.0a1~883 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=a9406e77fa7bd3618c16edd248c24010af7035c1;p=thirdparty%2FPython%2Fcpython.git Issue #25421: __sizeof__ methods of builtin types now use dynamic basic size. This allows sys.getsize() to work correctly with their subclasses with __slots__ defined. --- a9406e77fa7bd3618c16edd248c24010af7035c1 diff --cc Misc/NEWS index 92572fa1ce3b,299ed3c9fcc2..465c1bdbc704 --- a/Misc/NEWS +++ b/Misc/NEWS @@@ -10,13 -10,12 +10,17 @@@ Release date: tb Core and Builtins ----------------- + - Issue #25421: __sizeof__ methods of builtin types now use dynamic basic size. + This allows sys.getsize() to work correctly with their subclasses with + __slots__ defined. + - Issue #25709: Fixed problem with in-place string concatenation and utf-8 cache. +- Issue #5319: New Py_FinalizeEx() API allowing Python to set an exit status + of 120 on failure to flush buffered streams. + +- Issue #25485: telnetlib.Telnet is now a context manager. + - Issue #24097: Fixed crash in object.__reduce__() if slot name is freed inside __getattr__. diff --cc Modules/_collectionsmodule.c index 0e594703d074,4fffe01a84d8..e3d1910b9f8d --- a/Modules/_collectionsmodule.c +++ b/Modules/_collectionsmodule.c @@@ -1476,8 -1443,8 +1476,8 @@@ deque_sizeof(dequeobject *deque, void * Py_ssize_t res; Py_ssize_t blocks; - res = sizeof(dequeobject); + res = _PyObject_SIZE(Py_TYPE(deque)); - blocks = (deque->leftindex + Py_SIZE(deque) + BLOCKLEN - 1) / BLOCKLEN; + blocks = (size_t)(deque->leftindex + Py_SIZE(deque) + BLOCKLEN - 1) / BLOCKLEN; assert(deque->leftindex + Py_SIZE(deque) - 1 == (blocks - 1) * BLOCKLEN + deque->rightindex); res += blocks * sizeof(block);