summaryrefslogtreecommitdiff
path: root/Lib/sre_parse.py
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2014-12-01 11:50:07 +0200
committerSerhiy Storchaka <storchaka@gmail.com>2014-12-01 11:50:07 +0200
commit22a309a43458eab762c0d0cf508ff6807fc9b980 (patch)
treeaa14c89df35108d8ba5c22f254e739687816c664 /Lib/sre_parse.py
parent720b8c9dd7e0d8f7e9a879cb3a2669db9eb506e1 (diff)
downloadcpython-git-22a309a43458eab762c0d0cf508ff6807fc9b980.tar.gz
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.py10
1 files changed, 10 insertions, 0 deletions
diff --git a/Lib/sre_parse.py b/Lib/sre_parse.py
index 8d9a09a860..1a7d316253 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):