Skip to content

Commit

Permalink
bpo-39689: Do not test undefined casts to _Bool (GH-18964)
Browse files Browse the repository at this point in the history
- When casting to _Bool, arrays should only contain zeros or ones.
  • Loading branch information
Stefan Krah authored Mar 12, 2020
1 parent fdcd53f commit 1ae9cde
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions Lib/test/test_buffer.py
Original file line number Diff line number Diff line change
Expand Up @@ -2754,6 +2754,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
Expand Down

0 comments on commit 1ae9cde

Please sign in to comment.