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

re.finditer behaviour in re.MULTILINE mode fails to match first 7 characters #79054

Closed
tdawes mannequin opened this issue Oct 2, 2018 · 2 comments
Closed

re.finditer behaviour in re.MULTILINE mode fails to match first 7 characters #79054

tdawes mannequin opened this issue Oct 2, 2018 · 2 comments
Labels
3.7 (EOL) end of life 3.8 only security fixes topic-regex type-bug An unexpected behavior, bug, or error

Comments

@tdawes
Copy link
Mannequin

tdawes mannequin commented Oct 2, 2018

BPO 34873
Nosy @ezio-melotti

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 2018-10-02.21:32:07.630>
created_at = <Date 2018-10-02.21:29:14.486>
labels = ['expert-regex', '3.8', 'type-bug', '3.7', 'invalid']
title = 're.finditer behaviour in re.MULTILINE mode fails to match first 7 characters'
updated_at = <Date 2018-10-02.21:32:07.628>
user = 'https://bugs.python.org/tdawes'

bugs.python.org fields:

activity = <Date 2018-10-02.21:32:07.628>
actor = 'tdawes'
assignee = 'none'
closed = True
closed_date = <Date 2018-10-02.21:32:07.630>
closer = 'tdawes'
components = ['Regular Expressions']
creation = <Date 2018-10-02.21:29:14.486>
creator = 'tdawes'
dependencies = []
files = []
hgrepos = []
issue_num = 34873
keywords = []
message_count = 2.0
messages = ['326911', '326912']
nosy_count = 3.0
nosy_names = ['ezio.melotti', 'mrabarnett', 'tdawes']
pr_nums = []
priority = 'normal'
resolution = 'not a bug'
stage = 'resolved'
status = 'closed'
superseder = None
type = 'behavior'
url = 'https://bugs.python.org/issue34873'
versions = ['Python 2.7', 'Python 3.4', 'Python 3.5', 'Python 3.6', 'Python 3.7', 'Python 3.8']

@tdawes
Copy link
Mannequin Author

tdawes mannequin commented Oct 2, 2018

re.finditer appears to fail to match within the first 7 characters in a string when re.MULTILINE is used:

>>> REGEX = re.compile("y")
>>> [list(m.start() for m in REGEX.finditer("{}y".format("x"*i), re.MULTILINE)) for i in range(10)]
[[], [], [], [], [], [], [], [], [8], [9]]

Without re.MULTILINE, this works fine:

>>> [list(m.start() for m in REGEX.finditer("{}y".format("x"*i))) for i in range(10)]
[[0], [1], [2], [3], [4], [5], [6], [7], [8], [9]]

Passing re.MULTILINE to re.compile doesn't seem to have any effect.

@tdawes tdawes mannequin added 3.7 (EOL) end of life 3.8 only security fixes topic-regex type-bug An unexpected behavior, bug, or error labels Oct 2, 2018
@tdawes
Copy link
Mannequin Author

tdawes mannequin commented Oct 2, 2018

Please ignore, re.finditer and REGEX.finditer aren't the same. I was passing re.MULTILINE (= 8) to endPos.

@tdawes tdawes mannequin closed this as completed Oct 2, 2018
@tdawes tdawes mannequin added the invalid label Oct 2, 2018
@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
3.7 (EOL) end of life 3.8 only security fixes topic-regex type-bug An unexpected behavior, bug, or error
Projects
None yet
Development

No branches or pull requests

0 participants