summaryrefslogtreecommitdiffstats
path: root/Lib
diff options
context:
space:
mode:
authorMartin v. Loewis <martin@v.loewis.de>2012-04-24 17:13:57 (GMT)
committerMartin v. Loewis <martin@v.loewis.de>2012-04-24 17:13:57 (GMT)
commit4f2f3b6217a56680d425f4011502ba2f83cfd5af (patch)
treea2f0eb470417ed63fe79139333db65b4009cd5fe /Lib
parentf0c10f084022073c76d12ff66525e1b52d7188b7 (diff)
downloadcpython-4f2f3b6217a56680d425f4011502ba2f83cfd5af.zip
cpython-4f2f3b6217a56680d425f4011502ba2f83cfd5af.tar.gz
cpython-4f2f3b6217a56680d425f4011502ba2f83cfd5af.tar.bz2
Account for shared keys in type's __sizeof__ (#13903).
Diffstat (limited to 'Lib')
-rw-r--r--Lib/test/test_sys.py12
1 files changed, 9 insertions, 3 deletions
diff --git a/Lib/test/test_sys.py b/Lib/test/test_sys.py
index 65bfdda..0f93610 100644
--- a/Lib/test/test_sys.py
+++ b/Lib/test/test_sys.py
@@ -829,13 +829,19 @@ class SizeofTest(unittest.TestCase):
check((), size(vh))
check((1,2,3), size(vh) + 3*self.P)
# type
- # (PyTypeObject + PyNumberMethods + PyMappingMethods +
- # PySequenceMethods + PyBufferProcs)
- s = size(vh + 'P2P15Pl4PP9PP11PIP') + size('16Pi17P 3P 10P 2P 3P')
+ # static type: PyTypeObject
+ s = size(vh + 'P2P15Pl4PP9PP11PI')
check(int, s)
+ # (PyTypeObject + PyNumberMethods + PyMappingMethods +
+ # 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