Squash little bug in cython decimal deserializer

This commit is contained in:
Mark Florisson
2015-08-07 10:38:16 +01:00
parent 56a25df0fc
commit 8462e865f7
2 changed files with 7 additions and 1 deletions

View File

@@ -36,8 +36,13 @@ cdef class DesLongType(Deserializer):
# TODO: Use libmpdec: http://www.bytereef.org/mpdecimal/index.html
cdef class DesDecimalType(Deserializer):
cdef deserialize(self, Buffer *buf, int protocol_version):
cdef Buffer varint_buf
varint_buf.ptr = buf.ptr + 4
varint_buf.size = buf.size - 4
scale = int32_unpack(buf.ptr)
unscaled = varint_unpack(buf.ptr + 4)
unscaled = varint_unpack(to_bytes(&varint_buf))
return Decimal('%de%d' % (unscaled, -scale))

View File

@@ -177,6 +177,7 @@ cpdef varint_unpack(term):
# TODO: Optimize these two functions
def varint_unpack_py3(term):
cdef int64_t one = 1L
val = int(''.join("%02x" % i for i in term), 16)
if (term[0] & 128) != 0:
# There is a bug in Cython (0.20 - 0.22), where if we do