summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_sre.py
diff options
context:
space:
mode:
authorFredrik Lundh <fredrik@pythonware.com>2001-09-18 20:55:24 (GMT)
committerFredrik Lundh <fredrik@pythonware.com>2001-09-18 20:55:24 (GMT)
commit59b68656f846973840953220c4780f3558b59fb8 (patch)
tree6a91ff46e00681f594aa3c9280d268627d009cc5 /Lib/test/test_sre.py
parentab3b0343b89b4683148dadaf89728ee1198ebee5 (diff)
downloadcpython-59b68656f846973840953220c4780f3558b59fb8.zip
cpython-59b68656f846973840953220c4780f3558b59fb8.tar.gz
cpython-59b68656f846973840953220c4780f3558b59fb8.tar.bz2
fixed #449964: sre.sub raises an exception if the template contains a
\g<x> group reference followed by a character escape (also restructured a few things on the way to fixing #449000)
Diffstat (limited to 'Lib/test/test_sre.py')
-rw-r--r--Lib/test/test_sre.py3
1 files changed, 3 insertions, 0 deletions
diff --git a/Lib/test/test_sre.py b/Lib/test/test_sre.py
index 49fe4c6..4a71447 100644
--- a/Lib/test/test_sre.py
+++ b/Lib/test/test_sre.py
@@ -104,6 +104,9 @@ test(r"""sre.sub(r'(?P<a>x)', '\g<a>\g<1>', 'xx')""", 'xxxx')
test(r"""sre.sub(r'(?P<unk>x)', '\g<unk>\g<unk>', 'xx')""", 'xxxx')
test(r"""sre.sub(r'(?P<unk>x)', '\g<1>\g<1>', 'xx')""", 'xxxx')
+# bug 449964: fails for group followed by other escape
+test(r"""sre.sub(r'(?P<unk>x)', '\g<1>\g<1>\\b', 'xx')""", 'xx\bxx\b')
+
test(r"""sre.sub(r'a', r'\t\n\v\r\f\a\b\B\Z\a\A\w\W\s\S\d\D', 'a')""", '\t\n\v\r\f\a\b\\B\\Z\a\\A\\w\\W\\s\\S\\d\\D')
test(r"""sre.sub(r'a', '\t\n\v\r\f\a', 'a')""", '\t\n\v\r\f\a')
test(r"""sre.sub(r'a', '\t\n\v\r\f\a', 'a')""", (chr(9)+chr(10)+chr(11)+chr(13)+chr(12)+chr(7)))