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

2020-01-20 Thread Serhiy Storchaka


Serhiy Storchaka  added the comment:

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?

--
nosy: +serhiy.storchaka

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



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

2020-01-20 Thread Jürgen Gmach

New submission from Jürgen Gmach :

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\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 [=][^|]+ ) |\n
(?P (  (?P\n\\[\\[\n(?P.+?) 
\\s*\n([|] \\s* (?P.+?) \\s*)?\n]]\n
)|\n(?P\n<< \\s* (?P\\w+) 
\\s* (?P.*?) \\s* >>\n
(?P(.|\\n)*?)\n<>\n)\n|(?P\n<<(?P \\w+) 
(?P.*?) \\s* /*>>\n)|(?i)(?P\n{{\n   
 (?P.+?) \\s*\n(\\| \\s* (?P.+?) 
\\s*)?\n}}\n)|(?P {{{ (?P.*?) 
}}} ) | [^|])+ )\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 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com