Fix unix-ffi/re: Fix OverflowError in re.groups().#1089
Open
Josverl wants to merge 2 commits intomicropython:masterfrom
Open
Fix unix-ffi/re: Fix OverflowError in re.groups().#1089Josverl wants to merge 2 commits intomicropython:masterfrom
Josverl wants to merge 2 commits intomicropython:masterfrom
Conversation
Fixes: micropython/micropython#18877 Signed-off-by: Jos Verlinde <jos_verlinde@hotmail.com>
Signed-off-by: Jos Verlinde <jos_verlinde@hotmail.com>
Member
|
Thanks for this, the fix looks good! Can I suggest adding more tests, ie: m = re.match(r"(.)?", "")
assert m.group() == ""
assert m.group(0, 1) == ("", None)
assert m.groups() == (None,)
assert m.groups("default") == ("default",)That will test |
Contributor
Author
|
Sure, happy to add. I noticed that the readme mentions 'unsupported' for the unix-ffi folder, and I do not think these modules are included in CI testing either. So AFIKT the tests need to be run manually, so still useful for validating. |
Member
I think it is run under CI, see |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adjust the
re.groups()methods to properly handle thePCRE2_UNSETvalue for unmatched optional groups.This change prevents
OverflowErrorwhen callinggroups()on a match with no content.The return matches CPython's.
A test case for an empty string match has been added to verify expected behavior.
Fixes micropython/micropython#18877