Fix Issue #459 -- failed to deserialize empty doc.

This commit is contained in:
Matthew Honnibal 2016-10-23 16:31:05 +02:00
parent e99b3f5322
commit 936e6246aa

View File

@ -100,6 +100,8 @@ cdef class Packer:
self.attrs = tuple(attrs)
def pack(self, Doc doc):
if len(doc) == 0:
return b''
bits = self._orth_encode(doc)
if bits is None:
bits = self._char_encode(doc)
@ -116,6 +118,8 @@ cdef class Packer:
return doc
def unpack_into(self, byte_string, Doc doc):
if byte_string == b'':
return None
bits = BitArray(byte_string)
bits.seek(0)
cdef int32_t length = bits.read32()