[openstack-dev] [all][oslo] On Python 3, request_id must by Unicode, not bytes

Joshua Harlow harlowja at fastmail.com
Wed Dec 2 18:39:03 UTC 2015

Seems ok with me, not ideal but knowing the support of python 3.x in 
openstack it doesn't seem harmful to fix this while we still are able 
to; and in general if thats 'req-$uuid' ascii/unicode should be fine 
(since that's all that is).


Victor Stinner wrote:
> Hi,
> The next oslo.context release including the following change (still
> under review) might break the voting Python 3 gate of your project:
> https://review.openstack.org/#/c/250731/
> Please try to run Python 3 tests of your project with this change. I
> already ran the tests on Python 3 of the following projects:
> - ceilometer
> - cinder
> - heat
> - neutron
> - nova
> The type of the request_id attribute of oslo_context.RequestContext was
> changed from Unicode (str) to bytes on Python 3 in April "to fix an unit
> test". According to the author of the change, it was a mistake.
> The request_id is a string looks like 'req-83a6...', 'req-' followed by
> an UUID. On Python 3, it's annoying to manipulate a bytes string. For
> example, print(request_id) writes b'req-83a6...' instead of req-83a6...,
> request_id.startswith('req-83a6...') raises a TypeError, etc.
> I propose to modify request_id type again to make it a Unicode string to
> fix oslo.log (don't log b'req-...' anymore, but req-...):
> https://review.openstack.org/#/c/250731/
> It looks like it doesn't break services, but only one specific unit test
> duplicated in some projects. The unit test relies on the exact
> request_id type, it looks like: request_id.startswith(b'req-'). I fixed
> this unit test in Glance, Neutron and oslo.middlware to accept bytes and
> Unicode request_id.
> I also searched for b'req-' in http://codesearch.openstack.org/ to find
> all projects relying on the exact request_id type.
> Victor
> __________________________________________________________________________
> OpenStack Development Mailing List (not for usage questions)
> Unsubscribe: OpenStack-dev-request at lists.openstack.org?subject:unsubscribe
> http://lists.openstack.org/cgi-bin/mailman/listinfo/openstack-dev

More information about the OpenStack-dev mailing list