diff --git a/Lib/optparse.py b/Lib/optparse.py index 4fbe0947e34..5aa3b967b07 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: