-
-
Notifications
You must be signed in to change notification settings - Fork 31.1k
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
re: DeprecationWarning for flag not at the start of expression
is cutoff too early
#83575
Comments
The usage of flags not at the start of an expression is deprecated. Also see "Deprecate the use of flags not at the start of regular expression" / https://bugs.python.org/issue22493 A deprecation warning is issued, but is cutoff at 20 characters. For complex expressions this is way too small. Example ( jedie/python-creole#31 ): current output /home/jugmac00/Projects/bliss_deployment/work//home/jugmac00/.batou-shared-eggs/python_creole-1.3.2-py3.7.egg/creole/parser/creol2html_parser.py:48 output with patched sre_parse.py creole/parser/creol2html_parser.py:51 (Line number differs because there was a change in the source between these two test runs). I would like to create a pr and remove the limitation to 20 characters completely, but wanted to get feedback before I do so. The deprecation warning was created by Tim Graham - maybe he could elaborate why it was cut at 20 chars at first? |
Why do you want to output the full regular expression? Is not source file path, line number, and starting 20 characters not enough to identify the affected regular expression? |
flag not at the start of expression
is cutoff too earlyflag not at the start of expression
is cutoff too early
flag not at the start of expression
is cutoff too earlyflag not at the start of expression
is cutoff too early
The current output gives no clue about which flag is problematic, nor does it show the complete output (which at least would include the problematic flag), nor does it show the exact line, as it refers only to the line where compile gets called. The warning points to following line ( https://github.com/jedie/python-creole/blob/4e74f29daaf5026a3d4d6dae9f2e74f5f3655439/creole/parser/creol2html_parser.py#L49-L50 ): cell_re = re.compile(SpecialRules.cell, re.VERBOSE | re.UNICODE) And SpecialRules.cell is a quite a big class ( https://github.com/jedie/python-creole/blob/4e74f29daaf5026a3d4d6dae9f2e74f5f3655439/creole/parser/creol2html_rules.py#L16-L97 ) defining lots of partial expressions. Even if spotting this line ( https://github.com/jedie/python-creole/blob/4e74f29daaf5026a3d4d6dae9f2e74f5f3655439/creole/parser/creol2html_rules.py#L54 ) at the first glance it looks like it starts with the flag and should be correct (but is not as it turned out later).
It definitely was not enough for me (new to this code base as I only tried to report deprecation warnings in my application), and when you have a look at the comment ( jedie/python-creole#31 (comment) ) it even was not enough for the author/maintainer of this package. Do you expect any downside of printing the complete warning? |
I have to admit that I find the truncated version more readable. Some sort of truncation is useful, as a regex could be thousands of character long. Adding the offset to the warning message seems like a useful addition. |
This warning was introduced in 3.6. It is a time to convert it into an error. RE error messages contain position. But I understand that very few users will use 3.11 in nearest future, so I am going to add a position to warning message and backport this change. It is not a bugfix in strong meaning, but I think it is safe to backport it. |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: