Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions msgpack/_unpacker.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from cpython cimport *
cdef extern from "Python.h":
ctypedef struct PyObject
cdef int PyObject_AsReadBuffer(object o, const void* buff, Py_ssize_t* buf_len) except -1
cdef int PyObject_AsReadBuffer(object o, const void** buff, Py_ssize_t* buf_len) except -1

from libc.stdlib cimport *
from libc.string cimport *
Expand Down Expand Up @@ -95,7 +95,7 @@ def unpackb(object packed, object object_hook=None, object list_hook=None,
cdef char* cenc = NULL
cdef char* cerr = NULL

PyObject_AsReadBuffer(packed, <const void*>&buf, &buf_len)
PyObject_AsReadBuffer(packed, <const void**>&buf, &buf_len)

if encoding is not None:
if isinstance(encoding, unicode):
Expand Down
4 changes: 2 additions & 2 deletions msgpack/unpack.h
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ static inline int unpack_callback_uint64(unpack_user* u, uint64_t d, msgpack_unp
{
PyObject *p;
if (d > LONG_MAX) {
p = PyLong_FromUnsignedLongLong((unsigned long)d);
p = PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG)d);
} else {
p = PyInt_FromLong((long)d);
}
Expand Down Expand Up @@ -103,7 +103,7 @@ static inline int unpack_callback_int64(unpack_user* u, int64_t d, msgpack_unpac
{
PyObject *p;
if (d > LONG_MAX || d < LONG_MIN) {
p = PyLong_FromLongLong((unsigned long)d);
p = PyLong_FromLongLong((unsigned PY_LONG_LONG)d);
} else {
p = PyInt_FromLong((long)d);
}
Expand Down
5 changes: 3 additions & 2 deletions test/test_pack.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,12 @@
def check(data, use_list=False):
re = unpackb(packb(data), use_list=use_list)
assert re == data
assert type(re) == type(data)

def testPack():
test_data = [
0, 1, 127, 128, 255, 256, 65535, 65536,
-1, -32, -33, -128, -129, -32768, -32769,
0, 1, 127, 128, 255, 256, 65535, 65536, 4294967295, 4294967296,
-1, -32, -33, -128, -129, -32768, -32769, -4294967296, -4294967297,
1.0,
b"", b"a", b"a"*31, b"a"*32,
None, True, False,
Expand Down