unpack requires a string argument of length 1

Bug #1216163 reported by Clark Boylan
26
This bug affects 5 people
Affects Status Importance Assigned to Milestone
subunit
Fix Released
Critical
Robert Collins

Bug Description

With the recent release of python-subunit 0.0.14 some of our python27 unittests have begun failing with a "unpack requires a string argument of length 1" message (http://logs.openstack.org/37/43537/1/check/gate-zuul-python27/44a6863/console.html). Downgrading the python-subunit package to version 0.0.13 corrects the problem.

For what it is worth these error does not seem to occur under python 2.6 (http://logs.openstack.org/37/43537/1/check/gate-zuul-python26/a36aadc/console.html).

You can reproduce this locally by git cloning https://git.openstack.org/openstack-infra/zuul and running `tox -epy27` in the root dir of that project.

Revision history for this message
Clark Boylan (cboylan) wrote :

I neglected to mention that the unittests are being run by testr which forks subunit.run. The error seems to occur when running `testr list-tests` as well.

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

nuts. Will look at it asapish.

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

=== modified file 'python/subunit/v2.py'
--- python/subunit/v2.py 2013-08-23 21:47:28 +0000
+++ python/subunit/v2.py 2013-08-24 12:31:59 +0000
@@ -385,8 +385,10 @@
                         % (crc, packet_crc))
             if safe_hasattr(builtins, 'memoryview'):
                 body = memoryview(packet[-1])
+ view = True
             else:
                 body = packet[-1]
+ view = False
             # Discard CRC-32
             body = body[:-4]
             # One packet could have both file and status data; the Python API
@@ -421,6 +423,8 @@
                 content_length, consumed = self._parse_varint(body, pos)
                 pos += consumed
                 file_bytes = body[pos:pos+content_length]
+ if view:
+ file_bytes = file_bytes.tobytes()
                 if len(file_bytes) != content_length:
                     raise ParseError('File content extends past end of packet: '
                         'claimed %d bytes, %d available' % (

may help, though I can't yet reproduce the problem.

Revision history for this message
ZhiQiang Fan (aji-zqfan) wrote : Re: [Bug 1216163] Re: unpack requires a string argument of length 1

Thanks for your update, i modify the file and test it in
python-neutronclient via `tox -e py27`, but doesn't work. Need more
confirmation.

On Sat, Aug 24, 2013 at 8:41 PM, Robert Collins
<email address hidden>wrote:

> === modified file 'python/subunit/v2.py'
> --- python/subunit/v2.py 2013-08-23 21:47:28 +0000
> +++ python/subunit/v2.py 2013-08-24 12:31:59 +0000
> @@ -385,8 +385,10 @@
> % (crc, packet_crc))
> if safe_hasattr(builtins, 'memoryview'):
> body = memoryview(packet[-1])
> + view = True
> else:
> body = packet[-1]
> + view = False
> # Discard CRC-32
> body = body[:-4]
> # One packet could have both file and status data; the Python
> API
> @@ -421,6 +423,8 @@
> content_length, consumed = self._parse_varint(body, pos)
> pos += consumed
> file_bytes = body[pos:pos+content_length]
> + if view:
> + file_bytes = file_bytes.tobytes()
> if len(file_bytes) != content_length:
> raise ParseError('File content extends past end of
> packet: '
> 'claimed %d bytes, %d available' % (
>
>
> may help, though I can't yet reproduce the problem.
>
> --
> You received this bug notification because you are subscribed to the bug
> report.
> https://bugs.launchpad.net/bugs/1216163
>
> Title:
> unpack requires a string argument of length 1
>
> Status in SubUnit:
> New
>
> Bug description:
> With the recent release of python-subunit 0.0.14 some of our python27
> unittests have begun failing with a "unpack requires a string argument
> of length 1" message (http://logs.openstack.org/37/43537/1/check/gate-
> zuul-python27/44a6863/console.html). Downgrading the python-subunit
> package to version 0.0.13 corrects the problem.
>
> For what it is worth these error does not seem to occur under python
> 2.6 (http://logs.openstack.org/37/43537/1/check/gate-zuul-
> python26/a36aadc/console.html).
>
> You can reproduce this locally by git cloning
> https://git.openstack.org/openstack-infra/zuul and running `tox
> -epy27` in the root dir of that project.
>
> To manage notifications about this bug go to:
> https://bugs.launchpad.net/subunit/+bug/1216163/+subscriptions
>

--
blog: zqfan.github.com
git: github.com/zqfan

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

2.7.3 shows the problem, 2.7.5 doesn't; 3.2 does. I suspect memoryview and struct being incompatible in those releases :(

Changed in subunit:
milestone: none → next
assignee: nobody → Robert Collins (lifeless)
status: New → Triaged
importance: Undecided → Critical
Changed in subunit:
status: Triaged → Fix Released
Revision history for this message
ZhiQiang Fan (aji-zqfan) wrote :

yes, my python version is 2.7.3, confirmed, thank you.

Revision history for this message
Jay Buffington (jaybuff) wrote :

For the record, this bug manifested itself for me with this error message:
    sequence item 15: expected string, memoryview found

This is with python 2.7.5

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.