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
d62ecf51
Commit
d62ecf51
authored
Nov 14, 2016
by
Victor Stinner
Browse files
Options
Browse Files
Download
Plain Diff
Merge 3.6
parents
2294f83c
8bf43e6d
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
27 additions
and
12 deletions
+27
-12
Lib/re.py
Lib/re.py
+21
-12
Lib/test/test_re.py
Lib/test/test_re.py
+6
-0
No files found.
Lib/re.py
View file @
d62ecf51
...
...
@@ -119,6 +119,7 @@ This module also defines an exception 'error'.
"""
import
enum
import
sre_compile
import
sre_parse
import
functools
...
...
@@ -138,18 +139,26 @@ __all__ = [
__version__
=
"2.2.1"
# flags
A
=
ASCII
=
sre_compile
.
SRE_FLAG_ASCII
# assume ascii "locale"
I
=
IGNORECASE
=
sre_compile
.
SRE_FLAG_IGNORECASE
# ignore case
L
=
LOCALE
=
sre_compile
.
SRE_FLAG_LOCALE
# assume current 8-bit locale
U
=
UNICODE
=
sre_compile
.
SRE_FLAG_UNICODE
# assume unicode "locale"
M
=
MULTILINE
=
sre_compile
.
SRE_FLAG_MULTILINE
# make anchors look for newline
S
=
DOTALL
=
sre_compile
.
SRE_FLAG_DOTALL
# make dot match newline
X
=
VERBOSE
=
sre_compile
.
SRE_FLAG_VERBOSE
# ignore whitespace and comments
# sre extensions (experimental, don't rely on these)
T
=
TEMPLATE
=
sre_compile
.
SRE_FLAG_TEMPLATE
# disable backtracking
DEBUG
=
sre_compile
.
SRE_FLAG_DEBUG
# dump pattern after compilation
class
RegexFlag
(
enum
.
IntFlag
):
ASCII
=
sre_compile
.
SRE_FLAG_ASCII
# assume ascii "locale"
IGNORECASE
=
sre_compile
.
SRE_FLAG_IGNORECASE
# ignore case
LOCALE
=
sre_compile
.
SRE_FLAG_LOCALE
# assume current 8-bit locale
UNICODE
=
sre_compile
.
SRE_FLAG_UNICODE
# assume unicode "locale"
MULTILINE
=
sre_compile
.
SRE_FLAG_MULTILINE
# make anchors look for newline
DOTALL
=
sre_compile
.
SRE_FLAG_DOTALL
# make dot match newline
VERBOSE
=
sre_compile
.
SRE_FLAG_VERBOSE
# ignore whitespace and comments
A
=
ASCII
I
=
IGNORECASE
L
=
LOCALE
U
=
UNICODE
M
=
MULTILINE
S
=
DOTALL
X
=
VERBOSE
# sre extensions (experimental, don't rely on these)
TEMPLATE
=
sre_compile
.
SRE_FLAG_TEMPLATE
# disable backtracking
T
=
TEMPLATE
DEBUG
=
sre_compile
.
SRE_FLAG_DEBUG
# dump pattern after compilation
globals
().
update
(
RegexFlag
.
__members__
)
# sre exception
error
=
sre_compile
.
error
...
...
Lib/test/test_re.py
View file @
d62ecf51
...
...
@@ -1771,6 +1771,12 @@ SUBPATTERN None 0 0
self.checkPatternError(r'(?<>)', 'unknown extension ?<>', 1)
self.checkPatternError(r'(?', 'unexpected end of pattern', 2)
def test_enum(self):
# Issue #28082: Check that str(flag) returns a human readable string
# instead of an integer
self.assertIn('ASCII', str(re.A))
self.assertIn('DOTALL', str(re.S))
class PatternReprTests(unittest.TestCase):
def check(self, pattern, expected):
...
...
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