New submission from Serhiy Storchaka: There is a difference between handling inline modifiers in regular expressions between Python and all other regular expression engines that support inline modifiers. In other engines an inline modifier affect only the part of the pattern after it. It Python it affects also the part before it. For avoiding possible confusion and for removing this difference in distant future, using inline modifiers not at the start of the pattern was deprecated in 3.6 (see issue22493).
But the condition for raising a warning is too strong. It allows using '(?is)...', but '(?i)(?s)...' emits a warning. This makes hard modifying regular expressions by prefixing them with inline modifiers. This condition is unjustifiably strong because '(?i)(?s)...' doesn't have any ambiguity. It also disallows ' (?i)...' in verbose mode despite the fact that whitespaces are not significant in verbose mode. Proposed patch weaks the condition of deprecation warnings. It allows using several subsequent inline modifiers at the start of the pattern and ignores whitespaces in verbose mode. ---------- components: Library (Lib), Regular Expressions messages: 293197 nosy: ezio.melotti, mrabarnett, serhiy.storchaka priority: normal severity: normal stage: patch review status: open title: Weak deprecations for inline regular expression modifiers type: behavior versions: Python 3.6, Python 3.7 _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue30298> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com