]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-146238: Add missing tests for 'e', 'Zf' and 'Zd' array type codes in test_buffer...
authorSergey B Kirpichev <skirpichev@gmail.com>
Wed, 6 May 2026 13:14:49 +0000 (16:14 +0300)
committerGitHub <noreply@github.com>
Wed, 6 May 2026 13:14:49 +0000 (15:14 +0200)
This amends e79fd60.  I'll not fix this for 'F'/'D' complex types as
they might be removed.

Lib/test/test_buffer.py

index f08faa14b24c646a37ddfa1863a4aa4418f2a431..7454c8a15391e90d9dfc069adb4698b5c105225e 100644 (file)
@@ -143,7 +143,7 @@ MEMORYVIEW = NATIVE.copy()
 # Format codes supported by array.array
 ARRAY = NATIVE.copy()
 for k in NATIVE:
-    if not k in "bBhHiIlLfd":
+    if k not in list("bBhHiIlLefd") + ['Zf', 'Zd']:
         del ARRAY[k]
 
 BYTEFMT = NATIVE.copy()
@@ -4495,8 +4495,10 @@ class TestBufferProtocol(unittest.TestCase):
     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]
+        formats = [fmt for fmt in ARRAY
+                   if struct.calcsize(fmt) <= struct.calcsize('P')]
+        align = max(struct.calcsize(fmt) for fmt in formats)
+        cases = [array.array(fmt) for fmt in formats]
         # Empty arrays
         self.assertEqual(
             [_testcapi.buffer_pointer_as_int(case) % align for case in cases],