diff --git a/msgpack/fallback.py b/msgpack/fallback.py index 5f624b8..4307bc8 100644 --- a/msgpack/fallback.py +++ b/msgpack/fallback.py @@ -529,7 +529,7 @@ class Unpacker: raise ValueError("%s is not allowed for map key" % str(type(key))) if isinstance(key, str): key = sys.intern(key) - if isinstance(key, list): + elif isinstance(key, list): key = tuple(key) ret[key] = self._unpack(EX_CONSTRUCT) if self._object_hook is not None: diff --git a/msgpack/unpack.h b/msgpack/unpack.h index 4bd5fc4..28a0b04 100644 --- a/msgpack/unpack.h +++ b/msgpack/unpack.h @@ -198,8 +198,7 @@ static inline int unpack_callback_map_item(unpack_user* u, unsigned int current, } if (PyUnicode_CheckExact(k)) { PyUnicode_InternInPlace(&k); - } - if (PyList_CheckExact(k)) { + } else if (PyList_CheckExact(k)) { Py_ssize_t list_size = PyList_Size(k); PyObject* tuple = PyTuple_New(list_size);