mirror of
https://github.com/python/cpython.git
synced 2025-08-31 05:58:33 +00:00
Addendum to #764548: restore 2.1 compatibility.
This commit is contained in:
parent
12723bacea
commit
74902508dc
2 changed files with 9 additions and 3 deletions
|
@ -431,10 +431,16 @@ def _compile_info(code, pattern, flags):
|
|||
try:
|
||||
unicode
|
||||
except NameError:
|
||||
STRING_TYPES = type("")
|
||||
STRING_TYPES = (type(""),)
|
||||
else:
|
||||
STRING_TYPES = (type(""), type(unicode("")))
|
||||
|
||||
def isstring(obj):
|
||||
for tp in STRING_TYPES:
|
||||
if isinstance(obj, tp):
|
||||
return 1
|
||||
return 0
|
||||
|
||||
def _code(p, flags):
|
||||
|
||||
flags = p.pattern.flags | flags
|
||||
|
@ -453,7 +459,7 @@ def _code(p, flags):
|
|||
def compile(p, flags=0):
|
||||
# internal: convert pattern list to internal format
|
||||
|
||||
if isinstance(p, STRING_TYPES):
|
||||
if isstring(p):
|
||||
import sre_parse
|
||||
pattern = p
|
||||
p = sre_parse.parse(p, flags)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue