Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dir of an "_sre.SRE_Match" object not working #47497

Closed
vizcayno mannequin opened this issue Jul 1, 2008 · 3 comments
Closed

dir of an "_sre.SRE_Match" object not working #47497

vizcayno mannequin opened this issue Jul 1, 2008 · 3 comments
Labels
topic-regex type-bug An unexpected behavior, bug, or error

Comments

@vizcayno
Copy link
Mannequin

vizcayno mannequin commented Jul 1, 2008

BPO 3247
Nosy @amauryfa

Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

Show more details

GitHub fields:

assignee = None
closed_at = <Date 2008-07-02.23:07:20.515>
created_at = <Date 2008-07-01.00:10:49.983>
labels = ['expert-regex', 'type-bug']
title = 'dir of an "_sre.SRE_Match" object not working'
updated_at = <Date 2008-07-02.23:07:20.514>
user = 'https://bugs.python.org/vizcayno'

bugs.python.org fields:

activity = <Date 2008-07-02.23:07:20.514>
actor = 'amaury.forgeotdarc'
assignee = 'none'
closed = True
closed_date = <Date 2008-07-02.23:07:20.515>
closer = 'amaury.forgeotdarc'
components = ['Regular Expressions']
creation = <Date 2008-07-01.00:10:49.983>
creator = 'vizcayno'
dependencies = []
files = []
hgrepos = []
issue_num = 3247
keywords = []
message_count = 3.0
messages = ['69031', '69117', '69141']
nosy_count = 2.0
nosy_names = ['amaury.forgeotdarc', 'vizcayno']
pr_nums = []
priority = 'normal'
resolution = 'fixed'
stage = None
status = 'closed'
superseder = None
type = 'behavior'
url = 'https://bugs.python.org/issue3247'
versions = ['Python 3.0']

@vizcayno
Copy link
Mannequin Author

vizcayno mannequin commented Jul 1, 2008

For Windows XP SP3:

v = 'add 1 to 4.56'
import re
r=re.search("([0-9]+)\D+(\d+\.\d+)","add 1 to 4.56")
r
<_sre.SRE_Match object at 0x00BED920>
r.groups()
('1', '4.56')
dir(r)
[]

in pyhton 2.5 it shows:
['__copy__', '__deepcopy__', 'end', 'expand', 'group', 'groupdict', 'gro
ups', 'span', 'start']

@vizcayno vizcayno mannequin added topic-regex type-bug An unexpected behavior, bug, or error labels Jul 1, 2008
@amauryfa
Copy link
Member

amauryfa commented Jul 2, 2008

The cause is that this object use a custom tp_getattr slot, and use
Py_FindMethod from there. and py3k removed the special "__methods__"
lookup that allowed to lists these items.

Of course, nowadays the way to add methods is not to put them in
tp_getattr, but in a tp_methods slot.

@amauryfa
Copy link
Member

amauryfa commented Jul 2, 2008

Done in several changes: r64672 r64674 r64681.

Now the dir() is even more complete than before. I get:
['__class__', '__copy__', '__deepcopy__', '__delattr__', '__doc__',
'__eq__', '__format__', '__ge__', '__getattribute__', '__gt__',
'__hash__', '__init__', '__le__', '__lt__', '__ne__', '__new__',
'__reduce__', '__reduce_ex__', '__repr__','__setattr__', '__sizeof__',
'__str__', '__subclasshook__', 'end', 'endpos', 'expand', 'group',
'groupdict', 'groups', 'lastgroup', 'lastindex', 'pos', 're', 'regs',
'span', 'start', 'string']

@amauryfa amauryfa closed this as completed Jul 2, 2008
@ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
topic-regex type-bug An unexpected behavior, bug, or error
Projects
None yet
Development

No branches or pull requests

1 participant