Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

tell() is incorrect after read_bytes() #426

Copy link
Copy link
@eddyashton

Description

@eddyashton
Issue body actions

Using the default ._cmsgpack implementation of an Unpacker, you will get the wrong answer if you call tell() after read_bytes(). Here's a simple repro:

import msgpack
from io import BytesIO
buf = BytesIO(b'my data')
u = msgpack.Unpacker(buf)
print(u.tell())
u.read_bytes(5)
print(u.tell())

After calling u.read_bytes(5), u.tell() will still return 0. It looks like the stream_offset in _unpacker.pyx should be advanced in read_bytes(), but is currently only advanced by _unpack().

Note that this works correctly in the .fallback implementation, so a quick workaround is to use import msgpack.fallback as msgpack, but I assume this is much slower than the C implementation.

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

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.