From 3faad1a7958a7ef1139ba7760379906254844526 Mon Sep 17 00:00:00 2001 From: Stefan Krah Date: Thu, 12 Mar 2020 19:08:06 +0100 Subject: [PATCH] bpo-39689: Do not test undefined casts to _Bool. - When casting to _Bool, arrays should only contain zeros or ones. --- Lib/test/test_buffer.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Lib/test/test_buffer.py b/Lib/test/test_buffer.py index 2ddca06b8b568a..d440bcf7e0faa1 100644 --- a/Lib/test/test_buffer.py +++ b/Lib/test/test_buffer.py @@ -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