summaryrefslogtreecommitdiffstats
path: root/Lib/sre_parse.py
diff options
context:
space:
mode:
authorEzio Melotti <ezio.melotti@gmail.com>2012-11-03 18:33:08 (GMT)
committerEzio Melotti <ezio.melotti@gmail.com>2012-11-03 18:33:08 (GMT)
commit0941d9fc64e1429454282667d0ca47740c141943 (patch)
treeaa3c88e98ea74d685a1dd2f5b8b0e3ff1e839b0d /Lib/sre_parse.py
parentdedfa9bfaec868af2099b44e68bd98ebd5075062 (diff)
downloadcpython-0941d9fc64e1429454282667d0ca47740c141943.zip
cpython-0941d9fc64e1429454282667d0ca47740c141943.tar.gz
cpython-0941d9fc64e1429454282667d0ca47740c141943.tar.bz2
#12759: sre_parse now raises a proper error when the name of the group is missing. Initial patch by Serhiy Storchaka.
Diffstat (limited to 'Lib/sre_parse.py')
-rw-r--r--Lib/sre_parse.py8
1 files changed, 7 insertions, 1 deletions
diff --git a/Lib/sre_parse.py b/Lib/sre_parse.py
index 13737ca..9aea56a 100644
--- a/Lib/sre_parse.py
+++ b/Lib/sre_parse.py
@@ -548,6 +548,8 @@ def _parse(source, state):
break
name = name + char
group = 1
+ if not name:
+ raise error("missing group name")
if not isname(name):
raise error("bad character in group name")
elif sourcematch("="):
@@ -560,6 +562,8 @@ def _parse(source, state):
if char == ")":
break
name = name + char
+ if not name:
+ raise error("missing group name")
if not isname(name):
raise error("bad character in group name")
gid = state.groupdict.get(name)
@@ -612,6 +616,8 @@ def _parse(source, state):
break
condname = condname + char
group = 2
+ if not condname:
+ raise error("missing group name")
if isname(condname):
condgroup = state.groupdict.get(condname)
if condgroup is None:
@@ -743,7 +749,7 @@ def parse_template(source, pattern):
break
name = name + char
if not name:
- raise error("bad group name")
+ raise error("missing group name")
try:
index = int(name)
if index < 0: