diff options
Diffstat (limited to 'Lib')
-rw-r--r-- | Lib/sre_parse.py | 2 | ||||
-rw-r--r-- | Lib/test/test_re.py | 6 |
2 files changed, 7 insertions, 1 deletions
diff --git a/Lib/sre_parse.py b/Lib/sre_parse.py index 9aea56a..19dd4fc 100644 --- a/Lib/sre_parse.py +++ b/Lib/sre_parse.py @@ -235,7 +235,7 @@ def _class_escape(source, escape): if code: return code code = CATEGORIES.get(escape) - if code: + if code and code[0] == IN: return code try: c = escape[1:2] diff --git a/Lib/test/test_re.py b/Lib/test/test_re.py index 0c8c676..6b047e4 100644 --- a/Lib/test/test_re.py +++ b/Lib/test/test_re.py @@ -857,6 +857,12 @@ class ReTests(unittest.TestCase): # 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']) + @bigmemtest(size=_2G, memuse=character_size) def test_large_search(self, size): # Issue #10182: indices were 32-bit-truncated. |