@@ -911,10 +911,9 @@ def test_inline_flags(self):
911911 p = regex .compile ('(?iu)' + lower_char )
912912 self .assertEqual (bool (p .match (upper_char )), True )
913913
914+ # Changed to positional flags in regex 2023.12.23.
914915 self .assertEqual (bool (regex .match (r"(?i)a" , "A" )), True )
915- self .assertEqual (bool (regex .match (r"a(?i)" , "A" )), True )
916- self .assertEqual (bool (regex .match (r"(?iV1)a" , "A" )), True )
917- self .assertEqual (regex .match (r"a(?iV1)" , "A" ), None )
916+ self .assertEqual (regex .match (r"a(?i)" , "A" ), None )
918917
919918 def test_dollar_matches_twice (self ):
920919 # $ matches the end of string, and just before the terminating \n.
@@ -1396,18 +1395,15 @@ def test_scoped_and_inline_flags(self):
13961395 # Issues 433028, 433024, 433027.
13971396 self .assertEqual (regex .search (r"(?i)Ab" , "ab" ).span (), (0 , 2 ))
13981397 self .assertEqual (regex .search (r"(?i:A)b" , "ab" ).span (), (0 , 2 ))
1399- self .assertEqual (regex .search (r"A(?i)b" , "ab" ).span (), (0 , 2 ))
1400- self .assertEqual (regex .search (r"A(?iV1)b" , "ab" ), None )
1401-
1402- self .assertRaisesRegex (regex .error , self .CANT_TURN_OFF , lambda :
1403- regex .search (r"(?V0-i)Ab" , "ab" , flags = regex .I ))
1398+ # Changed to positional flags in regex 2023.12.23.
1399+ self .assertEqual (regex .search (r"A(?i)b" , "ab" ), None )
14041400
14051401 self .assertEqual (regex .search (r"(?V0)Ab" , "ab" ), None )
14061402 self .assertEqual (regex .search (r"(?V1)Ab" , "ab" ), None )
1407- self .assertEqual (regex .search (r"(?V1 -i)Ab" , "ab" , flags = regex .I ), None )
1403+ self .assertEqual (regex .search (r"(?-i)Ab" , "ab" , flags = regex .I ), None )
14081404 self .assertEqual (regex .search (r"(?-i:A)b" , "ab" , flags = regex .I ), None )
1409- self .assertEqual (regex .search (r"A(?V1 -i)b" , "ab" ,
1410- flags = regex . I ). span (), (0 , 2 ))
1405+ self .assertEqual (regex .search (r"A(?-i)b" , "ab" , flags = regex . I ). span () ,
1406+ (0 , 2 ))
14111407
14121408 def test_repeated_repeats (self ):
14131409 # Issue 2537.
@@ -1820,12 +1816,10 @@ def test_various(self):
18201816 ('a.*b' , 'acc\n ccb' , '' , ascii (None )),
18211817 ('a.{4,5}b' , 'acc\n ccb' , '' , ascii (None )),
18221818 ('a.b' , 'a\r b' , '0' , ascii ('a\r b' )),
1823- # The new behaviour is that the inline flag affects only what follows.
1824- ('a.b(?s)' , 'a\n b' , '0' , ascii ('a\n b' )),
1825- ('a.b(?sV1)' , 'a\n b' , '' , ascii (None )),
1819+ # Changed to positional flags in regex 2023.12.23.
1820+ ('a.b(?s)' , 'a\n b' , '' , ascii (None )),
18261821 ('(?s)a.b' , 'a\n b' , '0' , ascii ('a\n b' )),
1827- ('a.*(?s)b' , 'acc\n ccb' , '0' , ascii ('acc\n ccb' )),
1828- ('a.*(?sV1)b' , 'acc\n ccb' , '' , ascii (None )),
1822+ ('a.*(?s)b' , 'acc\n ccb' , '' , ascii (None )),
18291823 ('(?s)a.*b' , 'acc\n ccb' , '0' , ascii ('acc\n ccb' )),
18301824 ('(?s)a.{4,5}b' , 'acc\n ccb' , '0' , ascii ('acc\n ccb' )),
18311825
@@ -2345,12 +2339,9 @@ def test_various(self):
23452339 # Not an error under PCRE/PRE:
23462340 # When the new behaviour is turned on positional inline flags affect
23472341 # only what follows.
2348- ('w(?i)' , 'W' , '0' , ascii ('W' )),
2349- ('w(?iV1)' , 'W' , '0' , ascii (None )),
2342+ ('w(?i)' , 'W' , '0' , ascii (None )),
23502343 ('w(?i)' , 'w' , '0' , ascii ('w' )),
2351- ('w(?iV1)' , 'w' , '0' , ascii ('w' )),
23522344 ('(?i)w' , 'W' , '0' , ascii ('W' )),
2353- ('(?iV1)w' , 'W' , '0' , ascii ('W' )),
23542345
23552346 # Comments using the x embedded pattern modifier.
23562347 ("""(?x)w# comment 1
@@ -2403,14 +2394,10 @@ def test_various(self):
24032394 # Bug 114033: nothing to repeat.
24042395 (r'(x?)?' , 'x' , '0' , ascii ('x' )),
24052396 # Bug 115040: rescan if flags are modified inside pattern.
2406- # If the new behaviour is turned on then positional inline flags
2407- # affect only what follows.
2408- (r' (?x)foo ' , 'foo' , '0' , ascii ('foo' )),
2409- (r' (?V1x)foo ' , 'foo' , '0' , ascii (None )),
2397+ # Changed to positional flags in regex 2023.12.23.
2398+ (r' (?x)foo ' , 'foo' , '0' , ascii (None )),
24102399 (r'(?x) foo ' , 'foo' , '0' , ascii ('foo' )),
2411- (r'(?V1x) foo ' , 'foo' , '0' , ascii ('foo' )),
24122400 (r'(?x)foo ' , 'foo' , '0' , ascii ('foo' )),
2413- (r'(?V1x)foo ' , 'foo' , '0' , ascii ('foo' )),
24142401 # Bug 115618: negative lookahead.
24152402 (r'(?<!abc)(d.f)' , 'abcdefdof' , '0' , ascii ('dof' )),
24162403 # Bug 116251: character class bug.
@@ -3154,10 +3141,8 @@ def test_hg_bugs(self):
31543141
31553142 # Hg issue 39: regex.search("((?i)blah)\\s+\\1", "blah BLAH") doesn't
31563143 # return None
3157- self .assertEqual (regex .search (r"(?V0)((?i)blah)\s+\1" ,
3158- "blah BLAH" ).group (0 , 1 ), ("blah BLAH" , "blah" ))
3159- self .assertEqual (regex .search (r"(?V1)((?i)blah)\s+\1" , "blah BLAH" ),
3160- None )
3144+ # Changed to positional flags in regex 2023.12.23.
3145+ self .assertEqual (regex .search (r"((?i)blah)\s+\1" , "blah BLAH" ), None )
31613146
31623147 # Hg issue 40: regex.search("(\()?[^()]+(?(1)\)|)", "(abcd").group(0)
31633148 # returns "bcd" instead of "abcd"
@@ -4336,10 +4321,10 @@ def test_hg_bugs(self):
43364321 self .assertEqual (regex .search (r"^a?(a?)b?c\1$" , "abca" ).span (), (0 , 4 ))
43374322
43384323 # Git issue 498: Conditional negative lookahead inside positive lookahead fails to match
4339- self .assertEqual (regex .match (r" (?(?=a).|..)" , "ab" ).span (), (0 , 1 ))
4340- self .assertEqual (regex .match (r" (?(?=b).|..)" , "ab" ).span (), (0 , 2 ))
4341- self .assertEqual (regex .match (r" (?(?!a).|..)" , "ab" ).span (), (0 , 2 ))
4342- self .assertEqual (regex .match (r" (?(?!b).|..)" , "ab" ).span (), (0 , 1 ))
4324+ self .assertEqual (regex .match (r' (?(?=a).|..)' , 'ab' ).span (), (0 , 1 ))
4325+ self .assertEqual (regex .match (r' (?(?=b).|..)' , 'ab' ).span (), (0 , 2 ))
4326+ self .assertEqual (regex .match (r' (?(?!a).|..)' , 'ab' ).span (), (0 , 2 ))
4327+ self .assertEqual (regex .match (r' (?(?!b).|..)' , 'ab' ).span (), (0 , 1 ))
43434328
43444329 def test_fuzzy_ext (self ):
43454330 self .assertEqual (bool (regex .fullmatch (r'(?r)(?:a){e<=1:[a-z]}' , 'e' )),
@@ -4460,6 +4445,12 @@ def test_more_zerowidth(self):
44604445 self .assertEqual ([m .span () for m in regex .finditer (r'(?m)^\s*?$' ,
44614446 'foo\n \n \n bar' )], [(4 , 4 ), (4 , 5 ), (5 , 5 )])
44624447
4448+ def test_line_ending (self ):
4449+ self .assertEqual (regex .findall (r'\R' , '\r \n \n \x0B \f \r \x85 \u2028 \u2029 ' ),
4450+ ['\r \n ' , '\n ' , '\x0B ' , '\f ' , '\r ' , '\x85 ' , '\u2028 ' , '\u2029 ' ])
4451+ self .assertEqual (regex .findall (br'\R' , b'\r \n \n \x0B \f \r \x85 ' ), [b'\r \n ' ,
4452+ b'\n ' , b'\x0B ' , b'\f ' , b'\r ' ])
4453+
44634454def test_main ():
44644455 unittest .main (verbosity = 2 )
44654456
0 commit comments