[WIP] gh-89621: re.subn?(): raise error when RegexFlag is wrongly used as count argument #91477
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.
@serhiy-storchaka
In
re.subn?()functions, some users wrongly useRegexFlagas thecountparameter.Many invalid bug reports can be found (#89621, #86639, #85930, #85830, #79724, #75110, #73091, #72038, #70542, #66949, #61863, #59972, #56287, #56166, #56156, #55471). Maybe there are some code still generating incorrect data silently.
This PR is just a draft, not completive. I didn't expect this PR to be merged.
See if you agree with this method. Compared to changing
countto a keyword only parameter, it keeps compatibility, and the overhead is very small.If you want to make a better PR, please make it.
IMO making such PR is faster & easier than reviewing.
Or let me know if you want me to perfect this PR.