Error printing tracebacks to StringIO stream on Python 3

Bug #1336384 reported by Gediminas Paulauskas
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
subunit
Invalid
Critical
Unassigned

Bug Description

subunit is used in zope.testrunner

It's test fail under Python 3(.4). Example:

Error in test test_print_failure_containing_utf8_bytestrings (zope.testrunner.tests.test_subunit.TestSubunitTracebackPrinting)
Traceback (most recent call last):
  File "/usr/lib/python3.4/unittest/case.py", line 57, in testPartExecutor
    yield
  File "/usr/lib/python3.4/unittest/case.py", line 570, in run
    self.setUp()
  File "/home/menesis/src/zope/zopetoolkit/trunk/src/zope.testrunner/.tox/py34/lib/python3.4/site-packages/zope/testrunner/tests/test_subunit.py", line 57, in setUp
    options, stream=self.output)
  File "/home/menesis/src/zope/zopetoolkit/trunk/src/zope.testrunner/.tox/py34/lib/python3.4/site-packages/zope/testrunner/formatter.py", line 790, in __init__
    self._subunit = subunit.TestProtocolClient(self._stream)
  File "/home/menesis/src/zope/zopetoolkit/trunk/src/zope.testrunner/python_subunit-0.0.18-py3.4.egg/subunit/__init__.py", line 621, in __init__
    stream = make_stream_binary(stream)
  File "/home/menesis/src/zope/zopetoolkit/trunk/src/zope.testrunner/python_subunit-0.0.18-py3.4.egg/subunit/__init__.py", line 1294, in make_stream_binary
    return _unwrap_text(stream)
  File "/home/menesis/src/zope/zopetoolkit/trunk/src/zope.testrunner/python_subunit-0.0.18-py3.4.egg/subunit/__init__.py", line 1313, in _unwrap_text
    return stream.buffer
AttributeError: '_io.StringIO' object has no attribute 'buffer'

Revision history for this message
Gediminas Paulauskas (menesis) wrote :
Revision history for this message
Robert Collins (lifeless) wrote :

So, I'm a bit uncomfortable with the patch - because we require the ability to write raw bytes to a stream - and _io.StringIO will not accept raw bytes. What zope's own tests should be doing is something like:

bytestream = io.BytesIO()
stringstream = io.TextIOWrapper(bytestream, "utf8")
# now you can do string operations on stringstream and byte operations on bytestream.

which will work on all pythons from 2.6 through 3.4 and pypy.

Changed in subunit:
status: New → Triaged
importance: Undecided → Critical
Changed in subunit:
status: Triaged → Incomplete
Revision history for this message
Robert Collins (lifeless) wrote :

Ok, looking at this again, its really appropriate to fail. Subunit needs a binary stream. Either pass one in, or pass something that can be unwrapped in.

Changed in subunit:
status: Incomplete → Invalid
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.