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
9b7538c2
Commit
9b7538c2
authored
Dec 19, 2007
by
Raymond Hettinger
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix issue 1661: Flags argument silently ignored in re functions with compiled regexes.
parent
3b4902e2
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
10 additions
and
0 deletions
+10
-0
Lib/re.py
Lib/re.py
+2
-0
Lib/test/test_re.py
Lib/test/test_re.py
+8
-0
No files found.
Lib/re.py
View file @
9b7538c2
...
...
@@ -224,6 +224,8 @@ def _compile(*key):
return
p
pattern
,
flags
=
key
if
isinstance
(
pattern
,
_pattern_type
):
if
flags
:
raise
ValueError
(
'Cannot process flags argument with a compiled pattern'
)
return
pattern
if
not
sre_compile
.
isstring
(
pattern
):
raise
TypeError
,
"first argument must be string or compiled pattern"
...
...
Lib/test/test_re.py
View file @
9b7538c2
...
...
@@ -108,6 +108,14 @@ class ReTests(unittest.TestCase):
self.assertEqual(z, y)
self.assertEqual(type(z), type(y))
def test_bug_1661(self):
# Verify that flags do not get silently ignored with compiled patterns
pattern = re.compile('
.
')
self.assertRaises(ValueError, re.match, pattern, '
A
', re.I)
self.assertRaises(ValueError, re.search, pattern, '
A
', re.I)
self.assertRaises(ValueError, re.findall, pattern, '
A
', re.I)
self.assertRaises(ValueError, re.compile, pattern, re.I)
def test_sub_template_numeric_escape(self):
# bug 776311 and friends
self.assertEqual(re.sub('
x
', r'
\
0
', '
x
'), '
\
0
')
...
...
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