Support unpacking new types.

This commit is contained in:
INADA Naoki 2013-10-20 22:59:27 +09:00
parent 96bcd76f49
commit 822cce823c
4 changed files with 17 additions and 11 deletions

View file

@ -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;