mirror of
https://github.com/msgpack/msgpack-python.git
synced 2025-10-26 15:14:10 +00:00
fix long/int confusions in pyx version of unpack
This commit is contained in:
parent
82313b713e
commit
b0c193f3e0
1 changed files with 12 additions and 4 deletions
|
|
@ -68,7 +68,12 @@ static inline int unpack_callback_uint32(unpack_user* u, uint32_t d, msgpack_unp
|
||||||
|
|
||||||
static inline int unpack_callback_uint64(unpack_user* u, uint64_t d, msgpack_unpack_object* o)
|
static inline int unpack_callback_uint64(unpack_user* u, uint64_t d, msgpack_unpack_object* o)
|
||||||
{
|
{
|
||||||
PyObject *p = PyLong_FromUnsignedLongLong(d);
|
PyObject *p;
|
||||||
|
if (d > LONG_MAX) {
|
||||||
|
p = PyLong_FromUnsignedLongLong((unsigned long)d);
|
||||||
|
} else {
|
||||||
|
p = PyInt_FromLong((long)d);
|
||||||
|
}
|
||||||
if (!p)
|
if (!p)
|
||||||
return -1;
|
return -1;
|
||||||
*o = p;
|
*o = p;
|
||||||
|
|
@ -96,9 +101,12 @@ static inline int unpack_callback_int8(unpack_user* u, int8_t d, msgpack_unpack_
|
||||||
|
|
||||||
static inline int unpack_callback_int64(unpack_user* u, int64_t d, msgpack_unpack_object* o)
|
static inline int unpack_callback_int64(unpack_user* u, int64_t d, msgpack_unpack_object* o)
|
||||||
{
|
{
|
||||||
PyObject *p = PyLong_FromLongLong(d);
|
PyObject *p;
|
||||||
if (!p)
|
if (d > LONG_MAX || d < LONG_MIN) {
|
||||||
return -1;
|
p = PyLong_FromLongLong((unsigned long)d);
|
||||||
|
} else {
|
||||||
|
p = PyInt_FromLong((long)d);
|
||||||
|
}
|
||||||
*o = p;
|
*o = p;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue