diff Lib/test/test_sys.py @ 76530:b044e0568be2

Account for shared keys in type's __sizeof__ (#13903).
author Martin v. Loewis <martin@v.loewis.de>
date Tue, 24 Apr 2012 19:13:57 +0200
parents 6e5855854a2e
children eb5c5c23ca9b
line wrap: on
line diff
--- a/Lib/test/test_sys.py	Tue Apr 24 18:39:53 2012 +0200
+++ b/Lib/test/test_sys.py	Tue Apr 24 19:13:57 2012 +0200
@@ -829,13 +829,19 @@
         check((), size(vh))
         check((1,2,3), size(vh) + 3*self.P)
         # type
+        # static type: PyTypeObject
+        s = size(vh + 'P2P15Pl4PP9PP11PI')
+        check(int, s)
         # (PyTypeObject + PyNumberMethods + PyMappingMethods +
-        #  PySequenceMethods + PyBufferProcs)
-        s = size(vh + 'P2P15Pl4PP9PP11PIP') + size('16Pi17P 3P 10P 2P 3P')
-        check(int, s)
+        #  PySequenceMethods + PyBufferProcs + 4P)
+        s = size(vh + 'P2P15Pl4PP9PP11PI') + size('34P 3P 10P 2P 4P')
+        # Separate block for PyDictKeysObject with 4 entries
+        s += size("PPPP") + 4*size("PPP")
         # class
         class newstyleclass(object): pass
         check(newstyleclass, s)
+        # dict with shared keys
+        check(newstyleclass().__dict__, size(h+"PPP4P"))
         # unicode
         # each tuple contains a string and its expected character size
         # don't put any static strings here, as they may contain