mirror of
https://github.com/python/cpython.git
synced 2025-09-26 10:19:53 +00:00
Don't use StringType -- always test for basestring.
This commit is contained in:
parent
7fcf224ec8
commit
c2b87a6dff
1 changed files with 3 additions and 3 deletions
|
@ -823,7 +823,7 @@ except NameError:
|
||||||
(True, False) = (1, 0)
|
(True, False) = (1, 0)
|
||||||
|
|
||||||
def isbasestring(x):
|
def isbasestring(x):
|
||||||
return isinstance(x, types.StringType) or isinstance(x, types.UnicodeType)
|
return isinstance(x, basestring)
|
||||||
|
|
||||||
class Values:
|
class Values:
|
||||||
|
|
||||||
|
@ -1001,7 +1001,7 @@ class OptionContainer:
|
||||||
"""add_option(Option)
|
"""add_option(Option)
|
||||||
add_option(opt_str, ..., kwarg=val, ...)
|
add_option(opt_str, ..., kwarg=val, ...)
|
||||||
"""
|
"""
|
||||||
if type(args[0]) is types.StringType:
|
if isbasestring(args[0]):
|
||||||
option = self.option_class(*args, **kwargs)
|
option = self.option_class(*args, **kwargs)
|
||||||
elif len(args) == 1 and not kwargs:
|
elif len(args) == 1 and not kwargs:
|
||||||
option = args[0]
|
option = args[0]
|
||||||
|
@ -1312,7 +1312,7 @@ class OptionParser (OptionContainer):
|
||||||
|
|
||||||
def add_option_group(self, *args, **kwargs):
|
def add_option_group(self, *args, **kwargs):
|
||||||
# XXX lots of overlap with OptionContainer.add_option()
|
# XXX lots of overlap with OptionContainer.add_option()
|
||||||
if type(args[0]) is types.StringType:
|
if isbasestring(args[0]):
|
||||||
group = OptionGroup(self, *args, **kwargs)
|
group = OptionGroup(self, *args, **kwargs)
|
||||||
elif len(args) == 1 and not kwargs:
|
elif len(args) == 1 and not kwargs:
|
||||||
group = args[0]
|
group = args[0]
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue