@@ -620,21 +620,9 @@ def check_equal(view, is_equal):
620620 m = memoryview (a .tobytes ()).cast ('n' )
621621 check_equal (m , True )
622622
623- # Test '?' format (keep all the checks below for UBSan)
623+ # Test '?' format
624624 m = memoryview (b'\0 \1 \2 ' ).cast ('?' )
625625 check_equal (m , True )
626- # m1a and m1b are equivalent to [False, True, False]
627- m1a = memoryview (b'\0 \2 \0 ' ).cast ('?' )
628- self .assertEqual (m1a .tolist (), [False , True , False ])
629- m1b = memoryview (b'\0 \4 \0 ' ).cast ('?' )
630- self .assertEqual (m1b .tolist (), [False , True , False ])
631- self .assertEqual (m1a , m1b )
632- # m1a and m1b are equivalent to [True, True, True]
633- m2a = memoryview (b'\1 \3 \5 ' ).cast ('?' )
634- self .assertEqual (m2a .tolist (), [True , True , True ])
635- m2b = memoryview (b'\2 \4 \6 ' ).cast ('?' )
636- self .assertEqual (m2b .tolist (), [True , True , True ])
637- self .assertEqual (m2a , m2b )
638626
639627 # Test float formats
640628 for float_format in 'fd' :
@@ -660,6 +648,24 @@ def check_equal(view, is_equal):
660648 m = memoryview (data ).cast (complex_format )
661649 check_equal (m , True )
662650
651+ def test_boolean_format (self ):
652+ # Test '?' format (keep all the checks below for UBSan)
653+ # See github.com/python/cpython/issues/148390.
654+
655+ # m1a and m1b are equivalent to [False, True, False]
656+ m1a = memoryview (b'\0 \2 \0 ' ).cast ('?' )
657+ self .assertEqual (m1a .tolist (), [False , True , False ])
658+ m1b = memoryview (b'\0 \4 \0 ' ).cast ('?' )
659+ self .assertEqual (m1b .tolist (), [False , True , False ])
660+ self .assertEqual (m1a , m1b )
661+
662+ # m2a and m2b are equivalent to [True, True, True]
663+ m2a = memoryview (b'\1 \3 \5 ' ).cast ('?' )
664+ self .assertEqual (m2a .tolist (), [True , True , True ])
665+ m2b = memoryview (b'\2 \4 \6 ' ).cast ('?' )
666+ self .assertEqual (m2b .tolist (), [True , True , True ])
667+ self .assertEqual (m2a , m2b )
668+
663669
664670class BytesMemorySliceTest (unittest .TestCase ,
665671 BaseMemorySliceTests , BaseBytesMemoryTests ):
0 commit comments