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
Use re.fullmatch #750
Comments
@cdrini Your review, please. |
Ah ok, if I understand the problem correctly, in python <3.11 this would work: re.compile(r'^(?i)hello').match('HELLO')
# Equivalent to:
re.compile(r'^hello', re.IGNORECASE).match('HELLO') Now, the first example throws an error in 3.11 since Because web.py does manual modification or regex patterns (like |
The proposed solution is to change from using things like |
Ah but the sub case is trickier since there is no equivalent fn like fullmatch... |
I can't think of anything else! The proposed fix for subm seems reasonable. I love how it correctly handles the case where the regex already has |
We have an app where we have been setting global flags in the URL pattern with a prefix like
(?i)
or(?s)
. It has worked well until recently with Python 3.11 where there
module throws an error that the global flags must be set at the beginning of the pattern. I tracked this down to the fact that webpy is blindly modifying the pattern with anchors like^
pattern\Z
and there
module no longer tolerates the anchor (or any other pattern text) coming before the flags.This can be fixed in application.py by replacing this call:
with the equivalent:
This allows legal patterns with globals to be passed successfully, without adding any complexity to actually parse/split the pattern and add anchor after the globals.
I also see two other calls with the
re_subm
utility function. These look like:Since there isn't a variant of
sub
comparable tofullmatch
to require a full match without adding anchors to the pattern, you'd have to add something uglier if you want to allow flags here. For example, you can then introduce anchors that won't break the pattern:The text was updated successfully, but these errors were encountered: