Skip to content

Commit 2f6061c

Browse files
committed
Merge pull request #66 from yamt/fixes
some fixes and tests
2 parents d4bb86c + e250b89 commit 2f6061c

File tree

3 files changed

+7
-6
lines changed

3 files changed

+7
-6
lines changed

msgpack/_unpacker.pyx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
from cpython cimport *
55
cdef extern from "Python.h":
66
ctypedef struct PyObject
7-
cdef int PyObject_AsReadBuffer(object o, const void* buff, Py_ssize_t* buf_len) except -1
7+
cdef int PyObject_AsReadBuffer(object o, const void** buff, Py_ssize_t* buf_len) except -1
88

99
from libc.stdlib cimport *
1010
from libc.string cimport *
@@ -95,7 +95,7 @@ def unpackb(object packed, object object_hook=None, object list_hook=None,
9595
cdef char* cenc = NULL
9696
cdef char* cerr = NULL
9797

98-
PyObject_AsReadBuffer(packed, <const void*>&buf, &buf_len)
98+
PyObject_AsReadBuffer(packed, <const void**>&buf, &buf_len)
9999

100100
if encoding is not None:
101101
if isinstance(encoding, unicode):

msgpack/unpack.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ static inline int unpack_callback_uint64(unpack_user* u, uint64_t d, msgpack_unp
7070
{
7171
PyObject *p;
7272
if (d > LONG_MAX) {
73-
p = PyLong_FromUnsignedLongLong((unsigned long)d);
73+
p = PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG)d);
7474
} else {
7575
p = PyInt_FromLong((long)d);
7676
}
@@ -103,7 +103,7 @@ static inline int unpack_callback_int64(unpack_user* u, int64_t d, msgpack_unpac
103103
{
104104
PyObject *p;
105105
if (d > LONG_MAX || d < LONG_MIN) {
106-
p = PyLong_FromLongLong((unsigned long)d);
106+
p = PyLong_FromLongLong((unsigned PY_LONG_LONG)d);
107107
} else {
108108
p = PyInt_FromLong((long)d);
109109
}

test/test_pack.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,12 @@
1212
def check(data, use_list=False):
1313
re = unpackb(packb(data), use_list=use_list)
1414
assert re == data
15+
assert type(re) == type(data)
1516

1617
def testPack():
1718
test_data = [
18-
0, 1, 127, 128, 255, 256, 65535, 65536,
19-
-1, -32, -33, -128, -129, -32768, -32769,
19+
0, 1, 127, 128, 255, 256, 65535, 65536, 4294967295, 4294967296,
20+
-1, -32, -33, -128, -129, -32768, -32769, -4294967296, -4294967297,
2021
1.0,
2122
b"", b"a", b"a"*31, b"a"*32,
2223
None, True, False,

0 commit comments

Comments
 (0)