mirror of
https://github.com/msgpack/msgpack-python.git
synced 2026-02-08 02:40:09 +00:00
Fix Unpacker max_buffer_length handling (#506)
This commit is contained in:
parent
b75e3412fb
commit
500a238028
3 changed files with 24 additions and 17 deletions
|
|
@ -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")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue