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
6 changes: 1 addition & 5 deletions msgpack/_unpacker.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ cdef extern from "unpack.h":
Py_ssize_t count

ctypedef int (*execute_fn)(unpack_context* ctx, const char* data,
Py_ssize_t len, Py_ssize_t* off) except? -1
Py_ssize_t len, Py_ssize_t* off) except -1
execute_fn unpack_construct
execute_fn unpack_skip
execute_fn read_array_header
Expand Down Expand Up @@ -206,8 +206,6 @@ def unpackb(object packed, *, object object_hook=None, object list_hook=None,
raise FormatError
elif ret == -3:
raise StackError
elif PyErr_Occurred():
raise
else:
raise ValueError("Unpack failed: error = %d" % (ret,))

Expand Down Expand Up @@ -502,8 +500,6 @@ cdef class Unpacker:
raise FormatError
elif ret == -3:
raise StackError
elif PyErr_Occurred():
raise
else:
raise ValueError("Unpack failed: error = %d" % (ret,))
finally:
Expand Down
5 changes: 0 additions & 5 deletions msgpack/unpack.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,6 @@ struct unpack_context;
typedef struct unpack_context unpack_context;
typedef int (*execute_fn)(unpack_context *ctx, const char* data, Py_ssize_t len, Py_ssize_t* off);

static inline msgpack_unpack_object unpack_callback_root(unpack_user* u)
{
return NULL;
}

static inline int unpack_callback_uint16(unpack_user* u, uint16_t d, msgpack_unpack_object* o)
{
PyObject *p = PyLong_FromLong((long)d);
Expand Down
25 changes: 3 additions & 22 deletions msgpack/unpack_template.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,6 @@ struct unpack_context {
unsigned int cs;
unsigned int trail;
unsigned int top;
/*
unpack_stack* stack;
unsigned int stack_size;
unpack_stack embed_stack[MSGPACK_EMBED_STACK_SIZE];
*/
unpack_stack stack[MSGPACK_EMBED_STACK_SIZE];
};

Expand All @@ -49,22 +44,9 @@ static inline void unpack_init(unpack_context* ctx)
ctx->cs = CS_HEADER;
ctx->trail = 0;
ctx->top = 0;
/*
ctx->stack = ctx->embed_stack;
ctx->stack_size = MSGPACK_EMBED_STACK_SIZE;
*/
ctx->stack[0].obj = unpack_callback_root(&ctx->user);
ctx->stack[0].obj = NULL;
}

/*
static inline void unpack_destroy(unpack_context* ctx)
{
if(ctx->stack_size != MSGPACK_EMBED_STACK_SIZE) {
free(ctx->stack);
}
}
*/

static inline PyObject* unpack_data(unpack_context* ctx)
{
return (ctx)->stack[0].obj;
Expand Down Expand Up @@ -94,9 +76,6 @@ static inline int unpack_execute(bool construct, unpack_context* ctx, const char
unsigned int cs = ctx->cs;
unsigned int top = ctx->top;
unpack_stack* stack = ctx->stack;
/*
unsigned int stack_size = ctx->stack_size;
*/
unpack_user* user = &ctx->user;

PyObject* obj = NULL;
Expand Down Expand Up @@ -319,6 +298,7 @@ static inline int unpack_execute(bool construct, unpack_context* ctx, const char
start_container(_map, _msgpack_load32(uint32_t,n), CT_MAP_KEY);

default:
PyErr_Format(PyExc_RuntimeError, "Invalid state: %d", cs);
goto _failed;
}
}
Expand Down Expand Up @@ -355,6 +335,7 @@ static inline int unpack_execute(bool construct, unpack_context* ctx, const char
goto _header_again;

default:
PyErr_Format(PyExc_RuntimeError, "Invalid container type: %u", c->ct);
goto _failed;
}

Expand Down
Loading