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.
Created on 2014年10月08日 12:45 by serhiy.storchaka, last changed 2022年04月11日 14:58 by admin. This issue is now closed.
| Files | ||||
|---|---|---|---|---|
| File name | Uploaded | Description | Edit | |
| re_error_attrs.patch | serhiy.storchaka, 2014年10月08日 12:45 | review | ||
| re_error_attrs2.patch | serhiy.storchaka, 2014年10月08日 14:23 | review | ||
| re_error_attrs3.patch | serhiy.storchaka, 2014年10月09日 13:32 | review | ||
| re_error_attrs4.patch | serhiy.storchaka, 2014年10月10日 08:51 | review | ||
| Messages (11) | |||
|---|---|---|---|
| msg228787 - (view) | Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) | Date: 2014年10月08日 12:45 | |
Proposed patch adds additional attributes to the re.error exception: msg, pattern, pos, colno, lineno. It also adds helpful information to error message. Examples: >>> re.compile(r"abc\u123") Traceback (most recent call last): File "<stdin>", line 1, in <module> File "/home/serhiy/py/cpython/Lib/re.py", line 220, in compile return _compile(pattern, flags) File "/home/serhiy/py/cpython/Lib/re.py", line 287, in _compile p = sre_compile.compile(pattern, flags) File "/home/serhiy/py/cpython/Lib/sre_compile.py", line 465, in compile p = sre_parse.parse(p, flags) File "/home/serhiy/py/cpython/Lib/sre_parse.py", line 797, in parse p = _parse_sub(source, pattern, 0) File "/home/serhiy/py/cpython/Lib/sre_parse.py", line 387, in _parse_sub itemsappend(_parse(source, state)) File "/home/serhiy/py/cpython/Lib/sre_parse.py", line 767, in _parse code = _escape(source, this, state) File "/home/serhiy/py/cpython/Lib/sre_parse.py", line 378, in _escape raise source.error("bogus escape: %s" % repr(escape), len(escape)) sre_constants.error: bogus escape: '\\u123' at position 3 >>> re.compile(""" ... (?x) ... .++ ... """) Traceback (most recent call last): File "<stdin>", line 4, in <module> File "/home/serhiy/py/cpython/Lib/re.py", line 220, in compile return _compile(pattern, flags) File "/home/serhiy/py/cpython/Lib/re.py", line 287, in _compile p = sre_compile.compile(pattern, flags) File "/home/serhiy/py/cpython/Lib/sre_compile.py", line 465, in compile p = sre_parse.parse(p, flags) File "/home/serhiy/py/cpython/Lib/sre_parse.py", line 797, in parse p = _parse_sub(source, pattern, 0) File "/home/serhiy/py/cpython/Lib/sre_parse.py", line 387, in _parse_sub itemsappend(_parse(source, state)) File "/home/serhiy/py/cpython/Lib/sre_parse.py", line 602, in _parse source.tell() - here + len(this)) sre_constants.error: multiple repeat at position 16 (line 3, column 7) See also PEP 473, issue19361 and issue22364. |
|||
| msg228788 - (view) | Author: Antoine Pitrou (pitrou) * (Python committer) | Date: 2014年10月08日 13:16 | |
Sounds ok, but it would be nice to add some tests. |
|||
| msg228793 - (view) | Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) | Date: 2014年10月08日 14:23 | |
> Sounds ok, but it would be nice to add some tests. Thank you. Here is a patch with added test. |
|||
| msg228820 - (view) | Author: Matthew Barnett (mrabarnett) * (Python triager) | Date: 2014年10月08日 23:01 | |
I prefer to include the line and column numbers if it's a multi-line pattern, not just if the line number is > 1. BTW, it's shorter if you do this: self.colno = pos - pattern.rfind(newline, 0, pos) If there's no newline, .rfind will return -1. |
|||
| msg228874 - (view) | Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) | Date: 2014年10月09日 13:32 | |
Thank you Matthew for your suggestions. Here is updated patch. |
|||
| msg228972 - (view) | Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) | Date: 2014年10月10日 08:51 | |
Synchronized with the tip after issue19380 changes. |
|||
| msg230953 - (view) | Author: Ezio Melotti (ezio.melotti) * (Python committer) | Date: 2014年11月10日 11:09 | |
LGTM. |
|||
| msg230956 - (view) | Author: Roundup Robot (python-dev) (Python triager) | Date: 2014年11月10日 11:51 | |
New changeset 292c4d853662 by Serhiy Storchaka in branch 'default': Issue #22578: Added attributes to the re.error class. https://hg.python.org/cpython/rev/292c4d853662 |
|||
| msg230959 - (view) | Author: Roundup Robot (python-dev) (Python triager) | Date: 2014年11月10日 12:35 | |
New changeset 07f082b200a7 by Serhiy Storchaka in branch 'default': Fixed IDLE tests after changing re error messages (issue #22578). https://hg.python.org/cpython/rev/07f082b200a7 |
|||
| msg230960 - (view) | Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) | Date: 2014年11月10日 12:43 | |
Thank you Ezio for your review. |
|||
| msg231920 - (view) | Author: Roundup Robot (python-dev) (Python triager) | Date: 2014年12月01日 09:27 | |
New changeset 9711c60e3049 by Serhiy Storchaka in branch 'default': Removed unused function linecol() (added in issue #22578 by mistake). https://hg.python.org/cpython/rev/9711c60e3049 |
|||
| History | |||
|---|---|---|---|
| Date | User | Action | Args |
| 2022年04月11日 14:58:08 | admin | set | github: 66768 |
| 2016年10月16日 09:02:54 | serhiy.storchaka | link | issue16007 superseder |
| 2014年12月01日 09:27:20 | python-dev | set | messages: + msg231920 |
| 2014年11月10日 12:43:24 | serhiy.storchaka | set | status: open -> closed messages: + msg230960 assignee: serhiy.storchaka resolution: fixed stage: patch review -> resolved |
| 2014年11月10日 12:35:51 | python-dev | set | messages: + msg230959 |
| 2014年11月10日 11:51:17 | python-dev | set | nosy:
+ python-dev messages: + msg230956 |
| 2014年11月10日 11:09:48 | ezio.melotti | set | messages: + msg230953 |
| 2014年11月02日 15:07:52 | serhiy.storchaka | link | issue22364 dependencies |
| 2014年10月10日 08:51:49 | serhiy.storchaka | set | files:
+ re_error_attrs4.patch messages: + msg228972 |
| 2014年10月09日 13:32:16 | serhiy.storchaka | set | files:
+ re_error_attrs3.patch messages: + msg228874 |
| 2014年10月08日 23:01:42 | mrabarnett | set | messages: + msg228820 |
| 2014年10月08日 14:23:29 | serhiy.storchaka | set | files:
+ re_error_attrs2.patch messages: + msg228793 |
| 2014年10月08日 13:16:04 | pitrou | set | messages: + msg228788 |
| 2014年10月08日 13:11:05 | pitrou | set | title: Add addition attributes to re.error -> Add additional attributes to re.error |
| 2014年10月08日 12:46:15 | serhiy.storchaka | set | versions:
+ Python 3.5 nosy: + pitrou, ezio.melotti, mrabarnett components: + Regular Expressions type: enhancement stage: patch review |
| 2014年10月08日 12:45:10 | serhiy.storchaka | create | |