This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: Weak deprecations for inline regular expression modifiers
Type: behavior Stage: resolved
Components: Library (Lib), Regular Expressions Versions: Python 3.7, Python 3.6
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: ezio.melotti, mrabarnett, rhettinger, serhiy.storchaka
Priority: normal Keywords:

Created on 2017-05-07 14:39 by serhiy.storchaka, last changed 2022-04-11 14:58 by admin. This issue is now closed.

Pull Requests
URL Status Linked Edit
PR 1490 merged serhiy.storchaka, 2017-05-07 14:53
PR 1525 merged serhiy.storchaka, 2017-05-10 03:10
Messages (5)
msg293197 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2017-05-07 14:39
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.
msg293203 - (view) Author: Raymond Hettinger (rhettinger) * (Python committer) Date: 2017-05-07 17:41
LGTM
msg293372 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2017-05-10 03:05
New changeset 305ccbe27ea5ba82fd2d8c32ec739f980e524330 by Serhiy Storchaka in branch 'master':
bpo-30298: Weaken the condition of deprecation warnings for inline modifiers. (#1490)
https://github.com/python/cpython/commit/305ccbe27ea5ba82fd2d8c32ec739f980e524330
msg293374 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2017-05-10 03:44
New changeset 418d60a52579b6847776db3e354a8660b26dc752 by Serhiy Storchaka in branch '3.6':
[3.6] bpo-30298: Weaken the condition of deprecation warnings for inline modifiers. (GH-1490) (#1525)
https://github.com/python/cpython/commit/418d60a52579b6847776db3e354a8660b26dc752
msg293375 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2017-05-10 03:44
Thanks Raymond.
History
Date User Action Args
2022-04-11 14:58:46adminsetgithub: 74484
2017-05-10 03:44:51serhiy.storchakasetstatus: open -> closed
resolution: fixed
messages: + msg293375

stage: patch review -> resolved
2017-05-10 03:44:04serhiy.storchakasetmessages: + msg293374
2017-05-10 03:10:06serhiy.storchakasetpull_requests: + pull_request1624
2017-05-10 03:05:22serhiy.storchakasetmessages: + msg293372
2017-05-07 17:41:41rhettingersetnosy: + rhettinger
messages: + msg293203
2017-05-07 14:53:07serhiy.storchakasetpull_requests: + pull_request1592
2017-05-07 14:39:18serhiy.storchakacreate