PBR

use io.open() instead of open() for python 2/3 compatibility

Bug #1470551 reported by Lianhao Lu
10
This bug affects 2 people
Affects Status Importance Assigned to Milestone
PBR
Incomplete
Undecided
Lianhao Lu

Bug Description

When investigating the failure of http://logs.openstack.org/49/197549/1/check/gate-congress-python34/39a0589/console.html , I found that pbr is using built-in open() to open files like PKG-INFO and METADTA. This would result error in python 3 if those metadata files contains non-ascii characters.

We should use io.open(encoding='utf-8') to replace built-in open() for python2/3 compatibility.

Lianhao Lu (lianhao-lu)
Changed in pbr:
assignee: nobody → Lianhao Lu (lianhao-lu)
Changed in pbr:
status: New → In Progress
Revision history for this message
Robert Collins (lifeless) wrote :

So this is premature... the built in open, in text mode, uses
https://docs.python.org/3/library/locale.html#locale.getpreferredencoding by default, and AFAIK there isn't a defined encoding for PKG-INFO or METADATA - I've sent a follow up to the distutils thread on this from 2008! and we can go from there to see if there is one.

If there isn't, erroring on something we can't decode is probably just as fine as anything.

Changed in pbr:
status: In Progress → Incomplete
Revision history for this message
Robert Collins (lifeless) wrote :

Further - we can specify an encoding to open(), there's no need to use io.open specifically to do this.

I've confirmation that METADATA Is utf8, so we we can do it there, PKG-INFO is still an open question

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Change abandoned on pbr (master)

Change abandoned by ChangBo Guo(gcb) (<email address hidden>) on branch: master
Review: https://review.openstack.org/197626
Reason: Please restore it if you want to continue working on this.

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.