]> granicus.if.org Git - python/commitdiff
#9161: Fix regression in acceptance of unicode strings in add_option calls.
authorR. David Murray <rdmurray@bitdance.com>
Mon, 5 Jul 2010 16:06:05 +0000 (16:06 +0000)
committerR. David Murray <rdmurray@bitdance.com>
Mon, 5 Jul 2010 16:06:05 +0000 (16:06 +0000)
The original change in 2.6 was made during rc1 changeover, and did not
get ported to 2.7.  The original change may not even have been
intentional, but if so it doesn't seem to have caused any problems.

Lib/optparse.py
Misc/NEWS

index 8ab329104a51b88a08153d5b082bf0991711dad6..87d7737423209215b01867137c9ad680d5dca9cc 100644 (file)
@@ -1008,7 +1008,7 @@ class OptionContainer:
         """add_option(Option)
            add_option(opt_str, ..., kwarg=val, ...)
         """
-        if type(args[0]) is types.StringType:
+        if type(args[0]) in types.StringTypes:
             option = self.option_class(*args, **kwargs)
         elif len(args) == 1 and not kwargs:
             option = args[0]
index 5419617b0f0ad0fa561bbf5b3ece6fe57611039d..c6e7962288740c44e4c6d5bd385d4e63bf8d9b6a 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -16,6 +16,9 @@ Core and Builtins
 Library
 -------
 
+- Issue #9161: Fix regression in optparse's acceptance of unicode
+  strings in add_option calls.
+
 - Issue #9130: Fix validation of relative imports in parser module.
 
 - Issue #9128: Fix validation of class decorators in parser module.