Regressions in support for Python 3

Bug #987514 reported by Arfrever Frehtes Taifersar Arahesis
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
subunit
Fix Released
Critical
Arfrever Frehtes Taifersar Arahesis

Bug Description

Subunit trunk contains some regressions in support for Python 3 (mostly in test suite). I'm attaching the patch. With this patch, tests pass with Python 2.6, 2.7, 3.1 and 3.2.

Revision history for this message
Arfrever Frehtes Taifersar Arahesis (arfrever-fta) wrote :
Revision history for this message
Arfrever Frehtes Taifersar Arahesis (arfrever-fta) wrote :

Previous patch contained 1 needless change.

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

Thank you for the patch. Sadly we've let this happen for the tag support too, I'm fixing that up as a separate bug.

Changed in subunit:
assignee: nobody → Arfrever Frehtes Taifersar Arahesis (arfrever-fta)
milestone: none → next
status: Triaged → Fix Committed
Revision history for this message
Arfrever Frehtes Taifersar Arahesis (arfrever-fta) wrote :
Download full text (3.2 KiB)

Results for revision 169:

$ python3.2 -m testtools.run subunit.test_suite
Tests running...
======================================================================
ERROR: subunit.tests.test_subunit_filter.TestFilterCommand.test_default
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/tmp/subunit/python/subunit/tests/test_subunit_filter.py", line 323, in test_default
    "test: foo\n"
  File "/tmp/subunit/python/subunit/tests/test_subunit_filter.py", line 310, in run_command
    out, err = ps.communicate(stream)
  File "/usr/lib64/python3.2/subprocess.py", line 819, in communicate
    return self._communicate(input)
  File "/usr/lib64/python3.2/subprocess.py", line 1435, in _communicate
    stdout, stderr = self._communicate_with_poll(input)
  File "/usr/lib64/python3.2/subprocess.py", line 1502, in _communicate_with_poll
    input_offset += os.write(fd, chunk)
TypeError: 'str' does not support the buffer interface
======================================================================
ERROR: subunit.tests.test_subunit_filter.TestFilterCommand.test_tags
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/tmp/subunit/python/subunit/tests/test_subunit_filter.py", line 336, in test_tags
    "tags: a\n"
  File "/tmp/subunit/python/subunit/tests/test_subunit_filter.py", line 310, in run_command
    out, err = ps.communicate(stream)
  File "/usr/lib64/python3.2/subprocess.py", line 819, in communicate
    return self._communicate(input)
  File "/usr/lib64/python3.2/subprocess.py", line 1435, in _communicate
    stdout, stderr = self._communicate_with_poll(input)
  File "/usr/lib64/python3.2/subprocess.py", line 1502, in _communicate_with_poll
    input_offset += os.write(fd, chunk)
TypeError: 'str' does not support the buffer interface
======================================================================
ERROR: subunit.tests.test_subunit_filter.TestTestResultFilter.test_tags_tracked_correctly
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/tmp/subunit/python/subunit/tests/test_subunit_filter.py", line 107, in test_tags_tracked_correctly
    self.run_tests(result_filter, input_stream)
  File "/tmp/subunit/python/subunit/tests/test_subunit_filter.py", line 67, in run_tests
    test = subunit.ProtocolTestCase(BytesIO(input_stream))
TypeError: 'str' does not support the buffer interface
======================================================================
FAIL: subunit.tests.test_subunit_filter.TestTestResultFilter.test_tag_filter
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/tmp/subunit/python/subunit/tests/test_subunit_filter.py", line 94, in test_tag_filter
    self.assertEquals(tests_expected, tests_included)
testtools.matchers.MismatchError: !=:
reference = <map object at 0x245da50>
actual = [<subunit.RemotedTestCase description='passed'>,
 <subunit.RemotedTestCase description='error'>,
 <subunit.RemotedTestCase description='skipped'>,
 <subunit.RemotedTestCase description='todo'>]

Ra...

Read more...

Changed in subunit:
status: Fix Committed → In Progress
Revision history for this message
Arfrever Frehtes Taifersar Arahesis (arfrever-fta) wrote :
Download full text (3.2 KiB)

Revision 170 has been just committed. With this revision, test suite passes with Python 3.2, but still fails with 3.1:

$ python3.1 -m testtools.run subunit.test_suite
Tests running...
======================================================================
ERROR: subunit.tests.test_subunit_filter.TestFilterCommand.test_default
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/tmp/subunit/python/subunit/tests/test_subunit_filter.py", line 323, in test_default
    "test: foo\n"
  File "/tmp/subunit/python/subunit/tests/test_subunit_filter.py", line 312, in run_command
    raise RuntimeError("%s failed: %s" % (command, err))
