Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
49197473
Commit
49197473
authored
Oct 05, 2018
by
Serhiy Storchaka
Committed by
GitHub
Oct 05, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Simplify flags checks in sre_compile.py. (GH-9718)
Flags SRE_FLAG_UNICODE and SRE_FLAG_ASCII are mutually exclusive.
parent
6f9c55d1
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
5 additions
and
5 deletions
+5
-5
Lib/sre_compile.py
Lib/sre_compile.py
+5
-5
No files found.
Lib/sre_compile.py
View file @
49197473
...
...
@@ -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
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment