Index: Lib/sre_parse.py =================================================================== --- Lib/sre_parse.py (revision 62337) +++ Lib/sre_parse.py (working copy) @@ -568,6 +568,27 @@ raise error, "unknown group name" subpatternappend((GROUPREF, gid)) continue + elif sourcematch("#"): + # Python-Specific Comment -- allows for nested + # paren + depth = 1 + while 1: + if sourcematch("\\"): + # Ignore escaped characters + if not source.next: + break + elif source.next == "(": + depth += 1 + elif source.next == ")": + depth -= 1 + if not depth: + break + if source.next is None: + break + sourceget() + if not sourcematch(")"): + raise error, "unbalanced parenthesis" + continue else: char = sourceget() if char is None: