@@ -124,7 +124,7 @@ def test_basic_re_sub(self):
124124 (chr (9 )+ chr (10 )+ chr (11 )+ chr (13 )+ chr (12 )+ chr (7 )+ chr (8 )))
125125 for c in 'cdehijklmopqsuwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ' :
126126 with self .subTest (c ):
127- with self .assertWarns ( DeprecationWarning ):
127+ with self .assertRaises ( re . error ):
128128 self .assertEqual (re .sub ('a' , '\\ ' + c , 'a' ), '\\ ' + c )
129129
130130 self .assertEqual (re .sub ('^\s*' , 'X' , 'test' ), 'Xtest' )
@@ -633,14 +633,10 @@ def test_other_escapes(self):
633633 re .purge () # for warnings
634634 for c in 'ceghijklmopqyzCEFGHIJKLMNOPQRTVXY' :
635635 with self .subTest (c ):
636- with self .assertWarns (DeprecationWarning ):
637- self .assertEqual (re .fullmatch ('\\ %c' % c , c ).group (), c )
638- self .assertIsNone (re .match ('\\ %c' % c , 'a' ))
636+ self .assertRaises (re .error , re .compile , '\\ %c' % c )
639637 for c in 'ceghijklmopqyzABCEFGHIJKLMNOPQRTVXYZ' :
640638 with self .subTest (c ):
641- with self .assertWarns (DeprecationWarning ):
642- self .assertEqual (re .fullmatch ('[\\ %c]' % c , c ).group (), c )
643- self .assertIsNone (re .match ('[\\ %c]' % c , 'a' ))
639+ self .assertRaises (re .error , re .compile , '[\\ %c]' % c )
644640
645641 def test_string_boundaries (self ):
646642 # See http://bugs.python.org/issue10713
@@ -993,10 +989,8 @@ def test_sre_byte_literals(self):
993989 self .assertTrue (re .match ((r"\x%02x" % i ).encode (), bytes ([i ])))
994990 self .assertTrue (re .match ((r"\x%02x0" % i ).encode (), bytes ([i ])+ b"0" ))
995991 self .assertTrue (re .match ((r"\x%02xz" % i ).encode (), bytes ([i ])+ b"z" ))
996- with self .assertWarns (DeprecationWarning ):
997- self .assertTrue (re .match (br"\u1234" , b'u1234' ))
998- with self .assertWarns (DeprecationWarning ):
999- self .assertTrue (re .match (br"\U00012345" , b'U00012345' ))
992+ self .assertRaises (re .error , re .compile , br"\u1234" )
993+ self .assertRaises (re .error , re .compile , br"\U00012345" )
1000994 self .assertTrue (re .match (br"\0" , b"\000 " ))
1001995 self .assertTrue (re .match (br"\08" , b"\000 8" ))
1002996 self .assertTrue (re .match (br"\01" , b"\001 " ))
@@ -1018,10 +1012,8 @@ def test_sre_byte_class_literals(self):
10181012 self .assertTrue (re .match ((r"[\x%02x]" % i ).encode (), bytes ([i ])))
10191013 self .assertTrue (re .match ((r"[\x%02x0]" % i ).encode (), bytes ([i ])))
10201014 self .assertTrue (re .match ((r"[\x%02xz]" % i ).encode (), bytes ([i ])))
1021- with self .assertWarns (DeprecationWarning ):
1022- self .assertTrue (re .match (br"[\u1234]" , b'u' ))
1023- with self .assertWarns (DeprecationWarning ):
1024- self .assertTrue (re .match (br"[\U00012345]" , b'U' ))
1015+ self .assertRaises (re .error , re .compile , br"[\u1234]" )
1016+ self .assertRaises (re .error , re .compile , br"[\U00012345]" )
10251017 self .checkPatternError (br"[\567]" ,
10261018 r'octal escape value \567 outside of '
10271019 r'range 0-0o377' , 1 )
@@ -1363,12 +1355,12 @@ def test_locale_flag(self):
13631355 if bletter :
13641356 self .assertIsNone (pat .match (bletter ))
13651357 # Incompatibilities
1366- self .assertWarns ( DeprecationWarning , re .compile , '' , re .LOCALE )
1367- self .assertWarns ( DeprecationWarning , re .compile , '(?L)' )
1368- self .assertWarns ( DeprecationWarning , re .compile , b'' , re .LOCALE | re .ASCII )
1369- self .assertWarns ( DeprecationWarning , re .compile , b'(?L)' , re .ASCII )
1370- self .assertWarns ( DeprecationWarning , re .compile , b'(?a)' , re .LOCALE )
1371- self .assertWarns ( DeprecationWarning , re .compile , b'(?aL)' )
1358+ self .assertRaises ( ValueError , re .compile , '' , re .LOCALE )
1359+ self .assertRaises ( ValueError , re .compile , '(?L)' )
1360+ self .assertRaises ( ValueError , re .compile , b'' , re .LOCALE | re .ASCII )
1361+ self .assertRaises ( ValueError , re .compile , b'(?L)' , re .ASCII )
1362+ self .assertRaises ( ValueError , re .compile , b'(?a)' , re .LOCALE )
1363+ self .assertRaises ( ValueError , re .compile , b'(?aL)' )
13721364
13731365 def test_bug_6509 (self ):
13741366 # Replacement strings of both types must parse properly.
@@ -1419,13 +1411,6 @@ def test_compile(self):
14191411 # Test behaviour when not given a string or pattern as parameter
14201412 self .assertRaises (TypeError , re .compile , 0 )
14211413
1422- def test_bug_13899 (self ):
1423- # Issue #13899: re pattern r"[\A]" should work like "A" but matches
1424- # nothing. Ditto B and Z.
1425- with self .assertWarns (DeprecationWarning ):
1426- self .assertEqual (re .findall (r'[\A\B\b\C\Z]' , 'AB\b CZ' ),
1427- ['A' , 'B' , '\b ' , 'C' , 'Z' ])
1428-
14291414 @bigmemtest (size = _2G , memuse = 1 )
14301415 def test_large_search (self , size ):
14311416 # Issue #10182: indices were 32-bit-truncated.
0 commit comments