Author serhiy.storchaka
Recipients ezio.melotti, mrabarnett, serhiy.storchaka
Date 2017-05-15.19:47:50
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1494877670.21.0.548090172972.issue30375@psf.upfronthosting.co.za>
In-reply-to
Content
When compile a regular expression with groups or conditionals emitted warnings point on lines in the re module implementation rather than the line in user code.

>>> import re
>>> re.compile('x(?i)')
__main__:1: DeprecationWarning: Flags not at the start of the expression x(?i)
re.compile('x(?i)', re.IGNORECASE)
>>> re.compile('(x(?i))')
/home/serhiy/py/cpython/Lib/re.py:281: DeprecationWarning: Flags not at the start of the expression (x(?i))
  p = sre_compile.compile(pattern, flags)
re.compile('(x(?i))', re.IGNORECASE)
>>> re.compile('((x(?i)))')
/home/serhiy/py/cpython/Lib/sre_parse.py:889: DeprecationWarning: Flags not at the start of the expression ((x(?i)))
  p = _parse_sub(source, pattern, flags & SRE_FLAG_VERBOSE, False)
re.compile('((x(?i)))', re.IGNORECASE)

Proposed patch fixes this:

>>> import re
>>> re.compile('x(?i)')
__main__:1: DeprecationWarning: Flags not at the start of the expression x(?i)
re.compile('x(?i)', re.IGNORECASE)
>>> re.compile('(x(?i))')
__main__:1: DeprecationWarning: Flags not at the start of the expression (x(?i))
re.compile('(x(?i))', re.IGNORECASE)
>>> re.compile('((x(?i)))')
__main__:1: DeprecationWarning: Flags not at the start of the expression ((x(?i)))
re.compile('((x(?i)))', re.IGNORECASE)
History
Date User Action Args
2017-05-15 19:47:50serhiy.storchakasetrecipients: + serhiy.storchaka, ezio.melotti, mrabarnett
2017-05-15 19:47:50serhiy.storchakasetmessageid: <1494877670.21.0.548090172972.issue30375@psf.upfronthosting.co.za>
2017-05-15 19:47:50serhiy.storchakalinkissue30375 messages
2017-05-15 19:47:50serhiy.storchakacreate