Gentoo Archives: gentoo-portage-dev

From: Arfrever Frehtes Taifersar Arahesis <arfrever.fta@×××××.com>
To: Gentoo Portage Development <gentoo-portage-dev@l.g.o>
Subject: Re: [gentoo-portage-dev] [PATCH] xattr: centralize the various shims in one place
Date: Tue, 22 Oct 2013 15:59:43
Message-Id: 201310221759.05197.Arfrever.FTA@gmail.com
In Reply to: Re: [gentoo-portage-dev] [PATCH] xattr: centralize the various shims in one place by Mike Frysinger
1 2013-10-21 05:00 Mike Frysinger napisał(a):
2 > On Wednesday 16 October 2013 23:42:26 Arfrever Frehtes Taifersar wrote:
3 > > - cStringIO module should not be used. io module is a replacement available
4 > > since Python 2.6.
5 >
6 > unfortunately, that doesn't work as well as it should. python 2.7's interface
7 > is annoyingly different when using other python 2.7 modules. i'll have the
8 > code import the old module and then fallback to using the new io module.
9
10 (io.StringIO works only with unicode strings.
11 When bytes-compatible functions are really needed, then io.BytesIO can be used, which works only with bytes.
12 cStringIO.StringIO is designed to work with bytes, but cStringIO.StringIO().write(instance_of_unicode)
13 implicitly encodes its argument to bytes.)
14
15 In your another patch, portage.tests.bin.test_prepstrip.PrepStripFull._prepstrip() passes an instance of
16 cStringIO.StringIO class to portage.bin.prepstrip.main(), which passes it to portage.bin.prepstrip.Prepstrip(),
17 which passes it to print(), portage.elog.messages.eqawarn() and portage.elog.messages.ewarn().
18
19 pym/portage/bin/prepstrip.py should have:
20 from __future__ import unicode_literals
21
22 Then print('...', file=out) calls will work with an instance of io.StringIO class.
23
24 (portage.elog.messages.eqawarn() and portage.elog.messages.ewarn() internally decode message,
25 so they already work with out=io.StringIO, but not out=io.BytesIO.)
26
27 --
28 Arfrever Frehtes Taifersar Arahesis

Attachments

File name MIME type
signature.asc application/pgp-signature