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: "(?P=)" input for Tools/scripts/redemo.py raises unnhandled exception
Type: behavior Stage: resolved
Components: Demos and Tools, Regular Expressions Versions: Python 3.2, Python 3.3, Python 3.4, Python 2.7
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: ezio.melotti Nosy List: eric.araujo, ezio.melotti, fredeom, mashayk, python-dev, serhiy.storchaka
Priority: normal Keywords: easy, patch

Created on 2011-08-16 11:54 by fredeom, last changed 2022-04-11 14:57 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
redemo.py.png fredeom, 2011-08-16 11:54 Picture that shows issue
patch_for_12759 mashayk, 2011-11-22 01:35 patch checks for the empty group name review
patch_for_12759 mashayk, 2011-11-24 15:24 review
sre_empty_group_name.patch serhiy.storchaka, 2012-11-01 19:51 review
Messages (12)
msg142186 - (view) Author: Alexander (fredeom) Date: 2011-08-16 11:54
Run:
python <PYTHON_PATH>/Tools/scripts/redemo.py
Enter "(?P=)" in entry field.
See unhandled exception occures.
There is special text field in example for such cases. It should be used to show error messages, not a console.
msg143017 - (view) Author: Éric Araujo (eric.araujo) * (Python committer) Date: 2011-08-26 15:43
I can reproduce in 3.3 (the file has been moved to Tools/demo/redemo.py).  The Tk application does not crash but there is a traceback.  Would you like to work on a patch?  If so, there are good guidelines in the devguide.
msg143094 - (view) Author: Alexander (fredeom) Date: 2011-08-28 10:36
I would like to make a patch.
msg143219 - (view) Author: Éric Araujo (eric.araujo) * (Python committer) Date: 2011-08-30 14:55
Great!  Feel free to ask any questions here or through the core-mentorship mailing list.  Remember to read the devguide and work from a Mercurial clone of Python 3.2.  Thanks!
msg148070 - (view) Author: Masha Katsman (mashayk) Date: 2011-11-21 19:11
I am working on the patch. The fix is ready. Will be delivered shortly.
It is also broken when I specify (?P<>) pattern
msg148104 - (view) Author: Masha Katsman (mashayk) Date: 2011-11-22 01:35
The problem with the above expression is that it does not specify a group name. The expression itself is not right. So, it blows up when it tries to parse the name. I put the check for the empty name before any processing is done.
msg148114 - (view) Author: Ezio Melotti (ezio.melotti) * (Python committer) Date: 2011-11-22 12:53
Thanks for the patch!
The patch should also include tests for this case in Lib/test/test_re.py
msg148264 - (view) Author: Masha Katsman (mashayk) Date: 2011-11-24 15:24
Updating the patch with the test. The test checks that the re exception is thrown in case of the (?P=) and (?P<>) expressions.
It used to raise an Index exception. My only question is, the exception we raise now says, there invalid characters in the group name, whether in our case the group name is just empty.
msg173204 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2012-10-17 20:30
> My only question is, the exception we raise now says, there invalid characters in the group name, whether in our case the group name is just empty.

Good point. It would be better if you move the test outside isname() function and immediately raise an error with an appropriate message.
msg174459 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2012-11-01 19:51
Here is an updated patch. More appropriate error message used, many new tests added.
msg174664 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2012-11-03 18:34
New changeset 5b5c2c3b2268 by Ezio Melotti in branch '2.7':
#12759: sre_parse now raises a proper error when the name of the group is missing.  Initial patch by Serhiy Storchaka.
http://hg.python.org/cpython/rev/5b5c2c3b2268

New changeset 29983dd7191e by Ezio Melotti in branch '3.2':
#12759: sre_parse now raises a proper error when the name of the group is missing.  Initial patch by Serhiy Storchaka.
http://hg.python.org/cpython/rev/29983dd7191e

New changeset 28be586287c8 by Ezio Melotti in branch '3.3':
#12759: merge with 3.2.
http://hg.python.org/cpython/rev/28be586287c8

New changeset 3f4fbad75c99 by Ezio Melotti in branch 'default':
#12759: merge with 3.3.
http://hg.python.org/cpython/rev/3f4fbad75c99
msg174665 - (view) Author: Ezio Melotti (ezio.melotti) * (Python committer) Date: 2012-11-03 18:36
I updated the patch to use 'missing group name' instead of 'bad group name', and added a couple more tests.
This also fixes the issue in redemo.py.
Thanks Serhiy and Masha for the patches!
History
Date User Action Args
2022-04-11 14:57:20adminsetgithub: 56968
2012-11-29 17:35:09serhiy.storchakalinkissue16578 superseder
2012-11-03 18:36:54ezio.melottisetstatus: open -> closed
resolution: fixed
messages: + msg174665

stage: patch review -> resolved
2012-11-03 18:34:32python-devsetnosy: + python-dev
messages: + msg174664
2012-11-01 19:51:17serhiy.storchakasetfiles: + sre_empty_group_name.patch
versions: + Python 3.4
messages: + msg174459

keywords: + patch
stage: needs patch -> patch review
2012-10-17 20:30:33serhiy.storchakasetnosy: + serhiy.storchaka

messages: + msg173204
stage: patch review -> needs patch
2011-11-29 15:31:56eric.araujosetassignee: ezio.melotti
stage: test needed -> patch review
2011-11-24 15:24:06mashayksetfiles: + patch_for_12759

messages: + msg148264
2011-11-22 12:53:14ezio.melottisetmessages: + msg148114
components: + Regular Expressions
stage: needs patch -> test needed
2011-11-22 01:35:05mashayksetfiles: + patch_for_12759

messages: + msg148104
2011-11-21 19:14:20ezio.melottisetnosy: + ezio.melotti
2011-11-21 19:11:04mashayksetnosy: + mashayk
messages: + msg148070
2011-08-30 14:55:43eric.araujosetmessages: + msg143219
2011-08-28 10:36:19fredeomsetmessages: + msg143094
2011-08-26 15:43:58eric.araujosettitle: "(?P=)" input for Tools/scripts/redemo.py throw an exception -> "(?P=)" input for Tools/scripts/redemo.py raises unnhandled exception

keywords: + easy
nosy: + eric.araujo
versions: + Python 2.7, Python 3.2, Python 3.3, - Python 2.6
messages: + msg143017
stage: needs patch
2011-08-16 11:54:14fredeomcreate