Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 7 additions & 5 deletions Lib/test/test_buffer.py
Original file line number Diff line number Diff line change
Expand Up @@ -4465,9 +4465,9 @@ def test_bytearray_alignment(self):
@support.cpython_only
@unittest.skipIf(_testcapi is None, "requires _testcapi")
def test_array_alignment(self):
# gh-140557: pointer alignment of buffers including empty allocation
# should match the maximum array alignment.
align = max(struct.calcsize(fmt) for fmt in ARRAY)
# gh-140557: pointer alignment of empty buffers should be at least
# to `size_t`.
align = struct.calcsize("N")
cases = [array.array(fmt) for fmt in ARRAY]
# Empty arrays
self.assertEqual(
Expand All @@ -4476,9 +4476,11 @@ def test_array_alignment(self):
)
for case in cases:
case.append(0)
# Allocated arrays
# Allocated arrays. The minimum alignment is now governed by regular
# allocator rules; aligned for any type that fits in the allocation.
self.assertEqual(
[_testcapi.buffer_pointer_as_int(case) % align for case in cases],
[_testcapi.buffer_pointer_as_int(case) % case.itemsize
for case in cases],
[0] * len(cases),
)

Expand Down
Loading