[Python-checkins] cpython (3.2): #13899: \A, \Z, and \B now correctly match the A, Z, and B literals when used
ezio.melotti
python-checkins at python.org
Fri Jan 11 07:44:50 CET 2013
http://hg.python.org/cpython/rev/081db241ccda
changeset: 81388:081db241ccda
branch: 3.2
parent: 81381:65e55d86f2e6
user: Ezio Melotti <ezio.melotti at gmail.com>
date: Fri Jan 11 08:32:01 2013 +0200
summary:
#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.
files:
Lib/sre_parse.py | 2 +-
Lib/test/test_re.py | 6 ++++++
Misc/ACKS | 1 +
Misc/NEWS | 3 +++
4 files changed, 11 insertions(+), 1 deletions(-)
diff --git a/Lib/sre_parse.py b/Lib/sre_parse.py
--- a/Lib/sre_parse.py
+++ b/Lib/sre_parse.py
@@ -235,7 +235,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 --git a/Lib/test/test_re.py b/Lib/test/test_re.py
--- a/Lib/test/test_re.py
+++ b/Lib/test/test_re.py
@@ -857,6 +857,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'])
+
@bigmemtest(size=_2G, memuse=character_size)
def test_large_search(self, size):
# Issue #10182: indices were 32-bit-truncated.
diff --git a/Misc/ACKS b/Misc/ACKS
--- a/Misc/ACKS
+++ b/Misc/ACKS
@@ -65,6 +65,7 @@
Anton Barkovsky
Nick Barnes
Quentin Barnes
+Matthew Barnett
Richard Barran
Cesar Eduardo Barros
Des Barry
diff --git a/Misc/NEWS b/Misc/NEWS
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -199,6 +199,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 #15545: Fix regression in sqlite3's iterdump method where it was
failing if the connection used a row factory (such as sqlite3.Row) that
produced unsortable objects. (Regression was introduced by fix for 9750).
--
Repository URL: http://hg.python.org/cpython
More information about the Python-checkins
mailing list