]> granicus.if.org Git - python/commitdiff
Issue #25421: __sizeof__ methods of builtin types now use dynamic basic size.
authorSerhiy Storchaka <storchaka@gmail.com>
Sat, 19 Dec 2015 18:07:11 +0000 (20:07 +0200)
committerSerhiy Storchaka <storchaka@gmail.com>
Sat, 19 Dec 2015 18:07:11 +0000 (20:07 +0200)
This allows sys.getsize() to work correctly with their subclasses with
__slots__ defined.

1  2 
Misc/NEWS
Modules/_collectionsmodule.c
Modules/_elementtree.c
Modules/_pickle.c
Modules/itertoolsmodule.c
Objects/bytearrayobject.c
Objects/dictobject.c
Objects/setobject.c

diff --cc Misc/NEWS
index 92572fa1ce3bc6ab3c61ffc737b429fad6bdaee2,299ed3c9fcc2b54b6878c35d19d8b5a2aa9abe51..465c1bdbc704e2be57c67d60d92e6cebdd9dc58c
+++ 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__.
  
index 0e594703d074f6a6af9508164e50cb586e98253b,4fffe01a84d84f90fb1bad5f3ad6fcf7316f14df..e3d1910b9f8d7a532ba6184ceca00651031c1490
@@@ -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);
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge