Fix issue 1661: Flags argument silently ignored in re functions with compiled regexes.

This commit is contained in:
Raymond Hettinger 2007-12-19 18:13:31 +00:00
parent 0f5e7bf304
commit 80016c9555
2 changed files with 10 additions and 0 deletions

View file

@ -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"