RuntimeError: ['/usr/bin/python3.1', '/tmp/subunit/filters/subunit-filter'] failed: b'Traceback (most recent call last):\n File "/tmp/subunit/filters/subunit-filter", line 158, in <module>\n main()\n File "/tmp/subunit/filters/subunit-filter", line 153, in main\n forward=False)\n File "/tmp/subunit/python/subunit/filters.py", line 92, in filter_by_result\n result = result_factory(output_to)\n File "/tmp/subunit/filters/subunit-filter", line 150, in <lambda>\n lambda output_to: _make_result(sys.stdout, options, filter_predicate),\n File "/tmp/subunit/filters/subunit-filter", line 130, in _make_result\n TestProtocolClient(output),\n File "/tmp/subunit/python/subunit/__init__.py", line 614, in __init__\n stream = _make_stream_binary(stream)\n File "/tmp/subunit/python/subunit/__init__.py", line 1267, in _make_stream_binary\n return _unwrap_text(stream)\n File "/tmp/subunit/python/subunit/__init__.py", line 1281, in _unwrap_text\n if type(stream.read(0)) is str:\nIOError: not readable\n'
======================================================================
ERROR: subunit.tests.test_subunit_filter.TestFilterCommand.test_tags
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/tmp/subunit/python/subunit/tests/test_subunit_filter.py", line 336, in test_tags
    "tags: a\n"
  File "/tmp/subunit/python/subunit/tests/test_subunit_filter.py", line 312, in run_command
    raise RuntimeError("%s failed: %s" % (command, err))
RuntimeError: ['/usr/bin/python3.1', '/tmp/subunit/filters/subunit-filter', '-s', '--with-tag', 'a'] failed: b'Traceback (most recent call last):\n File "/tmp/subunit/filters/subunit-filter", line 158, in <module>\n main()\n File "/tmp/subunit/filters/subunit-filter", line 153, in main\n forward=False)\n File "/tmp/subunit/python/subunit/filters.py", line 92, in filter_by_result\n result = result_factory(output_to)\n File "/tmp/subunit/filters/subunit-filter", line 150, in <lambda>\n lambda output_to: _make_result(sys.stdout, options, filter_predicate),\n File "/tmp/subunit/filters/subunit-filter", line 130, in _make_result\n TestProtocolClient(output),\n File "/tmp/subunit/python/subunit/__init__.py", line 614, in __init__\n stream = _make_stream_binary(stream)\n File "/tmp/subunit/python/subunit/__init__.py", line 1267, in _make_stream_binary\n return _unwrap_text(stream)\n File "/tmp/subunit/python/subunit/__init__.py", line 128...

Read more...

Revision history for this message
Arfrever Frehtes Taifersar Arahesis (arfrever-fta) wrote :

The exceptions are different:

$ python3.1 -c 'open("/dev/null", "w").read()'
 Traceback (most recent call last):
   File "<string>", line 1, in <module>
 IOError: not readable
 $ python3.2 -c 'open("/dev/null", "w").read()'
 Traceback (most recent call last):
   File "<string>", line 1, in <module>
 io.UnsupportedOperation: not readable

The following fix works, but maybe _UnsupportedOperation should be changed.

--- python/subunit/__init__.py
 +++ python/subunit/__init__.py
 @@ -1280,7 +1280,7 @@
              # Read streams
              if type(stream.read(0)) is str:
                  return stream.buffer
 - except _UnsupportedOperation:
 + except (_UnsupportedOperation, IOError):
              # Cannot read from the stream: try via writes
              try:
                  stream.write(_b(''))

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

Thanks, will commit that.

Changed in subunit:
status: In Progress → Fix Committed
status: Fix Committed → In Progress
Revision history for this message
Robert Collins (lifeless) wrote :

(Also, I really appreciate your rapid testing!)

Changed in subunit:
status: In Progress → Fix Committed
Revision history for this message
Arfrever Frehtes Taifersar Arahesis (arfrever-fta) wrote :

Actually 'except IOError:' would suffice, since io.UnsupportedOperation is a subclass of IOError.

$ python3.1 -c 'import io; print(issubclass(io.UnsupportedOperation, IOError))'
True
$ python3.2 -c 'import io; print(issubclass(io.UnsupportedOperation, IOError))'
True

Changed in subunit:
status: Fix Committed → Fix Released
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.