Skip to content

Commit 7c23d37

Browse files
committed
Accept the 32-bit allocation-overflow rejection in the frame-count test
On 32-bit builds a footer frame count of 0xFFFFFFFF overflows the allocation size, so the size_t overflow guard raises OverflowError before the count-vs-file-size guard raises ValueError. Accept either rejection.
1 parent 572947c commit 7c23d37

1 file changed

Lines changed: 11 additions & 6 deletions

File tree

Lib/test/test_profiling/test_sampling_profiler/test_binary_format.py

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1090,14 +1090,19 @@ def test_open_rejects_frame_count_larger_than_file(self):
10901090
max_frames = (size - frame_off) // self.MIN_FRAME_ENTRY_SIZE
10911091
self._patch_footer_count(filename, self.FTR_OFF_FRAMES, 0xFFFFFFFF)
10921092

1093-
with self.assertRaises(ValueError) as cm:
1093+
# 0xFFFFFFFF frames exceed the file on every platform. On a 32-bit
1094+
# build it also overflows the allocation size, so the size_t overflow
1095+
# guard (OverflowError) fires before the count-vs-file-size guard
1096+
# (ValueError); either rejection is correct.
1097+
with self.assertRaises((ValueError, OverflowError)) as cm:
10941098
with BinaryReader(filename):
10951099
pass
1096-
self.assertEqual(
1097-
str(cm.exception),
1098-
f"Invalid frame count 4294967295 exceeds maximum "
1099-
f"possible {max_frames}",
1100-
)
1100+
if isinstance(cm.exception, ValueError):
1101+
self.assertEqual(
1102+
str(cm.exception),
1103+
f"Invalid frame count 4294967295 exceeds maximum "
1104+
f"possible {max_frames}",
1105+
)
11011106

11021107
def test_open_accepts_frame_count_at_capacity_boundary(self):
11031108
"""A frame count at the file-size cap opens; one more is rejected."""

0 commit comments

Comments
 (0)