8000 msgpack.Packer does not reset itself on error · Issue #210 · msgpack/msgpack-python · GitHub
[go: up one dir, main page]

Skip to content
msgpack.Packer does not reset itself on error #210
Closed
@himikof

Description

@himikof

When a serialization error happens, msgpack.Packer buffer is not reset and left in a partially written state. Immediate (without manually calling Packer.reset()) reuse of the packer leads to silently producing invalid msgpack data.

Reproduction:

>>> import msgpack
>>> p = msgpack.Packer()
>>> p.pack({0: msgpack})
Traceback (most recent call last):
  File "<input>", line 1, in <module>
  File "msgpack/_packer.pyx", line 223, in msgpack._packer.Packer.pack (msgpack/_packer.cpp:223)
  File "msgpack/_packer.pyx", line 225, in msgpack._packer.Packer.pack (msgpack/_packer.cpp:225)
  File "msgpack/_packer.pyx", line 184, in msgpack._packer.Packer._pack (msgpack/_packer.cpp:184)
  File "msgpack/_packer.pyx", line 220, in msgpack._packer.Packer._pack (msgpack/_packer.cpp:220)
TypeError: can't serialize <module 'msgpack' from '/usr/lib/python3.3/site-packages/msgpack/__init__.py'>
>>> p.pack(None)
b'\x81\x00\xc0'
>>> msgpack.packb(None)
b'\xc0'

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

      0