[Python-checkins] bpo-39689: Do not test undefined casts to _Bool (GH-18964) (#18965)

Miss Islington (bot) webhook-mailer at python.org
Thu Mar 12 14:55:41 EDT 2020


https://github.com/python/cpython/commit/636eecbbbbc16229432ec8e26e6da287c52f3ca3
commit: 636eecbbbbc16229432ec8e26e6da287c52f3ca3
branch: 3.7
author: Miss Islington (bot) <31488909+miss-islington at users.noreply.github.com>
committer: GitHub <noreply at github.com>
date: 2020-03-12T19:55:36+01:00
summary:

bpo-39689: Do not test undefined casts to _Bool (GH-18964) (#18965)

- When casting to _Bool, arrays should only contain zeros or ones.
(cherry picked from commit 1ae9cde4b2323235b5f9ff4bc76e4175a2257172)

Co-authored-by: Stefan Krah <skrah at bytereef.org>

files:
M Lib/test/test_buffer.py

diff --git a/Lib/test/test_buffer.py b/Lib/test/test_buffer.py
index 08727d87d4b36..2ae5ffaf61be7 100644
--- a/Lib/test/test_buffer.py
+++ b/Lib/test/test_buffer.py
@@ -2730,6 +2730,10 @@ def test_memoryview_cast_1D_ND(self):
         # 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



More information about the Python-checkins mailing list