mirror of
https://github.com/msgpack/msgpack-python.git
synced 2025-10-19 20:03:16 +00:00
Support unpacking new types.
This commit is contained in:
parent
96bcd76f49
commit
822cce823c
4 changed files with 17 additions and 11 deletions
|
@ -157,7 +157,7 @@ static inline int unpack_callback_array_item(unpack_user* u, unsigned int curren
|
|||
static inline int unpack_callback_array_end(unpack_user* u, msgpack_unpack_object* c)
|
||||
{
|
||||
if (u->list_hook) {
|
||||
PyObject *new_c = PyEval_CallFunction(u->list_hook, "(O)", *c);
|
||||
PyObject *new_c = PyObject_CallFunction(u->list_hook, "(O)", *c);
|
||||
if (!new_c)
|
||||
return -1;
|
||||
Py_DECREF(*c);
|
||||
|
@ -203,7 +203,7 @@ static inline int unpack_callback_map_item(unpack_user* u, unsigned int current,
|
|||
static inline int unpack_callback_map_end(unpack_user* u, msgpack_unpack_object* c)
|
||||
{
|
||||
if (u->object_hook) {
|
||||
PyObject *new_c = PyEval_CallFunction(u->object_hook, "(O)", *c);
|
||||
PyObject *new_c = PyObject_CallFunction(u->object_hook, "(O)", *c);
|
||||
if (!new_c)
|
||||
return -1;
|
||||
|
||||
|
@ -246,7 +246,11 @@ static inline int unpack_callback_ext(unpack_user* u, const char* base, const ch
|
|||
return -1;
|
||||
}
|
||||
// length also includes the typecode, so the actual data is lenght-1
|
||||
py = PyEval_CallFunction(u->ext_hook, "(is#)", typecode, pos, lenght-1);
|
||||
#if PY_MAJOR_VERSION == 2
|
||||
py = PyObject_CallFunction(u->ext_hook, "(is#)", typecode, pos, lenght-1);
|
||||
#else
|
||||
py = PyObject_CallFunction(u->ext_hook, "(iy#)", typecode, pos, lenght-1);
|
||||
#endif
|
||||
if (!py)
|
||||
return -1;
|
||||
*o = py;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue