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

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

Merged
merged 5 commits into from Feb 18, 2019

Conversation

animalize
Copy link
Contributor

@animalize animalize 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

@animalize animalize 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
@animalize animalize 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
Modules/sre_lib.h Outdated Show resolved Hide resolved
@animalize animalize force-pushed the fix_re branch 2 times, most recently from a16453e to 69410e5 Compare Jan 18, 2019
@animalize animalize 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
@animalize animalize force-pushed the fix_re branch 3 times, most recently from b989d2e to 6dfdfc5 Compare Jan 21, 2019
@animalize animalize 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`.
@animalize animalize 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 Feb 18, 2019
@serhiy-storchaka
Copy link
Member

serhiy-storchaka commented Feb 18, 2019

LGTM. Just rewrite a news entry.

@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

miss-islington commented Feb 18, 2019

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 <animalize@users.noreply.github.com>
@bedevere-bot
Copy link

bedevere-bot commented Feb 18, 2019

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 <animalize@users.noreply.github.com>
@animalize animalize deleted the fix_re branch Feb 18, 2019
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.

None yet

6 participants