[New-bugs-announce] [issue39394] DeprecationWarning for `flag not at the start of expression` is cutoff too early

Jürgen Gmach report at bugs.python.org
Mon Jan 20 05:44:04 EST 2020


New submission from Jürgen Gmach <juergen.gmach at googlemail.com>:

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 ( https://github.com/jedie/python-creole/issues/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
  /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: DeprecationWarning: Flags not at the start of the expression '(?P<image>\n         ' (truncated)
    re.VERBOSE | re.UNICODE


output with patched sre_parse.py

creole/parser/creol2html_parser.py:51
  /home/jugmac00/Projects/python-creole/creole/parser/creol2html_parser.py:51: DeprecationWarning: Flags not at the start of the expression '\n            \\| \\s*\n            (\n                (?P<head> [=][^|]+ ) |\n                (?P<cell> (  (?P<link>\n            \\[\\[\n            (?P<link_target>.+?) \\s*\n            ([|] \\s* (?P<link_text>.+?) \\s*)?\n            ]]\n        )|\n        (?P<macro_inline>\n        << \\s* (?P<macro_inline_start>\\w+) \\s* (?P<macro_inline_args>.*?) \\s* >>\n        (?P<macro_inline_text>(.|\\n)*?)\n        <</ \\s* (?P=macro_inline_start) \\s* >>\n        )\n    |(?P<macro_tag>\n            <<(?P<macro_tag_name> \\w+) (?P<macro_tag_args>.*?) \\s* /*>>\n        )|(?i)(?P<image>\n            {{\n            (?P<image_target>.+?) \\s*\n            (\\| \\s* (?P<image_text>.+?) \\s*)?\n            }}\n        )|(?P<pre_inline> {{{ (?P<pre_inline_text>.*?) }}} ) | [^|])+ )\n            ) \\s*\n        '
    cell_re = re.compile(x, re.VERBOSE | re.UNICODE)


(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?
https://github.com/python/cpython/commit/abf275af5804c5f76fbe10c5cb1dd3d2e4b04c5b

----------
components: Regular Expressions
messages: 360306
nosy: ezio.melotti, jugmac00, mrabarnett
priority: normal
severity: normal
status: open
title: DeprecationWarning for `flag not at the start of expression` is cutoff too early
type: enhancement
versions: Python 3.7, Python 3.8, Python 3.9

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue39394>
_______________________________________


More information about the New-bugs-announce mailing list