Issue 30363: Backport warnings in the re module to 2.7 (original) (raw)

The life of 2.7 is so long that our common practice of releasing one or two versions with warnings before removing a feature or changing the behavior in incompatible way doesn't work. People that will start porting to Python 3 in 2020 will be surprised.

Proposed patch backports warnings in the re module to 2.7 in py3k mode. Some of these warnings already are converted to errors, but the most important warnings are warnings about changing semantic. '\u' and '\U' have different meaning in 3.3+ (see ). re.split() with potentially empty pattern now emits FutureWarning and will change the behavior in future versions (see ).

Warnings about inline flags occurred not at the start of the regular expression (see and ) was not backported. Adding them requires changing the fnmatch module, non-trivially changing distutils, and likely will break third-party libraries.

Warnings are emitted only when Python is ran with the -3 option, and it is easy to fix regular expressions.