]> granicus.if.org Git - python/commitdiff
Change isbasestring function as discussed on the cvs list a while ago
authorChristian Heimes <christian@cheimes.de>
Sun, 27 Jan 2008 19:01:45 +0000 (19:01 +0000)
committerChristian Heimes <christian@cheimes.de>
Sun, 27 Jan 2008 19:01:45 +0000 (19:01 +0000)
Lib/optparse.py

index 4fbe0947e346f43aedad6d75a875c767ede91348..b4a17080210f7da9d8c88a5dd108a6a5d1e2412b 100644 (file)
@@ -823,12 +823,14 @@ try:
 except NameError:
     (True, False) = (1, 0)
 
-def isbasestring(x):
-    try:
+try:
+    basestring
+except NameError:
+    def isbasestring(x):
+        return isinstance(x, (types.StringType, types.UnicodeType))
+else:
+    def isbasestring(x):
         return isinstance(x, basestring)
-    except:
-        return isinstance(x, types.StringType) or isinstance(x, types.UnicodeType)
-
 
 class Values: