@@ -1175,7 +1175,7 @@ def test_escape(self):
1175
1175
check (b"[\\ \n ]" , b"[]" )
1176
1176
check (br'[\"]' , b'["]' )
1177
1177
check (br"[\']" , b"[']" )
1178
- check (br"[\\]" , br"[ \]" )
1178
+ check (br"[\\]" , b"[ \ \ ]" )
1179
1179
check (br"[\a]" , b"[\x07 ]" )
1180
1180
check (br"[\b]" , b"[\x08 ]" )
1181
1181
check (br"[\t]" , b"[\x09 ]" )
@@ -1184,20 +1184,25 @@ def test_escape(self):
1184
1184
check (br"[\f]" , b"[\x0c ]" )
1185
1185
check (br"[\r]" , b"[\x0d ]" )
1186
1186
check (br"[\7]" , b"[\x07 ]" )
1187
- check (br"[\8]" , br"[\8]" )
1188
1187
check (br"[\78]" , b"[\x07 8]" )
1189
1188
check (br"[\41]" , b"[!]" )
1190
1189
check (br"[\418]" , b"[!8]" )
1191
1190
check (br"[\101]" , b"[A]" )
1192
1191
check (br"[\1010]" , b"[A0]" )
1193
1192
check (br"[\501]" , b"[A]" )
1194
1193
check (br"[\x41]" , b"[A]" )
1195
- check (br"[\X41]" , br"[\X41]" )
1196
1194
check (br"[\x410]" , b"[A0]" )
1197
- for b in range (256 ):
1198
- if b not in b'\n "\' \\ abtnvfr01234567x' :
1199
- b = bytes ([b ])
1200
- check (b'\\ ' + b , b'\\ ' + b )
1195
+ for i in range (97 , 123 ):
1196
+ b = bytes ([i ])
1197
+ if b not in b'abfnrtvx' :
1198
+ with self .assertWarns (DeprecationWarning ):
1199
+ check (b"\\ " + b , b"\\ " + b )
1200
+ with self .assertWarns (DeprecationWarning ):
1201
+ check (b"\\ " + b .upper (), b"\\ " + b .upper ())
1202
+ with self .assertWarns (DeprecationWarning ):
1203
+ check (br"\8" , b"\\ 8" )
1204
+ with self .assertWarns (DeprecationWarning ):
1205
+ check (br"\9" , b"\\ 9" )
1201
1206
1202
1207
def test_errors (self ):
1203
1208
decode = codecs .escape_decode
@@ -2448,7 +2453,6 @@ def test_escape_decode(self):
2448
2453
check (br"[\f]" , "[\x0c ]" )
2449
2454
check (br"[\r]" , "[\x0d ]" )
2450
2455
check (br"[\7]" , "[\x07 ]" )
2451
- check (br"[\8]" , r"[\8]" )
2452
2456
check (br"[\78]" , "[\x07 8]" )
2453
2457
check (br"[\41]" , "[!]" )
2454
2458
check (br"[\418]" , "[!8]" )
@@ -2458,9 +2462,18 @@ def test_escape_decode(self):
2458
2462
check (br"[\x410]" , "[A0]" )
2459
2463
check (br"\u20ac" , "\u20ac " )
2460
2464
check (br"\U0001d120" , "\U0001d120 " )
2461
- for b in range (256 ):
2462
- if b not in b'\n "\' \\ abtnvfr01234567xuUN' :
2463
- check (b'\\ ' + bytes ([b ]), '\\ ' + chr (b ))
2465
+ for i in range (97 , 123 ):
2466
+ b = bytes ([i ])
2467
+ if b not in b'abfnrtuvx' :
2468
+ with self .assertWarns (DeprecationWarning ):
2469
+ check (b"\\ " + b , "\\ " + chr (i ))
2470
+ if b .upper () not in b'UN' :
2471
+ with self .assertWarns (DeprecationWarning ):
2472
+ check (b"\\ " + b .upper (), "\\ " + chr (i - 32 ))
2473
+ with self .assertWarns (DeprecationWarning ):
2474
+ check (br"\8" , "\\ 8" )
2475
+ with self .assertWarns (DeprecationWarning ):
2476
+ check (br"\9" , "\\ 9" )
2464
2477
2465
2478
def test_decode_errors (self ):
2466
2479
decode = codecs .unicode_escape_decode
0 commit comments