From: Markus Armbruster <armbru@redhat.com>
To: Paolo Bonzini <pbonzini@redhat.com>
Cc: "Kevin Wolf" <kwolf@redhat.com>,
"Philippe Mathieu-Daudé" <f4bug@amsat.org>,
"Fam Zheng" <famz@redhat.com>,
"Eduardo Habkost" <ehabkost@redhat.com>,
qemu-block@nongnu.org, qemu-devel@nongnu.org,
"Max Reitz" <mreitz@redhat.com>,
"Alex Bennée" <alex.bennee@linaro.org>
Subject: Re: [Qemu-devel] [Qemu-block] [PATCH v3] python: Use io.StringIO
Date: Thu, 11 Oct 2018 16:01:25 +0200 [thread overview]
Message-ID: <877eio37m2.fsf@dusky.pond.sub.org> (raw)
In-Reply-To: <ff422e9b-fd56-1be1-68cf-300dcd7a0cb4@redhat.com> (Paolo Bonzini's message of "Thu, 11 Oct 2018 14:43:34 +0200")
Paolo Bonzini <pbonzini@redhat.com> writes:
> On 11/10/2018 13:33, Kevin Wolf wrote:
>> 045 1s ... [13:31:47] [13:31:47] [failed, exit status 1] - output mismatch (see 045.out.bad)
>> --- /home/kwolf/source/qemu/tests/qemu-iotests/045.out 2017-01-24 14:49:48.000000000 +0100
>> +++ /home/kwolf/source/qemu/tests/qemu-iotests/045.out.bad 2018-10-11 13:31:47.266876850 +0200
>> @@ -1,5 +1,26 @@
>> -...........
>> -----------------------------------------------------------------------
>> -Ran 11 tests
>> -
>> -OK
>> +Traceback (most recent call last):
>> + File "045", line 178, in <module>
>> + iotests.main(supported_fmts=['raw'])
>> + File "/home/kwolf/source/qemu/tests/qemu-iotests/iotests.py", line 698, in main
>> + unittest.main(testRunner=MyTestRunner)
>> + File "/usr/lib64/python2.7/unittest/main.py", line 95, in __init__
>> + self.runTests()
>> + File "/usr/lib64/python2.7/unittest/main.py", line 232, in runTests
>> + self.result = testRunner.run(self.test)
>> + File "/usr/lib64/python2.7/unittest/runner.py", line 151, in run
>> + test(result)
>> + File "/usr/lib64/python2.7/unittest/suite.py", line 70, in __call__
>> + return self.run(*args, **kwds)
>> + File "/usr/lib64/python2.7/unittest/suite.py", line 108, in run
>> + test(result)
>> + File "/usr/lib64/python2.7/unittest/suite.py", line 70, in __call__
>> + return self.run(*args, **kwds)
>> + File "/usr/lib64/python2.7/unittest/suite.py", line 108, in run
>> + test(result)
>> + File "/usr/lib64/python2.7/unittest/case.py", line 431, in __call__
>> + return self.run(*args, **kwds)
>> + File "/usr/lib64/python2.7/unittest/case.py", line 406, in run
>> + result.addSuccess(self)
>> + File "/usr/lib64/python2.7/unittest/runner.py", line 62, in addSuccess
>> + self.stream.write('.')
>> +TypeError: unicode argument expected, got 'str'
>> Failures: 045
>> Failed 1 of 1 tests
>>
>> $ /usr/bin/env python --version
>> Python 2.7.15
>
> Indeed, io.StringIO exists in Python 2.7 but it's different! If Python
> 2 code is not unicode-friendly (it almost never is) it should use
> StringIO.StringIO, for example 'six' defines
>
> six.StringIO:
> This is an fake file object for textual data. It’s an alias for
> StringIO.StringIO in Python 2 and io.StringIO in Python 3.
>
> six.BytesIO:
> This is a fake file object for binary data. In Python 2, it’s an
> alias for StringIO.StringIO, but in Python 3, it’s an alias for
> io.BytesIO.
>
> So the solution seems to be a try/except (and then, better move the
> "from X import StringIO" to the top of the file then, rather than
> keeping it in def main).
>
> Paolo
I think we need to invest more resources in Python 2/3 compatiblity, or
else we'll miss our hard deadline of January 1, 2020.
https://pythonclock.org/
next prev parent reply other threads:[~2018-10-11 14:02 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-10-10 21:31 [Qemu-devel] [PATCH v3] python: Use io.StringIO Philippe Mathieu-Daudé
2018-10-10 22:22 ` [Qemu-devel] [Qemu-block] " Paolo Bonzini
2018-10-11 11:33 ` [Qemu-devel] " Kevin Wolf
2018-10-11 12:43 ` [Qemu-devel] [Qemu-block] " Paolo Bonzini
2018-10-11 14:01 ` Markus Armbruster [this message]
2018-10-11 14:44 ` Philippe Mathieu-Daudé
2018-10-11 14:56 ` Kevin Wolf
2018-10-11 17:02 ` Eduardo Habkost
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=877eio37m2.fsf@dusky.pond.sub.org \
--to=armbru@redhat.com \
--cc=alex.bennee@linaro.org \
--cc=ehabkost@redhat.com \
--cc=f4bug@amsat.org \
--cc=famz@redhat.com \
--cc=kwolf@redhat.com \
--cc=mreitz@redhat.com \
--cc=pbonzini@redhat.com \
--cc=qemu-block@nongnu.org \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.