Movatterモバイル変換


[0]ホーム

URL:


homepage

Issue24580

This issue trackerhas been migrated toGitHub, and is currentlyread-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title:Wrong or missing exception when compiling regexes with recursive named backreferences
Type:behaviorStage:resolved
Components:Regular ExpressionsVersions:Python 3.6, Python 3.4, Python 3.5, Python 2.7
process
Status:closedResolution:fixed
Dependencies:Superseder:
Assigned To: serhiy.storchakaNosy List: benjamin.peterson, dhaffey, ezio.melotti, mrabarnett, python-dev, serhiy.storchaka
Priority:normalKeywords:patch

Created on2015-07-07 01:25 bydhaffey, last changed2022-04-11 14:58 byadmin. This issue is nowclosed.

Files
File nameUploadedDescriptionEdit
re_open_group_symbolic_ref.patchserhiy.storchaka,2015-07-07 09:35review
re_open_group_symbolic_ref-3.4.patchserhiy.storchaka,2015-07-07 09:37review
Messages (5)
msg246390 -(view)Author: Dan Haffey (dhaffey)Date: 2015-07-07 01:25
Error reporting for recursive backreferences in regexes isn't consistent across both types of backref. Here's the exception for a recursive numeric backref:>>> import re>>> re.compile(r'(\1)')Traceback (most recent call last):    ...sre_constants.error: cannot refer to an open group at position 1Here's what I'm seeing on the 3.5 branch for a named backref:>>> re.compile(r'(?P<spam>(?P=spam))')Traceback (most recent call last):    ...RecursionError: maximum recursion depth exceededWhich is an improvement over 3.4 and below, where compilation succeeds and appears to treat (?P=spam) as valid but unmatchable.
msg246396 -(view)Author: Serhiy Storchaka (serhiy.storchaka)*(Python committer)Date: 2015-07-07 09:35
Here is a patch that forbids symbolic references to opened groups in 3.5+.
msg246397 -(view)Author: Serhiy Storchaka (serhiy.storchaka)*(Python committer)Date: 2015-07-07 09:37
It is questionable if an exception should be raised in older Python versions. Here is a patch for 3.4 that just issues a warning.
msg246913 -(view)Author: Roundup Robot (python-dev)(Python triager)Date: 2015-07-18 20:38
New changeset361d7af9396e by Serhiy Storchaka in branch '3.5':Issue#24580: Symbolic group references to open group in re patterns now arehttps://hg.python.org/cpython/rev/361d7af9396eNew changeset4d3557500019 by Serhiy Storchaka in branch 'default':Issue#24580: Symbolic group references to open group in re patterns now arehttps://hg.python.org/cpython/rev/4d3557500019
msg256740 -(view)Author: Serhiy Storchaka (serhiy.storchaka)*(Python committer)Date: 2015-12-19 21:26
It is too late for 3.4, and I left 2.7 as is. Reopen issue if you think that it is worth to add a warning to 2.7.
History
DateUserActionArgs
2022-04-11 14:58:18adminsetgithub: 68768
2015-12-19 21:26:32serhiy.storchakasetstatus: open -> closed

nosy: +benjamin.peterson
messages: +msg256740

resolution: fixed
stage: patch review -> resolved
2015-07-18 20:38:14python-devsetnosy: +python-dev
messages: +msg246913
2015-07-07 09:37:33serhiy.storchakasetversions: + Python 2.7, Python 3.4
2015-07-07 09:37:20serhiy.storchakasetfiles: +re_open_group_symbolic_ref-3.4.patch

messages: +msg246397
2015-07-07 09:35:19serhiy.storchakasetfiles: +re_open_group_symbolic_ref.patch
keywords: +patch
messages: +msg246396

stage: needs patch -> patch review
2015-07-07 04:31:20serhiy.storchakasetassignee:serhiy.storchaka
stage: needs patch

nosy: +serhiy.storchaka
versions: + Python 3.5, Python 3.6
2015-07-07 01:25:41dhaffeycreate
Supported byThe Python Software Foundation,
Powered byRoundup
Copyright © 1990-2022,Python Software Foundation
Legal Statements

[8]ページ先頭

©2009-2026 Movatter.jp