[Python-checkins] r55123 - python/branches/py3k-struni/Lib/optparse.py

guido.van.rossum python-checkins at python.org
Fri May 4 19:44:49 CEST 2007


Author: guido.van.rossum
Date: Fri May  4 19:44:47 2007
New Revision: 55123

Modified:
   python/branches/py3k-struni/Lib/optparse.py
Log:
Don't use StringType -- always test for basestring.


Modified: python/branches/py3k-struni/Lib/optparse.py
==============================================================================
--- python/branches/py3k-struni/Lib/optparse.py	(original)
+++ python/branches/py3k-struni/Lib/optparse.py	Fri May  4 19:44:47 2007
@@ -823,7 +823,7 @@
     (True, False) = (1, 0)
 
 def isbasestring(x):
-    return isinstance(x, types.StringType) or isinstance(x, types.UnicodeType)
+    return isinstance(x, basestring)
 
 class Values:
 
@@ -1001,7 +1001,7 @@
         """add_option(Option)
            add_option(opt_str, ..., kwarg=val, ...)
         """
-        if type(args[0]) is types.StringType:
+        if isbasestring(args[0]):
             option = self.option_class(*args, **kwargs)
         elif len(args) == 1 and not kwargs:
             option = args[0]
@@ -1312,7 +1312,7 @@
 
     def add_option_group(self, *args, **kwargs):
         # XXX lots of overlap with OptionContainer.add_option()
-        if type(args[0]) is types.StringType:
+        if isbasestring(args[0]):
             group = OptionGroup(self, *args, **kwargs)
         elif len(args) == 1 and not kwargs:
             group = args[0]


More information about the Python-checkins mailing list