summaryrefslogtreecommitdiffstats
path: root/Lib/test
diff options
context:
space:
mode:
authorR David Murray <rdmurray@bitdance.com>2013-04-14 17:00:54 (GMT)
committerR David Murray <rdmurray@bitdance.com>2013-04-14 17:00:54 (GMT)
commit26dfaac9ac0cf9a34006ab52a0e0cc4e39b772fa (patch)
tree36227d0c87ddb055c1b4b2f13020b0b7b19652e4 /Lib/test
parentf2fa5fc794834da5282218458bec3fa16da6671f (diff)
downloadcpython-26dfaac9ac0cf9a34006ab52a0e0cc4e39b772fa.zip
cpython-26dfaac9ac0cf9a34006ab52a0e0cc4e39b772fa.tar.gz
cpython-26dfaac9ac0cf9a34006ab52a0e0cc4e39b772fa.tar.bz2
#17341: Include name in re error message about invalid group name.
Patch by Jason Michalski.
Diffstat (limited to 'Lib/test')
-rw-r--r--Lib/test/test_re.py11
1 files changed, 11 insertions, 0 deletions
diff --git a/Lib/test/test_re.py b/Lib/test/test_re.py
index e90c770..8bc74a2 100644
--- a/Lib/test/test_re.py
+++ b/Lib/test/test_re.py
@@ -3,6 +3,7 @@ from test.support import verbose, run_unittest, gc_collect, bigmemtest, _2G, \
import io
import re
from re import Scanner
+import sre_constants
import sys
import string
import traceback
@@ -1029,6 +1030,16 @@ class ReTests(unittest.TestCase):
self.assertRaises(OverflowError, re.compile, r".{,%d}" % MAXREPEAT)
self.assertRaises(OverflowError, re.compile, r".{%d,}?" % MAXREPEAT)
+ def test_backref_group_name_in_exception(self):
+ # Issue 17341: Poor error message when compiling invalid regex
+ with self.assertRaisesRegex(sre_constants.error, '<foo>'):
+ re.compile('(?P=<foo>)')
+
+ def test_group_name_in_exception(self):
+ # Issue 17341: Poor error message when compiling invalid regex
+ with self.assertRaisesRegex(sre_constants.error, '\?foo'):
+ re.compile('(?P<?foo>)')
+
def run_re_tests():
from test.re_tests import tests, SUCCEED, FAIL, SYNTAX_ERROR