Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit c2b87a6

Browse files
committed
Don't use StringType -- always test for basestring.
1 parent 7fcf224 commit c2b87a6

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

Lib/optparse.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -823,7 +823,7 @@ def take_action(self, action, dest, opt, value, values, parser):
823823
(True, False) = (1, 0)
824824

825825
def isbasestring(x):
826-
return isinstance(x, types.StringType) or isinstance(x, types.UnicodeType)
826+
return isinstance(x, basestring)
827827

828828
class Values:
829829

@@ -1001,7 +1001,7 @@ def add_option(self, *args, **kwargs):
10011001
"""add_option(Option)
10021002
add_option(opt_str, ..., kwarg=val, ...)
10031003
"""
1004-
if type(args[0]) is types.StringType:
1004+
if isbasestring(args[0]):
10051005
option = self.option_class(*args, **kwargs)
10061006
elif len(args) == 1 and not kwargs:
10071007
option = args[0]
@@ -1312,7 +1312,7 @@ def get_default_values(self):
13121312

13131313
def add_option_group(self, *args, **kwargs):
13141314
# XXX lots of overlap with OptionContainer.add_option()
1315-
if type(args[0]) is types.StringType:
1315+
if isbasestring(args[0]):
13161316
group = OptionGroup(self, *args, **kwargs)
13171317
elif len(args) == 1 and not kwargs:
13181318
group = args[0]

0 commit comments

Comments
 (0)