Squash little bug in cython decimal deserializer
This commit is contained in:
		@@ -36,8 +36,13 @@ cdef class DesLongType(Deserializer):
 | 
				
			|||||||
# TODO: Use libmpdec: http://www.bytereef.org/mpdecimal/index.html
 | 
					# TODO: Use libmpdec: http://www.bytereef.org/mpdecimal/index.html
 | 
				
			||||||
cdef class DesDecimalType(Deserializer):
 | 
					cdef class DesDecimalType(Deserializer):
 | 
				
			||||||
    cdef deserialize(self, Buffer *buf, int protocol_version):
 | 
					    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)
 | 
					        scale = int32_unpack(buf.ptr)
 | 
				
			||||||
        unscaled = varint_unpack(buf.ptr + 4)
 | 
					        unscaled = varint_unpack(to_bytes(&varint_buf))
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        return Decimal('%de%d' % (unscaled, -scale))
 | 
					        return Decimal('%de%d' % (unscaled, -scale))
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -177,6 +177,7 @@ cpdef varint_unpack(term):
 | 
				
			|||||||
# TODO: Optimize these two functions
 | 
					# TODO: Optimize these two functions
 | 
				
			||||||
def varint_unpack_py3(term):
 | 
					def varint_unpack_py3(term):
 | 
				
			||||||
    cdef int64_t one = 1L
 | 
					    cdef int64_t one = 1L
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    val = int(''.join("%02x" % i for i in term), 16)
 | 
					    val = int(''.join("%02x" % i for i in term), 16)
 | 
				
			||||||
    if (term[0] & 128) != 0:
 | 
					    if (term[0] & 128) != 0:
 | 
				
			||||||
        # There is a bug in Cython (0.20 - 0.22), where if we do
 | 
					        # There is a bug in Cython (0.20 - 0.22), where if we do
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user