[Python-Dev] Problems with unicode_literals

Victor Stinner victor.stinner at haypocalc.com
Sat Jan 17 14:03:13 CET 2009


Le Saturday 17 January 2009 04:45:28 Barry Warsaw, vous avez écrit :
> The optparse one could easily be fixed for 2.6, if we agree it should
> be fixed.  This untested patch should do it I think:
>
> Index: Lib/optparse.py
> ===================================================================
> --- Lib/optparse.py	(revision 68465)
> +++ Lib/optparse.py	(working copy)
> @@ -994,7 +994,7 @@
>           """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]

See also related issues: 
 - http://bugs.python.org/issue2931: optparse: various problems with unicode 
and gettext
 - http://bugs.python.org/issue4319: optparse and non-ascii help strings

-- 
Victor Stinner aka haypo
http://www.haypocalc.com/blog/


More information about the Python-Dev mailing list