Author torne
Recipients torne
Date 2009-08-05.17:14:37
SpamBayes Score 7.48501e-10
Marked as misclassified No
Message-id <1249492479.55.0.250174703511.issue6650@psf.upfronthosting.co.za>
In-reply-to
Content
sre_parse raises an exception with the message "syntax error" - very
generic and confusing - in the case where something that looks like a
lookbehind assertion is invalid.

>>> import re
>>> re.match('(?<foo>.*)', 'foo')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib/python2.5/re.py", line 137, in match
    return _compile(pattern, flags).match(string)
  File "/usr/lib/python2.5/re.py", line 241, in _compile
    raise error, v # invalid expression
sre_constants.error: syntax error

This example is a typo for '(?P<foo>.*)' :)

This is the only case in sre_parse where the message "syntax error" is
used - the others are much more descriptive. Attached patch changes it
to "bad lookbehind assertion type: %s" for python 2.x head; should be
applied to 3.x also.
History
Date User Action Args
2009-08-05 17:14:39tornesetrecipients: + torne
2009-08-05 17:14:39tornesetmessageid: <1249492479.55.0.250174703511.issue6650@psf.upfronthosting.co.za>
2009-08-05 17:14:38tornelinkissue6650 messages
2009-08-05 17:14:37tornecreate