]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
bpo-39689: Do not test undefined casts to _Bool (GH-18964) (#18966)
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>
Thu, 12 Mar 2020 18:56:18 +0000 (11:56 -0700)
committerGitHub <noreply@github.com>
Thu, 12 Mar 2020 18:56:18 +0000 (19:56 +0100)
- When casting to _Bool, arrays should only contain zeros or ones.
(cherry picked from commit 1ae9cde4b2323235b5f9ff4bc76e4175a2257172)

Co-authored-by: Stefan Krah <skrah@bytereef.org>
Lib/test/test_buffer.py

index dd84faf371e7d6680619578f8c70cda25320b804..dcea2063215040445a80549ef89675553c559ff6 100644 (file)
@@ -2751,6 +2751,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