Fix Unpacker max_buffer_length handling (#506)

This commit is contained in:
Inada Naoki 2022-05-24 19:46:51 +09:00 committed by GitHub
parent b75e3412fb
commit 500a238028
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 24 additions and 17 deletions

View file

@ -2,7 +2,7 @@
# coding: utf-8
import io
from msgpack import Unpacker, BufferFull
from msgpack import pack
from msgpack import pack, packb
from msgpack.exceptions import OutOfData
from pytest import raises
@ -78,6 +78,15 @@ def test_maxbuffersize():
assert ord("b") == next(unpacker)
def test_maxbuffersize_file():
buff = io.BytesIO(packb(b"a" * 10) + packb([b"a" * 20] * 2))
unpacker = Unpacker(buff, read_size=1, max_buffer_size=19, max_bin_len=20)
assert unpacker.unpack() == b"a" * 10
# assert unpacker.unpack() == [b"a" * 20]*2
with raises(BufferFull):
print(unpacker.unpack())
def test_readbytes():
unpacker = Unpacker(read_size=3)
unpacker.feed(b"foobar")