@@ -1368,7 +1368,7 @@ def test_inline_flags(self):
13681368 self .assertTrue (re .match (p , lower_char ))
13691369 self .assertEqual (
13701370 str (warns .warnings [0 ].message ),
1371- 'Flags not at the start of the expression %s ' % p
1371+ 'Flags not at the start of the expression %r ' % p
13721372 )
13731373 self .assertEqual (warns .warnings [0 ].filename , __file__ )
13741374
@@ -1377,10 +1377,22 @@ def test_inline_flags(self):
13771377 self .assertTrue (re .match (p , lower_char ))
13781378 self .assertEqual (
13791379 str (warns .warnings [0 ].message ),
1380- 'Flags not at the start of the expression %s (truncated)' % p [:20 ]
1380+ 'Flags not at the start of the expression %r (truncated)' % p [:20 ]
13811381 )
13821382 self .assertEqual (warns .warnings [0 ].filename , __file__ )
13831383
1384+ # bpo-30605: Compiling a bytes instance regex was throwing a BytesWarning
1385+ with warnings .catch_warnings ():
1386+ warnings .simplefilter ('error' , BytesWarning )
1387+ p = b'A(?i)'
1388+ with self .assertWarns (DeprecationWarning ) as warns :
1389+ self .assertTrue (re .match (p , b'a' ))
1390+ self .assertEqual (
1391+ str (warns .warnings [0 ].message ),
1392+ 'Flags not at the start of the expression %r' % p
1393+ )
1394+ self .assertEqual (warns .warnings [0 ].filename , __file__ )
1395+
13841396 with self .assertWarns (DeprecationWarning ):
13851397 self .assertTrue (re .match ('(?s).(?i)' + upper_char , '\n ' + lower_char ))
13861398 with self .assertWarns (DeprecationWarning ):
0 commit comments