From 74902508dc395014dbdb9c2ed08263202e5d4e30 Mon Sep 17 00:00:00 2001
From: Just van Rossum <just@letterror.com>
Date: Wed, 2 Jul 2003 21:37:16 +0000
Subject: Addendum to #764548: restore 2.1 compatibility.

---
 Lib/sre.py         |  2 +-
 Lib/sre_compile.py | 10 ++++++++--
 2 files changed, 9 insertions(+), 3 deletions(-)

diff --git a/Lib/sre.py b/Lib/sre.py
index 7910c83..ffe2bc3 100644
--- a/Lib/sre.py
+++ b/Lib/sre.py
@@ -221,7 +221,7 @@ def _compile(*key):
     pattern, flags = key
     if isinstance(pattern, _pattern_type):
         return pattern
-    if not isinstance(pattern, sre_compile.STRING_TYPES):
+    if not sre_compile.isstring(pattern):
         raise TypeError, "first argument must be string or compiled pattern"
     try:
         p = sre_compile.compile(pattern, flags)
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)
-- 
cgit v0.12

