Add missing autoreset in Packer.pack_ext_type (#663)

This commit is contained in:
Kadir Can Ozden 2026-06-01 15:27:05 +03:00 committed by GitHub
parent 4a07745675
commit 284782d647
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 25 additions and 1 deletions

View file

@ -6,7 +6,7 @@ from msgpack import ExtType
def test_pack_ext_type():
def p(s):
packer = msgpack.Packer()
packer = msgpack.Packer(autoreset=False)
packer.pack_ext_type(0x42, s)
return packer.bytes()
@ -20,6 +20,15 @@ def test_pack_ext_type():
assert p(b"A" * 0x00012345) == b"\xc9\x00\x01\x23\x45\x42" + b"A" * 0x00012345 # ext 32
def test_pack_ext_type_autoreset():
packer = msgpack.Packer()
assert packer.pack_ext_type(0x42, b"A") == b"\xd4\x42A"
assert packer.bytes() == b""
assert packer.pack_ext_type(0x42, b"ABC") == b"\xc7\x03\x42ABC"
assert packer.bytes() == b""
def test_unpack_ext_type():
def check(b, expected):
assert msgpack.unpackb(b) == expected