From d00c981ffb56f44e235bb076cee7517578dc3b1e Mon Sep 17 00:00:00 2001 From: Sergey B Kirpichev Date: Mon, 4 May 2026 06:09:33 +0300 Subject: [PATCH 1/5] gh-146238: add missing tests for 'e' type code in test_buffer.py This amends e79fd60. I'll not fix this for 'F'/'D' complex types as they might be removed. --- Lib/test/test_buffer.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Lib/test/test_buffer.py b/Lib/test/test_buffer.py index 5a4f031e298c2f..8138fe7ad407c3 100644 --- a/Lib/test/test_buffer.py +++ b/Lib/test/test_buffer.py @@ -143,7 +143,7 @@ def native_type_range(fmt): # Format codes supported by array.array ARRAY = NATIVE.copy() for k in NATIVE: - if not k in "bBhHiIlLfd": + if not k in "bBhHiIlLefd": del ARRAY[k] BYTEFMT = NATIVE.copy() From b4569cbe97eb4a6ecbe5f8f933b0a5d6879dc041 Mon Sep 17 00:00:00 2001 From: Sergey B Kirpichev Date: Tue, 5 May 2026 05:24:17 +0300 Subject: [PATCH 2/5] + Zf/d --- Lib/test/test_buffer.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Lib/test/test_buffer.py b/Lib/test/test_buffer.py index 06fd05d8257c24..e7404586ea1c1e 100644 --- a/Lib/test/test_buffer.py +++ b/Lib/test/test_buffer.py @@ -143,7 +143,7 @@ def native_type_range(fmt): # Format codes supported by array.array ARRAY = NATIVE.copy() for k in NATIVE: - if not k in "bBhHiIlLefd": + if not k in list("bBhHiIlLefd") + ['Zf', 'Zd']: del ARRAY[k] BYTEFMT = NATIVE.copy() From 2e1c01bc1165d6b08e1a663ba8c0c067748d76f8 Mon Sep 17 00:00:00 2001 From: Sergey B Kirpichev Date: Tue, 5 May 2026 08:42:20 +0300 Subject: [PATCH 3/5] skip Zd in test_array_alignment() --- Lib/test/test_buffer.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Lib/test/test_buffer.py b/Lib/test/test_buffer.py index e7404586ea1c1e..c6ab22c6c7b487 100644 --- a/Lib/test/test_buffer.py +++ b/Lib/test/test_buffer.py @@ -4495,8 +4495,8 @@ def test_bytearray_alignment(self): 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) - cases = [array.array(fmt) for fmt in ARRAY] + align = max(struct.calcsize(fmt) for fmt in ARRAY if fmt != 'Zd') + cases = [array.array(fmt) for fmt in ARRAY if fmt != 'Zd'] # Empty arrays self.assertEqual( [_testcapi.buffer_pointer_as_int(case) % align for case in cases], From b97670b02c0362b6f900594d3bd992314c06a1d1 Mon Sep 17 00:00:00 2001 From: Sergey B Kirpichev Date: Tue, 5 May 2026 10:27:22 +0300 Subject: [PATCH 4/5] fix test --- Lib/test/test_buffer.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/Lib/test/test_buffer.py b/Lib/test/test_buffer.py index c6ab22c6c7b487..9e91ef42f06d49 100644 --- a/Lib/test/test_buffer.py +++ b/Lib/test/test_buffer.py @@ -50,6 +50,7 @@ try: import _testcapi + import _testlimitedcapi except ImportError: _testcapi = None @@ -4495,8 +4496,11 @@ def test_bytearray_alignment(self): 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 if fmt != 'Zd') - cases = [array.array(fmt) for fmt in ARRAY if fmt != 'Zd'] + MAX_ALIGN = _testlimitedcapi.ALIGNOF_MAX_ALIGN_T + align = max(struct.calcsize(fmt) for fmt in ARRAY + if struct.calcsize(fmt) <= MAX_ALIGN) + cases = [array.array(fmt) for fmt in ARRAY + if struct.calcsize(fmt) <= MAX_ALIGN] # Empty arrays self.assertEqual( [_testcapi.buffer_pointer_as_int(case) % align for case in cases], From 71ab6d163cd8cfbc758dd76bf0234087b560f745 Mon Sep 17 00:00:00 2001 From: Sergey B Kirpichev Date: Tue, 5 May 2026 13:42:01 +0300 Subject: [PATCH 5/5] +1 --- Lib/test/test_buffer.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Lib/test/test_buffer.py b/Lib/test/test_buffer.py index 9e91ef42f06d49..d575661be22957 100644 --- a/Lib/test/test_buffer.py +++ b/Lib/test/test_buffer.py @@ -4507,7 +4507,9 @@ def test_array_alignment(self): [0] * len(cases), ) for case in cases: - case.append(0) + fmt = case.typecode + if struct.calcsize(fmt) <= MAX_ALIGN: + case.append(0) # Allocated arrays self.assertEqual( [_testcapi.buffer_pointer_as_int(case) % align for case in cases],