#12759: sre_parse now raises a proper error when the name of the group is missing.  Initial patch by Serhiy Storchaka.
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 @@
                                 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 @@
                             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 @@
                             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 @@
                             break
                         name = name + char
                 if not name:
-                    raise error("bad group name")
+                    raise error("missing group name")
                 try:
                     index = int(name)
                     if index < 0: