Skip to content

Commit

Permalink
bpo-39689: Do not test undefined casts to _Bool (GH-18964) (#18966)
Browse files Browse the repository at this point in the history
- When casting to _Bool, arrays should only contain zeros or ones.
(cherry picked from commit 1ae9cde)

Co-authored-by: Stefan Krah <[email protected]>
  • Loading branch information
miss-islington and Stefan Krah authored Mar 12, 2020
1 parent 35ae5d9 commit f8ce3e2
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 @@ -2751,6 +2751,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 f8ce3e2

Please sign in to comment.