Movatterモバイル変換


[0]ホーム

URL:


homepage

Issue27177

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:re match.group should support __index__
Type:enhancementStage:resolved
Components:Regular ExpressionsVersions:Python 3.6
process
Status:closedResolution:fixed
Dependencies:Superseder:
Assigned To: serhiy.storchakaNosy List: ezio.melotti, jdemeyer, mrabarnett, python-dev, serhiy.storchaka, xiang.zhang
Priority:normalKeywords:patch

Created on2016-06-01 14:20 byjdemeyer, last changed2022-04-11 14:58 byadmin. This issue is nowclosed.

Files
File nameUploadedDescriptionEdit
re_match_index.patchjdemeyer,2016-06-01 14:20Patch for Python 2.7
issue27177.patchxiang.zhang,2016-06-15 07:02review
Messages (9)
msg266817 -(view)Author: Jeroen Demeyer (jdemeyer)*(Python triager)Date: 2016-06-01 14:20
```>>> class zero(object):...     def __index__(self):...         return 0... >>> z = zero()>>> import re>>> p = re.compile('(a)b')>>> m = p.match('ab')>>> m.group(0)'ab'>>> m.group(z)Traceback (most recent call last):  File "<stdin>", line 1, in <module>IndexError: no such group```
msg266822 -(view)Author: Serhiy Storchaka (serhiy.storchaka)*(Python committer)Date: 2016-06-01 16:35
This looks as new feature and can go only in 3.6.
msg266884 -(view)Author: Jeroen Demeyer (jdemeyer)*(Python triager)Date: 2016-06-02 12:35
I would still argue that it's a bug. The intention ofPEP 357 is that __index__ should be used whenever some object needs to be converted to a Py_ssize_t, which is exactly what you do here.
msg266885 -(view)Author: Matthew Barnett (mrabarnett)*(Python triager)Date: 2016-06-02 14:00
It would be a bug if it was supported but gave the wrong result.It has never been supported (the re module predatesPEP 357), so it's a new feature.
msg268606 -(view)Author: Xiang Zhang (xiang.zhang)*(Python committer)Date: 2016-06-15 07:02
Attach a patch to add this feature to Py3.6.
msg268775 -(view)Author: Serhiy Storchaka (serhiy.storchaka)*(Python committer)Date: 2016-06-18 07:37
What is the use case?
msg268797 -(view)Author: Jeroen Demeyer (jdemeyer)*(Python triager)Date: 2016-06-18 11:40
My use case is SageMath:http://trac.sagemath.org/ticket/20750
msg268800 -(view)Author: Serhiy Storchaka (serhiy.storchaka)*(Python committer)Date: 2016-06-18 13:06
Interesting. This is very unusual but reasonable use case.
msg268804 -(view)Author: Roundup Robot (python-dev)(Python triager)Date: 2016-06-18 13:48
New changeset0303ab246152 by Serhiy Storchaka in branch 'default':Issue#27177: Match objects in the re module now support index-like objectshttps://hg.python.org/cpython/rev/0303ab246152
History
DateUserActionArgs
2022-04-11 14:58:31adminsetgithub: 71364
2016-06-18 14:13:40serhiy.storchakasetstatus: open -> closed
resolution: fixed
stage: needs patch -> resolved
2016-06-18 13:48:29python-devsetnosy: +python-dev
messages: +msg268804
2016-06-18 13:06:55serhiy.storchakasetassignee:serhiy.storchaka
messages: +msg268800
2016-06-18 11:40:28jdemeyersetmessages: +msg268797
2016-06-18 07:37:37serhiy.storchakasetmessages: +msg268775
2016-06-15 07:02:13xiang.zhangsetfiles: +issue27177.patch
nosy: +xiang.zhang
messages: +msg268606

2016-06-02 14:00:55mrabarnettsetmessages: +msg266885
2016-06-02 12:35:59jdemeyersetmessages: +msg266884
2016-06-01 16:35:13serhiy.storchakasetversions: + Python 3.6, - Python 2.7
nosy: +serhiy.storchaka

messages: +msg266822

type: enhancement
stage: needs patch
2016-06-01 14:20:08jdemeyercreate
Supported byThe Python Software Foundation,
Powered byRoundup
Copyright © 1990-2022,Python Software Foundation
Legal Statements

[8]ページ先頭

©2009-2026 Movatter.jp