diff --git a/Lib/test/test_buffer.py b/Lib/test/test_buffer.py index ab65a44bda6e7e..87c981b7a553d1 100644 --- a/Lib/test/test_buffer.py +++ b/Lib/test/test_buffer.py @@ -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( @@ -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), )