]> 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:59 +0000 (19:01 +0000)
committerChristian Heimes <christian@cheimes.de>
Sun, 27 Jan 2008 19:01:59 +0000 (19:01 +0000)
Lib/optparse.py

index 4fbe0947e346f43aedad6d75a875c767ede91348..5aa3b967b07a484ce65a00f1fb3647aaf5dd220e 100644 (file)
@@ -823,11 +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: