[openstack-dev] [all][oslo] On Python 3, request_id must by Unicode, not bytes
Victor Stinner
vstinner at redhat.com
Tue Dec 1 10:30:28 UTC 2015
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
More information about the OpenStack-dev
mailing list