mirror of
https://github.com/python/cpython.git
synced 2025-08-04 00:48:58 +00:00
#17341: Include name in re error message about invalid group name.
Patch by Jason Michalski.
This commit is contained in:
parent
f2fa5fc794
commit
26dfaac9ac
4 changed files with 18 additions and 2 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue