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

_sre.SRE_Scanner object should have a fullmatch() method #65201

Closed
GarethGouldstone mannequin opened this issue Mar 21, 2014 · 7 comments
Closed

_sre.SRE_Scanner object should have a fullmatch() method #65201

GarethGouldstone mannequin opened this issue Mar 21, 2014 · 7 comments
Labels
topic-regex type-feature A feature request or enhancement

Comments

@GarethGouldstone
Copy link
Mannequin

GarethGouldstone mannequin commented Mar 21, 2014

BPO 21002
Nosy @Yhg1s, @ezio-melotti, @bitdancer, @serhiy-storchaka, @aeros, @LewisGaul

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 2019-10-27.19:56:21.127>
created_at = <Date 2014-03-21.01:31:17.554>
labels = ['expert-regex', 'type-feature']
title = '_sre.SRE_Scanner object should have a fullmatch() method'
updated_at = <Date 2019-10-27.19:56:21.127>
user = 'https://bugs.python.org/GarethGouldstone'

bugs.python.org fields:

activity = <Date 2019-10-27.19:56:21.127>
actor = 'serhiy.storchaka'
assignee = 'none'
closed = True
closed_date = <Date 2019-10-27.19:56:21.127>
closer = 'serhiy.storchaka'
components = ['Regular Expressions']
creation = <Date 2014-03-21.01:31:17.554>
creator = 'Gareth.Gouldstone'
dependencies = []
files = []
hgrepos = []
issue_num = 21002
keywords = []
message_count = 7.0
messages = ['214317', '214320', '214323', '214337', '355468', '355489', '355500']
nosy_count = 8.0
nosy_names = ['twouters', 'ezio.melotti', 'mrabarnett', 'r.david.murray', 'serhiy.storchaka', 'Gareth.Gouldstone', 'aeros', 'LewisGaul']
pr_nums = []
priority = 'normal'
resolution = 'rejected'
stage = 'resolved'
status = 'closed'
superseder = None
type = 'enhancement'
url = 'https://bugs.python.org/issue21002'
versions = ['Python 3.4', 'Python 3.5']

@GarethGouldstone
Copy link
Mannequin Author

GarethGouldstone mannequin commented Mar 21, 2014

I believe that the SRE_Scanner object should have a .fullmatch() method for consistency with other re pattern-matching behaviour.

>>> rex = re.compile('([^\\W\\d_]{1,2}[0-9]{1,2}[^\\d\\W_]?)[ \\t]*([0-9][^\\d\\W_]{2})')
>>> rex.scanner('bn20bs')
<_sre.SRE_Scanner object at 0x102006400>
>>> rex.scanner('bn20bs').search()                                           
<_sre.SRE_Match object; span=(0, 6), match='bn20bs'>
>>> rex.scanner('bn20bs').match()                                           
<_sre.SRE_Match object; span=(0, 6), match='bn20bs'>
>>> rex.scanner('bn20bs').fullmatch()                                           Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
AttributeError: '_sre.SRE_Scanner' object has no attribute 'fullmatch'

@GarethGouldstone GarethGouldstone mannequin added type-bug An unexpected behavior, bug, or error topic-regex labels Mar 21, 2014
@GarethGouldstone
Copy link
Mannequin Author

GarethGouldstone mannequin commented Mar 21, 2014

I also encountered bpo-20998, which explains the convoluted [^\\W\\d_] in place of [a-zA-Z] as I was investigating why case-insensitivity and quantifiers would not work together.

@bitdancer
Copy link
Member

Scanner isn't a public interface, so the real enhancement here would be to make it one, in which case adding fullmatch would make sense. I don't know if making it public is a good idea or not.

@bitdancer bitdancer added type-feature A feature request or enhancement and removed type-bug An unexpected behavior, bug, or error labels Mar 21, 2014
@GarethGouldstone
Copy link
Mannequin Author

GarethGouldstone mannequin commented Mar 21, 2014

Scanner may not be a public interface but it is widely documented, not least on page 67 of the O'reilly Python Cookbook.

Even if Scanner is not made public, then surely it should maintain consistency with the public interfaces?

@LewisGaul
Copy link
Mannequin

LewisGaul mannequin commented Oct 27, 2019

Scanner is not documented in CPython's own re documentation: https://docs.python.org/3/library/re.html#regular-expression-objects, so I'd say there's no obligation to maintain consistency with public APIs.

Is anyone able to make a call on whether this issue should be closed, or alternatively give some guidance on what work this issue should encompass?

@aeros
Copy link
Contributor

aeros commented Oct 27, 2019

Is anyone able to make a call on whether this issue should be closed, or alternatively give some guidance on what work this issue should encompass?

Added Serhiy to the nosy list, since he's an active maintainer for the re module.

@serhiy-storchaka
Copy link
Member

I concur with David. The SRE_Scanner object is not public. Its search() method is used for implementing finditer(). Its match() method could be useful for implementing a functional equivalent of \G in Perl. But I do not know a use case for its fullmatch() method.

If anybody provide a use case for SRE_Scanner.fullmatch() this issue can be reopened.

@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-feature A feature request or enhancement
Projects
None yet
Development

No branches or pull requests

3 participants