kill some duplicate code from unpack/unpackb and move the logic to Unpacker.unpack_one. By doing this we no longer need to make the module-level pack/unpack parametric on the class, because they contain no logic at all

This commit is contained in:
Antonio Cuni 2013-10-18 14:38:52 +02:00
parent d61097511a
commit 5529dfe596
2 changed files with 52 additions and 51 deletions

View file

@ -18,7 +18,9 @@ def test_extension_type():
return obj
obj = [42, 'hello', array.array('d', [1.1, 2.2, 3.3])]
s = msgpack.packb(obj, MyPacker)
obj2 = msgpack.unpackb(s, MyUnpacker)
packer = MyPacker()
unpacker = MyUnpacker(None)
s = packer.pack(obj)
unpacker.feed(s)
obj2 = unpacker.unpack_one()
assert obj == obj2