From: Christian Heimes Date: Sun, 27 Jan 2008 19:01:59 +0000 (+0000) Subject: Change isbasestring function as discussed on the cvs list a while ago X-Git-Tag: v2.5.2c1~40 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=0b11c5fdf60b22eeed3d77dd31cbd63c6e2e2f12;p=python Change isbasestring function as discussed on the cvs list a while ago --- diff --git a/Lib/optparse.py b/Lib/optparse.py index 4fbe0947e3..5aa3b967b0 100644 --- a/Lib/optparse.py +++ b/Lib/optparse.py @@ -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: