Commit fe8e6e74 authored by Ezio Melotti's avatar Ezio Melotti

#13899: \A, \Z, and \B now correctly match the A, Z, and B literals when used...

#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.
parent 26ed2340
...@@ -235,7 +235,7 @@ def _class_escape(source, escape): ...@@ -235,7 +235,7 @@ def _class_escape(source, escape):
if code: if code:
return code return code
code = CATEGORIES.get(escape) code = CATEGORIES.get(escape)
if code: if code and code[0] == IN:
return code return code
try: try:
c = escape[1:2] c = escape[1:2]
......
...@@ -857,6 +857,12 @@ class ReTests(unittest.TestCase): ...@@ -857,6 +857,12 @@ class ReTests(unittest.TestCase):
# Test behaviour when not given a string or pattern as parameter # Test behaviour when not given a string or pattern as parameter
self.assertRaises(TypeError, re.compile, 0) 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) @bigmemtest(size=_2G, memuse=character_size)
def test_large_search(self, size): def test_large_search(self, size):
# Issue #10182: indices were 32-bit-truncated. # Issue #10182: indices were 32-bit-truncated.
......
...@@ -65,6 +65,7 @@ Chris Barker ...@@ -65,6 +65,7 @@ Chris Barker
Anton Barkovsky Anton Barkovsky
Nick Barnes Nick Barnes
Quentin Barnes Quentin Barnes
Matthew Barnett
Richard Barran Richard Barran
Cesar Eduardo Barros Cesar Eduardo Barros
Des Barry Des Barry
......
...@@ -199,6 +199,9 @@ Core and Builtins ...@@ -199,6 +199,9 @@ Core and Builtins
Library 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 #15545: Fix regression in sqlite3's iterdump method where it was - Issue #15545: Fix regression in sqlite3's iterdump method where it was
failing if the connection used a row factory (such as sqlite3.Row) that failing if the connection used a row factory (such as sqlite3.Row) that
produced unsortable objects. (Regression was introduced by fix for 9750). produced unsortable objects. (Regression was introduced by fix for 9750).
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment