This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: Improved Error message for failing re expressions
Type: enhancement Stage: resolved
Components: Regular Expressions Versions: Python 3.4
process
Status: closed Resolution: out of date
Dependencies: Superseder: Add additional attributes to re.error
View: 22578
Assigned To: Nosy List: BreamoreBoy, Ramchandra Apte, Wael.Al.Jishi, benjamin.peterson, ezio.melotti, lingster, mrabarnett, serhiy.storchaka
Priority: normal Keywords:

Created on 2012-09-23 16:14 by lingster, last changed 2022-04-11 14:57 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
re.py lingster, 2012-09-23 16:14 amend regex.
Messages (6)
msg171051 - (view) Author: Ling Li (lingster) Date: 2012-09-23 16:14
Hi,

I would like to make a small improvement to the exception raised when _compile() function fails with exception on line 245. 

Please see attached amended file. The line of code is amended from: 

    raise error, v # invalid expression

to:

    raise error, r'%s with pattern: %s' % (v, pattern) # invalid expression

As this is my first contribution, please let me know if this is the correct procedure to submit changes.

Kind regards,
Ling
msg171054 - (view) Author: Benjamin Peterson (benjamin.peterson) * (Python committer) Date: 2012-09-23 16:21
Please provide a patch in unified diff format.
msg171055 - (view) Author: Ramchandra Apte (Ramchandra Apte) * Date: 2012-09-23 16:23
> As this is my first contribution, please let me know if this is the correct procedure to submit changes.

This is the correct procedure. http://docs.python.org/devguide/ (the Python Devlopment Guide) is a guide on how to contribute to Python.
Hope you enjoy your Python development experience!
msg171702 - (view) Author: Wael Al Jishi (Wael.Al.Jishi) Date: 2012-10-01 10:54
The attached file is very different to the current source, including the docstring. Is this from python 2.x?
msg227072 - (view) Author: Mark Lawrence (BreamoreBoy) * Date: 2014-09-18 21:32
The original try/except that leads to the raise does not exist in the latest 3.5 code.  I'd be inclined to close this as "out of date" for compatibility reasons if nothing else.
msg278754 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2016-10-16 09:02
Since 3.5 (issue22578) the re.error exception has attributes that contain a pattern and the position of the error. Error message contains the position of the error. A pattern is not included in the error message for purpose: it can be too long. Usually the pattern is clear from the context, and you always can check the pattern attribute.
History
Date User Action Args
2022-04-11 14:57:36adminsetgithub: 60211
2016-10-16 09:02:54serhiy.storchakasetstatus: open -> closed
superseder: Add additional attributes to re.error
messages: + msg278754

resolution: out of date
stage: needs patch -> resolved
2014-11-01 22:14:14ezio.melottisetnosy: + serhiy.storchaka
2014-09-18 21:32:15BreamoreBoysetnosy: + BreamoreBoy
messages: + msg227072
2012-10-01 10:54:46Wael.Al.Jishisetnosy: + Wael.Al.Jishi
messages: + msg171702
2012-09-30 16:56:46ezio.melottisetstage: needs patch
2012-09-23 16:23:34Ramchandra Aptesetnosy: + Ramchandra Apte
messages: + msg171055
2012-09-23 16:21:59benjamin.petersonsetnosy: + benjamin.peterson

messages: + msg171054
versions: + Python 3.4, - Python 2.7
2012-09-23 16:14:27lingstercreate