diff options
author | Just van Rossum <just@letterror.com> | 2003-07-02 21:37:16 (GMT) |
---|---|---|
committer | Just van Rossum <just@letterror.com> | 2003-07-02 21:37:16 (GMT) |
commit | 74902508dc395014dbdb9c2ed08263202e5d4e30 (patch) | |
tree | 81b32a9694015a6f76965a6c18b50aa37665c516 /Lib/sre_compile.py | |
parent | 12723baceab61f8812d68575c962696cc4e77fa1 (diff) | |
download | cpython-74902508dc395014dbdb9c2ed08263202e5d4e30.zip cpython-74902508dc395014dbdb9c2ed08263202e5d4e30.tar.gz cpython-74902508dc395014dbdb9c2ed08263202e5d4e30.tar.bz2 |
Addendum to #764548: restore 2.1 compatibility.
Diffstat (limited to 'Lib/sre_compile.py')
-rw-r--r-- | Lib/sre_compile.py | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/Lib/sre_compile.py b/Lib/sre_compile.py index 96f337a..8a26a0f 100644 --- a/Lib/sre_compile.py +++ b/Lib/sre_compile.py @@ -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) |