re Compile - a bug?

Colin J. Williams cjw at connection.com
Wed Feb 16 09:33:33 EST 2000


It seems that an unbalanced parenthesis in a comment gives: 

    hpat= compile(r'''
  File "G:\Program Files\Python\Lib\re.py", line 79, in compile
    code=pcre_compile(pattern, flags, groupindex)
pcre.error: ('unmatched brackets', 128)

with the text below:

hpat= compile(r'''
  (<(?P<Hdr>th) [^>]*>)           #  Either header up to terminating '>'
                                  # |(?P<Hdr>td)[^>]*>)  <-- Grief!
  (.*?)                           #  Followed by anything
  </(?P=Hdr)>",flags + VERBOSE    # Matching terminator
  ''')
               -------------------------------
Correctly, the PythonWin editor does not report the mismatch.

Colin W.




More information about the Python-list mailing list