]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
bpo-39689: Do not test undefined casts to _Bool (GH-18964)
authorStefan Krah <skrah@bytereef.org>
Thu, 12 Mar 2020 18:35:38 +0000 (19:35 +0100)
committerGitHub <noreply@github.com>
Thu, 12 Mar 2020 18:35:38 +0000 (19:35 +0100)
- When casting to _Bool, arrays should only contain zeros or ones.

Lib/test/test_buffer.py

index 2ddca06b8b568a1e2e3ac2d666dd2b7550c8d3e0..d440bcf7e0faa1faf7b00e9763d6a9f02d06a239 100644 (file)
@@ -2754,6 +2754,10 @@ class TestBufferProtocol(unittest.TestCase):
         # be 1D, at least one format must be 'c', 'b' or 'B'.
         for _tshape in gencastshapes():
             for char in fmtdict['@']:
+                # Casts to _Bool are undefined if the source contains values
+                # other than 0 or 1.
+                if char == "?":
+                    continue
                 tfmt = ('', '@')[randrange(2)] + char
                 tsize = struct.calcsize(tfmt)
                 n = prod(_tshape) * tsize