Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit a1fd078

Browse files
committed
Try to fix sizeof unit tests on dict
Issue #28056 and issue #26058.
1 parent fef7e94 commit a1fd078

2 files changed

Lines changed: 5 additions & 4 deletions

File tree

Lib/test/test_ordered_dict.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -668,7 +668,8 @@ def test_sizeof_exact(self):
668668
size = support.calcobjsize
669669
check = self.check_sizeof
670670

671-
basicsize = size('n2P3PnPn2P') + 8 + calcsize('2nP2n')
671+
basicsize = size('nQ2P' + '3PnPn2P') + calcsize('2nP2n')
672+
672673
entrysize = calcsize('n2P')
673674
p = calcsize('P')
674675
nodesize = calcsize('Pn2P')

Lib/test/test_sys.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -937,9 +937,9 @@ def inner():
937937
# method-wrapper (descriptor object)
938938
check({}.__iter__, size('2P'))
939939
# dict
940-
check({}, size('n2P') + 8 + calcsize('2nP2n') + 8 + (8*2//3)*calcsize('n2P'))
940+
check({}, size('nQ2P') + calcsize('2nP2n') + 8 + (8*2//3)*calcsize('n2P'))
941941
longdict = {1:1, 2:2, 3:3, 4:4, 5:5, 6:6, 7:7, 8:8}
942-
check(longdict, size('n2P') + 8 + calcsize('2nP2n') + 16 + (16*2//3)*calcsize('n2P'))
942+
check(longdict, size('nQ2P') + calcsize('2nP2n') + 16 + (16*2//3)*calcsize('n2P'))
943943
# dictionary-keyview
944944
check({}.keys(), size('P'))
945945
# dictionary-valueview
@@ -1103,7 +1103,7 @@ def delx(self): del self.__x
11031103
class newstyleclass(object): pass
11041104
check(newstyleclass, s)
11051105
# dict with shared keys
1106-
check(newstyleclass().__dict__, size('n2P' + '2nP2n') + 8)
1106+
check(newstyleclass().__dict__, size('nQ2P' + '2nP2n'))
11071107
# unicode
11081108
# each tuple contains a string and its expected character size
11091109
# don't put any static strings here, as they may contain

0 commit comments

Comments
 (0)