[openstack-dev] Sprint at Pycon: Port OpenStack to Python 3

John Dennis jdennis at redhat.com
Tue Apr 1 19:02:52 UTC 2014


On 04/01/2014 02:08 PM, John Dennis wrote:

>>> My concern is this. The singled biggest change in Py2 -> Py3 is
>>> string handling, especially with regards to str vs. unicode. We
>>> have a significant number of bugs in the current code base with
>>> regards to encoding exceptions, I just got done fixing a number of
>>> them, I know there are others.
>>
>> In which OpenStack component?
> 
> For one:
> 
> https://bugs.launchpad.net/keystone/+bug/1292311
> 
> But just looking at a lot of the OpenStack code it's easy to see things
> are going to blow up once you start passing around non-ASCII characters.

Oh almost forgot ...

The openstack log module blows up if you pass a UTF-8 encoded string.

For the LDAP code that limitation meant any logging had to be performed
before encoding and if any logging had to be done after encoding it
meant one had to be sure values were decoded again before logging.
That's very error prone.

I think the logging module needs to be fixed so that if it receives a
str or bytes object it will assume the encoding is UTF-8 (not default
ASCII) and properly decode it prior to forming the final message.

Not being able to log UTF-8 encoded strings is an accident waiting to
happen (nothing worse than an import message not getting seen because it
got trapped in an encode/decode exception handled (or not handled)
elsewhere)

-- 
John



More information about the OpenStack-dev mailing list