Code review comment for lp://qastaging/~mvo/ubuntu-release-upgrader/lp1071388

Revision history for this message
Michael Vogt (mvo) wrote :

On Wed, Nov 07, 2012 at 08:47:18PM -0000, Barry Warsaw wrote:
> A couple of quick thoughts: you might want to use "utf-8" instead of "utf8". It doesn't matter in practice, but better matches what getpreferredencoding() returns. Very minor nit.

Thanks, I fixed that.

> Also, in Python 3, we're generally calling subprocess.Popen(..., universal_newlines=True) now so that you can send unicode to the subprocess instead of bytes. That may avoid a call to .encode() below.
>
> http://docs.python.org/3/library/subprocess.html#frequently-used-arguments

Thanks, I will have to look in more details, but afaict this is also
because we get the data as bytes sometimes.

> decoding the results of sys.stdin.readline() also looks a bit suspect to me, since that should already return str instead of bytes. Are you sure that works? See also `python3 -h` and the PYTHONIOENCODING envar.

This code runs under py2 most of the time as the upgrade needs to be
support back to precise with the default install there. I.e.:
$ python -c 'import sys; print sys.getdefaultencoding()'
ascii

$ python3 -c 'import sys; print(sys.getdefaultencoding())'
utf-8

And it seems like py2 does not honor PYTHONIOENCODING :/

Cheers,
 Michael

« Back to merge proposal