Skip to content

Broken fallback implementation of Unpacker.read_bytes #352

Description

@jmuchemb
>>> from msgpack import *
>>> u = Unpacker(); u.feed('x'); u.read_bytes(1)
'x'
>>> u.next()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "msgpack/_unpacker.pyx", line 562, in msgpack._cmsgpack.Unpacker.__next__
  File "msgpack/_unpacker.pyx", line 489, in msgpack._cmsgpack.Unpacker._unpack
StopIteration: No more data to unpack.
>>> u.feed('\1'); u.next()
1

So far so good. Now with fallback implémentation:

>>> from msgpack.fallback import *
>>> u = Unpacker(); u.feed('x'); u.read_bytes(1)
bytearray(b'x')
>>> u.next()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib/python2.7/dist-packages/msgpack/fallback.py", line 690, in __next__
    raise StopIteration
StopIteration
>>> u.feed('\1'); u.next()
120

Something seems to be wrongly reset on StopIteration.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions