changeset: 81387:2bc04449fd8c branch: 2.7 parent: 81378:2a417ad8bfbf user: Ezio Melotti date: Fri Jan 11 08:32:01 2013 +0200 files: Lib/sre_parse.py Lib/test/test_re.py Misc/ACKS Misc/NEWS description: #13899: \A, \Z, and \B now correctly match the A, Z, and B literals when used inside character classes (e.g. [A]). Patch by Matthew Barnett. diff -r 2a417ad8bfbf -r 2bc04449fd8c Lib/sre_parse.py --- a/Lib/sre_parse.py Thu Jan 10 21:10:40 2013 -0500 +++ b/Lib/sre_parse.py Fri Jan 11 08:32:01 2013 +0200 @@ -228,7 +228,7 @@ if code: return code code = CATEGORIES.get(escape) - if code: + if code and code[0] == IN: return code try: c = escape[1:2] diff -r 2a417ad8bfbf -r 2bc04449fd8c Lib/test/test_re.py --- a/Lib/test/test_re.py Thu Jan 10 21:10:40 2013 -0500 +++ b/Lib/test/test_re.py Fri Jan 11 08:32:01 2013 +0200 @@ -821,6 +821,12 @@ # Test behaviour when not given a string or pattern as parameter self.assertRaises(TypeError, re.compile, 0) + def test_bug_13899(self): + # Issue #13899: re pattern r"[\A]" should work like "A" but matches + # nothing. Ditto B and Z. + self.assertEqual(re.findall(r'[\A\B\b\C\Z]', 'AB\bCZ'), + ['A', 'B', '\b', 'C', 'Z']) + @precisionbigmemtest(size=_2G, memuse=1) def test_large_search(self, size): # Issue #10182: indices were 32-bit-truncated. diff -r 2a417ad8bfbf -r 2bc04449fd8c Misc/ACKS --- a/Misc/ACKS Thu Jan 10 21:10:40 2013 -0500 +++ b/Misc/ACKS Fri Jan 11 08:32:01 2013 +0200 @@ -58,6 +58,7 @@ Anton Barkovsky Nick Barnes Quentin Barnes +Matthew Barnett Richard Barran Cesar Eduardo Barros Des Barry diff -r 2a417ad8bfbf -r 2bc04449fd8c Misc/NEWS --- a/Misc/NEWS Thu Jan 10 21:10:40 2013 -0500 +++ b/Misc/NEWS Fri Jan 11 08:32:01 2013 +0200 @@ -186,6 +186,9 @@ Library ------- +- Issue #13899: \A, \Z, and \B now correctly match the A, Z, and B literals + when used inside character classes (e.g. '[\A]'). Patch by Matthew Barnett. + - Issue #15109: Fix regression in sqlite3's iterdump method where it would die with an encoding error if the database contained string values containing non-ASCII. (Regression was introduced by fix for 9750).

AltStyle によって変換されたページ (->オリジナル) /