diff options
author | Ezio Melotti <ezio.melotti@gmail.com> | 2012-11-03 18:31:12 (GMT) |
---|---|---|
committer | Ezio Melotti <ezio.melotti@gmail.com> | 2012-11-03 18:31:12 (GMT) |
commit | ef3173877c78f1bbab1e570c68b2ce11460a9f5b (patch) | |
tree | 8ebc9c5c4171ff1408e783fd9e9099fee097c02c /Lib/sre_parse.py | |
parent | d1076dbef8c0cdf6c35101f7c99cdcd319a1e8e5 (diff) | |
download | cpython-ef3173877c78f1bbab1e570c68b2ce11460a9f5b.zip cpython-ef3173877c78f1bbab1e570c68b2ce11460a9f5b.tar.gz cpython-ef3173877c78f1bbab1e570c68b2ce11460a9f5b.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.py | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/Lib/sre_parse.py b/Lib/sre_parse.py index 182d1eb..7149dca 100644 --- a/Lib/sre_parse.py +++ b/Lib/sre_parse.py @@ -541,6 +541,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("="): @@ -553,6 +555,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) @@ -605,6 +609,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: @@ -723,7 +729,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: |