diff options
author | Serhiy Storchaka <storchaka@gmail.com> | 2018-10-05 17:53:45 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-10-05 17:53:45 (GMT) |
commit | 491974735c51141019ae4ef0492e63a8eb716636 (patch) | |
tree | 5e2014dc39c5ff5b4d617504e04541a728039160 /Lib/sre_compile.py | |
parent | 6f9c55d1c0bb399911ded00bb6b3e6f43a514ea2 (diff) | |
download | cpython-491974735c51141019ae4ef0492e63a8eb716636.zip cpython-491974735c51141019ae4ef0492e63a8eb716636.tar.gz cpython-491974735c51141019ae4ef0492e63a8eb716636.tar.bz2 |
Simplify flags checks in sre_compile.py. (GH-9718)
Flags SRE_FLAG_UNICODE and SRE_FLAG_ASCII are mutually exclusive.
Diffstat (limited to 'Lib/sre_compile.py')
-rw-r--r-- | Lib/sre_compile.py | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/Lib/sre_compile.py b/Lib/sre_compile.py index 3667042..c6398bf 100644 --- a/Lib/sre_compile.py +++ b/Lib/sre_compile.py @@ -80,7 +80,7 @@ def _compile(code, pattern, flags): tolower = None fixes = None if flags & SRE_FLAG_IGNORECASE and not flags & SRE_FLAG_LOCALE: - if flags & SRE_FLAG_UNICODE and not flags & SRE_FLAG_ASCII: + if flags & SRE_FLAG_UNICODE: iscased = _sre.unicode_iscased tolower = _sre.unicode_tolower fixes = _ignorecase_fixes @@ -196,7 +196,7 @@ def _compile(code, pattern, flags): av = AT_MULTILINE.get(av, av) if flags & SRE_FLAG_LOCALE: av = AT_LOCALE.get(av, av) - elif (flags & SRE_FLAG_UNICODE) and not (flags & SRE_FLAG_ASCII): + elif flags & SRE_FLAG_UNICODE: av = AT_UNICODE.get(av, av) emit(av) elif op is BRANCH: @@ -217,7 +217,7 @@ def _compile(code, pattern, flags): emit(op) if flags & SRE_FLAG_LOCALE: av = CH_LOCALE[av] - elif (flags & SRE_FLAG_UNICODE) and not (flags & SRE_FLAG_ASCII): + elif flags & SRE_FLAG_UNICODE: av = CH_UNICODE[av] emit(av) elif op is GROUPREF: @@ -265,7 +265,7 @@ def _compile_charset(charset, flags, code): elif op is CATEGORY: if flags & SRE_FLAG_LOCALE: emit(CH_LOCALE[av]) - elif (flags & SRE_FLAG_UNICODE) and not (flags & SRE_FLAG_ASCII): + elif flags & SRE_FLAG_UNICODE: emit(CH_UNICODE[av]) else: emit(av) @@ -453,7 +453,7 @@ def _generate_overlap_table(prefix): def _get_iscased(flags): if not flags & SRE_FLAG_IGNORECASE: return None - elif flags & SRE_FLAG_UNICODE and not flags & SRE_FLAG_ASCII: + elif flags & SRE_FLAG_UNICODE: return _sre.unicode_iscased else: return _sre.ascii_iscased |