diff --git a/Lib/test/test_buffer.py b/Lib/test/test_buffer.py index 08727d87d4b367..2ae5ffaf61be77 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