Skip to content

bpo-34294: re module, fix wrong capturing groups in rare cases #11546

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

Merged
merged 5 commits into from Feb 18, 2019
Merged

bpo-34294: re module, fix wrong capturing groups in rare cases #11546

merged 5 commits into from Feb 18, 2019

Conversation

ghost
Copy link

@ghost ghost commented Jan 14, 2019

  • Failed SRE(match) doesn't reset capturing groups, we need to reset them between two SRE(match) callings in loops. Otherwise the previous SRE(match)'s capturing groups may intrude upon the current SRE(match).
  • Add a missing index in re.rst

https://bugs.python.org/issue34294

@ghost ghost changed the title bpo-34294: in re module, reset state when must_advance bpo-34294: in re module, fix wrong capturing groups when advancing inside a match Jan 14, 2019
@ghost ghost changed the title bpo-34294: in re module, fix wrong capturing groups when advancing inside a match bpo-34294: in re module, fix wrong capturing groups when advancing inside a search Jan 15, 2019
@ghost ghost changed the title bpo-34294: in re module, fix wrong capturing groups when advancing inside a search bpo-34294: in re module, fix wrong capturing groups when must_advance attempt fails. Jan 18, 2019
@ghost ghost changed the title bpo-34294: in re module, fix wrong capturing groups when must_advance attempt fails. bpo-34294: in re module, fix wrong capturing groups in SRE(search) function. Jan 21, 2019
Need to reset capturing groups between two `SRE(match)` callings in loops, this fixes wrong capturing groups in rare cases.

Other changes in this commit:
* Emit `SRE_ERROR_STATE` when reach impossible code path, rather than return a match failure silently.
* Add two test-cases to `test_zerowidth()`.
* Add a missing index in `re.rst`.
* Remove an outdated FIXME comment in `_sre.c`.
@ghost ghost changed the title bpo-34294: in re module, fix wrong capturing groups in SRE(search) function. bpo-34294: re module, fix wrong capturing groups in rare cases Jan 23, 2019
@serhiy-storchaka serhiy-storchaka self-requested a review February 18, 2019 08:21
@serhiy-storchaka
Copy link
Member

LGTM. Just rewrite a news entry.

@serhiy-storchaka serhiy-storchaka merged commit 4a7f44a into python:master Feb 18, 2019
@serhiy-storchaka serhiy-storchaka added type-bug An unexpected behavior, bug, or error needs backport to 3.7 labels Feb 18, 2019
@miss-islington
Copy link
Contributor

Thanks @animalize for the PR, and @serhiy-storchaka for merging it 🌮🎉.. I'm working now to backport this PR to: 3.7.
🐍🍒⛏🤖

miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Feb 18, 2019
…onGH-11546)

Need to reset capturing groups between two SRE(match) callings in loops, this fixes wrong capturing groups in rare cases.

Also add a missing index in re.rst.
(cherry picked from commit 4a7f44a)

Co-authored-by: animalize <[email protected]>
@bedevere-bot
Copy link

GH-11919 is a backport of this pull request to the 3.7 branch.

miss-islington added a commit that referenced this pull request Feb 18, 2019
…1546)

Need to reset capturing groups between two SRE(match) callings in loops, this fixes wrong capturing groups in rare cases.

Also add a missing index in re.rst.
(cherry picked from commit 4a7f44a)

Co-authored-by: animalize <[email protected]>
@ghost ghost deleted the fix_re branch February 18, 2019 14:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type-bug An unexpected behavior, bug, or error
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants