kutsurak / python-bitstring

Automatically exported from code.google.com/p/python-bitstring
0 stars 0 forks source link

readlist doesn't work with byte and keyword argument #122

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
It doesn't work if you pass in the length for a byte with a keyword argument 
into readlist(). Example:

  s = BitStream('0x01020')
  x, y, z = s.readlist('a, hex:b, bytes:c', a=8, b=4, c=1)

The error is:
>>> from bitstring import BitStream
>>> s = BitStream('0x01020')
>>> x, y, z = s.readlist('a, hex:b, bytes:c', a=8, b=4, c=1)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "bitstring.py", line 3896, in readlist
    value, self._pos = self._readlist(fmt, self._pos, **kwargs)
  File "bitstring.py", line 2289, in _readlist
    value, pos = self._readtoken(name, pos, length)
  File "bitstring.py", line 1994, in _readtoken
    val = name_to_read[name](self, length, pos)
  File "bitstring.py", line 1329, in _readbytes
    assert length % 8 == 0
AssertionError

It's a current SVN checkout, I've tried it with Python 2.7 on Debian.

Original issue reported on code.google.com by volker.m...@gmail.com on 29 Mar 2012 at 4:00

Attachments:

GoogleCodeExporter commented 9 years ago
Thanks, you're absolutely right and the patch looks good too. It will be fixed 
in the next version.

Original comment by dr.scott...@gmail.com on 29 Mar 2012 at 4:53

GoogleCodeExporter commented 9 years ago

Original comment by dr.scott...@gmail.com on 29 Mar 2012 at 4:53

GoogleCodeExporter commented 9 years ago

Original comment by dr.scott...@gmail.com on 12 Jul 2012 at 8:34

GoogleCodeExporter commented 9 years ago
Fixed in r.962.

Original comment by dr.scott...@gmail.com on 22 Feb 2013 at 5:31