Unverified Kaydet (Commit) 39a156c5 authored tarafından Serhiy Storchaka's avatar Serhiy Storchaka Kaydeden (comit) GitHub

Fix the sizeof test for dicts with shared keys. (#4311)

By accident the size of the empty dict keys object matched the
size of values array.
üst a935654f
...@@ -1074,6 +1074,7 @@ class SizeofTest(unittest.TestCase): ...@@ -1074,6 +1074,7 @@ class SizeofTest(unittest.TestCase):
fmt += '3n2P' fmt += '3n2P'
s = vsize(fmt) s = vsize(fmt)
check(int, s) check(int, s)
# class
s = vsize(fmt + # PyTypeObject s = vsize(fmt + # PyTypeObject
'3P' # PyAsyncMethods '3P' # PyAsyncMethods
'36P' # PyNumberMethods '36P' # PyNumberMethods
...@@ -1081,13 +1082,17 @@ class SizeofTest(unittest.TestCase): ...@@ -1081,13 +1082,17 @@ class SizeofTest(unittest.TestCase):
'10P' # PySequenceMethods '10P' # PySequenceMethods
'2P' # PyBufferProcs '2P' # PyBufferProcs
'4P') '4P')
# Separate block for PyDictKeysObject with 8 keys and 5 entries
s += calcsize("2nP2n") + 8 + 5*calcsize("n2P")
# class
class newstyleclass(object): pass class newstyleclass(object): pass
check(newstyleclass, s) # Separate block for PyDictKeysObject with 8 keys and 5 entries
check(newstyleclass, s + calcsize("2nP2n0P") + 8 + 5*calcsize("n2P"))
# dict with shared keys
check(newstyleclass().__dict__, size('nQ2P') + 5*self.P)
o = newstyleclass()
o.a = o.b = o.c = o.d = o.e = o.f = o.g = o.h = 1
# Separate block for PyDictKeysObject with 16 keys and 10 entries
check(newstyleclass, s + calcsize("2nP2n0P") + 16 + 10*calcsize("n2P"))
# dict with shared keys # dict with shared keys
check(newstyleclass().__dict__, size('nQ2P' + '2nP2n')) check(newstyleclass().__dict__, size('nQ2P') + 10*self.P)
# unicode # unicode
# each tuple contains a string and its expected character size # each tuple contains a string and its expected character size
# don't put any static strings here, as they may contain # don't put any static strings here, as they may contain
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment