From 5b25bc05983c43d1663136bc4ca0e3e472a05c56 Mon Sep 17 00:00:00 2001 From: Christian Heimes Date: Sun, 27 Jan 2008 19:01:45 +0000 Subject: [PATCH] Change isbasestring function as discussed on the cvs list a while ago --- Lib/optparse.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/Lib/optparse.py b/Lib/optparse.py index 4fbe0947e34..b4a17080210 100644 --- a/Lib/optparse.py +++ b/Lib/optparse.py @@ -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: