[Python-Dev] Problems with unicode_literals

Barry Warsaw barry at python.org
Sun Jan 18 00:03:16 CET 2009


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On Jan 17, 2009, at 2:25 PM, Guido van Rossum wrote:

> On Sat, Jan 17, 2009 at 12:25 AM, "Martin v. Löwis" <martin at v.loewis.de 
> > wrote:
>>> 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]
>>>
>>> Should this be fixed, or wait for 2.7?
>>
>> It would be a new feature. So if we apply a strict policy, it
>> can't be added to 2.6.
>
> That seems a bit *too* strict to me, as long as the Unicode strings
> contain just ASCII. I'm fine with fixing both cases Barry mentioned,
> especially if it otherwise breaks "from __future__ import
> unicode_literals". I expect though that as one tries more things one
> will find more things broken with that mode.

Maybe not though!  I've finished converting the Mailman 3 code base  
and there were the only two problems that I could attribute to  
Python.  Everything else were really attributed to my own sloppiness  
between bytes and strings.  In fact, I started this experiment to fix  
a "problem" with the Storm ORM, which is much stricter about its  
column data types.  I'm happy enough with the code that I'm going to  
keep it even with the Python nits.

It sounds like you're amenable to fixing this in Python 2.6.

- -Barry

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (Darwin)

iQCVAwUBSXJjtXEjvBPtnXfVAQJ8pgP/WZptUyiYvMJnNGOQ/QF6fD7VpwN4GeDF
h/idTycEFx9xD32qcdoO+1mZTbsUHyyIg+5hbJP4LP7Iy3yGfVNioih7dg6M287F
2QQ9LVimxyWGvJ+imT508EWDydLfszDkDi9zaqYxvCIU0fbJTs4ylWOFDQlnktNh
HR/wU0n+7UQ=
=5GII
-----END PGP SIGNATURE-----


More information about the Python-Dev mailing list