# HG changeset patch # User MRAB # Date 1357581809 0 # Node ID 2d764503dec3031b16d421376c6e5d75eeff8d7a # Parent 9009178e08d955a915121580a84e4355ce24018d Issue #13899: re pattern r"[\A]" should work like "A" but matches nothing. Ditto B and Z. diff -r 9009178e08d9 -r 2d764503dec3 Lib/sre_parse.py --- a/Lib/sre_parse.py Mon Jan 07 14:19:12 2013 +0000 +++ b/Lib/sre_parse.py Mon Jan 07 18:03:29 2013 +0000 @@ -245,7 +245,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 9009178e08d9 -r 2d764503dec3 Lib/test/test_re.py --- a/Lib/test/test_re.py Mon Jan 07 14:19:12 2013 +0000 +++ b/Lib/test/test_re.py Mon Jan 07 18:03:29 2013 +0000 @@ -974,6 +974,12 @@ self.assertEqual(re.findall(r"(?i)(a)1円", "aa \u0100"), ['a']) self.assertEqual(re.match(r"(?s).{1,3}", "\u0100\u0100").span(), (0, 2)) + 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']) + def run_re_tests(): from test.re_tests import tests, SUCCEED, FAIL, SYNTAX_ERROR if verbose:

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