New submission from Torne Wuff <torne-pythonb...@wolfpuppy.org.uk>: 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. ---------- components: Regular Expressions files: sre_error_msg.diff keywords: patch messages: 91324 nosy: torne severity: normal status: open title: sre_parse contains a confusing generic error message type: behavior versions: Python 2.4, Python 2.5, Python 2.6, Python 2.7, Python 3.0, Python 3.1, Python 3.2 Added file: http://bugs.python.org/file14659/sre_error_msg.diff _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue6650> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com