mirror of
https://github.com/python/cpython.git
synced 2025-07-24 11:44:31 +00:00
Fix and test for bug #764548:
Use isinstance() instead of comparing types directly, to enable subclasses of str and unicode to be used as patterns. Blessed by /F.
This commit is contained in:
parent
5e4e39f12a
commit
12723bacea
3 changed files with 17 additions and 7 deletions
|
@ -219,9 +219,9 @@ def _compile(*key):
|
|||
if p is not None:
|
||||
return p
|
||||
pattern, flags = key
|
||||
if type(pattern) is _pattern_type:
|
||||
if isinstance(pattern, _pattern_type):
|
||||
return pattern
|
||||
if type(pattern) not in sre_compile.STRING_TYPES:
|
||||
if not isinstance(pattern, sre_compile.STRING_TYPES):
|
||||
raise TypeError, "first argument must be string or compiled pattern"
|
||||
try:
|
||||
p = sre_compile.compile(pattern, flags)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue