diff options
author | Serhiy Storchaka <storchaka@gmail.com> | 2014-12-01 09:50:07 (GMT) |
---|---|---|
committer | Serhiy Storchaka <storchaka@gmail.com> | 2014-12-01 09:50:07 (GMT) |
commit | 22a309a43458eab762c0d0cf508ff6807fc9b980 (patch) | |
tree | aa14c89df35108d8ba5c22f254e739687816c664 /Lib/sre_parse.py | |
parent | 720b8c9dd7e0d8f7e9a879cb3a2669db9eb506e1 (diff) | |
download | cpython-22a309a43458eab762c0d0cf508ff6807fc9b980.zip cpython-22a309a43458eab762c0d0cf508ff6807fc9b980.tar.gz cpython-22a309a43458eab762c0d0cf508ff6807fc9b980.tar.bz2 |
Issue #21032: Deprecated the use of re.LOCALE flag with str patterns or
re.ASCII. It was newer worked.
Diffstat (limited to 'Lib/sre_parse.py')
-rw-r--r-- | Lib/sre_parse.py | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/Lib/sre_parse.py b/Lib/sre_parse.py index 8d9a09a..1a7d316 100644 --- a/Lib/sre_parse.py +++ b/Lib/sre_parse.py @@ -751,6 +751,11 @@ def _parse(source, state): def fix_flags(src, flags): # Check and fix flags according to the type of pattern (str or bytes) if isinstance(src, str): + if flags & SRE_FLAG_LOCALE: + import warnings + warnings.warn("LOCALE flag with a str pattern is deprecated. " + "Will be an error in 3.6", + DeprecationWarning, stacklevel=6) if not flags & SRE_FLAG_ASCII: flags |= SRE_FLAG_UNICODE elif flags & SRE_FLAG_UNICODE: @@ -758,6 +763,11 @@ def fix_flags(src, flags): else: if flags & SRE_FLAG_UNICODE: raise ValueError("can't use UNICODE flag with a bytes pattern") + if flags & SRE_FLAG_LOCALE and flags & SRE_FLAG_ASCII: + import warnings + warnings.warn("ASCII and LOCALE flags are incompatible. " + "Will be an error in 3.6", + DeprecationWarning, stacklevel=6) return flags def parse(str, flags=0, pattern=None): |