Skip to content

Commit aec3759

Browse files
committed
Fix PyMarshal_WriteLongToFile() for 32-bit long (Windows)
1 parent a4945b5 commit aec3759

1 file changed

Lines changed: 10 additions & 6 deletions

File tree

Lib/test/test_capi/test_marshal.py

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -91,13 +91,17 @@ def mask32(value):
9191
return res
9292

9393
limit = 2 ** 31
94+
values = [
95+
_testcapi.LONG_MIN, _testcapi.LONG_MAX,
96+
-limit, -limit + 2, limit - 2, limit - 1,
97+
0, 123, -123,
98+
]
99+
# Test values larger than 32-bit on platforms with 64-bit C long
100+
if _testcapi.LONG_MAX > (2**31-1):
101+
values.extend((-limit - 2, limit, limit + 2))
102+
94103
for version in range(marshal.version + 1):
95-
for value in (
96-
_testcapi.LONG_MIN, _testcapi.LONG_MAX,
97-
-limit - 2, -limit, -limit + 2,
98-
limit - 2, limit, limit + 2,
99-
0, 123, -123,
100-
):
104+
for value in values:
101105
with self.subTest(value=value, version=version):
102106
write_long_to_file(value, filename, version)
103107
data = read_file(filename)

0 commit comments

Comments
 (0)