/* Generated by Cython 0.29.32 */

/* BEGIN: Cython Metadata
{
    "distutils": {
        "depends": [],
        "name": "btdht.krcp",
        "sources": [
            "btdht/krcp.pyx"
        ]
    },
    "module_name": "btdht.krcp"
}
END: Cython Metadata */

#ifndef PY_SSIZE_T_CLEAN
#define PY_SSIZE_T_CLEAN
#endif /* PY_SSIZE_T_CLEAN */
#include "Python.h"
#ifndef Py_PYTHON_H
    #error Python headers needed to compile C extensions, please install development version of Python.
#elif PY_VERSION_HEX < 0x02060000 || (0x03000000 <= PY_VERSION_HEX && PY_VERSION_HEX < 0x03030000)
    #error Cython requires Python 2.6+ or Python 3.3+.
#else
#define CYTHON_ABI "0_29_32"
#define CYTHON_HEX_VERSION 0x001D20F0
#define CYTHON_FUTURE_DIVISION 0
#include <stddef.h>
#ifndef offsetof
  #define offsetof(type, member) ( (size_t) & ((type*)0) -> member )
#endif
#if !defined(WIN32) && !defined(MS_WINDOWS)
  #ifndef __stdcall
    #define __stdcall
  #endif
  #ifndef __cdecl
    #define __cdecl
  #endif
  #ifndef __fastcall
    #define __fastcall
  #endif
#endif
#ifndef DL_IMPORT
  #define DL_IMPORT(t) t
#endif
#ifndef DL_EXPORT
  #define DL_EXPORT(t) t
#endif
#define __PYX_COMMA ,
#ifndef HAVE_LONG_LONG
  #if PY_VERSION_HEX >= 0x02070000
    #define HAVE_LONG_LONG
  #endif
#endif
#ifndef PY_LONG_LONG
  #define PY_LONG_LONG LONG_LONG
#endif
#ifndef Py_HUGE_VAL
  #define Py_HUGE_VAL HUGE_VAL
#endif
#ifdef PYPY_VERSION
  #define CYTHON_COMPILING_IN_PYPY 1
  #define CYTHON_COMPILING_IN_PYSTON 0
  #define CYTHON_COMPILING_IN_CPYTHON 0
  #define CYTHON_COMPILING_IN_NOGIL 0
  #undef CYTHON_USE_TYPE_SLOTS
  #define CYTHON_USE_TYPE_SLOTS 0
  #undef CYTHON_USE_PYTYPE_LOOKUP
  #define CYTHON_USE_PYTYPE_LOOKUP 0
  #if PY_VERSION_HEX < 0x03050000
    #undef CYTHON_USE_ASYNC_SLOTS
    #define CYTHON_USE_ASYNC_SLOTS 0
  #elif !defined(CYTHON_USE_ASYNC_SLOTS)
    #define CYTHON_USE_ASYNC_SLOTS 1
  #endif
  #undef CYTHON_USE_PYLIST_INTERNALS
  #define CYTHON_USE_PYLIST_INTERNALS 0
  #undef CYTHON_USE_UNICODE_INTERNALS
  #define CYTHON_USE_UNICODE_INTERNALS 0
  #undef CYTHON_USE_UNICODE_WRITER
  #define CYTHON_USE_UNICODE_WRITER 0
  #undef CYTHON_USE_PYLONG_INTERNALS
  #define CYTHON_USE_PYLONG_INTERNALS 0
  #undef CYTHON_AVOID_BORROWED_REFS
  #define CYTHON_AVOID_BORROWED_REFS 1
  #undef CYTHON_ASSUME_SAFE_MACROS
  #define CYTHON_ASSUME_SAFE_MACROS 0
  #undef CYTHON_UNPACK_METHODS
  #define CYTHON_UNPACK_METHODS 0
  #undef CYTHON_FAST_THREAD_STATE
  #define CYTHON_FAST_THREAD_STATE 0
  #undef CYTHON_FAST_PYCALL
  #define CYTHON_FAST_PYCALL 0
  #undef CYTHON_PEP489_MULTI_PHASE_INIT
  #define CYTHON_PEP489_MULTI_PHASE_INIT 0
  #undef CYTHON_USE_TP_FINALIZE
  #define CYTHON_USE_TP_FINALIZE 0
  #undef CYTHON_USE_DICT_VERSIONS
  #define CYTHON_USE_DICT_VERSIONS 0
  #undef CYTHON_USE_EXC_INFO_STACK
  #define CYTHON_USE_EXC_INFO_STACK 0
  #ifndef CYTHON_UPDATE_DESCRIPTOR_DOC
    #define CYTHON_UPDATE_DESCRIPTOR_DOC (PYPY_VERSION_HEX >= 0x07030900)
  #endif
#elif defined(PYSTON_VERSION)
  #define CYTHON_COMPILING_IN_PYPY 0
  #define CYTHON_COMPILING_IN_PYSTON 1
  #define CYTHON_COMPILING_IN_CPYTHON 0
  #define CYTHON_COMPILING_IN_NOGIL 0
  #ifndef CYTHON_USE_TYPE_SLOTS
    #define CYTHON_USE_TYPE_SLOTS 1
  #endif
  #undef CYTHON_USE_PYTYPE_LOOKUP
  #define CYTHON_USE_PYTYPE_LOOKUP 0
  #undef CYTHON_USE_ASYNC_SLOTS
  #define CYTHON_USE_ASYNC_SLOTS 0
  #undef CYTHON_USE_PYLIST_INTERNALS
  #define CYTHON_USE_PYLIST_INTERNALS 0
  #ifndef CYTHON_USE_UNICODE_INTERNALS
    #define CYTHON_USE_UNICODE_INTERNALS 1
  #endif
  #undef CYTHON_USE_UNICODE_WRITER
  #define CYTHON_USE_UNICODE_WRITER 0
  #undef CYTHON_USE_PYLONG_INTERNALS
  #define CYTHON_USE_PYLONG_INTERNALS 0
  #ifndef CYTHON_AVOID_BORROWED_REFS
    #define CYTHON_AVOID_BORROWED_REFS 0
  #endif
  #ifndef CYTHON_ASSUME_SAFE_MACROS
    #define CYTHON_ASSUME_SAFE_MACROS 1
  #endif
  #ifndef CYTHON_UNPACK_METHODS
    #define CYTHON_UNPACK_METHODS 1
  #endif
  #undef CYTHON_FAST_THREAD_STATE
  #define CYTHON_FAST_THREAD_STATE 0
  #undef CYTHON_FAST_PYCALL
  #define CYTHON_FAST_PYCALL 0
  #undef CYTHON_PEP489_MULTI_PHASE_INIT
  #define CYTHON_PEP489_MULTI_PHASE_INIT 0
  #undef CYTHON_USE_TP_FINALIZE
  #define CYTHON_USE_TP_FINALIZE 0
  #undef CYTHON_USE_DICT_VERSIONS
  #define CYTHON_USE_DICT_VERSIONS 0
  #undef CYTHON_USE_EXC_INFO_STACK
  #define CYTHON_USE_EXC_INFO_STACK 0
  #ifndef CYTHON_UPDATE_DESCRIPTOR_DOC
    #define CYTHON_UPDATE_DESCRIPTOR_DOC 0
  #endif
#elif defined(PY_NOGIL)
  #define CYTHON_COMPILING_IN_PYPY 0
  #define CYTHON_COMPILING_IN_PYSTON 0
  #define CYTHON_COMPILING_IN_CPYTHON 0
  #define CYTHON_COMPILING_IN_NOGIL 1
  #ifndef CYTHON_USE_TYPE_SLOTS
    #define CYTHON_USE_TYPE_SLOTS 1
  #endif
  #undef CYTHON_USE_PYTYPE_LOOKUP
  #define CYTHON_USE_PYTYPE_LOOKUP 0
  #ifndef CYTHON_USE_ASYNC_SLOTS
    #define CYTHON_USE_ASYNC_SLOTS 1
  #endif
  #undef CYTHON_USE_PYLIST_INTERNALS
  #define CYTHON_USE_PYLIST_INTERNALS 0
  #ifndef CYTHON_USE_UNICODE_INTERNALS
    #define CYTHON_USE_UNICODE_INTERNALS 1
  #endif
  #undef CYTHON_USE_UNICODE_WRITER
  #define CYTHON_USE_UNICODE_WRITER 0
  #undef CYTHON_USE_PYLONG_INTERNALS
  #define CYTHON_USE_PYLONG_INTERNALS 0
  #ifndef CYTHON_AVOID_BORROWED_REFS
    #define CYTHON_AVOID_BORROWED_REFS 0
  #endif
  #ifndef CYTHON_ASSUME_SAFE_MACROS
    #define CYTHON_ASSUME_SAFE_MACROS 1
  #endif
  #ifndef CYTHON_UNPACK_METHODS
    #define CYTHON_UNPACK_METHODS 1
  #endif
  #undef CYTHON_FAST_THREAD_STATE
  #define CYTHON_FAST_THREAD_STATE 0
  #undef CYTHON_FAST_PYCALL
  #define CYTHON_FAST_PYCALL 0
  #ifndef CYTHON_PEP489_MULTI_PHASE_INIT
    #define CYTHON_PEP489_MULTI_PHASE_INIT 1
  #endif
  #ifndef CYTHON_USE_TP_FINALIZE
    #define CYTHON_USE_TP_FINALIZE 1
  #endif
  #undef CYTHON_USE_DICT_VERSIONS
  #define CYTHON_USE_DICT_VERSIONS 0
  #undef CYTHON_USE_EXC_INFO_STACK
  #define CYTHON_USE_EXC_INFO_STACK 0
#else
  #define CYTHON_COMPILING_IN_PYPY 0
  #define CYTHON_COMPILING_IN_PYSTON 0
  #define CYTHON_COMPILING_IN_CPYTHON 1
  #define CYTHON_COMPILING_IN_NOGIL 0
  #ifndef CYTHON_USE_TYPE_SLOTS
    #define CYTHON_USE_TYPE_SLOTS 1
  #endif
  #if PY_VERSION_HEX < 0x02070000
    #undef CYTHON_USE_PYTYPE_LOOKUP
    #define CYTHON_USE_PYTYPE_LOOKUP 0
  #elif !defined(CYTHON_USE_PYTYPE_LOOKUP)
    #define CYTHON_USE_PYTYPE_LOOKUP 1
  #endif
  #if PY_MAJOR_VERSION < 3
    #undef CYTHON_USE_ASYNC_SLOTS
    #define CYTHON_USE_ASYNC_SLOTS 0
  #elif !defined(CYTHON_USE_ASYNC_SLOTS)
    #define CYTHON_USE_ASYNC_SLOTS 1
  #endif
  #if PY_VERSION_HEX < 0x02070000
    #undef CYTHON_USE_PYLONG_INTERNALS
    #define CYTHON_USE_PYLONG_INTERNALS 0
  #elif !defined(CYTHON_USE_PYLONG_INTERNALS)
    #define CYTHON_USE_PYLONG_INTERNALS 1
  #endif
  #ifndef CYTHON_USE_PYLIST_INTERNALS
    #define CYTHON_USE_PYLIST_INTERNALS 1
  #endif
  #ifndef CYTHON_USE_UNICODE_INTERNALS
    #define CYTHON_USE_UNICODE_INTERNALS 1
  #endif
  #if PY_VERSION_HEX < 0x030300F0 || PY_VERSION_HEX >= 0x030B00A2
    #undef CYTHON_USE_UNICODE_WRITER
    #define CYTHON_USE_UNICODE_WRITER 0
  #elif !defined(CYTHON_USE_UNICODE_WRITER)
    #define CYTHON_USE_UNICODE_WRITER 1
  #endif
  #ifndef CYTHON_AVOID_BORROWED_REFS
    #define CYTHON_AVOID_BORROWED_REFS 0
  #endif
  #ifndef CYTHON_ASSUME_SAFE_MACROS
    #define CYTHON_ASSUME_SAFE_MACROS 1
  #endif
  #ifndef CYTHON_UNPACK_METHODS
    #define CYTHON_UNPACK_METHODS 1
  #endif
  #if PY_VERSION_HEX >= 0x030B00A4
    #undef CYTHON_FAST_THREAD_STATE
    #define CYTHON_FAST_THREAD_STATE 0
  #elif !defined(CYTHON_FAST_THREAD_STATE)
    #define CYTHON_FAST_THREAD_STATE 1
  #endif
  #ifndef CYTHON_FAST_PYCALL
    #define CYTHON_FAST_PYCALL (PY_VERSION_HEX < 0x030A0000)
  #endif
  #ifndef CYTHON_PEP489_MULTI_PHASE_INIT
    #define CYTHON_PEP489_MULTI_PHASE_INIT (PY_VERSION_HEX >= 0x03050000)
  #endif
  #ifndef CYTHON_USE_TP_FINALIZE
    #define CYTHON_USE_TP_FINALIZE (PY_VERSION_HEX >= 0x030400a1)
  #endif
  #ifndef CYTHON_USE_DICT_VERSIONS
    #define CYTHON_USE_DICT_VERSIONS (PY_VERSION_HEX >= 0x030600B1)
  #endif
  #if PY_VERSION_HEX >= 0x030B00A4
    #undef CYTHON_USE_EXC_INFO_STACK
    #define CYTHON_USE_EXC_INFO_STACK 0
  #elif !defined(CYTHON_USE_EXC_INFO_STACK)
    #define CYTHON_USE_EXC_INFO_STACK (PY_VERSION_HEX >= 0x030700A3)
  #endif
  #ifndef CYTHON_UPDATE_DESCRIPTOR_DOC
    #define CYTHON_UPDATE_DESCRIPTOR_DOC 1
  #endif
#endif
#if !defined(CYTHON_FAST_PYCCALL)
#define CYTHON_FAST_PYCCALL  (CYTHON_FAST_PYCALL && PY_VERSION_HEX >= 0x030600B1)
#endif
#if CYTHON_USE_PYLONG_INTERNALS
  #if PY_MAJOR_VERSION < 3
    #include "longintrepr.h"
  #endif
  #undef SHIFT
  #undef BASE
  #undef MASK
  #ifdef SIZEOF_VOID_P
    enum { __pyx_check_sizeof_voidp = 1 / (int)(SIZEOF_VOID_P == sizeof(void*)) };
  #endif
#endif
#ifndef __has_attribute
  #define __has_attribute(x) 0
#endif
#ifndef __has_cpp_attribute
  #define __has_cpp_attribute(x) 0
#endif
#ifndef CYTHON_RESTRICT
  #if defined(__GNUC__)
    #define CYTHON_RESTRICT __restrict__
  #elif defined(_MSC_VER) && _MSC_VER >= 1400
    #define CYTHON_RESTRICT __restrict
  #elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
    #define CYTHON_RESTRICT restrict
  #else
    #define CYTHON_RESTRICT
  #endif
#endif
#ifndef CYTHON_UNUSED
# if defined(__GNUC__)
#   if !(defined(__cplusplus)) || (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4))
#     define CYTHON_UNUSED __attribute__ ((__unused__))
#   else
#     define CYTHON_UNUSED
#   endif
# elif defined(__ICC) || (defined(__INTEL_COMPILER) && !defined(_MSC_VER))
#   define CYTHON_UNUSED __attribute__ ((__unused__))
# else
#   define CYTHON_UNUSED
# endif
#endif
#ifndef CYTHON_MAYBE_UNUSED_VAR
#  if defined(__cplusplus)
     template<class T> void CYTHON_MAYBE_UNUSED_VAR( const T& ) { }
#  else
#    define CYTHON_MAYBE_UNUSED_VAR(x) (void)(x)
#  endif
#endif
#ifndef CYTHON_NCP_UNUSED
# if CYTHON_COMPILING_IN_CPYTHON
#  define CYTHON_NCP_UNUSED
# else
#  define CYTHON_NCP_UNUSED CYTHON_UNUSED
# endif
#endif
#define __Pyx_void_to_None(void_result) ((void)(void_result), Py_INCREF(Py_None), Py_None)
#ifdef _MSC_VER
    #ifndef _MSC_STDINT_H_
        #if _MSC_VER < 1300
           typedef unsigned char     uint8_t;
           typedef unsigned int      uint32_t;
        #else
           typedef unsigned __int8   uint8_t;
           typedef unsigned __int32  uint32_t;
        #endif
    #endif
#else
   #include <stdint.h>
#endif
#ifndef CYTHON_FALLTHROUGH
  #if defined(__cplusplus) && __cplusplus >= 201103L
    #if __has_cpp_attribute(fallthrough)
      #define CYTHON_FALLTHROUGH [[fallthrough]]
    #elif __has_cpp_attribute(clang::fallthrough)
      #define CYTHON_FALLTHROUGH [[clang::fallthrough]]
    #elif __has_cpp_attribute(gnu::fallthrough)
      #define CYTHON_FALLTHROUGH [[gnu::fallthrough]]
    #endif
  #endif
  #ifndef CYTHON_FALLTHROUGH
    #if __has_attribute(fallthrough)
      #define CYTHON_FALLTHROUGH __attribute__((fallthrough))
    #else
      #define CYTHON_FALLTHROUGH
    #endif
  #endif
  #if defined(__clang__ ) && defined(__apple_build_version__)
    #if __apple_build_version__ < 7000000
      #undef  CYTHON_FALLTHROUGH
      #define CYTHON_FALLTHROUGH
    #endif
  #endif
#endif

#ifndef CYTHON_INLINE
  #if defined(__clang__)
    #define CYTHON_INLINE __inline__ __attribute__ ((__unused__))
  #elif defined(__GNUC__)
    #define CYTHON_INLINE __inline__
  #elif defined(_MSC_VER)
    #define CYTHON_INLINE __inline
  #elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
    #define CYTHON_INLINE inline
  #else
    #define CYTHON_INLINE
  #endif
#endif

#if CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX < 0x02070600 && !defined(Py_OptimizeFlag)
  #define Py_OptimizeFlag 0
#endif
#define __PYX_BUILD_PY_SSIZE_T "n"
#define CYTHON_FORMAT_SSIZE_T "z"
#if PY_MAJOR_VERSION < 3
  #define __Pyx_BUILTIN_MODULE_NAME "__builtin__"
  #define __Pyx_PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)\
          PyCode_New(a+k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)
  #define __Pyx_DefaultClassType PyClass_Type
#else
  #define __Pyx_BUILTIN_MODULE_NAME "builtins"
  #define __Pyx_DefaultClassType PyType_Type
#if PY_VERSION_HEX >= 0x030B00A1
    static CYTHON_INLINE PyCodeObject* __Pyx_PyCode_New(int a, int k, int l, int s, int f,
                                                    PyObject *code, PyObject *c, PyObject* n, PyObject *v,
                                                    PyObject *fv, PyObject *cell, PyObject* fn,
                                                    PyObject *name, int fline, PyObject *lnos) {
        PyObject *kwds=NULL, *argcount=NULL, *posonlyargcount=NULL, *kwonlyargcount=NULL;
        PyObject *nlocals=NULL, *stacksize=NULL, *flags=NULL, *replace=NULL, *call_result=NULL, *empty=NULL;
        const char *fn_cstr=NULL;
        const char *name_cstr=NULL;
        PyCodeObject* co=NULL;
        PyObject *type, *value, *traceback;
        PyErr_Fetch(&type, &value, &traceback);
        if (!(kwds=PyDict_New())) goto end;
        if (!(argcount=PyLong_FromLong(a))) goto end;
        if (PyDict_SetItemString(kwds, "co_argcount", argcount) != 0) goto end;
        if (!(posonlyargcount=PyLong_FromLong(0))) goto end;
        if (PyDict_SetItemString(kwds, "co_posonlyargcount", posonlyargcount) != 0) goto end;
        if (!(kwonlyargcount=PyLong_FromLong(k))) goto end;
        if (PyDict_SetItemString(kwds, "co_kwonlyargcount", kwonlyargcount) != 0) goto end;
        if (!(nlocals=PyLong_FromLong(l))) goto end;
        if (PyDict_SetItemString(kwds, "co_nlocals", nlocals) != 0) goto end;
        if (!(stacksize=PyLong_FromLong(s))) goto end;
        if (PyDict_SetItemString(kwds, "co_stacksize", stacksize) != 0) goto end;
        if (!(flags=PyLong_FromLong(f))) goto end;
        if (PyDict_SetItemString(kwds, "co_flags", flags) != 0) goto end;
        if (PyDict_SetItemString(kwds, "co_code", code) != 0) goto end;
        if (PyDict_SetItemString(kwds, "co_consts", c) != 0) goto end;
        if (PyDict_SetItemString(kwds, "co_names", n) != 0) goto end;
        if (PyDict_SetItemString(kwds, "co_varnames", v) != 0) goto end;
        if (PyDict_SetItemString(kwds, "co_freevars", fv) != 0) goto end;
        if (PyDict_SetItemString(kwds, "co_cellvars", cell) != 0) goto end;
        if (PyDict_SetItemString(kwds, "co_linetable", lnos) != 0) goto end;
        if (!(fn_cstr=PyUnicode_AsUTF8AndSize(fn, NULL))) goto end;
        if (!(name_cstr=PyUnicode_AsUTF8AndSize(name, NULL))) goto end;
        if (!(co = PyCode_NewEmpty(fn_cstr, name_cstr, fline))) goto end;
        if (!(replace = PyObject_GetAttrString((PyObject*)co, "replace"))) goto cleanup_code_too;
        if (!(empty = PyTuple_New(0))) goto cleanup_code_too; // unfortunately __pyx_empty_tuple isn't available here
        if (!(call_result = PyObject_Call(replace, empty, kwds))) goto cleanup_code_too;
        Py_XDECREF((PyObject*)co);
        co = (PyCodeObject*)call_result;
        call_result = NULL;
        if (0) {
            cleanup_code_too:
            Py_XDECREF((PyObject*)co);
            co = NULL;
        }
        end:
        Py_XDECREF(kwds);
        Py_XDECREF(argcount);
        Py_XDECREF(posonlyargcount);
        Py_XDECREF(kwonlyargcount);
        Py_XDECREF(nlocals);
        Py_XDECREF(stacksize);
        Py_XDECREF(replace);
        Py_XDECREF(call_result);
        Py_XDECREF(empty);
        if (type) {
            PyErr_Restore(type, value, traceback);
        }
        return co;
    }
#else
  #define __Pyx_PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)\
          PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)
#endif
  #define __Pyx_DefaultClassType PyType_Type
#endif
#ifndef Py_TPFLAGS_CHECKTYPES
  #define Py_TPFLAGS_CHECKTYPES 0
#endif
#ifndef Py_TPFLAGS_HAVE_INDEX
  #define Py_TPFLAGS_HAVE_INDEX 0
#endif
#ifndef Py_TPFLAGS_HAVE_NEWBUFFER
  #define Py_TPFLAGS_HAVE_NEWBUFFER 0
#endif
#ifndef Py_TPFLAGS_HAVE_FINALIZE
  #define Py_TPFLAGS_HAVE_FINALIZE 0
#endif
#ifndef METH_STACKLESS
  #define METH_STACKLESS 0
#endif
#if PY_VERSION_HEX <= 0x030700A3 || !defined(METH_FASTCALL)
  #ifndef METH_FASTCALL
     #define METH_FASTCALL 0x80
  #endif
  typedef PyObject *(*__Pyx_PyCFunctionFast) (PyObject *self, PyObject *const *args, Py_ssize_t nargs);
  typedef PyObject *(*__Pyx_PyCFunctionFastWithKeywords) (PyObject *self, PyObject *const *args,
                                                          Py_ssize_t nargs, PyObject *kwnames);
#else
  #define __Pyx_PyCFunctionFast _PyCFunctionFast
  #define __Pyx_PyCFunctionFastWithKeywords _PyCFunctionFastWithKeywords
#endif
#if CYTHON_FAST_PYCCALL
#define __Pyx_PyFastCFunction_Check(func)\
    ((PyCFunction_Check(func) && (METH_FASTCALL == (PyCFunction_GET_FLAGS(func) & ~(METH_CLASS | METH_STATIC | METH_COEXIST | METH_KEYWORDS | METH_STACKLESS)))))
#else
#define __Pyx_PyFastCFunction_Check(func) 0
#endif
#if CYTHON_COMPILING_IN_PYPY && !defined(PyObject_Malloc)
  #define PyObject_Malloc(s)   PyMem_Malloc(s)
  #define PyObject_Free(p)     PyMem_Free(p)
  #define PyObject_Realloc(p)  PyMem_Realloc(p)
#endif
#if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX < 0x030400A1
  #define PyMem_RawMalloc(n)           PyMem_Malloc(n)
  #define PyMem_RawRealloc(p, n)       PyMem_Realloc(p, n)
  #define PyMem_RawFree(p)             PyMem_Free(p)
#endif
#if CYTHON_COMPILING_IN_PYSTON
  #define __Pyx_PyCode_HasFreeVars(co)  PyCode_HasFreeVars(co)
  #define __Pyx_PyFrame_SetLineNumber(frame, lineno) PyFrame_SetLineNumber(frame, lineno)
#else
  #define __Pyx_PyCode_HasFreeVars(co)  (PyCode_GetNumFree(co) > 0)
  #define __Pyx_PyFrame_SetLineNumber(frame, lineno)  (frame)->f_lineno = (lineno)
#endif
#if !CYTHON_FAST_THREAD_STATE || PY_VERSION_HEX < 0x02070000
  #define __Pyx_PyThreadState_Current PyThreadState_GET()
#elif PY_VERSION_HEX >= 0x03060000
  #define __Pyx_PyThreadState_Current _PyThreadState_UncheckedGet()
#elif PY_VERSION_HEX >= 0x03000000
  #define __Pyx_PyThreadState_Current PyThreadState_GET()
#else
  #define __Pyx_PyThreadState_Current _PyThreadState_Current
#endif
#if PY_VERSION_HEX < 0x030700A2 && !defined(PyThread_tss_create) && !defined(Py_tss_NEEDS_INIT)
#include "pythread.h"
#define Py_tss_NEEDS_INIT 0
typedef int Py_tss_t;
static CYTHON_INLINE int PyThread_tss_create(Py_tss_t *key) {
  *key = PyThread_create_key();
  return 0;
}
static CYTHON_INLINE Py_tss_t * PyThread_tss_alloc(void) {
  Py_tss_t *key = (Py_tss_t *)PyObject_Malloc(sizeof(Py_tss_t));
  *key = Py_tss_NEEDS_INIT;
  return key;
}
static CYTHON_INLINE void PyThread_tss_free(Py_tss_t *key) {
  PyObject_Free(key);
}
static CYTHON_INLINE int PyThread_tss_is_created(Py_tss_t *key) {
  return *key != Py_tss_NEEDS_INIT;
}
static CYTHON_INLINE void PyThread_tss_delete(Py_tss_t *key) {
  PyThread_delete_key(*key);
  *key = Py_tss_NEEDS_INIT;
}
static CYTHON_INLINE int PyThread_tss_set(Py_tss_t *key, void *value) {
  return PyThread_set_key_value(*key, value);
}
static CYTHON_INLINE void * PyThread_tss_get(Py_tss_t *key) {
  return PyThread_get_key_value(*key);
}
#endif
#if CYTHON_COMPILING_IN_CPYTHON || defined(_PyDict_NewPresized)
#define __Pyx_PyDict_NewPresized(n)  ((n <= 8) ? PyDict_New() : _PyDict_NewPresized(n))
#else
#define __Pyx_PyDict_NewPresized(n)  PyDict_New()
#endif
#if PY_MAJOR_VERSION >= 3 || CYTHON_FUTURE_DIVISION
  #define __Pyx_PyNumber_Divide(x,y)         PyNumber_TrueDivide(x,y)
  #define __Pyx_PyNumber_InPlaceDivide(x,y)  PyNumber_InPlaceTrueDivide(x,y)
#else
  #define __Pyx_PyNumber_Divide(x,y)         PyNumber_Divide(x,y)
  #define __Pyx_PyNumber_InPlaceDivide(x,y)  PyNumber_InPlaceDivide(x,y)
#endif
#if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030500A1 && CYTHON_USE_UNICODE_INTERNALS
#define __Pyx_PyDict_GetItemStr(dict, name)  _PyDict_GetItem_KnownHash(dict, name, ((PyASCIIObject *) name)->hash)
#else
#define __Pyx_PyDict_GetItemStr(dict, name)  PyDict_GetItem(dict, name)
#endif
#if PY_VERSION_HEX > 0x03030000 && defined(PyUnicode_KIND)
  #define CYTHON_PEP393_ENABLED 1
  #if defined(PyUnicode_IS_READY)
  #define __Pyx_PyUnicode_READY(op)       (likely(PyUnicode_IS_READY(op)) ?\
                                              0 : _PyUnicode_Ready((PyObject *)(op)))
  #else
  #define __Pyx_PyUnicode_READY(op)       (0)
  #endif
  #define __Pyx_PyUnicode_GET_LENGTH(u)   PyUnicode_GET_LENGTH(u)
  #define __Pyx_PyUnicode_READ_CHAR(u, i) PyUnicode_READ_CHAR(u, i)
  #define __Pyx_PyUnicode_MAX_CHAR_VALUE(u)   PyUnicode_MAX_CHAR_VALUE(u)
  #define __Pyx_PyUnicode_KIND(u)         PyUnicode_KIND(u)
  #define __Pyx_PyUnicode_DATA(u)         PyUnicode_DATA(u)
  #define __Pyx_PyUnicode_READ(k, d, i)   PyUnicode_READ(k, d, i)
  #define __Pyx_PyUnicode_WRITE(k, d, i, ch)  PyUnicode_WRITE(k, d, i, ch)
  #if defined(PyUnicode_IS_READY) && defined(PyUnicode_GET_SIZE)
  #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x03090000
  #define __Pyx_PyUnicode_IS_TRUE(u)      (0 != (likely(PyUnicode_IS_READY(u)) ? PyUnicode_GET_LENGTH(u) : ((PyCompactUnicodeObject *)(u))->wstr_length))
  #else
  #define __Pyx_PyUnicode_IS_TRUE(u)      (0 != (likely(PyUnicode_IS_READY(u)) ? PyUnicode_GET_LENGTH(u) : PyUnicode_GET_SIZE(u)))
  #endif
  #else
  #define __Pyx_PyUnicode_IS_TRUE(u)      (0 != PyUnicode_GET_LENGTH(u))
  #endif
#else
  #define CYTHON_PEP393_ENABLED 0
  #define PyUnicode_1BYTE_KIND  1
  #define PyUnicode_2BYTE_KIND  2
  #define PyUnicode_4BYTE_KIND  4
  #define __Pyx_PyUnicode_READY(op)       (0)
  #define __Pyx_PyUnicode_GET_LENGTH(u)   PyUnicode_GET_SIZE(u)
  #define __Pyx_PyUnicode_READ_CHAR(u, i) ((Py_UCS4)(PyUnicode_AS_UNICODE(u)[i]))
  #define __Pyx_PyUnicode_MAX_CHAR_VALUE(u)   ((sizeof(Py_UNICODE) == 2) ? 65535 : 1114111)
  #define __Pyx_PyUnicode_KIND(u)         (sizeof(Py_UNICODE))
  #define __Pyx_PyUnicode_DATA(u)         ((void*)PyUnicode_AS_UNICODE(u))
  #define __Pyx_PyUnicode_READ(k, d, i)   ((void)(k), (Py_UCS4)(((Py_UNICODE*)d)[i]))
  #define __Pyx_PyUnicode_WRITE(k, d, i, ch)  (((void)(k)), ((Py_UNICODE*)d)[i] = ch)
  #define __Pyx_PyUnicode_IS_TRUE(u)      (0 != PyUnicode_GET_SIZE(u))
#endif
#if CYTHON_COMPILING_IN_PYPY
  #define __Pyx_PyUnicode_Concat(a, b)      PyNumber_Add(a, b)
  #define __Pyx_PyUnicode_ConcatSafe(a, b)  PyNumber_Add(a, b)
#else
  #define __Pyx_PyUnicode_Concat(a, b)      PyUnicode_Concat(a, b)
  #define __Pyx_PyUnicode_ConcatSafe(a, b)  ((unlikely((a) == Py_None) || unlikely((b) == Py_None)) ?\
      PyNumber_Add(a, b) : __Pyx_PyUnicode_Concat(a, b))
#endif
#if CYTHON_COMPILING_IN_PYPY && !defined(PyUnicode_Contains)
  #define PyUnicode_Contains(u, s)  PySequence_Contains(u, s)
#endif
#if CYTHON_COMPILING_IN_PYPY && !defined(PyByteArray_Check)
  #define PyByteArray_Check(obj)  PyObject_TypeCheck(obj, &PyByteArray_Type)
#endif
#if CYTHON_COMPILING_IN_PYPY && !defined(PyObject_Format)
  #define PyObject_Format(obj, fmt)  PyObject_CallMethod(obj, "__format__", "O", fmt)
#endif
#define __Pyx_PyString_FormatSafe(a, b)   ((unlikely((a) == Py_None || (PyString_Check(b) && !PyString_CheckExact(b)))) ? PyNumber_Remainder(a, b) : __Pyx_PyString_Format(a, b))
#define __Pyx_PyUnicode_FormatSafe(a, b)  ((unlikely((a) == Py_None || (PyUnicode_Check(b) && !PyUnicode_CheckExact(b)))) ? PyNumber_Remainder(a, b) : PyUnicode_Format(a, b))
#if PY_MAJOR_VERSION >= 3
  #define __Pyx_PyString_Format(a, b)  PyUnicode_Format(a, b)
#else
  #define __Pyx_PyString_Format(a, b)  PyString_Format(a, b)
#endif
#if PY_MAJOR_VERSION < 3 && !defined(PyObject_ASCII)
  #define PyObject_ASCII(o)            PyObject_Repr(o)
#endif
#if PY_MAJOR_VERSION >= 3
  #define PyBaseString_Type            PyUnicode_Type
  #define PyStringObject               PyUnicodeObject
  #define PyString_Type                PyUnicode_Type
  #define PyString_Check               PyUnicode_Check
  #define PyString_CheckExact          PyUnicode_CheckExact
#ifndef PyObject_Unicode
  #define PyObject_Unicode             PyObject_Str
#endif
#endif
#if PY_MAJOR_VERSION >= 3
  #define __Pyx_PyBaseString_Check(obj) PyUnicode_Check(obj)
  #define __Pyx_PyBaseString_CheckExact(obj) PyUnicode_CheckExact(obj)
#else
  #define __Pyx_PyBaseString_Check(obj) (PyString_Check(obj) || PyUnicode_Check(obj))
  #define __Pyx_PyBaseString_CheckExact(obj) (PyString_CheckExact(obj) || PyUnicode_CheckExact(obj))
#endif
#ifndef PySet_CheckExact
  #define PySet_CheckExact(obj)        (Py_TYPE(obj) == &PySet_Type)
#endif
#if PY_VERSION_HEX >= 0x030900A4
  #define __Pyx_SET_REFCNT(obj, refcnt) Py_SET_REFCNT(obj, refcnt)
  #define __Pyx_SET_SIZE(obj, size) Py_SET_SIZE(obj, size)
#else
  #define __Pyx_SET_REFCNT(obj, refcnt) Py_REFCNT(obj) = (refcnt)
  #define __Pyx_SET_SIZE(obj, size) Py_SIZE(obj) = (size)
#endif
#if CYTHON_ASSUME_SAFE_MACROS
  #define __Pyx_PySequence_SIZE(seq)  Py_SIZE(seq)
#else
  #define __Pyx_PySequence_SIZE(seq)  PySequence_Size(seq)
#endif
#if PY_MAJOR_VERSION >= 3
  #define PyIntObject                  PyLongObject
  #define PyInt_Type                   PyLong_Type
  #define PyInt_Check(op)              PyLong_Check(op)
  #define PyInt_CheckExact(op)         PyLong_CheckExact(op)
  #define PyInt_FromString             PyLong_FromString
  #define PyInt_FromUnicode            PyLong_FromUnicode
  #define PyInt_FromLong               PyLong_FromLong
  #define PyInt_FromSize_t             PyLong_FromSize_t
  #define PyInt_FromSsize_t            PyLong_FromSsize_t
  #define PyInt_AsLong                 PyLong_AsLong
  #define PyInt_AS_LONG                PyLong_AS_LONG
  #define PyInt_AsSsize_t              PyLong_AsSsize_t
  #define PyInt_AsUnsignedLongMask     PyLong_AsUnsignedLongMask
  #define PyInt_AsUnsignedLongLongMask PyLong_AsUnsignedLongLongMask
  #define PyNumber_Int                 PyNumber_Long
#endif
#if PY_MAJOR_VERSION >= 3
  #define PyBoolObject                 PyLongObject
#endif
#if PY_MAJOR_VERSION >= 3 && CYTHON_COMPILING_IN_PYPY
  #ifndef PyUnicode_InternFromString
    #define PyUnicode_InternFromString(s) PyUnicode_FromString(s)
  #endif
#endif
#if PY_VERSION_HEX < 0x030200A4
  typedef long Py_hash_t;
  #define __Pyx_PyInt_FromHash_t PyInt_FromLong
  #define __Pyx_PyInt_AsHash_t   __Pyx_PyIndex_AsHash_t
#else
  #define __Pyx_PyInt_FromHash_t PyInt_FromSsize_t
  #define __Pyx_PyInt_AsHash_t   __Pyx_PyIndex_AsSsize_t
#endif
#if PY_MAJOR_VERSION >= 3
  #define __Pyx_PyMethod_New(func, self, klass) ((self) ? ((void)(klass), PyMethod_New(func, self)) : __Pyx_NewRef(func))
#else
  #define __Pyx_PyMethod_New(func, self, klass) PyMethod_New(func, self, klass)
#endif
#if CYTHON_USE_ASYNC_SLOTS
  #if PY_VERSION_HEX >= 0x030500B1
    #define __Pyx_PyAsyncMethodsStruct PyAsyncMethods
    #define __Pyx_PyType_AsAsync(obj) (Py_TYPE(obj)->tp_as_async)
  #else
    #define __Pyx_PyType_AsAsync(obj) ((__Pyx_PyAsyncMethodsStruct*) (Py_TYPE(obj)->tp_reserved))
  #endif
#else
  #define __Pyx_PyType_AsAsync(obj) NULL
#endif
#ifndef __Pyx_PyAsyncMethodsStruct
    typedef struct {
        unaryfunc am_await;
        unaryfunc am_aiter;
        unaryfunc am_anext;
    } __Pyx_PyAsyncMethodsStruct;
#endif

#if defined(_WIN32) || defined(WIN32) || defined(MS_WINDOWS)
  #if !defined(_USE_MATH_DEFINES)
    #define _USE_MATH_DEFINES
  #endif
#endif
#include <math.h>
#ifdef NAN
#define __PYX_NAN() ((float) NAN)
#else
static CYTHON_INLINE float __PYX_NAN() {
  float value;
  memset(&value, 0xFF, sizeof(value));
  return value;
}
#endif
#if defined(__CYGWIN__) && defined(_LDBL_EQ_DBL)
#define __Pyx_truncl trunc
#else
#define __Pyx_truncl truncl
#endif

#define __PYX_MARK_ERR_POS(f_index, lineno) \
    { __pyx_filename = __pyx_f[f_index]; (void)__pyx_filename; __pyx_lineno = lineno; (void)__pyx_lineno; __pyx_clineno = __LINE__; (void)__pyx_clineno; }
#define __PYX_ERR(f_index, lineno, Ln_error) \
    { __PYX_MARK_ERR_POS(f_index, lineno) goto Ln_error; }

#ifndef __PYX_EXTERN_C
  #ifdef __cplusplus
    #define __PYX_EXTERN_C extern "C"
  #else
    #define __PYX_EXTERN_C extern
  #endif
#endif

#define __PYX_HAVE__btdht__krcp
#define __PYX_HAVE_API__btdht__krcp
/* Early includes */
#include <math.h>
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
#ifdef _OPENMP
#include <omp.h>
#endif /* _OPENMP */

#if defined(PYREX_WITHOUT_ASSERTIONS) && !defined(CYTHON_WITHOUT_ASSERTIONS)
#define CYTHON_WITHOUT_ASSERTIONS
#endif

typedef struct {PyObject **p; const char *s; const Py_ssize_t n; const char* encoding;
                const char is_unicode; const char is_str; const char intern; } __Pyx_StringTabEntry;

#define __PYX_DEFAULT_STRING_ENCODING_IS_ASCII 0
#define __PYX_DEFAULT_STRING_ENCODING_IS_UTF8 0
#define __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT (PY_MAJOR_VERSION >= 3 && __PYX_DEFAULT_STRING_ENCODING_IS_UTF8)
#define __PYX_DEFAULT_STRING_ENCODING ""
#define __Pyx_PyObject_FromString __Pyx_PyBytes_FromString
#define __Pyx_PyObject_FromStringAndSize __Pyx_PyBytes_FromStringAndSize
#define __Pyx_uchar_cast(c) ((unsigned char)c)
#define __Pyx_long_cast(x) ((long)x)
#define __Pyx_fits_Py_ssize_t(v, type, is_signed)  (\
    (sizeof(type) < sizeof(Py_ssize_t))  ||\
    (sizeof(type) > sizeof(Py_ssize_t) &&\
          likely(v < (type)PY_SSIZE_T_MAX ||\
                 v == (type)PY_SSIZE_T_MAX)  &&\
          (!is_signed || likely(v > (type)PY_SSIZE_T_MIN ||\
                                v == (type)PY_SSIZE_T_MIN)))  ||\
    (sizeof(type) == sizeof(Py_ssize_t) &&\
          (is_signed || likely(v < (type)PY_SSIZE_T_MAX ||\
                               v == (type)PY_SSIZE_T_MAX)))  )
static CYTHON_INLINE int __Pyx_is_valid_index(Py_ssize_t i, Py_ssize_t limit) {
    return (size_t) i < (size_t) limit;
}
#if defined (__cplusplus) && __cplusplus >= 201103L
    #include <cstdlib>
    #define __Pyx_sst_abs(value) std::abs(value)
#elif SIZEOF_INT >= SIZEOF_SIZE_T
    #define __Pyx_sst_abs(value) abs(value)
#elif SIZEOF_LONG >= SIZEOF_SIZE_T
    #define __Pyx_sst_abs(value) labs(value)
#elif defined (_MSC_VER)
    #define __Pyx_sst_abs(value) ((Py_ssize_t)_abs64(value))
#elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
    #define __Pyx_sst_abs(value) llabs(value)
#elif defined (__GNUC__)
    #define __Pyx_sst_abs(value) __builtin_llabs(value)
#else
    #define __Pyx_sst_abs(value) ((value<0) ? -value : value)
#endif
static CYTHON_INLINE const char* __Pyx_PyObject_AsString(PyObject*);
static CYTHON_INLINE const char* __Pyx_PyObject_AsStringAndSize(PyObject*, Py_ssize_t* length);
#define __Pyx_PyByteArray_FromString(s) PyByteArray_FromStringAndSize((const char*)s, strlen((const char*)s))
#define __Pyx_PyByteArray_FromStringAndSize(s, l) PyByteArray_FromStringAndSize((const char*)s, l)
#define __Pyx_PyBytes_FromString        PyBytes_FromString
#define __Pyx_PyBytes_FromStringAndSize PyBytes_FromStringAndSize
static CYTHON_INLINE PyObject* __Pyx_PyUnicode_FromString(const char*);
#if PY_MAJOR_VERSION < 3
    #define __Pyx_PyStr_FromString        __Pyx_PyBytes_FromString
    #define __Pyx_PyStr_FromStringAndSize __Pyx_PyBytes_FromStringAndSize
#else
    #define __Pyx_PyStr_FromString        __Pyx_PyUnicode_FromString
    #define __Pyx_PyStr_FromStringAndSize __Pyx_PyUnicode_FromStringAndSize
#endif
#define __Pyx_PyBytes_AsWritableString(s)     ((char*) PyBytes_AS_STRING(s))
#define __Pyx_PyBytes_AsWritableSString(s)    ((signed char*) PyBytes_AS_STRING(s))
#define __Pyx_PyBytes_AsWritableUString(s)    ((unsigned char*) PyBytes_AS_STRING(s))
#define __Pyx_PyBytes_AsString(s)     ((const char*) PyBytes_AS_STRING(s))
#define __Pyx_PyBytes_AsSString(s)    ((const signed char*) PyBytes_AS_STRING(s))
#define __Pyx_PyBytes_AsUString(s)    ((const unsigned char*) PyBytes_AS_STRING(s))
#define __Pyx_PyObject_AsWritableString(s)    ((char*) __Pyx_PyObject_AsString(s))
#define __Pyx_PyObject_AsWritableSString(s)    ((signed char*) __Pyx_PyObject_AsString(s))
#define __Pyx_PyObject_AsWritableUString(s)    ((unsigned char*) __Pyx_PyObject_AsString(s))
#define __Pyx_PyObject_AsSString(s)    ((const signed char*) __Pyx_PyObject_AsString(s))
#define __Pyx_PyObject_AsUString(s)    ((const unsigned char*) __Pyx_PyObject_AsString(s))
#define __Pyx_PyObject_FromCString(s)  __Pyx_PyObject_FromString((const char*)s)
#define __Pyx_PyBytes_FromCString(s)   __Pyx_PyBytes_FromString((const char*)s)
#define __Pyx_PyByteArray_FromCString(s)   __Pyx_PyByteArray_FromString((const char*)s)
#define __Pyx_PyStr_FromCString(s)     __Pyx_PyStr_FromString((const char*)s)
#define __Pyx_PyUnicode_FromCString(s) __Pyx_PyUnicode_FromString((const char*)s)
static CYTHON_INLINE size_t __Pyx_Py_UNICODE_strlen(const Py_UNICODE *u) {
    const Py_UNICODE *u_end = u;
    while (*u_end++) ;
    return (size_t)(u_end - u - 1);
}
#define __Pyx_PyUnicode_FromUnicode(u)       PyUnicode_FromUnicode(u, __Pyx_Py_UNICODE_strlen(u))
#define __Pyx_PyUnicode_FromUnicodeAndLength PyUnicode_FromUnicode
#define __Pyx_PyUnicode_AsUnicode            PyUnicode_AsUnicode
#define __Pyx_NewRef(obj) (Py_INCREF(obj), obj)
#define __Pyx_Owned_Py_None(b) __Pyx_NewRef(Py_None)
static CYTHON_INLINE PyObject * __Pyx_PyBool_FromLong(long b);
static CYTHON_INLINE int __Pyx_PyObject_IsTrue(PyObject*);
static CYTHON_INLINE int __Pyx_PyObject_IsTrueAndDecref(PyObject*);
static CYTHON_INLINE PyObject* __Pyx_PyNumber_IntOrLong(PyObject* x);
#define __Pyx_PySequence_Tuple(obj)\
    (likely(PyTuple_CheckExact(obj)) ? __Pyx_NewRef(obj) : PySequence_Tuple(obj))
static CYTHON_INLINE Py_ssize_t __Pyx_PyIndex_AsSsize_t(PyObject*);
static CYTHON_INLINE PyObject * __Pyx_PyInt_FromSize_t(size_t);
static CYTHON_INLINE Py_hash_t __Pyx_PyIndex_AsHash_t(PyObject*);
#if CYTHON_ASSUME_SAFE_MACROS
#define __pyx_PyFloat_AsDouble(x) (PyFloat_CheckExact(x) ? PyFloat_AS_DOUBLE(x) : PyFloat_AsDouble(x))
#else
#define __pyx_PyFloat_AsDouble(x) PyFloat_AsDouble(x)
#endif
#define __pyx_PyFloat_AsFloat(x) ((float) __pyx_PyFloat_AsDouble(x))
#if PY_MAJOR_VERSION >= 3
#define __Pyx_PyNumber_Int(x) (PyLong_CheckExact(x) ? __Pyx_NewRef(x) : PyNumber_Long(x))
#else
#define __Pyx_PyNumber_Int(x) (PyInt_CheckExact(x) ? __Pyx_NewRef(x) : PyNumber_Int(x))
#endif
#define __Pyx_PyNumber_Float(x) (PyFloat_CheckExact(x) ? __Pyx_NewRef(x) : PyNumber_Float(x))
#if PY_MAJOR_VERSION < 3 && __PYX_DEFAULT_STRING_ENCODING_IS_ASCII
static int __Pyx_sys_getdefaultencoding_not_ascii;
static int __Pyx_init_sys_getdefaultencoding_params(void) {
    PyObject* sys;
    PyObject* default_encoding = NULL;
    PyObject* ascii_chars_u = NULL;
    PyObject* ascii_chars_b = NULL;
    const char* default_encoding_c;
    sys = PyImport_ImportModule("sys");
    if (!sys) goto bad;
    default_encoding = PyObject_CallMethod(sys, (char*) "getdefaultencoding", NULL);
    Py_DECREF(sys);
    if (!default_encoding) goto bad;
    default_encoding_c = PyBytes_AsString(default_encoding);
    if (!default_encoding_c) goto bad;
    if (strcmp(default_encoding_c, "ascii") == 0) {
        __Pyx_sys_getdefaultencoding_not_ascii = 0;
    } else {
        char ascii_chars[128];
        int c;
        for (c = 0; c < 128; c++) {
            ascii_chars[c] = c;
        }
        __Pyx_sys_getdefaultencoding_not_ascii = 1;
        ascii_chars_u = PyUnicode_DecodeASCII(ascii_chars, 128, NULL);
        if (!ascii_chars_u) goto bad;
        ascii_chars_b = PyUnicode_AsEncodedString(ascii_chars_u, default_encoding_c, NULL);
        if (!ascii_chars_b || !PyBytes_Check(ascii_chars_b) || memcmp(ascii_chars, PyBytes_AS_STRING(ascii_chars_b), 128) != 0) {
            PyErr_Format(
                PyExc_ValueError,
                "This module compiled with c_string_encoding=ascii, but default encoding '%.200s' is not a superset of ascii.",
                default_encoding_c);
            goto bad;
        }
        Py_DECREF(ascii_chars_u);
        Py_DECREF(ascii_chars_b);
    }
    Py_DECREF(default_encoding);
    return 0;
bad:
    Py_XDECREF(default_encoding);
    Py_XDECREF(ascii_chars_u);
    Py_XDECREF(ascii_chars_b);
    return -1;
}
#endif
#if __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT && PY_MAJOR_VERSION >= 3
#define __Pyx_PyUnicode_FromStringAndSize(c_str, size) PyUnicode_DecodeUTF8(c_str, size, NULL)
#else
#define __Pyx_PyUnicode_FromStringAndSize(c_str, size) PyUnicode_Decode(c_str, size, __PYX_DEFAULT_STRING_ENCODING, NULL)
#if __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT
static char* __PYX_DEFAULT_STRING_ENCODING;
static int __Pyx_init_sys_getdefaultencoding_params(void) {
    PyObject* sys;
    PyObject* default_encoding = NULL;
    char* default_encoding_c;
    sys = PyImport_ImportModule("sys");
    if (!sys) goto bad;
    default_encoding = PyObject_CallMethod(sys, (char*) (const char*) "getdefaultencoding", NULL);
    Py_DECREF(sys);
    if (!default_encoding) goto bad;
    default_encoding_c = PyBytes_AsString(default_encoding);
    if (!default_encoding_c) goto bad;
    __PYX_DEFAULT_STRING_ENCODING = (char*) malloc(strlen(default_encoding_c) + 1);
    if (!__PYX_DEFAULT_STRING_ENCODING) goto bad;
    strcpy(__PYX_DEFAULT_STRING_ENCODING, default_encoding_c);
    Py_DECREF(default_encoding);
    return 0;
bad:
    Py_XDECREF(default_encoding);
    return -1;
}
#endif
#endif


/* Test for GCC > 2.95 */
#if defined(__GNUC__)     && (__GNUC__ > 2 || (__GNUC__ == 2 && (__GNUC_MINOR__ > 95)))
  #define likely(x)   __builtin_expect(!!(x), 1)
  #define unlikely(x) __builtin_expect(!!(x), 0)
#else /* !__GNUC__ or GCC < 2.95 */
  #define likely(x)   (x)
  #define unlikely(x) (x)
#endif /* __GNUC__ */
static CYTHON_INLINE void __Pyx_pretend_to_initialize(void* ptr) { (void)ptr; }

static PyObject *__pyx_m = NULL;
static PyObject *__pyx_d;
static PyObject *__pyx_b;
static PyObject *__pyx_cython_runtime = NULL;
static PyObject *__pyx_empty_tuple;
static PyObject *__pyx_empty_bytes;
static PyObject *__pyx_empty_unicode;
static int __pyx_lineno;
static int __pyx_clineno = 0;
static const char * __pyx_cfilenm= __FILE__;
static const char *__pyx_filename;


static const char *__pyx_f[] = {
  "btdht/krcp.pyx",
  "stringsource",
};
/* ForceInitThreads.proto */
#ifndef __PYX_FORCE_INIT_THREADS
  #define __PYX_FORCE_INIT_THREADS 0
#endif

/* NoFastGil.proto */
#define __Pyx_PyGILState_Ensure PyGILState_Ensure
#define __Pyx_PyGILState_Release PyGILState_Release
#define __Pyx_FastGIL_Remember()
#define __Pyx_FastGIL_Forget()
#define __Pyx_FastGilFuncInit()


/*--- Type declarations ---*/
struct __pyx_obj_5btdht_4krcp_BMessage;
struct __pyx_opt_args_5btdht_4krcp_vlist_to_array;

/* "btdht/krcp.pyx":116
 *     return l
 * 
 * cdef char** vlist_to_array(l, int size=6):             # <<<<<<<<<<<<<<
 *     """
 *         Transform a python list of compact peers information to a C array
 */
struct __pyx_opt_args_5btdht_4krcp_vlist_to_array {
  int __pyx_n;
  int size;
};

/* "btdht/krcp.pxd":3
 * cdef long _decode_int(char* data, int *i, int max, long long *myint) nogil except -1
 * cdef int _decode_string(char* data, int* i, int max, int* j) nogil except -1
 * cdef class BMessage:             # <<<<<<<<<<<<<<
 *     cdef char* _y
 *     cdef int has_y
 */
struct __pyx_obj_5btdht_4krcp_BMessage {
  PyObject_HEAD
  struct __pyx_vtabstruct_5btdht_4krcp_BMessage *__pyx_vtab;
  char *_y;
  int has_y;
  int y_len;
  char *_t;
  int has_t;
  int t_len;
  char *_q;
  int has_q;
  int q_len;
  char *_v;
  int has_v;
  int v_len;
  int r;
  int a;
  int e;
  int _errno;
  char *_errmsg;
  int errmsg_len;
  char *id;
  int has_id;
  char *target;
  int has_target;
  char *info_hash;
  int has_info_hash;
  int implied_port;
  int has_implied_port;
  int port;
  int has_port;
  char *token;
  int has_token;
  int token_len;
  char *nodes;
  int has_nodes;
  int nodes_len;
  char **values;
  int values_nb;
  int has_values;
  char *encoded;
  int encoded_len;
  int encoded_uptodate;
  int debug;
  PyObject *addr_addr_3;
  PyObject *addr_addr_2;
  int addr_port;
  int failed;
  char *failed_msg;
};



/* "btdht/krcp.pyx":445
 * 
 * 
 * cdef class BMessage:             # <<<<<<<<<<<<<<
 *     """
 *         A bittorrent DHT message. This class is able to bdecode a bittorrent DHT message. It
 */

struct __pyx_vtabstruct_5btdht_4krcp_BMessage {
  int (*set_r)(struct __pyx_obj_5btdht_4krcp_BMessage *, int);
  int (*set_a)(struct __pyx_obj_5btdht_4krcp_BMessage *, int);
  int (*set_e)(struct __pyx_obj_5btdht_4krcp_BMessage *, int);
  int (*set_t)(struct __pyx_obj_5btdht_4krcp_BMessage *, char *, int);
  void (*del_t)(struct __pyx_obj_5btdht_4krcp_BMessage *);
  int (*set_v)(struct __pyx_obj_5btdht_4krcp_BMessage *, char *, int);
  void (*del_v)(struct __pyx_obj_5btdht_4krcp_BMessage *);
  int (*set_y)(struct __pyx_obj_5btdht_4krcp_BMessage *, char *, int);
  void (*del_y)(struct __pyx_obj_5btdht_4krcp_BMessage *);
  int (*set_q)(struct __pyx_obj_5btdht_4krcp_BMessage *, char *, int);
  void (*del_q)(struct __pyx_obj_5btdht_4krcp_BMessage *);
  int (*set_id)(struct __pyx_obj_5btdht_4krcp_BMessage *, char *, int);
  void (*del_id)(struct __pyx_obj_5btdht_4krcp_BMessage *);
  int (*set_target)(struct __pyx_obj_5btdht_4krcp_BMessage *, char *, int);
  void (*del_target)(struct __pyx_obj_5btdht_4krcp_BMessage *);
  int (*set_info_hash)(struct __pyx_obj_5btdht_4krcp_BMessage *, char *, int);
  void (*del_info_hash)(struct __pyx_obj_5btdht_4krcp_BMessage *);
  void (*del_implied_port)(struct __pyx_obj_5btdht_4krcp_BMessage *);
  int (*set_implied_port)(struct __pyx_obj_5btdht_4krcp_BMessage *, int);
  int (*set_port)(struct __pyx_obj_5btdht_4krcp_BMessage *, int);
  void (*del_port)(struct __pyx_obj_5btdht_4krcp_BMessage *);
  int (*set_token)(struct __pyx_obj_5btdht_4krcp_BMessage *, char *, int);
  void (*del_token)(struct __pyx_obj_5btdht_4krcp_BMessage *);
  int (*set_nodes)(struct __pyx_obj_5btdht_4krcp_BMessage *, char *, int);
  int (*del_nodes)(struct __pyx_obj_5btdht_4krcp_BMessage *);
  int (*set_values)(struct __pyx_obj_5btdht_4krcp_BMessage *, char **, int);
  void (*del_values)(struct __pyx_obj_5btdht_4krcp_BMessage *);
  int (*set_errmsg)(struct __pyx_obj_5btdht_4krcp_BMessage *, char *, int);
  void (*del_errmsg)(struct __pyx_obj_5btdht_4krcp_BMessage *);
  int (*set_errno)(struct __pyx_obj_5btdht_4krcp_BMessage *, int);
  void (*del_encoded)(struct __pyx_obj_5btdht_4krcp_BMessage *);
  int (*_encode_values)(struct __pyx_obj_5btdht_4krcp_BMessage *, char *, int *, int);
  int (*_encode_secondary_dict)(struct __pyx_obj_5btdht_4krcp_BMessage *, char *, int *, int);
  int (*_encode_error)(struct __pyx_obj_5btdht_4krcp_BMessage *, char *, int *, int);
  int (*_encode_main_dict)(struct __pyx_obj_5btdht_4krcp_BMessage *, char *, int *, int);
  int (*_encode)(struct __pyx_obj_5btdht_4krcp_BMessage *);
  int (*_encode_len)(struct __pyx_obj_5btdht_4krcp_BMessage *);
  int (*_decode_error)(struct __pyx_obj_5btdht_4krcp_BMessage *, char *, int *, int);
  int (*_decode_dict_elm)(struct __pyx_obj_5btdht_4krcp_BMessage *, char *, int *, int);
  int (*_decode_values)(struct __pyx_obj_5btdht_4krcp_BMessage *, char *, int *, int);
  int (*_decode_dict)(struct __pyx_obj_5btdht_4krcp_BMessage *, char *, int *, int);
  int (*_decode)(struct __pyx_obj_5btdht_4krcp_BMessage *, char *, int *, int);
};
static struct __pyx_vtabstruct_5btdht_4krcp_BMessage *__pyx_vtabptr_5btdht_4krcp_BMessage;

/* --- Runtime support code (head) --- */
/* Refnanny.proto */
#ifndef CYTHON_REFNANNY
  #define CYTHON_REFNANNY 0
#endif
#if CYTHON_REFNANNY
  typedef struct {
    void (*INCREF)(void*, PyObject*, int);
    void (*DECREF)(void*, PyObject*, int);
    void (*GOTREF)(void*, PyObject*, int);
    void (*GIVEREF)(void*, PyObject*, int);
    void* (*SetupContext)(const char*, int, const char*);
    void (*FinishContext)(void**);
  } __Pyx_RefNannyAPIStruct;
  static __Pyx_RefNannyAPIStruct *__Pyx_RefNanny = NULL;
  static __Pyx_RefNannyAPIStruct *__Pyx_RefNannyImportAPI(const char *modname);
  #define __Pyx_RefNannyDeclarations void *__pyx_refnanny = NULL;
#ifdef WITH_THREAD
  #define __Pyx_RefNannySetupContext(name, acquire_gil)\
          if (acquire_gil) {\
              PyGILState_STATE __pyx_gilstate_save = PyGILState_Ensure();\
              __pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE__);\
              PyGILState_Release(__pyx_gilstate_save);\
          } else {\
              __pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE__);\
          }
#else
  #define __Pyx_RefNannySetupContext(name, acquire_gil)\
          __pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE__)
#endif
  #define __Pyx_RefNannyFinishContext()\
          __Pyx_RefNanny->FinishContext(&__pyx_refnanny)
  #define __Pyx_INCREF(r)  __Pyx_RefNanny->INCREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
  #define __Pyx_DECREF(r)  __Pyx_RefNanny->DECREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
  #define __Pyx_GOTREF(r)  __Pyx_RefNanny->GOTREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
  #define __Pyx_GIVEREF(r) __Pyx_RefNanny->GIVEREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
  #define __Pyx_XINCREF(r)  do { if((r) != NULL) {__Pyx_INCREF(r); }} while(0)
  #define __Pyx_XDECREF(r)  do { if((r) != NULL) {__Pyx_DECREF(r); }} while(0)
  #define __Pyx_XGOTREF(r)  do { if((r) != NULL) {__Pyx_GOTREF(r); }} while(0)
  #define __Pyx_XGIVEREF(r) do { if((r) != NULL) {__Pyx_GIVEREF(r);}} while(0)
#else
  #define __Pyx_RefNannyDeclarations
  #define __Pyx_RefNannySetupContext(name, acquire_gil)
  #define __Pyx_RefNannyFinishContext()
  #define __Pyx_INCREF(r) Py_INCREF(r)
  #define __Pyx_DECREF(r) Py_DECREF(r)
  #define __Pyx_GOTREF(r)
  #define __Pyx_GIVEREF(r)
  #define __Pyx_XINCREF(r) Py_XINCREF(r)
  #define __Pyx_XDECREF(r) Py_XDECREF(r)
  #define __Pyx_XGOTREF(r)
  #define __Pyx_XGIVEREF(r)
#endif
#define __Pyx_XDECREF_SET(r, v) do {\
        PyObject *tmp = (PyObject *) r;\
        r = v; __Pyx_XDECREF(tmp);\
    } while (0)
#define __Pyx_DECREF_SET(r, v) do {\
        PyObject *tmp = (PyObject *) r;\
        r = v; __Pyx_DECREF(tmp);\
    } while (0)
#define __Pyx_CLEAR(r)    do { PyObject* tmp = ((PyObject*)(r)); r = NULL; __Pyx_DECREF(tmp);} while(0)
#define __Pyx_XCLEAR(r)   do { if((r) != NULL) {PyObject* tmp = ((PyObject*)(r)); r = NULL; __Pyx_DECREF(tmp);}} while(0)

/* PyObjectGetAttrStr.proto */
#if CYTHON_USE_TYPE_SLOTS
static CYTHON_INLINE PyObject* __Pyx_PyObject_GetAttrStr(PyObject* obj, PyObject* attr_name);
#else
#define __Pyx_PyObject_GetAttrStr(o,n) PyObject_GetAttr(o,n)
#endif

/* GetBuiltinName.proto */
static PyObject *__Pyx_GetBuiltinName(PyObject *name);

/* PyCFunctionFastCall.proto */
#if CYTHON_FAST_PYCCALL
static CYTHON_INLINE PyObject *__Pyx_PyCFunction_FastCall(PyObject *func, PyObject **args, Py_ssize_t nargs);
#else
#define __Pyx_PyCFunction_FastCall(func, args, nargs)  (assert(0), NULL)
#endif

/* PyFunctionFastCall.proto */
#if CYTHON_FAST_PYCALL
#define __Pyx_PyFunction_FastCall(func, args, nargs)\
    __Pyx_PyFunction_FastCallDict((func), (args), (nargs), NULL)
#if 1 || PY_VERSION_HEX < 0x030600B1
static PyObject *__Pyx_PyFunction_FastCallDict(PyObject *func, PyObject **args, Py_ssize_t nargs, PyObject *kwargs);
#else
#define __Pyx_PyFunction_FastCallDict(func, args, nargs, kwargs) _PyFunction_FastCallDict(func, args, nargs, kwargs)
#endif
#define __Pyx_BUILD_ASSERT_EXPR(cond)\
    (sizeof(char [1 - 2*!(cond)]) - 1)
#ifndef Py_MEMBER_SIZE
#define Py_MEMBER_SIZE(type, member) sizeof(((type *)0)->member)
#endif
#if CYTHON_FAST_PYCALL
  static size_t __pyx_pyframe_localsplus_offset = 0;
  #include "frameobject.h"
#if PY_VERSION_HEX >= 0x030b00a6
  #ifndef Py_BUILD_CORE
    #define Py_BUILD_CORE 1
  #endif
  #include "internal/pycore_frame.h"
#endif
  #define __Pxy_PyFrame_Initialize_Offsets()\
    ((void)__Pyx_BUILD_ASSERT_EXPR(sizeof(PyFrameObject) == offsetof(PyFrameObject, f_localsplus) + Py_MEMBER_SIZE(PyFrameObject, f_localsplus)),\
     (void)(__pyx_pyframe_localsplus_offset = ((size_t)PyFrame_Type.tp_basicsize) - Py_MEMBER_SIZE(PyFrameObject, f_localsplus)))
  #define __Pyx_PyFrame_GetLocalsplus(frame)\
    (assert(__pyx_pyframe_localsplus_offset), (PyObject **)(((char *)(frame)) + __pyx_pyframe_localsplus_offset))
#endif // CYTHON_FAST_PYCALL
#endif

/* PyObjectCall.proto */
#if CYTHON_COMPILING_IN_CPYTHON
static CYTHON_INLINE PyObject* __Pyx_PyObject_Call(PyObject *func, PyObject *arg, PyObject *kw);
#else
#define __Pyx_PyObject_Call(func, arg, kw) PyObject_Call(func, arg, kw)
#endif

/* PyObjectCallMethO.proto */
#if CYTHON_COMPILING_IN_CPYTHON
static CYTHON_INLINE PyObject* __Pyx_PyObject_CallMethO(PyObject *func, PyObject *arg);
#endif

/* PyObjectCallOneArg.proto */
static CYTHON_INLINE PyObject* __Pyx_PyObject_CallOneArg(PyObject *func, PyObject *arg);

/* PyThreadStateGet.proto */
#if CYTHON_FAST_THREAD_STATE
#define __Pyx_PyThreadState_declare  PyThreadState *__pyx_tstate;
#define __Pyx_PyThreadState_assign  __pyx_tstate = __Pyx_PyThreadState_Current;
#define __Pyx_PyErr_Occurred()  __pyx_tstate->curexc_type
#else
#define __Pyx_PyThreadState_declare
#define __Pyx_PyThreadState_assign
#define __Pyx_PyErr_Occurred()  PyErr_Occurred()
#endif

/* PyErrFetchRestore.proto */
#if CYTHON_FAST_THREAD_STATE
#define __Pyx_PyErr_Clear() __Pyx_ErrRestore(NULL, NULL, NULL)
#define __Pyx_ErrRestoreWithState(type, value, tb)  __Pyx_ErrRestoreInState(PyThreadState_GET(), type, value, tb)
#define __Pyx_ErrFetchWithState(type, value, tb)    __Pyx_ErrFetchInState(PyThreadState_GET(), type, value, tb)
#define __Pyx_ErrRestore(type, value, tb)  __Pyx_ErrRestoreInState(__pyx_tstate, type, value, tb)
#define __Pyx_ErrFetch(type, value, tb)    __Pyx_ErrFetchInState(__pyx_tstate, type, value, tb)
static CYTHON_INLINE void __Pyx_ErrRestoreInState(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb);
static CYTHON_INLINE void __Pyx_ErrFetchInState(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb);
#if CYTHON_COMPILING_IN_CPYTHON
#define __Pyx_PyErr_SetNone(exc) (Py_INCREF(exc), __Pyx_ErrRestore((exc), NULL, NULL))
#else
#define __Pyx_PyErr_SetNone(exc) PyErr_SetNone(exc)
#endif
#else
#define __Pyx_PyErr_Clear() PyErr_Clear()
#define __Pyx_PyErr_SetNone(exc) PyErr_SetNone(exc)
#define __Pyx_ErrRestoreWithState(type, value, tb)  PyErr_Restore(type, value, tb)
#define __Pyx_ErrFetchWithState(type, value, tb)  PyErr_Fetch(type, value, tb)
#define __Pyx_ErrRestoreInState(tstate, type, value, tb)  PyErr_Restore(type, value, tb)
#define __Pyx_ErrFetchInState(tstate, type, value, tb)  PyErr_Fetch(type, value, tb)
#define __Pyx_ErrRestore(type, value, tb)  PyErr_Restore(type, value, tb)
#define __Pyx_ErrFetch(type, value, tb)  PyErr_Fetch(type, value, tb)
#endif

/* RaiseException.proto */
static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, PyObject *cause);

/* WriteUnraisableException.proto */
static void __Pyx_WriteUnraisable(const char *name, int clineno,
                                  int lineno, const char *filename,
                                  int full_traceback, int nogil);

/* ListAppend.proto */
#if CYTHON_USE_PYLIST_INTERNALS && CYTHON_ASSUME_SAFE_MACROS
static CYTHON_INLINE int __Pyx_PyList_Append(PyObject* list, PyObject* x) {
    PyListObject* L = (PyListObject*) list;
    Py_ssize_t len = Py_SIZE(list);
    if (likely(L->allocated > len) & likely(len > (L->allocated >> 1))) {
        Py_INCREF(x);
        PyList_SET_ITEM(list, len, x);
        __Pyx_SET_SIZE(list, len + 1);
        return 0;
    }
    return PyList_Append(list, x);
}
#else
#define __Pyx_PyList_Append(L,x) PyList_Append(L,x)
#endif

/* GetItemInt.proto */
#define __Pyx_GetItemInt(o, i, type, is_signed, to_py_func, is_list, wraparound, boundscheck)\
    (__Pyx_fits_Py_ssize_t(i, type, is_signed) ?\
    __Pyx_GetItemInt_Fast(o, (Py_ssize_t)i, is_list, wraparound, boundscheck) :\
    (is_list ? (PyErr_SetString(PyExc_IndexError, "list index out of range"), (PyObject*)NULL) :\
               __Pyx_GetItemInt_Generic(o, to_py_func(i))))
#define __Pyx_GetItemInt_List(o, i, type, is_signed, to_py_func, is_list, wraparound, boundscheck)\
    (__Pyx_fits_Py_ssize_t(i, type, is_signed) ?\
    __Pyx_GetItemInt_List_Fast(o, (Py_ssize_t)i, wraparound, boundscheck) :\
    (PyErr_SetString(PyExc_IndexError, "list index out of range"), (PyObject*)NULL))
static CYTHON_INLINE PyObject *__Pyx_GetItemInt_List_Fast(PyObject *o, Py_ssize_t i,
                                                              int wraparound, int boundscheck);
#define __Pyx_GetItemInt_Tuple(o, i, type, is_signed, to_py_func, is_list, wraparound, boundscheck)\
    (__Pyx_fits_Py_ssize_t(i, type, is_signed) ?\
    __Pyx_GetItemInt_Tuple_Fast(o, (Py_ssize_t)i, wraparound, boundscheck) :\
    (PyErr_SetString(PyExc_IndexError, "tuple index out of range"), (PyObject*)NULL))
static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Tuple_Fast(PyObject *o, Py_ssize_t i,
                                                              int wraparound, int boundscheck);
static PyObject *__Pyx_GetItemInt_Generic(PyObject *o, PyObject* j);
static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Fast(PyObject *o, Py_ssize_t i,
                                                     int is_list, int wraparound, int boundscheck);

/* PyDictVersioning.proto */
#if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_TYPE_SLOTS
#define __PYX_DICT_VERSION_INIT  ((PY_UINT64_T) -1)
#define __PYX_GET_DICT_VERSION(dict)  (((PyDictObject*)(dict))->ma_version_tag)
#define __PYX_UPDATE_DICT_CACHE(dict, value, cache_var, version_var)\
    (version_var) = __PYX_GET_DICT_VERSION(dict);\
    (cache_var) = (value);
#define __PYX_PY_DICT_LOOKUP_IF_MODIFIED(VAR, DICT, LOOKUP) {\
    static PY_UINT64_T __pyx_dict_version = 0;\
    static PyObject *__pyx_dict_cached_value = NULL;\
    if (likely(__PYX_GET_DICT_VERSION(DICT) == __pyx_dict_version)) {\
        (VAR) = __pyx_dict_cached_value;\
    } else {\
        (VAR) = __pyx_dict_cached_value = (LOOKUP);\
        __pyx_dict_version = __PYX_GET_DICT_VERSION(DICT);\
    }\
}
static CYTHON_INLINE PY_UINT64_T __Pyx_get_tp_dict_version(PyObject *obj);
static CYTHON_INLINE PY_UINT64_T __Pyx_get_object_dict_version(PyObject *obj);
static CYTHON_INLINE int __Pyx_object_dict_version_matches(PyObject* obj, PY_UINT64_T tp_dict_version, PY_UINT64_T obj_dict_version);
#else
#define __PYX_GET_DICT_VERSION(dict)  (0)
#define __PYX_UPDATE_DICT_CACHE(dict, value, cache_var, version_var)
#define __PYX_PY_DICT_LOOKUP_IF_MODIFIED(VAR, DICT, LOOKUP)  (VAR) = (LOOKUP);
#endif

/* GetModuleGlobalName.proto */
#if CYTHON_USE_DICT_VERSIONS
#define __Pyx_GetModuleGlobalName(var, name)  {\
    static PY_UINT64_T __pyx_dict_version = 0;\
    static PyObject *__pyx_dict_cached_value = NULL;\
    (var) = (likely(__pyx_dict_version == __PYX_GET_DICT_VERSION(__pyx_d))) ?\
        (likely(__pyx_dict_cached_value) ? __Pyx_NewRef(__pyx_dict_cached_value) : __Pyx_GetBuiltinName(name)) :\
        __Pyx__GetModuleGlobalName(name, &__pyx_dict_version, &__pyx_dict_cached_value);\
}
#define __Pyx_GetModuleGlobalNameUncached(var, name)  {\
    PY_UINT64_T __pyx_dict_version;\
    PyObject *__pyx_dict_cached_value;\
    (var) = __Pyx__GetModuleGlobalName(name, &__pyx_dict_version, &__pyx_dict_cached_value);\
}
static PyObject *__Pyx__GetModuleGlobalName(PyObject *name, PY_UINT64_T *dict_version, PyObject **dict_cached_value);
#else
#define __Pyx_GetModuleGlobalName(var, name)  (var) = __Pyx__GetModuleGlobalName(name)
#define __Pyx_GetModuleGlobalNameUncached(var, name)  (var) = __Pyx__GetModuleGlobalName(name)
static CYTHON_INLINE PyObject *__Pyx__GetModuleGlobalName(PyObject *name);
#endif

/* PyObjectCall2Args.proto */
static CYTHON_UNUSED PyObject* __Pyx_PyObject_Call2Args(PyObject* function, PyObject* arg1, PyObject* arg2);

/* RaiseArgTupleInvalid.proto */
static void __Pyx_RaiseArgtupleInvalid(const char* func_name, int exact,
    Py_ssize_t num_min, Py_ssize_t num_max, Py_ssize_t num_found);

/* RaiseDoubleKeywords.proto */
static void __Pyx_RaiseDoubleKeywordsError(const char* func_name, PyObject* kw_name);

/* ParseKeywords.proto */
static int __Pyx_ParseOptionalKeywords(PyObject *kwds, PyObject **argnames[],\
    PyObject *kwds2, PyObject *values[], Py_ssize_t num_pos_args,\
    const char* function_name);

/* PyObjectSetAttrStr.proto */
#if CYTHON_USE_TYPE_SLOTS
#define __Pyx_PyObject_DelAttrStr(o,n) __Pyx_PyObject_SetAttrStr(o, n, NULL)
static CYTHON_INLINE int __Pyx_PyObject_SetAttrStr(PyObject* obj, PyObject* attr_name, PyObject* value);
#else
#define __Pyx_PyObject_DelAttrStr(o,n)   PyObject_DelAttr(o,n)
#define __Pyx_PyObject_SetAttrStr(o,n,v) PyObject_SetAttr(o,n,v)
#endif

/* PyObjectCallNoArg.proto */
#if CYTHON_COMPILING_IN_CPYTHON
static CYTHON_INLINE PyObject* __Pyx_PyObject_CallNoArg(PyObject *func);
#else
#define __Pyx_PyObject_CallNoArg(func) __Pyx_PyObject_Call(func, __pyx_empty_tuple, NULL)
#endif

/* IncludeStringH.proto */
#include <string.h>

/* ObjectGetItem.proto */
#if CYTHON_USE_TYPE_SLOTS
static CYTHON_INLINE PyObject *__Pyx_PyObject_GetItem(PyObject *obj, PyObject* key);
#else
#define __Pyx_PyObject_GetItem(obj, key)  PyObject_GetItem(obj, key)
#endif

/* PySequenceContains.proto */
static CYTHON_INLINE int __Pyx_PySequence_ContainsTF(PyObject* item, PyObject* seq, int eq) {
    int result = PySequence_Contains(seq, item);
    return unlikely(result < 0) ? result : (result == (eq == Py_EQ));
}

/* BytesEquals.proto */
static CYTHON_INLINE int __Pyx_PyBytes_Equals(PyObject* s1, PyObject* s2, int equals);

/* GetTopmostException.proto */
#if CYTHON_USE_EXC_INFO_STACK
static _PyErr_StackItem * __Pyx_PyErr_GetTopmostException(PyThreadState *tstate);
#endif

/* SaveResetException.proto */
#if CYTHON_FAST_THREAD_STATE
#define __Pyx_ExceptionSave(type, value, tb)  __Pyx__ExceptionSave(__pyx_tstate, type, value, tb)
static CYTHON_INLINE void __Pyx__ExceptionSave(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb);
#define __Pyx_ExceptionReset(type, value, tb)  __Pyx__ExceptionReset(__pyx_tstate, type, value, tb)
static CYTHON_INLINE void __Pyx__ExceptionReset(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb);
#else
#define __Pyx_ExceptionSave(type, value, tb)   PyErr_GetExcInfo(type, value, tb)
#define __Pyx_ExceptionReset(type, value, tb)  PyErr_SetExcInfo(type, value, tb)
#endif

/* PyErrExceptionMatches.proto */
#if CYTHON_FAST_THREAD_STATE
#define __Pyx_PyErr_ExceptionMatches(err) __Pyx_PyErr_ExceptionMatchesInState(__pyx_tstate, err)
static CYTHON_INLINE int __Pyx_PyErr_ExceptionMatchesInState(PyThreadState* tstate, PyObject* err);
#else
#define __Pyx_PyErr_ExceptionMatches(err)  PyErr_ExceptionMatches(err)
#endif

/* GetException.proto */
#if CYTHON_FAST_THREAD_STATE
#define __Pyx_GetException(type, value, tb)  __Pyx__GetException(__pyx_tstate, type, value, tb)
static int __Pyx__GetException(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb);
#else
static int __Pyx_GetException(PyObject **type, PyObject **value, PyObject **tb);
#endif

/* PyObject_GenericGetAttrNoDict.proto */
#if CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP && PY_VERSION_HEX < 0x03070000
static CYTHON_INLINE PyObject* __Pyx_PyObject_GenericGetAttrNoDict(PyObject* obj, PyObject* attr_name);
#else
#define __Pyx_PyObject_GenericGetAttrNoDict PyObject_GenericGetAttr
#endif

/* PyObject_GenericGetAttr.proto */
#if CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP && PY_VERSION_HEX < 0x03070000
static PyObject* __Pyx_PyObject_GenericGetAttr(PyObject* obj, PyObject* attr_name);
#else
#define __Pyx_PyObject_GenericGetAttr PyObject_GenericGetAttr
#endif

/* SetVTable.proto */
static int __Pyx_SetVtable(PyObject *dict, void *vtable);

/* PyObjectGetAttrStrNoError.proto */
static CYTHON_INLINE PyObject* __Pyx_PyObject_GetAttrStrNoError(PyObject* obj, PyObject* attr_name);

/* SetupReduce.proto */
static int __Pyx_setup_reduce(PyObject* type_obj);

/* Import.proto */
static PyObject *__Pyx_Import(PyObject *name, PyObject *from_list, int level);

/* ImportFrom.proto */
static PyObject* __Pyx_ImportFrom(PyObject* module, PyObject* name);

/* CalculateMetaclass.proto */
static PyObject *__Pyx_CalculateMetaclass(PyTypeObject *metaclass, PyObject *bases);

/* SetNameInClass.proto */
#if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030500A1
#define __Pyx_SetNameInClass(ns, name, value)\
    (likely(PyDict_CheckExact(ns)) ? _PyDict_SetItem_KnownHash(ns, name, value, ((PyASCIIObject *) name)->hash) : PyObject_SetItem(ns, name, value))
#elif CYTHON_COMPILING_IN_CPYTHON
#define __Pyx_SetNameInClass(ns, name, value)\
    (likely(PyDict_CheckExact(ns)) ? PyDict_SetItem(ns, name, value) : PyObject_SetItem(ns, name, value))
#else
#define __Pyx_SetNameInClass(ns, name, value)  PyObject_SetItem(ns, name, value)
#endif

/* FetchCommonType.proto */
static PyTypeObject* __Pyx_FetchCommonType(PyTypeObject* type);

/* CythonFunctionShared.proto */
#define __Pyx_CyFunction_USED 1
#define __Pyx_CYFUNCTION_STATICMETHOD  0x01
#define __Pyx_CYFUNCTION_CLASSMETHOD   0x02
#define __Pyx_CYFUNCTION_CCLASS        0x04
#define __Pyx_CyFunction_GetClosure(f)\
    (((__pyx_CyFunctionObject *) (f))->func_closure)
#define __Pyx_CyFunction_GetClassObj(f)\
    (((__pyx_CyFunctionObject *) (f))->func_classobj)
#define __Pyx_CyFunction_Defaults(type, f)\
    ((type *)(((__pyx_CyFunctionObject *) (f))->defaults))
#define __Pyx_CyFunction_SetDefaultsGetter(f, g)\
    ((__pyx_CyFunctionObject *) (f))->defaults_getter = (g)
typedef struct {
    PyCFunctionObject func;
#if PY_VERSION_HEX < 0x030500A0
    PyObject *func_weakreflist;
#endif
    PyObject *func_dict;
    PyObject *func_name;
    PyObject *func_qualname;
    PyObject *func_doc;
    PyObject *func_globals;
    PyObject *func_code;
    PyObject *func_closure;
    PyObject *func_classobj;
    void *defaults;
    int defaults_pyobjects;
    size_t defaults_size;  // used by FusedFunction for copying defaults
    int flags;
    PyObject *defaults_tuple;
    PyObject *defaults_kwdict;
    PyObject *(*defaults_getter)(PyObject *);
    PyObject *func_annotations;
} __pyx_CyFunctionObject;
static PyTypeObject *__pyx_CyFunctionType = 0;
#define __Pyx_CyFunction_Check(obj)  (__Pyx_TypeCheck(obj, __pyx_CyFunctionType))
static PyObject *__Pyx_CyFunction_Init(__pyx_CyFunctionObject* op, PyMethodDef *ml,
                                      int flags, PyObject* qualname,
                                      PyObject *self,
                                      PyObject *module, PyObject *globals,
                                      PyObject* code);
static CYTHON_INLINE void *__Pyx_CyFunction_InitDefaults(PyObject *m,
                                                         size_t size,
                                                         int pyobjects);
static CYTHON_INLINE void __Pyx_CyFunction_SetDefaultsTuple(PyObject *m,
                                                            PyObject *tuple);
static CYTHON_INLINE void __Pyx_CyFunction_SetDefaultsKwDict(PyObject *m,
                                                             PyObject *dict);
static CYTHON_INLINE void __Pyx_CyFunction_SetAnnotationsDict(PyObject *m,
                                                              PyObject *dict);
static int __pyx_CyFunction_init(void);

/* CythonFunction.proto */
static PyObject *__Pyx_CyFunction_New(PyMethodDef *ml,
                                      int flags, PyObject* qualname,
                                      PyObject *closure,
                                      PyObject *module, PyObject *globals,
                                      PyObject* code);

/* Py3ClassCreate.proto */
static PyObject *__Pyx_Py3MetaclassPrepare(PyObject *metaclass, PyObject *bases, PyObject *name, PyObject *qualname,
                                           PyObject *mkw, PyObject *modname, PyObject *doc);
static PyObject *__Pyx_Py3ClassCreate(PyObject *metaclass, PyObject *name, PyObject *bases, PyObject *dict,
                                      PyObject *mkw, int calculate_metaclass, int allow_py2_metaclass);

/* CLineInTraceback.proto */
#ifdef CYTHON_CLINE_IN_TRACEBACK
#define __Pyx_CLineForTraceback(tstate, c_line)  (((CYTHON_CLINE_IN_TRACEBACK)) ? c_line : 0)
#else
static int __Pyx_CLineForTraceback(PyThreadState *tstate, int c_line);
#endif

/* CodeObjectCache.proto */
typedef struct {
    PyCodeObject* code_object;
    int code_line;
} __Pyx_CodeObjectCacheEntry;
struct __Pyx_CodeObjectCache {
    int count;
    int max_count;
    __Pyx_CodeObjectCacheEntry* entries;
};
static struct __Pyx_CodeObjectCache __pyx_code_cache = {0,0,NULL};
static int __pyx_bisect_code_objects(__Pyx_CodeObjectCacheEntry* entries, int count, int code_line);
static PyCodeObject *__pyx_find_code_object(int code_line);
static void __pyx_insert_code_object(int code_line, PyCodeObject* code_object);

/* AddTraceback.proto */
static void __Pyx_AddTraceback(const char *funcname, int c_line,
                               int py_line, const char *filename);

/* GCCDiagnostics.proto */
#if defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6))
#define __Pyx_HAS_GCC_DIAGNOSTIC
#endif

/* CIntFromPy.proto */
static CYTHON_INLINE int __Pyx_PyInt_As_int(PyObject *);

/* CIntToPy.proto */
static CYTHON_INLINE PyObject* __Pyx_PyInt_From_int(int value);

/* CIntToPy.proto */
static CYTHON_INLINE PyObject* __Pyx_PyInt_From_char(char value);

/* CIntToPy.proto */
static CYTHON_INLINE PyObject* __Pyx_PyInt_From_long(long value);

/* CIntFromPy.proto */
static CYTHON_INLINE long __Pyx_PyInt_As_long(PyObject *);

/* FastTypeChecks.proto */
#if CYTHON_COMPILING_IN_CPYTHON
#define __Pyx_TypeCheck(obj, type) __Pyx_IsSubtype(Py_TYPE(obj), (PyTypeObject *)type)
static CYTHON_INLINE int __Pyx_IsSubtype(PyTypeObject *a, PyTypeObject *b);
static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches(PyObject *err, PyObject *type);
static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches2(PyObject *err, PyObject *type1, PyObject *type2);
#else
#define __Pyx_TypeCheck(obj, type) PyObject_TypeCheck(obj, (PyTypeObject *)type)
#define __Pyx_PyErr_GivenExceptionMatches(err, type) PyErr_GivenExceptionMatches(err, type)
#define __Pyx_PyErr_GivenExceptionMatches2(err, type1, type2) (PyErr_GivenExceptionMatches(err, type1) || PyErr_GivenExceptionMatches(err, type2))
#endif
#define __Pyx_PyException_Check(obj) __Pyx_TypeCheck(obj, PyExc_Exception)

/* CheckBinaryVersion.proto */
static int __Pyx_check_binary_version(void);

/* FunctionExport.proto */
static int __Pyx_ExportFunction(const char *name, void (*f)(void), const char *sig);

/* InitStrings.proto */
static int __Pyx_InitStrings(__Pyx_StringTabEntry *t);

static int __pyx_f_5btdht_4krcp_8BMessage_set_r(struct __pyx_obj_5btdht_4krcp_BMessage *__pyx_v_self, int __pyx_v_value); /* proto*/
static int __pyx_f_5btdht_4krcp_8BMessage_set_a(struct __pyx_obj_5btdht_4krcp_BMessage *__pyx_v_self, int __pyx_v_value); /* proto*/
static int __pyx_f_5btdht_4krcp_8BMessage_set_e(struct __pyx_obj_5btdht_4krcp_BMessage *__pyx_v_self, int __pyx_v_value); /* proto*/
static int __pyx_f_5btdht_4krcp_8BMessage_set_t(struct __pyx_obj_5btdht_4krcp_BMessage *__pyx_v_self, char *__pyx_v_value, int __pyx_v_size); /* proto*/
static void __pyx_f_5btdht_4krcp_8BMessage_del_t(struct __pyx_obj_5btdht_4krcp_BMessage *__pyx_v_self); /* proto*/
static int __pyx_f_5btdht_4krcp_8BMessage_set_v(struct __pyx_obj_5btdht_4krcp_BMessage *__pyx_v_self, char *__pyx_v_value, int __pyx_v_size); /* proto*/
static void __pyx_f_5btdht_4krcp_8BMessage_del_v(struct __pyx_obj_5btdht_4krcp_BMessage *__pyx_v_self); /* proto*/
static int __pyx_f_5btdht_4krcp_8BMessage_set_y(struct __pyx_obj_5btdht_4krcp_BMessage *__pyx_v_self, char *__pyx_v_value, int __pyx_v_size); /* proto*/
static void __pyx_f_5btdht_4krcp_8BMessage_del_y(struct __pyx_obj_5btdht_4krcp_BMessage *__pyx_v_self); /* proto*/
static int __pyx_f_5btdht_4krcp_8BMessage_set_q(struct __pyx_obj_5btdht_4krcp_BMessage *__pyx_v_self, char *__pyx_v_value, int __pyx_v_size); /* proto*/
static void __pyx_f_5btdht_4krcp_8BMessage_del_q(struct __pyx_obj_5btdht_4krcp_BMessage *__pyx_v_self); /* proto*/
static int __pyx_f_5btdht_4krcp_8BMessage_set_id(struct __pyx_obj_5btdht_4krcp_BMessage *__pyx_v_self, char *__pyx_v_value, int __pyx_v_size); /* proto*/
static void __pyx_f_5btdht_4krcp_8BMessage_del_id(struct __pyx_obj_5btdht_4krcp_BMessage *__pyx_v_self); /* proto*/
static int __pyx_f_5btdht_4krcp_8BMessage_set_target(struct __pyx_obj_5btdht_4krcp_BMessage *__pyx_v_self, char *__pyx_v_value, int __pyx_v_size); /* proto*/
static void __pyx_f_5btdht_4krcp_8BMessage_del_target(struct __pyx_obj_5btdht_4krcp_BMessage *__pyx_v_self); /* proto*/
static int __pyx_f_5btdht_4krcp_8BMessage_set_info_hash(struct __pyx_obj_5btdht_4krcp_BMessage *__pyx_v_self, char *__pyx_v_value, int __pyx_v_size); /* proto*/
static void __pyx_f_5btdht_4krcp_8BMessage_del_info_hash(struct __pyx_obj_5btdht_4krcp_BMessage *__pyx_v_self); /* proto*/
static void __pyx_f_5btdht_4krcp_8BMessage_del_implied_port(struct __pyx_obj_5btdht_4krcp_BMessage *__pyx_v_self); /* proto*/
static int __pyx_f_5btdht_4krcp_8BMessage_set_implied_port(struct __pyx_obj_5btdht_4krcp_BMessage *__pyx_v_self, int __pyx_v_value); /* proto*/
static int __pyx_f_5btdht_4krcp_8BMessage_set_port(struct __pyx_obj_5btdht_4krcp_BMessage *__pyx_v_self, int __pyx_v_value); /* proto*/
static void __pyx_f_5btdht_4krcp_8BMessage_del_port(struct __pyx_obj_5btdht_4krcp_BMessage *__pyx_v_self); /* proto*/
static int __pyx_f_5btdht_4krcp_8BMessage_set_token(struct __pyx_obj_5btdht_4krcp_BMessage *__pyx_v_self, char *__pyx_v_value, int __pyx_v_size); /* proto*/
static void __pyx_f_5btdht_4krcp_8BMessage_del_token(struct __pyx_obj_5btdht_4krcp_BMessage *__pyx_v_self); /* proto*/
static int __pyx_f_5btdht_4krcp_8BMessage_set_nodes(struct __pyx_obj_5btdht_4krcp_BMessage *__pyx_v_self, char *__pyx_v_value, int __pyx_v_size); /* proto*/
static int __pyx_f_5btdht_4krcp_8BMessage_del_nodes(struct __pyx_obj_5btdht_4krcp_BMessage *__pyx_v_self); /* proto*/
static int __pyx_f_5btdht_4krcp_8BMessage_set_values(struct __pyx_obj_5btdht_4krcp_BMessage *__pyx_v_self, char **__pyx_v_values, int __pyx_v_nb); /* proto*/
static void __pyx_f_5btdht_4krcp_8BMessage_del_values(struct __pyx_obj_5btdht_4krcp_BMessage *__pyx_v_self); /* proto*/
static int __pyx_f_5btdht_4krcp_8BMessage_set_errmsg(struct __pyx_obj_5btdht_4krcp_BMessage *__pyx_v_self, char *__pyx_v_value, int __pyx_v_size); /* proto*/
static void __pyx_f_5btdht_4krcp_8BMessage_del_errmsg(struct __pyx_obj_5btdht_4krcp_BMessage *__pyx_v_self); /* proto*/
static int __pyx_f_5btdht_4krcp_8BMessage_set_errno(struct __pyx_obj_5btdht_4krcp_BMessage *__pyx_v_self, int __pyx_v_value); /* proto*/
static void __pyx_f_5btdht_4krcp_8BMessage_del_encoded(struct __pyx_obj_5btdht_4krcp_BMessage *__pyx_v_self); /* proto*/
static int __pyx_f_5btdht_4krcp_8BMessage__encode_values(struct __pyx_obj_5btdht_4krcp_BMessage *__pyx_v_self, char *__pyx_v_data, int *__pyx_v_i, int __pyx_v_max); /* proto*/
static int __pyx_f_5btdht_4krcp_8BMessage__encode_secondary_dict(struct __pyx_obj_5btdht_4krcp_BMessage *__pyx_v_self, char *__pyx_v_data, int *__pyx_v_i, int __pyx_v_max); /* proto*/
static int __pyx_f_5btdht_4krcp_8BMessage__encode_error(struct __pyx_obj_5btdht_4krcp_BMessage *__pyx_v_self, char *__pyx_v_data, int *__pyx_v_i, int __pyx_v_max); /* proto*/
static int __pyx_f_5btdht_4krcp_8BMessage__encode_main_dict(struct __pyx_obj_5btdht_4krcp_BMessage *__pyx_v_self, char *__pyx_v_data, int *__pyx_v_i, int __pyx_v_max); /* proto*/
static int __pyx_f_5btdht_4krcp_8BMessage__encode(struct __pyx_obj_5btdht_4krcp_BMessage *__pyx_v_self); /* proto*/
static int __pyx_f_5btdht_4krcp_8BMessage__encode_len(struct __pyx_obj_5btdht_4krcp_BMessage *__pyx_v_self); /* proto*/
static int __pyx_f_5btdht_4krcp_8BMessage__decode_error(struct __pyx_obj_5btdht_4krcp_BMessage *__pyx_v_self, char *__pyx_v_data, int *__pyx_v_i, int __pyx_v_max); /* proto*/
static int __pyx_f_5btdht_4krcp_8BMessage__decode_dict_elm(struct __pyx_obj_5btdht_4krcp_BMessage *__pyx_v_self, char *__pyx_v_data, int *__pyx_v_i, int __pyx_v_max); /* proto*/
static int __pyx_f_5btdht_4krcp_8BMessage__decode_values(struct __pyx_obj_5btdht_4krcp_BMessage *__pyx_v_self, char *__pyx_v_data, int *__pyx_v_i, int __pyx_v_max); /* proto*/
static int __pyx_f_5btdht_4krcp_8BMessage__decode_dict(struct __pyx_obj_5btdht_4krcp_BMessage *__pyx_v_self, char *__pyx_v_data, int *__pyx_v_i, int __pyx_v_max); /* proto*/
static int __pyx_f_5btdht_4krcp_8BMessage__decode(struct __pyx_obj_5btdht_4krcp_BMessage *__pyx_v_self, char *__pyx_v_data, int *__pyx_v_i, int __pyx_v_max); /* proto*/

/* Module declarations from 'libc' */

/* Module declarations from 'libc.math' */

/* Module declarations from 'libc.string' */

/* Module declarations from 'libc.stdio' */

/* Module declarations from 'libc.stdlib' */

/* Module declarations from 'btdht.krcp' */
static PyTypeObject *__pyx_ptype_5btdht_4krcp_BMessage = 0;
static long __pyx_f_5btdht_4krcp__decode_int(char *, int *, int, PY_LONG_LONG *); /*proto*/
static int __pyx_f_5btdht_4krcp__decode_string(char *, int *, int, int *); /*proto*/
static int __pyx_f_5btdht_4krcp_str_to_int(char *, int); /*proto*/
static long __pyx_f_5btdht_4krcp_str_to_long(char *, int); /*proto*/
static int __pyx_f_5btdht_4krcp_int_length(int); /*proto*/
static PyObject *__pyx_f_5btdht_4krcp_varray_to_list(char **, PyObject *); /*proto*/
static char **__pyx_f_5btdht_4krcp_vlist_to_array(PyObject *, struct __pyx_opt_args_5btdht_4krcp_vlist_to_array *__pyx_optional_args); /*proto*/
static int __pyx_f_5btdht_4krcp__decode_pass_list(char *, int *, int); /*proto*/
static int __pyx_f_5btdht_4krcp__decode_pass_dict(char *, int *, int); /*proto*/
static int __pyx_f_5btdht_4krcp__encode_int(char *, int *, int, int); /*proto*/
static int __pyx_f_5btdht_4krcp__encode_string(char *, int *, int, char *, int); /*proto*/
#define __Pyx_MODULE_NAME "btdht.krcp"
extern int __pyx_module_is_main_btdht__krcp;
int __pyx_module_is_main_btdht__krcp = 0;

/* Implementation of 'btdht.krcp' */
static PyObject *__pyx_builtin_EnvironmentError;
static PyObject *__pyx_builtin_range;
static PyObject *__pyx_builtin_ValueError;
static PyObject *__pyx_builtin_super;
static PyObject *__pyx_builtin_NotImplementedError;
static PyObject *__pyx_builtin_KeyError;
static PyObject *__pyx_builtin_TypeError;
static const char __pyx_k_e[] = "e";
static const char __pyx_k_q[] = "q";
static const char __pyx_k_r[] = "%r";
static const char __pyx_k_t[] = "t";
static const char __pyx_k_y[] = "y";
static const char __pyx_k__2[] = "";
static const char __pyx_k_id[] = "id";
static const char __pyx_k_os[] = "os";
static const char __pyx_k_PY3[] = "PY3";
static const char __pyx_k_doc[] = "__doc__";
static const char __pyx_k_key[] = "key";
static const char __pyx_k_msg[] = "msg";
static const char __pyx_k_s_r[] = "%s: %r";
static const char __pyx_k_six[] = "six";
static const char __pyx_k_str[] = "__str__";
static const char __pyx_k_addr[] = "addr";
static const char __pyx_k_data[] = "data";
static const char __pyx_k_init[] = "__init__";
static const char __pyx_k_main[] = "__main__";
static const char __pyx_k_myid[] = "myid";
static const char __pyx_k_name[] = "__name__";
static const char __pyx_k_port[] = "port";
static const char __pyx_k_repr[] = "__repr__";
static const char __pyx_k_self[] = "self";
static const char __pyx_k_test[] = "__test__";
static const char __pyx_k_class[] = "__class__";
static const char __pyx_k_debug[] = "debug";
static const char __pyx_k_nodes[] = "nodes";
static const char __pyx_k_range[] = "range";
static const char __pyx_k_s_s_r[] = "%s > %s : %r";
static const char __pyx_k_super[] = "super";
static const char __pyx_k_token[] = "token";
static const char __pyx_k_utils[] = "utils";
static const char __pyx_k_value[] = "value";
static const char __pyx_k_BError[] = "BError";
static const char __pyx_k_encode[] = "encode";
static const char __pyx_k_import[] = "__import__";
static const char __pyx_k_kwargs[] = "kwargs";
static const char __pyx_k_module[] = "__module__";
static const char __pyx_k_reduce[] = "__reduce__";
static const char __pyx_k_target[] = "target";
static const char __pyx_k_values[] = "values";
static const char __pyx_k_bencode[] = "bencode";
static const char __pyx_k_compact[] = "compact";
static const char __pyx_k_datalen[] = "datalen";
static const char __pyx_k_default[] = "default";
static const char __pyx_k_prepare[] = "__prepare__";
static const char __pyx_k_BMessage[] = "BMessage";
static const char __pyx_k_KeyError[] = "KeyError";
static const char __pyx_k_MissingT[] = "MissingT";
static const char __pyx_k_getstate[] = "__getstate__";
static const char __pyx_k_qualname[] = "__qualname__";
static const char __pyx_k_s_at_s_r[] = "%s != : at %s %r";
static const char __pyx_k_setstate[] = "__setstate__";
static const char __pyx_k_TypeError[] = "TypeError";
static const char __pyx_k_addr_addr[] = "addr_addr";
static const char __pyx_k_bad_token[] = "bad token";
static const char __pyx_k_get_peers[] = "_get_peers";
static const char __pyx_k_get_token[] = "_get_token";
static const char __pyx_k_info_hash[] = "info_hash";
static const char __pyx_k_metaclass[] = "__metaclass__";
static const char __pyx_k_reduce_ex[] = "__reduce_ex__";
static const char __pyx_k_ValueError[] = "ValueError";
static const char __pyx_k_btdht_krcp[] = "btdht.krcp";
static const char __pyx_k_exceptions[] = "exceptions";
static const char __pyx_k_pyx_vtable[] = "__pyx_vtable__";
static const char __pyx_k_s_e_at_s_r[] = "%s != e at %s %r";
static const char __pyx_k_DecodeError[] = "DecodeError";
static const char __pyx_k_ServerError[] = "ServerError";
static const char __pyx_k_BError___str[] = "BError.__str__";
static const char __pyx_k_GenericError[] = "GenericError";
static const char __pyx_k_Server_Error[] = "Server Error";
static const char __pyx_k_implied_port[] = "implied_port";
static const char __pyx_k_port_missing[] = "port missing";
static const char __pyx_k_BError___init[] = "BError.__init__";
static const char __pyx_k_BError___repr[] = "BError.__repr__";
static const char __pyx_k_BError_encode[] = "BError.encode";
static const char __pyx_k_Method_Unknow[] = "Method Unknow";
static const char __pyx_k_ProtocolError[] = "ProtocolError";
static const char __pyx_k_reduce_cython[] = "__reduce_cython__";
static const char __pyx_k_token_missing[] = "token missing";
static const char __pyx_k_Protocol_Error[] = "Protocol Error";
static const char __pyx_k_btdht_krcp_pyx[] = "btdht/krcp.pyx";
static const char __pyx_k_target_missing[] = "target missing";
static const char __pyx_k_dict_pass_s_s_r[] = "dict_pass: %s > %s : %r";
static const char __pyx_k_get_valid_token[] = "_get_valid_token";
static const char __pyx_k_list_pass_s_s_r[] = "list_pass: %s > %s : %r";
static const char __pyx_k_setstate_cython[] = "__setstate_cython__";
static const char __pyx_k_EnvironmentError[] = "EnvironmentError";
static const char __pyx_k_Method_s_Unknown[] = "Method %s Unknown";
static const char __pyx_k_get_closest_nodes[] = "get_closest_nodes";
static const char __pyx_k_info_hash_missing[] = "info_hash missing";
static const char __pyx_k_MethodUnknownError[] = "MethodUnknownError";
static const char __pyx_k_ServerError___init[] = "ServerError.__init__";
static const char __pyx_k_cline_in_traceback[] = "cline_in_traceback";
static const char __pyx_k_GenericError___init[] = "GenericError.__init__";
static const char __pyx_k_NotImplementedError[] = "NotImplementedError";
static const char __pyx_k_ProtocolError___init[] = "ProtocolError.__init__";
static const char __pyx_k_t_should_not_be_None[] = "t should not be None";
static const char __pyx_k_MethodUnknownError___init[] = "MethodUnknownError.__init__";
static const char __pyx_k_Unable_to_encode_BMessage[] = "Unable to encode BMessage";
static const char __pyx_k_End_of_dict_not_found_s_d_r[] = "End of dict not found %s>=%d %r";
static const char __pyx_k_Fail_to_decode_dict_key_d_s[] = "Fail to decode dict key %d %s";
static const char __pyx_k_A_Generic_Error_error_code_201[] = "\n        A Generic Error, error code 201\n\n        :param bytes t: The value of the key t of the query for with the error is returned\n        :param bytes msg: An optionnal error message\n    ";
static const char __pyx_k_A_base_class_exception_for_all[] = "\n        A base class exception for all bittorrent DHT protocol error exceptions\n\n        :param bytes t: The value of the key t of the query for with the error is returned\n        :param list e: A couple [error code, error message]\n    ";
static const char __pyx_k_A_Protocol_Error_such_as_a_malf[] = "\n        A Protocol Error, such as a malformed packet, invalid arguments, or bad token,\n        error code 203\n\n        :param bytes t: The value of the key t of the query for with the error is returned\n        :param bytes msg: An optionnal error message\n    ";
static const char __pyx_k_A_Server_Error_error_code_202_p[] = "\n        A Server Error, error code 202\n\n        :param bytes t: The value of the key t of the query for with the error is returned\n        :param bytes msg: An optionnal error message\n    ";
static const char __pyx_k_Method_Unknown_error_code_204_p[] = "\n        Method Unknown, error code 204\n\n        :param bytes t: The value of the key t of the query for with the error is returned\n        :param bytes msg: An optionnal error message\n    ";
static const char __pyx_k_fail_to_decode_dict_element_d_r[] = "fail to decode dict element %d %r";
static const char __pyx_k_Can_only_set_strings_of_length_2[] = "Can only set strings of length 20B";
static const char __pyx_k_End_of_values_list_not_found_s_s[] = "End of values list not found %s >= %s found %s elements";
static const char __pyx_k_Trying_to_convert_s_to_long_long[] = "Trying to convert %s to long long but it's too big";
static const char __pyx_k_Unable_to_decode_element_of_dict[] = "Unable to decode element of dict at %d %r";
static const char __pyx_k_Unable_to_parse_one_of_the_eleme[] = "Unable to parse one of the element of the list %d %r";
static const char __pyx_k_list_element_should_be_of_length[] = "list element should be of length %d\n";
static const char __pyx_k_no_default___reduce___due_to_non[] = "no default __reduce__ due to non-trivial __cinit__";
static const char __pyx_k_Unable_to_parse_one_of_the_eleme_2[] = "Unable to parse one of the element of the dict %d %r";
static PyObject *__pyx_kp_s_A_Generic_Error_error_code_201;
static PyObject *__pyx_kp_s_A_Protocol_Error_such_as_a_malf;
static PyObject *__pyx_kp_s_A_Server_Error_error_code_202_p;
static PyObject *__pyx_kp_s_A_base_class_exception_for_all;
static PyObject *__pyx_n_s_BError;
static PyObject *__pyx_n_s_BError___init;
static PyObject *__pyx_n_s_BError___repr;
static PyObject *__pyx_n_s_BError___str;
static PyObject *__pyx_n_s_BError_encode;
static PyObject *__pyx_n_s_BMessage;
static PyObject *__pyx_kp_s_Can_only_set_strings_of_length_2;
static PyObject *__pyx_n_s_DecodeError;
static PyObject *__pyx_kp_s_End_of_dict_not_found_s_d_r;
static PyObject *__pyx_kp_s_End_of_values_list_not_found_s_s;
static PyObject *__pyx_n_s_EnvironmentError;
static PyObject *__pyx_kp_s_Fail_to_decode_dict_key_d_s;
static PyObject *__pyx_n_s_GenericError;
static PyObject *__pyx_n_s_GenericError___init;
static PyObject *__pyx_n_s_KeyError;
static PyObject *__pyx_n_s_MethodUnknownError;
static PyObject *__pyx_n_s_MethodUnknownError___init;
static PyObject *__pyx_kp_b_Method_Unknow;
static PyObject *__pyx_kp_s_Method_Unknown_error_code_204_p;
static PyObject *__pyx_kp_b_Method_s_Unknown;
static PyObject *__pyx_n_s_MissingT;
static PyObject *__pyx_n_s_NotImplementedError;
static PyObject *__pyx_n_s_PY3;
static PyObject *__pyx_n_s_ProtocolError;
static PyObject *__pyx_n_s_ProtocolError___init;
static PyObject *__pyx_kp_b_Protocol_Error;
static PyObject *__pyx_n_s_ServerError;
static PyObject *__pyx_n_s_ServerError___init;
static PyObject *__pyx_kp_b_Server_Error;
static PyObject *__pyx_kp_s_Trying_to_convert_s_to_long_long;
static PyObject *__pyx_n_s_TypeError;
static PyObject *__pyx_kp_s_Unable_to_decode_element_of_dict;
static PyObject *__pyx_kp_s_Unable_to_encode_BMessage;
static PyObject *__pyx_kp_s_Unable_to_parse_one_of_the_eleme;
static PyObject *__pyx_kp_s_Unable_to_parse_one_of_the_eleme_2;
static PyObject *__pyx_n_s_ValueError;
static PyObject *__pyx_kp_b__2;
static PyObject *__pyx_n_s_addr;
static PyObject *__pyx_n_s_addr_addr;
static PyObject *__pyx_kp_b_bad_token;
static PyObject *__pyx_n_s_bencode;
static PyObject *__pyx_n_s_btdht_krcp;
static PyObject *__pyx_kp_s_btdht_krcp_pyx;
static PyObject *__pyx_n_s_class;
static PyObject *__pyx_n_s_cline_in_traceback;
static PyObject *__pyx_n_s_compact;
static PyObject *__pyx_n_s_data;
static PyObject *__pyx_n_s_datalen;
static PyObject *__pyx_n_s_debug;
static PyObject *__pyx_n_s_default;
static PyObject *__pyx_kp_s_dict_pass_s_s_r;
static PyObject *__pyx_n_s_doc;
static PyObject *__pyx_n_b_e;
static PyObject *__pyx_n_s_e;
static PyObject *__pyx_n_s_encode;
static PyObject *__pyx_n_s_exceptions;
static PyObject *__pyx_kp_s_fail_to_decode_dict_element_d_r;
static PyObject *__pyx_n_s_get_closest_nodes;
static PyObject *__pyx_n_s_get_peers;
static PyObject *__pyx_n_s_get_token;
static PyObject *__pyx_n_s_get_valid_token;
static PyObject *__pyx_n_s_getstate;
static PyObject *__pyx_n_b_id;
static PyObject *__pyx_n_b_implied_port;
static PyObject *__pyx_n_s_import;
static PyObject *__pyx_n_b_info_hash;
static PyObject *__pyx_kp_b_info_hash_missing;
static PyObject *__pyx_n_s_init;
static PyObject *__pyx_n_s_key;
static PyObject *__pyx_n_s_kwargs;
static PyObject *__pyx_kp_s_list_element_should_be_of_length;
static PyObject *__pyx_kp_s_list_pass_s_s_r;
static PyObject *__pyx_n_s_main;
static PyObject *__pyx_n_s_metaclass;
static PyObject *__pyx_n_s_module;
static PyObject *__pyx_n_s_msg;
static PyObject *__pyx_n_s_myid;
static PyObject *__pyx_n_s_name;
static PyObject *__pyx_kp_s_no_default___reduce___due_to_non;
static PyObject *__pyx_n_b_nodes;
static PyObject *__pyx_n_s_os;
static PyObject *__pyx_n_b_port;
static PyObject *__pyx_kp_b_port_missing;
static PyObject *__pyx_n_s_prepare;
static PyObject *__pyx_n_s_pyx_vtable;
static PyObject *__pyx_n_s_q;
static PyObject *__pyx_n_s_qualname;
static PyObject *__pyx_kp_s_r;
static PyObject *__pyx_n_s_range;
static PyObject *__pyx_n_s_reduce;
static PyObject *__pyx_n_s_reduce_cython;
static PyObject *__pyx_n_s_reduce_ex;
static PyObject *__pyx_n_s_repr;
static PyObject *__pyx_kp_s_s_at_s_r;
static PyObject *__pyx_kp_s_s_e_at_s_r;
static PyObject *__pyx_kp_s_s_r;
static PyObject *__pyx_kp_s_s_s_r;
static PyObject *__pyx_n_s_self;
static PyObject *__pyx_n_s_setstate;
static PyObject *__pyx_n_s_setstate_cython;
static PyObject *__pyx_n_s_six;
static PyObject *__pyx_n_s_str;
static PyObject *__pyx_n_s_super;
static PyObject *__pyx_n_b_t;
static PyObject *__pyx_n_s_t;
static PyObject *__pyx_kp_s_t_should_not_be_None;
static PyObject *__pyx_n_b_target;
static PyObject *__pyx_kp_b_target_missing;
static PyObject *__pyx_n_s_test;
static PyObject *__pyx_n_b_token;
static PyObject *__pyx_kp_b_token_missing;
static PyObject *__pyx_n_s_utils;
static PyObject *__pyx_n_s_value;
static PyObject *__pyx_n_b_values;
static PyObject *__pyx_n_b_y;
static PyObject *__pyx_n_s_y;
static PyObject *__pyx_pf_5btdht_4krcp_6BError___init__(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_t, PyObject *__pyx_v_e, PyObject *__pyx_v_kwargs); /* proto */
static PyObject *__pyx_pf_5btdht_4krcp_6BError_2encode(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_5btdht_4krcp_6BError_4__str__(CYTHON_UNUSED PyObject *__pyx_self, CYTHON_UNUSED PyObject *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_5btdht_4krcp_6BError_6__repr__(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_5btdht_4krcp_12GenericError___init__(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_t, PyObject *__pyx_v_msg); /* proto */
static PyObject *__pyx_pf_5btdht_4krcp_11ServerError___init__(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_t, PyObject *__pyx_v_msg); /* proto */
static PyObject *__pyx_pf_5btdht_4krcp_13ProtocolError___init__(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_t, PyObject *__pyx_v_msg); /* proto */
static PyObject *__pyx_pf_5btdht_4krcp_18MethodUnknownError___init__(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_t, PyObject *__pyx_v_msg); /* proto */
static PyObject *__pyx_pf_5btdht_4krcp_8BMessage_response(struct __pyx_obj_5btdht_4krcp_BMessage *__pyx_v_self, PyObject *__pyx_v_dht); /* proto */
static PyObject *__pyx_pf_5btdht_4krcp_8BMessage_2encode(struct __pyx_obj_5btdht_4krcp_BMessage *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_5btdht_4krcp_8BMessage_4__repr__(struct __pyx_obj_5btdht_4krcp_BMessage *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_5btdht_4krcp_8BMessage_6__str__(CYTHON_UNUSED struct __pyx_obj_5btdht_4krcp_BMessage *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_5btdht_4krcp_8BMessage_5errno___get__(struct __pyx_obj_5btdht_4krcp_BMessage *__pyx_v_self); /* proto */
static int __pyx_pf_5btdht_4krcp_8BMessage_5errno_2__set__(struct __pyx_obj_5btdht_4krcp_BMessage *__pyx_v_self, int __pyx_v_value); /* proto */
static PyObject *__pyx_pf_5btdht_4krcp_8BMessage_6errmsg___get__(struct __pyx_obj_5btdht_4krcp_BMessage *__pyx_v_self); /* proto */
static int __pyx_pf_5btdht_4krcp_8BMessage_6errmsg_2__set__(struct __pyx_obj_5btdht_4krcp_BMessage *__pyx_v_self, char *__pyx_v_msg); /* proto */
static PyObject *__pyx_pf_5btdht_4krcp_8BMessage_4addr___get__(struct __pyx_obj_5btdht_4krcp_BMessage *__pyx_v_self); /* proto */
static int __pyx_pf_5btdht_4krcp_8BMessage_4addr_2__set__(struct __pyx_obj_5btdht_4krcp_BMessage *__pyx_v_self, PyObject *__pyx_v_addr); /* proto */
static int __pyx_pf_5btdht_4krcp_8BMessage_4addr_4__del__(struct __pyx_obj_5btdht_4krcp_BMessage *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_5btdht_4krcp_8BMessage_1y___get__(struct __pyx_obj_5btdht_4krcp_BMessage *__pyx_v_self); /* proto */
static int __pyx_pf_5btdht_4krcp_8BMessage_1y_2__set__(struct __pyx_obj_5btdht_4krcp_BMessage *__pyx_v_self, char *__pyx_v_value); /* proto */
static int __pyx_pf_5btdht_4krcp_8BMessage_1y_4__del__(struct __pyx_obj_5btdht_4krcp_BMessage *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_5btdht_4krcp_8BMessage_1t___get__(struct __pyx_obj_5btdht_4krcp_BMessage *__pyx_v_self); /* proto */
static int __pyx_pf_5btdht_4krcp_8BMessage_1t_2__set__(struct __pyx_obj_5btdht_4krcp_BMessage *__pyx_v_self, char *__pyx_v_value); /* proto */
static int __pyx_pf_5btdht_4krcp_8BMessage_1t_4__del__(struct __pyx_obj_5btdht_4krcp_BMessage *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_5btdht_4krcp_8BMessage_1q___get__(struct __pyx_obj_5btdht_4krcp_BMessage *__pyx_v_self); /* proto */
static int __pyx_pf_5btdht_4krcp_8BMessage_1q_2__set__(struct __pyx_obj_5btdht_4krcp_BMessage *__pyx_v_self, char *__pyx_v_value); /* proto */
static int __pyx_pf_5btdht_4krcp_8BMessage_1q_4__del__(struct __pyx_obj_5btdht_4krcp_BMessage *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_5btdht_4krcp_8BMessage_1v___get__(struct __pyx_obj_5btdht_4krcp_BMessage *__pyx_v_self); /* proto */
static int __pyx_pf_5btdht_4krcp_8BMessage_1v_2__set__(struct __pyx_obj_5btdht_4krcp_BMessage *__pyx_v_self, char *__pyx_v_value); /* proto */
static int __pyx_pf_5btdht_4krcp_8BMessage_1v_4__del__(struct __pyx_obj_5btdht_4krcp_BMessage *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_5btdht_4krcp_8BMessage_8__getitem__(struct __pyx_obj_5btdht_4krcp_BMessage *__pyx_v_self, char *__pyx_v_key); /* proto */
static int __pyx_pf_5btdht_4krcp_8BMessage_10__delitem__(struct __pyx_obj_5btdht_4krcp_BMessage *__pyx_v_self, char *__pyx_v_key); /* proto */
static int __pyx_pf_5btdht_4krcp_8BMessage_12__setitem__(struct __pyx_obj_5btdht_4krcp_BMessage *__pyx_v_self, char *__pyx_v_key, PyObject *__pyx_v_value); /* proto */
static PyObject *__pyx_pf_5btdht_4krcp_8BMessage_14get(struct __pyx_obj_5btdht_4krcp_BMessage *__pyx_v_self, char *__pyx_v_key, PyObject *__pyx_v_default); /* proto */
static void __pyx_pf_5btdht_4krcp_8BMessage_16__dealloc__(struct __pyx_obj_5btdht_4krcp_BMessage *__pyx_v_self); /* proto */
static int __pyx_pf_5btdht_4krcp_8BMessage_18__init__(struct __pyx_obj_5btdht_4krcp_BMessage *__pyx_v_self, PyObject *__pyx_v_addr, CYTHON_UNUSED PyObject *__pyx_v_debug); /* proto */
static int __pyx_pf_5btdht_4krcp_8BMessage_20__cinit__(struct __pyx_obj_5btdht_4krcp_BMessage *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v_addr, PyObject *__pyx_v_debug); /* proto */
static PyObject *__pyx_pf_5btdht_4krcp_8BMessage_22decode(struct __pyx_obj_5btdht_4krcp_BMessage *__pyx_v_self, char *__pyx_v_data, int __pyx_v_datalen); /* proto */
static PyObject *__pyx_pf_5btdht_4krcp_8BMessage_24__reduce_cython__(CYTHON_UNUSED struct __pyx_obj_5btdht_4krcp_BMessage *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_5btdht_4krcp_8BMessage_26__setstate_cython__(CYTHON_UNUSED struct __pyx_obj_5btdht_4krcp_BMessage *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v___pyx_state); /* proto */
static PyObject *__pyx_tp_new_5btdht_4krcp_BMessage(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
static PyObject *__pyx_int_201;
static PyObject *__pyx_int_202;
static PyObject *__pyx_int_203;
static PyObject *__pyx_int_204;
static PyObject *__pyx_tuple_;
static PyObject *__pyx_tuple__3;
static PyObject *__pyx_tuple__4;
static PyObject *__pyx_tuple__5;
static PyObject *__pyx_tuple__6;
static PyObject *__pyx_tuple__7;
static PyObject *__pyx_tuple__9;
static PyObject *__pyx_tuple__11;
static PyObject *__pyx_tuple__13;
static PyObject *__pyx_tuple__15;
static PyObject *__pyx_tuple__17;
static PyObject *__pyx_tuple__18;
static PyObject *__pyx_tuple__20;
static PyObject *__pyx_tuple__21;
static PyObject *__pyx_tuple__23;
static PyObject *__pyx_tuple__24;
static PyObject *__pyx_tuple__26;
static PyObject *__pyx_codeobj__8;
static PyObject *__pyx_codeobj__10;
static PyObject *__pyx_codeobj__12;
static PyObject *__pyx_codeobj__14;
static PyObject *__pyx_codeobj__16;
static PyObject *__pyx_codeobj__19;
static PyObject *__pyx_codeobj__22;
static PyObject *__pyx_codeobj__25;
/* Late includes */

/* "btdht/krcp.pyx":25
 * from .exceptions import MissingT, DecodeError
 * 
 * cdef int str_to_int(char* data, int len) nogil:             # <<<<<<<<<<<<<<
 *     """
 *         Transform a string of 1-9 to an int
 */

static int __pyx_f_5btdht_4krcp_str_to_int(char *__pyx_v_data, int __pyx_v_len) {
  char *__pyx_v_msg;
  int __pyx_v_i;
  int __pyx_r;
  int __pyx_t_1;

  /* "btdht/krcp.pyx":38
 *             This function can be called without the python GIL
 *     """
 *     cdef char* msg = NULL             # <<<<<<<<<<<<<<
 *     cdef int i
 *     try:
 */
  __pyx_v_msg = NULL;

  /* "btdht/krcp.pyx":40
 *     cdef char* msg = NULL
 *     cdef int i
 *     try:             # <<<<<<<<<<<<<<
 *         msg = <char *>malloc((len+1) * sizeof(char))
 *         strncpy(msg, data, len)
 */
  /*try:*/ {

    /* "btdht/krcp.pyx":41
 *     cdef int i
 *     try:
 *         msg = <char *>malloc((len+1) * sizeof(char))             # <<<<<<<<<<<<<<
 *         strncpy(msg, data, len)
 *         msg[len]='\0'
 */
    __pyx_v_msg = ((char *)malloc(((__pyx_v_len + 1) * (sizeof(char)))));

    /* "btdht/krcp.pyx":42
 *     try:
 *         msg = <char *>malloc((len+1) * sizeof(char))
 *         strncpy(msg, data, len)             # <<<<<<<<<<<<<<
 *         msg[len]='\0'
 *         i = atoi(msg)
 */
    (void)(strncpy(__pyx_v_msg, __pyx_v_data, __pyx_v_len));

    /* "btdht/krcp.pyx":43
 *         msg = <char *>malloc((len+1) * sizeof(char))
 *         strncpy(msg, data, len)
 *         msg[len]='\0'             # <<<<<<<<<<<<<<
 *         i = atoi(msg)
 *     finally:
 */
    (__pyx_v_msg[__pyx_v_len]) = '\x00';

    /* "btdht/krcp.pyx":44
 *         strncpy(msg, data, len)
 *         msg[len]='\0'
 *         i = atoi(msg)             # <<<<<<<<<<<<<<
 *     finally:
 *         if msg != NULL:
 */
    __pyx_v_i = atoi(__pyx_v_msg);
  }

  /* "btdht/krcp.pyx":46
 *         i = atoi(msg)
 *     finally:
 *         if msg != NULL:             # <<<<<<<<<<<<<<
 *             free(msg)
 *     return i
 */
  /*finally:*/ {
    /*normal exit:*/{
      __pyx_t_1 = ((__pyx_v_msg != NULL) != 0);
      if (__pyx_t_1) {

        /* "btdht/krcp.pyx":47
 *     finally:
 *         if msg != NULL:
 *             free(msg)             # <<<<<<<<<<<<<<
 *     return i
 * 
 */
        free(__pyx_v_msg);

        /* "btdht/krcp.pyx":46
 *         i = atoi(msg)
 *     finally:
 *         if msg != NULL:             # <<<<<<<<<<<<<<
 *             free(msg)
 *     return i
 */
      }
      goto __pyx_L5;
    }
    __pyx_L5:;
  }

  /* "btdht/krcp.pyx":48
 *         if msg != NULL:
 *             free(msg)
 *     return i             # <<<<<<<<<<<<<<
 * 
 * cdef long str_to_long(char* data, int len) nogil:
 */
  __pyx_r = __pyx_v_i;
  goto __pyx_L0;

  /* "btdht/krcp.pyx":25
 * from .exceptions import MissingT, DecodeError
 * 
 * cdef int str_to_int(char* data, int len) nogil:             # <<<<<<<<<<<<<<
 *     """
 *         Transform a string of 1-9 to an int
 */

  /* function exit code */
  __pyx_L0:;
  return __pyx_r;
}

/* "btdht/krcp.pyx":50
 *     return i
 * 
 * cdef long str_to_long(char* data, int len) nogil:             # <<<<<<<<<<<<<<
 *     """
 *         Transform a string of 1-9 to an int
 */

static long __pyx_f_5btdht_4krcp_str_to_long(char *__pyx_v_data, int __pyx_v_len) {
  char *__pyx_v_msg;
  PY_LONG_LONG __pyx_v_i;
  long __pyx_r;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  int __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  #ifdef WITH_THREAD
  PyGILState_STATE __pyx_gilstate_save;
  #endif
  __Pyx_RefNannySetupContext("str_to_long", 1);

  /* "btdht/krcp.pyx":51
 * 
 * cdef long str_to_long(char* data, int len) nogil:
 *     """             # <<<<<<<<<<<<<<
 *         Transform a string of 1-9 to an int
 * 
 */
  /*try:*/ {

    /* "btdht/krcp.pyx":63
 *             This function can be called without the python GIL
 *     """
 *     cdef char* msg = NULL             # <<<<<<<<<<<<<<
 *     cdef long long i
 *     if data[0] == b'-' and len > 16 or len > 17:
 */
    __pyx_v_msg = NULL;

    /* "btdht/krcp.pyx":65
 *     cdef char* msg = NULL
 *     cdef long long i
 *     if data[0] == b'-' and len > 16 or len > 17:             # <<<<<<<<<<<<<<
 *         with gil:
 *             raise EnvironmentError(
 */
    __pyx_t_2 = (((__pyx_v_data[0]) == '-') != 0);
    if (!__pyx_t_2) {
      goto __pyx_L8_next_or;
    } else {
    }
    __pyx_t_2 = ((__pyx_v_len > 16) != 0);
    if (!__pyx_t_2) {
    } else {
      __pyx_t_1 = __pyx_t_2;
      goto __pyx_L7_bool_binop_done;
    }
    __pyx_L8_next_or:;
    __pyx_t_2 = ((__pyx_v_len > 17) != 0);
    __pyx_t_1 = __pyx_t_2;
    __pyx_L7_bool_binop_done:;
    if (__pyx_t_1) {

      /* "btdht/krcp.pyx":66
 *     cdef long long i
 *     if data[0] == b'-' and len > 16 or len > 17:
 *         with gil:             # <<<<<<<<<<<<<<
 *             raise EnvironmentError(
 *                 "Trying to convert %s to long long but it's too big" % data[:len]
 */
      {
          #ifdef WITH_THREAD
          PyGILState_STATE __pyx_gilstate_save = __Pyx_PyGILState_Ensure();
          #endif
          /*try:*/ {

            /* "btdht/krcp.pyx":68
 *         with gil:
 *             raise EnvironmentError(
 *                 "Trying to convert %s to long long but it's too big" % data[:len]             # <<<<<<<<<<<<<<
 *             )
 *     try:
 */
            __pyx_t_3 = __Pyx_PyBytes_FromStringAndSize(__pyx_v_data + 0, __pyx_v_len - 0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 68, __pyx_L11_error)
            __Pyx_GOTREF(__pyx_t_3);
            __pyx_t_4 = __Pyx_PyString_Format(__pyx_kp_s_Trying_to_convert_s_to_long_long, __pyx_t_3); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 68, __pyx_L11_error)
            __Pyx_GOTREF(__pyx_t_4);
            __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

            /* "btdht/krcp.pyx":67
 *     if data[0] == b'-' and len > 16 or len > 17:
 *         with gil:
 *             raise EnvironmentError(             # <<<<<<<<<<<<<<
 *                 "Trying to convert %s to long long but it's too big" % data[:len]
 *             )
 */
            __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_builtin_EnvironmentError, __pyx_t_4); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 67, __pyx_L11_error)
            __Pyx_GOTREF(__pyx_t_3);
            __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
            __Pyx_Raise(__pyx_t_3, 0, 0, 0);
            __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
            __PYX_ERR(0, 67, __pyx_L11_error)
          }

          /* "btdht/krcp.pyx":66
 *     cdef long long i
 *     if data[0] == b'-' and len > 16 or len > 17:
 *         with gil:             # <<<<<<<<<<<<<<
 *             raise EnvironmentError(
 *                 "Trying to convert %s to long long but it's too big" % data[:len]
 */
          /*finally:*/ {
            __pyx_L11_error: {
              #ifdef WITH_THREAD
              __Pyx_PyGILState_Release(__pyx_gilstate_save);
              #endif
              goto __pyx_L4_error;
            }
          }
      }

      /* "btdht/krcp.pyx":65
 *     cdef char* msg = NULL
 *     cdef long long i
 *     if data[0] == b'-' and len > 16 or len > 17:             # <<<<<<<<<<<<<<
 *         with gil:
 *             raise EnvironmentError(
 */
    }

    /* "btdht/krcp.pyx":70
 *                 "Trying to convert %s to long long but it's too big" % data[:len]
 *             )
 *     try:             # <<<<<<<<<<<<<<
 *         msg = <char *>malloc((len+1) * sizeof(char))
 *         strncpy(msg, data, len)
 */
    /*try:*/ {

      /* "btdht/krcp.pyx":71
 *             )
 *     try:
 *         msg = <char *>malloc((len+1) * sizeof(char))             # <<<<<<<<<<<<<<
 *         strncpy(msg, data, len)
 *         msg[len]=b'\0'
 */
      __pyx_v_msg = ((char *)malloc(((__pyx_v_len + 1) * (sizeof(char)))));

      /* "btdht/krcp.pyx":72
 *     try:
 *         msg = <char *>malloc((len+1) * sizeof(char))
 *         strncpy(msg, data, len)             # <<<<<<<<<<<<<<
 *         msg[len]=b'\0'
 *         i = atol(msg)
 */
      (void)(strncpy(__pyx_v_msg, __pyx_v_data, __pyx_v_len));

      /* "btdht/krcp.pyx":73
 *         msg = <char *>malloc((len+1) * sizeof(char))
 *         strncpy(msg, data, len)
 *         msg[len]=b'\0'             # <<<<<<<<<<<<<<
 *         i = atol(msg)
 *     finally:
 */
      (__pyx_v_msg[__pyx_v_len]) = '\x00';

      /* "btdht/krcp.pyx":74
 *         strncpy(msg, data, len)
 *         msg[len]=b'\0'
 *         i = atol(msg)             # <<<<<<<<<<<<<<
 *     finally:
 *         if msg != NULL:
 */
      __pyx_v_i = atol(__pyx_v_msg);
    }

    /* "btdht/krcp.pyx":76
 *         i = atol(msg)
 *     finally:
 *         if msg != NULL:             # <<<<<<<<<<<<<<
 *             free(msg)
 *     return i
 */
    /*finally:*/ {
      /*normal exit:*/{
        __pyx_t_1 = ((__pyx_v_msg != NULL) != 0);
        if (__pyx_t_1) {

          /* "btdht/krcp.pyx":77
 *     finally:
 *         if msg != NULL:
 *             free(msg)             # <<<<<<<<<<<<<<
 *     return i
 * 
 */
          free(__pyx_v_msg);

          /* "btdht/krcp.pyx":76
 *         i = atol(msg)
 *     finally:
 *         if msg != NULL:             # <<<<<<<<<<<<<<
 *             free(msg)
 *     return i
 */
        }
        goto __pyx_L15;
      }
      __pyx_L15:;
    }

    /* "btdht/krcp.pyx":78
 *         if msg != NULL:
 *             free(msg)
 *     return i             # <<<<<<<<<<<<<<
 * 
 * cdef int int_length(int i) nogil:
 */
    __pyx_r = __pyx_v_i;
    goto __pyx_L3_return;
  }

  /* "btdht/krcp.pyx":51
 * 
 * cdef long str_to_long(char* data, int len) nogil:
 *     """             # <<<<<<<<<<<<<<
 *         Transform a string of 1-9 to an int
 * 
 */
  /*finally:*/ {
    __pyx_L3_return: {
      #ifdef WITH_THREAD
      __pyx_gilstate_save = __Pyx_PyGILState_Ensure();
      #endif
      goto __pyx_L0;
    }
    __pyx_L4_error: {
      #ifdef WITH_THREAD
      __pyx_gilstate_save = __Pyx_PyGILState_Ensure();
      #endif
      goto __pyx_L1_error;
    }
  }

  /* "btdht/krcp.pyx":50
 *     return i
 * 
 * cdef long str_to_long(char* data, int len) nogil:             # <<<<<<<<<<<<<<
 *     """
 *         Transform a string of 1-9 to an int
 */

  /* function exit code */
  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_WriteUnraisable("btdht.krcp.str_to_long", __pyx_clineno, __pyx_lineno, __pyx_filename, 1, 1);
  __pyx_r = 0;
  __pyx_L0:;
  #ifdef WITH_THREAD
  __Pyx_PyGILState_Release(__pyx_gilstate_save);
  #endif
  return __pyx_r;
}

/* "btdht/krcp.pyx":80
 *     return i
 * 
 * cdef int int_length(int i) nogil:             # <<<<<<<<<<<<<<
 *     """
 *         :param int i: An integer
 */

static int __pyx_f_5btdht_4krcp_int_length(int __pyx_v_i) {
  int __pyx_r;
  int __pyx_t_1;

  /* "btdht/krcp.pyx":89
 *             This function can be called without the python GIL
 *     """
 *     if i == 0:             # <<<<<<<<<<<<<<
 *         return 1
 *     elif i < 0:
 */
  __pyx_t_1 = ((__pyx_v_i == 0) != 0);
  if (__pyx_t_1) {

    /* "btdht/krcp.pyx":90
 *     """
 *     if i == 0:
 *         return 1             # <<<<<<<<<<<<<<
 *     elif i < 0:
 *         return (<int> math.log10(0-i)) + 2
 */
    __pyx_r = 1;
    goto __pyx_L0;

    /* "btdht/krcp.pyx":89
 *             This function can be called without the python GIL
 *     """
 *     if i == 0:             # <<<<<<<<<<<<<<
 *         return 1
 *     elif i < 0:
 */
  }

  /* "btdht/krcp.pyx":91
 *     if i == 0:
 *         return 1
 *     elif i < 0:             # <<<<<<<<<<<<<<
 *         return (<int> math.log10(0-i)) + 2
 *     else:
 */
  __pyx_t_1 = ((__pyx_v_i < 0) != 0);
  if (__pyx_t_1) {

    /* "btdht/krcp.pyx":92
 *         return 1
 *     elif i < 0:
 *         return (<int> math.log10(0-i)) + 2             # <<<<<<<<<<<<<<
 *     else:
 *         return (<int> math.log10(i)) + 1
 */
    __pyx_r = (((int)log10((0 - __pyx_v_i))) + 2);
    goto __pyx_L0;

    /* "btdht/krcp.pyx":91
 *     if i == 0:
 *         return 1
 *     elif i < 0:             # <<<<<<<<<<<<<<
 *         return (<int> math.log10(0-i)) + 2
 *     else:
 */
  }

  /* "btdht/krcp.pyx":94
 *         return (<int> math.log10(0-i)) + 2
 *     else:
 *         return (<int> math.log10(i)) + 1             # <<<<<<<<<<<<<<
 * 
 * cdef varray_to_list(char ** data, size):
 */
  /*else*/ {
    __pyx_r = (((int)log10(__pyx_v_i)) + 1);
    goto __pyx_L0;
  }

  /* "btdht/krcp.pyx":80
 *     return i
 * 
 * cdef int int_length(int i) nogil:             # <<<<<<<<<<<<<<
 *     """
 *         :param int i: An integer
 */

  /* function exit code */
  __pyx_L0:;
  return __pyx_r;
}

/* "btdht/krcp.pyx":96
 *         return (<int> math.log10(i)) + 1
 * 
 * cdef varray_to_list(char ** data, size):             # <<<<<<<<<<<<<<
 *     """
 *         Transform a an C array of compact peers information to a python list
 */

static PyObject *__pyx_f_5btdht_4krcp_varray_to_list(char **__pyx_v_data, PyObject *__pyx_v_size) {
  PyObject *__pyx_v_l = NULL;
  PyObject *__pyx_v_i = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  Py_ssize_t __pyx_t_3;
  PyObject *(*__pyx_t_4)(PyObject *);
  Py_ssize_t __pyx_t_5;
  int __pyx_t_6;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("varray_to_list", 0);

  /* "btdht/krcp.pyx":111
 *             concatenated onto the end.
 *     """
 *     l=[]             # <<<<<<<<<<<<<<
 *     for i in range(size):
 *         l.append(data[i][:6])
 */
  __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 111, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_l = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "btdht/krcp.pyx":112
 *     """
 *     l=[]
 *     for i in range(size):             # <<<<<<<<<<<<<<
 *         l.append(data[i][:6])
 *     return l
 */
  __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_builtin_range, __pyx_v_size); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 112, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (likely(PyList_CheckExact(__pyx_t_1)) || PyTuple_CheckExact(__pyx_t_1)) {
    __pyx_t_2 = __pyx_t_1; __Pyx_INCREF(__pyx_t_2); __pyx_t_3 = 0;
    __pyx_t_4 = NULL;
  } else {
    __pyx_t_3 = -1; __pyx_t_2 = PyObject_GetIter(__pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 112, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_4 = Py_TYPE(__pyx_t_2)->tp_iternext; if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 112, __pyx_L1_error)
  }
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  for (;;) {
    if (likely(!__pyx_t_4)) {
      if (likely(PyList_CheckExact(__pyx_t_2))) {
        if (__pyx_t_3 >= PyList_GET_SIZE(__pyx_t_2)) break;
        #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
        __pyx_t_1 = PyList_GET_ITEM(__pyx_t_2, __pyx_t_3); __Pyx_INCREF(__pyx_t_1); __pyx_t_3++; if (unlikely(0 < 0)) __PYX_ERR(0, 112, __pyx_L1_error)
        #else
        __pyx_t_1 = PySequence_ITEM(__pyx_t_2, __pyx_t_3); __pyx_t_3++; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 112, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_1);
        #endif
      } else {
        if (__pyx_t_3 >= PyTuple_GET_SIZE(__pyx_t_2)) break;
        #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
        __pyx_t_1 = PyTuple_GET_ITEM(__pyx_t_2, __pyx_t_3); __Pyx_INCREF(__pyx_t_1); __pyx_t_3++; if (unlikely(0 < 0)) __PYX_ERR(0, 112, __pyx_L1_error)
        #else
        __pyx_t_1 = PySequence_ITEM(__pyx_t_2, __pyx_t_3); __pyx_t_3++; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 112, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_1);
        #endif
      }
    } else {
      __pyx_t_1 = __pyx_t_4(__pyx_t_2);
      if (unlikely(!__pyx_t_1)) {
        PyObject* exc_type = PyErr_Occurred();
        if (exc_type) {
          if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
          else __PYX_ERR(0, 112, __pyx_L1_error)
        }
        break;
      }
      __Pyx_GOTREF(__pyx_t_1);
    }
    __Pyx_XDECREF_SET(__pyx_v_i, __pyx_t_1);
    __pyx_t_1 = 0;

    /* "btdht/krcp.pyx":113
 *     l=[]
 *     for i in range(size):
 *         l.append(data[i][:6])             # <<<<<<<<<<<<<<
 *     return l
 * 
 */
    __pyx_t_5 = __Pyx_PyIndex_AsSsize_t(__pyx_v_i); if (unlikely((__pyx_t_5 == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 113, __pyx_L1_error)
    __pyx_t_1 = __Pyx_PyBytes_FromStringAndSize((__pyx_v_data[__pyx_t_5]) + 0, 6 - 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 113, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_6 = __Pyx_PyList_Append(__pyx_v_l, __pyx_t_1); if (unlikely(__pyx_t_6 == ((int)-1))) __PYX_ERR(0, 113, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

    /* "btdht/krcp.pyx":112
 *     """
 *     l=[]
 *     for i in range(size):             # <<<<<<<<<<<<<<
 *         l.append(data[i][:6])
 *     return l
 */
  }
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "btdht/krcp.pyx":114
 *     for i in range(size):
 *         l.append(data[i][:6])
 *     return l             # <<<<<<<<<<<<<<
 * 
 * cdef char** vlist_to_array(l, int size=6):
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v_l);
  __pyx_r = __pyx_v_l;
  goto __pyx_L0;

  /* "btdht/krcp.pyx":96
 *         return (<int> math.log10(i)) + 1
 * 
 * cdef varray_to_list(char ** data, size):             # <<<<<<<<<<<<<<
 *     """
 *         Transform a an C array of compact peers information to a python list
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_AddTraceback("btdht.krcp.varray_to_list", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_l);
  __Pyx_XDECREF(__pyx_v_i);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "btdht/krcp.pyx":116
 *     return l
 * 
 * cdef char** vlist_to_array(l, int size=6):             # <<<<<<<<<<<<<<
 *     """
 *         Transform a python list of compact peers information to a C array
 */

static char **__pyx_f_5btdht_4krcp_vlist_to_array(PyObject *__pyx_v_l, struct __pyx_opt_args_5btdht_4krcp_vlist_to_array *__pyx_optional_args) {
  int __pyx_v_size = ((int)6);
  char **__pyx_v_data;
  Py_ssize_t __pyx_v_i;
  char **__pyx_r;
  __Pyx_RefNannyDeclarations
  Py_ssize_t __pyx_t_1;
  Py_ssize_t __pyx_t_2;
  Py_ssize_t __pyx_t_3;
  PyObject *__pyx_t_4 = NULL;
  Py_ssize_t __pyx_t_5;
  int __pyx_t_6;
  PyObject *__pyx_t_7 = NULL;
  char const *__pyx_t_8;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("vlist_to_array", 0);
  if (__pyx_optional_args) {
    if (__pyx_optional_args->__pyx_n > 0) {
      __pyx_v_size = __pyx_optional_args->size;
    }
  }

  /* "btdht/krcp.pyx":128
 *             You need to manually free the returned value to free the memory.
 *     """
 *     cdef char ** data = <char**>malloc(len(l) * sizeof(char*))             # <<<<<<<<<<<<<<
 *     for i in range(len(l)):
 *         if len(l[i]) != size:
 */
  __pyx_t_1 = PyObject_Length(__pyx_v_l); if (unlikely(__pyx_t_1 == ((Py_ssize_t)-1))) __PYX_ERR(0, 128, __pyx_L1_error)
  __pyx_v_data = ((char **)malloc((__pyx_t_1 * (sizeof(char *)))));

  /* "btdht/krcp.pyx":129
 *     """
 *     cdef char ** data = <char**>malloc(len(l) * sizeof(char*))
 *     for i in range(len(l)):             # <<<<<<<<<<<<<<
 *         if len(l[i]) != size:
 *             raise ValueError("list element should be of length %d\n" % size)
 */
  __pyx_t_1 = PyObject_Length(__pyx_v_l); if (unlikely(__pyx_t_1 == ((Py_ssize_t)-1))) __PYX_ERR(0, 129, __pyx_L1_error)
  __pyx_t_2 = __pyx_t_1;
  for (__pyx_t_3 = 0; __pyx_t_3 < __pyx_t_2; __pyx_t_3+=1) {
    __pyx_v_i = __pyx_t_3;

    /* "btdht/krcp.pyx":130
 *     cdef char ** data = <char**>malloc(len(l) * sizeof(char*))
 *     for i in range(len(l)):
 *         if len(l[i]) != size:             # <<<<<<<<<<<<<<
 *             raise ValueError("list element should be of length %d\n" % size)
 *         data[i]=<char*>malloc(6 * sizeof(char))
 */
    __pyx_t_4 = __Pyx_GetItemInt(__pyx_v_l, __pyx_v_i, Py_ssize_t, 1, PyInt_FromSsize_t, 0, 1, 1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 130, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_5 = PyObject_Length(__pyx_t_4); if (unlikely(__pyx_t_5 == ((Py_ssize_t)-1))) __PYX_ERR(0, 130, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_6 = ((__pyx_t_5 != __pyx_v_size) != 0);
    if (unlikely(__pyx_t_6)) {

      /* "btdht/krcp.pyx":131
 *     for i in range(len(l)):
 *         if len(l[i]) != size:
 *             raise ValueError("list element should be of length %d\n" % size)             # <<<<<<<<<<<<<<
 *         data[i]=<char*>malloc(6 * sizeof(char))
 *         strncpy(data[i], l[i], 6)
 */
      __pyx_t_4 = __Pyx_PyInt_From_int(__pyx_v_size); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 131, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_t_7 = __Pyx_PyString_Format(__pyx_kp_s_list_element_should_be_of_length, __pyx_t_4); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 131, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_7);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __pyx_t_4 = __Pyx_PyObject_CallOneArg(__pyx_builtin_ValueError, __pyx_t_7); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 131, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      __Pyx_Raise(__pyx_t_4, 0, 0, 0);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __PYX_ERR(0, 131, __pyx_L1_error)

      /* "btdht/krcp.pyx":130
 *     cdef char ** data = <char**>malloc(len(l) * sizeof(char*))
 *     for i in range(len(l)):
 *         if len(l[i]) != size:             # <<<<<<<<<<<<<<
 *             raise ValueError("list element should be of length %d\n" % size)
 *         data[i]=<char*>malloc(6 * sizeof(char))
 */
    }

    /* "btdht/krcp.pyx":132
 *         if len(l[i]) != size:
 *             raise ValueError("list element should be of length %d\n" % size)
 *         data[i]=<char*>malloc(6 * sizeof(char))             # <<<<<<<<<<<<<<
 *         strncpy(data[i], l[i], 6)
 *     return data
 */
    (__pyx_v_data[__pyx_v_i]) = ((char *)malloc((6 * (sizeof(char)))));

    /* "btdht/krcp.pyx":133
 *             raise ValueError("list element should be of length %d\n" % size)
 *         data[i]=<char*>malloc(6 * sizeof(char))
 *         strncpy(data[i], l[i], 6)             # <<<<<<<<<<<<<<
 *     return data
 * 
 */
    __pyx_t_4 = __Pyx_GetItemInt(__pyx_v_l, __pyx_v_i, Py_ssize_t, 1, PyInt_FromSsize_t, 0, 1, 1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 133, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_8 = __Pyx_PyObject_AsString(__pyx_t_4); if (unlikely((!__pyx_t_8) && PyErr_Occurred())) __PYX_ERR(0, 133, __pyx_L1_error)
    (void)(strncpy((__pyx_v_data[__pyx_v_i]), __pyx_t_8, 6));
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  }

  /* "btdht/krcp.pyx":134
 *         data[i]=<char*>malloc(6 * sizeof(char))
 *         strncpy(data[i], l[i], 6)
 *     return data             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_r = __pyx_v_data;
  goto __pyx_L0;

  /* "btdht/krcp.pyx":116
 *     return l
 * 
 * cdef char** vlist_to_array(l, int size=6):             # <<<<<<<<<<<<<<
 *     """
 *         Transform a python list of compact peers information to a C array
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_WriteUnraisable("btdht.krcp.vlist_to_array", __pyx_clineno, __pyx_lineno, __pyx_filename, 1, 0);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "btdht/krcp.pyx":137
 * 
 * 
 * cdef int _decode_pass_list(char* data, int *i, int max) nogil except -1:             # <<<<<<<<<<<<<<
 *     """
 *         Pass a bencoded list in a bencoded string
 */

static int __pyx_f_5btdht_4krcp__decode_pass_list(char *__pyx_v_data, int *__pyx_v_i, int __pyx_v_max) {
  int __pyx_v_j[1];
  PY_LONG_LONG __pyx_v_ll[1];
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  PyObject *__pyx_t_7 = NULL;
  long __pyx_t_8;
  int __pyx_t_9;
  int __pyx_t_10;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  #ifdef WITH_THREAD
  PyGILState_STATE __pyx_gilstate_save;
  #endif
  __Pyx_RefNannySetupContext("_decode_pass_list", 1);

  /* "btdht/krcp.pyx":138
 * 
 * cdef int _decode_pass_list(char* data, int *i, int max) nogil except -1:
 *     """             # <<<<<<<<<<<<<<
 *         Pass a bencoded list in a bencoded string
 * 
 */
  /*try:*/ {

    /* "btdht/krcp.pyx":154
 *     cdef int j[1]
 *     cdef long long ll[1]
 *     if i[0] >= max + 1:             # <<<<<<<<<<<<<<
 *         with gil:
 *             raise DecodeError("%s > %s : %r" % (i[0], max, data[:max]))
 */
    __pyx_t_1 = (((__pyx_v_i[0]) >= (__pyx_v_max + 1)) != 0);
    if (__pyx_t_1) {

      /* "btdht/krcp.pyx":155
 *     cdef long long ll[1]
 *     if i[0] >= max + 1:
 *         with gil:             # <<<<<<<<<<<<<<
 *             raise DecodeError("%s > %s : %r" % (i[0], max, data[:max]))
 *     if data[i[0]] != b"l":
 */
      {
          #ifdef WITH_THREAD
          PyGILState_STATE __pyx_gilstate_save = __Pyx_PyGILState_Ensure();
          #endif
          /*try:*/ {

            /* "btdht/krcp.pyx":156
 *     if i[0] >= max + 1:
 *         with gil:
 *             raise DecodeError("%s > %s : %r" % (i[0], max, data[:max]))             # <<<<<<<<<<<<<<
 *     if data[i[0]] != b"l":
 *         return False
 */
            __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_DecodeError); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 156, __pyx_L8_error)
            __Pyx_GOTREF(__pyx_t_3);
            __pyx_t_4 = __Pyx_PyInt_From_int((__pyx_v_i[0])); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 156, __pyx_L8_error)
            __Pyx_GOTREF(__pyx_t_4);
            __pyx_t_5 = __Pyx_PyInt_From_int(__pyx_v_max); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 156, __pyx_L8_error)
            __Pyx_GOTREF(__pyx_t_5);
            __pyx_t_6 = __Pyx_PyBytes_FromStringAndSize(__pyx_v_data + 0, __pyx_v_max - 0); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 156, __pyx_L8_error)
            __Pyx_GOTREF(__pyx_t_6);
            __pyx_t_7 = PyTuple_New(3); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 156, __pyx_L8_error)
            __Pyx_GOTREF(__pyx_t_7);
            __Pyx_GIVEREF(__pyx_t_4);
            PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_4);
            __Pyx_GIVEREF(__pyx_t_5);
            PyTuple_SET_ITEM(__pyx_t_7, 1, __pyx_t_5);
            __Pyx_GIVEREF(__pyx_t_6);
            PyTuple_SET_ITEM(__pyx_t_7, 2, __pyx_t_6);
            __pyx_t_4 = 0;
            __pyx_t_5 = 0;
            __pyx_t_6 = 0;
            __pyx_t_6 = __Pyx_PyString_Format(__pyx_kp_s_s_s_r, __pyx_t_7); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 156, __pyx_L8_error)
            __Pyx_GOTREF(__pyx_t_6);
            __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
            __pyx_t_7 = NULL;
            if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
              __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_3);
              if (likely(__pyx_t_7)) {
                PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
                __Pyx_INCREF(__pyx_t_7);
                __Pyx_INCREF(function);
                __Pyx_DECREF_SET(__pyx_t_3, function);
              }
            }
            __pyx_t_2 = (__pyx_t_7) ? __Pyx_PyObject_Call2Args(__pyx_t_3, __pyx_t_7, __pyx_t_6) : __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_6);
            __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
            __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
            if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 156, __pyx_L8_error)
            __Pyx_GOTREF(__pyx_t_2);
            __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
            __Pyx_Raise(__pyx_t_2, 0, 0, 0);
            __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
            __PYX_ERR(0, 156, __pyx_L8_error)
          }

          /* "btdht/krcp.pyx":155
 *     cdef long long ll[1]
 *     if i[0] >= max + 1:
 *         with gil:             # <<<<<<<<<<<<<<
 *             raise DecodeError("%s > %s : %r" % (i[0], max, data[:max]))
 *     if data[i[0]] != b"l":
 */
          /*finally:*/ {
            __pyx_L8_error: {
              #ifdef WITH_THREAD
              __Pyx_PyGILState_Release(__pyx_gilstate_save);
              #endif
              goto __pyx_L4_error;
            }
          }
      }

      /* "btdht/krcp.pyx":154
 *     cdef int j[1]
 *     cdef long long ll[1]
 *     if i[0] >= max + 1:             # <<<<<<<<<<<<<<
 *         with gil:
 *             raise DecodeError("%s > %s : %r" % (i[0], max, data[:max]))
 */
    }

    /* "btdht/krcp.pyx":157
 *         with gil:
 *             raise DecodeError("%s > %s : %r" % (i[0], max, data[:max]))
 *     if data[i[0]] != b"l":             # <<<<<<<<<<<<<<
 *         return False
 *     i[0]+=1
 */
    __pyx_t_1 = (((__pyx_v_data[(__pyx_v_i[0])]) != 'l') != 0);
    if (__pyx_t_1) {

      /* "btdht/krcp.pyx":158
 *             raise DecodeError("%s > %s : %r" % (i[0], max, data[:max]))
 *     if data[i[0]] != b"l":
 *         return False             # <<<<<<<<<<<<<<
 *     i[0]+=1
 *     while data[i[0]] != b'e' and i[0] < max:
 */
      __pyx_r = 0;
      goto __pyx_L3_return;

      /* "btdht/krcp.pyx":157
 *         with gil:
 *             raise DecodeError("%s > %s : %r" % (i[0], max, data[:max]))
 *     if data[i[0]] != b"l":             # <<<<<<<<<<<<<<
 *         return False
 *     i[0]+=1
 */
    }

    /* "btdht/krcp.pyx":159
 *     if data[i[0]] != b"l":
 *         return False
 *     i[0]+=1             # <<<<<<<<<<<<<<
 *     while data[i[0]] != b'e' and i[0] < max:
 *         if (
 */
    __pyx_t_8 = 0;
    (__pyx_v_i[__pyx_t_8]) = ((__pyx_v_i[__pyx_t_8]) + 1);

    /* "btdht/krcp.pyx":160
 *         return False
 *     i[0]+=1
 *     while data[i[0]] != b'e' and i[0] < max:             # <<<<<<<<<<<<<<
 *         if (
 *             not _decode_string(data, i, max, j) and
 */
    while (1) {
      __pyx_t_9 = (((__pyx_v_data[(__pyx_v_i[0])]) != 'e') != 0);
      if (__pyx_t_9) {
      } else {
        __pyx_t_1 = __pyx_t_9;
        goto __pyx_L13_bool_binop_done;
      }
      __pyx_t_9 = (((__pyx_v_i[0]) < __pyx_v_max) != 0);
      __pyx_t_1 = __pyx_t_9;
      __pyx_L13_bool_binop_done:;
      if (!__pyx_t_1) break;

      /* "btdht/krcp.pyx":162
 *     while data[i[0]] != b'e' and i[0] < max:
 *         if (
 *             not _decode_string(data, i, max, j) and             # <<<<<<<<<<<<<<
 *             not  _decode_int(data, i, max, ll) and
 *             not _decode_pass_list(data, i, max) and
 */
      __pyx_t_10 = __pyx_f_5btdht_4krcp__decode_string(__pyx_v_data, __pyx_v_i, __pyx_v_max, __pyx_v_j); if (unlikely(__pyx_t_10 == ((int)-1))) __PYX_ERR(0, 162, __pyx_L4_error)
      __pyx_t_9 = ((!(__pyx_t_10 != 0)) != 0);
      if (__pyx_t_9) {
      } else {
        __pyx_t_1 = __pyx_t_9;
        goto __pyx_L16_bool_binop_done;
      }

      /* "btdht/krcp.pyx":163
 *         if (
 *             not _decode_string(data, i, max, j) and
 *             not  _decode_int(data, i, max, ll) and             # <<<<<<<<<<<<<<
 *             not _decode_pass_list(data, i, max) and
 *             not _decode_pass_dict(data, i, max)
 */
      __pyx_t_8 = __pyx_f_5btdht_4krcp__decode_int(__pyx_v_data, __pyx_v_i, __pyx_v_max, __pyx_v_ll); if (unlikely(__pyx_t_8 == ((long)-1L))) __PYX_ERR(0, 163, __pyx_L4_error)
      __pyx_t_9 = ((!(__pyx_t_8 != 0)) != 0);
      if (__pyx_t_9) {
      } else {
        __pyx_t_1 = __pyx_t_9;
        goto __pyx_L16_bool_binop_done;
      }

      /* "btdht/krcp.pyx":164
 *             not _decode_string(data, i, max, j) and
 *             not  _decode_int(data, i, max, ll) and
 *             not _decode_pass_list(data, i, max) and             # <<<<<<<<<<<<<<
 *             not _decode_pass_dict(data, i, max)
 *         ):
 */
      __pyx_t_10 = __pyx_f_5btdht_4krcp__decode_pass_list(__pyx_v_data, __pyx_v_i, __pyx_v_max); if (unlikely(__pyx_t_10 == ((int)-1))) __PYX_ERR(0, 164, __pyx_L4_error)
      __pyx_t_9 = ((!(__pyx_t_10 != 0)) != 0);
      if (__pyx_t_9) {
      } else {
        __pyx_t_1 = __pyx_t_9;
        goto __pyx_L16_bool_binop_done;
      }

      /* "btdht/krcp.pyx":165
 *             not  _decode_int(data, i, max, ll) and
 *             not _decode_pass_list(data, i, max) and
 *             not _decode_pass_dict(data, i, max)             # <<<<<<<<<<<<<<
 *         ):
 *             with gil:
 */
      __pyx_t_10 = __pyx_f_5btdht_4krcp__decode_pass_dict(__pyx_v_data, __pyx_v_i, __pyx_v_max); if (unlikely(__pyx_t_10 == ((int)-1))) __PYX_ERR(0, 165, __pyx_L4_error)
      __pyx_t_9 = ((!(__pyx_t_10 != 0)) != 0);
      __pyx_t_1 = __pyx_t_9;
      __pyx_L16_bool_binop_done:;

      /* "btdht/krcp.pyx":161
 *     i[0]+=1
 *     while data[i[0]] != b'e' and i[0] < max:
 *         if (             # <<<<<<<<<<<<<<
 *             not _decode_string(data, i, max, j) and
 *             not  _decode_int(data, i, max, ll) and
 */
      if (__pyx_t_1) {

        /* "btdht/krcp.pyx":167
 *             not _decode_pass_dict(data, i, max)
 *         ):
 *             with gil:             # <<<<<<<<<<<<<<
 *                 raise DecodeError(
 *                     "Unable to parse one of the element of the list %d %r" % (i[0], data[:max])
 */
        {
            #ifdef WITH_THREAD
            PyGILState_STATE __pyx_gilstate_save = __Pyx_PyGILState_Ensure();
            #endif
            /*try:*/ {

              /* "btdht/krcp.pyx":168
 *         ):
 *             with gil:
 *                 raise DecodeError(             # <<<<<<<<<<<<<<
 *                     "Unable to parse one of the element of the list %d %r" % (i[0], data[:max])
 *                 )
 */
              __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_DecodeError); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 168, __pyx_L23_error)
              __Pyx_GOTREF(__pyx_t_3);

              /* "btdht/krcp.pyx":169
 *             with gil:
 *                 raise DecodeError(
 *                     "Unable to parse one of the element of the list %d %r" % (i[0], data[:max])             # <<<<<<<<<<<<<<
 *                 )
 *     if i[0] >= max:
 */
              __pyx_t_6 = __Pyx_PyInt_From_int((__pyx_v_i[0])); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 169, __pyx_L23_error)
              __Pyx_GOTREF(__pyx_t_6);
              __pyx_t_7 = __Pyx_PyBytes_FromStringAndSize(__pyx_v_data + 0, __pyx_v_max - 0); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 169, __pyx_L23_error)
              __Pyx_GOTREF(__pyx_t_7);
              __pyx_t_5 = PyTuple_New(2); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 169, __pyx_L23_error)
              __Pyx_GOTREF(__pyx_t_5);
              __Pyx_GIVEREF(__pyx_t_6);
              PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_6);
              __Pyx_GIVEREF(__pyx_t_7);
              PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_t_7);
              __pyx_t_6 = 0;
              __pyx_t_7 = 0;
              __pyx_t_7 = __Pyx_PyString_Format(__pyx_kp_s_Unable_to_parse_one_of_the_eleme, __pyx_t_5); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 169, __pyx_L23_error)
              __Pyx_GOTREF(__pyx_t_7);
              __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
              __pyx_t_5 = NULL;
              if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
                __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_3);
                if (likely(__pyx_t_5)) {
                  PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
                  __Pyx_INCREF(__pyx_t_5);
                  __Pyx_INCREF(function);
                  __Pyx_DECREF_SET(__pyx_t_3, function);
                }
              }
              __pyx_t_2 = (__pyx_t_5) ? __Pyx_PyObject_Call2Args(__pyx_t_3, __pyx_t_5, __pyx_t_7) : __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_7);
              __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
              __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
              if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 168, __pyx_L23_error)
              __Pyx_GOTREF(__pyx_t_2);
              __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
              __Pyx_Raise(__pyx_t_2, 0, 0, 0);
              __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
              __PYX_ERR(0, 168, __pyx_L23_error)
            }

            /* "btdht/krcp.pyx":167
 *             not _decode_pass_dict(data, i, max)
 *         ):
 *             with gil:             # <<<<<<<<<<<<<<
 *                 raise DecodeError(
 *                     "Unable to parse one of the element of the list %d %r" % (i[0], data[:max])
 */
            /*finally:*/ {
              __pyx_L23_error: {
                #ifdef WITH_THREAD
                __Pyx_PyGILState_Release(__pyx_gilstate_save);
                #endif
                goto __pyx_L4_error;
              }
            }
        }

        /* "btdht/krcp.pyx":161
 *     i[0]+=1
 *     while data[i[0]] != b'e' and i[0] < max:
 *         if (             # <<<<<<<<<<<<<<
 *             not _decode_string(data, i, max, j) and
 *             not  _decode_int(data, i, max, ll) and
 */
      }
    }

    /* "btdht/krcp.pyx":171
 *                     "Unable to parse one of the element of the list %d %r" % (i[0], data[:max])
 *                 )
 *     if i[0] >= max:             # <<<<<<<<<<<<<<
 *         with gil:
 *             raise DecodeError("list_pass: %s > %s : %r" % (i[0], max, data[:max]))
 */
    __pyx_t_1 = (((__pyx_v_i[0]) >= __pyx_v_max) != 0);
    if (__pyx_t_1) {

      /* "btdht/krcp.pyx":172
 *                 )
 *     if i[0] >= max:
 *         with gil:             # <<<<<<<<<<<<<<
 *             raise DecodeError("list_pass: %s > %s : %r" % (i[0], max, data[:max]))
 *     if data[i[0]] != b'e':
 */
      {
          #ifdef WITH_THREAD
          PyGILState_STATE __pyx_gilstate_save = __Pyx_PyGILState_Ensure();
          #endif
          /*try:*/ {

            /* "btdht/krcp.pyx":173
 *     if i[0] >= max:
 *         with gil:
 *             raise DecodeError("list_pass: %s > %s : %r" % (i[0], max, data[:max]))             # <<<<<<<<<<<<<<
 *     if data[i[0]] != b'e':
 *         return False
 */
            __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_DecodeError); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 173, __pyx_L27_error)
            __Pyx_GOTREF(__pyx_t_3);
            __pyx_t_7 = __Pyx_PyInt_From_int((__pyx_v_i[0])); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 173, __pyx_L27_error)
            __Pyx_GOTREF(__pyx_t_7);
            __pyx_t_5 = __Pyx_PyInt_From_int(__pyx_v_max); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 173, __pyx_L27_error)
            __Pyx_GOTREF(__pyx_t_5);
            __pyx_t_6 = __Pyx_PyBytes_FromStringAndSize(__pyx_v_data + 0, __pyx_v_max - 0); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 173, __pyx_L27_error)
            __Pyx_GOTREF(__pyx_t_6);
            __pyx_t_4 = PyTuple_New(3); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 173, __pyx_L27_error)
            __Pyx_GOTREF(__pyx_t_4);
            __Pyx_GIVEREF(__pyx_t_7);
            PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_7);
            __Pyx_GIVEREF(__pyx_t_5);
            PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_t_5);
            __Pyx_GIVEREF(__pyx_t_6);
            PyTuple_SET_ITEM(__pyx_t_4, 2, __pyx_t_6);
            __pyx_t_7 = 0;
            __pyx_t_5 = 0;
            __pyx_t_6 = 0;
            __pyx_t_6 = __Pyx_PyString_Format(__pyx_kp_s_list_pass_s_s_r, __pyx_t_4); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 173, __pyx_L27_error)
            __Pyx_GOTREF(__pyx_t_6);
            __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
            __pyx_t_4 = NULL;
            if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
              __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
              if (likely(__pyx_t_4)) {
                PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
                __Pyx_INCREF(__pyx_t_4);
                __Pyx_INCREF(function);
                __Pyx_DECREF_SET(__pyx_t_3, function);
              }
            }
            __pyx_t_2 = (__pyx_t_4) ? __Pyx_PyObject_Call2Args(__pyx_t_3, __pyx_t_4, __pyx_t_6) : __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_6);
            __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
            __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
            if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 173, __pyx_L27_error)
            __Pyx_GOTREF(__pyx_t_2);
            __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
            __Pyx_Raise(__pyx_t_2, 0, 0, 0);
            __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
            __PYX_ERR(0, 173, __pyx_L27_error)
          }

          /* "btdht/krcp.pyx":172
 *                 )
 *     if i[0] >= max:
 *         with gil:             # <<<<<<<<<<<<<<
 *             raise DecodeError("list_pass: %s > %s : %r" % (i[0], max, data[:max]))
 *     if data[i[0]] != b'e':
 */
          /*finally:*/ {
            __pyx_L27_error: {
              #ifdef WITH_THREAD
              __Pyx_PyGILState_Release(__pyx_gilstate_save);
              #endif
              goto __pyx_L4_error;
            }
          }
      }

      /* "btdht/krcp.pyx":171
 *                     "Unable to parse one of the element of the list %d %r" % (i[0], data[:max])
 *                 )
 *     if i[0] >= max:             # <<<<<<<<<<<<<<
 *         with gil:
 *             raise DecodeError("list_pass: %s > %s : %r" % (i[0], max, data[:max]))
 */
    }

    /* "btdht/krcp.pyx":174
 *         with gil:
 *             raise DecodeError("list_pass: %s > %s : %r" % (i[0], max, data[:max]))
 *     if data[i[0]] != b'e':             # <<<<<<<<<<<<<<
 *         return False
 *     i[0]+=1
 */
    __pyx_t_1 = (((__pyx_v_data[(__pyx_v_i[0])]) != 'e') != 0);
    if (__pyx_t_1) {

      /* "btdht/krcp.pyx":175
 *             raise DecodeError("list_pass: %s > %s : %r" % (i[0], max, data[:max]))
 *     if data[i[0]] != b'e':
 *         return False             # <<<<<<<<<<<<<<
 *     i[0]+=1
 *     return True
 */
      __pyx_r = 0;
      goto __pyx_L3_return;

      /* "btdht/krcp.pyx":174
 *         with gil:
 *             raise DecodeError("list_pass: %s > %s : %r" % (i[0], max, data[:max]))
 *     if data[i[0]] != b'e':             # <<<<<<<<<<<<<<
 *         return False
 *     i[0]+=1
 */
    }

    /* "btdht/krcp.pyx":176
 *     if data[i[0]] != b'e':
 *         return False
 *     i[0]+=1             # <<<<<<<<<<<<<<
 *     return True
 * 
 */
    __pyx_t_8 = 0;
    (__pyx_v_i[__pyx_t_8]) = ((__pyx_v_i[__pyx_t_8]) + 1);

    /* "btdht/krcp.pyx":177
 *         return False
 *     i[0]+=1
 *     return True             # <<<<<<<<<<<<<<
 * 
 * cdef int _decode_pass_dict(char* data, int *i, int max) nogil except -1:
 */
    __pyx_r = 1;
    goto __pyx_L3_return;
  }

  /* "btdht/krcp.pyx":138
 * 
 * cdef int _decode_pass_list(char* data, int *i, int max) nogil except -1:
 *     """             # <<<<<<<<<<<<<<
 *         Pass a bencoded list in a bencoded string
 * 
 */
  /*finally:*/ {
    __pyx_L3_return: {
      #ifdef WITH_THREAD
      __pyx_gilstate_save = __Pyx_PyGILState_Ensure();
      #endif
      goto __pyx_L0;
    }
    __pyx_L4_error: {
      #ifdef WITH_THREAD
      __pyx_gilstate_save = __Pyx_PyGILState_Ensure();
      #endif
      goto __pyx_L1_error;
    }
  }

  /* "btdht/krcp.pyx":137
 * 
 * 
 * cdef int _decode_pass_list(char* data, int *i, int max) nogil except -1:             # <<<<<<<<<<<<<<
 *     """
 *         Pass a bencoded list in a bencoded string
 */

  /* function exit code */
  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_AddTraceback("btdht.krcp._decode_pass_list", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  #ifdef WITH_THREAD
  __Pyx_PyGILState_Release(__pyx_gilstate_save);
  #endif
  return __pyx_r;
}

/* "btdht/krcp.pyx":179
 *     return True
 * 
 * cdef int _decode_pass_dict(char* data, int *i, int max) nogil except -1:             # <<<<<<<<<<<<<<
 *     """
 *         Pass a bencoded dict in a bencoded string
 */

static int __pyx_f_5btdht_4krcp__decode_pass_dict(char *__pyx_v_data, int *__pyx_v_i, int __pyx_v_max) {
  int __pyx_v_j[1];
  PY_LONG_LONG __pyx_v_ll[1];
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  PyObject *__pyx_t_7 = NULL;
  long __pyx_t_8;
  int __pyx_t_9;
  int __pyx_t_10;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  #ifdef WITH_THREAD
  PyGILState_STATE __pyx_gilstate_save;
  #endif
  __Pyx_RefNannySetupContext("_decode_pass_dict", 1);

  /* "btdht/krcp.pyx":180
 * 
 * cdef int _decode_pass_dict(char* data, int *i, int max) nogil except -1:
 *     """             # <<<<<<<<<<<<<<
 *         Pass a bencoded dict in a bencoded string
 * 
 */
  /*try:*/ {

    /* "btdht/krcp.pyx":196
 *     cdef int j[1]
 *     cdef long long ll[1]
 *     if i[0] >= max + 1:             # <<<<<<<<<<<<<<
 *         with gil:
 *             raise DecodeError("%s > %s : %r" % (i[0], max, data[:max]))
 */
    __pyx_t_1 = (((__pyx_v_i[0]) >= (__pyx_v_max + 1)) != 0);
    if (__pyx_t_1) {

      /* "btdht/krcp.pyx":197
 *     cdef long long ll[1]
 *     if i[0] >= max + 1:
 *         with gil:             # <<<<<<<<<<<<<<
 *             raise DecodeError("%s > %s : %r" % (i[0], max, data[:max]))
 *     if data[i[0]] != b"d":
 */
      {
          #ifdef WITH_THREAD
          PyGILState_STATE __pyx_gilstate_save = __Pyx_PyGILState_Ensure();
          #endif
          /*try:*/ {

            /* "btdht/krcp.pyx":198
 *     if i[0] >= max + 1:
 *         with gil:
 *             raise DecodeError("%s > %s : %r" % (i[0], max, data[:max]))             # <<<<<<<<<<<<<<
 *     if data[i[0]] != b"d":
 *         return False
 */
            __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_DecodeError); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 198, __pyx_L8_error)
            __Pyx_GOTREF(__pyx_t_3);
            __pyx_t_4 = __Pyx_PyInt_From_int((__pyx_v_i[0])); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 198, __pyx_L8_error)
            __Pyx_GOTREF(__pyx_t_4);
            __pyx_t_5 = __Pyx_PyInt_From_int(__pyx_v_max); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 198, __pyx_L8_error)
            __Pyx_GOTREF(__pyx_t_5);
            __pyx_t_6 = __Pyx_PyBytes_FromStringAndSize(__pyx_v_data + 0, __pyx_v_max - 0); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 198, __pyx_L8_error)
            __Pyx_GOTREF(__pyx_t_6);
            __pyx_t_7 = PyTuple_New(3); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 198, __pyx_L8_error)
            __Pyx_GOTREF(__pyx_t_7);
            __Pyx_GIVEREF(__pyx_t_4);
            PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_4);
            __Pyx_GIVEREF(__pyx_t_5);
            PyTuple_SET_ITEM(__pyx_t_7, 1, __pyx_t_5);
            __Pyx_GIVEREF(__pyx_t_6);
            PyTuple_SET_ITEM(__pyx_t_7, 2, __pyx_t_6);
            __pyx_t_4 = 0;
            __pyx_t_5 = 0;
            __pyx_t_6 = 0;
            __pyx_t_6 = __Pyx_PyString_Format(__pyx_kp_s_s_s_r, __pyx_t_7); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 198, __pyx_L8_error)
            __Pyx_GOTREF(__pyx_t_6);
            __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
            __pyx_t_7 = NULL;
            if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
              __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_3);
              if (likely(__pyx_t_7)) {
                PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
                __Pyx_INCREF(__pyx_t_7);
                __Pyx_INCREF(function);
                __Pyx_DECREF_SET(__pyx_t_3, function);
              }
            }
            __pyx_t_2 = (__pyx_t_7) ? __Pyx_PyObject_Call2Args(__pyx_t_3, __pyx_t_7, __pyx_t_6) : __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_6);
            __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
            __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
            if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 198, __pyx_L8_error)
            __Pyx_GOTREF(__pyx_t_2);
            __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
            __Pyx_Raise(__pyx_t_2, 0, 0, 0);
            __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
            __PYX_ERR(0, 198, __pyx_L8_error)
          }

          /* "btdht/krcp.pyx":197
 *     cdef long long ll[1]
 *     if i[0] >= max + 1:
 *         with gil:             # <<<<<<<<<<<<<<
 *             raise DecodeError("%s > %s : %r" % (i[0], max, data[:max]))
 *     if data[i[0]] != b"d":
 */
          /*finally:*/ {
            __pyx_L8_error: {
              #ifdef WITH_THREAD
              __Pyx_PyGILState_Release(__pyx_gilstate_save);
              #endif
              goto __pyx_L4_error;
            }
          }
      }

      /* "btdht/krcp.pyx":196
 *     cdef int j[1]
 *     cdef long long ll[1]
 *     if i[0] >= max + 1:             # <<<<<<<<<<<<<<
 *         with gil:
 *             raise DecodeError("%s > %s : %r" % (i[0], max, data[:max]))
 */
    }

    /* "btdht/krcp.pyx":199
 *         with gil:
 *             raise DecodeError("%s > %s : %r" % (i[0], max, data[:max]))
 *     if data[i[0]] != b"d":             # <<<<<<<<<<<<<<
 *         return False
 *     i[0]+=1
 */
    __pyx_t_1 = (((__pyx_v_data[(__pyx_v_i[0])]) != 'd') != 0);
    if (__pyx_t_1) {

      /* "btdht/krcp.pyx":200
 *             raise DecodeError("%s > %s : %r" % (i[0], max, data[:max]))
 *     if data[i[0]] != b"d":
 *         return False             # <<<<<<<<<<<<<<
 *     i[0]+=1
 *     while data[i[0]] != b'e' and i[0] < max:
 */
      __pyx_r = 0;
      goto __pyx_L3_return;

      /* "btdht/krcp.pyx":199
 *         with gil:
 *             raise DecodeError("%s > %s : %r" % (i[0], max, data[:max]))
 *     if data[i[0]] != b"d":             # <<<<<<<<<<<<<<
 *         return False
 *     i[0]+=1
 */
    }

    /* "btdht/krcp.pyx":201
 *     if data[i[0]] != b"d":
 *         return False
 *     i[0]+=1             # <<<<<<<<<<<<<<
 *     while data[i[0]] != b'e' and i[0] < max:
 *         if (
 */
    __pyx_t_8 = 0;
    (__pyx_v_i[__pyx_t_8]) = ((__pyx_v_i[__pyx_t_8]) + 1);

    /* "btdht/krcp.pyx":202
 *         return False
 *     i[0]+=1
 *     while data[i[0]] != b'e' and i[0] < max:             # <<<<<<<<<<<<<<
 *         if (
 *             not _decode_string(data, i, max, j) or
 */
    while (1) {
      __pyx_t_9 = (((__pyx_v_data[(__pyx_v_i[0])]) != 'e') != 0);
      if (__pyx_t_9) {
      } else {
        __pyx_t_1 = __pyx_t_9;
        goto __pyx_L13_bool_binop_done;
      }
      __pyx_t_9 = (((__pyx_v_i[0]) < __pyx_v_max) != 0);
      __pyx_t_1 = __pyx_t_9;
      __pyx_L13_bool_binop_done:;
      if (!__pyx_t_1) break;

      /* "btdht/krcp.pyx":204
 *     while data[i[0]] != b'e' and i[0] < max:
 *         if (
 *             not _decode_string(data, i, max, j) or             # <<<<<<<<<<<<<<
 *             (
 *                 not _decode_string(data, i, max, j) and
 */
      __pyx_t_10 = __pyx_f_5btdht_4krcp__decode_string(__pyx_v_data, __pyx_v_i, __pyx_v_max, __pyx_v_j); if (unlikely(__pyx_t_10 == ((int)-1))) __PYX_ERR(0, 204, __pyx_L4_error)
      __pyx_t_9 = ((!(__pyx_t_10 != 0)) != 0);
      if (!__pyx_t_9) {
      } else {
        __pyx_t_1 = __pyx_t_9;
        goto __pyx_L16_bool_binop_done;
      }

      /* "btdht/krcp.pyx":206
 *             not _decode_string(data, i, max, j) or
 *             (
 *                 not _decode_string(data, i, max, j) and             # <<<<<<<<<<<<<<
 *                 not _decode_int(data, i, max, ll) and
 *                 not _decode_pass_list(data, i, max) and
 */
      __pyx_t_10 = __pyx_f_5btdht_4krcp__decode_string(__pyx_v_data, __pyx_v_i, __pyx_v_max, __pyx_v_j); if (unlikely(__pyx_t_10 == ((int)-1))) __PYX_ERR(0, 206, __pyx_L4_error)
      __pyx_t_9 = ((!(__pyx_t_10 != 0)) != 0);
      if (__pyx_t_9) {
      } else {
        __pyx_t_1 = __pyx_t_9;
        goto __pyx_L16_bool_binop_done;
      }

      /* "btdht/krcp.pyx":207
 *             (
 *                 not _decode_string(data, i, max, j) and
 *                 not _decode_int(data, i, max, ll) and             # <<<<<<<<<<<<<<
 *                 not _decode_pass_list(data, i, max) and
 *                 not _decode_pass_dict(data, i, max)
 */
      __pyx_t_8 = __pyx_f_5btdht_4krcp__decode_int(__pyx_v_data, __pyx_v_i, __pyx_v_max, __pyx_v_ll); if (unlikely(__pyx_t_8 == ((long)-1L))) __PYX_ERR(0, 207, __pyx_L4_error)
      __pyx_t_9 = ((!(__pyx_t_8 != 0)) != 0);
      if (__pyx_t_9) {
      } else {
        __pyx_t_1 = __pyx_t_9;
        goto __pyx_L16_bool_binop_done;
      }

      /* "btdht/krcp.pyx":208
 *                 not _decode_string(data, i, max, j) and
 *                 not _decode_int(data, i, max, ll) and
 *                 not _decode_pass_list(data, i, max) and             # <<<<<<<<<<<<<<
 *                 not _decode_pass_dict(data, i, max)
 *             )
 */
      __pyx_t_10 = __pyx_f_5btdht_4krcp__decode_pass_list(__pyx_v_data, __pyx_v_i, __pyx_v_max); if (unlikely(__pyx_t_10 == ((int)-1))) __PYX_ERR(0, 208, __pyx_L4_error)
      __pyx_t_9 = ((!(__pyx_t_10 != 0)) != 0);
      if (__pyx_t_9) {
      } else {
        __pyx_t_1 = __pyx_t_9;
        goto __pyx_L16_bool_binop_done;
      }

      /* "btdht/krcp.pyx":209
 *                 not _decode_int(data, i, max, ll) and
 *                 not _decode_pass_list(data, i, max) and
 *                 not _decode_pass_dict(data, i, max)             # <<<<<<<<<<<<<<
 *             )
 *         ):
 */
      __pyx_t_10 = __pyx_f_5btdht_4krcp__decode_pass_dict(__pyx_v_data, __pyx_v_i, __pyx_v_max); if (unlikely(__pyx_t_10 == ((int)-1))) __PYX_ERR(0, 209, __pyx_L4_error)
      __pyx_t_9 = ((!(__pyx_t_10 != 0)) != 0);
      __pyx_t_1 = __pyx_t_9;
      __pyx_L16_bool_binop_done:;

      /* "btdht/krcp.pyx":203
 *     i[0]+=1
 *     while data[i[0]] != b'e' and i[0] < max:
 *         if (             # <<<<<<<<<<<<<<
 *             not _decode_string(data, i, max, j) or
 *             (
 */
      if (__pyx_t_1) {

        /* "btdht/krcp.pyx":212
 *             )
 *         ):
 *             with gil:             # <<<<<<<<<<<<<<
 *                 raise DecodeError(
 *                     "Unable to parse one of the element of the dict %d %r" % (i[0], data[:max])
 */
        {
            #ifdef WITH_THREAD
            PyGILState_STATE __pyx_gilstate_save = __Pyx_PyGILState_Ensure();
            #endif
            /*try:*/ {

              /* "btdht/krcp.pyx":213
 *         ):
 *             with gil:
 *                 raise DecodeError(             # <<<<<<<<<<<<<<
 *                     "Unable to parse one of the element of the dict %d %r" % (i[0], data[:max])
 *                 )
 */
              __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_DecodeError); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 213, __pyx_L24_error)
              __Pyx_GOTREF(__pyx_t_3);

              /* "btdht/krcp.pyx":214
 *             with gil:
 *                 raise DecodeError(
 *                     "Unable to parse one of the element of the dict %d %r" % (i[0], data[:max])             # <<<<<<<<<<<<<<
 *                 )
 *     if i[0] >= max:
 */
              __pyx_t_6 = __Pyx_PyInt_From_int((__pyx_v_i[0])); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 214, __pyx_L24_error)
              __Pyx_GOTREF(__pyx_t_6);
              __pyx_t_7 = __Pyx_PyBytes_FromStringAndSize(__pyx_v_data + 0, __pyx_v_max - 0); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 214, __pyx_L24_error)
              __Pyx_GOTREF(__pyx_t_7);
              __pyx_t_5 = PyTuple_New(2); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 214, __pyx_L24_error)
              __Pyx_GOTREF(__pyx_t_5);
              __Pyx_GIVEREF(__pyx_t_6);
              PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_6);
              __Pyx_GIVEREF(__pyx_t_7);
              PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_t_7);
              __pyx_t_6 = 0;
              __pyx_t_7 = 0;
              __pyx_t_7 = __Pyx_PyString_Format(__pyx_kp_s_Unable_to_parse_one_of_the_eleme_2, __pyx_t_5); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 214, __pyx_L24_error)
              __Pyx_GOTREF(__pyx_t_7);
              __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
              __pyx_t_5 = NULL;
              if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
                __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_3);
                if (likely(__pyx_t_5)) {
                  PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
                  __Pyx_INCREF(__pyx_t_5);
                  __Pyx_INCREF(function);
                  __Pyx_DECREF_SET(__pyx_t_3, function);
                }
              }
              __pyx_t_2 = (__pyx_t_5) ? __Pyx_PyObject_Call2Args(__pyx_t_3, __pyx_t_5, __pyx_t_7) : __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_7);
              __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
              __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
              if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 213, __pyx_L24_error)
              __Pyx_GOTREF(__pyx_t_2);
              __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
              __Pyx_Raise(__pyx_t_2, 0, 0, 0);
              __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
              __PYX_ERR(0, 213, __pyx_L24_error)
            }

            /* "btdht/krcp.pyx":212
 *             )
 *         ):
 *             with gil:             # <<<<<<<<<<<<<<
 *                 raise DecodeError(
 *                     "Unable to parse one of the element of the dict %d %r" % (i[0], data[:max])
 */
            /*finally:*/ {
              __pyx_L24_error: {
                #ifdef WITH_THREAD
                __Pyx_PyGILState_Release(__pyx_gilstate_save);
                #endif
                goto __pyx_L4_error;
              }
            }
        }

        /* "btdht/krcp.pyx":203
 *     i[0]+=1
 *     while data[i[0]] != b'e' and i[0] < max:
 *         if (             # <<<<<<<<<<<<<<
 *             not _decode_string(data, i, max, j) or
 *             (
 */
      }
    }

    /* "btdht/krcp.pyx":216
 *                     "Unable to parse one of the element of the dict %d %r" % (i[0], data[:max])
 *                 )
 *     if i[0] >= max:             # <<<<<<<<<<<<<<
 *         with gil:
 *             raise DecodeError("dict_pass: %s > %s : %r" % (i[0], max, data[:max]))
 */
    __pyx_t_1 = (((__pyx_v_i[0]) >= __pyx_v_max) != 0);
    if (__pyx_t_1) {

      /* "btdht/krcp.pyx":217
 *                 )
 *     if i[0] >= max:
 *         with gil:             # <<<<<<<<<<<<<<
 *             raise DecodeError("dict_pass: %s > %s : %r" % (i[0], max, data[:max]))
 *     if data[i[0]] != b'e':
 */
      {
          #ifdef WITH_THREAD
          PyGILState_STATE __pyx_gilstate_save = __Pyx_PyGILState_Ensure();
          #endif
          /*try:*/ {

            /* "btdht/krcp.pyx":218
 *     if i[0] >= max:
 *         with gil:
 *             raise DecodeError("dict_pass: %s > %s : %r" % (i[0], max, data[:max]))             # <<<<<<<<<<<<<<
 *     if data[i[0]] != b'e':
 *         return False
 */
            __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_DecodeError); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 218, __pyx_L28_error)
            __Pyx_GOTREF(__pyx_t_3);
            __pyx_t_7 = __Pyx_PyInt_From_int((__pyx_v_i[0])); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 218, __pyx_L28_error)
            __Pyx_GOTREF(__pyx_t_7);
            __pyx_t_5 = __Pyx_PyInt_From_int(__pyx_v_max); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 218, __pyx_L28_error)
            __Pyx_GOTREF(__pyx_t_5);
            __pyx_t_6 = __Pyx_PyBytes_FromStringAndSize(__pyx_v_data + 0, __pyx_v_max - 0); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 218, __pyx_L28_error)
            __Pyx_GOTREF(__pyx_t_6);
            __pyx_t_4 = PyTuple_New(3); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 218, __pyx_L28_error)
            __Pyx_GOTREF(__pyx_t_4);
            __Pyx_GIVEREF(__pyx_t_7);
            PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_7);
            __Pyx_GIVEREF(__pyx_t_5);
            PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_t_5);
            __Pyx_GIVEREF(__pyx_t_6);
            PyTuple_SET_ITEM(__pyx_t_4, 2, __pyx_t_6);
            __pyx_t_7 = 0;
            __pyx_t_5 = 0;
            __pyx_t_6 = 0;
            __pyx_t_6 = __Pyx_PyString_Format(__pyx_kp_s_dict_pass_s_s_r, __pyx_t_4); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 218, __pyx_L28_error)
            __Pyx_GOTREF(__pyx_t_6);
            __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
            __pyx_t_4 = NULL;
            if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
              __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
              if (likely(__pyx_t_4)) {
                PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
                __Pyx_INCREF(__pyx_t_4);
                __Pyx_INCREF(function);
                __Pyx_DECREF_SET(__pyx_t_3, function);
              }
            }
            __pyx_t_2 = (__pyx_t_4) ? __Pyx_PyObject_Call2Args(__pyx_t_3, __pyx_t_4, __pyx_t_6) : __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_6);
            __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
            __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
            if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 218, __pyx_L28_error)
            __Pyx_GOTREF(__pyx_t_2);
            __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
            __Pyx_Raise(__pyx_t_2, 0, 0, 0);
            __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
            __PYX_ERR(0, 218, __pyx_L28_error)
          }

          /* "btdht/krcp.pyx":217
 *                 )
 *     if i[0] >= max:
 *         with gil:             # <<<<<<<<<<<<<<
 *             raise DecodeError("dict_pass: %s > %s : %r" % (i[0], max, data[:max]))
 *     if data[i[0]] != b'e':
 */
          /*finally:*/ {
            __pyx_L28_error: {
              #ifdef WITH_THREAD
              __Pyx_PyGILState_Release(__pyx_gilstate_save);
              #endif
              goto __pyx_L4_error;
            }
          }
      }

      /* "btdht/krcp.pyx":216
 *                     "Unable to parse one of the element of the dict %d %r" % (i[0], data[:max])
 *                 )
 *     if i[0] >= max:             # <<<<<<<<<<<<<<
 *         with gil:
 *             raise DecodeError("dict_pass: %s > %s : %r" % (i[0], max, data[:max]))
 */
    }

    /* "btdht/krcp.pyx":219
 *         with gil:
 *             raise DecodeError("dict_pass: %s > %s : %r" % (i[0], max, data[:max]))
 *     if data[i[0]] != b'e':             # <<<<<<<<<<<<<<
 *         return False
 *     i[0]+=1
 */
    __pyx_t_1 = (((__pyx_v_data[(__pyx_v_i[0])]) != 'e') != 0);
    if (__pyx_t_1) {

      /* "btdht/krcp.pyx":220
 *             raise DecodeError("dict_pass: %s > %s : %r" % (i[0], max, data[:max]))
 *     if data[i[0]] != b'e':
 *         return False             # <<<<<<<<<<<<<<
 *     i[0]+=1
 *     return True
 */
      __pyx_r = 0;
      goto __pyx_L3_return;

      /* "btdht/krcp.pyx":219
 *         with gil:
 *             raise DecodeError("dict_pass: %s > %s : %r" % (i[0], max, data[:max]))
 *     if data[i[0]] != b'e':             # <<<<<<<<<<<<<<
 *         return False
 *     i[0]+=1
 */
    }

    /* "btdht/krcp.pyx":221
 *     if data[i[0]] != b'e':
 *         return False
 *     i[0]+=1             # <<<<<<<<<<<<<<
 *     return True
 * 
 */
    __pyx_t_8 = 0;
    (__pyx_v_i[__pyx_t_8]) = ((__pyx_v_i[__pyx_t_8]) + 1);

    /* "btdht/krcp.pyx":222
 *         return False
 *     i[0]+=1
 *     return True             # <<<<<<<<<<<<<<
 * 
 * cdef int _decode_string(char* data, int* i, int max, int* j) nogil except -1:
 */
    __pyx_r = 1;
    goto __pyx_L3_return;
  }

  /* "btdht/krcp.pyx":180
 * 
 * cdef int _decode_pass_dict(char* data, int *i, int max) nogil except -1:
 *     """             # <<<<<<<<<<<<<<
 *         Pass a bencoded dict in a bencoded string
 * 
 */
  /*finally:*/ {
    __pyx_L3_return: {
      #ifdef WITH_THREAD
      __pyx_gilstate_save = __Pyx_PyGILState_Ensure();
      #endif
      goto __pyx_L0;
    }
    __pyx_L4_error: {
      #ifdef WITH_THREAD
      __pyx_gilstate_save = __Pyx_PyGILState_Ensure();
      #endif
      goto __pyx_L1_error;
    }
  }

  /* "btdht/krcp.pyx":179
 *     return True
 * 
 * cdef int _decode_pass_dict(char* data, int *i, int max) nogil except -1:             # <<<<<<<<<<<<<<
 *     """
 *         Pass a bencoded dict in a bencoded string
 */

  /* function exit code */
  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_AddTraceback("btdht.krcp._decode_pass_dict", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  #ifdef WITH_THREAD
  __Pyx_PyGILState_Release(__pyx_gilstate_save);
  #endif
  return __pyx_r;
}

/* "btdht/krcp.pyx":224
 *     return True
 * 
 * cdef int _decode_string(char* data, int* i, int max, int* j) nogil except -1:             # <<<<<<<<<<<<<<
 *     """
 *         Pass a bencoded string in a bencoded string
 */

static int __pyx_f_5btdht_4krcp__decode_string(char *__pyx_v_data, int *__pyx_v_i, int __pyx_v_max, int *__pyx_v_j) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  int __pyx_t_2;
  long __pyx_t_3;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  PyObject *__pyx_t_7 = NULL;
  PyObject *__pyx_t_8 = NULL;
  PyObject *__pyx_t_9 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  #ifdef WITH_THREAD
  PyGILState_STATE __pyx_gilstate_save;
  #endif
  __Pyx_RefNannySetupContext("_decode_string", 1);

  /* "btdht/krcp.pyx":225
 * 
 * cdef int _decode_string(char* data, int* i, int max, int* j) nogil except -1:
 *     """             # <<<<<<<<<<<<<<
 *         Pass a bencoded string in a bencoded string
 * 
 */
  /*try:*/ {

    /* "btdht/krcp.pyx":240
 *     """
 *     cdef int ret
 *     if data[i[0]] == b'0' \             # <<<<<<<<<<<<<<
 *     or data[i[0]] == b'2' \
 *     or data[i[0]] == b'3' \
 */
    __pyx_t_2 = (((__pyx_v_data[(__pyx_v_i[0])]) == '0') != 0);
    if (!__pyx_t_2) {
    } else {
      __pyx_t_1 = __pyx_t_2;
      goto __pyx_L7_bool_binop_done;
    }

    /* "btdht/krcp.pyx":241
 *     cdef int ret
 *     if data[i[0]] == b'0' \
 *     or data[i[0]] == b'2' \             # <<<<<<<<<<<<<<
 *     or data[i[0]] == b'3' \
 *     or data[i[0]] == b'4' \
 */
    __pyx_t_2 = (((__pyx_v_data[(__pyx_v_i[0])]) == '2') != 0);
    if (!__pyx_t_2) {
    } else {
      __pyx_t_1 = __pyx_t_2;
      goto __pyx_L7_bool_binop_done;
    }

    /* "btdht/krcp.pyx":242
 *     if data[i[0]] == b'0' \
 *     or data[i[0]] == b'2' \
 *     or data[i[0]] == b'3' \             # <<<<<<<<<<<<<<
 *     or data[i[0]] == b'4' \
 *     or data[i[0]] == b'5' \
 */
    __pyx_t_2 = (((__pyx_v_data[(__pyx_v_i[0])]) == '3') != 0);
    if (!__pyx_t_2) {
    } else {
      __pyx_t_1 = __pyx_t_2;
      goto __pyx_L7_bool_binop_done;
    }

    /* "btdht/krcp.pyx":243
 *     or data[i[0]] == b'2' \
 *     or data[i[0]] == b'3' \
 *     or data[i[0]] == b'4' \             # <<<<<<<<<<<<<<
 *     or data[i[0]] == b'5' \
 *     or data[i[0]] == b'6' \
 */
    __pyx_t_2 = (((__pyx_v_data[(__pyx_v_i[0])]) == '4') != 0);
    if (!__pyx_t_2) {
    } else {
      __pyx_t_1 = __pyx_t_2;
      goto __pyx_L7_bool_binop_done;
    }

    /* "btdht/krcp.pyx":244
 *     or data[i[0]] == b'3' \
 *     or data[i[0]] == b'4' \
 *     or data[i[0]] == b'5' \             # <<<<<<<<<<<<<<
 *     or data[i[0]] == b'6' \
 *     or data[i[0]] == b'7' \
 */
    __pyx_t_2 = (((__pyx_v_data[(__pyx_v_i[0])]) == '5') != 0);
    if (!__pyx_t_2) {
    } else {
      __pyx_t_1 = __pyx_t_2;
      goto __pyx_L7_bool_binop_done;
    }

    /* "btdht/krcp.pyx":245
 *     or data[i[0]] == b'4' \
 *     or data[i[0]] == b'5' \
 *     or data[i[0]] == b'6' \             # <<<<<<<<<<<<<<
 *     or data[i[0]] == b'7' \
 *     or data[i[0]] == b'8' \
 */
    __pyx_t_2 = (((__pyx_v_data[(__pyx_v_i[0])]) == '6') != 0);
    if (!__pyx_t_2) {
    } else {
      __pyx_t_1 = __pyx_t_2;
      goto __pyx_L7_bool_binop_done;
    }

    /* "btdht/krcp.pyx":246
 *     or data[i[0]] == b'5' \
 *     or data[i[0]] == b'6' \
 *     or data[i[0]] == b'7' \             # <<<<<<<<<<<<<<
 *     or data[i[0]] == b'8' \
 *     or data[i[0]] == b'9' \
 */
    __pyx_t_2 = (((__pyx_v_data[(__pyx_v_i[0])]) == '7') != 0);
    if (!__pyx_t_2) {
    } else {
      __pyx_t_1 = __pyx_t_2;
      goto __pyx_L7_bool_binop_done;
    }

    /* "btdht/krcp.pyx":247
 *     or data[i[0]] == b'6' \
 *     or data[i[0]] == b'7' \
 *     or data[i[0]] == b'8' \             # <<<<<<<<<<<<<<
 *     or data[i[0]] == b'9' \
 *     or data[i[0]] == b'1':
 */
    __pyx_t_2 = (((__pyx_v_data[(__pyx_v_i[0])]) == '8') != 0);
    if (!__pyx_t_2) {
    } else {
      __pyx_t_1 = __pyx_t_2;
      goto __pyx_L7_bool_binop_done;
    }

    /* "btdht/krcp.pyx":248
 *     or data[i[0]] == b'7' \
 *     or data[i[0]] == b'8' \
 *     or data[i[0]] == b'9' \             # <<<<<<<<<<<<<<
 *     or data[i[0]] == b'1':
 *         j[0]=i[0]+1
 */
    __pyx_t_2 = (((__pyx_v_data[(__pyx_v_i[0])]) == '9') != 0);
    if (!__pyx_t_2) {
    } else {
      __pyx_t_1 = __pyx_t_2;
      goto __pyx_L7_bool_binop_done;
    }

    /* "btdht/krcp.pyx":249
 *     or data[i[0]] == b'8' \
 *     or data[i[0]] == b'9' \
 *     or data[i[0]] == b'1':             # <<<<<<<<<<<<<<
 *         j[0]=i[0]+1
 *         while data[j[0]] != b':' and j[0] < max:
 */
    __pyx_t_2 = (((__pyx_v_data[(__pyx_v_i[0])]) == '1') != 0);
    __pyx_t_1 = __pyx_t_2;
    __pyx_L7_bool_binop_done:;

    /* "btdht/krcp.pyx":240
 *     """
 *     cdef int ret
 *     if data[i[0]] == b'0' \             # <<<<<<<<<<<<<<
 *     or data[i[0]] == b'2' \
 *     or data[i[0]] == b'3' \
 */
    if (__pyx_t_1) {

      /* "btdht/krcp.pyx":250
 *     or data[i[0]] == b'9' \
 *     or data[i[0]] == b'1':
 *         j[0]=i[0]+1             # <<<<<<<<<<<<<<
 *         while data[j[0]] != b':' and j[0] < max:
 *             j[0]+=1
 */
      (__pyx_v_j[0]) = ((__pyx_v_i[0]) + 1);

      /* "btdht/krcp.pyx":251
 *     or data[i[0]] == b'1':
 *         j[0]=i[0]+1
 *         while data[j[0]] != b':' and j[0] < max:             # <<<<<<<<<<<<<<
 *             j[0]+=1
 *         if data[j[0]] == b':':
 */
      while (1) {
        __pyx_t_2 = (((__pyx_v_data[(__pyx_v_j[0])]) != ':') != 0);
        if (__pyx_t_2) {
        } else {
          __pyx_t_1 = __pyx_t_2;
          goto __pyx_L19_bool_binop_done;
        }
        __pyx_t_2 = (((__pyx_v_j[0]) < __pyx_v_max) != 0);
        __pyx_t_1 = __pyx_t_2;
        __pyx_L19_bool_binop_done:;
        if (!__pyx_t_1) break;

        /* "btdht/krcp.pyx":252
 *         j[0]=i[0]+1
 *         while data[j[0]] != b':' and j[0] < max:
 *             j[0]+=1             # <<<<<<<<<<<<<<
 *         if data[j[0]] == b':':
 *             i[0] = j[0] + str_to_int(data + i[0], j[0]-i[0]) + 1
 */
        __pyx_t_3 = 0;
        (__pyx_v_j[__pyx_t_3]) = ((__pyx_v_j[__pyx_t_3]) + 1);
      }

      /* "btdht/krcp.pyx":253
 *         while data[j[0]] != b':' and j[0] < max:
 *             j[0]+=1
 *         if data[j[0]] == b':':             # <<<<<<<<<<<<<<
 *             i[0] = j[0] + str_to_int(data + i[0], j[0]-i[0]) + 1
 *             j[0]+=1
 */
      __pyx_t_1 = (((__pyx_v_data[(__pyx_v_j[0])]) == ':') != 0);
      if (__pyx_t_1) {

        /* "btdht/krcp.pyx":254
 *             j[0]+=1
 *         if data[j[0]] == b':':
 *             i[0] = j[0] + str_to_int(data + i[0], j[0]-i[0]) + 1             # <<<<<<<<<<<<<<
 *             j[0]+=1
 *             if i[0] <= max:
 */
        (__pyx_v_i[0]) = (((__pyx_v_j[0]) + __pyx_f_5btdht_4krcp_str_to_int((__pyx_v_data + (__pyx_v_i[0])), ((__pyx_v_j[0]) - (__pyx_v_i[0])))) + 1);

        /* "btdht/krcp.pyx":255
 *         if data[j[0]] == b':':
 *             i[0] = j[0] + str_to_int(data + i[0], j[0]-i[0]) + 1
 *             j[0]+=1             # <<<<<<<<<<<<<<
 *             if i[0] <= max:
 *                 return True
 */
        __pyx_t_3 = 0;
        (__pyx_v_j[__pyx_t_3]) = ((__pyx_v_j[__pyx_t_3]) + 1);

        /* "btdht/krcp.pyx":256
 *             i[0] = j[0] + str_to_int(data + i[0], j[0]-i[0]) + 1
 *             j[0]+=1
 *             if i[0] <= max:             # <<<<<<<<<<<<<<
 *                 return True
 *             else:
 */
        __pyx_t_1 = (((__pyx_v_i[0]) <= __pyx_v_max) != 0);
        if (__pyx_t_1) {

          /* "btdht/krcp.pyx":257
 *             j[0]+=1
 *             if i[0] <= max:
 *                 return True             # <<<<<<<<<<<<<<
 *             else:
 *                 with gil:
 */
          __pyx_r = 1;
          goto __pyx_L3_return;

          /* "btdht/krcp.pyx":256
 *             i[0] = j[0] + str_to_int(data + i[0], j[0]-i[0]) + 1
 *             j[0]+=1
 *             if i[0] <= max:             # <<<<<<<<<<<<<<
 *                 return True
 *             else:
 */
        }

        /* "btdht/krcp.pyx":259
 *                 return True
 *             else:
 *                 with gil:             # <<<<<<<<<<<<<<
 *                      raise DecodeError("%s > %s : %r" % (i[0], max, data[:max]))
 *         else:
 */
        /*else*/ {
          {
              #ifdef WITH_THREAD
              PyGILState_STATE __pyx_gilstate_save = __Pyx_PyGILState_Ensure();
              #endif
              /*try:*/ {

                /* "btdht/krcp.pyx":260
 *             else:
 *                 with gil:
 *                      raise DecodeError("%s > %s : %r" % (i[0], max, data[:max]))             # <<<<<<<<<<<<<<
 *         else:
 *             with gil:
 */
                __Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_n_s_DecodeError); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 260, __pyx_L24_error)
                __Pyx_GOTREF(__pyx_t_5);
                __pyx_t_6 = __Pyx_PyInt_From_int((__pyx_v_i[0])); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 260, __pyx_L24_error)
                __Pyx_GOTREF(__pyx_t_6);
                __pyx_t_7 = __Pyx_PyInt_From_int(__pyx_v_max); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 260, __pyx_L24_error)
                __Pyx_GOTREF(__pyx_t_7);
                __pyx_t_8 = __Pyx_PyBytes_FromStringAndSize(__pyx_v_data + 0, __pyx_v_max - 0); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 260, __pyx_L24_error)
                __Pyx_GOTREF(__pyx_t_8);
                __pyx_t_9 = PyTuple_New(3); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 260, __pyx_L24_error)
                __Pyx_GOTREF(__pyx_t_9);
                __Pyx_GIVEREF(__pyx_t_6);
                PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_t_6);
                __Pyx_GIVEREF(__pyx_t_7);
                PyTuple_SET_ITEM(__pyx_t_9, 1, __pyx_t_7);
                __Pyx_GIVEREF(__pyx_t_8);
                PyTuple_SET_ITEM(__pyx_t_9, 2, __pyx_t_8);
                __pyx_t_6 = 0;
                __pyx_t_7 = 0;
                __pyx_t_8 = 0;
                __pyx_t_8 = __Pyx_PyString_Format(__pyx_kp_s_s_s_r, __pyx_t_9); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 260, __pyx_L24_error)
                __Pyx_GOTREF(__pyx_t_8);
                __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
                __pyx_t_9 = NULL;
                if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_5))) {
                  __pyx_t_9 = PyMethod_GET_SELF(__pyx_t_5);
                  if (likely(__pyx_t_9)) {
                    PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5);
                    __Pyx_INCREF(__pyx_t_9);
                    __Pyx_INCREF(function);
                    __Pyx_DECREF_SET(__pyx_t_5, function);
                  }
                }
                __pyx_t_4 = (__pyx_t_9) ? __Pyx_PyObject_Call2Args(__pyx_t_5, __pyx_t_9, __pyx_t_8) : __Pyx_PyObject_CallOneArg(__pyx_t_5, __pyx_t_8);
                __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
                __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
                if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 260, __pyx_L24_error)
                __Pyx_GOTREF(__pyx_t_4);
                __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
                __Pyx_Raise(__pyx_t_4, 0, 0, 0);
                __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
                __PYX_ERR(0, 260, __pyx_L24_error)
              }

              /* "btdht/krcp.pyx":259
 *                 return True
 *             else:
 *                 with gil:             # <<<<<<<<<<<<<<
 *                      raise DecodeError("%s > %s : %r" % (i[0], max, data[:max]))
 *         else:
 */
              /*finally:*/ {
                __pyx_L24_error: {
                  #ifdef WITH_THREAD
                  __Pyx_PyGILState_Release(__pyx_gilstate_save);
                  #endif
                  goto __pyx_L4_error;
                }
              }
          }
        }

        /* "btdht/krcp.pyx":253
 *         while data[j[0]] != b':' and j[0] < max:
 *             j[0]+=1
 *         if data[j[0]] == b':':             # <<<<<<<<<<<<<<
 *             i[0] = j[0] + str_to_int(data + i[0], j[0]-i[0]) + 1
 *             j[0]+=1
 */
      }

      /* "btdht/krcp.pyx":262
 *                      raise DecodeError("%s > %s : %r" % (i[0], max, data[:max]))
 *         else:
 *             with gil:             # <<<<<<<<<<<<<<
 *                 raise DecodeError("%s != : at %s %r" % (data[j[0]], j[0], data[:max]))
 *     else:
 */
      /*else*/ {
        {
            #ifdef WITH_THREAD
            PyGILState_STATE __pyx_gilstate_save = __Pyx_PyGILState_Ensure();
            #endif
            /*try:*/ {

              /* "btdht/krcp.pyx":263
 *         else:
 *             with gil:
 *                 raise DecodeError("%s != : at %s %r" % (data[j[0]], j[0], data[:max]))             # <<<<<<<<<<<<<<
 *     else:
 *         return False
 */
              __Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_n_s_DecodeError); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 263, __pyx_L27_error)
              __Pyx_GOTREF(__pyx_t_5);
              __pyx_t_8 = __Pyx_PyInt_From_char((__pyx_v_data[(__pyx_v_j[0])])); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 263, __pyx_L27_error)
              __Pyx_GOTREF(__pyx_t_8);
              __pyx_t_9 = __Pyx_PyInt_From_int((__pyx_v_j[0])); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 263, __pyx_L27_error)
              __Pyx_GOTREF(__pyx_t_9);
              __pyx_t_7 = __Pyx_PyBytes_FromStringAndSize(__pyx_v_data + 0, __pyx_v_max - 0); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 263, __pyx_L27_error)
              __Pyx_GOTREF(__pyx_t_7);
              __pyx_t_6 = PyTuple_New(3); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 263, __pyx_L27_error)
              __Pyx_GOTREF(__pyx_t_6);
              __Pyx_GIVEREF(__pyx_t_8);
              PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_8);
              __Pyx_GIVEREF(__pyx_t_9);
              PyTuple_SET_ITEM(__pyx_t_6, 1, __pyx_t_9);
              __Pyx_GIVEREF(__pyx_t_7);
              PyTuple_SET_ITEM(__pyx_t_6, 2, __pyx_t_7);
              __pyx_t_8 = 0;
              __pyx_t_9 = 0;
              __pyx_t_7 = 0;
              __pyx_t_7 = __Pyx_PyString_Format(__pyx_kp_s_s_at_s_r, __pyx_t_6); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 263, __pyx_L27_error)
              __Pyx_GOTREF(__pyx_t_7);
              __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
              __pyx_t_6 = NULL;
              if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_5))) {
                __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_5);
                if (likely(__pyx_t_6)) {
                  PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5);
                  __Pyx_INCREF(__pyx_t_6);
                  __Pyx_INCREF(function);
                  __Pyx_DECREF_SET(__pyx_t_5, function);
                }
              }
              __pyx_t_4 = (__pyx_t_6) ? __Pyx_PyObject_Call2Args(__pyx_t_5, __pyx_t_6, __pyx_t_7) : __Pyx_PyObject_CallOneArg(__pyx_t_5, __pyx_t_7);
              __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
              __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
              if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 263, __pyx_L27_error)
              __Pyx_GOTREF(__pyx_t_4);
              __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
              __Pyx_Raise(__pyx_t_4, 0, 0, 0);
              __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
              __PYX_ERR(0, 263, __pyx_L27_error)
            }

            /* "btdht/krcp.pyx":262
 *                      raise DecodeError("%s > %s : %r" % (i[0], max, data[:max]))
 *         else:
 *             with gil:             # <<<<<<<<<<<<<<
 *                 raise DecodeError("%s != : at %s %r" % (data[j[0]], j[0], data[:max]))
 *     else:
 */
            /*finally:*/ {
              __pyx_L27_error: {
                #ifdef WITH_THREAD
                __Pyx_PyGILState_Release(__pyx_gilstate_save);
                #endif
                goto __pyx_L4_error;
              }
            }
        }
      }

      /* "btdht/krcp.pyx":240
 *     """
 *     cdef int ret
 *     if data[i[0]] == b'0' \             # <<<<<<<<<<<<<<
 *     or data[i[0]] == b'2' \
 *     or data[i[0]] == b'3' \
 */
    }

    /* "btdht/krcp.pyx":265
 *                 raise DecodeError("%s != : at %s %r" % (data[j[0]], j[0], data[:max]))
 *     else:
 *         return False             # <<<<<<<<<<<<<<
 * 
 * cdef long _decode_int(char* data, int *i, int max, long long  *myint) nogil except -1:
 */
    /*else*/ {
      __pyx_r = 0;
      goto __pyx_L3_return;
    }
  }

  /* "btdht/krcp.pyx":225
 * 
 * cdef int _decode_string(char* data, int* i, int max, int* j) nogil except -1:
 *     """             # <<<<<<<<<<<<<<
 *         Pass a bencoded string in a bencoded string
 * 
 */
  /*finally:*/ {
    __pyx_L3_return: {
      #ifdef WITH_THREAD
      __pyx_gilstate_save = __Pyx_PyGILState_Ensure();
      #endif
      goto __pyx_L0;
    }
    __pyx_L4_error: {
      #ifdef WITH_THREAD
      __pyx_gilstate_save = __Pyx_PyGILState_Ensure();
      #endif
      goto __pyx_L1_error;
    }
  }

  /* "btdht/krcp.pyx":224
 *     return True
 * 
 * cdef int _decode_string(char* data, int* i, int max, int* j) nogil except -1:             # <<<<<<<<<<<<<<
 *     """
 *         Pass a bencoded string in a bencoded string
 */

  /* function exit code */
  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_XDECREF(__pyx_t_9);
  __Pyx_AddTraceback("btdht.krcp._decode_string", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  #ifdef WITH_THREAD
  __Pyx_PyGILState_Release(__pyx_gilstate_save);
  #endif
  return __pyx_r;
}

/* "btdht/krcp.pyx":267
 *         return False
 * 
 * cdef long _decode_int(char* data, int *i, int max, long long  *myint) nogil except -1:             # <<<<<<<<<<<<<<
 *     """
 *         Decode a bencoded int and write it to ``myint``
 */

static long __pyx_f_5btdht_4krcp__decode_int(char *__pyx_v_data, int *__pyx_v_i, int __pyx_v_max, PY_LONG_LONG *__pyx_v_myint) {
  int __pyx_v_j;
  long __pyx_r;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  long __pyx_t_2;
  int __pyx_t_3;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  PyObject *__pyx_t_7 = NULL;
  PyObject *__pyx_t_8 = NULL;
  PyObject *__pyx_t_9 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  #ifdef WITH_THREAD
  PyGILState_STATE __pyx_gilstate_save;
  #endif
  __Pyx_RefNannySetupContext("_decode_int", 1);

  /* "btdht/krcp.pyx":268
 * 
 * cdef long _decode_int(char* data, int *i, int max, long long  *myint) nogil except -1:
 *     """             # <<<<<<<<<<<<<<
 *         Decode a bencoded int and write it to ``myint``
 * 
 */
  /*try:*/ {

    /* "btdht/krcp.pyx":289
 *     """
 *     cdef int j
 *     if data[i[0]] == b'i':             # <<<<<<<<<<<<<<
 *         i[0]+=1
 *         j = i[0]
 */
    __pyx_t_1 = (((__pyx_v_data[(__pyx_v_i[0])]) == 'i') != 0);
    if (__pyx_t_1) {

      /* "btdht/krcp.pyx":290
 *     cdef int j
 *     if data[i[0]] == b'i':
 *         i[0]+=1             # <<<<<<<<<<<<<<
 *         j = i[0]
 *         while data[j] != b'e' and j < max:
 */
      __pyx_t_2 = 0;
      (__pyx_v_i[__pyx_t_2]) = ((__pyx_v_i[__pyx_t_2]) + 1);

      /* "btdht/krcp.pyx":291
 *     if data[i[0]] == b'i':
 *         i[0]+=1
 *         j = i[0]             # <<<<<<<<<<<<<<
 *         while data[j] != b'e' and j < max:
 *             j+=1
 */
      __pyx_v_j = (__pyx_v_i[0]);

      /* "btdht/krcp.pyx":292
 *         i[0]+=1
 *         j = i[0]
 *         while data[j] != b'e' and j < max:             # <<<<<<<<<<<<<<
 *             j+=1
 *         if data[j] == b'e':
 */
      while (1) {
        __pyx_t_3 = (((__pyx_v_data[__pyx_v_j]) != 'e') != 0);
        if (__pyx_t_3) {
        } else {
          __pyx_t_1 = __pyx_t_3;
          goto __pyx_L9_bool_binop_done;
        }
        __pyx_t_3 = ((__pyx_v_j < __pyx_v_max) != 0);
        __pyx_t_1 = __pyx_t_3;
        __pyx_L9_bool_binop_done:;
        if (!__pyx_t_1) break;

        /* "btdht/krcp.pyx":293
 *         j = i[0]
 *         while data[j] != b'e' and j < max:
 *             j+=1             # <<<<<<<<<<<<<<
 *         if data[j] == b'e':
 *             myint[0]=str_to_long(data + i[0], j-i[0])
 */
        __pyx_v_j = (__pyx_v_j + 1);
      }

      /* "btdht/krcp.pyx":294
 *         while data[j] != b'e' and j < max:
 *             j+=1
 *         if data[j] == b'e':             # <<<<<<<<<<<<<<
 *             myint[0]=str_to_long(data + i[0], j-i[0])
 *             i[0]=j+1
 */
      __pyx_t_1 = (((__pyx_v_data[__pyx_v_j]) == 'e') != 0);
      if (__pyx_t_1) {

        /* "btdht/krcp.pyx":295
 *             j+=1
 *         if data[j] == b'e':
 *             myint[0]=str_to_long(data + i[0], j-i[0])             # <<<<<<<<<<<<<<
 *             i[0]=j+1
 *             if i[0] <= max:
 */
        (__pyx_v_myint[0]) = __pyx_f_5btdht_4krcp_str_to_long((__pyx_v_data + (__pyx_v_i[0])), (__pyx_v_j - (__pyx_v_i[0])));

        /* "btdht/krcp.pyx":296
 *         if data[j] == b'e':
 *             myint[0]=str_to_long(data + i[0], j-i[0])
 *             i[0]=j+1             # <<<<<<<<<<<<<<
 *             if i[0] <= max:
 *                 return True
 */
        (__pyx_v_i[0]) = (__pyx_v_j + 1);

        /* "btdht/krcp.pyx":297
 *             myint[0]=str_to_long(data + i[0], j-i[0])
 *             i[0]=j+1
 *             if i[0] <= max:             # <<<<<<<<<<<<<<
 *                 return True
 *             else:
 */
        __pyx_t_1 = (((__pyx_v_i[0]) <= __pyx_v_max) != 0);
        if (__pyx_t_1) {

          /* "btdht/krcp.pyx":298
 *             i[0]=j+1
 *             if i[0] <= max:
 *                 return True             # <<<<<<<<<<<<<<
 *             else:
 *                 with gil:
 */
          __pyx_r = 1;
          goto __pyx_L3_return;

          /* "btdht/krcp.pyx":297
 *             myint[0]=str_to_long(data + i[0], j-i[0])
 *             i[0]=j+1
 *             if i[0] <= max:             # <<<<<<<<<<<<<<
 *                 return True
 *             else:
 */
        }

        /* "btdht/krcp.pyx":300
 *                 return True
 *             else:
 *                 with gil:             # <<<<<<<<<<<<<<
 *                      raise DecodeError("%s > %s : %r" % (i[0], max, data[:max]))
 *         else:
 */
        /*else*/ {
          {
              #ifdef WITH_THREAD
              PyGILState_STATE __pyx_gilstate_save = __Pyx_PyGILState_Ensure();
              #endif
              /*try:*/ {

                /* "btdht/krcp.pyx":301
 *             else:
 *                 with gil:
 *                      raise DecodeError("%s > %s : %r" % (i[0], max, data[:max]))             # <<<<<<<<<<<<<<
 *         else:
 *             with gil:
 */
                __Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_n_s_DecodeError); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 301, __pyx_L14_error)
                __Pyx_GOTREF(__pyx_t_5);
                __pyx_t_6 = __Pyx_PyInt_From_int((__pyx_v_i[0])); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 301, __pyx_L14_error)
                __Pyx_GOTREF(__pyx_t_6);
                __pyx_t_7 = __Pyx_PyInt_From_int(__pyx_v_max); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 301, __pyx_L14_error)
                __Pyx_GOTREF(__pyx_t_7);
                __pyx_t_8 = __Pyx_PyBytes_FromStringAndSize(__pyx_v_data + 0, __pyx_v_max - 0); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 301, __pyx_L14_error)
                __Pyx_GOTREF(__pyx_t_8);
                __pyx_t_9 = PyTuple_New(3); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 301, __pyx_L14_error)
                __Pyx_GOTREF(__pyx_t_9);
                __Pyx_GIVEREF(__pyx_t_6);
                PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_t_6);
                __Pyx_GIVEREF(__pyx_t_7);
                PyTuple_SET_ITEM(__pyx_t_9, 1, __pyx_t_7);
                __Pyx_GIVEREF(__pyx_t_8);
                PyTuple_SET_ITEM(__pyx_t_9, 2, __pyx_t_8);
                __pyx_t_6 = 0;
                __pyx_t_7 = 0;
                __pyx_t_8 = 0;
                __pyx_t_8 = __Pyx_PyString_Format(__pyx_kp_s_s_s_r, __pyx_t_9); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 301, __pyx_L14_error)
                __Pyx_GOTREF(__pyx_t_8);
                __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
                __pyx_t_9 = NULL;
                if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_5))) {
                  __pyx_t_9 = PyMethod_GET_SELF(__pyx_t_5);
                  if (likely(__pyx_t_9)) {
                    PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5);
                    __Pyx_INCREF(__pyx_t_9);
                    __Pyx_INCREF(function);
                    __Pyx_DECREF_SET(__pyx_t_5, function);
                  }
                }
                __pyx_t_4 = (__pyx_t_9) ? __Pyx_PyObject_Call2Args(__pyx_t_5, __pyx_t_9, __pyx_t_8) : __Pyx_PyObject_CallOneArg(__pyx_t_5, __pyx_t_8);
                __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
                __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
                if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 301, __pyx_L14_error)
                __Pyx_GOTREF(__pyx_t_4);
                __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
                __Pyx_Raise(__pyx_t_4, 0, 0, 0);
                __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
                __PYX_ERR(0, 301, __pyx_L14_error)
              }

              /* "btdht/krcp.pyx":300
 *                 return True
 *             else:
 *                 with gil:             # <<<<<<<<<<<<<<
 *                      raise DecodeError("%s > %s : %r" % (i[0], max, data[:max]))
 *         else:
 */
              /*finally:*/ {
                __pyx_L14_error: {
                  #ifdef WITH_THREAD
                  __Pyx_PyGILState_Release(__pyx_gilstate_save);
                  #endif
                  goto __pyx_L4_error;
                }
              }
          }
        }

        /* "btdht/krcp.pyx":294
 *         while data[j] != b'e' and j < max:
 *             j+=1
 *         if data[j] == b'e':             # <<<<<<<<<<<<<<
 *             myint[0]=str_to_long(data + i[0], j-i[0])
 *             i[0]=j+1
 */
      }

      /* "btdht/krcp.pyx":303
 *                      raise DecodeError("%s > %s : %r" % (i[0], max, data[:max]))
 *         else:
 *             with gil:             # <<<<<<<<<<<<<<
 *                 raise DecodeError("%s != e at %s %r" % (data[j], j, data[:max]))
 *     else:
 */
      /*else*/ {
        {
            #ifdef WITH_THREAD
            PyGILState_STATE __pyx_gilstate_save = __Pyx_PyGILState_Ensure();
            #endif
            /*try:*/ {

              /* "btdht/krcp.pyx":304
 *         else:
 *             with gil:
 *                 raise DecodeError("%s != e at %s %r" % (data[j], j, data[:max]))             # <<<<<<<<<<<<<<
 *     else:
 *         return False
 */
              __Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_n_s_DecodeError); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 304, __pyx_L17_error)
              __Pyx_GOTREF(__pyx_t_5);
              __pyx_t_8 = __Pyx_PyInt_From_char((__pyx_v_data[__pyx_v_j])); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 304, __pyx_L17_error)
              __Pyx_GOTREF(__pyx_t_8);
              __pyx_t_9 = __Pyx_PyInt_From_int(__pyx_v_j); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 304, __pyx_L17_error)
              __Pyx_GOTREF(__pyx_t_9);
              __pyx_t_7 = __Pyx_PyBytes_FromStringAndSize(__pyx_v_data + 0, __pyx_v_max - 0); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 304, __pyx_L17_error)
              __Pyx_GOTREF(__pyx_t_7);
              __pyx_t_6 = PyTuple_New(3); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 304, __pyx_L17_error)
              __Pyx_GOTREF(__pyx_t_6);
              __Pyx_GIVEREF(__pyx_t_8);
              PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_8);
              __Pyx_GIVEREF(__pyx_t_9);
              PyTuple_SET_ITEM(__pyx_t_6, 1, __pyx_t_9);
              __Pyx_GIVEREF(__pyx_t_7);
              PyTuple_SET_ITEM(__pyx_t_6, 2, __pyx_t_7);
              __pyx_t_8 = 0;
              __pyx_t_9 = 0;
              __pyx_t_7 = 0;
              __pyx_t_7 = __Pyx_PyString_Format(__pyx_kp_s_s_e_at_s_r, __pyx_t_6); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 304, __pyx_L17_error)
              __Pyx_GOTREF(__pyx_t_7);
              __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
              __pyx_t_6 = NULL;
              if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_5))) {
                __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_5);
                if (likely(__pyx_t_6)) {
                  PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5);
                  __Pyx_INCREF(__pyx_t_6);
                  __Pyx_INCREF(function);
                  __Pyx_DECREF_SET(__pyx_t_5, function);
                }
              }
              __pyx_t_4 = (__pyx_t_6) ? __Pyx_PyObject_Call2Args(__pyx_t_5, __pyx_t_6, __pyx_t_7) : __Pyx_PyObject_CallOneArg(__pyx_t_5, __pyx_t_7);
              __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
              __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
              if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 304, __pyx_L17_error)
              __Pyx_GOTREF(__pyx_t_4);
              __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
              __Pyx_Raise(__pyx_t_4, 0, 0, 0);
              __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
              __PYX_ERR(0, 304, __pyx_L17_error)
            }

            /* "btdht/krcp.pyx":303
 *                      raise DecodeError("%s > %s : %r" % (i[0], max, data[:max]))
 *         else:
 *             with gil:             # <<<<<<<<<<<<<<
 *                 raise DecodeError("%s != e at %s %r" % (data[j], j, data[:max]))
 *     else:
 */
            /*finally:*/ {
              __pyx_L17_error: {
                #ifdef WITH_THREAD
                __Pyx_PyGILState_Release(__pyx_gilstate_save);
                #endif
                goto __pyx_L4_error;
              }
            }
        }
      }

      /* "btdht/krcp.pyx":289
 *     """
 *     cdef int j
 *     if data[i[0]] == b'i':             # <<<<<<<<<<<<<<
 *         i[0]+=1
 *         j = i[0]
 */
    }

    /* "btdht/krcp.pyx":306
 *                 raise DecodeError("%s != e at %s %r" % (data[j], j, data[:max]))
 *     else:
 *         return False             # <<<<<<<<<<<<<<
 * 
 * cdef int _encode_int(char* data, int *i, int max, int j) nogil:
 */
    /*else*/ {
      __pyx_r = 0;
      goto __pyx_L3_return;
    }
  }

  /* "btdht/krcp.pyx":268
 * 
 * cdef long _decode_int(char* data, int *i, int max, long long  *myint) nogil except -1:
 *     """             # <<<<<<<<<<<<<<
 *         Decode a bencoded int and write it to ``myint``
 * 
 */
  /*finally:*/ {
    __pyx_L3_return: {
      #ifdef WITH_THREAD
      __pyx_gilstate_save = __Pyx_PyGILState_Ensure();
      #endif
      goto __pyx_L0;
    }
    __pyx_L4_error: {
      #ifdef WITH_THREAD
      __pyx_gilstate_save = __Pyx_PyGILState_Ensure();
      #endif
      goto __pyx_L1_error;
    }
  }

  /* "btdht/krcp.pyx":267
 *         return False
 * 
 * cdef long _decode_int(char* data, int *i, int max, long long  *myint) nogil except -1:             # <<<<<<<<<<<<<<
 *     """
 *         Decode a bencoded int and write it to ``myint``
 */

  /* function exit code */
  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_XDECREF(__pyx_t_9);
  __Pyx_AddTraceback("btdht.krcp._decode_int", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1L;
  __pyx_L0:;
  #ifdef WITH_THREAD
  __Pyx_PyGILState_Release(__pyx_gilstate_save);
  #endif
  return __pyx_r;
}

/* "btdht/krcp.pyx":308
 *         return False
 * 
 * cdef int _encode_int(char* data, int *i, int max, int j) nogil:             # <<<<<<<<<<<<<<
 *     """
 *         Bencode the integer ``j``and write it in ``data`` at offset ``i``
 */

static int __pyx_f_5btdht_4krcp__encode_int(char *__pyx_v_data, int *__pyx_v_i, int __pyx_v_max, int __pyx_v_j) {
  int __pyx_v_l;
  int __pyx_r;
  int __pyx_t_1;
  long __pyx_t_2;

  /* "btdht/krcp.pyx":325
 *     """
 *     cdef int l
 *     l = int_length(j)             # <<<<<<<<<<<<<<
 *     if max >= i[0] + l + 2:
 *          data[i[0]]=b'i'
 */
  __pyx_v_l = __pyx_f_5btdht_4krcp_int_length(__pyx_v_j);

  /* "btdht/krcp.pyx":326
 *     cdef int l
 *     l = int_length(j)
 *     if max >= i[0] + l + 2:             # <<<<<<<<<<<<<<
 *          data[i[0]]=b'i'
 *          i[0]+=1
 */
  __pyx_t_1 = ((__pyx_v_max >= (((__pyx_v_i[0]) + __pyx_v_l) + 2)) != 0);
  if (__pyx_t_1) {

    /* "btdht/krcp.pyx":327
 *     l = int_length(j)
 *     if max >= i[0] + l + 2:
 *          data[i[0]]=b'i'             # <<<<<<<<<<<<<<
 *          i[0]+=1
 *          sprintf(data + i[0], b"%d", j)
 */
    (__pyx_v_data[(__pyx_v_i[0])]) = 'i';

    /* "btdht/krcp.pyx":328
 *     if max >= i[0] + l + 2:
 *          data[i[0]]=b'i'
 *          i[0]+=1             # <<<<<<<<<<<<<<
 *          sprintf(data + i[0], b"%d", j)
 *          i[0]+=l
 */
    __pyx_t_2 = 0;
    (__pyx_v_i[__pyx_t_2]) = ((__pyx_v_i[__pyx_t_2]) + 1);

    /* "btdht/krcp.pyx":329
 *          data[i[0]]=b'i'
 *          i[0]+=1
 *          sprintf(data + i[0], b"%d", j)             # <<<<<<<<<<<<<<
 *          i[0]+=l
 *          data[i[0]]=b'e'
 */
    (void)(sprintf((__pyx_v_data + (__pyx_v_i[0])), ((char const *)"%d"), __pyx_v_j));

    /* "btdht/krcp.pyx":330
 *          i[0]+=1
 *          sprintf(data + i[0], b"%d", j)
 *          i[0]+=l             # <<<<<<<<<<<<<<
 *          data[i[0]]=b'e'
 *          i[0]+=1
 */
    __pyx_t_2 = 0;
    (__pyx_v_i[__pyx_t_2]) = ((__pyx_v_i[__pyx_t_2]) + __pyx_v_l);

    /* "btdht/krcp.pyx":331
 *          sprintf(data + i[0], b"%d", j)
 *          i[0]+=l
 *          data[i[0]]=b'e'             # <<<<<<<<<<<<<<
 *          i[0]+=1
 *          return True
 */
    (__pyx_v_data[(__pyx_v_i[0])]) = 'e';

    /* "btdht/krcp.pyx":332
 *          i[0]+=l
 *          data[i[0]]=b'e'
 *          i[0]+=1             # <<<<<<<<<<<<<<
 *          return True
 *     else:
 */
    __pyx_t_2 = 0;
    (__pyx_v_i[__pyx_t_2]) = ((__pyx_v_i[__pyx_t_2]) + 1);

    /* "btdht/krcp.pyx":333
 *          data[i[0]]=b'e'
 *          i[0]+=1
 *          return True             # <<<<<<<<<<<<<<
 *     else:
 *         printf("encode_int: %d < %d\n", max, i[0] + l + 2)
 */
    __pyx_r = 1;
    goto __pyx_L0;

    /* "btdht/krcp.pyx":326
 *     cdef int l
 *     l = int_length(j)
 *     if max >= i[0] + l + 2:             # <<<<<<<<<<<<<<
 *          data[i[0]]=b'i'
 *          i[0]+=1
 */
  }

  /* "btdht/krcp.pyx":335
 *          return True
 *     else:
 *         printf("encode_int: %d < %d\n", max, i[0] + l + 2)             # <<<<<<<<<<<<<<
 *         return False
 * 
 */
  /*else*/ {
    (void)(printf(((char const *)"encode_int: %d < %d\n"), __pyx_v_max, (((__pyx_v_i[0]) + __pyx_v_l) + 2)));

    /* "btdht/krcp.pyx":336
 *     else:
 *         printf("encode_int: %d < %d\n", max, i[0] + l + 2)
 *         return False             # <<<<<<<<<<<<<<
 * 
 * cdef int _encode_string(char* data, int* i, int max, char* str, int strlen) nogil:
 */
    __pyx_r = 0;
    goto __pyx_L0;
  }

  /* "btdht/krcp.pyx":308
 *         return False
 * 
 * cdef int _encode_int(char* data, int *i, int max, int j) nogil:             # <<<<<<<<<<<<<<
 *     """
 *         Bencode the integer ``j``and write it in ``data`` at offset ``i``
 */

  /* function exit code */
  __pyx_L0:;
  return __pyx_r;
}

/* "btdht/krcp.pyx":338
 *         return False
 * 
 * cdef int _encode_string(char* data, int* i, int max, char* str, int strlen) nogil:             # <<<<<<<<<<<<<<
 *     """
 *         Bencode the string ``str`` of length ``trlen`` and write it in ``data`` at offset ``i``
 */

static int __pyx_f_5btdht_4krcp__encode_string(char *__pyx_v_data, int *__pyx_v_i, int __pyx_v_max, char *__pyx_v_str, int __pyx_v_strlen) {
  int __pyx_v_l;
  int __pyx_r;
  int __pyx_t_1;
  long __pyx_t_2;

  /* "btdht/krcp.pyx":356
 *     """
 *     cdef int l
 *     l = int_length(strlen)             # <<<<<<<<<<<<<<
 *     if max >= i[0] + l + 1 + strlen: # size as char + : + string
 *         sprintf(data + i[0], b"%d", strlen)
 */
  __pyx_v_l = __pyx_f_5btdht_4krcp_int_length(__pyx_v_strlen);

  /* "btdht/krcp.pyx":357
 *     cdef int l
 *     l = int_length(strlen)
 *     if max >= i[0] + l + 1 + strlen: # size as char + : + string             # <<<<<<<<<<<<<<
 *         sprintf(data + i[0], b"%d", strlen)
 *         i[0]+=l
 */
  __pyx_t_1 = ((__pyx_v_max >= ((((__pyx_v_i[0]) + __pyx_v_l) + 1) + __pyx_v_strlen)) != 0);
  if (__pyx_t_1) {

    /* "btdht/krcp.pyx":358
 *     l = int_length(strlen)
 *     if max >= i[0] + l + 1 + strlen: # size as char + : + string
 *         sprintf(data + i[0], b"%d", strlen)             # <<<<<<<<<<<<<<
 *         i[0]+=l
 *         data[i[0]]=b':'
 */
    (void)(sprintf((__pyx_v_data + (__pyx_v_i[0])), ((char const *)"%d"), __pyx_v_strlen));

    /* "btdht/krcp.pyx":359
 *     if max >= i[0] + l + 1 + strlen: # size as char + : + string
 *         sprintf(data + i[0], b"%d", strlen)
 *         i[0]+=l             # <<<<<<<<<<<<<<
 *         data[i[0]]=b':'
 *         i[0]+=1
 */
    __pyx_t_2 = 0;
    (__pyx_v_i[__pyx_t_2]) = ((__pyx_v_i[__pyx_t_2]) + __pyx_v_l);

    /* "btdht/krcp.pyx":360
 *         sprintf(data + i[0], b"%d", strlen)
 *         i[0]+=l
 *         data[i[0]]=b':'             # <<<<<<<<<<<<<<
 *         i[0]+=1
 *         strncpy(data + i[0], str, strlen)
 */
    (__pyx_v_data[(__pyx_v_i[0])]) = ':';

    /* "btdht/krcp.pyx":361
 *         i[0]+=l
 *         data[i[0]]=b':'
 *         i[0]+=1             # <<<<<<<<<<<<<<
 *         strncpy(data + i[0], str, strlen)
 *         i[0]+=strlen
 */
    __pyx_t_2 = 0;
    (__pyx_v_i[__pyx_t_2]) = ((__pyx_v_i[__pyx_t_2]) + 1);

    /* "btdht/krcp.pyx":362
 *         data[i[0]]=b':'
 *         i[0]+=1
 *         strncpy(data + i[0], str, strlen)             # <<<<<<<<<<<<<<
 *         i[0]+=strlen
 *         return True
 */
    (void)(strncpy((__pyx_v_data + (__pyx_v_i[0])), __pyx_v_str, __pyx_v_strlen));

    /* "btdht/krcp.pyx":363
 *         i[0]+=1
 *         strncpy(data + i[0], str, strlen)
 *         i[0]+=strlen             # <<<<<<<<<<<<<<
 *         return True
 *     else:
 */
    __pyx_t_2 = 0;
    (__pyx_v_i[__pyx_t_2]) = ((__pyx_v_i[__pyx_t_2]) + __pyx_v_strlen);

    /* "btdht/krcp.pyx":364
 *         strncpy(data + i[0], str, strlen)
 *         i[0]+=strlen
 *         return True             # <<<<<<<<<<<<<<
 *     else:
 *         printf("encode_string: %d < %d\n", max, i[0] + l + 1 + strlen)
 */
    __pyx_r = 1;
    goto __pyx_L0;

    /* "btdht/krcp.pyx":357
 *     cdef int l
 *     l = int_length(strlen)
 *     if max >= i[0] + l + 1 + strlen: # size as char + : + string             # <<<<<<<<<<<<<<
 *         sprintf(data + i[0], b"%d", strlen)
 *         i[0]+=l
 */
  }

  /* "btdht/krcp.pyx":366
 *         return True
 *     else:
 *         printf("encode_string: %d < %d\n", max, i[0] + l + 1 + strlen)             # <<<<<<<<<<<<<<
 *         return False
 * 
 */
  /*else*/ {
    (void)(printf(((char const *)"encode_string: %d < %d\n"), __pyx_v_max, ((((__pyx_v_i[0]) + __pyx_v_l) + 1) + __pyx_v_strlen)));

    /* "btdht/krcp.pyx":367
 *     else:
 *         printf("encode_string: %d < %d\n", max, i[0] + l + 1 + strlen)
 *         return False             # <<<<<<<<<<<<<<
 * 
 * class BError(Exception):
 */
    __pyx_r = 0;
    goto __pyx_L0;
  }

  /* "btdht/krcp.pyx":338
 *         return False
 * 
 * cdef int _encode_string(char* data, int* i, int max, char* str, int strlen) nogil:             # <<<<<<<<<<<<<<
 *     """
 *         Bencode the string ``str`` of length ``trlen`` and write it in ``data`` at offset ``i``
 */

  /* function exit code */
  __pyx_L0:;
  return __pyx_r;
}

/* "btdht/krcp.pyx":384
 *     # The second element is a string containing the error message
 *     e = None
 *     def __init__(self, t, e, **kwargs):             # <<<<<<<<<<<<<<
 *         if t is None:
 *             raise ValueError("t should not be None")
 */

/* Python wrapper */
static PyObject *__pyx_pw_5btdht_4krcp_6BError_1__init__(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyMethodDef __pyx_mdef_5btdht_4krcp_6BError_1__init__ = {"__init__", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_5btdht_4krcp_6BError_1__init__, METH_VARARGS|METH_KEYWORDS, 0};
static PyObject *__pyx_pw_5btdht_4krcp_6BError_1__init__(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_self = 0;
  PyObject *__pyx_v_t = 0;
  PyObject *__pyx_v_e = 0;
  PyObject *__pyx_v_kwargs = 0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__init__ (wrapper)", 0);
  __pyx_v_kwargs = PyDict_New(); if (unlikely(!__pyx_v_kwargs)) return NULL;
  __Pyx_GOTREF(__pyx_v_kwargs);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_self,&__pyx_n_s_t,&__pyx_n_s_e,0};
    PyObject* values[3] = {0,0,0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        CYTHON_FALLTHROUGH;
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_self)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_t)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("__init__", 1, 3, 3, 1); __PYX_ERR(0, 384, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  2:
        if (likely((values[2] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_e)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("__init__", 1, 3, 3, 2); __PYX_ERR(0, 384, __pyx_L3_error)
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, __pyx_v_kwargs, values, pos_args, "__init__") < 0)) __PYX_ERR(0, 384, __pyx_L3_error)
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) != 3) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
      values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
    }
    __pyx_v_self = values[0];
    __pyx_v_t = values[1];
    __pyx_v_e = values[2];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("__init__", 1, 3, 3, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 384, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_DECREF(__pyx_v_kwargs); __pyx_v_kwargs = 0;
  __Pyx_AddTraceback("btdht.krcp.BError.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_5btdht_4krcp_6BError___init__(__pyx_self, __pyx_v_self, __pyx_v_t, __pyx_v_e, __pyx_v_kwargs);

  /* function exit code */
  __Pyx_XDECREF(__pyx_v_kwargs);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5btdht_4krcp_6BError___init__(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_t, PyObject *__pyx_v_e, PyObject *__pyx_v_kwargs) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  int __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__init__", 0);

  /* "btdht/krcp.pyx":385
 *     e = None
 *     def __init__(self, t, e, **kwargs):
 *         if t is None:             # <<<<<<<<<<<<<<
 *             raise ValueError("t should not be None")
 *         self.t = t
 */
  __pyx_t_1 = (__pyx_v_t == Py_None);
  __pyx_t_2 = (__pyx_t_1 != 0);
  if (unlikely(__pyx_t_2)) {

    /* "btdht/krcp.pyx":386
 *     def __init__(self, t, e, **kwargs):
 *         if t is None:
 *             raise ValueError("t should not be None")             # <<<<<<<<<<<<<<
 *         self.t = t
 *         self.e = e
 */
    __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple_, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 386, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_Raise(__pyx_t_3, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __PYX_ERR(0, 386, __pyx_L1_error)

    /* "btdht/krcp.pyx":385
 *     e = None
 *     def __init__(self, t, e, **kwargs):
 *         if t is None:             # <<<<<<<<<<<<<<
 *             raise ValueError("t should not be None")
 *         self.t = t
 */
  }

  /* "btdht/krcp.pyx":387
 *         if t is None:
 *             raise ValueError("t should not be None")
 *         self.t = t             # <<<<<<<<<<<<<<
 *         self.e = e
 *         super(BError, self).__init__(*e, **kwargs)
 */
  if (__Pyx_PyObject_SetAttrStr(__pyx_v_self, __pyx_n_s_t, __pyx_v_t) < 0) __PYX_ERR(0, 387, __pyx_L1_error)

  /* "btdht/krcp.pyx":388
 *             raise ValueError("t should not be None")
 *         self.t = t
 *         self.e = e             # <<<<<<<<<<<<<<
 *         super(BError, self).__init__(*e, **kwargs)
 * 
 */
  if (__Pyx_PyObject_SetAttrStr(__pyx_v_self, __pyx_n_s_e, __pyx_v_e) < 0) __PYX_ERR(0, 388, __pyx_L1_error)

  /* "btdht/krcp.pyx":389
 *         self.t = t
 *         self.e = e
 *         super(BError, self).__init__(*e, **kwargs)             # <<<<<<<<<<<<<<
 * 
 *     def encode(self):
 */
  __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_BError); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 389, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = PyTuple_New(2); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 389, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_GIVEREF(__pyx_t_3);
  PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_3);
  __Pyx_INCREF(__pyx_v_self);
  __Pyx_GIVEREF(__pyx_v_self);
  PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_v_self);
  __pyx_t_3 = 0;
  __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_super, __pyx_t_4, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 389, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_init); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 389, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_3 = __Pyx_PySequence_Tuple(__pyx_v_e); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 389, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_5 = PyDict_Copy(__pyx_v_kwargs); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 389, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_t_6 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_3, __pyx_t_5); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 389, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;

  /* "btdht/krcp.pyx":384
 *     # The second element is a string containing the error message
 *     e = None
 *     def __init__(self, t, e, **kwargs):             # <<<<<<<<<<<<<<
 *         if t is None:
 *             raise ValueError("t should not be None")
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_AddTraceback("btdht.krcp.BError.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "btdht/krcp.pyx":391
 *         super(BError, self).__init__(*e, **kwargs)
 * 
 *     def encode(self):             # <<<<<<<<<<<<<<
 *         """
 *             Bencode the error message
 */

/* Python wrapper */
static PyObject *__pyx_pw_5btdht_4krcp_6BError_3encode(PyObject *__pyx_self, PyObject *__pyx_v_self); /*proto*/
static char __pyx_doc_5btdht_4krcp_6BError_2encode[] = "\n            Bencode the error message\n\n            :return: The bencoded error message ready to be send\n            :rtype: bytes\n        ";
static PyMethodDef __pyx_mdef_5btdht_4krcp_6BError_3encode = {"encode", (PyCFunction)__pyx_pw_5btdht_4krcp_6BError_3encode, METH_O, __pyx_doc_5btdht_4krcp_6BError_2encode};
static PyObject *__pyx_pw_5btdht_4krcp_6BError_3encode(PyObject *__pyx_self, PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("encode (wrapper)", 0);
  __pyx_r = __pyx_pf_5btdht_4krcp_6BError_2encode(__pyx_self, ((PyObject *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5btdht_4krcp_6BError_2encode(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("encode", 0);

  /* "btdht/krcp.pyx":398
 *             :rtype: bytes
 *         """
 *         return utils.bencode({b"y":self.y, b"t":self.t, b"e":self.e})             # <<<<<<<<<<<<<<
 * 
 *     def __str__(self):
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_utils); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 398, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_bencode); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 398, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = __Pyx_PyDict_NewPresized(3); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 398, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_y); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 398, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  if (PyDict_SetItem(__pyx_t_2, __pyx_n_b_y, __pyx_t_4) < 0) __PYX_ERR(0, 398, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_t); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 398, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  if (PyDict_SetItem(__pyx_t_2, __pyx_n_b_t, __pyx_t_4) < 0) __PYX_ERR(0, 398, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_e); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 398, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  if (PyDict_SetItem(__pyx_t_2, __pyx_n_b_e, __pyx_t_4) < 0) __PYX_ERR(0, 398, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_4 = NULL;
  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
    __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
    if (likely(__pyx_t_4)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
      __Pyx_INCREF(__pyx_t_4);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_3, function);
    }
  }
  __pyx_t_1 = (__pyx_t_4) ? __Pyx_PyObject_Call2Args(__pyx_t_3, __pyx_t_4, __pyx_t_2) : __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_2);
  __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 398, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "btdht/krcp.pyx":391
 *         super(BError, self).__init__(*e, **kwargs)
 * 
 *     def encode(self):             # <<<<<<<<<<<<<<
 *         """
 *             Bencode the error message
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_AddTraceback("btdht.krcp.BError.encode", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "btdht/krcp.pyx":400
 *         return utils.bencode({b"y":self.y, b"t":self.t, b"e":self.e})
 * 
 *     def __str__(self):             # <<<<<<<<<<<<<<
 *         raise NotImplementedError()
 * 
 */

/* Python wrapper */
static PyObject *__pyx_pw_5btdht_4krcp_6BError_5__str__(PyObject *__pyx_self, PyObject *__pyx_v_self); /*proto*/
static PyMethodDef __pyx_mdef_5btdht_4krcp_6BError_5__str__ = {"__str__", (PyCFunction)__pyx_pw_5btdht_4krcp_6BError_5__str__, METH_O, 0};
static PyObject *__pyx_pw_5btdht_4krcp_6BError_5__str__(PyObject *__pyx_self, PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__str__ (wrapper)", 0);
  __pyx_r = __pyx_pf_5btdht_4krcp_6BError_4__str__(__pyx_self, ((PyObject *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5btdht_4krcp_6BError_4__str__(CYTHON_UNUSED PyObject *__pyx_self, CYTHON_UNUSED PyObject *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__str__", 0);

  /* "btdht/krcp.pyx":401
 * 
 *     def __str__(self):
 *         raise NotImplementedError()             # <<<<<<<<<<<<<<
 * 
 *     def __repr__(self):
 */
  __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_builtin_NotImplementedError); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 401, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_Raise(__pyx_t_1, 0, 0, 0);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __PYX_ERR(0, 401, __pyx_L1_error)

  /* "btdht/krcp.pyx":400
 *         return utils.bencode({b"y":self.y, b"t":self.t, b"e":self.e})
 * 
 *     def __str__(self):             # <<<<<<<<<<<<<<
 *         raise NotImplementedError()
 * 
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("btdht.krcp.BError.__str__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "btdht/krcp.pyx":403
 *         raise NotImplementedError()
 * 
 *     def __repr__(self):             # <<<<<<<<<<<<<<
 *         return "%s: %r" % (self.__class__.__name__, self.e)
 * 
 */

/* Python wrapper */
static PyObject *__pyx_pw_5btdht_4krcp_6BError_7__repr__(PyObject *__pyx_self, PyObject *__pyx_v_self); /*proto*/
static PyMethodDef __pyx_mdef_5btdht_4krcp_6BError_7__repr__ = {"__repr__", (PyCFunction)__pyx_pw_5btdht_4krcp_6BError_7__repr__, METH_O, 0};
static PyObject *__pyx_pw_5btdht_4krcp_6BError_7__repr__(PyObject *__pyx_self, PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__repr__ (wrapper)", 0);
  __pyx_r = __pyx_pf_5btdht_4krcp_6BError_6__repr__(__pyx_self, ((PyObject *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5btdht_4krcp_6BError_6__repr__(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__repr__", 0);

  /* "btdht/krcp.pyx":404
 * 
 *     def __repr__(self):
 *         return "%s: %r" % (self.__class__.__name__, self.e)             # <<<<<<<<<<<<<<
 * 
 * class GenericError(BError):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_class); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 404, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_name); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 404, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_e); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 404, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 404, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_GIVEREF(__pyx_t_2);
  PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_2);
  __Pyx_GIVEREF(__pyx_t_1);
  PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_t_1);
  __pyx_t_2 = 0;
  __pyx_t_1 = 0;
  __pyx_t_1 = __Pyx_PyString_Format(__pyx_kp_s_s_r, __pyx_t_3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 404, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "btdht/krcp.pyx":403
 *         raise NotImplementedError()
 * 
 *     def __repr__(self):             # <<<<<<<<<<<<<<
 *         return "%s: %r" % (self.__class__.__name__, self.e)
 * 
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("btdht.krcp.BError.__repr__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "btdht/krcp.pyx":413
 *         :param bytes msg: An optionnal error message
 *     """
 *     def __init__(self, t, msg=b""):             # <<<<<<<<<<<<<<
 *         super(GenericError, self).__init__(t=t, e=[201, msg])
 * class ServerError(BError):
 */

/* Python wrapper */
static PyObject *__pyx_pw_5btdht_4krcp_12GenericError_1__init__(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyMethodDef __pyx_mdef_5btdht_4krcp_12GenericError_1__init__ = {"__init__", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_5btdht_4krcp_12GenericError_1__init__, METH_VARARGS|METH_KEYWORDS, 0};
static PyObject *__pyx_pw_5btdht_4krcp_12GenericError_1__init__(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_self = 0;
  PyObject *__pyx_v_t = 0;
  PyObject *__pyx_v_msg = 0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__init__ (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_self,&__pyx_n_s_t,&__pyx_n_s_msg,0};
    PyObject* values[3] = {0,0,0};
    values[2] = ((PyObject *)((PyObject*)__pyx_kp_b__2));
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        CYTHON_FALLTHROUGH;
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_self)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_t)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("__init__", 0, 2, 3, 1); __PYX_ERR(0, 413, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  2:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_msg);
          if (value) { values[2] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__init__") < 0)) __PYX_ERR(0, 413, __pyx_L3_error)
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        CYTHON_FALLTHROUGH;
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    __pyx_v_self = values[0];
    __pyx_v_t = values[1];
    __pyx_v_msg = values[2];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("__init__", 0, 2, 3, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 413, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("btdht.krcp.GenericError.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_5btdht_4krcp_12GenericError___init__(__pyx_self, __pyx_v_self, __pyx_v_t, __pyx_v_msg);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5btdht_4krcp_12GenericError___init__(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_t, PyObject *__pyx_v_msg) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__init__", 0);

  /* "btdht/krcp.pyx":414
 *     """
 *     def __init__(self, t, msg=b""):
 *         super(GenericError, self).__init__(t=t, e=[201, msg])             # <<<<<<<<<<<<<<
 * class ServerError(BError):
 *     """
 */
  __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_GenericError); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 414, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 414, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_GIVEREF(__pyx_t_1);
  PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_1);
  __Pyx_INCREF(__pyx_v_self);
  __Pyx_GIVEREF(__pyx_v_self);
  PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_v_self);
  __pyx_t_1 = 0;
  __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_super, __pyx_t_2, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 414, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_init); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 414, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = __Pyx_PyDict_NewPresized(2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 414, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_t, __pyx_v_t) < 0) __PYX_ERR(0, 414, __pyx_L1_error)
  __pyx_t_3 = PyList_New(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 414, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_INCREF(__pyx_int_201);
  __Pyx_GIVEREF(__pyx_int_201);
  PyList_SET_ITEM(__pyx_t_3, 0, __pyx_int_201);
  __Pyx_INCREF(__pyx_v_msg);
  __Pyx_GIVEREF(__pyx_v_msg);
  PyList_SET_ITEM(__pyx_t_3, 1, __pyx_v_msg);
  if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_e, __pyx_t_3) < 0) __PYX_ERR(0, 414, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_empty_tuple, __pyx_t_1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 414, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

  /* "btdht/krcp.pyx":413
 *         :param bytes msg: An optionnal error message
 *     """
 *     def __init__(self, t, msg=b""):             # <<<<<<<<<<<<<<
 *         super(GenericError, self).__init__(t=t, e=[201, msg])
 * class ServerError(BError):
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("btdht.krcp.GenericError.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "btdht/krcp.pyx":422
 *         :param bytes msg: An optionnal error message
 *     """
 *     def __init__(self, t, msg=b"Server Error"):             # <<<<<<<<<<<<<<
 *         super(ServerError, self).__init__(t=t, e=[202, msg])
 * class ProtocolError(BError):
 */

/* Python wrapper */
static PyObject *__pyx_pw_5btdht_4krcp_11ServerError_1__init__(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyMethodDef __pyx_mdef_5btdht_4krcp_11ServerError_1__init__ = {"__init__", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_5btdht_4krcp_11ServerError_1__init__, METH_VARARGS|METH_KEYWORDS, 0};
static PyObject *__pyx_pw_5btdht_4krcp_11ServerError_1__init__(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_self = 0;
  PyObject *__pyx_v_t = 0;
  PyObject *__pyx_v_msg = 0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__init__ (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_self,&__pyx_n_s_t,&__pyx_n_s_msg,0};
    PyObject* values[3] = {0,0,0};
    values[2] = ((PyObject *)((PyObject*)__pyx_kp_b_Server_Error));
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        CYTHON_FALLTHROUGH;
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_self)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_t)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("__init__", 0, 2, 3, 1); __PYX_ERR(0, 422, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  2:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_msg);
          if (value) { values[2] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__init__") < 0)) __PYX_ERR(0, 422, __pyx_L3_error)
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        CYTHON_FALLTHROUGH;
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    __pyx_v_self = values[0];
    __pyx_v_t = values[1];
    __pyx_v_msg = values[2];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("__init__", 0, 2, 3, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 422, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("btdht.krcp.ServerError.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_5btdht_4krcp_11ServerError___init__(__pyx_self, __pyx_v_self, __pyx_v_t, __pyx_v_msg);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5btdht_4krcp_11ServerError___init__(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_t, PyObject *__pyx_v_msg) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__init__", 0);

  /* "btdht/krcp.pyx":423
 *     """
 *     def __init__(self, t, msg=b"Server Error"):
 *         super(ServerError, self).__init__(t=t, e=[202, msg])             # <<<<<<<<<<<<<<
 * class ProtocolError(BError):
 *     """
 */
  __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_ServerError); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 423, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 423, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_GIVEREF(__pyx_t_1);
  PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_1);
  __Pyx_INCREF(__pyx_v_self);
  __Pyx_GIVEREF(__pyx_v_self);
  PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_v_self);
  __pyx_t_1 = 0;
  __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_super, __pyx_t_2, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 423, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_init); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 423, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = __Pyx_PyDict_NewPresized(2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 423, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_t, __pyx_v_t) < 0) __PYX_ERR(0, 423, __pyx_L1_error)
  __pyx_t_3 = PyList_New(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 423, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_INCREF(__pyx_int_202);
  __Pyx_GIVEREF(__pyx_int_202);
  PyList_SET_ITEM(__pyx_t_3, 0, __pyx_int_202);
  __Pyx_INCREF(__pyx_v_msg);
  __Pyx_GIVEREF(__pyx_v_msg);
  PyList_SET_ITEM(__pyx_t_3, 1, __pyx_v_msg);
  if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_e, __pyx_t_3) < 0) __PYX_ERR(0, 423, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_empty_tuple, __pyx_t_1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 423, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

  /* "btdht/krcp.pyx":422
 *         :param bytes msg: An optionnal error message
 *     """
 *     def __init__(self, t, msg=b"Server Error"):             # <<<<<<<<<<<<<<
 *         super(ServerError, self).__init__(t=t, e=[202, msg])
 * class ProtocolError(BError):
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("btdht.krcp.ServerError.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "btdht/krcp.pyx":432
 *         :param bytes msg: An optionnal error message
 *     """
 *     def __init__(self, t, msg=b"Protocol Error"):             # <<<<<<<<<<<<<<
 *         super(ProtocolError, self).__init__(t=t, e=[203, msg])
 * class MethodUnknownError(BError):
 */

/* Python wrapper */
static PyObject *__pyx_pw_5btdht_4krcp_13ProtocolError_1__init__(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyMethodDef __pyx_mdef_5btdht_4krcp_13ProtocolError_1__init__ = {"__init__", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_5btdht_4krcp_13ProtocolError_1__init__, METH_VARARGS|METH_KEYWORDS, 0};
static PyObject *__pyx_pw_5btdht_4krcp_13ProtocolError_1__init__(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_self = 0;
  PyObject *__pyx_v_t = 0;
  PyObject *__pyx_v_msg = 0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__init__ (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_self,&__pyx_n_s_t,&__pyx_n_s_msg,0};
    PyObject* values[3] = {0,0,0};
    values[2] = ((PyObject *)((PyObject*)__pyx_kp_b_Protocol_Error));
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        CYTHON_FALLTHROUGH;
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_self)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_t)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("__init__", 0, 2, 3, 1); __PYX_ERR(0, 432, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  2:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_msg);
          if (value) { values[2] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__init__") < 0)) __PYX_ERR(0, 432, __pyx_L3_error)
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        CYTHON_FALLTHROUGH;
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    __pyx_v_self = values[0];
    __pyx_v_t = values[1];
    __pyx_v_msg = values[2];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("__init__", 0, 2, 3, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 432, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("btdht.krcp.ProtocolError.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_5btdht_4krcp_13ProtocolError___init__(__pyx_self, __pyx_v_self, __pyx_v_t, __pyx_v_msg);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5btdht_4krcp_13ProtocolError___init__(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_t, PyObject *__pyx_v_msg) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__init__", 0);

  /* "btdht/krcp.pyx":433
 *     """
 *     def __init__(self, t, msg=b"Protocol Error"):
 *         super(ProtocolError, self).__init__(t=t, e=[203, msg])             # <<<<<<<<<<<<<<
 * class MethodUnknownError(BError):
 *     """
 */
  __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_ProtocolError); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 433, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 433, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_GIVEREF(__pyx_t_1);
  PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_1);
  __Pyx_INCREF(__pyx_v_self);
  __Pyx_GIVEREF(__pyx_v_self);
  PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_v_self);
  __pyx_t_1 = 0;
  __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_super, __pyx_t_2, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 433, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_init); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 433, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = __Pyx_PyDict_NewPresized(2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 433, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_t, __pyx_v_t) < 0) __PYX_ERR(0, 433, __pyx_L1_error)
  __pyx_t_3 = PyList_New(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 433, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_INCREF(__pyx_int_203);
  __Pyx_GIVEREF(__pyx_int_203);
  PyList_SET_ITEM(__pyx_t_3, 0, __pyx_int_203);
  __Pyx_INCREF(__pyx_v_msg);
  __Pyx_GIVEREF(__pyx_v_msg);
  PyList_SET_ITEM(__pyx_t_3, 1, __pyx_v_msg);
  if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_e, __pyx_t_3) < 0) __PYX_ERR(0, 433, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_empty_tuple, __pyx_t_1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 433, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

  /* "btdht/krcp.pyx":432
 *         :param bytes msg: An optionnal error message
 *     """
 *     def __init__(self, t, msg=b"Protocol Error"):             # <<<<<<<<<<<<<<
 *         super(ProtocolError, self).__init__(t=t, e=[203, msg])
 * class MethodUnknownError(BError):
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("btdht.krcp.ProtocolError.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "btdht/krcp.pyx":441
 *         :param bytes msg: An optionnal error message
 *     """
 *     def __init__(self, t, msg=b"Method Unknow"):             # <<<<<<<<<<<<<<
 *         super(MethodUnknownError, self).__init__(t=t, e=[204, msg])
 * 
 */

/* Python wrapper */
static PyObject *__pyx_pw_5btdht_4krcp_18MethodUnknownError_1__init__(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyMethodDef __pyx_mdef_5btdht_4krcp_18MethodUnknownError_1__init__ = {"__init__", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_5btdht_4krcp_18MethodUnknownError_1__init__, METH_VARARGS|METH_KEYWORDS, 0};
static PyObject *__pyx_pw_5btdht_4krcp_18MethodUnknownError_1__init__(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_self = 0;
  PyObject *__pyx_v_t = 0;
  PyObject *__pyx_v_msg = 0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__init__ (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_self,&__pyx_n_s_t,&__pyx_n_s_msg,0};
    PyObject* values[3] = {0,0,0};
    values[2] = ((PyObject *)((PyObject*)__pyx_kp_b_Method_Unknow));
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        CYTHON_FALLTHROUGH;
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_self)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_t)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("__init__", 0, 2, 3, 1); __PYX_ERR(0, 441, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  2:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_msg);
          if (value) { values[2] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__init__") < 0)) __PYX_ERR(0, 441, __pyx_L3_error)
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        CYTHON_FALLTHROUGH;
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    __pyx_v_self = values[0];
    __pyx_v_t = values[1];
    __pyx_v_msg = values[2];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("__init__", 0, 2, 3, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 441, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("btdht.krcp.MethodUnknownError.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_5btdht_4krcp_18MethodUnknownError___init__(__pyx_self, __pyx_v_self, __pyx_v_t, __pyx_v_msg);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5btdht_4krcp_18MethodUnknownError___init__(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_t, PyObject *__pyx_v_msg) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__init__", 0);

  /* "btdht/krcp.pyx":442
 *     """
 *     def __init__(self, t, msg=b"Method Unknow"):
 *         super(MethodUnknownError, self).__init__(t=t, e=[204, msg])             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_MethodUnknownError); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 442, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 442, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_GIVEREF(__pyx_t_1);
  PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_1);
  __Pyx_INCREF(__pyx_v_self);
  __Pyx_GIVEREF(__pyx_v_self);
  PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_v_self);
  __pyx_t_1 = 0;
  __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_super, __pyx_t_2, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 442, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_init); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 442, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = __Pyx_PyDict_NewPresized(2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 442, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_t, __pyx_v_t) < 0) __PYX_ERR(0, 442, __pyx_L1_error)
  __pyx_t_3 = PyList_New(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 442, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_INCREF(__pyx_int_204);
  __Pyx_GIVEREF(__pyx_int_204);
  PyList_SET_ITEM(__pyx_t_3, 0, __pyx_int_204);
  __Pyx_INCREF(__pyx_v_msg);
  __Pyx_GIVEREF(__pyx_v_msg);
  PyList_SET_ITEM(__pyx_t_3, 1, __pyx_v_msg);
  if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_e, __pyx_t_3) < 0) __PYX_ERR(0, 442, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_empty_tuple, __pyx_t_1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 442, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

  /* "btdht/krcp.pyx":441
 *         :param bytes msg: An optionnal error message
 *     """
 *     def __init__(self, t, msg=b"Method Unknow"):             # <<<<<<<<<<<<<<
 *         super(MethodUnknownError, self).__init__(t=t, e=[204, msg])
 * 
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("btdht.krcp.MethodUnknownError.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "btdht/krcp.pyx":497
 *             is totally optionnal in the protocol.
 *     """
 *     cdef int set_r(self, int value) nogil:             # <<<<<<<<<<<<<<
 *         """
 *             :param bool value: If ``True`` mark the current :class:`BMessage` as having a ``r`` dict
 */

static int __pyx_f_5btdht_4krcp_8BMessage_set_r(struct __pyx_obj_5btdht_4krcp_BMessage *__pyx_v_self, int __pyx_v_value) {
  int __pyx_r;

  /* "btdht/krcp.pyx":505
 *                 This method can be called without the python GIL
 *         """
 *         self.encoded_uptodate = False             # <<<<<<<<<<<<<<
 *         self.r = value
 *         return True
 */
  __pyx_v_self->encoded_uptodate = 0;

  /* "btdht/krcp.pyx":506
 *         """
 *         self.encoded_uptodate = False
 *         self.r = value             # <<<<<<<<<<<<<<
 *         return True
 * 
 */
  __pyx_v_self->r = __pyx_v_value;

  /* "btdht/krcp.pyx":507
 *         self.encoded_uptodate = False
 *         self.r = value
 *         return True             # <<<<<<<<<<<<<<
 * 
 *     cdef int set_a(self, int value) nogil:
 */
  __pyx_r = 1;
  goto __pyx_L0;

  /* "btdht/krcp.pyx":497
 *             is totally optionnal in the protocol.
 *     """
 *     cdef int set_r(self, int value) nogil:             # <<<<<<<<<<<<<<
 *         """
 *             :param bool value: If ``True`` mark the current :class:`BMessage` as having a ``r`` dict
 */

  /* function exit code */
  __pyx_L0:;
  return __pyx_r;
}

/* "btdht/krcp.pyx":509
 *         return True
 * 
 *     cdef int set_a(self, int value) nogil:             # <<<<<<<<<<<<<<
 *         """
 *             :param bool value: If ``True`` mark the current :class:`BMessage` as a ``a`` dict
 */

static int __pyx_f_5btdht_4krcp_8BMessage_set_a(struct __pyx_obj_5btdht_4krcp_BMessage *__pyx_v_self, int __pyx_v_value) {
  int __pyx_r;

  /* "btdht/krcp.pyx":517
 *                 This method can be called without the python GIL
 *         """
 *         self.encoded_uptodate = False             # <<<<<<<<<<<<<<
 *         self.a = value
 *         return True
 */
  __pyx_v_self->encoded_uptodate = 0;

  /* "btdht/krcp.pyx":518
 *         """
 *         self.encoded_uptodate = False
 *         self.a = value             # <<<<<<<<<<<<<<
 *         return True
 * 
 */
  __pyx_v_self->a = __pyx_v_value;

  /* "btdht/krcp.pyx":519
 *         self.encoded_uptodate = False
 *         self.a = value
 *         return True             # <<<<<<<<<<<<<<
 * 
 *     cdef int set_e(self, int value) nogil:
 */
  __pyx_r = 1;
  goto __pyx_L0;

  /* "btdht/krcp.pyx":509
 *         return True
 * 
 *     cdef int set_a(self, int value) nogil:             # <<<<<<<<<<<<<<
 *         """
 *             :param bool value: If ``True`` mark the current :class:`BMessage` as a ``a`` dict
 */

  /* function exit code */
  __pyx_L0:;
  return __pyx_r;
}

/* "btdht/krcp.pyx":521
 *         return True
 * 
 *     cdef int set_e(self, int value) nogil:             # <<<<<<<<<<<<<<
 *         """
 *             :param bool value: If ``True`` mark the current :class:`BMessage` as an error,
 */

static int __pyx_f_5btdht_4krcp_8BMessage_set_e(struct __pyx_obj_5btdht_4krcp_BMessage *__pyx_v_self, int __pyx_v_value) {
  int __pyx_r;

  /* "btdht/krcp.pyx":529
 *                 This method can be called without the python GIL
 *         """
 *         self.encoded_uptodate = False             # <<<<<<<<<<<<<<
 *         self.e = value
 *         return True
 */
  __pyx_v_self->encoded_uptodate = 0;

  /* "btdht/krcp.pyx":530
 *         """
 *         self.encoded_uptodate = False
 *         self.e = value             # <<<<<<<<<<<<<<
 *         return True
 * 
 */
  __pyx_v_self->e = __pyx_v_value;

  /* "btdht/krcp.pyx":531
 *         self.encoded_uptodate = False
 *         self.e = value
 *         return True             # <<<<<<<<<<<<<<
 * 
 *     cdef int set_t(self, char* value, int size) nogil:
 */
  __pyx_r = 1;
  goto __pyx_L0;

  /* "btdht/krcp.pyx":521
 *         return True
 * 
 *     cdef int set_e(self, int value) nogil:             # <<<<<<<<<<<<<<
 *         """
 *             :param bool value: If ``True`` mark the current :class:`BMessage` as an error,
 */

  /* function exit code */
  __pyx_L0:;
  return __pyx_r;
}

/* "btdht/krcp.pyx":533
 *         return True
 * 
 *     cdef int set_t(self, char* value, int size) nogil:             # <<<<<<<<<<<<<<
 *         """
 *             Set the ``t`` current message key to ``value``
 */

static int __pyx_f_5btdht_4krcp_8BMessage_set_t(struct __pyx_obj_5btdht_4krcp_BMessage *__pyx_v_self, char *__pyx_v_value, int __pyx_v_size) {
  int __pyx_r;
  int __pyx_t_1;

  /* "btdht/krcp.pyx":543
 *                 This method can be called without the python GIL
 *         """
 *         self.encoded_uptodate = False             # <<<<<<<<<<<<<<
 *         if self.has_t:
 *             free(self._t)
 */
  __pyx_v_self->encoded_uptodate = 0;

  /* "btdht/krcp.pyx":544
 *         """
 *         self.encoded_uptodate = False
 *         if self.has_t:             # <<<<<<<<<<<<<<
 *             free(self._t)
 *         else:
 */
  __pyx_t_1 = (__pyx_v_self->has_t != 0);
  if (__pyx_t_1) {

    /* "btdht/krcp.pyx":545
 *         self.encoded_uptodate = False
 *         if self.has_t:
 *             free(self._t)             # <<<<<<<<<<<<<<
 *         else:
 *             self.has_t = True
 */
    free(__pyx_v_self->_t);

    /* "btdht/krcp.pyx":544
 *         """
 *         self.encoded_uptodate = False
 *         if self.has_t:             # <<<<<<<<<<<<<<
 *             free(self._t)
 *         else:
 */
    goto __pyx_L3;
  }

  /* "btdht/krcp.pyx":547
 *             free(self._t)
 *         else:
 *             self.has_t = True             # <<<<<<<<<<<<<<
 *         self._t = <char*>malloc(size * sizeof(char))
 *         self.t_len = size
 */
  /*else*/ {
    __pyx_v_self->has_t = 1;
  }
  __pyx_L3:;

  /* "btdht/krcp.pyx":548
 *         else:
 *             self.has_t = True
 *         self._t = <char*>malloc(size * sizeof(char))             # <<<<<<<<<<<<<<
 *         self.t_len = size
 *         strncpy(self._t, value, size)
 */
  __pyx_v_self->_t = ((char *)malloc((__pyx_v_size * (sizeof(char)))));

  /* "btdht/krcp.pyx":549
 *             self.has_t = True
 *         self._t = <char*>malloc(size * sizeof(char))
 *         self.t_len = size             # <<<<<<<<<<<<<<
 *         strncpy(self._t, value, size)
 *         return True
 */
  __pyx_v_self->t_len = __pyx_v_size;

  /* "btdht/krcp.pyx":550
 *         self._t = <char*>malloc(size * sizeof(char))
 *         self.t_len = size
 *         strncpy(self._t, value, size)             # <<<<<<<<<<<<<<
 *         return True
 * 
 */
  (void)(strncpy(__pyx_v_self->_t, __pyx_v_value, __pyx_v_size));

  /* "btdht/krcp.pyx":551
 *         self.t_len = size
 *         strncpy(self._t, value, size)
 *         return True             # <<<<<<<<<<<<<<
 * 
 *     cdef void del_t(self) nogil:
 */
  __pyx_r = 1;
  goto __pyx_L0;

  /* "btdht/krcp.pyx":533
 *         return True
 * 
 *     cdef int set_t(self, char* value, int size) nogil:             # <<<<<<<<<<<<<<
 *         """
 *             Set the ``t`` current message key to ``value``
 */

  /* function exit code */
  __pyx_L0:;
  return __pyx_r;
}

/* "btdht/krcp.pyx":553
 *         return True
 * 
 *     cdef void del_t(self) nogil:             # <<<<<<<<<<<<<<
 *         """
 *             Unset the ``t`` current message key
 */

static void __pyx_f_5btdht_4krcp_8BMessage_del_t(struct __pyx_obj_5btdht_4krcp_BMessage *__pyx_v_self) {
  int __pyx_t_1;

  /* "btdht/krcp.pyx":560
 *                 This method can be called without the python GIL
 *         """
 *         if self.has_t:             # <<<<<<<<<<<<<<
 *             self.encoded_uptodate = False
 *             self.has_t = False
 */
  __pyx_t_1 = (__pyx_v_self->has_t != 0);
  if (__pyx_t_1) {

    /* "btdht/krcp.pyx":561
 *         """
 *         if self.has_t:
 *             self.encoded_uptodate = False             # <<<<<<<<<<<<<<
 *             self.has_t = False
 *             self.t_len = 0
 */
    __pyx_v_self->encoded_uptodate = 0;

    /* "btdht/krcp.pyx":562
 *         if self.has_t:
 *             self.encoded_uptodate = False
 *             self.has_t = False             # <<<<<<<<<<<<<<
 *             self.t_len = 0
 *             free(self._t)
 */
    __pyx_v_self->has_t = 0;

    /* "btdht/krcp.pyx":563
 *             self.encoded_uptodate = False
 *             self.has_t = False
 *             self.t_len = 0             # <<<<<<<<<<<<<<
 *             free(self._t)
 * 
 */
    __pyx_v_self->t_len = 0;

    /* "btdht/krcp.pyx":564
 *             self.has_t = False
 *             self.t_len = 0
 *             free(self._t)             # <<<<<<<<<<<<<<
 * 
 *     cdef int set_v(self, char* value, int size) nogil:
 */
    free(__pyx_v_self->_t);

    /* "btdht/krcp.pyx":560
 *                 This method can be called without the python GIL
 *         """
 *         if self.has_t:             # <<<<<<<<<<<<<<
 *             self.encoded_uptodate = False
 *             self.has_t = False
 */
  }

  /* "btdht/krcp.pyx":553
 *         return True
 * 
 *     cdef void del_t(self) nogil:             # <<<<<<<<<<<<<<
 *         """
 *             Unset the ``t`` current message key
 */

  /* function exit code */
}

/* "btdht/krcp.pyx":566
 *             free(self._t)
 * 
 *     cdef int set_v(self, char* value, int size) nogil:             # <<<<<<<<<<<<<<
 *         """
 *             Set the ``v`` current message key to ``value``
 */

static int __pyx_f_5btdht_4krcp_8BMessage_set_v(struct __pyx_obj_5btdht_4krcp_BMessage *__pyx_v_self, char *__pyx_v_value, int __pyx_v_size) {
  int __pyx_r;
  int __pyx_t_1;

  /* "btdht/krcp.pyx":576
 *                 This method can be called without the python GIL
 *         """
 *         self.encoded_uptodate = False             # <<<<<<<<<<<<<<
 *         if self.has_v:
 *             free(self._v)
 */
  __pyx_v_self->encoded_uptodate = 0;

  /* "btdht/krcp.pyx":577
 *         """
 *         self.encoded_uptodate = False
 *         if self.has_v:             # <<<<<<<<<<<<<<
 *             free(self._v)
 *         else:
 */
  __pyx_t_1 = (__pyx_v_self->has_v != 0);
  if (__pyx_t_1) {

    /* "btdht/krcp.pyx":578
 *         self.encoded_uptodate = False
 *         if self.has_v:
 *             free(self._v)             # <<<<<<<<<<<<<<
 *         else:
 *             self.has_v = True
 */
    free(__pyx_v_self->_v);

    /* "btdht/krcp.pyx":577
 *         """
 *         self.encoded_uptodate = False
 *         if self.has_v:             # <<<<<<<<<<<<<<
 *             free(self._v)
 *         else:
 */
    goto __pyx_L3;
  }

  /* "btdht/krcp.pyx":580
 *             free(self._v)
 *         else:
 *             self.has_v = True             # <<<<<<<<<<<<<<
 *         self._v = <char*>malloc(size * sizeof(char))
 *         self.v_len = size
 */
  /*else*/ {
    __pyx_v_self->has_v = 1;
  }
  __pyx_L3:;

  /* "btdht/krcp.pyx":581
 *         else:
 *             self.has_v = True
 *         self._v = <char*>malloc(size * sizeof(char))             # <<<<<<<<<<<<<<
 *         self.v_len = size
 *         strncpy(self._v, value, size)
 */
  __pyx_v_self->_v = ((char *)malloc((__pyx_v_size * (sizeof(char)))));

  /* "btdht/krcp.pyx":582
 *             self.has_v = True
 *         self._v = <char*>malloc(size * sizeof(char))
 *         self.v_len = size             # <<<<<<<<<<<<<<
 *         strncpy(self._v, value, size)
 *         return True
 */
  __pyx_v_self->v_len = __pyx_v_size;

  /* "btdht/krcp.pyx":583
 *         self._v = <char*>malloc(size * sizeof(char))
 *         self.v_len = size
 *         strncpy(self._v, value, size)             # <<<<<<<<<<<<<<
 *         return True
 * 
 */
  (void)(strncpy(__pyx_v_self->_v, __pyx_v_value, __pyx_v_size));

  /* "btdht/krcp.pyx":584
 *         self.v_len = size
 *         strncpy(self._v, value, size)
 *         return True             # <<<<<<<<<<<<<<
 * 
 *     cdef void del_v(self) nogil:
 */
  __pyx_r = 1;
  goto __pyx_L0;

  /* "btdht/krcp.pyx":566
 *             free(self._t)
 * 
 *     cdef int set_v(self, char* value, int size) nogil:             # <<<<<<<<<<<<<<
 *         """
 *             Set the ``v`` current message key to ``value``
 */

  /* function exit code */
  __pyx_L0:;
  return __pyx_r;
}

/* "btdht/krcp.pyx":586
 *         return True
 * 
 *     cdef void del_v(self) nogil:             # <<<<<<<<<<<<<<
 *         """
 *             Unset the ``v`` current message key
 */

static void __pyx_f_5btdht_4krcp_8BMessage_del_v(struct __pyx_obj_5btdht_4krcp_BMessage *__pyx_v_self) {
  int __pyx_t_1;

  /* "btdht/krcp.pyx":593
 *                 This method can be called without the python GIL
 *         """
 *         if self.has_v:             # <<<<<<<<<<<<<<
 *             self.encoded_uptodate = False
 *             self.has_v = False
 */
  __pyx_t_1 = (__pyx_v_self->has_v != 0);
  if (__pyx_t_1) {

    /* "btdht/krcp.pyx":594
 *         """
 *         if self.has_v:
 *             self.encoded_uptodate = False             # <<<<<<<<<<<<<<
 *             self.has_v = False
 *             self.v_len = 0
 */
    __pyx_v_self->encoded_uptodate = 0;

    /* "btdht/krcp.pyx":595
 *         if self.has_v:
 *             self.encoded_uptodate = False
 *             self.has_v = False             # <<<<<<<<<<<<<<
 *             self.v_len = 0
 *             free(self._v)
 */
    __pyx_v_self->has_v = 0;

    /* "btdht/krcp.pyx":596
 *             self.encoded_uptodate = False
 *             self.has_v = False
 *             self.v_len = 0             # <<<<<<<<<<<<<<
 *             free(self._v)
 * 
 */
    __pyx_v_self->v_len = 0;

    /* "btdht/krcp.pyx":597
 *             self.has_v = False
 *             self.v_len = 0
 *             free(self._v)             # <<<<<<<<<<<<<<
 * 
 *     cdef int set_y(self, char* value, int size) nogil:
 */
    free(__pyx_v_self->_v);

    /* "btdht/krcp.pyx":593
 *                 This method can be called without the python GIL
 *         """
 *         if self.has_v:             # <<<<<<<<<<<<<<
 *             self.encoded_uptodate = False
 *             self.has_v = False
 */
  }

  /* "btdht/krcp.pyx":586
 *         return True
 * 
 *     cdef void del_v(self) nogil:             # <<<<<<<<<<<<<<
 *         """
 *             Unset the ``v`` current message key
 */

  /* function exit code */
}

/* "btdht/krcp.pyx":599
 *             free(self._v)
 * 
 *     cdef int set_y(self, char* value, int size) nogil:             # <<<<<<<<<<<<<<
 *         """
 *             Set the ``y`` current message key to ``value``
 */

static int __pyx_f_5btdht_4krcp_8BMessage_set_y(struct __pyx_obj_5btdht_4krcp_BMessage *__pyx_v_self, char *__pyx_v_value, int __pyx_v_size) {
  int __pyx_r;
  int __pyx_t_1;

  /* "btdht/krcp.pyx":609
 *                 This method can be called without the python GIL
 *         """
 *         self.encoded_uptodate = False             # <<<<<<<<<<<<<<
 *         if self.has_y:
 *             free(self._y)
 */
  __pyx_v_self->encoded_uptodate = 0;

  /* "btdht/krcp.pyx":610
 *         """
 *         self.encoded_uptodate = False
 *         if self.has_y:             # <<<<<<<<<<<<<<
 *             free(self._y)
 *         else:
 */
  __pyx_t_1 = (__pyx_v_self->has_y != 0);
  if (__pyx_t_1) {

    /* "btdht/krcp.pyx":611
 *         self.encoded_uptodate = False
 *         if self.has_y:
 *             free(self._y)             # <<<<<<<<<<<<<<
 *         else:
 *             self.has_y = True
 */
    free(__pyx_v_self->_y);

    /* "btdht/krcp.pyx":610
 *         """
 *         self.encoded_uptodate = False
 *         if self.has_y:             # <<<<<<<<<<<<<<
 *             free(self._y)
 *         else:
 */
    goto __pyx_L3;
  }

  /* "btdht/krcp.pyx":613
 *             free(self._y)
 *         else:
 *             self.has_y = True             # <<<<<<<<<<<<<<
 *         self._y = <char*>malloc(size * sizeof(char))
 *         self.y_len = size
 */
  /*else*/ {
    __pyx_v_self->has_y = 1;
  }
  __pyx_L3:;

  /* "btdht/krcp.pyx":614
 *         else:
 *             self.has_y = True
 *         self._y = <char*>malloc(size * sizeof(char))             # <<<<<<<<<<<<<<
 *         self.y_len = size
 *         strncpy(self._y, value, size)
 */
  __pyx_v_self->_y = ((char *)malloc((__pyx_v_size * (sizeof(char)))));

  /* "btdht/krcp.pyx":615
 *             self.has_y = True
 *         self._y = <char*>malloc(size * sizeof(char))
 *         self.y_len = size             # <<<<<<<<<<<<<<
 *         strncpy(self._y, value, size)
 *         return True
 */
  __pyx_v_self->y_len = __pyx_v_size;

  /* "btdht/krcp.pyx":616
 *         self._y = <char*>malloc(size * sizeof(char))
 *         self.y_len = size
 *         strncpy(self._y, value, size)             # <<<<<<<<<<<<<<
 *         return True
 * 
 */
  (void)(strncpy(__pyx_v_self->_y, __pyx_v_value, __pyx_v_size));

  /* "btdht/krcp.pyx":617
 *         self.y_len = size
 *         strncpy(self._y, value, size)
 *         return True             # <<<<<<<<<<<<<<
 * 
 *     cdef void del_y(self) nogil:
 */
  __pyx_r = 1;
  goto __pyx_L0;

  /* "btdht/krcp.pyx":599
 *             free(self._v)
 * 
 *     cdef int set_y(self, char* value, int size) nogil:             # <<<<<<<<<<<<<<
 *         """
 *             Set the ``y`` current message key to ``value``
 */

  /* function exit code */
  __pyx_L0:;
  return __pyx_r;
}

/* "btdht/krcp.pyx":619
 *         return True
 * 
 *     cdef void del_y(self) nogil:             # <<<<<<<<<<<<<<
 *         """
 *             Unset the ``y`` current message key
 */

static void __pyx_f_5btdht_4krcp_8BMessage_del_y(struct __pyx_obj_5btdht_4krcp_BMessage *__pyx_v_self) {
  int __pyx_t_1;

  /* "btdht/krcp.pyx":626
 *                 This method can be called without the python GIL
 *         """
 *         if self.has_y:             # <<<<<<<<<<<<<<
 *             self.encoded_uptodate = False
 *             self.has_y = False
 */
  __pyx_t_1 = (__pyx_v_self->has_y != 0);
  if (__pyx_t_1) {

    /* "btdht/krcp.pyx":627
 *         """
 *         if self.has_y:
 *             self.encoded_uptodate = False             # <<<<<<<<<<<<<<
 *             self.has_y = False
 *             self.y_len = 0
 */
    __pyx_v_self->encoded_uptodate = 0;

    /* "btdht/krcp.pyx":628
 *         if self.has_y:
 *             self.encoded_uptodate = False
 *             self.has_y = False             # <<<<<<<<<<<<<<
 *             self.y_len = 0
 *             free(self._y)
 */
    __pyx_v_self->has_y = 0;

    /* "btdht/krcp.pyx":629
 *             self.encoded_uptodate = False
 *             self.has_y = False
 *             self.y_len = 0             # <<<<<<<<<<<<<<
 *             free(self._y)
 * 
 */
    __pyx_v_self->y_len = 0;

    /* "btdht/krcp.pyx":630
 *             self.has_y = False
 *             self.y_len = 0
 *             free(self._y)             # <<<<<<<<<<<<<<
 * 
 *     cdef int set_q(self, char* value, int size) nogil:
 */
    free(__pyx_v_self->_y);

    /* "btdht/krcp.pyx":626
 *                 This method can be called without the python GIL
 *         """
 *         if self.has_y:             # <<<<<<<<<<<<<<
 *             self.encoded_uptodate = False
 *             self.has_y = False
 */
  }

  /* "btdht/krcp.pyx":619
 *         return True
 * 
 *     cdef void del_y(self) nogil:             # <<<<<<<<<<<<<<
 *         """
 *             Unset the ``y`` current message key
 */

  /* function exit code */
}

/* "btdht/krcp.pyx":632
 *             free(self._y)
 * 
 *     cdef int set_q(self, char* value, int size) nogil:             # <<<<<<<<<<<<<<
 *         """
 *             Set the ``q`` current message key to ``value``
 */

static int __pyx_f_5btdht_4krcp_8BMessage_set_q(struct __pyx_obj_5btdht_4krcp_BMessage *__pyx_v_self, char *__pyx_v_value, int __pyx_v_size) {
  int __pyx_r;
  int __pyx_t_1;

  /* "btdht/krcp.pyx":642
 *                 This method can be called without the python GIL
 *         """
 *         self.encoded_uptodate = False             # <<<<<<<<<<<<<<
 *         if self.has_q:
 *             free(self._q)
 */
  __pyx_v_self->encoded_uptodate = 0;

  /* "btdht/krcp.pyx":643
 *         """
 *         self.encoded_uptodate = False
 *         if self.has_q:             # <<<<<<<<<<<<<<
 *             free(self._q)
 *         else:
 */
  __pyx_t_1 = (__pyx_v_self->has_q != 0);
  if (__pyx_t_1) {

    /* "btdht/krcp.pyx":644
 *         self.encoded_uptodate = False
 *         if self.has_q:
 *             free(self._q)             # <<<<<<<<<<<<<<
 *         else:
 *             self.has_q = True
 */
    free(__pyx_v_self->_q);

    /* "btdht/krcp.pyx":643
 *         """
 *         self.encoded_uptodate = False
 *         if self.has_q:             # <<<<<<<<<<<<<<
 *             free(self._q)
 *         else:
 */
    goto __pyx_L3;
  }

  /* "btdht/krcp.pyx":646
 *             free(self._q)
 *         else:
 *             self.has_q = True             # <<<<<<<<<<<<<<
 *         self._q = <char*>malloc(size * sizeof(char))
 *         self.q_len = size
 */
  /*else*/ {
    __pyx_v_self->has_q = 1;
  }
  __pyx_L3:;

  /* "btdht/krcp.pyx":647
 *         else:
 *             self.has_q = True
 *         self._q = <char*>malloc(size * sizeof(char))             # <<<<<<<<<<<<<<
 *         self.q_len = size
 *         strncpy(self._q, value, size)
 */
  __pyx_v_self->_q = ((char *)malloc((__pyx_v_size * (sizeof(char)))));

  /* "btdht/krcp.pyx":648
 *             self.has_q = True
 *         self._q = <char*>malloc(size * sizeof(char))
 *         self.q_len = size             # <<<<<<<<<<<<<<
 *         strncpy(self._q, value, size)
 *         return True
 */
  __pyx_v_self->q_len = __pyx_v_size;

  /* "btdht/krcp.pyx":649
 *         self._q = <char*>malloc(size * sizeof(char))
 *         self.q_len = size
 *         strncpy(self._q, value, size)             # <<<<<<<<<<<<<<
 *         return True
 * 
 */
  (void)(strncpy(__pyx_v_self->_q, __pyx_v_value, __pyx_v_size));

  /* "btdht/krcp.pyx":650
 *         self.q_len = size
 *         strncpy(self._q, value, size)
 *         return True             # <<<<<<<<<<<<<<
 * 
 *     cdef void del_q(self) nogil:
 */
  __pyx_r = 1;
  goto __pyx_L0;

  /* "btdht/krcp.pyx":632
 *             free(self._y)
 * 
 *     cdef int set_q(self, char* value, int size) nogil:             # <<<<<<<<<<<<<<
 *         """
 *             Set the ``q`` current message key to ``value``
 */

  /* function exit code */
  __pyx_L0:;
  return __pyx_r;
}

/* "btdht/krcp.pyx":652
 *         return True
 * 
 *     cdef void del_q(self) nogil:             # <<<<<<<<<<<<<<
 *         """
 *             Unset the ``q`` current message key
 */

static void __pyx_f_5btdht_4krcp_8BMessage_del_q(struct __pyx_obj_5btdht_4krcp_BMessage *__pyx_v_self) {
  int __pyx_t_1;

  /* "btdht/krcp.pyx":659
 *                 This method can be called without the python GIL
 *         """
 *         if self.has_q:             # <<<<<<<<<<<<<<
 *             self.encoded_uptodate = False
 *             self.has_q = False
 */
  __pyx_t_1 = (__pyx_v_self->has_q != 0);
  if (__pyx_t_1) {

    /* "btdht/krcp.pyx":660
 *         """
 *         if self.has_q:
 *             self.encoded_uptodate = False             # <<<<<<<<<<<<<<
 *             self.has_q = False
 *             self.q_len = 0
 */
    __pyx_v_self->encoded_uptodate = 0;

    /* "btdht/krcp.pyx":661
 *         if self.has_q:
 *             self.encoded_uptodate = False
 *             self.has_q = False             # <<<<<<<<<<<<<<
 *             self.q_len = 0
 *             free(self._q)
 */
    __pyx_v_self->has_q = 0;

    /* "btdht/krcp.pyx":662
 *             self.encoded_uptodate = False
 *             self.has_q = False
 *             self.q_len = 0             # <<<<<<<<<<<<<<
 *             free(self._q)
 * 
 */
    __pyx_v_self->q_len = 0;

    /* "btdht/krcp.pyx":663
 *             self.has_q = False
 *             self.q_len = 0
 *             free(self._q)             # <<<<<<<<<<<<<<
 * 
 *     cdef int set_id(self, char* value, int size) nogil except -1:
 */
    free(__pyx_v_self->_q);

    /* "btdht/krcp.pyx":659
 *                 This method can be called without the python GIL
 *         """
 *         if self.has_q:             # <<<<<<<<<<<<<<
 *             self.encoded_uptodate = False
 *             self.has_q = False
 */
  }

  /* "btdht/krcp.pyx":652
 *         return True
 * 
 *     cdef void del_q(self) nogil:             # <<<<<<<<<<<<<<
 *         """
 *             Unset the ``q`` current message key
 */

  /* function exit code */
}

/* "btdht/krcp.pyx":665
 *             free(self._q)
 * 
 *     cdef int set_id(self, char* value, int size) nogil except -1:             # <<<<<<<<<<<<<<
 *         """
 *             Set the id of the message
 */

static int __pyx_f_5btdht_4krcp_8BMessage_set_id(struct __pyx_obj_5btdht_4krcp_BMessage *__pyx_v_self, char *__pyx_v_value, int __pyx_v_size) {
  int __pyx_r;
  int __pyx_t_1;

  /* "btdht/krcp.pyx":675
 *                 This method can be called without the python GIL
 *         """
 *         self.encoded_uptodate = False             # <<<<<<<<<<<<<<
 *         if self.has_id:
 *             free(self.id)
 */
  __pyx_v_self->encoded_uptodate = 0;

  /* "btdht/krcp.pyx":676
 *         """
 *         self.encoded_uptodate = False
 *         if self.has_id:             # <<<<<<<<<<<<<<
 *             free(self.id)
 *         else:
 */
  __pyx_t_1 = (__pyx_v_self->has_id != 0);
  if (__pyx_t_1) {

    /* "btdht/krcp.pyx":677
 *         self.encoded_uptodate = False
 *         if self.has_id:
 *             free(self.id)             # <<<<<<<<<<<<<<
 *         else:
 *             self.has_id = True
 */
    free(__pyx_v_self->id);

    /* "btdht/krcp.pyx":676
 *         """
 *         self.encoded_uptodate = False
 *         if self.has_id:             # <<<<<<<<<<<<<<
 *             free(self.id)
 *         else:
 */
    goto __pyx_L3;
  }

  /* "btdht/krcp.pyx":679
 *             free(self.id)
 *         else:
 *             self.has_id = True             # <<<<<<<<<<<<<<
 *         self.id = <char*>malloc(size * sizeof(char))
 *         strncpy(self.id, value, size)
 */
  /*else*/ {
    __pyx_v_self->has_id = 1;
  }
  __pyx_L3:;

  /* "btdht/krcp.pyx":680
 *         else:
 *             self.has_id = True
 *         self.id = <char*>malloc(size * sizeof(char))             # <<<<<<<<<<<<<<
 *         strncpy(self.id, value, size)
 *         return True
 */
  __pyx_v_self->id = ((char *)malloc((__pyx_v_size * (sizeof(char)))));

  /* "btdht/krcp.pyx":681
 *             self.has_id = True
 *         self.id = <char*>malloc(size * sizeof(char))
 *         strncpy(self.id, value, size)             # <<<<<<<<<<<<<<
 *         return True
 * 
 */
  (void)(strncpy(__pyx_v_self->id, __pyx_v_value, __pyx_v_size));

  /* "btdht/krcp.pyx":682
 *         self.id = <char*>malloc(size * sizeof(char))
 *         strncpy(self.id, value, size)
 *         return True             # <<<<<<<<<<<<<<
 * 
 *     cdef void del_id(self) nogil:
 */
  __pyx_r = 1;
  goto __pyx_L0;

  /* "btdht/krcp.pyx":665
 *             free(self._q)
 * 
 *     cdef int set_id(self, char* value, int size) nogil except -1:             # <<<<<<<<<<<<<<
 *         """
 *             Set the id of the message
 */

  /* function exit code */
  __pyx_L0:;
  return __pyx_r;
}

/* "btdht/krcp.pyx":684
 *         return True
 * 
 *     cdef void del_id(self) nogil:             # <<<<<<<<<<<<<<
 *         """
 *             Unset the id of the message
 */

static void __pyx_f_5btdht_4krcp_8BMessage_del_id(struct __pyx_obj_5btdht_4krcp_BMessage *__pyx_v_self) {
  int __pyx_t_1;

  /* "btdht/krcp.pyx":691
 *                 This method can be called without the python GIL
 *         """
 *         if self.has_id:             # <<<<<<<<<<<<<<
 *             self.encoded_uptodate = False
 *             self.has_id = False
 */
  __pyx_t_1 = (__pyx_v_self->has_id != 0);
  if (__pyx_t_1) {

    /* "btdht/krcp.pyx":692
 *         """
 *         if self.has_id:
 *             self.encoded_uptodate = False             # <<<<<<<<<<<<<<
 *             self.has_id = False
 *             free(self.id)
 */
    __pyx_v_self->encoded_uptodate = 0;

    /* "btdht/krcp.pyx":693
 *         if self.has_id:
 *             self.encoded_uptodate = False
 *             self.has_id = False             # <<<<<<<<<<<<<<
 *             free(self.id)
 * 
 */
    __pyx_v_self->has_id = 0;

    /* "btdht/krcp.pyx":694
 *             self.encoded_uptodate = False
 *             self.has_id = False
 *             free(self.id)             # <<<<<<<<<<<<<<
 * 
 *     cdef int set_target(self, char* value, int size) nogil except -1:
 */
    free(__pyx_v_self->id);

    /* "btdht/krcp.pyx":691
 *                 This method can be called without the python GIL
 *         """
 *         if self.has_id:             # <<<<<<<<<<<<<<
 *             self.encoded_uptodate = False
 *             self.has_id = False
 */
  }

  /* "btdht/krcp.pyx":684
 *         return True
 * 
 *     cdef void del_id(self) nogil:             # <<<<<<<<<<<<<<
 *         """
 *             Unset the id of the message
 */

  /* function exit code */
}

/* "btdht/krcp.pyx":696
 *             free(self.id)
 * 
 *     cdef int set_target(self, char* value, int size) nogil except -1:             # <<<<<<<<<<<<<<
 *         """
 *             Set the target of the message
 */

static int __pyx_f_5btdht_4krcp_8BMessage_set_target(struct __pyx_obj_5btdht_4krcp_BMessage *__pyx_v_self, char *__pyx_v_value, int __pyx_v_size) {
  int __pyx_r;
  int __pyx_t_1;

  /* "btdht/krcp.pyx":706
 *                 This method can be called without the python GIL
 *         """
 *         self.encoded_uptodate = False             # <<<<<<<<<<<<<<
 *         if self.has_target:
 *             free(self.target)
 */
  __pyx_v_self->encoded_uptodate = 0;

  /* "btdht/krcp.pyx":707
 *         """
 *         self.encoded_uptodate = False
 *         if self.has_target:             # <<<<<<<<<<<<<<
 *             free(self.target)
 *         else:
 */
  __pyx_t_1 = (__pyx_v_self->has_target != 0);
  if (__pyx_t_1) {

    /* "btdht/krcp.pyx":708
 *         self.encoded_uptodate = False
 *         if self.has_target:
 *             free(self.target)             # <<<<<<<<<<<<<<
 *         else:
 *             self.has_target = True
 */
    free(__pyx_v_self->target);

    /* "btdht/krcp.pyx":707
 *         """
 *         self.encoded_uptodate = False
 *         if self.has_target:             # <<<<<<<<<<<<<<
 *             free(self.target)
 *         else:
 */
    goto __pyx_L3;
  }

  /* "btdht/krcp.pyx":710
 *             free(self.target)
 *         else:
 *             self.has_target = True             # <<<<<<<<<<<<<<
 *         self.target = <char*>malloc(size * sizeof(char))
 *         strncpy(self.target, value, size)
 */
  /*else*/ {
    __pyx_v_self->has_target = 1;
  }
  __pyx_L3:;

  /* "btdht/krcp.pyx":711
 *         else:
 *             self.has_target = True
 *         self.target = <char*>malloc(size * sizeof(char))             # <<<<<<<<<<<<<<
 *         strncpy(self.target, value, size)
 *         return True
 */
  __pyx_v_self->target = ((char *)malloc((__pyx_v_size * (sizeof(char)))));

  /* "btdht/krcp.pyx":712
 *             self.has_target = True
 *         self.target = <char*>malloc(size * sizeof(char))
 *         strncpy(self.target, value, size)             # <<<<<<<<<<<<<<
 *         return True
 * 
 */
  (void)(strncpy(__pyx_v_self->target, __pyx_v_value, __pyx_v_size));

  /* "btdht/krcp.pyx":713
 *         self.target = <char*>malloc(size * sizeof(char))
 *         strncpy(self.target, value, size)
 *         return True             # <<<<<<<<<<<<<<
 * 
 *     cdef void del_target(self) nogil:
 */
  __pyx_r = 1;
  goto __pyx_L0;

  /* "btdht/krcp.pyx":696
 *             free(self.id)
 * 
 *     cdef int set_target(self, char* value, int size) nogil except -1:             # <<<<<<<<<<<<<<
 *         """
 *             Set the target of the message
 */

  /* function exit code */
  __pyx_L0:;
  return __pyx_r;
}

/* "btdht/krcp.pyx":715
 *         return True
 * 
 *     cdef void del_target(self) nogil:             # <<<<<<<<<<<<<<
 *         """
 *             Unset the target of the message
 */

static void __pyx_f_5btdht_4krcp_8BMessage_del_target(struct __pyx_obj_5btdht_4krcp_BMessage *__pyx_v_self) {
  int __pyx_t_1;

  /* "btdht/krcp.pyx":722
 *                 This method can be called without the python GIL
 *         """
 *         if self.has_target:             # <<<<<<<<<<<<<<
 *             self.has_target = False
 *             self.encoded_uptodate = False
 */
  __pyx_t_1 = (__pyx_v_self->has_target != 0);
  if (__pyx_t_1) {

    /* "btdht/krcp.pyx":723
 *         """
 *         if self.has_target:
 *             self.has_target = False             # <<<<<<<<<<<<<<
 *             self.encoded_uptodate = False
 *             free(self.target)
 */
    __pyx_v_self->has_target = 0;

    /* "btdht/krcp.pyx":724
 *         if self.has_target:
 *             self.has_target = False
 *             self.encoded_uptodate = False             # <<<<<<<<<<<<<<
 *             free(self.target)
 * 
 */
    __pyx_v_self->encoded_uptodate = 0;

    /* "btdht/krcp.pyx":725
 *             self.has_target = False
 *             self.encoded_uptodate = False
 *             free(self.target)             # <<<<<<<<<<<<<<
 * 
 *     cdef int set_info_hash(self, char* value, int size) nogil except -1:
 */
    free(__pyx_v_self->target);

    /* "btdht/krcp.pyx":722
 *                 This method can be called without the python GIL
 *         """
 *         if self.has_target:             # <<<<<<<<<<<<<<
 *             self.has_target = False
 *             self.encoded_uptodate = False
 */
  }

  /* "btdht/krcp.pyx":715
 *         return True
 * 
 *     cdef void del_target(self) nogil:             # <<<<<<<<<<<<<<
 *         """
 *             Unset the target of the message
 */

  /* function exit code */
}

/* "btdht/krcp.pyx":727
 *             free(self.target)
 * 
 *     cdef int set_info_hash(self, char* value, int size) nogil except -1:             # <<<<<<<<<<<<<<
 *         """
 *             Set the info_hash of the message
 */

static int __pyx_f_5btdht_4krcp_8BMessage_set_info_hash(struct __pyx_obj_5btdht_4krcp_BMessage *__pyx_v_self, char *__pyx_v_value, int __pyx_v_size) {
  int __pyx_r;
  int __pyx_t_1;

  /* "btdht/krcp.pyx":737
 *                 This method can be called without the python GIL
 *         """
 *         self.encoded_uptodate = False             # <<<<<<<<<<<<<<
 *         if self.has_info_hash:
 *             free(self.info_hash)
 */
  __pyx_v_self->encoded_uptodate = 0;

  /* "btdht/krcp.pyx":738
 *         """
 *         self.encoded_uptodate = False
 *         if self.has_info_hash:             # <<<<<<<<<<<<<<
 *             free(self.info_hash)
 *         else:
 */
  __pyx_t_1 = (__pyx_v_self->has_info_hash != 0);
  if (__pyx_t_1) {

    /* "btdht/krcp.pyx":739
 *         self.encoded_uptodate = False
 *         if self.has_info_hash:
 *             free(self.info_hash)             # <<<<<<<<<<<<<<
 *         else:
 *             self.has_info_hash = True
 */
    free(__pyx_v_self->info_hash);

    /* "btdht/krcp.pyx":738
 *         """
 *         self.encoded_uptodate = False
 *         if self.has_info_hash:             # <<<<<<<<<<<<<<
 *             free(self.info_hash)
 *         else:
 */
    goto __pyx_L3;
  }

  /* "btdht/krcp.pyx":741
 *             free(self.info_hash)
 *         else:
 *             self.has_info_hash = True             # <<<<<<<<<<<<<<
 *         self.info_hash = <char*>malloc(size * sizeof(char))
 *         strncpy(self.info_hash, value, size)
 */
  /*else*/ {
    __pyx_v_self->has_info_hash = 1;
  }
  __pyx_L3:;

  /* "btdht/krcp.pyx":742
 *         else:
 *             self.has_info_hash = True
 *         self.info_hash = <char*>malloc(size * sizeof(char))             # <<<<<<<<<<<<<<
 *         strncpy(self.info_hash, value, size)
 *         return True
 */
  __pyx_v_self->info_hash = ((char *)malloc((__pyx_v_size * (sizeof(char)))));

  /* "btdht/krcp.pyx":743
 *             self.has_info_hash = True
 *         self.info_hash = <char*>malloc(size * sizeof(char))
 *         strncpy(self.info_hash, value, size)             # <<<<<<<<<<<<<<
 *         return True
 * 
 */
  (void)(strncpy(__pyx_v_self->info_hash, __pyx_v_value, __pyx_v_size));

  /* "btdht/krcp.pyx":744
 *         self.info_hash = <char*>malloc(size * sizeof(char))
 *         strncpy(self.info_hash, value, size)
 *         return True             # <<<<<<<<<<<<<<
 * 
 *     cdef void del_info_hash(self) nogil:
 */
  __pyx_r = 1;
  goto __pyx_L0;

  /* "btdht/krcp.pyx":727
 *             free(self.target)
 * 
 *     cdef int set_info_hash(self, char* value, int size) nogil except -1:             # <<<<<<<<<<<<<<
 *         """
 *             Set the info_hash of the message
 */

  /* function exit code */
  __pyx_L0:;
  return __pyx_r;
}

/* "btdht/krcp.pyx":746
 *         return True
 * 
 *     cdef void del_info_hash(self) nogil:             # <<<<<<<<<<<<<<
 *         """
 *             Unset the info_hash of the message
 */

static void __pyx_f_5btdht_4krcp_8BMessage_del_info_hash(struct __pyx_obj_5btdht_4krcp_BMessage *__pyx_v_self) {
  int __pyx_t_1;

  /* "btdht/krcp.pyx":753
 *                 This method can be called without the python GIL
 *         """
 *         if self.has_info_hash:             # <<<<<<<<<<<<<<
 *             self.has_info_hash = False
 *             self.encoded_uptodate = False
 */
  __pyx_t_1 = (__pyx_v_self->has_info_hash != 0);
  if (__pyx_t_1) {

    /* "btdht/krcp.pyx":754
 *         """
 *         if self.has_info_hash:
 *             self.has_info_hash = False             # <<<<<<<<<<<<<<
 *             self.encoded_uptodate = False
 *             free(self.info_hash)
 */
    __pyx_v_self->has_info_hash = 0;

    /* "btdht/krcp.pyx":755
 *         if self.has_info_hash:
 *             self.has_info_hash = False
 *             self.encoded_uptodate = False             # <<<<<<<<<<<<<<
 *             free(self.info_hash)
 * 
 */
    __pyx_v_self->encoded_uptodate = 0;

    /* "btdht/krcp.pyx":756
 *             self.has_info_hash = False
 *             self.encoded_uptodate = False
 *             free(self.info_hash)             # <<<<<<<<<<<<<<
 * 
 *     cdef void del_implied_port(self) nogil:
 */
    free(__pyx_v_self->info_hash);

    /* "btdht/krcp.pyx":753
 *                 This method can be called without the python GIL
 *         """
 *         if self.has_info_hash:             # <<<<<<<<<<<<<<
 *             self.has_info_hash = False
 *             self.encoded_uptodate = False
 */
  }

  /* "btdht/krcp.pyx":746
 *         return True
 * 
 *     cdef void del_info_hash(self) nogil:             # <<<<<<<<<<<<<<
 *         """
 *             Unset the info_hash of the message
 */

  /* function exit code */
}

/* "btdht/krcp.pyx":758
 *             free(self.info_hash)
 * 
 *     cdef void del_implied_port(self) nogil:             # <<<<<<<<<<<<<<
 *         """
 *             Unset implied_port
 */

static void __pyx_f_5btdht_4krcp_8BMessage_del_implied_port(struct __pyx_obj_5btdht_4krcp_BMessage *__pyx_v_self) {

  /* "btdht/krcp.pyx":765
 *                 This method can be called without the python GIL
 *         """
 *         self.has_implied_port = False             # <<<<<<<<<<<<<<
 *         self.encoded_uptodate = False
 * 
 */
  __pyx_v_self->has_implied_port = 0;

  /* "btdht/krcp.pyx":766
 *         """
 *         self.has_implied_port = False
 *         self.encoded_uptodate = False             # <<<<<<<<<<<<<<
 * 
 *     cdef int set_implied_port(self, int value) nogil:
 */
  __pyx_v_self->encoded_uptodate = 0;

  /* "btdht/krcp.pyx":758
 *             free(self.info_hash)
 * 
 *     cdef void del_implied_port(self) nogil:             # <<<<<<<<<<<<<<
 *         """
 *             Unset implied_port
 */

  /* function exit code */
}

/* "btdht/krcp.pyx":768
 *         self.encoded_uptodate = False
 * 
 *     cdef int set_implied_port(self, int value) nogil:             # <<<<<<<<<<<<<<
 *         """
 *             Set implied_port to ``value``
 */

static int __pyx_f_5btdht_4krcp_8BMessage_set_implied_port(struct __pyx_obj_5btdht_4krcp_BMessage *__pyx_v_self, int __pyx_v_value) {
  int __pyx_r;

  /* "btdht/krcp.pyx":777
 *                 This method can be called without the python GIL
 *         """
 *         self.encoded_uptodate = False             # <<<<<<<<<<<<<<
 *         self.implied_port = value
 *         self.has_implied_port = True
 */
  __pyx_v_self->encoded_uptodate = 0;

  /* "btdht/krcp.pyx":778
 *         """
 *         self.encoded_uptodate = False
 *         self.implied_port = value             # <<<<<<<<<<<<<<
 *         self.has_implied_port = True
 *         return True
 */
  __pyx_v_self->implied_port = __pyx_v_value;

  /* "btdht/krcp.pyx":779
 *         self.encoded_uptodate = False
 *         self.implied_port = value
 *         self.has_implied_port = True             # <<<<<<<<<<<<<<
 *         return True
 * 
 */
  __pyx_v_self->has_implied_port = 1;

  /* "btdht/krcp.pyx":780
 *         self.implied_port = value
 *         self.has_implied_port = True
 *         return True             # <<<<<<<<<<<<<<
 * 
 *     cdef int set_port(self, int value) nogil:
 */
  __pyx_r = 1;
  goto __pyx_L0;

  /* "btdht/krcp.pyx":768
 *         self.encoded_uptodate = False
 * 
 *     cdef int set_implied_port(self, int value) nogil:             # <<<<<<<<<<<<<<
 *         """
 *             Set implied_port to ``value``
 */

  /* function exit code */
  __pyx_L0:;
  return __pyx_r;
}

/* "btdht/krcp.pyx":782
 *         return True
 * 
 *     cdef int set_port(self, int value) nogil:             # <<<<<<<<<<<<<<
 *         """
 *             Set port to ``value``
 */

static int __pyx_f_5btdht_4krcp_8BMessage_set_port(struct __pyx_obj_5btdht_4krcp_BMessage *__pyx_v_self, int __pyx_v_value) {
  int __pyx_r;

  /* "btdht/krcp.pyx":791
 *                 This method can be called without the python GIL
 *         """
 *         self.encoded_uptodate = False             # <<<<<<<<<<<<<<
 *         self.port = value
 *         self.has_port = True
 */
  __pyx_v_self->encoded_uptodate = 0;

  /* "btdht/krcp.pyx":792
 *         """
 *         self.encoded_uptodate = False
 *         self.port = value             # <<<<<<<<<<<<<<
 *         self.has_port = True
 *         return True
 */
  __pyx_v_self->port = __pyx_v_value;

  /* "btdht/krcp.pyx":793
 *         self.encoded_uptodate = False
 *         self.port = value
 *         self.has_port = True             # <<<<<<<<<<<<<<
 *         return True
 * 
 */
  __pyx_v_self->has_port = 1;

  /* "btdht/krcp.pyx":794
 *         self.port = value
 *         self.has_port = True
 *         return True             # <<<<<<<<<<<<<<
 * 
 *     cdef void del_port(self) nogil:
 */
  __pyx_r = 1;
  goto __pyx_L0;

  /* "btdht/krcp.pyx":782
 *         return True
 * 
 *     cdef int set_port(self, int value) nogil:             # <<<<<<<<<<<<<<
 *         """
 *             Set port to ``value``
 */

  /* function exit code */
  __pyx_L0:;
  return __pyx_r;
}

/* "btdht/krcp.pyx":796
 *         return True
 * 
 *     cdef void del_port(self) nogil:             # <<<<<<<<<<<<<<
 *         """
 *             Unset port attribut of th emessage
 */

static void __pyx_f_5btdht_4krcp_8BMessage_del_port(struct __pyx_obj_5btdht_4krcp_BMessage *__pyx_v_self) {

  /* "btdht/krcp.pyx":803
 *                 This method can be called without the python GIL
 *         """
 *         self.has_port = False             # <<<<<<<<<<<<<<
 *         self.encoded_uptodate = False
 * 
 */
  __pyx_v_self->has_port = 0;

  /* "btdht/krcp.pyx":804
 *         """
 *         self.has_port = False
 *         self.encoded_uptodate = False             # <<<<<<<<<<<<<<
 * 
 *     cdef int set_token(self, char* value, int size) nogil:
 */
  __pyx_v_self->encoded_uptodate = 0;

  /* "btdht/krcp.pyx":796
 *         return True
 * 
 *     cdef void del_port(self) nogil:             # <<<<<<<<<<<<<<
 *         """
 *             Unset port attribut of th emessage
 */

  /* function exit code */
}

/* "btdht/krcp.pyx":806
 *         self.encoded_uptodate = False
 * 
 *     cdef int set_token(self, char* value, int size) nogil:             # <<<<<<<<<<<<<<
 *         """
 *             Set the token of the message
 */

static int __pyx_f_5btdht_4krcp_8BMessage_set_token(struct __pyx_obj_5btdht_4krcp_BMessage *__pyx_v_self, char *__pyx_v_value, int __pyx_v_size) {
  int __pyx_r;
  int __pyx_t_1;

  /* "btdht/krcp.pyx":816
 *                 This method can be called without the python GIL
 *         """
 *         self.encoded_uptodate = False             # <<<<<<<<<<<<<<
 *         if self.has_token:
 *             free(self.token)
 */
  __pyx_v_self->encoded_uptodate = 0;

  /* "btdht/krcp.pyx":817
 *         """
 *         self.encoded_uptodate = False
 *         if self.has_token:             # <<<<<<<<<<<<<<
 *             free(self.token)
 *         else:
 */
  __pyx_t_1 = (__pyx_v_self->has_token != 0);
  if (__pyx_t_1) {

    /* "btdht/krcp.pyx":818
 *         self.encoded_uptodate = False
 *         if self.has_token:
 *             free(self.token)             # <<<<<<<<<<<<<<
 *         else:
 *             self.has_token = True
 */
    free(__pyx_v_self->token);

    /* "btdht/krcp.pyx":817
 *         """
 *         self.encoded_uptodate = False
 *         if self.has_token:             # <<<<<<<<<<<<<<
 *             free(self.token)
 *         else:
 */
    goto __pyx_L3;
  }

  /* "btdht/krcp.pyx":820
 *             free(self.token)
 *         else:
 *             self.has_token = True             # <<<<<<<<<<<<<<
 *         self.token_len = size
 *         self.token = <char*>malloc(size * sizeof(char))
 */
  /*else*/ {
    __pyx_v_self->has_token = 1;
  }
  __pyx_L3:;

  /* "btdht/krcp.pyx":821
 *         else:
 *             self.has_token = True
 *         self.token_len = size             # <<<<<<<<<<<<<<
 *         self.token = <char*>malloc(size * sizeof(char))
 *         strncpy(self.token, value, size)
 */
  __pyx_v_self->token_len = __pyx_v_size;

  /* "btdht/krcp.pyx":822
 *             self.has_token = True
 *         self.token_len = size
 *         self.token = <char*>malloc(size * sizeof(char))             # <<<<<<<<<<<<<<
 *         strncpy(self.token, value, size)
 *         return True
 */
  __pyx_v_self->token = ((char *)malloc((__pyx_v_size * (sizeof(char)))));

  /* "btdht/krcp.pyx":823
 *         self.token_len = size
 *         self.token = <char*>malloc(size * sizeof(char))
 *         strncpy(self.token, value, size)             # <<<<<<<<<<<<<<
 *         return True
 * 
 */
  (void)(strncpy(__pyx_v_self->token, __pyx_v_value, __pyx_v_size));

  /* "btdht/krcp.pyx":824
 *         self.token = <char*>malloc(size * sizeof(char))
 *         strncpy(self.token, value, size)
 *         return True             # <<<<<<<<<<<<<<
 * 
 *     cdef void del_token(self) nogil:
 */
  __pyx_r = 1;
  goto __pyx_L0;

  /* "btdht/krcp.pyx":806
 *         self.encoded_uptodate = False
 * 
 *     cdef int set_token(self, char* value, int size) nogil:             # <<<<<<<<<<<<<<
 *         """
 *             Set the token of the message
 */

  /* function exit code */
  __pyx_L0:;
  return __pyx_r;
}

/* "btdht/krcp.pyx":826
 *         return True
 * 
 *     cdef void del_token(self) nogil:             # <<<<<<<<<<<<<<
 *         """
 *             Unset the token of the message
 */

static void __pyx_f_5btdht_4krcp_8BMessage_del_token(struct __pyx_obj_5btdht_4krcp_BMessage *__pyx_v_self) {
  int __pyx_t_1;

  /* "btdht/krcp.pyx":833
 *                 This method can be called without the python GIL
 *         """
 *         if self.has_token:             # <<<<<<<<<<<<<<
 *             self.has_token = False
 *             self.encoded_uptodate = False
 */
  __pyx_t_1 = (__pyx_v_self->has_token != 0);
  if (__pyx_t_1) {

    /* "btdht/krcp.pyx":834
 *         """
 *         if self.has_token:
 *             self.has_token = False             # <<<<<<<<<<<<<<
 *             self.encoded_uptodate = False
 *             self.token_len = 0
 */
    __pyx_v_self->has_token = 0;

    /* "btdht/krcp.pyx":835
 *         if self.has_token:
 *             self.has_token = False
 *             self.encoded_uptodate = False             # <<<<<<<<<<<<<<
 *             self.token_len = 0
 *             free(self.token)
 */
    __pyx_v_self->encoded_uptodate = 0;

    /* "btdht/krcp.pyx":836
 *             self.has_token = False
 *             self.encoded_uptodate = False
 *             self.token_len = 0             # <<<<<<<<<<<<<<
 *             free(self.token)
 * 
 */
    __pyx_v_self->token_len = 0;

    /* "btdht/krcp.pyx":837
 *             self.encoded_uptodate = False
 *             self.token_len = 0
 *             free(self.token)             # <<<<<<<<<<<<<<
 * 
 *     cdef int set_nodes(self, char* value, int size) nogil:
 */
    free(__pyx_v_self->token);

    /* "btdht/krcp.pyx":833
 *                 This method can be called without the python GIL
 *         """
 *         if self.has_token:             # <<<<<<<<<<<<<<
 *             self.has_token = False
 *             self.encoded_uptodate = False
 */
  }

  /* "btdht/krcp.pyx":826
 *         return True
 * 
 *     cdef void del_token(self) nogil:             # <<<<<<<<<<<<<<
 *         """
 *             Unset the token of the message
 */

  /* function exit code */
}

/* "btdht/krcp.pyx":839
 *             free(self.token)
 * 
 *     cdef int set_nodes(self, char* value, int size) nogil:             # <<<<<<<<<<<<<<
 *         """
 *             Set the nodes attribute of the message
 */

static int __pyx_f_5btdht_4krcp_8BMessage_set_nodes(struct __pyx_obj_5btdht_4krcp_BMessage *__pyx_v_self, char *__pyx_v_value, int __pyx_v_size) {
  int __pyx_r;
  int __pyx_t_1;

  /* "btdht/krcp.pyx":849
 *                 This method can be called without the python GIL
 *         """
 *         self.encoded_uptodate = False             # <<<<<<<<<<<<<<
 *         if self.has_nodes:
 *             free(self.nodes)
 */
  __pyx_v_self->encoded_uptodate = 0;

  /* "btdht/krcp.pyx":850
 *         """
 *         self.encoded_uptodate = False
 *         if self.has_nodes:             # <<<<<<<<<<<<<<
 *             free(self.nodes)
 *         else:
 */
  __pyx_t_1 = (__pyx_v_self->has_nodes != 0);
  if (__pyx_t_1) {

    /* "btdht/krcp.pyx":851
 *         self.encoded_uptodate = False
 *         if self.has_nodes:
 *             free(self.nodes)             # <<<<<<<<<<<<<<
 *         else:
 *             self.has_nodes = True
 */
    free(__pyx_v_self->nodes);

    /* "btdht/krcp.pyx":850
 *         """
 *         self.encoded_uptodate = False
 *         if self.has_nodes:             # <<<<<<<<<<<<<<
 *             free(self.nodes)
 *         else:
 */
    goto __pyx_L3;
  }

  /* "btdht/krcp.pyx":853
 *             free(self.nodes)
 *         else:
 *             self.has_nodes = True             # <<<<<<<<<<<<<<
 *         self.nodes_len = size
 *         self.nodes = <char*>malloc(size * sizeof(char))
 */
  /*else*/ {
    __pyx_v_self->has_nodes = 1;
  }
  __pyx_L3:;

  /* "btdht/krcp.pyx":854
 *         else:
 *             self.has_nodes = True
 *         self.nodes_len = size             # <<<<<<<<<<<<<<
 *         self.nodes = <char*>malloc(size * sizeof(char))
 *         strncpy(self.nodes, value, size)
 */
  __pyx_v_self->nodes_len = __pyx_v_size;

  /* "btdht/krcp.pyx":855
 *             self.has_nodes = True
 *         self.nodes_len = size
 *         self.nodes = <char*>malloc(size * sizeof(char))             # <<<<<<<<<<<<<<
 *         strncpy(self.nodes, value, size)
 *         return True
 */
  __pyx_v_self->nodes = ((char *)malloc((__pyx_v_size * (sizeof(char)))));

  /* "btdht/krcp.pyx":856
 *         self.nodes_len = size
 *         self.nodes = <char*>malloc(size * sizeof(char))
 *         strncpy(self.nodes, value, size)             # <<<<<<<<<<<<<<
 *         return True
 * 
 */
  (void)(strncpy(__pyx_v_self->nodes, __pyx_v_value, __pyx_v_size));

  /* "btdht/krcp.pyx":857
 *         self.nodes = <char*>malloc(size * sizeof(char))
 *         strncpy(self.nodes, value, size)
 *         return True             # <<<<<<<<<<<<<<
 * 
 *     cdef int del_nodes(self) nogil:
 */
  __pyx_r = 1;
  goto __pyx_L0;

  /* "btdht/krcp.pyx":839
 *             free(self.token)
 * 
 *     cdef int set_nodes(self, char* value, int size) nogil:             # <<<<<<<<<<<<<<
 *         """
 *             Set the nodes attribute of the message
 */

  /* function exit code */
  __pyx_L0:;
  return __pyx_r;
}

/* "btdht/krcp.pyx":859
 *         return True
 * 
 *     cdef int del_nodes(self) nogil:             # <<<<<<<<<<<<<<
 *         """
 *             Unset the nodes attribute of the message
 */

static int __pyx_f_5btdht_4krcp_8BMessage_del_nodes(struct __pyx_obj_5btdht_4krcp_BMessage *__pyx_v_self) {
  int __pyx_r;
  int __pyx_t_1;

  /* "btdht/krcp.pyx":866
 *                 This method can be called without the python GIL
 *         """
 *         if self.has_nodes:             # <<<<<<<<<<<<<<
 *             self.has_nodes = False
 *             self.encoded_uptodate = False
 */
  __pyx_t_1 = (__pyx_v_self->has_nodes != 0);
  if (__pyx_t_1) {

    /* "btdht/krcp.pyx":867
 *         """
 *         if self.has_nodes:
 *             self.has_nodes = False             # <<<<<<<<<<<<<<
 *             self.encoded_uptodate = False
 *             self.nodes_len = 0
 */
    __pyx_v_self->has_nodes = 0;

    /* "btdht/krcp.pyx":868
 *         if self.has_nodes:
 *             self.has_nodes = False
 *             self.encoded_uptodate = False             # <<<<<<<<<<<<<<
 *             self.nodes_len = 0
 *             free(self.nodes)
 */
    __pyx_v_self->encoded_uptodate = 0;

    /* "btdht/krcp.pyx":869
 *             self.has_nodes = False
 *             self.encoded_uptodate = False
 *             self.nodes_len = 0             # <<<<<<<<<<<<<<
 *             free(self.nodes)
 * 
 */
    __pyx_v_self->nodes_len = 0;

    /* "btdht/krcp.pyx":870
 *             self.encoded_uptodate = False
 *             self.nodes_len = 0
 *             free(self.nodes)             # <<<<<<<<<<<<<<
 * 
 *     cdef int set_values(self, char** values, int nb) nogil:
 */
    free(__pyx_v_self->nodes);

    /* "btdht/krcp.pyx":866
 *                 This method can be called without the python GIL
 *         """
 *         if self.has_nodes:             # <<<<<<<<<<<<<<
 *             self.has_nodes = False
 *             self.encoded_uptodate = False
 */
  }

  /* "btdht/krcp.pyx":859
 *         return True
 * 
 *     cdef int del_nodes(self) nogil:             # <<<<<<<<<<<<<<
 *         """
 *             Unset the nodes attribute of the message
 */

  /* function exit code */
  __pyx_r = 0;
  return __pyx_r;
}

/* "btdht/krcp.pyx":872
 *             free(self.nodes)
 * 
 *     cdef int set_values(self, char** values, int nb) nogil:             # <<<<<<<<<<<<<<
 *         """
 *             Set the values of the message
 */

static int __pyx_f_5btdht_4krcp_8BMessage_set_values(struct __pyx_obj_5btdht_4krcp_BMessage *__pyx_v_self, char **__pyx_v_values, int __pyx_v_nb) {
  int __pyx_v_i;
  int __pyx_r;
  int __pyx_t_1;
  int __pyx_t_2;
  int __pyx_t_3;
  int __pyx_t_4;

  /* "btdht/krcp.pyx":883
 *         """
 *         cdef int i
 *         self.encoded_uptodate = False             # <<<<<<<<<<<<<<
 *         if self.has_values:
 *             for i in prange(self.values_nb):
 */
  __pyx_v_self->encoded_uptodate = 0;

  /* "btdht/krcp.pyx":884
 *         cdef int i
 *         self.encoded_uptodate = False
 *         if self.has_values:             # <<<<<<<<<<<<<<
 *             for i in prange(self.values_nb):
 *                 free(self.values[i])
 */
  __pyx_t_1 = (__pyx_v_self->has_values != 0);
  if (__pyx_t_1) {

    /* "btdht/krcp.pyx":885
 *         self.encoded_uptodate = False
 *         if self.has_values:
 *             for i in prange(self.values_nb):             # <<<<<<<<<<<<<<
 *                 free(self.values[i])
 *             free(self.values)
 */
    __pyx_t_2 = __pyx_v_self->values_nb;
    if ((1 == 0)) abort();
    {
        #if ((defined(__APPLE__) || defined(__OSX__)) && (defined(__GNUC__) && (__GNUC__ > 2 || (__GNUC__ == 2 && (__GNUC_MINOR__ > 95)))))
            #undef likely
            #undef unlikely
            #define likely(x)   (x)
            #define unlikely(x) (x)
        #endif
        __pyx_t_4 = (__pyx_t_2 - 0 + 1 - 1/abs(1)) / 1;
        if (__pyx_t_4 > 0)
        {
            #ifdef _OPENMP
            #pragma omp parallel
            #endif /* _OPENMP */
            {
                #ifdef _OPENMP
                #pragma omp for firstprivate(__pyx_v_i) lastprivate(__pyx_v_i)
                #endif /* _OPENMP */
                for (__pyx_t_3 = 0; __pyx_t_3 < __pyx_t_4; __pyx_t_3++){
                    {
                        __pyx_v_i = (int)(0 + 1 * __pyx_t_3);

                        /* "btdht/krcp.pyx":886
 *         if self.has_values:
 *             for i in prange(self.values_nb):
 *                 free(self.values[i])             # <<<<<<<<<<<<<<
 *             free(self.values)
 *         else:
 */
                        free((__pyx_v_self->values[__pyx_v_i]));
                    }
                }
            }
        }
    }
    #if ((defined(__APPLE__) || defined(__OSX__)) && (defined(__GNUC__) && (__GNUC__ > 2 || (__GNUC__ == 2 && (__GNUC_MINOR__ > 95)))))
        #undef likely
        #undef unlikely
        #define likely(x)   __builtin_expect(!!(x), 1)
        #define unlikely(x) __builtin_expect(!!(x), 0)
    #endif

    /* "btdht/krcp.pyx":887
 *             for i in prange(self.values_nb):
 *                 free(self.values[i])
 *             free(self.values)             # <<<<<<<<<<<<<<
 *         else:
 *             self.has_values = True
 */
    free(__pyx_v_self->values);

    /* "btdht/krcp.pyx":884
 *         cdef int i
 *         self.encoded_uptodate = False
 *         if self.has_values:             # <<<<<<<<<<<<<<
 *             for i in prange(self.values_nb):
 *                 free(self.values[i])
 */
    goto __pyx_L3;
  }

  /* "btdht/krcp.pyx":889
 *             free(self.values)
 *         else:
 *             self.has_values = True             # <<<<<<<<<<<<<<
 *         self.values_nb = nb
 *         self.values = values
 */
  /*else*/ {
    __pyx_v_self->has_values = 1;
  }
  __pyx_L3:;

  /* "btdht/krcp.pyx":890
 *         else:
 *             self.has_values = True
 *         self.values_nb = nb             # <<<<<<<<<<<<<<
 *         self.values = values
 *         return True
 */
  __pyx_v_self->values_nb = __pyx_v_nb;

  /* "btdht/krcp.pyx":891
 *             self.has_values = True
 *         self.values_nb = nb
 *         self.values = values             # <<<<<<<<<<<<<<
 *         return True
 * 
 */
  __pyx_v_self->values = __pyx_v_values;

  /* "btdht/krcp.pyx":892
 *         self.values_nb = nb
 *         self.values = values
 *         return True             # <<<<<<<<<<<<<<
 * 
 *     cdef void del_values(self) nogil:
 */
  __pyx_r = 1;
  goto __pyx_L0;

  /* "btdht/krcp.pyx":872
 *             free(self.nodes)
 * 
 *     cdef int set_values(self, char** values, int nb) nogil:             # <<<<<<<<<<<<<<
 *         """
 *             Set the values of the message
 */

  /* function exit code */
  __pyx_L0:;
  return __pyx_r;
}

/* "btdht/krcp.pyx":894
 *         return True
 * 
 *     cdef void del_values(self) nogil:             # <<<<<<<<<<<<<<
 *         """
 *             Unset the values of the messages
 */

static void __pyx_f_5btdht_4krcp_8BMessage_del_values(struct __pyx_obj_5btdht_4krcp_BMessage *__pyx_v_self) {
  int __pyx_v_i;
  int __pyx_t_1;
  int __pyx_t_2;
  int __pyx_t_3;
  int __pyx_t_4;

  /* "btdht/krcp.pyx":901
 *                 This method can be called without the python GIL
 *         """
 *         cdef int i = 0             # <<<<<<<<<<<<<<
 *         if self.has_values:
 *             self.has_values = False
 */
  __pyx_v_i = 0;

  /* "btdht/krcp.pyx":902
 *         """
 *         cdef int i = 0
 *         if self.has_values:             # <<<<<<<<<<<<<<
 *             self.has_values = False
 *             self.encoded_uptodate = False
 */
  __pyx_t_1 = (__pyx_v_self->has_values != 0);
  if (__pyx_t_1) {

    /* "btdht/krcp.pyx":903
 *         cdef int i = 0
 *         if self.has_values:
 *             self.has_values = False             # <<<<<<<<<<<<<<
 *             self.encoded_uptodate = False
 *             for i in prange(self.values_nb):
 */
    __pyx_v_self->has_values = 0;

    /* "btdht/krcp.pyx":904
 *         if self.has_values:
 *             self.has_values = False
 *             self.encoded_uptodate = False             # <<<<<<<<<<<<<<
 *             for i in prange(self.values_nb):
 *                 free(self.values[i])
 */
    __pyx_v_self->encoded_uptodate = 0;

    /* "btdht/krcp.pyx":905
 *             self.has_values = False
 *             self.encoded_uptodate = False
 *             for i in prange(self.values_nb):             # <<<<<<<<<<<<<<
 *                 free(self.values[i])
 *             self.values_nb = 0
 */
    __pyx_t_2 = __pyx_v_self->values_nb;
    if ((1 == 0)) abort();
    {
        #if ((defined(__APPLE__) || defined(__OSX__)) && (defined(__GNUC__) && (__GNUC__ > 2 || (__GNUC__ == 2 && (__GNUC_MINOR__ > 95)))))
            #undef likely
            #undef unlikely
            #define likely(x)   (x)
            #define unlikely(x) (x)
        #endif
        __pyx_t_4 = (__pyx_t_2 - 0 + 1 - 1/abs(1)) / 1;
        if (__pyx_t_4 > 0)
        {
            #ifdef _OPENMP
            #pragma omp parallel
            #endif /* _OPENMP */
            {
                #ifdef _OPENMP
                #pragma omp for firstprivate(__pyx_v_i) lastprivate(__pyx_v_i)
                #endif /* _OPENMP */
                for (__pyx_t_3 = 0; __pyx_t_3 < __pyx_t_4; __pyx_t_3++){
                    {
                        __pyx_v_i = (int)(0 + 1 * __pyx_t_3);

                        /* "btdht/krcp.pyx":906
 *             self.encoded_uptodate = False
 *             for i in prange(self.values_nb):
 *                 free(self.values[i])             # <<<<<<<<<<<<<<
 *             self.values_nb = 0
 *             free(self.values)
 */
                        free((__pyx_v_self->values[__pyx_v_i]));
                    }
                }
            }
        }
    }
    #if ((defined(__APPLE__) || defined(__OSX__)) && (defined(__GNUC__) && (__GNUC__ > 2 || (__GNUC__ == 2 && (__GNUC_MINOR__ > 95)))))
        #undef likely
        #undef unlikely
        #define likely(x)   __builtin_expect(!!(x), 1)
        #define unlikely(x) __builtin_expect(!!(x), 0)
    #endif

    /* "btdht/krcp.pyx":907
 *             for i in prange(self.values_nb):
 *                 free(self.values[i])
 *             self.values_nb = 0             # <<<<<<<<<<<<<<
 *             free(self.values)
 * 
 */
    __pyx_v_self->values_nb = 0;

    /* "btdht/krcp.pyx":908
 *                 free(self.values[i])
 *             self.values_nb = 0
 *             free(self.values)             # <<<<<<<<<<<<<<
 * 
 *     cdef int set_errmsg(self, char* value, int size) nogil:
 */
    free(__pyx_v_self->values);

    /* "btdht/krcp.pyx":902
 *         """
 *         cdef int i = 0
 *         if self.has_values:             # <<<<<<<<<<<<<<
 *             self.has_values = False
 *             self.encoded_uptodate = False
 */
  }

  /* "btdht/krcp.pyx":894
 *         return True
 * 
 *     cdef void del_values(self) nogil:             # <<<<<<<<<<<<<<
 *         """
 *             Unset the values of the messages
 */

  /* function exit code */
}

/* "btdht/krcp.pyx":910
 *             free(self.values)
 * 
 *     cdef int set_errmsg(self, char* value, int size) nogil:             # <<<<<<<<<<<<<<
 *         """
 *             Set the errmsg attribute
 */

static int __pyx_f_5btdht_4krcp_8BMessage_set_errmsg(struct __pyx_obj_5btdht_4krcp_BMessage *__pyx_v_self, char *__pyx_v_value, int __pyx_v_size) {
  int __pyx_r;
  int __pyx_t_1;

  /* "btdht/krcp.pyx":920
 *                 This method can be called without the python GIL
 *         """
 *         self.encoded_uptodate = False             # <<<<<<<<<<<<<<
 *         if self.errmsg_len > 0:
 *             free(self._errmsg)
 */
  __pyx_v_self->encoded_uptodate = 0;

  /* "btdht/krcp.pyx":921
 *         """
 *         self.encoded_uptodate = False
 *         if self.errmsg_len > 0:             # <<<<<<<<<<<<<<
 *             free(self._errmsg)
 *         self.errmsg_len = size
 */
  __pyx_t_1 = ((__pyx_v_self->errmsg_len > 0) != 0);
  if (__pyx_t_1) {

    /* "btdht/krcp.pyx":922
 *         self.encoded_uptodate = False
 *         if self.errmsg_len > 0:
 *             free(self._errmsg)             # <<<<<<<<<<<<<<
 *         self.errmsg_len = size
 *         self._errmsg = <char*>malloc(size * sizeof(char))
 */
    free(__pyx_v_self->_errmsg);

    /* "btdht/krcp.pyx":921
 *         """
 *         self.encoded_uptodate = False
 *         if self.errmsg_len > 0:             # <<<<<<<<<<<<<<
 *             free(self._errmsg)
 *         self.errmsg_len = size
 */
  }

  /* "btdht/krcp.pyx":923
 *         if self.errmsg_len > 0:
 *             free(self._errmsg)
 *         self.errmsg_len = size             # <<<<<<<<<<<<<<
 *         self._errmsg = <char*>malloc(size * sizeof(char))
 *         strncpy(self._errmsg, value, size)
 */
  __pyx_v_self->errmsg_len = __pyx_v_size;

  /* "btdht/krcp.pyx":924
 *             free(self._errmsg)
 *         self.errmsg_len = size
 *         self._errmsg = <char*>malloc(size * sizeof(char))             # <<<<<<<<<<<<<<
 *         strncpy(self._errmsg, value, size)
 *         return True
 */
  __pyx_v_self->_errmsg = ((char *)malloc((__pyx_v_size * (sizeof(char)))));

  /* "btdht/krcp.pyx":925
 *         self.errmsg_len = size
 *         self._errmsg = <char*>malloc(size * sizeof(char))
 *         strncpy(self._errmsg, value, size)             # <<<<<<<<<<<<<<
 *         return True
 * 
 */
  (void)(strncpy(__pyx_v_self->_errmsg, __pyx_v_value, __pyx_v_size));

  /* "btdht/krcp.pyx":926
 *         self._errmsg = <char*>malloc(size * sizeof(char))
 *         strncpy(self._errmsg, value, size)
 *         return True             # <<<<<<<<<<<<<<
 * 
 *     cdef void del_errmsg(self) nogil:
 */
  __pyx_r = 1;
  goto __pyx_L0;

  /* "btdht/krcp.pyx":910
 *             free(self.values)
 * 
 *     cdef int set_errmsg(self, char* value, int size) nogil:             # <<<<<<<<<<<<<<
 *         """
 *             Set the errmsg attribute
 */

  /* function exit code */
  __pyx_L0:;
  return __pyx_r;
}

/* "btdht/krcp.pyx":928
 *         return True
 * 
 *     cdef void del_errmsg(self) nogil:             # <<<<<<<<<<<<<<
 *         """
 *             Unset the errmsg attribute
 */

static void __pyx_f_5btdht_4krcp_8BMessage_del_errmsg(struct __pyx_obj_5btdht_4krcp_BMessage *__pyx_v_self) {
  int __pyx_t_1;

  /* "btdht/krcp.pyx":935
 *                 This method can be called without the python GIL
 *         """
 *         if self.errmsg_len > 0:             # <<<<<<<<<<<<<<
 *             self.errmsg_len = 0
 *             self.encoded_uptodate = False
 */
  __pyx_t_1 = ((__pyx_v_self->errmsg_len > 0) != 0);
  if (__pyx_t_1) {

    /* "btdht/krcp.pyx":936
 *         """
 *         if self.errmsg_len > 0:
 *             self.errmsg_len = 0             # <<<<<<<<<<<<<<
 *             self.encoded_uptodate = False
 *             free(self._errmsg)
 */
    __pyx_v_self->errmsg_len = 0;

    /* "btdht/krcp.pyx":937
 *         if self.errmsg_len > 0:
 *             self.errmsg_len = 0
 *             self.encoded_uptodate = False             # <<<<<<<<<<<<<<
 *             free(self._errmsg)
 * 
 */
    __pyx_v_self->encoded_uptodate = 0;

    /* "btdht/krcp.pyx":938
 *             self.errmsg_len = 0
 *             self.encoded_uptodate = False
 *             free(self._errmsg)             # <<<<<<<<<<<<<<
 * 
 *     cdef int set_errno(self, int value) nogil:
 */
    free(__pyx_v_self->_errmsg);

    /* "btdht/krcp.pyx":935
 *                 This method can be called without the python GIL
 *         """
 *         if self.errmsg_len > 0:             # <<<<<<<<<<<<<<
 *             self.errmsg_len = 0
 *             self.encoded_uptodate = False
 */
  }

  /* "btdht/krcp.pyx":928
 *         return True
 * 
 *     cdef void del_errmsg(self) nogil:             # <<<<<<<<<<<<<<
 *         """
 *             Unset the errmsg attribute
 */

  /* function exit code */
}

/* "btdht/krcp.pyx":940
 *             free(self._errmsg)
 * 
 *     cdef int set_errno(self, int value) nogil:             # <<<<<<<<<<<<<<
 *         """
 *             Set the errno attribute
 */

static int __pyx_f_5btdht_4krcp_8BMessage_set_errno(struct __pyx_obj_5btdht_4krcp_BMessage *__pyx_v_self, int __pyx_v_value) {
  int __pyx_r;

  /* "btdht/krcp.pyx":949
 *                 This method can be called without the python GIL
 *         """
 *         self.encoded_uptodate = False             # <<<<<<<<<<<<<<
 *         self._errno = value
 *         return True
 */
  __pyx_v_self->encoded_uptodate = 0;

  /* "btdht/krcp.pyx":950
 *         """
 *         self.encoded_uptodate = False
 *         self._errno = value             # <<<<<<<<<<<<<<
 *         return True
 * 
 */
  __pyx_v_self->_errno = __pyx_v_value;

  /* "btdht/krcp.pyx":951
 *         self.encoded_uptodate = False
 *         self._errno = value
 *         return True             # <<<<<<<<<<<<<<
 * 
 *     cdef void del_encoded(self) nogil:
 */
  __pyx_r = 1;
  goto __pyx_L0;

  /* "btdht/krcp.pyx":940
 *             free(self._errmsg)
 * 
 *     cdef int set_errno(self, int value) nogil:             # <<<<<<<<<<<<<<
 *         """
 *             Set the errno attribute
 */

  /* function exit code */
  __pyx_L0:;
  return __pyx_r;
}

/* "btdht/krcp.pyx":953
 *         return True
 * 
 *     cdef void del_encoded(self) nogil:             # <<<<<<<<<<<<<<
 *         """
 *             Mark the message as not encoded (invalided the cache of bencoded  string of the message)
 */

static void __pyx_f_5btdht_4krcp_8BMessage_del_encoded(struct __pyx_obj_5btdht_4krcp_BMessage *__pyx_v_self) {
  int __pyx_t_1;

  /* "btdht/krcp.pyx":960
 *                 This method can be called without the python GIL
 *         """
 *         if self.encoded_len > 0:             # <<<<<<<<<<<<<<
 *             self.encoded_len = 0
 *             self.encoded_uptodate = False
 */
  __pyx_t_1 = ((__pyx_v_self->encoded_len > 0) != 0);
  if (__pyx_t_1) {

    /* "btdht/krcp.pyx":961
 *         """
 *         if self.encoded_len > 0:
 *             self.encoded_len = 0             # <<<<<<<<<<<<<<
 *             self.encoded_uptodate = False
 *             free(self.encoded)
 */
    __pyx_v_self->encoded_len = 0;

    /* "btdht/krcp.pyx":962
 *         if self.encoded_len > 0:
 *             self.encoded_len = 0
 *             self.encoded_uptodate = False             # <<<<<<<<<<<<<<
 *             free(self.encoded)
 * 
 */
    __pyx_v_self->encoded_uptodate = 0;

    /* "btdht/krcp.pyx":963
 *             self.encoded_len = 0
 *             self.encoded_uptodate = False
 *             free(self.encoded)             # <<<<<<<<<<<<<<
 * 
 *     def response(self, dht):
 */
    free(__pyx_v_self->encoded);

    /* "btdht/krcp.pyx":960
 *                 This method can be called without the python GIL
 *         """
 *         if self.encoded_len > 0:             # <<<<<<<<<<<<<<
 *             self.encoded_len = 0
 *             self.encoded_uptodate = False
 */
  }

  /* "btdht/krcp.pyx":953
 *         return True
 * 
 *     cdef void del_encoded(self) nogil:             # <<<<<<<<<<<<<<
 *         """
 *             Mark the message as not encoded (invalided the cache of bencoded  string of the message)
 */

  /* function exit code */
}

/* "btdht/krcp.pyx":965
 *             free(self.encoded)
 * 
 *     def response(self, dht):             # <<<<<<<<<<<<<<
 *         """
 *             If the message is a query, return the response message to send
 */

/* Python wrapper */
static PyObject *__pyx_pw_5btdht_4krcp_8BMessage_1response(PyObject *__pyx_v_self, PyObject *__pyx_v_dht); /*proto*/
static char __pyx_doc_5btdht_4krcp_8BMessage_response[] = "\n            If the message is a query, return the response message to send\n\n            :param dht.DHT_BASE dht: The dht instance from which the message is originated\n            :return: A :class:`BMessage` to send as response to the query\n            :raises ProtocolError: if the query is malformated. To send as response to the querier\n            :raises MethodUnknownError: If the RPC DHT method asked in the query is unknown.\n                To send as response to the querier\n        ";
static PyObject *__pyx_pw_5btdht_4krcp_8BMessage_1response(PyObject *__pyx_v_self, PyObject *__pyx_v_dht) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("response (wrapper)", 0);
  __pyx_r = __pyx_pf_5btdht_4krcp_8BMessage_response(((struct __pyx_obj_5btdht_4krcp_BMessage *)__pyx_v_self), ((PyObject *)__pyx_v_dht));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5btdht_4krcp_8BMessage_response(struct __pyx_obj_5btdht_4krcp_BMessage *__pyx_v_self, PyObject *__pyx_v_dht) {
  struct __pyx_obj_5btdht_4krcp_BMessage *__pyx_v_rep = 0;
  char *__pyx_v_id;
  int __pyx_v_l1;
  int __pyx_v_l2;
  char *__pyx_v_nodes;
  char *__pyx_v_token;
  char **__pyx_v_values;
  PyObject *__pyx_v_s = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  char *__pyx_t_3;
  int __pyx_t_4;
  int __pyx_t_5;
  int __pyx_t_6;
  PyObject *__pyx_t_7 = NULL;
  PyObject *__pyx_t_8 = NULL;
  PyObject *__pyx_t_9 = NULL;
  size_t __pyx_t_10;
  Py_ssize_t __pyx_t_11;
  PyObject *__pyx_t_12 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("response", 0);

  /* "btdht/krcp.pyx":975
 *                 To send as response to the querier
 *         """
 *         cdef BMessage rep = BMessage()             # <<<<<<<<<<<<<<
 *         cdef char* id = NULL
 *         cdef int l1 = 0
 */
  __pyx_t_1 = __Pyx_PyObject_CallNoArg(((PyObject *)__pyx_ptype_5btdht_4krcp_BMessage)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 975, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_rep = ((struct __pyx_obj_5btdht_4krcp_BMessage *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "btdht/krcp.pyx":976
 *         """
 *         cdef BMessage rep = BMessage()
 *         cdef char* id = NULL             # <<<<<<<<<<<<<<
 *         cdef int l1 = 0
 *         cdef int l2 = 0
 */
  __pyx_v_id = NULL;

  /* "btdht/krcp.pyx":977
 *         cdef BMessage rep = BMessage()
 *         cdef char* id = NULL
 *         cdef int l1 = 0             # <<<<<<<<<<<<<<
 *         cdef int l2 = 0
 *         cdef char* nodes = NULL
 */
  __pyx_v_l1 = 0;

  /* "btdht/krcp.pyx":978
 *         cdef char* id = NULL
 *         cdef int l1 = 0
 *         cdef int l2 = 0             # <<<<<<<<<<<<<<
 *         cdef char* nodes = NULL
 *         cdef char* token = NULL
 */
  __pyx_v_l2 = 0;

  /* "btdht/krcp.pyx":979
 *         cdef int l1 = 0
 *         cdef int l2 = 0
 *         cdef char* nodes = NULL             # <<<<<<<<<<<<<<
 *         cdef char* token = NULL
 *         cdef char** values = NULL
 */
  __pyx_v_nodes = NULL;

  /* "btdht/krcp.pyx":980
 *         cdef int l2 = 0
 *         cdef char* nodes = NULL
 *         cdef char* token = NULL             # <<<<<<<<<<<<<<
 *         cdef char** values = NULL
 *         s = dht.myid.value
 */
  __pyx_v_token = NULL;

  /* "btdht/krcp.pyx":981
 *         cdef char* nodes = NULL
 *         cdef char* token = NULL
 *         cdef char** values = NULL             # <<<<<<<<<<<<<<
 *         s = dht.myid.value
 *         id = s
 */
  __pyx_v_values = NULL;

  /* "btdht/krcp.pyx":982
 *         cdef char* token = NULL
 *         cdef char** values = NULL
 *         s = dht.myid.value             # <<<<<<<<<<<<<<
 *         id = s
 *         with nogil:
 */
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_dht, __pyx_n_s_myid); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 982, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_value); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 982, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v_s = __pyx_t_2;
  __pyx_t_2 = 0;

  /* "btdht/krcp.pyx":983
 *         cdef char** values = NULL
 *         s = dht.myid.value
 *         id = s             # <<<<<<<<<<<<<<
 *         with nogil:
 *             if self.has_y and self.y_len == 1 and strncmp(self._y, b"q", 1) == 0:
 */
  __pyx_t_3 = __Pyx_PyObject_AsWritableString(__pyx_v_s); if (unlikely((!__pyx_t_3) && PyErr_Occurred())) __PYX_ERR(0, 983, __pyx_L1_error)
  __pyx_v_id = __pyx_t_3;

  /* "btdht/krcp.pyx":984
 *         s = dht.myid.value
 *         id = s
 *         with nogil:             # <<<<<<<<<<<<<<
 *             if self.has_y and self.y_len == 1 and strncmp(self._y, b"q", 1) == 0:
 *                 if self.has_q:
 */
  {
      #ifdef WITH_THREAD
      PyThreadState *_save;
      Py_UNBLOCK_THREADS
      __Pyx_FastGIL_Remember();
      #endif
      /*try:*/ {

        /* "btdht/krcp.pyx":985
 *         id = s
 *         with nogil:
 *             if self.has_y and self.y_len == 1 and strncmp(self._y, b"q", 1) == 0:             # <<<<<<<<<<<<<<
 *                 if self.has_q:
 *                     if self.q_len == 4 and strncmp(self._q, b"ping", 4) == 0:
 */
        __pyx_t_5 = (__pyx_v_self->has_y != 0);
        if (__pyx_t_5) {
        } else {
          __pyx_t_4 = __pyx_t_5;
          goto __pyx_L7_bool_binop_done;
        }
        __pyx_t_5 = ((__pyx_v_self->y_len == 1) != 0);
        if (__pyx_t_5) {
        } else {
          __pyx_t_4 = __pyx_t_5;
          goto __pyx_L7_bool_binop_done;
        }
        __pyx_t_5 = ((strncmp(__pyx_v_self->_y, ((char const *)"q"), 1) == 0) != 0);
        __pyx_t_4 = __pyx_t_5;
        __pyx_L7_bool_binop_done:;
        if (__pyx_t_4) {

          /* "btdht/krcp.pyx":986
 *         with nogil:
 *             if self.has_y and self.y_len == 1 and strncmp(self._y, b"q", 1) == 0:
 *                 if self.has_q:             # <<<<<<<<<<<<<<
 *                     if self.q_len == 4 and strncmp(self._q, b"ping", 4) == 0:
 *                         rep.set_y(b"r", 1)
 */
          __pyx_t_4 = (__pyx_v_self->has_q != 0);
          if (__pyx_t_4) {

            /* "btdht/krcp.pyx":987
 *             if self.has_y and self.y_len == 1 and strncmp(self._y, b"q", 1) == 0:
 *                 if self.has_q:
 *                     if self.q_len == 4 and strncmp(self._q, b"ping", 4) == 0:             # <<<<<<<<<<<<<<
 *                         rep.set_y(b"r", 1)
 *                         rep.set_t(self._t, self.t_len)
 */
            __pyx_t_5 = ((__pyx_v_self->q_len == 4) != 0);
            if (__pyx_t_5) {
            } else {
              __pyx_t_4 = __pyx_t_5;
              goto __pyx_L12_bool_binop_done;
            }
            __pyx_t_5 = ((strncmp(__pyx_v_self->_q, ((char const *)"ping"), 4) == 0) != 0);
            __pyx_t_4 = __pyx_t_5;
            __pyx_L12_bool_binop_done:;
            if (__pyx_t_4) {

              /* "btdht/krcp.pyx":988
 *                 if self.has_q:
 *                     if self.q_len == 4 and strncmp(self._q, b"ping", 4) == 0:
 *                         rep.set_y(b"r", 1)             # <<<<<<<<<<<<<<
 *                         rep.set_t(self._t, self.t_len)
 *                         rep.set_r(True)
 */
              (void)(((struct __pyx_vtabstruct_5btdht_4krcp_BMessage *)__pyx_v_rep->__pyx_vtab)->set_y(__pyx_v_rep, ((char *)"r"), 1));

              /* "btdht/krcp.pyx":989
 *                     if self.q_len == 4 and strncmp(self._q, b"ping", 4) == 0:
 *                         rep.set_y(b"r", 1)
 *                         rep.set_t(self._t, self.t_len)             # <<<<<<<<<<<<<<
 *                         rep.set_r(True)
 *                         rep.set_id(id, 20)
 */
              (void)(((struct __pyx_vtabstruct_5btdht_4krcp_BMessage *)__pyx_v_rep->__pyx_vtab)->set_t(__pyx_v_rep, __pyx_v_self->_t, __pyx_v_self->t_len));

              /* "btdht/krcp.pyx":990
 *                         rep.set_y(b"r", 1)
 *                         rep.set_t(self._t, self.t_len)
 *                         rep.set_r(True)             # <<<<<<<<<<<<<<
 *                         rep.set_id(id, 20)
 *                         self._encode()
 */
              (void)(((struct __pyx_vtabstruct_5btdht_4krcp_BMessage *)__pyx_v_rep->__pyx_vtab)->set_r(__pyx_v_rep, 1));

              /* "btdht/krcp.pyx":991
 *                         rep.set_t(self._t, self.t_len)
 *                         rep.set_r(True)
 *                         rep.set_id(id, 20)             # <<<<<<<<<<<<<<
 *                         self._encode()
 *                         with gil:
 */
              __pyx_t_6 = ((struct __pyx_vtabstruct_5btdht_4krcp_BMessage *)__pyx_v_rep->__pyx_vtab)->set_id(__pyx_v_rep, __pyx_v_id, 20); if (unlikely(__pyx_t_6 == ((int)-1))) __PYX_ERR(0, 991, __pyx_L4_error)

              /* "btdht/krcp.pyx":992
 *                         rep.set_r(True)
 *                         rep.set_id(id, 20)
 *                         self._encode()             # <<<<<<<<<<<<<<
 *                         with gil:
 *                             return rep
 */
              (void)(((struct __pyx_vtabstruct_5btdht_4krcp_BMessage *)__pyx_v_self->__pyx_vtab)->_encode(__pyx_v_self));

              /* "btdht/krcp.pyx":993
 *                         rep.set_id(id, 20)
 *                         self._encode()
 *                         with gil:             # <<<<<<<<<<<<<<
 *                             return rep
 *                     elif self.q_len == 9 and strncmp(self._q, b"find_nodes", 9) == 0:
 */
              {
                  #ifdef WITH_THREAD
                  PyGILState_STATE __pyx_gilstate_save = __Pyx_PyGILState_Ensure();
                  #endif
                  /*try:*/ {

                    /* "btdht/krcp.pyx":994
 *                         self._encode()
 *                         with gil:
 *                             return rep             # <<<<<<<<<<<<<<
 *                     elif self.q_len == 9 and strncmp(self._q, b"find_nodes", 9) == 0:
 *                         if not self.has_target:
 */
                    __Pyx_XDECREF(__pyx_r);
                    __Pyx_INCREF(((PyObject *)__pyx_v_rep));
                    __pyx_r = ((PyObject *)__pyx_v_rep);
                    goto __pyx_L14_return;
                  }

                  /* "btdht/krcp.pyx":993
 *                         rep.set_id(id, 20)
 *                         self._encode()
 *                         with gil:             # <<<<<<<<<<<<<<
 *                             return rep
 *                     elif self.q_len == 9 and strncmp(self._q, b"find_nodes", 9) == 0:
 */
                  /*finally:*/ {
                    __pyx_L14_return: {
                      #ifdef WITH_THREAD
                      __Pyx_PyGILState_Release(__pyx_gilstate_save);
                      #endif
                      goto __pyx_L3_return;
                    }
                  }
              }

              /* "btdht/krcp.pyx":987
 *             if self.has_y and self.y_len == 1 and strncmp(self._y, b"q", 1) == 0:
 *                 if self.has_q:
 *                     if self.q_len == 4 and strncmp(self._q, b"ping", 4) == 0:             # <<<<<<<<<<<<<<
 *                         rep.set_y(b"r", 1)
 *                         rep.set_t(self._t, self.t_len)
 */
            }

            /* "btdht/krcp.pyx":995
 *                         with gil:
 *                             return rep
 *                     elif self.q_len == 9 and strncmp(self._q, b"find_nodes", 9) == 0:             # <<<<<<<<<<<<<<
 *                         if not self.has_target:
 *                             with gil:
 */
            __pyx_t_5 = ((__pyx_v_self->q_len == 9) != 0);
            if (__pyx_t_5) {
            } else {
              __pyx_t_4 = __pyx_t_5;
              goto __pyx_L17_bool_binop_done;
            }
            __pyx_t_5 = ((strncmp(__pyx_v_self->_q, ((char const *)"find_nodes"), 9) == 0) != 0);
            __pyx_t_4 = __pyx_t_5;
            __pyx_L17_bool_binop_done:;
            if (__pyx_t_4) {

              /* "btdht/krcp.pyx":996
 *                             return rep
 *                     elif self.q_len == 9 and strncmp(self._q, b"find_nodes", 9) == 0:
 *                         if not self.has_target:             # <<<<<<<<<<<<<<
 *                             with gil:
 *                                 raise ProtocolError(self.t, b"target missing")
 */
              __pyx_t_4 = ((!(__pyx_v_self->has_target != 0)) != 0);
              if (__pyx_t_4) {

                /* "btdht/krcp.pyx":997
 *                     elif self.q_len == 9 and strncmp(self._q, b"find_nodes", 9) == 0:
 *                         if not self.has_target:
 *                             with gil:             # <<<<<<<<<<<<<<
 *                                 raise ProtocolError(self.t, b"target missing")
 *                         rep.set_y(b"r", 1)
 */
                {
                    #ifdef WITH_THREAD
                    PyGILState_STATE __pyx_gilstate_save = __Pyx_PyGILState_Ensure();
                    #endif
                    /*try:*/ {

                      /* "btdht/krcp.pyx":998
 *                         if not self.has_target:
 *                             with gil:
 *                                 raise ProtocolError(self.t, b"target missing")             # <<<<<<<<<<<<<<
 *                         rep.set_y(b"r", 1)
 *                         rep.set_t(self._t, self.t_len)
 */
                      __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_ProtocolError); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 998, __pyx_L21_error)
                      __Pyx_GOTREF(__pyx_t_1);
                      __pyx_t_7 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_t); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 998, __pyx_L21_error)
                      __Pyx_GOTREF(__pyx_t_7);
                      __pyx_t_8 = NULL;
                      __pyx_t_6 = 0;
                      if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_1))) {
                        __pyx_t_8 = PyMethod_GET_SELF(__pyx_t_1);
                        if (likely(__pyx_t_8)) {
                          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1);
                          __Pyx_INCREF(__pyx_t_8);
                          __Pyx_INCREF(function);
                          __Pyx_DECREF_SET(__pyx_t_1, function);
                          __pyx_t_6 = 1;
                        }
                      }
                      #if CYTHON_FAST_PYCALL
                      if (PyFunction_Check(__pyx_t_1)) {
                        PyObject *__pyx_temp[3] = {__pyx_t_8, __pyx_t_7, __pyx_kp_b_target_missing};
                        __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_1, __pyx_temp+1-__pyx_t_6, 2+__pyx_t_6); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 998, __pyx_L21_error)
                        __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
                        __Pyx_GOTREF(__pyx_t_2);
                        __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
                      } else
                      #endif
                      #if CYTHON_FAST_PYCCALL
                      if (__Pyx_PyFastCFunction_Check(__pyx_t_1)) {
                        PyObject *__pyx_temp[3] = {__pyx_t_8, __pyx_t_7, __pyx_kp_b_target_missing};
                        __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_1, __pyx_temp+1-__pyx_t_6, 2+__pyx_t_6); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 998, __pyx_L21_error)
                        __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
                        __Pyx_GOTREF(__pyx_t_2);
                        __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
                      } else
                      #endif
                      {
                        __pyx_t_9 = PyTuple_New(2+__pyx_t_6); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 998, __pyx_L21_error)
                        __Pyx_GOTREF(__pyx_t_9);
                        if (__pyx_t_8) {
                          __Pyx_GIVEREF(__pyx_t_8); PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_t_8); __pyx_t_8 = NULL;
                        }
                        __Pyx_GIVEREF(__pyx_t_7);
                        PyTuple_SET_ITEM(__pyx_t_9, 0+__pyx_t_6, __pyx_t_7);
                        __Pyx_INCREF(__pyx_kp_b_target_missing);
                        __Pyx_GIVEREF(__pyx_kp_b_target_missing);
                        PyTuple_SET_ITEM(__pyx_t_9, 1+__pyx_t_6, __pyx_kp_b_target_missing);
                        __pyx_t_7 = 0;
                        __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_9, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 998, __pyx_L21_error)
                        __Pyx_GOTREF(__pyx_t_2);
                        __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
                      }
                      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
                      __Pyx_Raise(__pyx_t_2, 0, 0, 0);
                      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
                      __PYX_ERR(0, 998, __pyx_L21_error)
                    }

                    /* "btdht/krcp.pyx":997
 *                     elif self.q_len == 9 and strncmp(self._q, b"find_nodes", 9) == 0:
 *                         if not self.has_target:
 *                             with gil:             # <<<<<<<<<<<<<<
 *                                 raise ProtocolError(self.t, b"target missing")
 *                         rep.set_y(b"r", 1)
 */
                    /*finally:*/ {
                      __pyx_L21_error: {
                        #ifdef WITH_THREAD
                        __Pyx_PyGILState_Release(__pyx_gilstate_save);
                        #endif
                        goto __pyx_L4_error;
                      }
                    }
                }

                /* "btdht/krcp.pyx":996
 *                             return rep
 *                     elif self.q_len == 9 and strncmp(self._q, b"find_nodes", 9) == 0:
 *                         if not self.has_target:             # <<<<<<<<<<<<<<
 *                             with gil:
 *                                 raise ProtocolError(self.t, b"target missing")
 */
              }

              /* "btdht/krcp.pyx":999
 *                             with gil:
 *                                 raise ProtocolError(self.t, b"target missing")
 *                         rep.set_y(b"r", 1)             # <<<<<<<<<<<<<<
 *                         rep.set_t(self._t, self.t_len)
 *                         rep.set_r(True)
 */
              (void)(((struct __pyx_vtabstruct_5btdht_4krcp_BMessage *)__pyx_v_rep->__pyx_vtab)->set_y(__pyx_v_rep, ((char *)"r"), 1));

              /* "btdht/krcp.pyx":1000
 *                                 raise ProtocolError(self.t, b"target missing")
 *                         rep.set_y(b"r", 1)
 *                         rep.set_t(self._t, self.t_len)             # <<<<<<<<<<<<<<
 *                         rep.set_r(True)
 *                         rep.set_id(id, 20)
 */
              (void)(((struct __pyx_vtabstruct_5btdht_4krcp_BMessage *)__pyx_v_rep->__pyx_vtab)->set_t(__pyx_v_rep, __pyx_v_self->_t, __pyx_v_self->t_len));

              /* "btdht/krcp.pyx":1001
 *                         rep.set_y(b"r", 1)
 *                         rep.set_t(self._t, self.t_len)
 *                         rep.set_r(True)             # <<<<<<<<<<<<<<
 *                         rep.set_id(id, 20)
 *                         with gil:
 */
              (void)(((struct __pyx_vtabstruct_5btdht_4krcp_BMessage *)__pyx_v_rep->__pyx_vtab)->set_r(__pyx_v_rep, 1));

              /* "btdht/krcp.pyx":1002
 *                         rep.set_t(self._t, self.t_len)
 *                         rep.set_r(True)
 *                         rep.set_id(id, 20)             # <<<<<<<<<<<<<<
 *                         with gil:
 *                             s = dht.get_closest_nodes(self.target[:20], compact=True)
 */
              __pyx_t_6 = ((struct __pyx_vtabstruct_5btdht_4krcp_BMessage *)__pyx_v_rep->__pyx_vtab)->set_id(__pyx_v_rep, __pyx_v_id, 20); if (unlikely(__pyx_t_6 == ((int)-1))) __PYX_ERR(0, 1002, __pyx_L4_error)

              /* "btdht/krcp.pyx":1003
 *                         rep.set_r(True)
 *                         rep.set_id(id, 20)
 *                         with gil:             # <<<<<<<<<<<<<<
 *                             s = dht.get_closest_nodes(self.target[:20], compact=True)
 *                             nodes = s
 */
              {
                  #ifdef WITH_THREAD
                  PyGILState_STATE __pyx_gilstate_save = __Pyx_PyGILState_Ensure();
                  #endif
                  /*try:*/ {

                    /* "btdht/krcp.pyx":1004
 *                         rep.set_id(id, 20)
 *                         with gil:
 *                             s = dht.get_closest_nodes(self.target[:20], compact=True)             # <<<<<<<<<<<<<<
 *                             nodes = s
 *                             l1 = len(nodes)
 */
                    __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_dht, __pyx_n_s_get_closest_nodes); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1004, __pyx_L24_error)
                    __Pyx_GOTREF(__pyx_t_2);
                    __pyx_t_1 = __Pyx_PyBytes_FromStringAndSize(__pyx_v_self->target + 0, 20 - 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1004, __pyx_L24_error)
                    __Pyx_GOTREF(__pyx_t_1);
                    __pyx_t_9 = PyTuple_New(1); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 1004, __pyx_L24_error)
                    __Pyx_GOTREF(__pyx_t_9);
                    __Pyx_GIVEREF(__pyx_t_1);
                    PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_t_1);
                    __pyx_t_1 = 0;
                    __pyx_t_1 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1004, __pyx_L24_error)
                    __Pyx_GOTREF(__pyx_t_1);
                    if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_compact, Py_True) < 0) __PYX_ERR(0, 1004, __pyx_L24_error)
                    __pyx_t_7 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_9, __pyx_t_1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1004, __pyx_L24_error)
                    __Pyx_GOTREF(__pyx_t_7);
                    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
                    __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
                    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
                    __Pyx_DECREF_SET(__pyx_v_s, __pyx_t_7);
                    __pyx_t_7 = 0;

                    /* "btdht/krcp.pyx":1005
 *                         with gil:
 *                             s = dht.get_closest_nodes(self.target[:20], compact=True)
 *                             nodes = s             # <<<<<<<<<<<<<<
 *                             l1 = len(nodes)
 *                         rep.set_nodes(nodes, l1)
 */
                    __pyx_t_3 = __Pyx_PyObject_AsWritableString(__pyx_v_s); if (unlikely((!__pyx_t_3) && PyErr_Occurred())) __PYX_ERR(0, 1005, __pyx_L24_error)
                    __pyx_v_nodes = __pyx_t_3;

                    /* "btdht/krcp.pyx":1006
 *                             s = dht.get_closest_nodes(self.target[:20], compact=True)
 *                             nodes = s
 *                             l1 = len(nodes)             # <<<<<<<<<<<<<<
 *                         rep.set_nodes(nodes, l1)
 *                         self._encode()
 */
                    __pyx_t_10 = strlen(__pyx_v_nodes); 
                    __pyx_v_l1 = __pyx_t_10;
                  }

                  /* "btdht/krcp.pyx":1003
 *                         rep.set_r(True)
 *                         rep.set_id(id, 20)
 *                         with gil:             # <<<<<<<<<<<<<<
 *                             s = dht.get_closest_nodes(self.target[:20], compact=True)
 *                             nodes = s
 */
                  /*finally:*/ {
                    /*normal exit:*/{
                      #ifdef WITH_THREAD
                      __Pyx_PyGILState_Release(__pyx_gilstate_save);
                      #endif
                      goto __pyx_L25;
                    }
                    __pyx_L24_error: {
                      #ifdef WITH_THREAD
                      __Pyx_PyGILState_Release(__pyx_gilstate_save);
                      #endif
                      goto __pyx_L4_error;
                    }
                    __pyx_L25:;
                  }
              }

              /* "btdht/krcp.pyx":1007
 *                             nodes = s
 *                             l1 = len(nodes)
 *                         rep.set_nodes(nodes, l1)             # <<<<<<<<<<<<<<
 *                         self._encode()
 *                         with gil:
 */
              (void)(((struct __pyx_vtabstruct_5btdht_4krcp_BMessage *)__pyx_v_rep->__pyx_vtab)->set_nodes(__pyx_v_rep, __pyx_v_nodes, __pyx_v_l1));

              /* "btdht/krcp.pyx":1008
 *                             l1 = len(nodes)
 *                         rep.set_nodes(nodes, l1)
 *                         self._encode()             # <<<<<<<<<<<<<<
 *                         with gil:
 *                             return rep
 */
              (void)(((struct __pyx_vtabstruct_5btdht_4krcp_BMessage *)__pyx_v_self->__pyx_vtab)->_encode(__pyx_v_self));

              /* "btdht/krcp.pyx":1009
 *                         rep.set_nodes(nodes, l1)
 *                         self._encode()
 *                         with gil:             # <<<<<<<<<<<<<<
 *                             return rep
 *                     elif self.q_len == 9 and strncmp(self._q, b"get_peers", 9) == 0:
 */
              {
                  #ifdef WITH_THREAD
                  PyGILState_STATE __pyx_gilstate_save = __Pyx_PyGILState_Ensure();
                  #endif
                  /*try:*/ {

                    /* "btdht/krcp.pyx":1010
 *                         self._encode()
 *                         with gil:
 *                             return rep             # <<<<<<<<<<<<<<
 *                     elif self.q_len == 9 and strncmp(self._q, b"get_peers", 9) == 0:
 *                         if not self.has_info_hash:
 */
                    __Pyx_XDECREF(__pyx_r);
                    __Pyx_INCREF(((PyObject *)__pyx_v_rep));
                    __pyx_r = ((PyObject *)__pyx_v_rep);
                    goto __pyx_L26_return;
                  }

                  /* "btdht/krcp.pyx":1009
 *                         rep.set_nodes(nodes, l1)
 *                         self._encode()
 *                         with gil:             # <<<<<<<<<<<<<<
 *                             return rep
 *                     elif self.q_len == 9 and strncmp(self._q, b"get_peers", 9) == 0:
 */
                  /*finally:*/ {
                    __pyx_L26_return: {
                      #ifdef WITH_THREAD
                      __Pyx_PyGILState_Release(__pyx_gilstate_save);
                      #endif
                      goto __pyx_L3_return;
                    }
                  }
              }

              /* "btdht/krcp.pyx":995
 *                         with gil:
 *                             return rep
 *                     elif self.q_len == 9 and strncmp(self._q, b"find_nodes", 9) == 0:             # <<<<<<<<<<<<<<
 *                         if not self.has_target:
 *                             with gil:
 */
            }

            /* "btdht/krcp.pyx":1011
 *                         with gil:
 *                             return rep
 *                     elif self.q_len == 9 and strncmp(self._q, b"get_peers", 9) == 0:             # <<<<<<<<<<<<<<
 *                         if not self.has_info_hash:
 *                             with gil:
 */
            __pyx_t_5 = ((__pyx_v_self->q_len == 9) != 0);
            if (__pyx_t_5) {
            } else {
              __pyx_t_4 = __pyx_t_5;
              goto __pyx_L29_bool_binop_done;
            }
            __pyx_t_5 = ((strncmp(__pyx_v_self->_q, ((char const *)"get_peers"), 9) == 0) != 0);
            __pyx_t_4 = __pyx_t_5;
            __pyx_L29_bool_binop_done:;
            if (__pyx_t_4) {

              /* "btdht/krcp.pyx":1012
 *                             return rep
 *                     elif self.q_len == 9 and strncmp(self._q, b"get_peers", 9) == 0:
 *                         if not self.has_info_hash:             # <<<<<<<<<<<<<<
 *                             with gil:
 *                                 raise ProtocolError(self.t, b"info_hash missing")
 */
              __pyx_t_4 = ((!(__pyx_v_self->has_info_hash != 0)) != 0);
              if (__pyx_t_4) {

                /* "btdht/krcp.pyx":1013
 *                     elif self.q_len == 9 and strncmp(self._q, b"get_peers", 9) == 0:
 *                         if not self.has_info_hash:
 *                             with gil:             # <<<<<<<<<<<<<<
 *                                 raise ProtocolError(self.t, b"info_hash missing")
 *                         rep.set_y(b"r", 1)
 */
                {
                    #ifdef WITH_THREAD
                    PyGILState_STATE __pyx_gilstate_save = __Pyx_PyGILState_Ensure();
                    #endif
                    /*try:*/ {

                      /* "btdht/krcp.pyx":1014
 *                         if not self.has_info_hash:
 *                             with gil:
 *                                 raise ProtocolError(self.t, b"info_hash missing")             # <<<<<<<<<<<<<<
 *                         rep.set_y(b"r", 1)
 *                         rep.set_t(self._t, self.t_len)
 */
                      __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_ProtocolError); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1014, __pyx_L33_error)
                      __Pyx_GOTREF(__pyx_t_1);
                      __pyx_t_9 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_t); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 1014, __pyx_L33_error)
                      __Pyx_GOTREF(__pyx_t_9);
                      __pyx_t_2 = NULL;
                      __pyx_t_6 = 0;
                      if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_1))) {
                        __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_1);
                        if (likely(__pyx_t_2)) {
                          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1);
                          __Pyx_INCREF(__pyx_t_2);
                          __Pyx_INCREF(function);
                          __Pyx_DECREF_SET(__pyx_t_1, function);
                          __pyx_t_6 = 1;
                        }
                      }
                      #if CYTHON_FAST_PYCALL
                      if (PyFunction_Check(__pyx_t_1)) {
                        PyObject *__pyx_temp[3] = {__pyx_t_2, __pyx_t_9, __pyx_kp_b_info_hash_missing};
                        __pyx_t_7 = __Pyx_PyFunction_FastCall(__pyx_t_1, __pyx_temp+1-__pyx_t_6, 2+__pyx_t_6); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1014, __pyx_L33_error)
                        __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
                        __Pyx_GOTREF(__pyx_t_7);
                        __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
                      } else
                      #endif
                      #if CYTHON_FAST_PYCCALL
                      if (__Pyx_PyFastCFunction_Check(__pyx_t_1)) {
                        PyObject *__pyx_temp[3] = {__pyx_t_2, __pyx_t_9, __pyx_kp_b_info_hash_missing};
                        __pyx_t_7 = __Pyx_PyCFunction_FastCall(__pyx_t_1, __pyx_temp+1-__pyx_t_6, 2+__pyx_t_6); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1014, __pyx_L33_error)
                        __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
                        __Pyx_GOTREF(__pyx_t_7);
                        __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
                      } else
                      #endif
                      {
                        __pyx_t_8 = PyTuple_New(2+__pyx_t_6); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 1014, __pyx_L33_error)
                        __Pyx_GOTREF(__pyx_t_8);
                        if (__pyx_t_2) {
                          __Pyx_GIVEREF(__pyx_t_2); PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_2); __pyx_t_2 = NULL;
                        }
                        __Pyx_GIVEREF(__pyx_t_9);
                        PyTuple_SET_ITEM(__pyx_t_8, 0+__pyx_t_6, __pyx_t_9);
                        __Pyx_INCREF(__pyx_kp_b_info_hash_missing);
                        __Pyx_GIVEREF(__pyx_kp_b_info_hash_missing);
                        PyTuple_SET_ITEM(__pyx_t_8, 1+__pyx_t_6, __pyx_kp_b_info_hash_missing);
                        __pyx_t_9 = 0;
                        __pyx_t_7 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_8, NULL); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1014, __pyx_L33_error)
                        __Pyx_GOTREF(__pyx_t_7);
                        __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
                      }
                      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
                      __Pyx_Raise(__pyx_t_7, 0, 0, 0);
                      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
                      __PYX_ERR(0, 1014, __pyx_L33_error)
                    }

                    /* "btdht/krcp.pyx":1013
 *                     elif self.q_len == 9 and strncmp(self._q, b"get_peers", 9) == 0:
 *                         if not self.has_info_hash:
 *                             with gil:             # <<<<<<<<<<<<<<
 *                                 raise ProtocolError(self.t, b"info_hash missing")
 *                         rep.set_y(b"r", 1)
 */
                    /*finally:*/ {
                      __pyx_L33_error: {
                        #ifdef WITH_THREAD
                        __Pyx_PyGILState_Release(__pyx_gilstate_save);
                        #endif
                        goto __pyx_L4_error;
                      }
                    }
                }

                /* "btdht/krcp.pyx":1012
 *                             return rep
 *                     elif self.q_len == 9 and strncmp(self._q, b"get_peers", 9) == 0:
 *                         if not self.has_info_hash:             # <<<<<<<<<<<<<<
 *                             with gil:
 *                                 raise ProtocolError(self.t, b"info_hash missing")
 */
              }

              /* "btdht/krcp.pyx":1015
 *                             with gil:
 *                                 raise ProtocolError(self.t, b"info_hash missing")
 *                         rep.set_y(b"r", 1)             # <<<<<<<<<<<<<<
 *                         rep.set_t(self._t, self.t_len)
 *                         rep.set_r(True)
 */
              (void)(((struct __pyx_vtabstruct_5btdht_4krcp_BMessage *)__pyx_v_rep->__pyx_vtab)->set_y(__pyx_v_rep, ((char *)"r"), 1));

              /* "btdht/krcp.pyx":1016
 *                                 raise ProtocolError(self.t, b"info_hash missing")
 *                         rep.set_y(b"r", 1)
 *                         rep.set_t(self._t, self.t_len)             # <<<<<<<<<<<<<<
 *                         rep.set_r(True)
 *                         rep.set_id(id, 20)
 */
              (void)(((struct __pyx_vtabstruct_5btdht_4krcp_BMessage *)__pyx_v_rep->__pyx_vtab)->set_t(__pyx_v_rep, __pyx_v_self->_t, __pyx_v_self->t_len));

              /* "btdht/krcp.pyx":1017
 *                         rep.set_y(b"r", 1)
 *                         rep.set_t(self._t, self.t_len)
 *                         rep.set_r(True)             # <<<<<<<<<<<<<<
 *                         rep.set_id(id, 20)
 *                         with gil:
 */
              (void)(((struct __pyx_vtabstruct_5btdht_4krcp_BMessage *)__pyx_v_rep->__pyx_vtab)->set_r(__pyx_v_rep, 1));

              /* "btdht/krcp.pyx":1018
 *                         rep.set_t(self._t, self.t_len)
 *                         rep.set_r(True)
 *                         rep.set_id(id, 20)             # <<<<<<<<<<<<<<
 *                         with gil:
 *                             s = dht._get_token(self.addr[0])
 */
              __pyx_t_6 = ((struct __pyx_vtabstruct_5btdht_4krcp_BMessage *)__pyx_v_rep->__pyx_vtab)->set_id(__pyx_v_rep, __pyx_v_id, 20); if (unlikely(__pyx_t_6 == ((int)-1))) __PYX_ERR(0, 1018, __pyx_L4_error)

              /* "btdht/krcp.pyx":1019
 *                         rep.set_r(True)
 *                         rep.set_id(id, 20)
 *                         with gil:             # <<<<<<<<<<<<<<
 *                             s = dht._get_token(self.addr[0])
 *                             token = s
 */
              {
                  #ifdef WITH_THREAD
                  PyGILState_STATE __pyx_gilstate_save = __Pyx_PyGILState_Ensure();
                  #endif
                  /*try:*/ {

                    /* "btdht/krcp.pyx":1020
 *                         rep.set_id(id, 20)
 *                         with gil:
 *                             s = dht._get_token(self.addr[0])             # <<<<<<<<<<<<<<
 *                             token = s
 *                             l1 = len(s)
 */
                    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_dht, __pyx_n_s_get_token); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1020, __pyx_L36_error)
                    __Pyx_GOTREF(__pyx_t_1);
                    __pyx_t_8 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_addr); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 1020, __pyx_L36_error)
                    __Pyx_GOTREF(__pyx_t_8);
                    __pyx_t_9 = __Pyx_GetItemInt(__pyx_t_8, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 1020, __pyx_L36_error)
                    __Pyx_GOTREF(__pyx_t_9);
                    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
                    __pyx_t_8 = NULL;
                    if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_1))) {
                      __pyx_t_8 = PyMethod_GET_SELF(__pyx_t_1);
                      if (likely(__pyx_t_8)) {
                        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1);
                        __Pyx_INCREF(__pyx_t_8);
                        __Pyx_INCREF(function);
                        __Pyx_DECREF_SET(__pyx_t_1, function);
                      }
                    }
                    __pyx_t_7 = (__pyx_t_8) ? __Pyx_PyObject_Call2Args(__pyx_t_1, __pyx_t_8, __pyx_t_9) : __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_t_9);
                    __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
                    __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
                    if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1020, __pyx_L36_error)
                    __Pyx_GOTREF(__pyx_t_7);
                    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
                    __Pyx_DECREF_SET(__pyx_v_s, __pyx_t_7);
                    __pyx_t_7 = 0;

                    /* "btdht/krcp.pyx":1021
 *                         with gil:
 *                             s = dht._get_token(self.addr[0])
 *                             token = s             # <<<<<<<<<<<<<<
 *                             l1 = len(s)
 *                             s = dht._get_peers(self.info_hash[:20])
 */
                    __pyx_t_3 = __Pyx_PyObject_AsWritableString(__pyx_v_s); if (unlikely((!__pyx_t_3) && PyErr_Occurred())) __PYX_ERR(0, 1021, __pyx_L36_error)
                    __pyx_v_token = __pyx_t_3;

                    /* "btdht/krcp.pyx":1022
 *                             s = dht._get_token(self.addr[0])
 *                             token = s
 *                             l1 = len(s)             # <<<<<<<<<<<<<<
 *                             s = dht._get_peers(self.info_hash[:20])
 *                             if s:
 */
                    __pyx_t_11 = PyObject_Length(__pyx_v_s); if (unlikely(__pyx_t_11 == ((Py_ssize_t)-1))) __PYX_ERR(0, 1022, __pyx_L36_error)
                    __pyx_v_l1 = __pyx_t_11;

                    /* "btdht/krcp.pyx":1023
 *                             token = s
 *                             l1 = len(s)
 *                             s = dht._get_peers(self.info_hash[:20])             # <<<<<<<<<<<<<<
 *                             if s:
 *                                 values = vlist_to_array(s)
 */
                    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_dht, __pyx_n_s_get_peers); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1023, __pyx_L36_error)
                    __Pyx_GOTREF(__pyx_t_1);
                    __pyx_t_9 = __Pyx_PyBytes_FromStringAndSize(__pyx_v_self->info_hash + 0, 20 - 0); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 1023, __pyx_L36_error)
                    __Pyx_GOTREF(__pyx_t_9);
                    __pyx_t_8 = NULL;
                    if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_1))) {
                      __pyx_t_8 = PyMethod_GET_SELF(__pyx_t_1);
                      if (likely(__pyx_t_8)) {
                        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1);
                        __Pyx_INCREF(__pyx_t_8);
                        __Pyx_INCREF(function);
                        __Pyx_DECREF_SET(__pyx_t_1, function);
                      }
                    }
                    __pyx_t_7 = (__pyx_t_8) ? __Pyx_PyObject_Call2Args(__pyx_t_1, __pyx_t_8, __pyx_t_9) : __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_t_9);
                    __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
                    __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
                    if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1023, __pyx_L36_error)
                    __Pyx_GOTREF(__pyx_t_7);
                    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
                    __Pyx_DECREF_SET(__pyx_v_s, __pyx_t_7);
                    __pyx_t_7 = 0;

                    /* "btdht/krcp.pyx":1024
 *                             l1 = len(s)
 *                             s = dht._get_peers(self.info_hash[:20])
 *                             if s:             # <<<<<<<<<<<<<<
 *                                 values = vlist_to_array(s)
 *                             else:
 */
                    __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_v_s); if (unlikely(__pyx_t_4 < 0)) __PYX_ERR(0, 1024, __pyx_L36_error)
                    if (__pyx_t_4) {

                      /* "btdht/krcp.pyx":1025
 *                             s = dht._get_peers(self.info_hash[:20])
 *                             if s:
 *                                 values = vlist_to_array(s)             # <<<<<<<<<<<<<<
 *                             else:
 *                                 s = dht.get_closest_nodes(self.target[:20], compact=True)
 */
                      __pyx_v_values = __pyx_f_5btdht_4krcp_vlist_to_array(__pyx_v_s, NULL);

                      /* "btdht/krcp.pyx":1024
 *                             l1 = len(s)
 *                             s = dht._get_peers(self.info_hash[:20])
 *                             if s:             # <<<<<<<<<<<<<<
 *                                 values = vlist_to_array(s)
 *                             else:
 */
                      goto __pyx_L38;
                    }

                    /* "btdht/krcp.pyx":1027
 *                                 values = vlist_to_array(s)
 *                             else:
 *                                 s = dht.get_closest_nodes(self.target[:20], compact=True)             # <<<<<<<<<<<<<<
 *                                 nodes = s
 *                             l2 = len(s)
 */
                    /*else*/ {
                      __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_v_dht, __pyx_n_s_get_closest_nodes); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1027, __pyx_L36_error)
                      __Pyx_GOTREF(__pyx_t_7);
                      __pyx_t_1 = __Pyx_PyBytes_FromStringAndSize(__pyx_v_self->target + 0, 20 - 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1027, __pyx_L36_error)
                      __Pyx_GOTREF(__pyx_t_1);
                      __pyx_t_9 = PyTuple_New(1); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 1027, __pyx_L36_error)
                      __Pyx_GOTREF(__pyx_t_9);
                      __Pyx_GIVEREF(__pyx_t_1);
                      PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_t_1);
                      __pyx_t_1 = 0;
                      __pyx_t_1 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1027, __pyx_L36_error)
                      __Pyx_GOTREF(__pyx_t_1);
                      if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_compact, Py_True) < 0) __PYX_ERR(0, 1027, __pyx_L36_error)
                      __pyx_t_8 = __Pyx_PyObject_Call(__pyx_t_7, __pyx_t_9, __pyx_t_1); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 1027, __pyx_L36_error)
                      __Pyx_GOTREF(__pyx_t_8);
                      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
                      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
                      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
                      __Pyx_DECREF_SET(__pyx_v_s, __pyx_t_8);
                      __pyx_t_8 = 0;

                      /* "btdht/krcp.pyx":1028
 *                             else:
 *                                 s = dht.get_closest_nodes(self.target[:20], compact=True)
 *                                 nodes = s             # <<<<<<<<<<<<<<
 *                             l2 = len(s)
 *                         rep.set_token(token, l1)
 */
                      __pyx_t_3 = __Pyx_PyObject_AsWritableString(__pyx_v_s); if (unlikely((!__pyx_t_3) && PyErr_Occurred())) __PYX_ERR(0, 1028, __pyx_L36_error)
                      __pyx_v_nodes = __pyx_t_3;
                    }
                    __pyx_L38:;

                    /* "btdht/krcp.pyx":1029
 *                                 s = dht.get_closest_nodes(self.target[:20], compact=True)
 *                                 nodes = s
 *                             l2 = len(s)             # <<<<<<<<<<<<<<
 *                         rep.set_token(token, l1)
 *                         if values != NULL:
 */
                    __pyx_t_11 = PyObject_Length(__pyx_v_s); if (unlikely(__pyx_t_11 == ((Py_ssize_t)-1))) __PYX_ERR(0, 1029, __pyx_L36_error)
                    __pyx_v_l2 = __pyx_t_11;
                  }

                  /* "btdht/krcp.pyx":1019
 *                         rep.set_r(True)
 *                         rep.set_id(id, 20)
 *                         with gil:             # <<<<<<<<<<<<<<
 *                             s = dht._get_token(self.addr[0])
 *                             token = s
 */
                  /*finally:*/ {
                    /*normal exit:*/{
                      #ifdef WITH_THREAD
                      __Pyx_PyGILState_Release(__pyx_gilstate_save);
                      #endif
                      goto __pyx_L37;
                    }
                    __pyx_L36_error: {
                      #ifdef WITH_THREAD
                      __Pyx_PyGILState_Release(__pyx_gilstate_save);
                      #endif
                      goto __pyx_L4_error;
                    }
                    __pyx_L37:;
                  }
              }

              /* "btdht/krcp.pyx":1030
 *                                 nodes = s
 *                             l2 = len(s)
 *                         rep.set_token(token, l1)             # <<<<<<<<<<<<<<
 *                         if values != NULL:
 *                             rep.set_values(values, l2)
 */
              (void)(((struct __pyx_vtabstruct_5btdht_4krcp_BMessage *)__pyx_v_rep->__pyx_vtab)->set_token(__pyx_v_rep, __pyx_v_token, __pyx_v_l1));

              /* "btdht/krcp.pyx":1031
 *                             l2 = len(s)
 *                         rep.set_token(token, l1)
 *                         if values != NULL:             # <<<<<<<<<<<<<<
 *                             rep.set_values(values, l2)
 *                         else:
 */
              __pyx_t_4 = ((__pyx_v_values != NULL) != 0);
              if (__pyx_t_4) {

                /* "btdht/krcp.pyx":1032
 *                         rep.set_token(token, l1)
 *                         if values != NULL:
 *                             rep.set_values(values, l2)             # <<<<<<<<<<<<<<
 *                         else:
 *                             rep.set_nodes(nodes, l2)
 */
                (void)(((struct __pyx_vtabstruct_5btdht_4krcp_BMessage *)__pyx_v_rep->__pyx_vtab)->set_values(__pyx_v_rep, __pyx_v_values, __pyx_v_l2));

                /* "btdht/krcp.pyx":1031
 *                             l2 = len(s)
 *                         rep.set_token(token, l1)
 *                         if values != NULL:             # <<<<<<<<<<<<<<
 *                             rep.set_values(values, l2)
 *                         else:
 */
                goto __pyx_L39;
              }

              /* "btdht/krcp.pyx":1034
 *                             rep.set_values(values, l2)
 *                         else:
 *                             rep.set_nodes(nodes, l2)             # <<<<<<<<<<<<<<
 *                         self._encode()
 *                         with gil:
 */
              /*else*/ {
                (void)(((struct __pyx_vtabstruct_5btdht_4krcp_BMessage *)__pyx_v_rep->__pyx_vtab)->set_nodes(__pyx_v_rep, __pyx_v_nodes, __pyx_v_l2));
              }
              __pyx_L39:;

              /* "btdht/krcp.pyx":1035
 *                         else:
 *                             rep.set_nodes(nodes, l2)
 *                         self._encode()             # <<<<<<<<<<<<<<
 *                         with gil:
 *                             return rep
 */
              (void)(((struct __pyx_vtabstruct_5btdht_4krcp_BMessage *)__pyx_v_self->__pyx_vtab)->_encode(__pyx_v_self));

              /* "btdht/krcp.pyx":1036
 *                             rep.set_nodes(nodes, l2)
 *                         self._encode()
 *                         with gil:             # <<<<<<<<<<<<<<
 *                             return rep
 *                     elif self.q_len == 13 and strncmp(self._q, b"announce_peer", 13) == 0:
 */
              {
                  #ifdef WITH_THREAD
                  PyGILState_STATE __pyx_gilstate_save = __Pyx_PyGILState_Ensure();
                  #endif
                  /*try:*/ {

                    /* "btdht/krcp.pyx":1037
 *                         self._encode()
 *                         with gil:
 *                             return rep             # <<<<<<<<<<<<<<
 *                     elif self.q_len == 13 and strncmp(self._q, b"announce_peer", 13) == 0:
 *                         if not self.has_info_hash:
 */
                    __Pyx_XDECREF(__pyx_r);
                    __Pyx_INCREF(((PyObject *)__pyx_v_rep));
                    __pyx_r = ((PyObject *)__pyx_v_rep);
                    goto __pyx_L40_return;
                  }

                  /* "btdht/krcp.pyx":1036
 *                             rep.set_nodes(nodes, l2)
 *                         self._encode()
 *                         with gil:             # <<<<<<<<<<<<<<
 *                             return rep
 *                     elif self.q_len == 13 and strncmp(self._q, b"announce_peer", 13) == 0:
 */
                  /*finally:*/ {
                    __pyx_L40_return: {
                      #ifdef WITH_THREAD
                      __Pyx_PyGILState_Release(__pyx_gilstate_save);
                      #endif
                      goto __pyx_L3_return;
                    }
                  }
              }

              /* "btdht/krcp.pyx":1011
 *                         with gil:
 *                             return rep
 *                     elif self.q_len == 9 and strncmp(self._q, b"get_peers", 9) == 0:             # <<<<<<<<<<<<<<
 *                         if not self.has_info_hash:
 *                             with gil:
 */
            }

            /* "btdht/krcp.pyx":1038
 *                         with gil:
 *                             return rep
 *                     elif self.q_len == 13 and strncmp(self._q, b"announce_peer", 13) == 0:             # <<<<<<<<<<<<<<
 *                         if not self.has_info_hash:
 *                             with gil:
 */
            __pyx_t_5 = ((__pyx_v_self->q_len == 13) != 0);
            if (__pyx_t_5) {
            } else {
              __pyx_t_4 = __pyx_t_5;
              goto __pyx_L43_bool_binop_done;
            }
            __pyx_t_5 = ((strncmp(__pyx_v_self->_q, ((char const *)"announce_peer"), 13) == 0) != 0);
            __pyx_t_4 = __pyx_t_5;
            __pyx_L43_bool_binop_done:;
            if (__pyx_t_4) {

              /* "btdht/krcp.pyx":1039
 *                             return rep
 *                     elif self.q_len == 13 and strncmp(self._q, b"announce_peer", 13) == 0:
 *                         if not self.has_info_hash:             # <<<<<<<<<<<<<<
 *                             with gil:
 *                                 raise ProtocolError(self.t, b"info_hash missing")
 */
              __pyx_t_4 = ((!(__pyx_v_self->has_info_hash != 0)) != 0);
              if (__pyx_t_4) {

                /* "btdht/krcp.pyx":1040
 *                     elif self.q_len == 13 and strncmp(self._q, b"announce_peer", 13) == 0:
 *                         if not self.has_info_hash:
 *                             with gil:             # <<<<<<<<<<<<<<
 *                                 raise ProtocolError(self.t, b"info_hash missing")
 *                         if not self.has_port:
 */
                {
                    #ifdef WITH_THREAD
                    PyGILState_STATE __pyx_gilstate_save = __Pyx_PyGILState_Ensure();
                    #endif
                    /*try:*/ {

                      /* "btdht/krcp.pyx":1041
 *                         if not self.has_info_hash:
 *                             with gil:
 *                                 raise ProtocolError(self.t, b"info_hash missing")             # <<<<<<<<<<<<<<
 *                         if not self.has_port:
 *                             with gil:
 */
                      __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_ProtocolError); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1041, __pyx_L47_error)
                      __Pyx_GOTREF(__pyx_t_1);
                      __pyx_t_9 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_t); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 1041, __pyx_L47_error)
                      __Pyx_GOTREF(__pyx_t_9);
                      __pyx_t_7 = NULL;
                      __pyx_t_6 = 0;
                      if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_1))) {
                        __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_1);
                        if (likely(__pyx_t_7)) {
                          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1);
                          __Pyx_INCREF(__pyx_t_7);
                          __Pyx_INCREF(function);
                          __Pyx_DECREF_SET(__pyx_t_1, function);
                          __pyx_t_6 = 1;
                        }
                      }
                      #if CYTHON_FAST_PYCALL
                      if (PyFunction_Check(__pyx_t_1)) {
                        PyObject *__pyx_temp[3] = {__pyx_t_7, __pyx_t_9, __pyx_kp_b_info_hash_missing};
                        __pyx_t_8 = __Pyx_PyFunction_FastCall(__pyx_t_1, __pyx_temp+1-__pyx_t_6, 2+__pyx_t_6); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 1041, __pyx_L47_error)
                        __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
                        __Pyx_GOTREF(__pyx_t_8);
                        __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
                      } else
                      #endif
                      #if CYTHON_FAST_PYCCALL
                      if (__Pyx_PyFastCFunction_Check(__pyx_t_1)) {
                        PyObject *__pyx_temp[3] = {__pyx_t_7, __pyx_t_9, __pyx_kp_b_info_hash_missing};
                        __pyx_t_8 = __Pyx_PyCFunction_FastCall(__pyx_t_1, __pyx_temp+1-__pyx_t_6, 2+__pyx_t_6); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 1041, __pyx_L47_error)
                        __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
                        __Pyx_GOTREF(__pyx_t_8);
                        __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
                      } else
                      #endif
                      {
                        __pyx_t_2 = PyTuple_New(2+__pyx_t_6); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1041, __pyx_L47_error)
                        __Pyx_GOTREF(__pyx_t_2);
                        if (__pyx_t_7) {
                          __Pyx_GIVEREF(__pyx_t_7); PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_7); __pyx_t_7 = NULL;
                        }
                        __Pyx_GIVEREF(__pyx_t_9);
                        PyTuple_SET_ITEM(__pyx_t_2, 0+__pyx_t_6, __pyx_t_9);
                        __Pyx_INCREF(__pyx_kp_b_info_hash_missing);
                        __Pyx_GIVEREF(__pyx_kp_b_info_hash_missing);
                        PyTuple_SET_ITEM(__pyx_t_2, 1+__pyx_t_6, __pyx_kp_b_info_hash_missing);
                        __pyx_t_9 = 0;
                        __pyx_t_8 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_2, NULL); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 1041, __pyx_L47_error)
                        __Pyx_GOTREF(__pyx_t_8);
                        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
                      }
                      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
                      __Pyx_Raise(__pyx_t_8, 0, 0, 0);
                      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
                      __PYX_ERR(0, 1041, __pyx_L47_error)
                    }

                    /* "btdht/krcp.pyx":1040
 *                     elif self.q_len == 13 and strncmp(self._q, b"announce_peer", 13) == 0:
 *                         if not self.has_info_hash:
 *                             with gil:             # <<<<<<<<<<<<<<
 *                                 raise ProtocolError(self.t, b"info_hash missing")
 *                         if not self.has_port:
 */
                    /*finally:*/ {
                      __pyx_L47_error: {
                        #ifdef WITH_THREAD
                        __Pyx_PyGILState_Release(__pyx_gilstate_save);
                        #endif
                        goto __pyx_L4_error;
                      }
                    }
                }

                /* "btdht/krcp.pyx":1039
 *                             return rep
 *                     elif self.q_len == 13 and strncmp(self._q, b"announce_peer", 13) == 0:
 *                         if not self.has_info_hash:             # <<<<<<<<<<<<<<
 *                             with gil:
 *                                 raise ProtocolError(self.t, b"info_hash missing")
 */
              }

              /* "btdht/krcp.pyx":1042
 *                             with gil:
 *                                 raise ProtocolError(self.t, b"info_hash missing")
 *                         if not self.has_port:             # <<<<<<<<<<<<<<
 *                             with gil:
 *                                 raise ProtocolError(self.t, b"port missing")
 */
              __pyx_t_4 = ((!(__pyx_v_self->has_port != 0)) != 0);
              if (__pyx_t_4) {

                /* "btdht/krcp.pyx":1043
 *                                 raise ProtocolError(self.t, b"info_hash missing")
 *                         if not self.has_port:
 *                             with gil:             # <<<<<<<<<<<<<<
 *                                 raise ProtocolError(self.t, b"port missing")
 *                         if not self.has_token:
 */
                {
                    #ifdef WITH_THREAD
                    PyGILState_STATE __pyx_gilstate_save = __Pyx_PyGILState_Ensure();
                    #endif
                    /*try:*/ {

                      /* "btdht/krcp.pyx":1044
 *                         if not self.has_port:
 *                             with gil:
 *                                 raise ProtocolError(self.t, b"port missing")             # <<<<<<<<<<<<<<
 *                         if not self.has_token:
 *                             with gil:
 */
                      __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_ProtocolError); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1044, __pyx_L51_error)
                      __Pyx_GOTREF(__pyx_t_1);
                      __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_t); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1044, __pyx_L51_error)
                      __Pyx_GOTREF(__pyx_t_2);
                      __pyx_t_9 = NULL;
                      __pyx_t_6 = 0;
                      if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_1))) {
                        __pyx_t_9 = PyMethod_GET_SELF(__pyx_t_1);
                        if (likely(__pyx_t_9)) {
                          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1);
                          __Pyx_INCREF(__pyx_t_9);
                          __Pyx_INCREF(function);
                          __Pyx_DECREF_SET(__pyx_t_1, function);
                          __pyx_t_6 = 1;
                        }
                      }
                      #if CYTHON_FAST_PYCALL
                      if (PyFunction_Check(__pyx_t_1)) {
                        PyObject *__pyx_temp[3] = {__pyx_t_9, __pyx_t_2, __pyx_kp_b_port_missing};
                        __pyx_t_8 = __Pyx_PyFunction_FastCall(__pyx_t_1, __pyx_temp+1-__pyx_t_6, 2+__pyx_t_6); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 1044, __pyx_L51_error)
                        __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
                        __Pyx_GOTREF(__pyx_t_8);
                        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
                      } else
                      #endif
                      #if CYTHON_FAST_PYCCALL
                      if (__Pyx_PyFastCFunction_Check(__pyx_t_1)) {
                        PyObject *__pyx_temp[3] = {__pyx_t_9, __pyx_t_2, __pyx_kp_b_port_missing};
                        __pyx_t_8 = __Pyx_PyCFunction_FastCall(__pyx_t_1, __pyx_temp+1-__pyx_t_6, 2+__pyx_t_6); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 1044, __pyx_L51_error)
                        __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
                        __Pyx_GOTREF(__pyx_t_8);
                        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
                      } else
                      #endif
                      {
                        __pyx_t_7 = PyTuple_New(2+__pyx_t_6); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1044, __pyx_L51_error)
                        __Pyx_GOTREF(__pyx_t_7);
                        if (__pyx_t_9) {
                          __Pyx_GIVEREF(__pyx_t_9); PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_9); __pyx_t_9 = NULL;
                        }
                        __Pyx_GIVEREF(__pyx_t_2);
                        PyTuple_SET_ITEM(__pyx_t_7, 0+__pyx_t_6, __pyx_t_2);
                        __Pyx_INCREF(__pyx_kp_b_port_missing);
                        __Pyx_GIVEREF(__pyx_kp_b_port_missing);
                        PyTuple_SET_ITEM(__pyx_t_7, 1+__pyx_t_6, __pyx_kp_b_port_missing);
                        __pyx_t_2 = 0;
                        __pyx_t_8 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_7, NULL); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 1044, __pyx_L51_error)
                        __Pyx_GOTREF(__pyx_t_8);
                        __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
                      }
                      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
                      __Pyx_Raise(__pyx_t_8, 0, 0, 0);
                      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
                      __PYX_ERR(0, 1044, __pyx_L51_error)
                    }

                    /* "btdht/krcp.pyx":1043
 *                                 raise ProtocolError(self.t, b"info_hash missing")
 *                         if not self.has_port:
 *                             with gil:             # <<<<<<<<<<<<<<
 *                                 raise ProtocolError(self.t, b"port missing")
 *                         if not self.has_token:
 */
                    /*finally:*/ {
                      __pyx_L51_error: {
                        #ifdef WITH_THREAD
                        __Pyx_PyGILState_Release(__pyx_gilstate_save);
                        #endif
                        goto __pyx_L4_error;
                      }
                    }
                }

                /* "btdht/krcp.pyx":1042
 *                             with gil:
 *                                 raise ProtocolError(self.t, b"info_hash missing")
 *                         if not self.has_port:             # <<<<<<<<<<<<<<
 *                             with gil:
 *                                 raise ProtocolError(self.t, b"port missing")
 */
              }

              /* "btdht/krcp.pyx":1045
 *                             with gil:
 *                                 raise ProtocolError(self.t, b"port missing")
 *                         if not self.has_token:             # <<<<<<<<<<<<<<
 *                             with gil:
 *                                 raise ProtocolError(self.t, b"token missing")
 */
              __pyx_t_4 = ((!(__pyx_v_self->has_token != 0)) != 0);
              if (__pyx_t_4) {

                /* "btdht/krcp.pyx":1046
 *                                 raise ProtocolError(self.t, b"port missing")
 *                         if not self.has_token:
 *                             with gil:             # <<<<<<<<<<<<<<
 *                                 raise ProtocolError(self.t, b"token missing")
 *                         with gil:
 */
                {
                    #ifdef WITH_THREAD
                    PyGILState_STATE __pyx_gilstate_save = __Pyx_PyGILState_Ensure();
                    #endif
                    /*try:*/ {

                      /* "btdht/krcp.pyx":1047
 *                         if not self.has_token:
 *                             with gil:
 *                                 raise ProtocolError(self.t, b"token missing")             # <<<<<<<<<<<<<<
 *                         with gil:
 *                             s = dht._get_valid_token(self.addr[0])
 */
                      __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_ProtocolError); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1047, __pyx_L55_error)
                      __Pyx_GOTREF(__pyx_t_1);
                      __pyx_t_7 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_t); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1047, __pyx_L55_error)
                      __Pyx_GOTREF(__pyx_t_7);
                      __pyx_t_2 = NULL;
                      __pyx_t_6 = 0;
                      if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_1))) {
                        __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_1);
                        if (likely(__pyx_t_2)) {
                          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1);
                          __Pyx_INCREF(__pyx_t_2);
                          __Pyx_INCREF(function);
                          __Pyx_DECREF_SET(__pyx_t_1, function);
                          __pyx_t_6 = 1;
                        }
                      }
                      #if CYTHON_FAST_PYCALL
                      if (PyFunction_Check(__pyx_t_1)) {
                        PyObject *__pyx_temp[3] = {__pyx_t_2, __pyx_t_7, __pyx_kp_b_token_missing};
                        __pyx_t_8 = __Pyx_PyFunction_FastCall(__pyx_t_1, __pyx_temp+1-__pyx_t_6, 2+__pyx_t_6); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 1047, __pyx_L55_error)
                        __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
                        __Pyx_GOTREF(__pyx_t_8);
                        __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
                      } else
                      #endif
                      #if CYTHON_FAST_PYCCALL
                      if (__Pyx_PyFastCFunction_Check(__pyx_t_1)) {
                        PyObject *__pyx_temp[3] = {__pyx_t_2, __pyx_t_7, __pyx_kp_b_token_missing};
                        __pyx_t_8 = __Pyx_PyCFunction_FastCall(__pyx_t_1, __pyx_temp+1-__pyx_t_6, 2+__pyx_t_6); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 1047, __pyx_L55_error)
                        __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
                        __Pyx_GOTREF(__pyx_t_8);
                        __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
                      } else
                      #endif
                      {
                        __pyx_t_9 = PyTuple_New(2+__pyx_t_6); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 1047, __pyx_L55_error)
                        __Pyx_GOTREF(__pyx_t_9);
                        if (__pyx_t_2) {
                          __Pyx_GIVEREF(__pyx_t_2); PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_t_2); __pyx_t_2 = NULL;
                        }
                        __Pyx_GIVEREF(__pyx_t_7);
                        PyTuple_SET_ITEM(__pyx_t_9, 0+__pyx_t_6, __pyx_t_7);
                        __Pyx_INCREF(__pyx_kp_b_token_missing);
                        __Pyx_GIVEREF(__pyx_kp_b_token_missing);
                        PyTuple_SET_ITEM(__pyx_t_9, 1+__pyx_t_6, __pyx_kp_b_token_missing);
                        __pyx_t_7 = 0;
                        __pyx_t_8 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_9, NULL); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 1047, __pyx_L55_error)
                        __Pyx_GOTREF(__pyx_t_8);
                        __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
                      }
                      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
                      __Pyx_Raise(__pyx_t_8, 0, 0, 0);
                      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
                      __PYX_ERR(0, 1047, __pyx_L55_error)
                    }

                    /* "btdht/krcp.pyx":1046
 *                                 raise ProtocolError(self.t, b"port missing")
 *                         if not self.has_token:
 *                             with gil:             # <<<<<<<<<<<<<<
 *                                 raise ProtocolError(self.t, b"token missing")
 *                         with gil:
 */
                    /*finally:*/ {
                      __pyx_L55_error: {
                        #ifdef WITH_THREAD
                        __Pyx_PyGILState_Release(__pyx_gilstate_save);
                        #endif
                        goto __pyx_L4_error;
                      }
                    }
                }

                /* "btdht/krcp.pyx":1045
 *                             with gil:
 *                                 raise ProtocolError(self.t, b"port missing")
 *                         if not self.has_token:             # <<<<<<<<<<<<<<
 *                             with gil:
 *                                 raise ProtocolError(self.t, b"token missing")
 */
              }

              /* "btdht/krcp.pyx":1048
 *                             with gil:
 *                                 raise ProtocolError(self.t, b"token missing")
 *                         with gil:             # <<<<<<<<<<<<<<
 *                             s = dht._get_valid_token(self.addr[0])
 *                             if not self[b"token"] in s:
 */
              {
                  #ifdef WITH_THREAD
                  PyGILState_STATE __pyx_gilstate_save = __Pyx_PyGILState_Ensure();
                  #endif
                  /*try:*/ {

                    /* "btdht/krcp.pyx":1049
 *                                 raise ProtocolError(self.t, b"token missing")
 *                         with gil:
 *                             s = dht._get_valid_token(self.addr[0])             # <<<<<<<<<<<<<<
 *                             if not self[b"token"] in s:
 *                                 raise ProtocolError(self.t, b"bad token")
 */
                    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_dht, __pyx_n_s_get_valid_token); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1049, __pyx_L58_error)
                    __Pyx_GOTREF(__pyx_t_1);
                    __pyx_t_9 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_addr); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 1049, __pyx_L58_error)
                    __Pyx_GOTREF(__pyx_t_9);
                    __pyx_t_7 = __Pyx_GetItemInt(__pyx_t_9, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1049, __pyx_L58_error)
                    __Pyx_GOTREF(__pyx_t_7);
                    __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
                    __pyx_t_9 = NULL;
                    if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_1))) {
                      __pyx_t_9 = PyMethod_GET_SELF(__pyx_t_1);
                      if (likely(__pyx_t_9)) {
                        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1);
                        __Pyx_INCREF(__pyx_t_9);
                        __Pyx_INCREF(function);
                        __Pyx_DECREF_SET(__pyx_t_1, function);
                      }
                    }
                    __pyx_t_8 = (__pyx_t_9) ? __Pyx_PyObject_Call2Args(__pyx_t_1, __pyx_t_9, __pyx_t_7) : __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_t_7);
                    __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
                    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
                    if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 1049, __pyx_L58_error)
                    __Pyx_GOTREF(__pyx_t_8);
                    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
                    __Pyx_DECREF_SET(__pyx_v_s, __pyx_t_8);
                    __pyx_t_8 = 0;

                    /* "btdht/krcp.pyx":1050
 *                         with gil:
 *                             s = dht._get_valid_token(self.addr[0])
 *                             if not self[b"token"] in s:             # <<<<<<<<<<<<<<
 *                                 raise ProtocolError(self.t, b"bad token")
 *                         rep.set_y(b"r", 1)
 */
                    __pyx_t_8 = __Pyx_PyObject_GetItem(((PyObject *)__pyx_v_self), __pyx_n_b_token); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 1050, __pyx_L58_error)
                    __Pyx_GOTREF(__pyx_t_8);
                    __pyx_t_4 = (__Pyx_PySequence_ContainsTF(__pyx_t_8, __pyx_v_s, Py_NE)); if (unlikely(__pyx_t_4 < 0)) __PYX_ERR(0, 1050, __pyx_L58_error)
                    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
                    __pyx_t_5 = (__pyx_t_4 != 0);
                    if (unlikely(__pyx_t_5)) {

                      /* "btdht/krcp.pyx":1051
 *                             s = dht._get_valid_token(self.addr[0])
 *                             if not self[b"token"] in s:
 *                                 raise ProtocolError(self.t, b"bad token")             # <<<<<<<<<<<<<<
 *                         rep.set_y(b"r", 1)
 *                         rep.set_t(self._t, self.t_len)
 */
                      __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_ProtocolError); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1051, __pyx_L58_error)
                      __Pyx_GOTREF(__pyx_t_1);
                      __pyx_t_7 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_t); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1051, __pyx_L58_error)
                      __Pyx_GOTREF(__pyx_t_7);
                      __pyx_t_9 = NULL;
                      __pyx_t_6 = 0;
                      if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_1))) {
                        __pyx_t_9 = PyMethod_GET_SELF(__pyx_t_1);
                        if (likely(__pyx_t_9)) {
                          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1);
                          __Pyx_INCREF(__pyx_t_9);
                          __Pyx_INCREF(function);
                          __Pyx_DECREF_SET(__pyx_t_1, function);
                          __pyx_t_6 = 1;
                        }
                      }
                      #if CYTHON_FAST_PYCALL
                      if (PyFunction_Check(__pyx_t_1)) {
                        PyObject *__pyx_temp[3] = {__pyx_t_9, __pyx_t_7, __pyx_kp_b_bad_token};
                        __pyx_t_8 = __Pyx_PyFunction_FastCall(__pyx_t_1, __pyx_temp+1-__pyx_t_6, 2+__pyx_t_6); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 1051, __pyx_L58_error)
                        __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
                        __Pyx_GOTREF(__pyx_t_8);
                        __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
                      } else
                      #endif
                      #if CYTHON_FAST_PYCCALL
                      if (__Pyx_PyFastCFunction_Check(__pyx_t_1)) {
                        PyObject *__pyx_temp[3] = {__pyx_t_9, __pyx_t_7, __pyx_kp_b_bad_token};
                        __pyx_t_8 = __Pyx_PyCFunction_FastCall(__pyx_t_1, __pyx_temp+1-__pyx_t_6, 2+__pyx_t_6); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 1051, __pyx_L58_error)
                        __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
                        __Pyx_GOTREF(__pyx_t_8);
                        __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
                      } else
                      #endif
                      {
                        __pyx_t_2 = PyTuple_New(2+__pyx_t_6); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1051, __pyx_L58_error)
                        __Pyx_GOTREF(__pyx_t_2);
                        if (__pyx_t_9) {
                          __Pyx_GIVEREF(__pyx_t_9); PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_9); __pyx_t_9 = NULL;
                        }
                        __Pyx_GIVEREF(__pyx_t_7);
                        PyTuple_SET_ITEM(__pyx_t_2, 0+__pyx_t_6, __pyx_t_7);
                        __Pyx_INCREF(__pyx_kp_b_bad_token);
                        __Pyx_GIVEREF(__pyx_kp_b_bad_token);
                        PyTuple_SET_ITEM(__pyx_t_2, 1+__pyx_t_6, __pyx_kp_b_bad_token);
                        __pyx_t_7 = 0;
                        __pyx_t_8 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_2, NULL); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 1051, __pyx_L58_error)
                        __Pyx_GOTREF(__pyx_t_8);
                        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
                      }
                      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
                      __Pyx_Raise(__pyx_t_8, 0, 0, 0);
                      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
                      __PYX_ERR(0, 1051, __pyx_L58_error)

                      /* "btdht/krcp.pyx":1050
 *                         with gil:
 *                             s = dht._get_valid_token(self.addr[0])
 *                             if not self[b"token"] in s:             # <<<<<<<<<<<<<<
 *                                 raise ProtocolError(self.t, b"bad token")
 *                         rep.set_y(b"r", 1)
 */
                    }
                  }

                  /* "btdht/krcp.pyx":1048
 *                             with gil:
 *                                 raise ProtocolError(self.t, b"token missing")
 *                         with gil:             # <<<<<<<<<<<<<<
 *                             s = dht._get_valid_token(self.addr[0])
 *                             if not self[b"token"] in s:
 */
                  /*finally:*/ {
                    /*normal exit:*/{
                      #ifdef WITH_THREAD
                      __Pyx_PyGILState_Release(__pyx_gilstate_save);
                      #endif
                      goto __pyx_L59;
                    }
                    __pyx_L58_error: {
                      #ifdef WITH_THREAD
                      __Pyx_PyGILState_Release(__pyx_gilstate_save);
                      #endif
                      goto __pyx_L4_error;
                    }
                    __pyx_L59:;
                  }
              }

              /* "btdht/krcp.pyx":1052
 *                             if not self[b"token"] in s:
 *                                 raise ProtocolError(self.t, b"bad token")
 *                         rep.set_y(b"r", 1)             # <<<<<<<<<<<<<<
 *                         rep.set_t(self._t, self.t_len)
 *                         rep.set_r(True)
 */
              (void)(((struct __pyx_vtabstruct_5btdht_4krcp_BMessage *)__pyx_v_rep->__pyx_vtab)->set_y(__pyx_v_rep, ((char *)"r"), 1));

              /* "btdht/krcp.pyx":1053
 *                                 raise ProtocolError(self.t, b"bad token")
 *                         rep.set_y(b"r", 1)
 *                         rep.set_t(self._t, self.t_len)             # <<<<<<<<<<<<<<
 *                         rep.set_r(True)
 *                         rep.set_id(id, 20)
 */
              (void)(((struct __pyx_vtabstruct_5btdht_4krcp_BMessage *)__pyx_v_rep->__pyx_vtab)->set_t(__pyx_v_rep, __pyx_v_self->_t, __pyx_v_self->t_len));

              /* "btdht/krcp.pyx":1054
 *                         rep.set_y(b"r", 1)
 *                         rep.set_t(self._t, self.t_len)
 *                         rep.set_r(True)             # <<<<<<<<<<<<<<
 *                         rep.set_id(id, 20)
 *                         self._encode()
 */
              (void)(((struct __pyx_vtabstruct_5btdht_4krcp_BMessage *)__pyx_v_rep->__pyx_vtab)->set_r(__pyx_v_rep, 1));

              /* "btdht/krcp.pyx":1055
 *                         rep.set_t(self._t, self.t_len)
 *                         rep.set_r(True)
 *                         rep.set_id(id, 20)             # <<<<<<<<<<<<<<
 *                         self._encode()
 *                         with gil:
 */
              __pyx_t_6 = ((struct __pyx_vtabstruct_5btdht_4krcp_BMessage *)__pyx_v_rep->__pyx_vtab)->set_id(__pyx_v_rep, __pyx_v_id, 20); if (unlikely(__pyx_t_6 == ((int)-1))) __PYX_ERR(0, 1055, __pyx_L4_error)

              /* "btdht/krcp.pyx":1056
 *                         rep.set_r(True)
 *                         rep.set_id(id, 20)
 *                         self._encode()             # <<<<<<<<<<<<<<
 *                         with gil:
 *                             return rep
 */
              (void)(((struct __pyx_vtabstruct_5btdht_4krcp_BMessage *)__pyx_v_self->__pyx_vtab)->_encode(__pyx_v_self));

              /* "btdht/krcp.pyx":1057
 *                         rep.set_id(id, 20)
 *                         self._encode()
 *                         with gil:             # <<<<<<<<<<<<<<
 *                             return rep
 *                     else:
 */
              {
                  #ifdef WITH_THREAD
                  PyGILState_STATE __pyx_gilstate_save = __Pyx_PyGILState_Ensure();
                  #endif
                  /*try:*/ {

                    /* "btdht/krcp.pyx":1058
 *                         self._encode()
 *                         with gil:
 *                             return rep             # <<<<<<<<<<<<<<
 *                     else:
 *                         with gil:
 */
                    __Pyx_XDECREF(__pyx_r);
                    __Pyx_INCREF(((PyObject *)__pyx_v_rep));
                    __pyx_r = ((PyObject *)__pyx_v_rep);
                    goto __pyx_L61_return;
                  }

                  /* "btdht/krcp.pyx":1057
 *                         rep.set_id(id, 20)
 *                         self._encode()
 *                         with gil:             # <<<<<<<<<<<<<<
 *                             return rep
 *                     else:
 */
                  /*finally:*/ {
                    __pyx_L61_return: {
                      #ifdef WITH_THREAD
                      __Pyx_PyGILState_Release(__pyx_gilstate_save);
                      #endif
                      goto __pyx_L3_return;
                    }
                  }
              }

              /* "btdht/krcp.pyx":1038
 *                         with gil:
 *                             return rep
 *                     elif self.q_len == 13 and strncmp(self._q, b"announce_peer", 13) == 0:             # <<<<<<<<<<<<<<
 *                         if not self.has_info_hash:
 *                             with gil:
 */
            }

            /* "btdht/krcp.pyx":1060
 *                             return rep
 *                     else:
 *                         with gil:             # <<<<<<<<<<<<<<
 *                             raise MethodUnknownError(self.t, b"Method %s Unknown" % self.q)
 *                 else:
 */
            /*else*/ {
              {
                  #ifdef WITH_THREAD
                  PyGILState_STATE __pyx_gilstate_save = __Pyx_PyGILState_Ensure();
                  #endif
                  /*try:*/ {

                    /* "btdht/krcp.pyx":1061
 *                     else:
 *                         with gil:
 *                             raise MethodUnknownError(self.t, b"Method %s Unknown" % self.q)             # <<<<<<<<<<<<<<
 *                 else:
 *                     printf("no rpc method name %d\n", 0)
 */
                    __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_MethodUnknownError); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1061, __pyx_L65_error)
                    __Pyx_GOTREF(__pyx_t_1);
                    __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_t); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1061, __pyx_L65_error)
                    __Pyx_GOTREF(__pyx_t_2);
                    __pyx_t_7 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_q); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1061, __pyx_L65_error)
                    __Pyx_GOTREF(__pyx_t_7);
                    __pyx_t_9 = PyNumber_Remainder(__pyx_kp_b_Method_s_Unknown, __pyx_t_7); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 1061, __pyx_L65_error)
                    __Pyx_GOTREF(__pyx_t_9);
                    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
                    __pyx_t_7 = NULL;
                    __pyx_t_6 = 0;
                    if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_1))) {
                      __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_1);
                      if (likely(__pyx_t_7)) {
                        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1);
                        __Pyx_INCREF(__pyx_t_7);
                        __Pyx_INCREF(function);
                        __Pyx_DECREF_SET(__pyx_t_1, function);
                        __pyx_t_6 = 1;
                      }
                    }
                    #if CYTHON_FAST_PYCALL
                    if (PyFunction_Check(__pyx_t_1)) {
                      PyObject *__pyx_temp[3] = {__pyx_t_7, __pyx_t_2, __pyx_t_9};
                      __pyx_t_8 = __Pyx_PyFunction_FastCall(__pyx_t_1, __pyx_temp+1-__pyx_t_6, 2+__pyx_t_6); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 1061, __pyx_L65_error)
                      __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
                      __Pyx_GOTREF(__pyx_t_8);
                      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
                      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
                    } else
                    #endif
                    #if CYTHON_FAST_PYCCALL
                    if (__Pyx_PyFastCFunction_Check(__pyx_t_1)) {
                      PyObject *__pyx_temp[3] = {__pyx_t_7, __pyx_t_2, __pyx_t_9};
                      __pyx_t_8 = __Pyx_PyCFunction_FastCall(__pyx_t_1, __pyx_temp+1-__pyx_t_6, 2+__pyx_t_6); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 1061, __pyx_L65_error)
                      __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
                      __Pyx_GOTREF(__pyx_t_8);
                      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
                      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
                    } else
                    #endif
                    {
                      __pyx_t_12 = PyTuple_New(2+__pyx_t_6); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 1061, __pyx_L65_error)
                      __Pyx_GOTREF(__pyx_t_12);
                      if (__pyx_t_7) {
                        __Pyx_GIVEREF(__pyx_t_7); PyTuple_SET_ITEM(__pyx_t_12, 0, __pyx_t_7); __pyx_t_7 = NULL;
                      }
                      __Pyx_GIVEREF(__pyx_t_2);
                      PyTuple_SET_ITEM(__pyx_t_12, 0+__pyx_t_6, __pyx_t_2);
                      __Pyx_GIVEREF(__pyx_t_9);
                      PyTuple_SET_ITEM(__pyx_t_12, 1+__pyx_t_6, __pyx_t_9);
                      __pyx_t_2 = 0;
                      __pyx_t_9 = 0;
                      __pyx_t_8 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_12, NULL); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 1061, __pyx_L65_error)
                      __Pyx_GOTREF(__pyx_t_8);
                      __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
                    }
                    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
                    __Pyx_Raise(__pyx_t_8, 0, 0, 0);
                    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
                    __PYX_ERR(0, 1061, __pyx_L65_error)
                  }

                  /* "btdht/krcp.pyx":1060
 *                             return rep
 *                     else:
 *                         with gil:             # <<<<<<<<<<<<<<
 *                             raise MethodUnknownError(self.t, b"Method %s Unknown" % self.q)
 *                 else:
 */
                  /*finally:*/ {
                    __pyx_L65_error: {
                      #ifdef WITH_THREAD
                      __Pyx_PyGILState_Release(__pyx_gilstate_save);
                      #endif
                      goto __pyx_L4_error;
                    }
                  }
              }
            }

            /* "btdht/krcp.pyx":986
 *         with nogil:
 *             if self.has_y and self.y_len == 1 and strncmp(self._y, b"q", 1) == 0:
 *                 if self.has_q:             # <<<<<<<<<<<<<<
 *                     if self.q_len == 4 and strncmp(self._q, b"ping", 4) == 0:
 *                         rep.set_y(b"r", 1)
 */
          }

          /* "btdht/krcp.pyx":1063
 *                             raise MethodUnknownError(self.t, b"Method %s Unknown" % self.q)
 *                 else:
 *                     printf("no rpc method name %d\n", 0)             # <<<<<<<<<<<<<<
 *             else:
 *                 printf("not query %d\n", 1)
 */
          /*else*/ {
            (void)(printf(((char const *)"no rpc method name %d\n"), 0));
          }

          /* "btdht/krcp.pyx":985
 *         id = s
 *         with nogil:
 *             if self.has_y and self.y_len == 1 and strncmp(self._y, b"q", 1) == 0:             # <<<<<<<<<<<<<<
 *                 if self.has_q:
 *                     if self.q_len == 4 and strncmp(self._q, b"ping", 4) == 0:
 */
          goto __pyx_L6;
        }

        /* "btdht/krcp.pyx":1065
 *                     printf("no rpc method name %d\n", 0)
 *             else:
 *                 printf("not query %d\n", 1)             # <<<<<<<<<<<<<<
 * 
 *     cdef int _encode_values(self, char* data, int* i, int max) nogil:
 */
        /*else*/ {
          (void)(printf(((char const *)"not query %d\n"), 1));
        }
        __pyx_L6:;
      }

      /* "btdht/krcp.pyx":984
 *         s = dht.myid.value
 *         id = s
 *         with nogil:             # <<<<<<<<<<<<<<
 *             if self.has_y and self.y_len == 1 and strncmp(self._y, b"q", 1) == 0:
 *                 if self.has_q:
 */
      /*finally:*/ {
        /*normal exit:*/{
          #ifdef WITH_THREAD
          __Pyx_FastGIL_Forget();
          Py_BLOCK_THREADS
          #endif
          goto __pyx_L5;
        }
        __pyx_L3_return: {
          #ifdef WITH_THREAD
          __Pyx_FastGIL_Forget();
          Py_BLOCK_THREADS
          #endif
          goto __pyx_L0;
        }
        __pyx_L4_error: {
          #ifdef WITH_THREAD
          __Pyx_FastGIL_Forget();
          Py_BLOCK_THREADS
          #endif
          goto __pyx_L1_error;
        }
        __pyx_L5:;
      }
  }

  /* "btdht/krcp.pyx":965
 *             free(self.encoded)
 * 
 *     def response(self, dht):             # <<<<<<<<<<<<<<
 *         """
 *             If the message is a query, return the response message to send
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_XDECREF(__pyx_t_9);
  __Pyx_XDECREF(__pyx_t_12);
  __Pyx_AddTraceback("btdht.krcp.BMessage.response", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_rep);
  __Pyx_XDECREF(__pyx_v_s);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "btdht/krcp.pyx":1067
 *                 printf("not query %d\n", 1)
 * 
 *     cdef int _encode_values(self, char* data, int* i, int max) nogil:             # <<<<<<<<<<<<<<
 *         """
 *             If the values attribute of the message is set, bencode it in ``data``
 */

static int __pyx_f_5btdht_4krcp_8BMessage__encode_values(struct __pyx_obj_5btdht_4krcp_BMessage *__pyx_v_self, char *__pyx_v_data, int *__pyx_v_i, int __pyx_v_max) {
  int __pyx_v_j;
  int __pyx_r;
  int __pyx_t_1;
  long __pyx_t_2;
  int __pyx_t_3;
  int __pyx_t_4;
  int __pyx_t_5;

  /* "btdht/krcp.pyx":1081
 *         """
 *         cdef int j
 *         if i[0] + self.values_nb * 8 + 2 > max:             # <<<<<<<<<<<<<<
 *             printf("encode_values: %d < %d\n", max, i[0] + self.values_nb * 8 + 2)
 *             return False
 */
  __pyx_t_1 = (((((__pyx_v_i[0]) + (__pyx_v_self->values_nb * 8)) + 2) > __pyx_v_max) != 0);
  if (__pyx_t_1) {

    /* "btdht/krcp.pyx":1082
 *         cdef int j
 *         if i[0] + self.values_nb * 8 + 2 > max:
 *             printf("encode_values: %d < %d\n", max, i[0] + self.values_nb * 8 + 2)             # <<<<<<<<<<<<<<
 *             return False
 *         data[i[0]]=b'l'
 */
    (void)(printf(((char const *)"encode_values: %d < %d\n"), __pyx_v_max, (((__pyx_v_i[0]) + (__pyx_v_self->values_nb * 8)) + 2)));

    /* "btdht/krcp.pyx":1083
 *         if i[0] + self.values_nb * 8 + 2 > max:
 *             printf("encode_values: %d < %d\n", max, i[0] + self.values_nb * 8 + 2)
 *             return False             # <<<<<<<<<<<<<<
 *         data[i[0]]=b'l'
 *         i[0]+=1
 */
    __pyx_r = 0;
    goto __pyx_L0;

    /* "btdht/krcp.pyx":1081
 *         """
 *         cdef int j
 *         if i[0] + self.values_nb * 8 + 2 > max:             # <<<<<<<<<<<<<<
 *             printf("encode_values: %d < %d\n", max, i[0] + self.values_nb * 8 + 2)
 *             return False
 */
  }

  /* "btdht/krcp.pyx":1084
 *             printf("encode_values: %d < %d\n", max, i[0] + self.values_nb * 8 + 2)
 *             return False
 *         data[i[0]]=b'l'             # <<<<<<<<<<<<<<
 *         i[0]+=1
 *         for j in prange(self.values_nb):
 */
  (__pyx_v_data[(__pyx_v_i[0])]) = 'l';

  /* "btdht/krcp.pyx":1085
 *             return False
 *         data[i[0]]=b'l'
 *         i[0]+=1             # <<<<<<<<<<<<<<
 *         for j in prange(self.values_nb):
 *             #printf("encode value %d in encode_values\n", j)
 */
  __pyx_t_2 = 0;
  (__pyx_v_i[__pyx_t_2]) = ((__pyx_v_i[__pyx_t_2]) + 1);

  /* "btdht/krcp.pyx":1086
 *         data[i[0]]=b'l'
 *         i[0]+=1
 *         for j in prange(self.values_nb):             # <<<<<<<<<<<<<<
 *             #printf("encode value %d in encode_values\n", j)
 *             strncpy(data + i[0],"6:", 2)
 */
  __pyx_t_3 = __pyx_v_self->values_nb;
  if ((1 == 0)) abort();
  {
      #if ((defined(__APPLE__) || defined(__OSX__)) && (defined(__GNUC__) && (__GNUC__ > 2 || (__GNUC__ == 2 && (__GNUC_MINOR__ > 95)))))
          #undef likely
          #undef unlikely
          #define likely(x)   (x)
          #define unlikely(x) (x)
      #endif
      __pyx_t_5 = (__pyx_t_3 - 0 + 1 - 1/abs(1)) / 1;
      if (__pyx_t_5 > 0)
      {
          #ifdef _OPENMP
          #pragma omp parallel private(__pyx_t_2)
          #endif /* _OPENMP */
          {
              #ifdef _OPENMP
              #pragma omp for firstprivate(__pyx_v_j) lastprivate(__pyx_v_j)
              #endif /* _OPENMP */
              for (__pyx_t_4 = 0; __pyx_t_4 < __pyx_t_5; __pyx_t_4++){
                  {
                      __pyx_v_j = (int)(0 + 1 * __pyx_t_4);

                      /* "btdht/krcp.pyx":1088
 *         for j in prange(self.values_nb):
 *             #printf("encode value %d in encode_values\n", j)
 *             strncpy(data + i[0],"6:", 2)             # <<<<<<<<<<<<<<
 *             i[0]+=2
 *             strncpy(data + i[0], self.values[j], 6)
 */
                      (void)(strncpy((__pyx_v_data + (__pyx_v_i[0])), ((char const *)"6:"), 2));

                      /* "btdht/krcp.pyx":1089
 *             #printf("encode value %d in encode_values\n", j)
 *             strncpy(data + i[0],"6:", 2)
 *             i[0]+=2             # <<<<<<<<<<<<<<
 *             strncpy(data + i[0], self.values[j], 6)
 *             i[0]+=6
 */
                      __pyx_t_2 = 0;
                      (__pyx_v_i[__pyx_t_2]) = ((__pyx_v_i[__pyx_t_2]) + 2);

                      /* "btdht/krcp.pyx":1090
 *             strncpy(data + i[0],"6:", 2)
 *             i[0]+=2
 *             strncpy(data + i[0], self.values[j], 6)             # <<<<<<<<<<<<<<
 *             i[0]+=6
 *         data[i[0]]=b'e'
 */
                      (void)(strncpy((__pyx_v_data + (__pyx_v_i[0])), (__pyx_v_self->values[__pyx_v_j]), 6));

                      /* "btdht/krcp.pyx":1091
 *             i[0]+=2
 *             strncpy(data + i[0], self.values[j], 6)
 *             i[0]+=6             # <<<<<<<<<<<<<<
 *         data[i[0]]=b'e'
 *         i[0]+=1
 */
                      __pyx_t_2 = 0;
                      (__pyx_v_i[__pyx_t_2]) = ((__pyx_v_i[__pyx_t_2]) + 6);
                  }
              }
          }
      }
  }
  #if ((defined(__APPLE__) || defined(__OSX__)) && (defined(__GNUC__) && (__GNUC__ > 2 || (__GNUC__ == 2 && (__GNUC_MINOR__ > 95)))))
      #undef likely
      #undef unlikely
      #define likely(x)   __builtin_expect(!!(x), 1)
      #define unlikely(x) __builtin_expect(!!(x), 0)
  #endif

  /* "btdht/krcp.pyx":1092
 *             strncpy(data + i[0], self.values[j], 6)
 *             i[0]+=6
 *         data[i[0]]=b'e'             # <<<<<<<<<<<<<<
 *         i[0]+=1
 *         return True
 */
  (__pyx_v_data[(__pyx_v_i[0])]) = 'e';

  /* "btdht/krcp.pyx":1093
 *             i[0]+=6
 *         data[i[0]]=b'e'
 *         i[0]+=1             # <<<<<<<<<<<<<<
 *         return True
 * 
 */
  __pyx_t_2 = 0;
  (__pyx_v_i[__pyx_t_2]) = ((__pyx_v_i[__pyx_t_2]) + 1);

  /* "btdht/krcp.pyx":1094
 *         data[i[0]]=b'e'
 *         i[0]+=1
 *         return True             # <<<<<<<<<<<<<<
 * 
 *     cdef int _encode_secondary_dict(self, char* data, int* i, int max) nogil:
 */
  __pyx_r = 1;
  goto __pyx_L0;

  /* "btdht/krcp.pyx":1067
 *                 printf("not query %d\n", 1)
 * 
 *     cdef int _encode_values(self, char* data, int* i, int max) nogil:             # <<<<<<<<<<<<<<
 *         """
 *             If the values attribute of the message is set, bencode it in ``data``
 */

  /* function exit code */
  __pyx_L0:;
  return __pyx_r;
}

/* "btdht/krcp.pyx":1096
 *         return True
 * 
 *     cdef int _encode_secondary_dict(self, char* data, int* i, int max) nogil:             # <<<<<<<<<<<<<<
 *         """
 *             Bencode the secondary dictionnary of the message and write it to ``data``
 */

static int __pyx_f_5btdht_4krcp_8BMessage__encode_secondary_dict(struct __pyx_obj_5btdht_4krcp_BMessage *__pyx_v_self, char *__pyx_v_data, int *__pyx_v_i, int __pyx_v_max) {
  int __pyx_r;
  int __pyx_t_1;
  long __pyx_t_2;

  /* "btdht/krcp.pyx":1129
 *                     although no mecanism is preventing you to do it.
 *         """
 *         if i[0] + 1 > max:             # <<<<<<<<<<<<<<
 *             printf("encode_secondary:%d\n", 0)
 *             return False
 */
  __pyx_t_1 = ((((__pyx_v_i[0]) + 1) > __pyx_v_max) != 0);
  if (__pyx_t_1) {

    /* "btdht/krcp.pyx":1130
 *         """
 *         if i[0] + 1 > max:
 *             printf("encode_secondary:%d\n", 0)             # <<<<<<<<<<<<<<
 *             return False
 *         data[i[0]] = b'd'
 */
    (void)(printf(((char const *)"encode_secondary:%d\n"), 0));

    /* "btdht/krcp.pyx":1131
 *         if i[0] + 1 > max:
 *             printf("encode_secondary:%d\n", 0)
 *             return False             # <<<<<<<<<<<<<<
 *         data[i[0]] = b'd'
 *         i[0]+=1
 */
    __pyx_r = 0;
    goto __pyx_L0;

    /* "btdht/krcp.pyx":1129
 *                     although no mecanism is preventing you to do it.
 *         """
 *         if i[0] + 1 > max:             # <<<<<<<<<<<<<<
 *             printf("encode_secondary:%d\n", 0)
 *             return False
 */
  }

  /* "btdht/krcp.pyx":1132
 *             printf("encode_secondary:%d\n", 0)
 *             return False
 *         data[i[0]] = b'd'             # <<<<<<<<<<<<<<
 *         i[0]+=1
 *         if self.has_id:
 */
  (__pyx_v_data[(__pyx_v_i[0])]) = 'd';

  /* "btdht/krcp.pyx":1133
 *             return False
 *         data[i[0]] = b'd'
 *         i[0]+=1             # <<<<<<<<<<<<<<
 *         if self.has_id:
 *             if i[0] + 4 > max:
 */
  __pyx_t_2 = 0;
  (__pyx_v_i[__pyx_t_2]) = ((__pyx_v_i[__pyx_t_2]) + 1);

  /* "btdht/krcp.pyx":1134
 *         data[i[0]] = b'd'
 *         i[0]+=1
 *         if self.has_id:             # <<<<<<<<<<<<<<
 *             if i[0] + 4 > max:
 *                 printf("encode_secondary:%d\n", 1)
 */
  __pyx_t_1 = (__pyx_v_self->has_id != 0);
  if (__pyx_t_1) {

    /* "btdht/krcp.pyx":1135
 *         i[0]+=1
 *         if self.has_id:
 *             if i[0] + 4 > max:             # <<<<<<<<<<<<<<
 *                 printf("encode_secondary:%d\n", 1)
 *                 return False
 */
    __pyx_t_1 = ((((__pyx_v_i[0]) + 4) > __pyx_v_max) != 0);
    if (__pyx_t_1) {

      /* "btdht/krcp.pyx":1136
 *         if self.has_id:
 *             if i[0] + 4 > max:
 *                 printf("encode_secondary:%d\n", 1)             # <<<<<<<<<<<<<<
 *                 return False
 *             strncpy(data + i[0], b"2:id", 4)
 */
      (void)(printf(((char const *)"encode_secondary:%d\n"), 1));

      /* "btdht/krcp.pyx":1137
 *             if i[0] + 4 > max:
 *                 printf("encode_secondary:%d\n", 1)
 *                 return False             # <<<<<<<<<<<<<<
 *             strncpy(data + i[0], b"2:id", 4)
 *             i[0]+=4
 */
      __pyx_r = 0;
      goto __pyx_L0;

      /* "btdht/krcp.pyx":1135
 *         i[0]+=1
 *         if self.has_id:
 *             if i[0] + 4 > max:             # <<<<<<<<<<<<<<
 *                 printf("encode_secondary:%d\n", 1)
 *                 return False
 */
    }

    /* "btdht/krcp.pyx":1138
 *                 printf("encode_secondary:%d\n", 1)
 *                 return False
 *             strncpy(data + i[0], b"2:id", 4)             # <<<<<<<<<<<<<<
 *             i[0]+=4
 *             if not _encode_string(data, i, max, self.id, 20):
 */
    (void)(strncpy((__pyx_v_data + (__pyx_v_i[0])), ((char const *)"2:id"), 4));

    /* "btdht/krcp.pyx":1139
 *                 return False
 *             strncpy(data + i[0], b"2:id", 4)
 *             i[0]+=4             # <<<<<<<<<<<<<<
 *             if not _encode_string(data, i, max, self.id, 20):
 *                 return False
 */
    __pyx_t_2 = 0;
    (__pyx_v_i[__pyx_t_2]) = ((__pyx_v_i[__pyx_t_2]) + 4);

    /* "btdht/krcp.pyx":1140
 *             strncpy(data + i[0], b"2:id", 4)
 *             i[0]+=4
 *             if not _encode_string(data, i, max, self.id, 20):             # <<<<<<<<<<<<<<
 *                 return False
 *         if self.has_implied_port:
 */
    __pyx_t_1 = ((!(__pyx_f_5btdht_4krcp__encode_string(__pyx_v_data, __pyx_v_i, __pyx_v_max, __pyx_v_self->id, 20) != 0)) != 0);
    if (__pyx_t_1) {

      /* "btdht/krcp.pyx":1141
 *             i[0]+=4
 *             if not _encode_string(data, i, max, self.id, 20):
 *                 return False             # <<<<<<<<<<<<<<
 *         if self.has_implied_port:
 *             if i[0] + 15 > max:
 */
      __pyx_r = 0;
      goto __pyx_L0;

      /* "btdht/krcp.pyx":1140
 *             strncpy(data + i[0], b"2:id", 4)
 *             i[0]+=4
 *             if not _encode_string(data, i, max, self.id, 20):             # <<<<<<<<<<<<<<
 *                 return False
 *         if self.has_implied_port:
 */
    }

    /* "btdht/krcp.pyx":1134
 *         data[i[0]] = b'd'
 *         i[0]+=1
 *         if self.has_id:             # <<<<<<<<<<<<<<
 *             if i[0] + 4 > max:
 *                 printf("encode_secondary:%d\n", 1)
 */
  }

  /* "btdht/krcp.pyx":1142
 *             if not _encode_string(data, i, max, self.id, 20):
 *                 return False
 *         if self.has_implied_port:             # <<<<<<<<<<<<<<
 *             if i[0] + 15 > max:
 *                 printf("encode_secondary:%d\n", 2)
 */
  __pyx_t_1 = (__pyx_v_self->has_implied_port != 0);
  if (__pyx_t_1) {

    /* "btdht/krcp.pyx":1143
 *                 return False
 *         if self.has_implied_port:
 *             if i[0] + 15 > max:             # <<<<<<<<<<<<<<
 *                 printf("encode_secondary:%d\n", 2)
 *                 return False
 */
    __pyx_t_1 = ((((__pyx_v_i[0]) + 15) > __pyx_v_max) != 0);
    if (__pyx_t_1) {

      /* "btdht/krcp.pyx":1144
 *         if self.has_implied_port:
 *             if i[0] + 15 > max:
 *                 printf("encode_secondary:%d\n", 2)             # <<<<<<<<<<<<<<
 *                 return False
 *             strncpy(data + i[0], b"12:implied_port", 15)
 */
      (void)(printf(((char const *)"encode_secondary:%d\n"), 2));

      /* "btdht/krcp.pyx":1145
 *             if i[0] + 15 > max:
 *                 printf("encode_secondary:%d\n", 2)
 *                 return False             # <<<<<<<<<<<<<<
 *             strncpy(data + i[0], b"12:implied_port", 15)
 *             i[0]+=15
 */
      __pyx_r = 0;
      goto __pyx_L0;

      /* "btdht/krcp.pyx":1143
 *                 return False
 *         if self.has_implied_port:
 *             if i[0] + 15 > max:             # <<<<<<<<<<<<<<
 *                 printf("encode_secondary:%d\n", 2)
 *                 return False
 */
    }

    /* "btdht/krcp.pyx":1146
 *                 printf("encode_secondary:%d\n", 2)
 *                 return False
 *             strncpy(data + i[0], b"12:implied_port", 15)             # <<<<<<<<<<<<<<
 *             i[0]+=15
 *             if not _encode_int(data, i, max, self.implied_port):
 */
    (void)(strncpy((__pyx_v_data + (__pyx_v_i[0])), ((char const *)"12:implied_port"), 15));

    /* "btdht/krcp.pyx":1147
 *                 return False
 *             strncpy(data + i[0], b"12:implied_port", 15)
 *             i[0]+=15             # <<<<<<<<<<<<<<
 *             if not _encode_int(data, i, max, self.implied_port):
 *                 return False
 */
    __pyx_t_2 = 0;
    (__pyx_v_i[__pyx_t_2]) = ((__pyx_v_i[__pyx_t_2]) + 15);

    /* "btdht/krcp.pyx":1148
 *             strncpy(data + i[0], b"12:implied_port", 15)
 *             i[0]+=15
 *             if not _encode_int(data, i, max, self.implied_port):             # <<<<<<<<<<<<<<
 *                 return False
 *         if self.has_info_hash:
 */
    __pyx_t_1 = ((!(__pyx_f_5btdht_4krcp__encode_int(__pyx_v_data, __pyx_v_i, __pyx_v_max, __pyx_v_self->implied_port) != 0)) != 0);
    if (__pyx_t_1) {

      /* "btdht/krcp.pyx":1149
 *             i[0]+=15
 *             if not _encode_int(data, i, max, self.implied_port):
 *                 return False             # <<<<<<<<<<<<<<
 *         if self.has_info_hash:
 *             if i[0] + 11 > max:
 */
      __pyx_r = 0;
      goto __pyx_L0;

      /* "btdht/krcp.pyx":1148
 *             strncpy(data + i[0], b"12:implied_port", 15)
 *             i[0]+=15
 *             if not _encode_int(data, i, max, self.implied_port):             # <<<<<<<<<<<<<<
 *                 return False
 *         if self.has_info_hash:
 */
    }

    /* "btdht/krcp.pyx":1142
 *             if not _encode_string(data, i, max, self.id, 20):
 *                 return False
 *         if self.has_implied_port:             # <<<<<<<<<<<<<<
 *             if i[0] + 15 > max:
 *                 printf("encode_secondary:%d\n", 2)
 */
  }

  /* "btdht/krcp.pyx":1150
 *             if not _encode_int(data, i, max, self.implied_port):
 *                 return False
 *         if self.has_info_hash:             # <<<<<<<<<<<<<<
 *             if i[0] + 11 > max:
 *                 printf("encode_secondary:%d\n", 3)
 */
  __pyx_t_1 = (__pyx_v_self->has_info_hash != 0);
  if (__pyx_t_1) {

    /* "btdht/krcp.pyx":1151
 *                 return False
 *         if self.has_info_hash:
 *             if i[0] + 11 > max:             # <<<<<<<<<<<<<<
 *                 printf("encode_secondary:%d\n", 3)
 *                 return False
 */
    __pyx_t_1 = ((((__pyx_v_i[0]) + 11) > __pyx_v_max) != 0);
    if (__pyx_t_1) {

      /* "btdht/krcp.pyx":1152
 *         if self.has_info_hash:
 *             if i[0] + 11 > max:
 *                 printf("encode_secondary:%d\n", 3)             # <<<<<<<<<<<<<<
 *                 return False
 *             strncpy(data + i[0], b"9:info_hash", 11)
 */
      (void)(printf(((char const *)"encode_secondary:%d\n"), 3));

      /* "btdht/krcp.pyx":1153
 *             if i[0] + 11 > max:
 *                 printf("encode_secondary:%d\n", 3)
 *                 return False             # <<<<<<<<<<<<<<
 *             strncpy(data + i[0], b"9:info_hash", 11)
 *             i[0]+=11
 */
      __pyx_r = 0;
      goto __pyx_L0;

      /* "btdht/krcp.pyx":1151
 *                 return False
 *         if self.has_info_hash:
 *             if i[0] + 11 > max:             # <<<<<<<<<<<<<<
 *                 printf("encode_secondary:%d\n", 3)
 *                 return False
 */
    }

    /* "btdht/krcp.pyx":1154
 *                 printf("encode_secondary:%d\n", 3)
 *                 return False
 *             strncpy(data + i[0], b"9:info_hash", 11)             # <<<<<<<<<<<<<<
 *             i[0]+=11
 *             if not _encode_string(data, i, max, self.info_hash, 20):
 */
    (void)(strncpy((__pyx_v_data + (__pyx_v_i[0])), ((char const *)"9:info_hash"), 11));

    /* "btdht/krcp.pyx":1155
 *                 return False
 *             strncpy(data + i[0], b"9:info_hash", 11)
 *             i[0]+=11             # <<<<<<<<<<<<<<
 *             if not _encode_string(data, i, max, self.info_hash, 20):
 *                 return False
 */
    __pyx_t_2 = 0;
    (__pyx_v_i[__pyx_t_2]) = ((__pyx_v_i[__pyx_t_2]) + 11);

    /* "btdht/krcp.pyx":1156
 *             strncpy(data + i[0], b"9:info_hash", 11)
 *             i[0]+=11
 *             if not _encode_string(data, i, max, self.info_hash, 20):             # <<<<<<<<<<<<<<
 *                 return False
 *         if self.has_nodes:
 */
    __pyx_t_1 = ((!(__pyx_f_5btdht_4krcp__encode_string(__pyx_v_data, __pyx_v_i, __pyx_v_max, __pyx_v_self->info_hash, 20) != 0)) != 0);
    if (__pyx_t_1) {

      /* "btdht/krcp.pyx":1157
 *             i[0]+=11
 *             if not _encode_string(data, i, max, self.info_hash, 20):
 *                 return False             # <<<<<<<<<<<<<<
 *         if self.has_nodes:
 *             if i[0] + 7 > max:
 */
      __pyx_r = 0;
      goto __pyx_L0;

      /* "btdht/krcp.pyx":1156
 *             strncpy(data + i[0], b"9:info_hash", 11)
 *             i[0]+=11
 *             if not _encode_string(data, i, max, self.info_hash, 20):             # <<<<<<<<<<<<<<
 *                 return False
 *         if self.has_nodes:
 */
    }

    /* "btdht/krcp.pyx":1150
 *             if not _encode_int(data, i, max, self.implied_port):
 *                 return False
 *         if self.has_info_hash:             # <<<<<<<<<<<<<<
 *             if i[0] + 11 > max:
 *                 printf("encode_secondary:%d\n", 3)
 */
  }

  /* "btdht/krcp.pyx":1158
 *             if not _encode_string(data, i, max, self.info_hash, 20):
 *                 return False
 *         if self.has_nodes:             # <<<<<<<<<<<<<<
 *             if i[0] + 7 > max:
 *                 printf("encode_secondary:%d\n", 4)
 */
  __pyx_t_1 = (__pyx_v_self->has_nodes != 0);
  if (__pyx_t_1) {

    /* "btdht/krcp.pyx":1159
 *                 return False
 *         if self.has_nodes:
 *             if i[0] + 7 > max:             # <<<<<<<<<<<<<<
 *                 printf("encode_secondary:%d\n", 4)
 *                 return False
 */
    __pyx_t_1 = ((((__pyx_v_i[0]) + 7) > __pyx_v_max) != 0);
    if (__pyx_t_1) {

      /* "btdht/krcp.pyx":1160
 *         if self.has_nodes:
 *             if i[0] + 7 > max:
 *                 printf("encode_secondary:%d\n", 4)             # <<<<<<<<<<<<<<
 *                 return False
 *             strncpy(data + i[0], b"5:nodes", 7)
 */
      (void)(printf(((char const *)"encode_secondary:%d\n"), 4));

      /* "btdht/krcp.pyx":1161
 *             if i[0] + 7 > max:
 *                 printf("encode_secondary:%d\n", 4)
 *                 return False             # <<<<<<<<<<<<<<
 *             strncpy(data + i[0], b"5:nodes", 7)
 *             i[0]+=7
 */
      __pyx_r = 0;
      goto __pyx_L0;

      /* "btdht/krcp.pyx":1159
 *                 return False
 *         if self.has_nodes:
 *             if i[0] + 7 > max:             # <<<<<<<<<<<<<<
 *                 printf("encode_secondary:%d\n", 4)
 *                 return False
 */
    }

    /* "btdht/krcp.pyx":1162
 *                 printf("encode_secondary:%d\n", 4)
 *                 return False
 *             strncpy(data + i[0], b"5:nodes", 7)             # <<<<<<<<<<<<<<
 *             i[0]+=7
 *             if not _encode_string(data, i, max, self.nodes, self.nodes_len):
 */
    (void)(strncpy((__pyx_v_data + (__pyx_v_i[0])), ((char const *)"5:nodes"), 7));

    /* "btdht/krcp.pyx":1163
 *                 return False
 *             strncpy(data + i[0], b"5:nodes", 7)
 *             i[0]+=7             # <<<<<<<<<<<<<<
 *             if not _encode_string(data, i, max, self.nodes, self.nodes_len):
 *                 return False
 */
    __pyx_t_2 = 0;
    (__pyx_v_i[__pyx_t_2]) = ((__pyx_v_i[__pyx_t_2]) + 7);

    /* "btdht/krcp.pyx":1164
 *             strncpy(data + i[0], b"5:nodes", 7)
 *             i[0]+=7
 *             if not _encode_string(data, i, max, self.nodes, self.nodes_len):             # <<<<<<<<<<<<<<
 *                 return False
 *         if self.has_port:
 */
    __pyx_t_1 = ((!(__pyx_f_5btdht_4krcp__encode_string(__pyx_v_data, __pyx_v_i, __pyx_v_max, __pyx_v_self->nodes, __pyx_v_self->nodes_len) != 0)) != 0);
    if (__pyx_t_1) {

      /* "btdht/krcp.pyx":1165
 *             i[0]+=7
 *             if not _encode_string(data, i, max, self.nodes, self.nodes_len):
 *                 return False             # <<<<<<<<<<<<<<
 *         if self.has_port:
 *             if i[0] + 6 > max:
 */
      __pyx_r = 0;
      goto __pyx_L0;

      /* "btdht/krcp.pyx":1164
 *             strncpy(data + i[0], b"5:nodes", 7)
 *             i[0]+=7
 *             if not _encode_string(data, i, max, self.nodes, self.nodes_len):             # <<<<<<<<<<<<<<
 *                 return False
 *         if self.has_port:
 */
    }

    /* "btdht/krcp.pyx":1158
 *             if not _encode_string(data, i, max, self.info_hash, 20):
 *                 return False
 *         if self.has_nodes:             # <<<<<<<<<<<<<<
 *             if i[0] + 7 > max:
 *                 printf("encode_secondary:%d\n", 4)
 */
  }

  /* "btdht/krcp.pyx":1166
 *             if not _encode_string(data, i, max, self.nodes, self.nodes_len):
 *                 return False
 *         if self.has_port:             # <<<<<<<<<<<<<<
 *             if i[0] + 6 > max:
 *                 printf("encode_secondary:%d\n", 5)
 */
  __pyx_t_1 = (__pyx_v_self->has_port != 0);
  if (__pyx_t_1) {

    /* "btdht/krcp.pyx":1167
 *                 return False
 *         if self.has_port:
 *             if i[0] + 6 > max:             # <<<<<<<<<<<<<<
 *                 printf("encode_secondary:%d\n", 5)
 *                 return False
 */
    __pyx_t_1 = ((((__pyx_v_i[0]) + 6) > __pyx_v_max) != 0);
    if (__pyx_t_1) {

      /* "btdht/krcp.pyx":1168
 *         if self.has_port:
 *             if i[0] + 6 > max:
 *                 printf("encode_secondary:%d\n", 5)             # <<<<<<<<<<<<<<
 *                 return False
 *             strncpy(data + i[0], b"4:port", 6)
 */
      (void)(printf(((char const *)"encode_secondary:%d\n"), 5));

      /* "btdht/krcp.pyx":1169
 *             if i[0] + 6 > max:
 *                 printf("encode_secondary:%d\n", 5)
 *                 return False             # <<<<<<<<<<<<<<
 *             strncpy(data + i[0], b"4:port", 6)
 *             i[0]+=6
 */
      __pyx_r = 0;
      goto __pyx_L0;

      /* "btdht/krcp.pyx":1167
 *                 return False
 *         if self.has_port:
 *             if i[0] + 6 > max:             # <<<<<<<<<<<<<<
 *                 printf("encode_secondary:%d\n", 5)
 *                 return False
 */
    }

    /* "btdht/krcp.pyx":1170
 *                 printf("encode_secondary:%d\n", 5)
 *                 return False
 *             strncpy(data + i[0], b"4:port", 6)             # <<<<<<<<<<<<<<
 *             i[0]+=6
 *             if not _encode_int(data, i, max, self.port):
 */
    (void)(strncpy((__pyx_v_data + (__pyx_v_i[0])), ((char const *)"4:port"), 6));

    /* "btdht/krcp.pyx":1171
 *                 return False
 *             strncpy(data + i[0], b"4:port", 6)
 *             i[0]+=6             # <<<<<<<<<<<<<<
 *             if not _encode_int(data, i, max, self.port):
 *                 return False
 */
    __pyx_t_2 = 0;
    (__pyx_v_i[__pyx_t_2]) = ((__pyx_v_i[__pyx_t_2]) + 6);

    /* "btdht/krcp.pyx":1172
 *             strncpy(data + i[0], b"4:port", 6)
 *             i[0]+=6
 *             if not _encode_int(data, i, max, self.port):             # <<<<<<<<<<<<<<
 *                 return False
 *         if self.has_target:
 */
    __pyx_t_1 = ((!(__pyx_f_5btdht_4krcp__encode_int(__pyx_v_data, __pyx_v_i, __pyx_v_max, __pyx_v_self->port) != 0)) != 0);
    if (__pyx_t_1) {

      /* "btdht/krcp.pyx":1173
 *             i[0]+=6
 *             if not _encode_int(data, i, max, self.port):
 *                 return False             # <<<<<<<<<<<<<<
 *         if self.has_target:
 *             if i[0] + 8 > max:
 */
      __pyx_r = 0;
      goto __pyx_L0;

      /* "btdht/krcp.pyx":1172
 *             strncpy(data + i[0], b"4:port", 6)
 *             i[0]+=6
 *             if not _encode_int(data, i, max, self.port):             # <<<<<<<<<<<<<<
 *                 return False
 *         if self.has_target:
 */
    }

    /* "btdht/krcp.pyx":1166
 *             if not _encode_string(data, i, max, self.nodes, self.nodes_len):
 *                 return False
 *         if self.has_port:             # <<<<<<<<<<<<<<
 *             if i[0] + 6 > max:
 *                 printf("encode_secondary:%d\n", 5)
 */
  }

  /* "btdht/krcp.pyx":1174
 *             if not _encode_int(data, i, max, self.port):
 *                 return False
 *         if self.has_target:             # <<<<<<<<<<<<<<
 *             if i[0] + 8 > max:
 *                 printf("encode_secondary:%d\n", 6)
 */
  __pyx_t_1 = (__pyx_v_self->has_target != 0);
  if (__pyx_t_1) {

    /* "btdht/krcp.pyx":1175
 *                 return False
 *         if self.has_target:
 *             if i[0] + 8 > max:             # <<<<<<<<<<<<<<
 *                 printf("encode_secondary:%d\n", 6)
 *                 return False
 */
    __pyx_t_1 = ((((__pyx_v_i[0]) + 8) > __pyx_v_max) != 0);
    if (__pyx_t_1) {

      /* "btdht/krcp.pyx":1176
 *         if self.has_target:
 *             if i[0] + 8 > max:
 *                 printf("encode_secondary:%d\n", 6)             # <<<<<<<<<<<<<<
 *                 return False
 *             strncpy(data + i[0], b"6:target", 8)
 */
      (void)(printf(((char const *)"encode_secondary:%d\n"), 6));

      /* "btdht/krcp.pyx":1177
 *             if i[0] + 8 > max:
 *                 printf("encode_secondary:%d\n", 6)
 *                 return False             # <<<<<<<<<<<<<<
 *             strncpy(data + i[0], b"6:target", 8)
 *             i[0]+=8
 */
      __pyx_r = 0;
      goto __pyx_L0;

      /* "btdht/krcp.pyx":1175
 *                 return False
 *         if self.has_target:
 *             if i[0] + 8 > max:             # <<<<<<<<<<<<<<
 *                 printf("encode_secondary:%d\n", 6)
 *                 return False
 */
    }

    /* "btdht/krcp.pyx":1178
 *                 printf("encode_secondary:%d\n", 6)
 *                 return False
 *             strncpy(data + i[0], b"6:target", 8)             # <<<<<<<<<<<<<<
 *             i[0]+=8
 *             if not _encode_string(data, i, max, self.target, 20):
 */
    (void)(strncpy((__pyx_v_data + (__pyx_v_i[0])), ((char const *)"6:target"), 8));

    /* "btdht/krcp.pyx":1179
 *                 return False
 *             strncpy(data + i[0], b"6:target", 8)
 *             i[0]+=8             # <<<<<<<<<<<<<<
 *             if not _encode_string(data, i, max, self.target, 20):
 *                 return False
 */
    __pyx_t_2 = 0;
    (__pyx_v_i[__pyx_t_2]) = ((__pyx_v_i[__pyx_t_2]) + 8);

    /* "btdht/krcp.pyx":1180
 *             strncpy(data + i[0], b"6:target", 8)
 *             i[0]+=8
 *             if not _encode_string(data, i, max, self.target, 20):             # <<<<<<<<<<<<<<
 *                 return False
 *         if self.has_token:
 */
    __pyx_t_1 = ((!(__pyx_f_5btdht_4krcp__encode_string(__pyx_v_data, __pyx_v_i, __pyx_v_max, __pyx_v_self->target, 20) != 0)) != 0);
    if (__pyx_t_1) {

      /* "btdht/krcp.pyx":1181
 *             i[0]+=8
 *             if not _encode_string(data, i, max, self.target, 20):
 *                 return False             # <<<<<<<<<<<<<<
 *         if self.has_token:
 *             if i[0] + 7 > max:
 */
      __pyx_r = 0;
      goto __pyx_L0;

      /* "btdht/krcp.pyx":1180
 *             strncpy(data + i[0], b"6:target", 8)
 *             i[0]+=8
 *             if not _encode_string(data, i, max, self.target, 20):             # <<<<<<<<<<<<<<
 *                 return False
 *         if self.has_token:
 */
    }

    /* "btdht/krcp.pyx":1174
 *             if not _encode_int(data, i, max, self.port):
 *                 return False
 *         if self.has_target:             # <<<<<<<<<<<<<<
 *             if i[0] + 8 > max:
 *                 printf("encode_secondary:%d\n", 6)
 */
  }

  /* "btdht/krcp.pyx":1182
 *             if not _encode_string(data, i, max, self.target, 20):
 *                 return False
 *         if self.has_token:             # <<<<<<<<<<<<<<
 *             if i[0] + 7 > max:
 *                 printf("encode_secondary:%d\n", 7)
 */
  __pyx_t_1 = (__pyx_v_self->has_token != 0);
  if (__pyx_t_1) {

    /* "btdht/krcp.pyx":1183
 *                 return False
 *         if self.has_token:
 *             if i[0] + 7 > max:             # <<<<<<<<<<<<<<
 *                 printf("encode_secondary:%d\n", 7)
 *                 return False
 */
    __pyx_t_1 = ((((__pyx_v_i[0]) + 7) > __pyx_v_max) != 0);
    if (__pyx_t_1) {

      /* "btdht/krcp.pyx":1184
 *         if self.has_token:
 *             if i[0] + 7 > max:
 *                 printf("encode_secondary:%d\n", 7)             # <<<<<<<<<<<<<<
 *                 return False
 *             strncpy(data + i[0], b"5:token", 7)
 */
      (void)(printf(((char const *)"encode_secondary:%d\n"), 7));

      /* "btdht/krcp.pyx":1185
 *             if i[0] + 7 > max:
 *                 printf("encode_secondary:%d\n", 7)
 *                 return False             # <<<<<<<<<<<<<<
 *             strncpy(data + i[0], b"5:token", 7)
 *             i[0]+=7
 */
      __pyx_r = 0;
      goto __pyx_L0;

      /* "btdht/krcp.pyx":1183
 *                 return False
 *         if self.has_token:
 *             if i[0] + 7 > max:             # <<<<<<<<<<<<<<
 *                 printf("encode_secondary:%d\n", 7)
 *                 return False
 */
    }

    /* "btdht/krcp.pyx":1186
 *                 printf("encode_secondary:%d\n", 7)
 *                 return False
 *             strncpy(data + i[0], b"5:token", 7)             # <<<<<<<<<<<<<<
 *             i[0]+=7
 *             if not _encode_string(data, i, max, self.token, self.token_len):
 */
    (void)(strncpy((__pyx_v_data + (__pyx_v_i[0])), ((char const *)"5:token"), 7));

    /* "btdht/krcp.pyx":1187
 *                 return False
 *             strncpy(data + i[0], b"5:token", 7)
 *             i[0]+=7             # <<<<<<<<<<<<<<
 *             if not _encode_string(data, i, max, self.token, self.token_len):
 *                 return False
 */
    __pyx_t_2 = 0;
    (__pyx_v_i[__pyx_t_2]) = ((__pyx_v_i[__pyx_t_2]) + 7);

    /* "btdht/krcp.pyx":1188
 *             strncpy(data + i[0], b"5:token", 7)
 *             i[0]+=7
 *             if not _encode_string(data, i, max, self.token, self.token_len):             # <<<<<<<<<<<<<<
 *                 return False
 *         if self.has_values:
 */
    __pyx_t_1 = ((!(__pyx_f_5btdht_4krcp__encode_string(__pyx_v_data, __pyx_v_i, __pyx_v_max, __pyx_v_self->token, __pyx_v_self->token_len) != 0)) != 0);
    if (__pyx_t_1) {

      /* "btdht/krcp.pyx":1189
 *             i[0]+=7
 *             if not _encode_string(data, i, max, self.token, self.token_len):
 *                 return False             # <<<<<<<<<<<<<<
 *         if self.has_values:
 *             if i[0] + 8 > max:
 */
      __pyx_r = 0;
      goto __pyx_L0;

      /* "btdht/krcp.pyx":1188
 *             strncpy(data + i[0], b"5:token", 7)
 *             i[0]+=7
 *             if not _encode_string(data, i, max, self.token, self.token_len):             # <<<<<<<<<<<<<<
 *                 return False
 *         if self.has_values:
 */
    }

    /* "btdht/krcp.pyx":1182
 *             if not _encode_string(data, i, max, self.target, 20):
 *                 return False
 *         if self.has_token:             # <<<<<<<<<<<<<<
 *             if i[0] + 7 > max:
 *                 printf("encode_secondary:%d\n", 7)
 */
  }

  /* "btdht/krcp.pyx":1190
 *             if not _encode_string(data, i, max, self.token, self.token_len):
 *                 return False
 *         if self.has_values:             # <<<<<<<<<<<<<<
 *             if i[0] + 8 > max:
 *                 printf("encode_secondary:%d\n", 8)
 */
  __pyx_t_1 = (__pyx_v_self->has_values != 0);
  if (__pyx_t_1) {

    /* "btdht/krcp.pyx":1191
 *                 return False
 *         if self.has_values:
 *             if i[0] + 8 > max:             # <<<<<<<<<<<<<<
 *                 printf("encode_secondary:%d\n", 8)
 *                 return False
 */
    __pyx_t_1 = ((((__pyx_v_i[0]) + 8) > __pyx_v_max) != 0);
    if (__pyx_t_1) {

      /* "btdht/krcp.pyx":1192
 *         if self.has_values:
 *             if i[0] + 8 > max:
 *                 printf("encode_secondary:%d\n", 8)             # <<<<<<<<<<<<<<
 *                 return False
 *             strncpy(data + i[0], b"6:values", 8)
 */
      (void)(printf(((char const *)"encode_secondary:%d\n"), 8));

      /* "btdht/krcp.pyx":1193
 *             if i[0] + 8 > max:
 *                 printf("encode_secondary:%d\n", 8)
 *                 return False             # <<<<<<<<<<<<<<
 *             strncpy(data + i[0], b"6:values", 8)
 *             i[0]+=8
 */
      __pyx_r = 0;
      goto __pyx_L0;

      /* "btdht/krcp.pyx":1191
 *                 return False
 *         if self.has_values:
 *             if i[0] + 8 > max:             # <<<<<<<<<<<<<<
 *                 printf("encode_secondary:%d\n", 8)
 *                 return False
 */
    }

    /* "btdht/krcp.pyx":1194
 *                 printf("encode_secondary:%d\n", 8)
 *                 return False
 *             strncpy(data + i[0], b"6:values", 8)             # <<<<<<<<<<<<<<
 *             i[0]+=8
 *             if not self._encode_values(data, i, max):
 */
    (void)(strncpy((__pyx_v_data + (__pyx_v_i[0])), ((char const *)"6:values"), 8));

    /* "btdht/krcp.pyx":1195
 *                 return False
 *             strncpy(data + i[0], b"6:values", 8)
 *             i[0]+=8             # <<<<<<<<<<<<<<
 *             if not self._encode_values(data, i, max):
 *                 return False
 */
    __pyx_t_2 = 0;
    (__pyx_v_i[__pyx_t_2]) = ((__pyx_v_i[__pyx_t_2]) + 8);

    /* "btdht/krcp.pyx":1196
 *             strncpy(data + i[0], b"6:values", 8)
 *             i[0]+=8
 *             if not self._encode_values(data, i, max):             # <<<<<<<<<<<<<<
 *                 return False
 *         if i[0] + 1 > max:
 */
    __pyx_t_1 = ((!(((struct __pyx_vtabstruct_5btdht_4krcp_BMessage *)__pyx_v_self->__pyx_vtab)->_encode_values(__pyx_v_self, __pyx_v_data, __pyx_v_i, __pyx_v_max) != 0)) != 0);
    if (__pyx_t_1) {

      /* "btdht/krcp.pyx":1197
 *             i[0]+=8
 *             if not self._encode_values(data, i, max):
 *                 return False             # <<<<<<<<<<<<<<
 *         if i[0] + 1 > max:
 *             printf("encode_secondary:%d\n", 9)
 */
      __pyx_r = 0;
      goto __pyx_L0;

      /* "btdht/krcp.pyx":1196
 *             strncpy(data + i[0], b"6:values", 8)
 *             i[0]+=8
 *             if not self._encode_values(data, i, max):             # <<<<<<<<<<<<<<
 *                 return False
 *         if i[0] + 1 > max:
 */
    }

    /* "btdht/krcp.pyx":1190
 *             if not _encode_string(data, i, max, self.token, self.token_len):
 *                 return False
 *         if self.has_values:             # <<<<<<<<<<<<<<
 *             if i[0] + 8 > max:
 *                 printf("encode_secondary:%d\n", 8)
 */
  }

  /* "btdht/krcp.pyx":1198
 *             if not self._encode_values(data, i, max):
 *                 return False
 *         if i[0] + 1 > max:             # <<<<<<<<<<<<<<
 *             printf("encode_secondary:%d\n", 9)
 *             return False
 */
  __pyx_t_1 = ((((__pyx_v_i[0]) + 1) > __pyx_v_max) != 0);
  if (__pyx_t_1) {

    /* "btdht/krcp.pyx":1199
 *                 return False
 *         if i[0] + 1 > max:
 *             printf("encode_secondary:%d\n", 9)             # <<<<<<<<<<<<<<
 *             return False
 *         data[i[0]] = b'e'
 */
    (void)(printf(((char const *)"encode_secondary:%d\n"), 9));

    /* "btdht/krcp.pyx":1200
 *         if i[0] + 1 > max:
 *             printf("encode_secondary:%d\n", 9)
 *             return False             # <<<<<<<<<<<<<<
 *         data[i[0]] = b'e'
 *         i[0]+=1
 */
    __pyx_r = 0;
    goto __pyx_L0;

    /* "btdht/krcp.pyx":1198
 *             if not self._encode_values(data, i, max):
 *                 return False
 *         if i[0] + 1 > max:             # <<<<<<<<<<<<<<
 *             printf("encode_secondary:%d\n", 9)
 *             return False
 */
  }

  /* "btdht/krcp.pyx":1201
 *             printf("encode_secondary:%d\n", 9)
 *             return False
 *         data[i[0]] = b'e'             # <<<<<<<<<<<<<<
 *         i[0]+=1
 *         return True
 */
  (__pyx_v_data[(__pyx_v_i[0])]) = 'e';

  /* "btdht/krcp.pyx":1202
 *             return False
 *         data[i[0]] = b'e'
 *         i[0]+=1             # <<<<<<<<<<<<<<
 *         return True
 * 
 */
  __pyx_t_2 = 0;
  (__pyx_v_i[__pyx_t_2]) = ((__pyx_v_i[__pyx_t_2]) + 1);

  /* "btdht/krcp.pyx":1203
 *         data[i[0]] = b'e'
 *         i[0]+=1
 *         return True             # <<<<<<<<<<<<<<
 * 
 *     cdef int _encode_error(self, char* data, int* i, int max) nogil:
 */
  __pyx_r = 1;
  goto __pyx_L0;

  /* "btdht/krcp.pyx":1096
 *         return True
 * 
 *     cdef int _encode_secondary_dict(self, char* data, int* i, int max) nogil:             # <<<<<<<<<<<<<<
 *         """
 *             Bencode the secondary dictionnary of the message and write it to ``data``
 */

  /* function exit code */
  __pyx_L0:;
  return __pyx_r;
}

/* "btdht/krcp.pyx":1205
 *         return True
 * 
 *     cdef int _encode_error(self, char* data, int* i, int max) nogil:             # <<<<<<<<<<<<<<
 *         """
 *             Bencode the error list of an error message
 */

static int __pyx_f_5btdht_4krcp_8BMessage__encode_error(struct __pyx_obj_5btdht_4krcp_BMessage *__pyx_v_self, char *__pyx_v_data, int *__pyx_v_i, int __pyx_v_max) {
  int __pyx_r;
  int __pyx_t_1;
  long __pyx_t_2;

  /* "btdht/krcp.pyx":1233
 *                     together, although no mecanism is preventing you to do it.
 *         """
 *         if i[0] + 2 > max:             # <<<<<<<<<<<<<<
 *             printf("encode_error: %d", 0)
 *             return False
 */
  __pyx_t_1 = ((((__pyx_v_i[0]) + 2) > __pyx_v_max) != 0);
  if (__pyx_t_1) {

    /* "btdht/krcp.pyx":1234
 *         """
 *         if i[0] + 2 > max:
 *             printf("encode_error: %d", 0)             # <<<<<<<<<<<<<<
 *             return False
 *         data[i[0]] = b'l'
 */
    (void)(printf(((char const *)"encode_error: %d"), 0));

    /* "btdht/krcp.pyx":1235
 *         if i[0] + 2 > max:
 *             printf("encode_error: %d", 0)
 *             return False             # <<<<<<<<<<<<<<
 *         data[i[0]] = b'l'
 *         i[0]+=1
 */
    __pyx_r = 0;
    goto __pyx_L0;

    /* "btdht/krcp.pyx":1233
 *                     together, although no mecanism is preventing you to do it.
 *         """
 *         if i[0] + 2 > max:             # <<<<<<<<<<<<<<
 *             printf("encode_error: %d", 0)
 *             return False
 */
  }

  /* "btdht/krcp.pyx":1236
 *             printf("encode_error: %d", 0)
 *             return False
 *         data[i[0]] = b'l'             # <<<<<<<<<<<<<<
 *         i[0]+=1
 *         if not _encode_int(data, i, max, self._errno):
 */
  (__pyx_v_data[(__pyx_v_i[0])]) = 'l';

  /* "btdht/krcp.pyx":1237
 *             return False
 *         data[i[0]] = b'l'
 *         i[0]+=1             # <<<<<<<<<<<<<<
 *         if not _encode_int(data, i, max, self._errno):
 *             return False
 */
  __pyx_t_2 = 0;
  (__pyx_v_i[__pyx_t_2]) = ((__pyx_v_i[__pyx_t_2]) + 1);

  /* "btdht/krcp.pyx":1238
 *         data[i[0]] = b'l'
 *         i[0]+=1
 *         if not _encode_int(data, i, max, self._errno):             # <<<<<<<<<<<<<<
 *             return False
 *         if not _encode_string(data, i, max, self._errmsg, self.errmsg_len):
 */
  __pyx_t_1 = ((!(__pyx_f_5btdht_4krcp__encode_int(__pyx_v_data, __pyx_v_i, __pyx_v_max, __pyx_v_self->_errno) != 0)) != 0);
  if (__pyx_t_1) {

    /* "btdht/krcp.pyx":1239
 *         i[0]+=1
 *         if not _encode_int(data, i, max, self._errno):
 *             return False             # <<<<<<<<<<<<<<
 *         if not _encode_string(data, i, max, self._errmsg, self.errmsg_len):
 *             return False
 */
    __pyx_r = 0;
    goto __pyx_L0;

    /* "btdht/krcp.pyx":1238
 *         data[i[0]] = b'l'
 *         i[0]+=1
 *         if not _encode_int(data, i, max, self._errno):             # <<<<<<<<<<<<<<
 *             return False
 *         if not _encode_string(data, i, max, self._errmsg, self.errmsg_len):
 */
  }

  /* "btdht/krcp.pyx":1240
 *         if not _encode_int(data, i, max, self._errno):
 *             return False
 *         if not _encode_string(data, i, max, self._errmsg, self.errmsg_len):             # <<<<<<<<<<<<<<
 *             return False
 *         if i[0] >= max:
 */
  __pyx_t_1 = ((!(__pyx_f_5btdht_4krcp__encode_string(__pyx_v_data, __pyx_v_i, __pyx_v_max, __pyx_v_self->_errmsg, __pyx_v_self->errmsg_len) != 0)) != 0);
  if (__pyx_t_1) {

    /* "btdht/krcp.pyx":1241
 *             return False
 *         if not _encode_string(data, i, max, self._errmsg, self.errmsg_len):
 *             return False             # <<<<<<<<<<<<<<
 *         if i[0] >= max:
 *             printf("encode_error: %d", 1)
 */
    __pyx_r = 0;
    goto __pyx_L0;

    /* "btdht/krcp.pyx":1240
 *         if not _encode_int(data, i, max, self._errno):
 *             return False
 *         if not _encode_string(data, i, max, self._errmsg, self.errmsg_len):             # <<<<<<<<<<<<<<
 *             return False
 *         if i[0] >= max:
 */
  }

  /* "btdht/krcp.pyx":1242
 *         if not _encode_string(data, i, max, self._errmsg, self.errmsg_len):
 *             return False
 *         if i[0] >= max:             # <<<<<<<<<<<<<<
 *             printf("encode_error: %d", 1)
 *             return False
 */
  __pyx_t_1 = (((__pyx_v_i[0]) >= __pyx_v_max) != 0);
  if (__pyx_t_1) {

    /* "btdht/krcp.pyx":1243
 *             return False
 *         if i[0] >= max:
 *             printf("encode_error: %d", 1)             # <<<<<<<<<<<<<<
 *             return False
 *         data[i[0]] = b'e'
 */
    (void)(printf(((char const *)"encode_error: %d"), 1));

    /* "btdht/krcp.pyx":1244
 *         if i[0] >= max:
 *             printf("encode_error: %d", 1)
 *             return False             # <<<<<<<<<<<<<<
 *         data[i[0]] = b'e'
 *         i[0]+=1
 */
    __pyx_r = 0;
    goto __pyx_L0;

    /* "btdht/krcp.pyx":1242
 *         if not _encode_string(data, i, max, self._errmsg, self.errmsg_len):
 *             return False
 *         if i[0] >= max:             # <<<<<<<<<<<<<<
 *             printf("encode_error: %d", 1)
 *             return False
 */
  }

  /* "btdht/krcp.pyx":1245
 *             printf("encode_error: %d", 1)
 *             return False
 *         data[i[0]] = b'e'             # <<<<<<<<<<<<<<
 *         i[0]+=1
 *         return True
 */
  (__pyx_v_data[(__pyx_v_i[0])]) = 'e';

  /* "btdht/krcp.pyx":1246
 *             return False
 *         data[i[0]] = b'e'
 *         i[0]+=1             # <<<<<<<<<<<<<<
 *         return True
 * 
 */
  __pyx_t_2 = 0;
  (__pyx_v_i[__pyx_t_2]) = ((__pyx_v_i[__pyx_t_2]) + 1);

  /* "btdht/krcp.pyx":1247
 *         data[i[0]] = b'e'
 *         i[0]+=1
 *         return True             # <<<<<<<<<<<<<<
 * 
 *     cdef int _encode_main_dict(self, char* data, int* i, int max) nogil:
 */
  __pyx_r = 1;
  goto __pyx_L0;

  /* "btdht/krcp.pyx":1205
 *         return True
 * 
 *     cdef int _encode_error(self, char* data, int* i, int max) nogil:             # <<<<<<<<<<<<<<
 *         """
 *             Bencode the error list of an error message
 */

  /* function exit code */
  __pyx_L0:;
  return __pyx_r;
}

/* "btdht/krcp.pyx":1249
 *         return True
 * 
 *     cdef int _encode_main_dict(self, char* data, int* i, int max) nogil:             # <<<<<<<<<<<<<<
 *         """
 *             Bencode the message primary dictionnary
 */

static int __pyx_f_5btdht_4krcp_8BMessage__encode_main_dict(struct __pyx_obj_5btdht_4krcp_BMessage *__pyx_v_self, char *__pyx_v_data, int *__pyx_v_i, int __pyx_v_max) {
  int __pyx_r;
  int __pyx_t_1;
  long __pyx_t_2;

  /* "btdht/krcp.pyx":1262
 *                 This method can be called without the python GIL
 *         """
 *         if i[0] + 1 > max:             # <<<<<<<<<<<<<<
 *             printf("encode_main: %d\n", 0)
 *             return False
 */
  __pyx_t_1 = ((((__pyx_v_i[0]) + 1) > __pyx_v_max) != 0);
  if (__pyx_t_1) {

    /* "btdht/krcp.pyx":1263
 *         """
 *         if i[0] + 1 > max:
 *             printf("encode_main: %d\n", 0)             # <<<<<<<<<<<<<<
 *             return False
 *         data[i[0]] = b'd'
 */
    (void)(printf(((char const *)"encode_main: %d\n"), 0));

    /* "btdht/krcp.pyx":1264
 *         if i[0] + 1 > max:
 *             printf("encode_main: %d\n", 0)
 *             return False             # <<<<<<<<<<<<<<
 *         data[i[0]] = b'd'
 *         i[0]+=1
 */
    __pyx_r = 0;
    goto __pyx_L0;

    /* "btdht/krcp.pyx":1262
 *                 This method can be called without the python GIL
 *         """
 *         if i[0] + 1 > max:             # <<<<<<<<<<<<<<
 *             printf("encode_main: %d\n", 0)
 *             return False
 */
  }

  /* "btdht/krcp.pyx":1265
 *             printf("encode_main: %d\n", 0)
 *             return False
 *         data[i[0]] = b'd'             # <<<<<<<<<<<<<<
 *         i[0]+=1
 *         if self.a:
 */
  (__pyx_v_data[(__pyx_v_i[0])]) = 'd';

  /* "btdht/krcp.pyx":1266
 *             return False
 *         data[i[0]] = b'd'
 *         i[0]+=1             # <<<<<<<<<<<<<<
 *         if self.a:
 *             if i[0] + 3 > max:
 */
  __pyx_t_2 = 0;
  (__pyx_v_i[__pyx_t_2]) = ((__pyx_v_i[__pyx_t_2]) + 1);

  /* "btdht/krcp.pyx":1267
 *         data[i[0]] = b'd'
 *         i[0]+=1
 *         if self.a:             # <<<<<<<<<<<<<<
 *             if i[0] + 3 > max:
 *                 printf("encode_main: %d\n", 1)
 */
  __pyx_t_1 = (__pyx_v_self->a != 0);
  if (__pyx_t_1) {

    /* "btdht/krcp.pyx":1268
 *         i[0]+=1
 *         if self.a:
 *             if i[0] + 3 > max:             # <<<<<<<<<<<<<<
 *                 printf("encode_main: %d\n", 1)
 *                 return False
 */
    __pyx_t_1 = ((((__pyx_v_i[0]) + 3) > __pyx_v_max) != 0);
    if (__pyx_t_1) {

      /* "btdht/krcp.pyx":1269
 *         if self.a:
 *             if i[0] + 3 > max:
 *                 printf("encode_main: %d\n", 1)             # <<<<<<<<<<<<<<
 *                 return False
 *             strncpy(data + i[0], b"1:a", 3)
 */
      (void)(printf(((char const *)"encode_main: %d\n"), 1));

      /* "btdht/krcp.pyx":1270
 *             if i[0] + 3 > max:
 *                 printf("encode_main: %d\n", 1)
 *                 return False             # <<<<<<<<<<<<<<
 *             strncpy(data + i[0], b"1:a", 3)
 *             i[0]+=3
 */
      __pyx_r = 0;
      goto __pyx_L0;

      /* "btdht/krcp.pyx":1268
 *         i[0]+=1
 *         if self.a:
 *             if i[0] + 3 > max:             # <<<<<<<<<<<<<<
 *                 printf("encode_main: %d\n", 1)
 *                 return False
 */
    }

    /* "btdht/krcp.pyx":1271
 *                 printf("encode_main: %d\n", 1)
 *                 return False
 *             strncpy(data + i[0], b"1:a", 3)             # <<<<<<<<<<<<<<
 *             i[0]+=3
 *             if not self._encode_secondary_dict(data, i, max):
 */
    (void)(strncpy((__pyx_v_data + (__pyx_v_i[0])), ((char const *)"1:a"), 3));

    /* "btdht/krcp.pyx":1272
 *                 return False
 *             strncpy(data + i[0], b"1:a", 3)
 *             i[0]+=3             # <<<<<<<<<<<<<<
 *             if not self._encode_secondary_dict(data, i, max):
 *                 return False
 */
    __pyx_t_2 = 0;
    (__pyx_v_i[__pyx_t_2]) = ((__pyx_v_i[__pyx_t_2]) + 3);

    /* "btdht/krcp.pyx":1273
 *             strncpy(data + i[0], b"1:a", 3)
 *             i[0]+=3
 *             if not self._encode_secondary_dict(data, i, max):             # <<<<<<<<<<<<<<
 *                 return False
 *         if self.e:
 */
    __pyx_t_1 = ((!(((struct __pyx_vtabstruct_5btdht_4krcp_BMessage *)__pyx_v_self->__pyx_vtab)->_encode_secondary_dict(__pyx_v_self, __pyx_v_data, __pyx_v_i, __pyx_v_max) != 0)) != 0);
    if (__pyx_t_1) {

      /* "btdht/krcp.pyx":1274
 *             i[0]+=3
 *             if not self._encode_secondary_dict(data, i, max):
 *                 return False             # <<<<<<<<<<<<<<
 *         if self.e:
 *             if i[0] + 3 > max:
 */
      __pyx_r = 0;
      goto __pyx_L0;

      /* "btdht/krcp.pyx":1273
 *             strncpy(data + i[0], b"1:a", 3)
 *             i[0]+=3
 *             if not self._encode_secondary_dict(data, i, max):             # <<<<<<<<<<<<<<
 *                 return False
 *         if self.e:
 */
    }

    /* "btdht/krcp.pyx":1267
 *         data[i[0]] = b'd'
 *         i[0]+=1
 *         if self.a:             # <<<<<<<<<<<<<<
 *             if i[0] + 3 > max:
 *                 printf("encode_main: %d\n", 1)
 */
  }

  /* "btdht/krcp.pyx":1275
 *             if not self._encode_secondary_dict(data, i, max):
 *                 return False
 *         if self.e:             # <<<<<<<<<<<<<<
 *             if i[0] + 3 > max:
 *                 printf("encode_main: %d\n", 8)
 */
  __pyx_t_1 = (__pyx_v_self->e != 0);
  if (__pyx_t_1) {

    /* "btdht/krcp.pyx":1276
 *                 return False
 *         if self.e:
 *             if i[0] + 3 > max:             # <<<<<<<<<<<<<<
 *                 printf("encode_main: %d\n", 8)
 *                 return False
 */
    __pyx_t_1 = ((((__pyx_v_i[0]) + 3) > __pyx_v_max) != 0);
    if (__pyx_t_1) {

      /* "btdht/krcp.pyx":1277
 *         if self.e:
 *             if i[0] + 3 > max:
 *                 printf("encode_main: %d\n", 8)             # <<<<<<<<<<<<<<
 *                 return False
 *             strncpy(data + i[0], b"1:e", 3)
 */
      (void)(printf(((char const *)"encode_main: %d\n"), 8));

      /* "btdht/krcp.pyx":1278
 *             if i[0] + 3 > max:
 *                 printf("encode_main: %d\n", 8)
 *                 return False             # <<<<<<<<<<<<<<
 *             strncpy(data + i[0], b"1:e", 3)
 *             i[0]+=3
 */
      __pyx_r = 0;
      goto __pyx_L0;

      /* "btdht/krcp.pyx":1276
 *                 return False
 *         if self.e:
 *             if i[0] + 3 > max:             # <<<<<<<<<<<<<<
 *                 printf("encode_main: %d\n", 8)
 *                 return False
 */
    }

    /* "btdht/krcp.pyx":1279
 *                 printf("encode_main: %d\n", 8)
 *                 return False
 *             strncpy(data + i[0], b"1:e", 3)             # <<<<<<<<<<<<<<
 *             i[0]+=3
 *             if not self._encode_error(data, i, max):
 */
    (void)(strncpy((__pyx_v_data + (__pyx_v_i[0])), ((char const *)"1:e"), 3));

    /* "btdht/krcp.pyx":1280
 *                 return False
 *             strncpy(data + i[0], b"1:e", 3)
 *             i[0]+=3             # <<<<<<<<<<<<<<
 *             if not self._encode_error(data, i, max):
 *                 return False
 */
    __pyx_t_2 = 0;
    (__pyx_v_i[__pyx_t_2]) = ((__pyx_v_i[__pyx_t_2]) + 3);

    /* "btdht/krcp.pyx":1281
 *             strncpy(data + i[0], b"1:e", 3)
 *             i[0]+=3
 *             if not self._encode_error(data, i, max):             # <<<<<<<<<<<<<<
 *                 return False
 *         if self.has_q:
 */
    __pyx_t_1 = ((!(((struct __pyx_vtabstruct_5btdht_4krcp_BMessage *)__pyx_v_self->__pyx_vtab)->_encode_error(__pyx_v_self, __pyx_v_data, __pyx_v_i, __pyx_v_max) != 0)) != 0);
    if (__pyx_t_1) {

      /* "btdht/krcp.pyx":1282
 *             i[0]+=3
 *             if not self._encode_error(data, i, max):
 *                 return False             # <<<<<<<<<<<<<<
 *         if self.has_q:
 *             if i[0] + 3 > max:
 */
      __pyx_r = 0;
      goto __pyx_L0;

      /* "btdht/krcp.pyx":1281
 *             strncpy(data + i[0], b"1:e", 3)
 *             i[0]+=3
 *             if not self._encode_error(data, i, max):             # <<<<<<<<<<<<<<
 *                 return False
 *         if self.has_q:
 */
    }

    /* "btdht/krcp.pyx":1275
 *             if not self._encode_secondary_dict(data, i, max):
 *                 return False
 *         if self.e:             # <<<<<<<<<<<<<<
 *             if i[0] + 3 > max:
 *                 printf("encode_main: %d\n", 8)
 */
  }

  /* "btdht/krcp.pyx":1283
 *             if not self._encode_error(data, i, max):
 *                 return False
 *         if self.has_q:             # <<<<<<<<<<<<<<
 *             if i[0] + 3 > max:
 *                 printf("encode_main: %d\n", 2)
 */
  __pyx_t_1 = (__pyx_v_self->has_q != 0);
  if (__pyx_t_1) {

    /* "btdht/krcp.pyx":1284
 *                 return False
 *         if self.has_q:
 *             if i[0] + 3 > max:             # <<<<<<<<<<<<<<
 *                 printf("encode_main: %d\n", 2)
 *                 return False
 */
    __pyx_t_1 = ((((__pyx_v_i[0]) + 3) > __pyx_v_max) != 0);
    if (__pyx_t_1) {

      /* "btdht/krcp.pyx":1285
 *         if self.has_q:
 *             if i[0] + 3 > max:
 *                 printf("encode_main: %d\n", 2)             # <<<<<<<<<<<<<<
 *                 return False
 *             strncpy(data + i[0], b"1:q", 3)
 */
      (void)(printf(((char const *)"encode_main: %d\n"), 2));

      /* "btdht/krcp.pyx":1286
 *             if i[0] + 3 > max:
 *                 printf("encode_main: %d\n", 2)
 *                 return False             # <<<<<<<<<<<<<<
 *             strncpy(data + i[0], b"1:q", 3)
 *             i[0]+=3
 */
      __pyx_r = 0;
      goto __pyx_L0;

      /* "btdht/krcp.pyx":1284
 *                 return False
 *         if self.has_q:
 *             if i[0] + 3 > max:             # <<<<<<<<<<<<<<
 *                 printf("encode_main: %d\n", 2)
 *                 return False
 */
    }

    /* "btdht/krcp.pyx":1287
 *                 printf("encode_main: %d\n", 2)
 *                 return False
 *             strncpy(data + i[0], b"1:q", 3)             # <<<<<<<<<<<<<<
 *             i[0]+=3
 *             if not _encode_string(data, i, max, self._q, self.q_len):
 */
    (void)(strncpy((__pyx_v_data + (__pyx_v_i[0])), ((char const *)"1:q"), 3));

    /* "btdht/krcp.pyx":1288
 *                 return False
 *             strncpy(data + i[0], b"1:q", 3)
 *             i[0]+=3             # <<<<<<<<<<<<<<
 *             if not _encode_string(data, i, max, self._q, self.q_len):
 *                 return False
 */
    __pyx_t_2 = 0;
    (__pyx_v_i[__pyx_t_2]) = ((__pyx_v_i[__pyx_t_2]) + 3);

    /* "btdht/krcp.pyx":1289
 *             strncpy(data + i[0], b"1:q", 3)
 *             i[0]+=3
 *             if not _encode_string(data, i, max, self._q, self.q_len):             # <<<<<<<<<<<<<<
 *                 return False
 *         if self.r:
 */
    __pyx_t_1 = ((!(__pyx_f_5btdht_4krcp__encode_string(__pyx_v_data, __pyx_v_i, __pyx_v_max, __pyx_v_self->_q, __pyx_v_self->q_len) != 0)) != 0);
    if (__pyx_t_1) {

      /* "btdht/krcp.pyx":1290
 *             i[0]+=3
 *             if not _encode_string(data, i, max, self._q, self.q_len):
 *                 return False             # <<<<<<<<<<<<<<
 *         if self.r:
 *             if i[0] + 3 > max:
 */
      __pyx_r = 0;
      goto __pyx_L0;

      /* "btdht/krcp.pyx":1289
 *             strncpy(data + i[0], b"1:q", 3)
 *             i[0]+=3
 *             if not _encode_string(data, i, max, self._q, self.q_len):             # <<<<<<<<<<<<<<
 *                 return False
 *         if self.r:
 */
    }

    /* "btdht/krcp.pyx":1283
 *             if not self._encode_error(data, i, max):
 *                 return False
 *         if self.has_q:             # <<<<<<<<<<<<<<
 *             if i[0] + 3 > max:
 *                 printf("encode_main: %d\n", 2)
 */
  }

  /* "btdht/krcp.pyx":1291
 *             if not _encode_string(data, i, max, self._q, self.q_len):
 *                 return False
 *         if self.r:             # <<<<<<<<<<<<<<
 *             if i[0] + 3 > max:
 *                 printf("encode_main: %d\n", 3)
 */
  __pyx_t_1 = (__pyx_v_self->r != 0);
  if (__pyx_t_1) {

    /* "btdht/krcp.pyx":1292
 *                 return False
 *         if self.r:
 *             if i[0] + 3 > max:             # <<<<<<<<<<<<<<
 *                 printf("encode_main: %d\n", 3)
 *                 return False
 */
    __pyx_t_1 = ((((__pyx_v_i[0]) + 3) > __pyx_v_max) != 0);
    if (__pyx_t_1) {

      /* "btdht/krcp.pyx":1293
 *         if self.r:
 *             if i[0] + 3 > max:
 *                 printf("encode_main: %d\n", 3)             # <<<<<<<<<<<<<<
 *                 return False
 *             strncpy(data + i[0], b"1:r", 3)
 */
      (void)(printf(((char const *)"encode_main: %d\n"), 3));

      /* "btdht/krcp.pyx":1294
 *             if i[0] + 3 > max:
 *                 printf("encode_main: %d\n", 3)
 *                 return False             # <<<<<<<<<<<<<<
 *             strncpy(data + i[0], b"1:r", 3)
 *             i[0]+=3
 */
      __pyx_r = 0;
      goto __pyx_L0;

      /* "btdht/krcp.pyx":1292
 *                 return False
 *         if self.r:
 *             if i[0] + 3 > max:             # <<<<<<<<<<<<<<
 *                 printf("encode_main: %d\n", 3)
 *                 return False
 */
    }

    /* "btdht/krcp.pyx":1295
 *                 printf("encode_main: %d\n", 3)
 *                 return False
 *             strncpy(data + i[0], b"1:r", 3)             # <<<<<<<<<<<<<<
 *             i[0]+=3
 *             if not self._encode_secondary_dict(data, i, max):
 */
    (void)(strncpy((__pyx_v_data + (__pyx_v_i[0])), ((char const *)"1:r"), 3));

    /* "btdht/krcp.pyx":1296
 *                 return False
 *             strncpy(data + i[0], b"1:r", 3)
 *             i[0]+=3             # <<<<<<<<<<<<<<
 *             if not self._encode_secondary_dict(data, i, max):
 *                 return False
 */
    __pyx_t_2 = 0;
    (__pyx_v_i[__pyx_t_2]) = ((__pyx_v_i[__pyx_t_2]) + 3);

    /* "btdht/krcp.pyx":1297
 *             strncpy(data + i[0], b"1:r", 3)
 *             i[0]+=3
 *             if not self._encode_secondary_dict(data, i, max):             # <<<<<<<<<<<<<<
 *                 return False
 *         if self.has_t:
 */
    __pyx_t_1 = ((!(((struct __pyx_vtabstruct_5btdht_4krcp_BMessage *)__pyx_v_self->__pyx_vtab)->_encode_secondary_dict(__pyx_v_self, __pyx_v_data, __pyx_v_i, __pyx_v_max) != 0)) != 0);
    if (__pyx_t_1) {

      /* "btdht/krcp.pyx":1298
 *             i[0]+=3
 *             if not self._encode_secondary_dict(data, i, max):
 *                 return False             # <<<<<<<<<<<<<<
 *         if self.has_t:
 *             if i[0] + 3 > max:
 */
      __pyx_r = 0;
      goto __pyx_L0;

      /* "btdht/krcp.pyx":1297
 *             strncpy(data + i[0], b"1:r", 3)
 *             i[0]+=3
 *             if not self._encode_secondary_dict(data, i, max):             # <<<<<<<<<<<<<<
 *                 return False
 *         if self.has_t:
 */
    }

    /* "btdht/krcp.pyx":1291
 *             if not _encode_string(data, i, max, self._q, self.q_len):
 *                 return False
 *         if self.r:             # <<<<<<<<<<<<<<
 *             if i[0] + 3 > max:
 *                 printf("encode_main: %d\n", 3)
 */
  }

  /* "btdht/krcp.pyx":1299
 *             if not self._encode_secondary_dict(data, i, max):
 *                 return False
 *         if self.has_t:             # <<<<<<<<<<<<<<
 *             if i[0] + 3 > max:
 *                 printf("encode_main: %d\n", 4)
 */
  __pyx_t_1 = (__pyx_v_self->has_t != 0);
  if (__pyx_t_1) {

    /* "btdht/krcp.pyx":1300
 *                 return False
 *         if self.has_t:
 *             if i[0] + 3 > max:             # <<<<<<<<<<<<<<
 *                 printf("encode_main: %d\n", 4)
 *                 return False
 */
    __pyx_t_1 = ((((__pyx_v_i[0]) + 3) > __pyx_v_max) != 0);
    if (__pyx_t_1) {

      /* "btdht/krcp.pyx":1301
 *         if self.has_t:
 *             if i[0] + 3 > max:
 *                 printf("encode_main: %d\n", 4)             # <<<<<<<<<<<<<<
 *                 return False
 *             strncpy(data + i[0], b"1:t", 3)
 */
      (void)(printf(((char const *)"encode_main: %d\n"), 4));

      /* "btdht/krcp.pyx":1302
 *             if i[0] + 3 > max:
 *                 printf("encode_main: %d\n", 4)
 *                 return False             # <<<<<<<<<<<<<<
 *             strncpy(data + i[0], b"1:t", 3)
 *             i[0]+=3
 */
      __pyx_r = 0;
      goto __pyx_L0;

      /* "btdht/krcp.pyx":1300
 *                 return False
 *         if self.has_t:
 *             if i[0] + 3 > max:             # <<<<<<<<<<<<<<
 *                 printf("encode_main: %d\n", 4)
 *                 return False
 */
    }

    /* "btdht/krcp.pyx":1303
 *                 printf("encode_main: %d\n", 4)
 *                 return False
 *             strncpy(data + i[0], b"1:t", 3)             # <<<<<<<<<<<<<<
 *             i[0]+=3
 *             if not _encode_string(data, i, max, self._t, self.t_len):
 */
    (void)(strncpy((__pyx_v_data + (__pyx_v_i[0])), ((char const *)"1:t"), 3));

    /* "btdht/krcp.pyx":1304
 *                 return False
 *             strncpy(data + i[0], b"1:t", 3)
 *             i[0]+=3             # <<<<<<<<<<<<<<
 *             if not _encode_string(data, i, max, self._t, self.t_len):
 *                 return False
 */
    __pyx_t_2 = 0;
    (__pyx_v_i[__pyx_t_2]) = ((__pyx_v_i[__pyx_t_2]) + 3);

    /* "btdht/krcp.pyx":1305
 *             strncpy(data + i[0], b"1:t", 3)
 *             i[0]+=3
 *             if not _encode_string(data, i, max, self._t, self.t_len):             # <<<<<<<<<<<<<<
 *                 return False
 *         if self.has_v:
 */
    __pyx_t_1 = ((!(__pyx_f_5btdht_4krcp__encode_string(__pyx_v_data, __pyx_v_i, __pyx_v_max, __pyx_v_self->_t, __pyx_v_self->t_len) != 0)) != 0);
    if (__pyx_t_1) {

      /* "btdht/krcp.pyx":1306
 *             i[0]+=3
 *             if not _encode_string(data, i, max, self._t, self.t_len):
 *                 return False             # <<<<<<<<<<<<<<
 *         if self.has_v:
 *             if i[0] + 3 > max:
 */
      __pyx_r = 0;
      goto __pyx_L0;

      /* "btdht/krcp.pyx":1305
 *             strncpy(data + i[0], b"1:t", 3)
 *             i[0]+=3
 *             if not _encode_string(data, i, max, self._t, self.t_len):             # <<<<<<<<<<<<<<
 *                 return False
 *         if self.has_v:
 */
    }

    /* "btdht/krcp.pyx":1299
 *             if not self._encode_secondary_dict(data, i, max):
 *                 return False
 *         if self.has_t:             # <<<<<<<<<<<<<<
 *             if i[0] + 3 > max:
 *                 printf("encode_main: %d\n", 4)
 */
  }

  /* "btdht/krcp.pyx":1307
 *             if not _encode_string(data, i, max, self._t, self.t_len):
 *                 return False
 *         if self.has_v:             # <<<<<<<<<<<<<<
 *             if i[0] + 3 > max:
 *                 printf("encode_main: %d\n", 5)
 */
  __pyx_t_1 = (__pyx_v_self->has_v != 0);
  if (__pyx_t_1) {

    /* "btdht/krcp.pyx":1308
 *                 return False
 *         if self.has_v:
 *             if i[0] + 3 > max:             # <<<<<<<<<<<<<<
 *                 printf("encode_main: %d\n", 5)
 *                 return False
 */
    __pyx_t_1 = ((((__pyx_v_i[0]) + 3) > __pyx_v_max) != 0);
    if (__pyx_t_1) {

      /* "btdht/krcp.pyx":1309
 *         if self.has_v:
 *             if i[0] + 3 > max:
 *                 printf("encode_main: %d\n", 5)             # <<<<<<<<<<<<<<
 *                 return False
 *             strncpy(data + i[0], b"1:v", 3)
 */
      (void)(printf(((char const *)"encode_main: %d\n"), 5));

      /* "btdht/krcp.pyx":1310
 *             if i[0] + 3 > max:
 *                 printf("encode_main: %d\n", 5)
 *                 return False             # <<<<<<<<<<<<<<
 *             strncpy(data + i[0], b"1:v", 3)
 *             i[0]+=3
 */
      __pyx_r = 0;
      goto __pyx_L0;

      /* "btdht/krcp.pyx":1308
 *                 return False
 *         if self.has_v:
 *             if i[0] + 3 > max:             # <<<<<<<<<<<<<<
 *                 printf("encode_main: %d\n", 5)
 *                 return False
 */
    }

    /* "btdht/krcp.pyx":1311
 *                 printf("encode_main: %d\n", 5)
 *                 return False
 *             strncpy(data + i[0], b"1:v", 3)             # <<<<<<<<<<<<<<
 *             i[0]+=3
 *             if not _encode_string(data, i, max, self._v, self.v_len):
 */
    (void)(strncpy((__pyx_v_data + (__pyx_v_i[0])), ((char const *)"1:v"), 3));

    /* "btdht/krcp.pyx":1312
 *                 return False
 *             strncpy(data + i[0], b"1:v", 3)
 *             i[0]+=3             # <<<<<<<<<<<<<<
 *             if not _encode_string(data, i, max, self._v, self.v_len):
 *                 return False
 */
    __pyx_t_2 = 0;
    (__pyx_v_i[__pyx_t_2]) = ((__pyx_v_i[__pyx_t_2]) + 3);

    /* "btdht/krcp.pyx":1313
 *             strncpy(data + i[0], b"1:v", 3)
 *             i[0]+=3
 *             if not _encode_string(data, i, max, self._v, self.v_len):             # <<<<<<<<<<<<<<
 *                 return False
 *         if self.has_y:
 */
    __pyx_t_1 = ((!(__pyx_f_5btdht_4krcp__encode_string(__pyx_v_data, __pyx_v_i, __pyx_v_max, __pyx_v_self->_v, __pyx_v_self->v_len) != 0)) != 0);
    if (__pyx_t_1) {

      /* "btdht/krcp.pyx":1314
 *             i[0]+=3
 *             if not _encode_string(data, i, max, self._v, self.v_len):
 *                 return False             # <<<<<<<<<<<<<<
 *         if self.has_y:
 *             if i[0] + 3 > max:
 */
      __pyx_r = 0;
      goto __pyx_L0;

      /* "btdht/krcp.pyx":1313
 *             strncpy(data + i[0], b"1:v", 3)
 *             i[0]+=3
 *             if not _encode_string(data, i, max, self._v, self.v_len):             # <<<<<<<<<<<<<<
 *                 return False
 *         if self.has_y:
 */
    }

    /* "btdht/krcp.pyx":1307
 *             if not _encode_string(data, i, max, self._t, self.t_len):
 *                 return False
 *         if self.has_v:             # <<<<<<<<<<<<<<
 *             if i[0] + 3 > max:
 *                 printf("encode_main: %d\n", 5)
 */
  }

  /* "btdht/krcp.pyx":1315
 *             if not _encode_string(data, i, max, self._v, self.v_len):
 *                 return False
 *         if self.has_y:             # <<<<<<<<<<<<<<
 *             if i[0] + 3 > max:
 *                 printf("encode_main: %d %d\n", 6, i[0])
 */
  __pyx_t_1 = (__pyx_v_self->has_y != 0);
  if (__pyx_t_1) {

    /* "btdht/krcp.pyx":1316
 *                 return False
 *         if self.has_y:
 *             if i[0] + 3 > max:             # <<<<<<<<<<<<<<
 *                 printf("encode_main: %d %d\n", 6, i[0])
 *                 return False
 */
    __pyx_t_1 = ((((__pyx_v_i[0]) + 3) > __pyx_v_max) != 0);
    if (__pyx_t_1) {

      /* "btdht/krcp.pyx":1317
 *         if self.has_y:
 *             if i[0] + 3 > max:
 *                 printf("encode_main: %d %d\n", 6, i[0])             # <<<<<<<<<<<<<<
 *                 return False
 *             strncpy(data + i[0], b"1:y", 3)
 */
      (void)(printf(((char const *)"encode_main: %d %d\n"), 6, (__pyx_v_i[0])));

      /* "btdht/krcp.pyx":1318
 *             if i[0] + 3 > max:
 *                 printf("encode_main: %d %d\n", 6, i[0])
 *                 return False             # <<<<<<<<<<<<<<
 *             strncpy(data + i[0], b"1:y", 3)
 *             i[0]+=3
 */
      __pyx_r = 0;
      goto __pyx_L0;

      /* "btdht/krcp.pyx":1316
 *                 return False
 *         if self.has_y:
 *             if i[0] + 3 > max:             # <<<<<<<<<<<<<<
 *                 printf("encode_main: %d %d\n", 6, i[0])
 *                 return False
 */
    }

    /* "btdht/krcp.pyx":1319
 *                 printf("encode_main: %d %d\n", 6, i[0])
 *                 return False
 *             strncpy(data + i[0], b"1:y", 3)             # <<<<<<<<<<<<<<
 *             i[0]+=3
 *             if not _encode_string(data, i, max, self._y, self.y_len):
 */
    (void)(strncpy((__pyx_v_data + (__pyx_v_i[0])), ((char const *)"1:y"), 3));

    /* "btdht/krcp.pyx":1320
 *                 return False
 *             strncpy(data + i[0], b"1:y", 3)
 *             i[0]+=3             # <<<<<<<<<<<<<<
 *             if not _encode_string(data, i, max, self._y, self.y_len):
 *                 return False
 */
    __pyx_t_2 = 0;
    (__pyx_v_i[__pyx_t_2]) = ((__pyx_v_i[__pyx_t_2]) + 3);

    /* "btdht/krcp.pyx":1321
 *             strncpy(data + i[0], b"1:y", 3)
 *             i[0]+=3
 *             if not _encode_string(data, i, max, self._y, self.y_len):             # <<<<<<<<<<<<<<
 *                 return False
 *         if i[0] + 1 > max:
 */
    __pyx_t_1 = ((!(__pyx_f_5btdht_4krcp__encode_string(__pyx_v_data, __pyx_v_i, __pyx_v_max, __pyx_v_self->_y, __pyx_v_self->y_len) != 0)) != 0);
    if (__pyx_t_1) {

      /* "btdht/krcp.pyx":1322
 *             i[0]+=3
 *             if not _encode_string(data, i, max, self._y, self.y_len):
 *                 return False             # <<<<<<<<<<<<<<
 *         if i[0] + 1 > max:
 *             printf("encode_main: %d\n", 7)
 */
      __pyx_r = 0;
      goto __pyx_L0;

      /* "btdht/krcp.pyx":1321
 *             strncpy(data + i[0], b"1:y", 3)
 *             i[0]+=3
 *             if not _encode_string(data, i, max, self._y, self.y_len):             # <<<<<<<<<<<<<<
 *                 return False
 *         if i[0] + 1 > max:
 */
    }

    /* "btdht/krcp.pyx":1315
 *             if not _encode_string(data, i, max, self._v, self.v_len):
 *                 return False
 *         if self.has_y:             # <<<<<<<<<<<<<<
 *             if i[0] + 3 > max:
 *                 printf("encode_main: %d %d\n", 6, i[0])
 */
  }

  /* "btdht/krcp.pyx":1323
 *             if not _encode_string(data, i, max, self._y, self.y_len):
 *                 return False
 *         if i[0] + 1 > max:             # <<<<<<<<<<<<<<
 *             printf("encode_main: %d\n", 7)
 *             return False
 */
  __pyx_t_1 = ((((__pyx_v_i[0]) + 1) > __pyx_v_max) != 0);
  if (__pyx_t_1) {

    /* "btdht/krcp.pyx":1324
 *                 return False
 *         if i[0] + 1 > max:
 *             printf("encode_main: %d\n", 7)             # <<<<<<<<<<<<<<
 *             return False
 *         data[i[0]] = b'e'
 */
    (void)(printf(((char const *)"encode_main: %d\n"), 7));

    /* "btdht/krcp.pyx":1325
 *         if i[0] + 1 > max:
 *             printf("encode_main: %d\n", 7)
 *             return False             # <<<<<<<<<<<<<<
 *         data[i[0]] = b'e'
 *         i[0]+=1
 */
    __pyx_r = 0;
    goto __pyx_L0;

    /* "btdht/krcp.pyx":1323
 *             if not _encode_string(data, i, max, self._y, self.y_len):
 *                 return False
 *         if i[0] + 1 > max:             # <<<<<<<<<<<<<<
 *             printf("encode_main: %d\n", 7)
 *             return False
 */
  }

  /* "btdht/krcp.pyx":1326
 *             printf("encode_main: %d\n", 7)
 *             return False
 *         data[i[0]] = b'e'             # <<<<<<<<<<<<<<
 *         i[0]+=1
 *         return True
 */
  (__pyx_v_data[(__pyx_v_i[0])]) = 'e';

  /* "btdht/krcp.pyx":1327
 *             return False
 *         data[i[0]] = b'e'
 *         i[0]+=1             # <<<<<<<<<<<<<<
 *         return True
 * 
 */
  __pyx_t_2 = 0;
  (__pyx_v_i[__pyx_t_2]) = ((__pyx_v_i[__pyx_t_2]) + 1);

  /* "btdht/krcp.pyx":1328
 *         data[i[0]] = b'e'
 *         i[0]+=1
 *         return True             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_r = 1;
  goto __pyx_L0;

  /* "btdht/krcp.pyx":1249
 *         return True
 * 
 *     cdef int _encode_main_dict(self, char* data, int* i, int max) nogil:             # <<<<<<<<<<<<<<
 *         """
 *             Bencode the message primary dictionnary
 */

  /* function exit code */
  __pyx_L0:;
  return __pyx_r;
}

/* "btdht/krcp.pyx":1331
 * 
 * 
 *     cdef int _encode(self) nogil:             # <<<<<<<<<<<<<<
 *         """
 *             Bencode the current message
 */

static int __pyx_f_5btdht_4krcp_8BMessage__encode(struct __pyx_obj_5btdht_4krcp_BMessage *__pyx_v_self) {
  int __pyx_v_i;
  int __pyx_r;
  int __pyx_t_1;

  /* "btdht/krcp.pyx":1340
 *                 This method can be called without the python GIL
 *         """
 *         cdef int i=0             # <<<<<<<<<<<<<<
 *         if self.encoded_len > 0:
 *             free(self.encoded)
 */
  __pyx_v_i = 0;

  /* "btdht/krcp.pyx":1341
 *         """
 *         cdef int i=0
 *         if self.encoded_len > 0:             # <<<<<<<<<<<<<<
 *             free(self.encoded)
 *         self.encoded_len = self._encode_len()
 */
  __pyx_t_1 = ((__pyx_v_self->encoded_len > 0) != 0);
  if (__pyx_t_1) {

    /* "btdht/krcp.pyx":1342
 *         cdef int i=0
 *         if self.encoded_len > 0:
 *             free(self.encoded)             # <<<<<<<<<<<<<<
 *         self.encoded_len = self._encode_len()
 *         #printf("free%d\n", 0)
 */
    free(__pyx_v_self->encoded);

    /* "btdht/krcp.pyx":1341
 *         """
 *         cdef int i=0
 *         if self.encoded_len > 0:             # <<<<<<<<<<<<<<
 *             free(self.encoded)
 *         self.encoded_len = self._encode_len()
 */
  }

  /* "btdht/krcp.pyx":1343
 *         if self.encoded_len > 0:
 *             free(self.encoded)
 *         self.encoded_len = self._encode_len()             # <<<<<<<<<<<<<<
 *         #printf("free%d\n", 0)
 *         #printf("free%d\n", 1)
 */
  __pyx_v_self->encoded_len = ((struct __pyx_vtabstruct_5btdht_4krcp_BMessage *)__pyx_v_self->__pyx_vtab)->_encode_len(__pyx_v_self);

  /* "btdht/krcp.pyx":1346
 *         #printf("free%d\n", 0)
 *         #printf("free%d\n", 1)
 *         self.encoded = <char *> malloc(self.encoded_len * sizeof(char))             # <<<<<<<<<<<<<<
 *         if self._encode_main_dict(self.encoded, &i, self.encoded_len):
 *             self.encoded_uptodate = True
 */
  __pyx_v_self->encoded = ((char *)malloc((__pyx_v_self->encoded_len * (sizeof(char)))));

  /* "btdht/krcp.pyx":1347
 *         #printf("free%d\n", 1)
 *         self.encoded = <char *> malloc(self.encoded_len * sizeof(char))
 *         if self._encode_main_dict(self.encoded, &i, self.encoded_len):             # <<<<<<<<<<<<<<
 *             self.encoded_uptodate = True
 *             return True
 */
  __pyx_t_1 = (((struct __pyx_vtabstruct_5btdht_4krcp_BMessage *)__pyx_v_self->__pyx_vtab)->_encode_main_dict(__pyx_v_self, __pyx_v_self->encoded, (&__pyx_v_i), __pyx_v_self->encoded_len) != 0);
  if (__pyx_t_1) {

    /* "btdht/krcp.pyx":1348
 *         self.encoded = <char *> malloc(self.encoded_len * sizeof(char))
 *         if self._encode_main_dict(self.encoded, &i, self.encoded_len):
 *             self.encoded_uptodate = True             # <<<<<<<<<<<<<<
 *             return True
 *         else:
 */
    __pyx_v_self->encoded_uptodate = 1;

    /* "btdht/krcp.pyx":1349
 *         if self._encode_main_dict(self.encoded, &i, self.encoded_len):
 *             self.encoded_uptodate = True
 *             return True             # <<<<<<<<<<<<<<
 *         else:
 *             free(self.encoded)
 */
    __pyx_r = 1;
    goto __pyx_L0;

    /* "btdht/krcp.pyx":1347
 *         #printf("free%d\n", 1)
 *         self.encoded = <char *> malloc(self.encoded_len * sizeof(char))
 *         if self._encode_main_dict(self.encoded, &i, self.encoded_len):             # <<<<<<<<<<<<<<
 *             self.encoded_uptodate = True
 *             return True
 */
  }

  /* "btdht/krcp.pyx":1351
 *             return True
 *         else:
 *             free(self.encoded)             # <<<<<<<<<<<<<<
 *             self.encoded_len = 0
 *             self.encoded_uptodate = False
 */
  /*else*/ {
    free(__pyx_v_self->encoded);

    /* "btdht/krcp.pyx":1352
 *         else:
 *             free(self.encoded)
 *             self.encoded_len = 0             # <<<<<<<<<<<<<<
 *             self.encoded_uptodate = False
 *             return False
 */
    __pyx_v_self->encoded_len = 0;

    /* "btdht/krcp.pyx":1353
 *             free(self.encoded)
 *             self.encoded_len = 0
 *             self.encoded_uptodate = False             # <<<<<<<<<<<<<<
 *             return False
 * 
 */
    __pyx_v_self->encoded_uptodate = 0;

    /* "btdht/krcp.pyx":1354
 *             self.encoded_len = 0
 *             self.encoded_uptodate = False
 *             return False             # <<<<<<<<<<<<<<
 * 
 *     cdef int _encode_len(self) nogil:
 */
    __pyx_r = 0;
    goto __pyx_L0;
  }

  /* "btdht/krcp.pyx":1331
 * 
 * 
 *     cdef int _encode(self) nogil:             # <<<<<<<<<<<<<<
 *         """
 *             Bencode the current message
 */

  /* function exit code */
  __pyx_L0:;
  return __pyx_r;
}

/* "btdht/krcp.pyx":1356
 *             return False
 * 
 *     cdef int _encode_len(self) nogil:             # <<<<<<<<<<<<<<
 *         """
 *             Compute the length of the message once bencoded
 */

static int __pyx_f_5btdht_4krcp_8BMessage__encode_len(struct __pyx_obj_5btdht_4krcp_BMessage *__pyx_v_self) {
  int __pyx_v_estimated_len;
  int __pyx_r;
  int __pyx_t_1;
  int __pyx_t_2;

  /* "btdht/krcp.pyx":1369
 *                 will be written to.
 *         """
 *         cdef int estimated_len = 2 # the d and e of the global dict             # <<<<<<<<<<<<<<
 *         if self.has_y:
 *             estimated_len+=int_length(self.y_len) + 1 + self.y_len + 3# len + : + str
 */
  __pyx_v_estimated_len = 2;

  /* "btdht/krcp.pyx":1370
 *         """
 *         cdef int estimated_len = 2 # the d and e of the global dict
 *         if self.has_y:             # <<<<<<<<<<<<<<
 *             estimated_len+=int_length(self.y_len) + 1 + self.y_len + 3# len + : + str
 *         if self.has_t:
 */
  __pyx_t_1 = (__pyx_v_self->has_y != 0);
  if (__pyx_t_1) {

    /* "btdht/krcp.pyx":1371
 *         cdef int estimated_len = 2 # the d and e of the global dict
 *         if self.has_y:
 *             estimated_len+=int_length(self.y_len) + 1 + self.y_len + 3# len + : + str             # <<<<<<<<<<<<<<
 *         if self.has_t:
 *             estimated_len+=int_length(self.t_len) + 1 + self.t_len + 3
 */
    __pyx_v_estimated_len = (__pyx_v_estimated_len + (((__pyx_f_5btdht_4krcp_int_length(__pyx_v_self->y_len) + 1) + __pyx_v_self->y_len) + 3));

    /* "btdht/krcp.pyx":1370
 *         """
 *         cdef int estimated_len = 2 # the d and e of the global dict
 *         if self.has_y:             # <<<<<<<<<<<<<<
 *             estimated_len+=int_length(self.y_len) + 1 + self.y_len + 3# len + : + str
 *         if self.has_t:
 */
  }

  /* "btdht/krcp.pyx":1372
 *         if self.has_y:
 *             estimated_len+=int_length(self.y_len) + 1 + self.y_len + 3# len + : + str
 *         if self.has_t:             # <<<<<<<<<<<<<<
 *             estimated_len+=int_length(self.t_len) + 1 + self.t_len + 3
 *         if self.has_q:
 */
  __pyx_t_1 = (__pyx_v_self->has_t != 0);
  if (__pyx_t_1) {

    /* "btdht/krcp.pyx":1373
 *             estimated_len+=int_length(self.y_len) + 1 + self.y_len + 3# len + : + str
 *         if self.has_t:
 *             estimated_len+=int_length(self.t_len) + 1 + self.t_len + 3             # <<<<<<<<<<<<<<
 *         if self.has_q:
 *             estimated_len+=int_length(self.q_len) + 1 + self.q_len + 3
 */
    __pyx_v_estimated_len = (__pyx_v_estimated_len + (((__pyx_f_5btdht_4krcp_int_length(__pyx_v_self->t_len) + 1) + __pyx_v_self->t_len) + 3));

    /* "btdht/krcp.pyx":1372
 *         if self.has_y:
 *             estimated_len+=int_length(self.y_len) + 1 + self.y_len + 3# len + : + str
 *         if self.has_t:             # <<<<<<<<<<<<<<
 *             estimated_len+=int_length(self.t_len) + 1 + self.t_len + 3
 *         if self.has_q:
 */
  }

  /* "btdht/krcp.pyx":1374
 *         if self.has_t:
 *             estimated_len+=int_length(self.t_len) + 1 + self.t_len + 3
 *         if self.has_q:             # <<<<<<<<<<<<<<
 *             estimated_len+=int_length(self.q_len) + 1 + self.q_len + 3
 *         if self.has_v:
 */
  __pyx_t_1 = (__pyx_v_self->has_q != 0);
  if (__pyx_t_1) {

    /* "btdht/krcp.pyx":1375
 *             estimated_len+=int_length(self.t_len) + 1 + self.t_len + 3
 *         if self.has_q:
 *             estimated_len+=int_length(self.q_len) + 1 + self.q_len + 3             # <<<<<<<<<<<<<<
 *         if self.has_v:
 *             estimated_len+=int_length(self.v_len) + 1 + self.v_len + 3
 */
    __pyx_v_estimated_len = (__pyx_v_estimated_len + (((__pyx_f_5btdht_4krcp_int_length(__pyx_v_self->q_len) + 1) + __pyx_v_self->q_len) + 3));

    /* "btdht/krcp.pyx":1374
 *         if self.has_t:
 *             estimated_len+=int_length(self.t_len) + 1 + self.t_len + 3
 *         if self.has_q:             # <<<<<<<<<<<<<<
 *             estimated_len+=int_length(self.q_len) + 1 + self.q_len + 3
 *         if self.has_v:
 */
  }

  /* "btdht/krcp.pyx":1376
 *         if self.has_q:
 *             estimated_len+=int_length(self.q_len) + 1 + self.q_len + 3
 *         if self.has_v:             # <<<<<<<<<<<<<<
 *             estimated_len+=int_length(self.v_len) + 1 + self.v_len + 3
 *         if self.r or self.a or self.e: # only one can be True
 */
  __pyx_t_1 = (__pyx_v_self->has_v != 0);
  if (__pyx_t_1) {

    /* "btdht/krcp.pyx":1377
 *             estimated_len+=int_length(self.q_len) + 1 + self.q_len + 3
 *         if self.has_v:
 *             estimated_len+=int_length(self.v_len) + 1 + self.v_len + 3             # <<<<<<<<<<<<<<
 *         if self.r or self.a or self.e: # only one can be True
 *             estimated_len+=2 + 3 # the d and e of the a ou r dict
 */
    __pyx_v_estimated_len = (__pyx_v_estimated_len + (((__pyx_f_5btdht_4krcp_int_length(__pyx_v_self->v_len) + 1) + __pyx_v_self->v_len) + 3));

    /* "btdht/krcp.pyx":1376
 *         if self.has_q:
 *             estimated_len+=int_length(self.q_len) + 1 + self.q_len + 3
 *         if self.has_v:             # <<<<<<<<<<<<<<
 *             estimated_len+=int_length(self.v_len) + 1 + self.v_len + 3
 *         if self.r or self.a or self.e: # only one can be True
 */
  }

  /* "btdht/krcp.pyx":1378
 *         if self.has_v:
 *             estimated_len+=int_length(self.v_len) + 1 + self.v_len + 3
 *         if self.r or self.a or self.e: # only one can be True             # <<<<<<<<<<<<<<
 *             estimated_len+=2 + 3 # the d and e of the a ou r dict
 *         if self.e:
 */
  __pyx_t_2 = (__pyx_v_self->r != 0);
  if (!__pyx_t_2) {
  } else {
    __pyx_t_1 = __pyx_t_2;
    goto __pyx_L8_bool_binop_done;
  }
  __pyx_t_2 = (__pyx_v_self->a != 0);
  if (!__pyx_t_2) {
  } else {
    __pyx_t_1 = __pyx_t_2;
    goto __pyx_L8_bool_binop_done;
  }
  __pyx_t_2 = (__pyx_v_self->e != 0);
  __pyx_t_1 = __pyx_t_2;
  __pyx_L8_bool_binop_done:;
  if (__pyx_t_1) {

    /* "btdht/krcp.pyx":1379
 *             estimated_len+=int_length(self.v_len) + 1 + self.v_len + 3
 *         if self.r or self.a or self.e: # only one can be True
 *             estimated_len+=2 + 3 # the d and e of the a ou r dict             # <<<<<<<<<<<<<<
 *         if self.e:
 *             estimated_len+=(
 */
    __pyx_v_estimated_len = (__pyx_v_estimated_len + 5);

    /* "btdht/krcp.pyx":1378
 *         if self.has_v:
 *             estimated_len+=int_length(self.v_len) + 1 + self.v_len + 3
 *         if self.r or self.a or self.e: # only one can be True             # <<<<<<<<<<<<<<
 *             estimated_len+=2 + 3 # the d and e of the a ou r dict
 *         if self.e:
 */
  }

  /* "btdht/krcp.pyx":1380
 *         if self.r or self.a or self.e: # only one can be True
 *             estimated_len+=2 + 3 # the d and e of the a ou r dict
 *         if self.e:             # <<<<<<<<<<<<<<
 *             estimated_len+=(
 *                 int_length(self._errno) + 2 +
 */
  __pyx_t_1 = (__pyx_v_self->e != 0);
  if (__pyx_t_1) {

    /* "btdht/krcp.pyx":1381
 *             estimated_len+=2 + 3 # the d and e of the a ou r dict
 *         if self.e:
 *             estimated_len+=(             # <<<<<<<<<<<<<<
 *                 int_length(self._errno) + 2 +
 *                 self.errmsg_len + 1 + int_length(self.errmsg_len)
 */
    __pyx_v_estimated_len = (__pyx_v_estimated_len + ((((__pyx_f_5btdht_4krcp_int_length(__pyx_v_self->_errno) + 2) + __pyx_v_self->errmsg_len) + 1) + __pyx_f_5btdht_4krcp_int_length(__pyx_v_self->errmsg_len)));

    /* "btdht/krcp.pyx":1380
 *         if self.r or self.a or self.e: # only one can be True
 *             estimated_len+=2 + 3 # the d and e of the a ou r dict
 *         if self.e:             # <<<<<<<<<<<<<<
 *             estimated_len+=(
 *                 int_length(self._errno) + 2 +
 */
  }

  /* "btdht/krcp.pyx":1385
 *                 self.errmsg_len + 1 + int_length(self.errmsg_len)
 *             )
 *         if self.r or self.a:             # <<<<<<<<<<<<<<
 *             if self.has_id:
 *                 estimated_len+=23 + 4
 */
  __pyx_t_2 = (__pyx_v_self->r != 0);
  if (!__pyx_t_2) {
  } else {
    __pyx_t_1 = __pyx_t_2;
    goto __pyx_L13_bool_binop_done;
  }
  __pyx_t_2 = (__pyx_v_self->a != 0);
  __pyx_t_1 = __pyx_t_2;
  __pyx_L13_bool_binop_done:;
  if (__pyx_t_1) {

    /* "btdht/krcp.pyx":1386
 *             )
 *         if self.r or self.a:
 *             if self.has_id:             # <<<<<<<<<<<<<<
 *                 estimated_len+=23 + 4
 *             if self.has_target:
 */
    __pyx_t_1 = (__pyx_v_self->has_id != 0);
    if (__pyx_t_1) {

      /* "btdht/krcp.pyx":1387
 *         if self.r or self.a:
 *             if self.has_id:
 *                 estimated_len+=23 + 4             # <<<<<<<<<<<<<<
 *             if self.has_target:
 *                 estimated_len+=23 + 8
 */
      __pyx_v_estimated_len = (__pyx_v_estimated_len + 27);

      /* "btdht/krcp.pyx":1386
 *             )
 *         if self.r or self.a:
 *             if self.has_id:             # <<<<<<<<<<<<<<
 *                 estimated_len+=23 + 4
 *             if self.has_target:
 */
    }

    /* "btdht/krcp.pyx":1388
 *             if self.has_id:
 *                 estimated_len+=23 + 4
 *             if self.has_target:             # <<<<<<<<<<<<<<
 *                 estimated_len+=23 + 8
 *             if self.has_info_hash:
 */
    __pyx_t_1 = (__pyx_v_self->has_target != 0);
    if (__pyx_t_1) {

      /* "btdht/krcp.pyx":1389
 *                 estimated_len+=23 + 4
 *             if self.has_target:
 *                 estimated_len+=23 + 8             # <<<<<<<<<<<<<<
 *             if self.has_info_hash:
 *                 estimated_len+=23 + 11
 */
      __pyx_v_estimated_len = (__pyx_v_estimated_len + 31);

      /* "btdht/krcp.pyx":1388
 *             if self.has_id:
 *                 estimated_len+=23 + 4
 *             if self.has_target:             # <<<<<<<<<<<<<<
 *                 estimated_len+=23 + 8
 *             if self.has_info_hash:
 */
    }

    /* "btdht/krcp.pyx":1390
 *             if self.has_target:
 *                 estimated_len+=23 + 8
 *             if self.has_info_hash:             # <<<<<<<<<<<<<<
 *                 estimated_len+=23 + 11
 *             if self.has_implied_port:
 */
    __pyx_t_1 = (__pyx_v_self->has_info_hash != 0);
    if (__pyx_t_1) {

      /* "btdht/krcp.pyx":1391
 *                 estimated_len+=23 + 8
 *             if self.has_info_hash:
 *                 estimated_len+=23 + 11             # <<<<<<<<<<<<<<
 *             if self.has_implied_port:
 *                 estimated_len+=int_length(self.implied_port) + 2 + 15# i + int + e
 */
      __pyx_v_estimated_len = (__pyx_v_estimated_len + 34);

      /* "btdht/krcp.pyx":1390
 *             if self.has_target:
 *                 estimated_len+=23 + 8
 *             if self.has_info_hash:             # <<<<<<<<<<<<<<
 *                 estimated_len+=23 + 11
 *             if self.has_implied_port:
 */
    }

    /* "btdht/krcp.pyx":1392
 *             if self.has_info_hash:
 *                 estimated_len+=23 + 11
 *             if self.has_implied_port:             # <<<<<<<<<<<<<<
 *                 estimated_len+=int_length(self.implied_port) + 2 + 15# i + int + e
 *             if self.has_port:
 */
    __pyx_t_1 = (__pyx_v_self->has_implied_port != 0);
    if (__pyx_t_1) {

      /* "btdht/krcp.pyx":1393
 *                 estimated_len+=23 + 11
 *             if self.has_implied_port:
 *                 estimated_len+=int_length(self.implied_port) + 2 + 15# i + int + e             # <<<<<<<<<<<<<<
 *             if self.has_port:
 *                 estimated_len+=int_length(self.port) + 2 + 6
 */
      __pyx_v_estimated_len = (__pyx_v_estimated_len + ((__pyx_f_5btdht_4krcp_int_length(__pyx_v_self->implied_port) + 2) + 15));

      /* "btdht/krcp.pyx":1392
 *             if self.has_info_hash:
 *                 estimated_len+=23 + 11
 *             if self.has_implied_port:             # <<<<<<<<<<<<<<
 *                 estimated_len+=int_length(self.implied_port) + 2 + 15# i + int + e
 *             if self.has_port:
 */
    }

    /* "btdht/krcp.pyx":1394
 *             if self.has_implied_port:
 *                 estimated_len+=int_length(self.implied_port) + 2 + 15# i + int + e
 *             if self.has_port:             # <<<<<<<<<<<<<<
 *                 estimated_len+=int_length(self.port) + 2 + 6
 *             if self.has_nodes:
 */
    __pyx_t_1 = (__pyx_v_self->has_port != 0);
    if (__pyx_t_1) {

      /* "btdht/krcp.pyx":1395
 *                 estimated_len+=int_length(self.implied_port) + 2 + 15# i + int + e
 *             if self.has_port:
 *                 estimated_len+=int_length(self.port) + 2 + 6             # <<<<<<<<<<<<<<
 *             if self.has_nodes:
 *                 estimated_len+=int_length(self.nodes_len) + 1 + self.nodes_len + 7
 */
      __pyx_v_estimated_len = (__pyx_v_estimated_len + ((__pyx_f_5btdht_4krcp_int_length(__pyx_v_self->port) + 2) + 6));

      /* "btdht/krcp.pyx":1394
 *             if self.has_implied_port:
 *                 estimated_len+=int_length(self.implied_port) + 2 + 15# i + int + e
 *             if self.has_port:             # <<<<<<<<<<<<<<
 *                 estimated_len+=int_length(self.port) + 2 + 6
 *             if self.has_nodes:
 */
    }

    /* "btdht/krcp.pyx":1396
 *             if self.has_port:
 *                 estimated_len+=int_length(self.port) + 2 + 6
 *             if self.has_nodes:             # <<<<<<<<<<<<<<
 *                 estimated_len+=int_length(self.nodes_len) + 1 + self.nodes_len + 7
 *             if self.has_token:
 */
    __pyx_t_1 = (__pyx_v_self->has_nodes != 0);
    if (__pyx_t_1) {

      /* "btdht/krcp.pyx":1397
 *                 estimated_len+=int_length(self.port) + 2 + 6
 *             if self.has_nodes:
 *                 estimated_len+=int_length(self.nodes_len) + 1 + self.nodes_len + 7             # <<<<<<<<<<<<<<
 *             if self.has_token:
 *                 estimated_len+=int_length(self.token_len) + 1 + self.token_len + 7
 */
      __pyx_v_estimated_len = (__pyx_v_estimated_len + (((__pyx_f_5btdht_4krcp_int_length(__pyx_v_self->nodes_len) + 1) + __pyx_v_self->nodes_len) + 7));

      /* "btdht/krcp.pyx":1396
 *             if self.has_port:
 *                 estimated_len+=int_length(self.port) + 2 + 6
 *             if self.has_nodes:             # <<<<<<<<<<<<<<
 *                 estimated_len+=int_length(self.nodes_len) + 1 + self.nodes_len + 7
 *             if self.has_token:
 */
    }

    /* "btdht/krcp.pyx":1398
 *             if self.has_nodes:
 *                 estimated_len+=int_length(self.nodes_len) + 1 + self.nodes_len + 7
 *             if self.has_token:             # <<<<<<<<<<<<<<
 *                 estimated_len+=int_length(self.token_len) + 1 + self.token_len + 7
 *             if self.has_values:
 */
    __pyx_t_1 = (__pyx_v_self->has_token != 0);
    if (__pyx_t_1) {

      /* "btdht/krcp.pyx":1399
 *                 estimated_len+=int_length(self.nodes_len) + 1 + self.nodes_len + 7
 *             if self.has_token:
 *                 estimated_len+=int_length(self.token_len) + 1 + self.token_len + 7             # <<<<<<<<<<<<<<
 *             if self.has_values:
 *                 estimated_len+= 8 * self.values_nb + 2 + 8 # l + nb * IPPORT + e
 */
      __pyx_v_estimated_len = (__pyx_v_estimated_len + (((__pyx_f_5btdht_4krcp_int_length(__pyx_v_self->token_len) + 1) + __pyx_v_self->token_len) + 7));

      /* "btdht/krcp.pyx":1398
 *             if self.has_nodes:
 *                 estimated_len+=int_length(self.nodes_len) + 1 + self.nodes_len + 7
 *             if self.has_token:             # <<<<<<<<<<<<<<
 *                 estimated_len+=int_length(self.token_len) + 1 + self.token_len + 7
 *             if self.has_values:
 */
    }

    /* "btdht/krcp.pyx":1400
 *             if self.has_token:
 *                 estimated_len+=int_length(self.token_len) + 1 + self.token_len + 7
 *             if self.has_values:             # <<<<<<<<<<<<<<
 *                 estimated_len+= 8 * self.values_nb + 2 + 8 # l + nb * IPPORT + e
 *         #printf("estimated_len: %d\n" , estimated_len)
 */
    __pyx_t_1 = (__pyx_v_self->has_values != 0);
    if (__pyx_t_1) {

      /* "btdht/krcp.pyx":1401
 *                 estimated_len+=int_length(self.token_len) + 1 + self.token_len + 7
 *             if self.has_values:
 *                 estimated_len+= 8 * self.values_nb + 2 + 8 # l + nb * IPPORT + e             # <<<<<<<<<<<<<<
 *         #printf("estimated_len: %d\n" , estimated_len)
 *         return estimated_len
 */
      __pyx_v_estimated_len = (__pyx_v_estimated_len + (((8 * __pyx_v_self->values_nb) + 2) + 8));

      /* "btdht/krcp.pyx":1400
 *             if self.has_token:
 *                 estimated_len+=int_length(self.token_len) + 1 + self.token_len + 7
 *             if self.has_values:             # <<<<<<<<<<<<<<
 *                 estimated_len+= 8 * self.values_nb + 2 + 8 # l + nb * IPPORT + e
 *         #printf("estimated_len: %d\n" , estimated_len)
 */
    }

    /* "btdht/krcp.pyx":1385
 *                 self.errmsg_len + 1 + int_length(self.errmsg_len)
 *             )
 *         if self.r or self.a:             # <<<<<<<<<<<<<<
 *             if self.has_id:
 *                 estimated_len+=23 + 4
 */
  }

  /* "btdht/krcp.pyx":1403
 *                 estimated_len+= 8 * self.values_nb + 2 + 8 # l + nb * IPPORT + e
 *         #printf("estimated_len: %d\n" , estimated_len)
 *         return estimated_len             # <<<<<<<<<<<<<<
 * 
 *     def encode(self):
 */
  __pyx_r = __pyx_v_estimated_len;
  goto __pyx_L0;

  /* "btdht/krcp.pyx":1356
 *             return False
 * 
 *     cdef int _encode_len(self) nogil:             # <<<<<<<<<<<<<<
 *         """
 *             Compute the length of the message once bencoded
 */

  /* function exit code */
  __pyx_L0:;
  return __pyx_r;
}

/* "btdht/krcp.pyx":1405
 *         return estimated_len
 * 
 *     def encode(self):             # <<<<<<<<<<<<<<
 *         """
 *             Bencoded the current message if necessary
 */

/* Python wrapper */
static PyObject *__pyx_pw_5btdht_4krcp_8BMessage_3encode(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static char __pyx_doc_5btdht_4krcp_8BMessage_2encode[] = "\n            Bencoded the current message if necessary\n\n            :return: The bencoded message\n            :rtype: bytes\n        ";
static PyObject *__pyx_pw_5btdht_4krcp_8BMessage_3encode(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("encode (wrapper)", 0);
  __pyx_r = __pyx_pf_5btdht_4krcp_8BMessage_2encode(((struct __pyx_obj_5btdht_4krcp_BMessage *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5btdht_4krcp_8BMessage_2encode(struct __pyx_obj_5btdht_4krcp_BMessage *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("encode", 0);

  /* "btdht/krcp.pyx":1412
 *             :rtype: bytes
 *         """
 *         if self.encoded_uptodate:             # <<<<<<<<<<<<<<
 *                 return self.encoded[:self.encoded_len]
 *         else:
 */
  __pyx_t_1 = (__pyx_v_self->encoded_uptodate != 0);
  if (__pyx_t_1) {

    /* "btdht/krcp.pyx":1413
 *         """
 *         if self.encoded_uptodate:
 *                 return self.encoded[:self.encoded_len]             # <<<<<<<<<<<<<<
 *         else:
 *             with nogil:
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_2 = __Pyx_PyBytes_FromStringAndSize(__pyx_v_self->encoded + 0, __pyx_v_self->encoded_len - 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1413, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_r = __pyx_t_2;
    __pyx_t_2 = 0;
    goto __pyx_L0;

    /* "btdht/krcp.pyx":1412
 *             :rtype: bytes
 *         """
 *         if self.encoded_uptodate:             # <<<<<<<<<<<<<<
 *                 return self.encoded[:self.encoded_len]
 *         else:
 */
  }

  /* "btdht/krcp.pyx":1415
 *                 return self.encoded[:self.encoded_len]
 *         else:
 *             with nogil:             # <<<<<<<<<<<<<<
 *                 self._encode()
 *         if self.encoded_uptodate:
 */
  /*else*/ {
    {
        #ifdef WITH_THREAD
        PyThreadState *_save;
        Py_UNBLOCK_THREADS
        __Pyx_FastGIL_Remember();
        #endif
        /*try:*/ {

          /* "btdht/krcp.pyx":1416
 *         else:
 *             with nogil:
 *                 self._encode()             # <<<<<<<<<<<<<<
 *         if self.encoded_uptodate:
 *                 return self.encoded[:self.encoded_len]
 */
          (void)(((struct __pyx_vtabstruct_5btdht_4krcp_BMessage *)__pyx_v_self->__pyx_vtab)->_encode(__pyx_v_self));
        }

        /* "btdht/krcp.pyx":1415
 *                 return self.encoded[:self.encoded_len]
 *         else:
 *             with nogil:             # <<<<<<<<<<<<<<
 *                 self._encode()
 *         if self.encoded_uptodate:
 */
        /*finally:*/ {
          /*normal exit:*/{
            #ifdef WITH_THREAD
            __Pyx_FastGIL_Forget();
            Py_BLOCK_THREADS
            #endif
            goto __pyx_L6;
          }
          __pyx_L6:;
        }
    }
  }

  /* "btdht/krcp.pyx":1417
 *             with nogil:
 *                 self._encode()
 *         if self.encoded_uptodate:             # <<<<<<<<<<<<<<
 *                 return self.encoded[:self.encoded_len]
 *         else:
 */
  __pyx_t_1 = (__pyx_v_self->encoded_uptodate != 0);
  if (likely(__pyx_t_1)) {

    /* "btdht/krcp.pyx":1418
 *                 self._encode()
 *         if self.encoded_uptodate:
 *                 return self.encoded[:self.encoded_len]             # <<<<<<<<<<<<<<
 *         else:
 *             raise EnvironmentError("Unable to encode BMessage")
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_2 = __Pyx_PyBytes_FromStringAndSize(__pyx_v_self->encoded + 0, __pyx_v_self->encoded_len - 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1418, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_r = __pyx_t_2;
    __pyx_t_2 = 0;
    goto __pyx_L0;

    /* "btdht/krcp.pyx":1417
 *             with nogil:
 *                 self._encode()
 *         if self.encoded_uptodate:             # <<<<<<<<<<<<<<
 *                 return self.encoded[:self.encoded_len]
 *         else:
 */
  }

  /* "btdht/krcp.pyx":1420
 *                 return self.encoded[:self.encoded_len]
 *         else:
 *             raise EnvironmentError("Unable to encode BMessage")             # <<<<<<<<<<<<<<
 * 
 *     def __repr__(self):
 */
  /*else*/ {
    __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_EnvironmentError, __pyx_tuple__3, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1420, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_Raise(__pyx_t_2, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __PYX_ERR(0, 1420, __pyx_L1_error)
  }

  /* "btdht/krcp.pyx":1405
 *         return estimated_len
 * 
 *     def encode(self):             # <<<<<<<<<<<<<<
 *         """
 *             Bencoded the current message if necessary
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_AddTraceback("btdht.krcp.BMessage.encode", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "btdht/krcp.pyx":1422
 *             raise EnvironmentError("Unable to encode BMessage")
 * 
 *     def __repr__(self):             # <<<<<<<<<<<<<<
 *         return "%r" % self.encode()
 * 
 */

/* Python wrapper */
static PyObject *__pyx_pw_5btdht_4krcp_8BMessage_5__repr__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_5btdht_4krcp_8BMessage_5__repr__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__repr__ (wrapper)", 0);
  __pyx_r = __pyx_pf_5btdht_4krcp_8BMessage_4__repr__(((struct __pyx_obj_5btdht_4krcp_BMessage *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5btdht_4krcp_8BMessage_4__repr__(struct __pyx_obj_5btdht_4krcp_BMessage *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__repr__", 0);

  /* "btdht/krcp.pyx":1423
 * 
 *     def __repr__(self):
 *         return "%r" % self.encode()             # <<<<<<<<<<<<<<
 * 
 *     def __str__(self):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_encode); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1423, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = NULL;
  if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) {
    __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
    if (likely(__pyx_t_3)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_3);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_2, function);
    }
  }
  __pyx_t_1 = (__pyx_t_3) ? __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3) : __Pyx_PyObject_CallNoArg(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1423, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = __Pyx_PyString_FormatSafe(__pyx_kp_s_r, __pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1423, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_r = __pyx_t_2;
  __pyx_t_2 = 0;
  goto __pyx_L0;

  /* "btdht/krcp.pyx":1422
 *             raise EnvironmentError("Unable to encode BMessage")
 * 
 *     def __repr__(self):             # <<<<<<<<<<<<<<
 *         return "%r" % self.encode()
 * 
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("btdht.krcp.BMessage.__repr__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "btdht/krcp.pyx":1425
 *         return "%r" % self.encode()
 * 
 *     def __str__(self):             # <<<<<<<<<<<<<<
 *         raise NotImplementedError()
 * 
 */

/* Python wrapper */
static PyObject *__pyx_pw_5btdht_4krcp_8BMessage_7__str__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_5btdht_4krcp_8BMessage_7__str__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__str__ (wrapper)", 0);
  __pyx_r = __pyx_pf_5btdht_4krcp_8BMessage_6__str__(((struct __pyx_obj_5btdht_4krcp_BMessage *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5btdht_4krcp_8BMessage_6__str__(CYTHON_UNUSED struct __pyx_obj_5btdht_4krcp_BMessage *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__str__", 0);

  /* "btdht/krcp.pyx":1426
 * 
 *     def __str__(self):
 *         raise NotImplementedError()             # <<<<<<<<<<<<<<
 * 
 *     #: The error number of the message if the message is and erro message
 */
  __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_builtin_NotImplementedError); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1426, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_Raise(__pyx_t_1, 0, 0, 0);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __PYX_ERR(0, 1426, __pyx_L1_error)

  /* "btdht/krcp.pyx":1425
 *         return "%r" % self.encode()
 * 
 *     def __str__(self):             # <<<<<<<<<<<<<<
 *         raise NotImplementedError()
 * 
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("btdht.krcp.BMessage.__str__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "btdht/krcp.pyx":1430
 *     #: The error number of the message if the message is and erro message
 *     property errno:
 *         def __get__(self):             # <<<<<<<<<<<<<<
 *             if self.e:
 *                 return self._errno
 */

/* Python wrapper */
static PyObject *__pyx_pw_5btdht_4krcp_8BMessage_5errno_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_5btdht_4krcp_8BMessage_5errno_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_5btdht_4krcp_8BMessage_5errno___get__(((struct __pyx_obj_5btdht_4krcp_BMessage *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5btdht_4krcp_8BMessage_5errno___get__(struct __pyx_obj_5btdht_4krcp_BMessage *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__get__", 0);

  /* "btdht/krcp.pyx":1431
 *     property errno:
 *         def __get__(self):
 *             if self.e:             # <<<<<<<<<<<<<<
 *                 return self._errno
 *             else:
 */
  __pyx_t_1 = (__pyx_v_self->e != 0);
  if (__pyx_t_1) {

    /* "btdht/krcp.pyx":1432
 *         def __get__(self):
 *             if self.e:
 *                 return self._errno             # <<<<<<<<<<<<<<
 *             else:
 *                 return None
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_2 = __Pyx_PyInt_From_int(__pyx_v_self->_errno); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1432, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_r = __pyx_t_2;
    __pyx_t_2 = 0;
    goto __pyx_L0;

    /* "btdht/krcp.pyx":1431
 *     property errno:
 *         def __get__(self):
 *             if self.e:             # <<<<<<<<<<<<<<
 *                 return self._errno
 *             else:
 */
  }

  /* "btdht/krcp.pyx":1434
 *                 return self._errno
 *             else:
 *                 return None             # <<<<<<<<<<<<<<
 *         def __set__(self, int value):
 *             self.set_errno(value)
 */
  /*else*/ {
    __Pyx_XDECREF(__pyx_r);
    __pyx_r = Py_None; __Pyx_INCREF(Py_None);
    goto __pyx_L0;
  }

  /* "btdht/krcp.pyx":1430
 *     #: The error number of the message if the message is and erro message
 *     property errno:
 *         def __get__(self):             # <<<<<<<<<<<<<<
 *             if self.e:
 *                 return self._errno
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_AddTraceback("btdht.krcp.BMessage.errno.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "btdht/krcp.pyx":1435
 *             else:
 *                 return None
 *         def __set__(self, int value):             # <<<<<<<<<<<<<<
 *             self.set_errno(value)
 * 
 */

/* Python wrapper */
static int __pyx_pw_5btdht_4krcp_8BMessage_5errno_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_arg_value); /*proto*/
static int __pyx_pw_5btdht_4krcp_8BMessage_5errno_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_arg_value) {
  int __pyx_v_value;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__set__ (wrapper)", 0);
  assert(__pyx_arg_value); {
    __pyx_v_value = __Pyx_PyInt_As_int(__pyx_arg_value); if (unlikely((__pyx_v_value == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 1435, __pyx_L3_error)
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L3_error:;
  __Pyx_AddTraceback("btdht.krcp.BMessage.errno.__set__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return -1;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_5btdht_4krcp_8BMessage_5errno_2__set__(((struct __pyx_obj_5btdht_4krcp_BMessage *)__pyx_v_self), ((int)__pyx_v_value));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static int __pyx_pf_5btdht_4krcp_8BMessage_5errno_2__set__(struct __pyx_obj_5btdht_4krcp_BMessage *__pyx_v_self, int __pyx_v_value) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__set__", 0);

  /* "btdht/krcp.pyx":1436
 *                 return None
 *         def __set__(self, int value):
 *             self.set_errno(value)             # <<<<<<<<<<<<<<
 * 
 *     #: The error message of the message if the message is and erro message
 */
  (void)(((struct __pyx_vtabstruct_5btdht_4krcp_BMessage *)__pyx_v_self->__pyx_vtab)->set_errno(__pyx_v_self, __pyx_v_value));

  /* "btdht/krcp.pyx":1435
 *             else:
 *                 return None
 *         def __set__(self, int value):             # <<<<<<<<<<<<<<
 *             self.set_errno(value)
 * 
 */

  /* function exit code */
  __pyx_r = 0;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "btdht/krcp.pyx":1440
 *     #: The error message of the message if the message is and erro message
 *     property errmsg:
 *         def __get__(self):             # <<<<<<<<<<<<<<
 *             if self.e:
 *                 return self._errmsg[:self.errmsg_len]
 */

/* Python wrapper */
static PyObject *__pyx_pw_5btdht_4krcp_8BMessage_6errmsg_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_5btdht_4krcp_8BMessage_6errmsg_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_5btdht_4krcp_8BMessage_6errmsg___get__(((struct __pyx_obj_5btdht_4krcp_BMessage *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5btdht_4krcp_8BMessage_6errmsg___get__(struct __pyx_obj_5btdht_4krcp_BMessage *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__get__", 0);

  /* "btdht/krcp.pyx":1441
 *     property errmsg:
 *         def __get__(self):
 *             if self.e:             # <<<<<<<<<<<<<<
 *                 return self._errmsg[:self.errmsg_len]
 *             else:
 */
  __pyx_t_1 = (__pyx_v_self->e != 0);
  if (__pyx_t_1) {

    /* "btdht/krcp.pyx":1442
 *         def __get__(self):
 *             if self.e:
 *                 return self._errmsg[:self.errmsg_len]             # <<<<<<<<<<<<<<
 *             else:
 *                 return None
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_2 = __Pyx_PyBytes_FromStringAndSize(__pyx_v_self->_errmsg + 0, __pyx_v_self->errmsg_len - 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1442, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_r = __pyx_t_2;
    __pyx_t_2 = 0;
    goto __pyx_L0;

    /* "btdht/krcp.pyx":1441
 *     property errmsg:
 *         def __get__(self):
 *             if self.e:             # <<<<<<<<<<<<<<
 *                 return self._errmsg[:self.errmsg_len]
 *             else:
 */
  }

  /* "btdht/krcp.pyx":1444
 *                 return self._errmsg[:self.errmsg_len]
 *             else:
 *                 return None             # <<<<<<<<<<<<<<
 *         def __set__(self, char* msg):
 *             l = len(msg)
 */
  /*else*/ {
    __Pyx_XDECREF(__pyx_r);
    __pyx_r = Py_None; __Pyx_INCREF(Py_None);
    goto __pyx_L0;
  }

  /* "btdht/krcp.pyx":1440
 *     #: The error message of the message if the message is and erro message
 *     property errmsg:
 *         def __get__(self):             # <<<<<<<<<<<<<<
 *             if self.e:
 *                 return self._errmsg[:self.errmsg_len]
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_AddTraceback("btdht.krcp.BMessage.errmsg.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "btdht/krcp.pyx":1445
 *             else:
 *                 return None
 *         def __set__(self, char* msg):             # <<<<<<<<<<<<<<
 *             l = len(msg)
 *             with nogil:
 */

/* Python wrapper */
static int __pyx_pw_5btdht_4krcp_8BMessage_6errmsg_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_arg_msg); /*proto*/
static int __pyx_pw_5btdht_4krcp_8BMessage_6errmsg_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_arg_msg) {
  char *__pyx_v_msg;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__set__ (wrapper)", 0);
  assert(__pyx_arg_msg); {
    __pyx_v_msg = __Pyx_PyObject_AsWritableString(__pyx_arg_msg); if (unlikely((!__pyx_v_msg) && PyErr_Occurred())) __PYX_ERR(0, 1445, __pyx_L3_error)
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L3_error:;
  __Pyx_AddTraceback("btdht.krcp.BMessage.errmsg.__set__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return -1;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_5btdht_4krcp_8BMessage_6errmsg_2__set__(((struct __pyx_obj_5btdht_4krcp_BMessage *)__pyx_v_self), ((char *)__pyx_v_msg));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static int __pyx_pf_5btdht_4krcp_8BMessage_6errmsg_2__set__(struct __pyx_obj_5btdht_4krcp_BMessage *__pyx_v_self, char *__pyx_v_msg) {
  Py_ssize_t __pyx_v_l;
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  size_t __pyx_t_1;
  __Pyx_RefNannySetupContext("__set__", 0);

  /* "btdht/krcp.pyx":1446
 *                 return None
 *         def __set__(self, char* msg):
 *             l = len(msg)             # <<<<<<<<<<<<<<
 *             with nogil:
 *                 self.set_errmsg(msg, l)
 */
  __pyx_t_1 = strlen(__pyx_v_msg); 
  __pyx_v_l = __pyx_t_1;

  /* "btdht/krcp.pyx":1447
 *         def __set__(self, char* msg):
 *             l = len(msg)
 *             with nogil:             # <<<<<<<<<<<<<<
 *                 self.set_errmsg(msg, l)
 * 
 */
  {
      #ifdef WITH_THREAD
      PyThreadState *_save;
      Py_UNBLOCK_THREADS
      __Pyx_FastGIL_Remember();
      #endif
      /*try:*/ {

        /* "btdht/krcp.pyx":1448
 *             l = len(msg)
 *             with nogil:
 *                 self.set_errmsg(msg, l)             # <<<<<<<<<<<<<<
 * 
 *     #: The couple (ip, port) source of the message
 */
        (void)(((struct __pyx_vtabstruct_5btdht_4krcp_BMessage *)__pyx_v_self->__pyx_vtab)->set_errmsg(__pyx_v_self, __pyx_v_msg, __pyx_v_l));
      }

      /* "btdht/krcp.pyx":1447
 *         def __set__(self, char* msg):
 *             l = len(msg)
 *             with nogil:             # <<<<<<<<<<<<<<
 *                 self.set_errmsg(msg, l)
 * 
 */
      /*finally:*/ {
        /*normal exit:*/{
          #ifdef WITH_THREAD
          __Pyx_FastGIL_Forget();
          Py_BLOCK_THREADS
          #endif
          goto __pyx_L5;
        }
        __pyx_L5:;
      }
  }

  /* "btdht/krcp.pyx":1445
 *             else:
 *                 return None
 *         def __set__(self, char* msg):             # <<<<<<<<<<<<<<
 *             l = len(msg)
 *             with nogil:
 */

  /* function exit code */
  __pyx_r = 0;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "btdht/krcp.pyx":1452
 *     #: The couple (ip, port) source of the message
 *     property addr:
 *         def __get__(self):             # <<<<<<<<<<<<<<
 *             if six.PY3:
 *                 if self.addr_addr_3 and self.addr_port > 0:
 */

/* Python wrapper */
static PyObject *__pyx_pw_5btdht_4krcp_8BMessage_4addr_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_5btdht_4krcp_8BMessage_4addr_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_5btdht_4krcp_8BMessage_4addr___get__(((struct __pyx_obj_5btdht_4krcp_BMessage *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5btdht_4krcp_8BMessage_4addr___get__(struct __pyx_obj_5btdht_4krcp_BMessage *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  int __pyx_t_3;
  int __pyx_t_4;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__get__", 0);

  /* "btdht/krcp.pyx":1453
 *     property addr:
 *         def __get__(self):
 *             if six.PY3:             # <<<<<<<<<<<<<<
 *                 if self.addr_addr_3 and self.addr_port > 0:
 *                     return (self.addr_addr_3, self.addr_port)
 */
  __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_six); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1453, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_PY3); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1453, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_3 < 0)) __PYX_ERR(0, 1453, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  if (__pyx_t_3) {

    /* "btdht/krcp.pyx":1454
 *         def __get__(self):
 *             if six.PY3:
 *                 if self.addr_addr_3 and self.addr_port > 0:             # <<<<<<<<<<<<<<
 *                     return (self.addr_addr_3, self.addr_port)
 *                 else:
 */
    __pyx_t_4 = (__pyx_v_self->addr_addr_3 != Py_None)&&(__Pyx_PyUnicode_IS_TRUE(__pyx_v_self->addr_addr_3) != 0);
    if (__pyx_t_4) {
    } else {
      __pyx_t_3 = __pyx_t_4;
      goto __pyx_L5_bool_binop_done;
    }
    __pyx_t_4 = ((__pyx_v_self->addr_port > 0) != 0);
    __pyx_t_3 = __pyx_t_4;
    __pyx_L5_bool_binop_done:;
    if (__pyx_t_3) {

      /* "btdht/krcp.pyx":1455
 *             if six.PY3:
 *                 if self.addr_addr_3 and self.addr_port > 0:
 *                     return (self.addr_addr_3, self.addr_port)             # <<<<<<<<<<<<<<
 *                 else:
 *                     return None
 */
      __Pyx_XDECREF(__pyx_r);
      __pyx_t_2 = __Pyx_PyInt_From_int(__pyx_v_self->addr_port); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1455, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1455, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_INCREF(__pyx_v_self->addr_addr_3);
      __Pyx_GIVEREF(__pyx_v_self->addr_addr_3);
      PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_self->addr_addr_3);
      __Pyx_GIVEREF(__pyx_t_2);
      PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_t_2);
      __pyx_t_2 = 0;
      __pyx_r = __pyx_t_1;
      __pyx_t_1 = 0;
      goto __pyx_L0;

      /* "btdht/krcp.pyx":1454
 *         def __get__(self):
 *             if six.PY3:
 *                 if self.addr_addr_3 and self.addr_port > 0:             # <<<<<<<<<<<<<<
 *                     return (self.addr_addr_3, self.addr_port)
 *                 else:
 */
    }

    /* "btdht/krcp.pyx":1457
 *                     return (self.addr_addr_3, self.addr_port)
 *                 else:
 *                     return None             # <<<<<<<<<<<<<<
 *             else:
 *                 if self.addr_addr_2 and self.addr_port > 0:
 */
    /*else*/ {
      __Pyx_XDECREF(__pyx_r);
      __pyx_r = Py_None; __Pyx_INCREF(Py_None);
      goto __pyx_L0;
    }

    /* "btdht/krcp.pyx":1453
 *     property addr:
 *         def __get__(self):
 *             if six.PY3:             # <<<<<<<<<<<<<<
 *                 if self.addr_addr_3 and self.addr_port > 0:
 *                     return (self.addr_addr_3, self.addr_port)
 */
  }

  /* "btdht/krcp.pyx":1459
 *                     return None
 *             else:
 *                 if self.addr_addr_2 and self.addr_port > 0:             # <<<<<<<<<<<<<<
 *                     return (self.addr_addr_2, self.addr_port)
 *                 else:
 */
  /*else*/ {
    __pyx_t_4 = (__pyx_v_self->addr_addr_2 != Py_None)&&(PyBytes_GET_SIZE(__pyx_v_self->addr_addr_2) != 0);
    if (__pyx_t_4) {
    } else {
      __pyx_t_3 = __pyx_t_4;
      goto __pyx_L8_bool_binop_done;
    }
    __pyx_t_4 = ((__pyx_v_self->addr_port > 0) != 0);
    __pyx_t_3 = __pyx_t_4;
    __pyx_L8_bool_binop_done:;
    if (__pyx_t_3) {

      /* "btdht/krcp.pyx":1460
 *             else:
 *                 if self.addr_addr_2 and self.addr_port > 0:
 *                     return (self.addr_addr_2, self.addr_port)             # <<<<<<<<<<<<<<
 *                 else:
 *                     return None
 */
      __Pyx_XDECREF(__pyx_r);
      __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_self->addr_port); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1460, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1460, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_INCREF(__pyx_v_self->addr_addr_2);
      __Pyx_GIVEREF(__pyx_v_self->addr_addr_2);
      PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_self->addr_addr_2);
      __Pyx_GIVEREF(__pyx_t_1);
      PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_t_1);
      __pyx_t_1 = 0;
      __pyx_r = __pyx_t_2;
      __pyx_t_2 = 0;
      goto __pyx_L0;

      /* "btdht/krcp.pyx":1459
 *                     return None
 *             else:
 *                 if self.addr_addr_2 and self.addr_port > 0:             # <<<<<<<<<<<<<<
 *                     return (self.addr_addr_2, self.addr_port)
 *                 else:
 */
    }

    /* "btdht/krcp.pyx":1462
 *                     return (self.addr_addr_2, self.addr_port)
 *                 else:
 *                     return None             # <<<<<<<<<<<<<<
 *         def __set__(self, addr):
 *             if addr is not None:
 */
    /*else*/ {
      __Pyx_XDECREF(__pyx_r);
      __pyx_r = Py_None; __Pyx_INCREF(Py_None);
      goto __pyx_L0;
    }
  }

  /* "btdht/krcp.pyx":1452
 *     #: The couple (ip, port) source of the message
 *     property addr:
 *         def __get__(self):             # <<<<<<<<<<<<<<
 *             if six.PY3:
 *                 if self.addr_addr_3 and self.addr_port > 0:
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_AddTraceback("btdht.krcp.BMessage.addr.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "btdht/krcp.pyx":1463
 *                 else:
 *                     return None
 *         def __set__(self, addr):             # <<<<<<<<<<<<<<
 *             if addr is not None:
 *                 if six.PY3:
 */

/* Python wrapper */
static int __pyx_pw_5btdht_4krcp_8BMessage_4addr_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_addr); /*proto*/
static int __pyx_pw_5btdht_4krcp_8BMessage_4addr_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_addr) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__set__ (wrapper)", 0);
  __pyx_r = __pyx_pf_5btdht_4krcp_8BMessage_4addr_2__set__(((struct __pyx_obj_5btdht_4krcp_BMessage *)__pyx_v_self), ((PyObject *)__pyx_v_addr));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static int __pyx_pf_5btdht_4krcp_8BMessage_4addr_2__set__(struct __pyx_obj_5btdht_4krcp_BMessage *__pyx_v_self, PyObject *__pyx_v_addr) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  int __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  int __pyx_t_5;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__set__", 0);

  /* "btdht/krcp.pyx":1464
 *                     return None
 *         def __set__(self, addr):
 *             if addr is not None:             # <<<<<<<<<<<<<<
 *                 if six.PY3:
 *                     self.addr_addr_3 = addr[0]
 */
  __pyx_t_1 = (__pyx_v_addr != Py_None);
  __pyx_t_2 = (__pyx_t_1 != 0);
  if (__pyx_t_2) {

    /* "btdht/krcp.pyx":1465
 *         def __set__(self, addr):
 *             if addr is not None:
 *                 if six.PY3:             # <<<<<<<<<<<<<<
 *                     self.addr_addr_3 = addr[0]
 *                 else:
 */
    __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_six); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1465, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_PY3); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1465, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(0, 1465, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    if (__pyx_t_2) {

      /* "btdht/krcp.pyx":1466
 *             if addr is not None:
 *                 if six.PY3:
 *                     self.addr_addr_3 = addr[0]             # <<<<<<<<<<<<<<
 *                 else:
 *                     self.addr_addr_2 = addr[0]
 */
      __pyx_t_4 = __Pyx_GetItemInt(__pyx_v_addr, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1466, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      if (!(likely(PyUnicode_CheckExact(__pyx_t_4))||((__pyx_t_4) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "unicode", Py_TYPE(__pyx_t_4)->tp_name), 0))) __PYX_ERR(0, 1466, __pyx_L1_error)
      __Pyx_GIVEREF(__pyx_t_4);
      __Pyx_GOTREF(__pyx_v_self->addr_addr_3);
      __Pyx_DECREF(__pyx_v_self->addr_addr_3);
      __pyx_v_self->addr_addr_3 = ((PyObject*)__pyx_t_4);
      __pyx_t_4 = 0;

      /* "btdht/krcp.pyx":1465
 *         def __set__(self, addr):
 *             if addr is not None:
 *                 if six.PY3:             # <<<<<<<<<<<<<<
 *                     self.addr_addr_3 = addr[0]
 *                 else:
 */
      goto __pyx_L4;
    }

    /* "btdht/krcp.pyx":1468
 *                     self.addr_addr_3 = addr[0]
 *                 else:
 *                     self.addr_addr_2 = addr[0]             # <<<<<<<<<<<<<<
 *                 self.addr_port = addr[1]
 *         def __del__(self):
 */
    /*else*/ {
      __pyx_t_4 = __Pyx_GetItemInt(__pyx_v_addr, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1468, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      if (!(likely(PyBytes_CheckExact(__pyx_t_4))||((__pyx_t_4) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "bytes", Py_TYPE(__pyx_t_4)->tp_name), 0))) __PYX_ERR(0, 1468, __pyx_L1_error)
      __Pyx_GIVEREF(__pyx_t_4);
      __Pyx_GOTREF(__pyx_v_self->addr_addr_2);
      __Pyx_DECREF(__pyx_v_self->addr_addr_2);
      __pyx_v_self->addr_addr_2 = ((PyObject*)__pyx_t_4);
      __pyx_t_4 = 0;
    }
    __pyx_L4:;

    /* "btdht/krcp.pyx":1469
 *                 else:
 *                     self.addr_addr_2 = addr[0]
 *                 self.addr_port = addr[1]             # <<<<<<<<<<<<<<
 *         def __del__(self):
 *             self.addr_addr = None
 */
    __pyx_t_4 = __Pyx_GetItemInt(__pyx_v_addr, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1469, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_5 = __Pyx_PyInt_As_int(__pyx_t_4); if (unlikely((__pyx_t_5 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 1469, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_v_self->addr_port = __pyx_t_5;

    /* "btdht/krcp.pyx":1464
 *                     return None
 *         def __set__(self, addr):
 *             if addr is not None:             # <<<<<<<<<<<<<<
 *                 if six.PY3:
 *                     self.addr_addr_3 = addr[0]
 */
  }

  /* "btdht/krcp.pyx":1463
 *                 else:
 *                     return None
 *         def __set__(self, addr):             # <<<<<<<<<<<<<<
 *             if addr is not None:
 *                 if six.PY3:
 */

  /* function exit code */
  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_AddTraceback("btdht.krcp.BMessage.addr.__set__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "btdht/krcp.pyx":1470
 *                     self.addr_addr_2 = addr[0]
 *                 self.addr_port = addr[1]
 *         def __del__(self):             # <<<<<<<<<<<<<<
 *             self.addr_addr = None
 *             self.addr_port = 0
 */

/* Python wrapper */
static int __pyx_pw_5btdht_4krcp_8BMessage_4addr_5__del__(PyObject *__pyx_v_self); /*proto*/
static int __pyx_pw_5btdht_4krcp_8BMessage_4addr_5__del__(PyObject *__pyx_v_self) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__del__ (wrapper)", 0);
  __pyx_r = __pyx_pf_5btdht_4krcp_8BMessage_4addr_4__del__(((struct __pyx_obj_5btdht_4krcp_BMessage *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static int __pyx_pf_5btdht_4krcp_8BMessage_4addr_4__del__(struct __pyx_obj_5btdht_4krcp_BMessage *__pyx_v_self) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__del__", 0);

  /* "btdht/krcp.pyx":1471
 *                 self.addr_port = addr[1]
 *         def __del__(self):
 *             self.addr_addr = None             # <<<<<<<<<<<<<<
 *             self.addr_port = 0
 * 
 */
  if (__Pyx_PyObject_SetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_addr_addr, Py_None) < 0) __PYX_ERR(0, 1471, __pyx_L1_error)

  /* "btdht/krcp.pyx":1472
 *         def __del__(self):
 *             self.addr_addr = None
 *             self.addr_port = 0             # <<<<<<<<<<<<<<
 * 
 *     #: The ``y` key of the message. Possible value are ``"q"`` for a query, `"r"` for a response
 */
  __pyx_v_self->addr_port = 0;

  /* "btdht/krcp.pyx":1470
 *                     self.addr_addr_2 = addr[0]
 *                 self.addr_port = addr[1]
 *         def __del__(self):             # <<<<<<<<<<<<<<
 *             self.addr_addr = None
 *             self.addr_port = 0
 */

  /* function exit code */
  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_AddTraceback("btdht.krcp.BMessage.addr.__del__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "btdht/krcp.pyx":1477
 *     #: and ``"e"`` for an error.
 *     property y:
 *         def __get__(self):             # <<<<<<<<<<<<<<
 *             if self.has_y:
 *                 return self._y[:self.y_len]
 */

/* Python wrapper */
static PyObject *__pyx_pw_5btdht_4krcp_8BMessage_1y_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_5btdht_4krcp_8BMessage_1y_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_5btdht_4krcp_8BMessage_1y___get__(((struct __pyx_obj_5btdht_4krcp_BMessage *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5btdht_4krcp_8BMessage_1y___get__(struct __pyx_obj_5btdht_4krcp_BMessage *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__get__", 0);

  /* "btdht/krcp.pyx":1478
 *     property y:
 *         def __get__(self):
 *             if self.has_y:             # <<<<<<<<<<<<<<
 *                 return self._y[:self.y_len]
 *             else:
 */
  __pyx_t_1 = (__pyx_v_self->has_y != 0);
  if (__pyx_t_1) {

    /* "btdht/krcp.pyx":1479
 *         def __get__(self):
 *             if self.has_y:
 *                 return self._y[:self.y_len]             # <<<<<<<<<<<<<<
 *             else:
 *                 return None
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_2 = __Pyx_PyBytes_FromStringAndSize(__pyx_v_self->_y + 0, __pyx_v_self->y_len - 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1479, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_r = __pyx_t_2;
    __pyx_t_2 = 0;
    goto __pyx_L0;

    /* "btdht/krcp.pyx":1478
 *     property y:
 *         def __get__(self):
 *             if self.has_y:             # <<<<<<<<<<<<<<
 *                 return self._y[:self.y_len]
 *             else:
 */
  }

  /* "btdht/krcp.pyx":1481
 *                 return self._y[:self.y_len]
 *             else:
 *                 return None             # <<<<<<<<<<<<<<
 *         def __set__(self,char* value):
 *             l = len(value)
 */
  /*else*/ {
    __Pyx_XDECREF(__pyx_r);
    __pyx_r = Py_None; __Pyx_INCREF(Py_None);
    goto __pyx_L0;
  }

  /* "btdht/krcp.pyx":1477
 *     #: and ``"e"`` for an error.
 *     property y:
 *         def __get__(self):             # <<<<<<<<<<<<<<
 *             if self.has_y:
 *                 return self._y[:self.y_len]
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_AddTraceback("btdht.krcp.BMessage.y.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "btdht/krcp.pyx":1482
 *             else:
 *                 return None
 *         def __set__(self,char* value):             # <<<<<<<<<<<<<<
 *             l = len(value)
 *             with nogil:
 */

/* Python wrapper */
static int __pyx_pw_5btdht_4krcp_8BMessage_1y_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_arg_value); /*proto*/
static int __pyx_pw_5btdht_4krcp_8BMessage_1y_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_arg_value) {
  char *__pyx_v_value;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__set__ (wrapper)", 0);
  assert(__pyx_arg_value); {
    __pyx_v_value = __Pyx_PyObject_AsWritableString(__pyx_arg_value); if (unlikely((!__pyx_v_value) && PyErr_Occurred())) __PYX_ERR(0, 1482, __pyx_L3_error)
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L3_error:;
  __Pyx_AddTraceback("btdht.krcp.BMessage.y.__set__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return -1;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_5btdht_4krcp_8BMessage_1y_2__set__(((struct __pyx_obj_5btdht_4krcp_BMessage *)__pyx_v_self), ((char *)__pyx_v_value));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static int __pyx_pf_5btdht_4krcp_8BMessage_1y_2__set__(struct __pyx_obj_5btdht_4krcp_BMessage *__pyx_v_self, char *__pyx_v_value) {
  Py_ssize_t __pyx_v_l;
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  size_t __pyx_t_1;
  __Pyx_RefNannySetupContext("__set__", 0);

  /* "btdht/krcp.pyx":1483
 *                 return None
 *         def __set__(self,char* value):
 *             l = len(value)             # <<<<<<<<<<<<<<
 *             with nogil:
 *                 self.set_y(value, l)
 */
  __pyx_t_1 = strlen(__pyx_v_value); 
  __pyx_v_l = __pyx_t_1;

  /* "btdht/krcp.pyx":1484
 *         def __set__(self,char* value):
 *             l = len(value)
 *             with nogil:             # <<<<<<<<<<<<<<
 *                 self.set_y(value, l)
 *         def __del__(self):
 */
  {
      #ifdef WITH_THREAD
      PyThreadState *_save;
      Py_UNBLOCK_THREADS
      __Pyx_FastGIL_Remember();
      #endif
      /*try:*/ {

        /* "btdht/krcp.pyx":1485
 *             l = len(value)
 *             with nogil:
 *                 self.set_y(value, l)             # <<<<<<<<<<<<<<
 *         def __del__(self):
 *             with nogil:
 */
        (void)(((struct __pyx_vtabstruct_5btdht_4krcp_BMessage *)__pyx_v_self->__pyx_vtab)->set_y(__pyx_v_self, __pyx_v_value, __pyx_v_l));
      }

      /* "btdht/krcp.pyx":1484
 *         def __set__(self,char* value):
 *             l = len(value)
 *             with nogil:             # <<<<<<<<<<<<<<
 *                 self.set_y(value, l)
 *         def __del__(self):
 */
      /*finally:*/ {
        /*normal exit:*/{
          #ifdef WITH_THREAD
          __Pyx_FastGIL_Forget();
          Py_BLOCK_THREADS
          #endif
          goto __pyx_L5;
        }
        __pyx_L5:;
      }
  }

  /* "btdht/krcp.pyx":1482
 *             else:
 *                 return None
 *         def __set__(self,char* value):             # <<<<<<<<<<<<<<
 *             l = len(value)
 *             with nogil:
 */

  /* function exit code */
  __pyx_r = 0;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "btdht/krcp.pyx":1486
 *             with nogil:
 *                 self.set_y(value, l)
 *         def __del__(self):             # <<<<<<<<<<<<<<
 *             with nogil:
 *                 self.del_y()
 */

/* Python wrapper */
static int __pyx_pw_5btdht_4krcp_8BMessage_1y_5__del__(PyObject *__pyx_v_self); /*proto*/
static int __pyx_pw_5btdht_4krcp_8BMessage_1y_5__del__(PyObject *__pyx_v_self) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__del__ (wrapper)", 0);
  __pyx_r = __pyx_pf_5btdht_4krcp_8BMessage_1y_4__del__(((struct __pyx_obj_5btdht_4krcp_BMessage *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static int __pyx_pf_5btdht_4krcp_8BMessage_1y_4__del__(struct __pyx_obj_5btdht_4krcp_BMessage *__pyx_v_self) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__del__", 0);

  /* "btdht/krcp.pyx":1487
 *                 self.set_y(value, l)
 *         def __del__(self):
 *             with nogil:             # <<<<<<<<<<<<<<
 *                 self.del_y()
 * 
 */
  {
      #ifdef WITH_THREAD
      PyThreadState *_save;
      Py_UNBLOCK_THREADS
      __Pyx_FastGIL_Remember();
      #endif
      /*try:*/ {

        /* "btdht/krcp.pyx":1488
 *         def __del__(self):
 *             with nogil:
 *                 self.del_y()             # <<<<<<<<<<<<<<
 * 
 *     #: The ``t`` key, a random string, transaction id used to match queries and responses together.
 */
        ((struct __pyx_vtabstruct_5btdht_4krcp_BMessage *)__pyx_v_self->__pyx_vtab)->del_y(__pyx_v_self);
      }

      /* "btdht/krcp.pyx":1487
 *                 self.set_y(value, l)
 *         def __del__(self):
 *             with nogil:             # <<<<<<<<<<<<<<
 *                 self.del_y()
 * 
 */
      /*finally:*/ {
        /*normal exit:*/{
          #ifdef WITH_THREAD
          __Pyx_FastGIL_Forget();
          Py_BLOCK_THREADS
          #endif
          goto __pyx_L5;
        }
        __pyx_L5:;
      }
  }

  /* "btdht/krcp.pyx":1486
 *             with nogil:
 *                 self.set_y(value, l)
 *         def __del__(self):             # <<<<<<<<<<<<<<
 *             with nogil:
 *                 self.del_y()
 */

  /* function exit code */
  __pyx_r = 0;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "btdht/krcp.pyx":1492
 *     #: The ``t`` key, a random string, transaction id used to match queries and responses together.
 *     property t:
 *         def __get__(self):             # <<<<<<<<<<<<<<
 *             if self.has_t:
 *                 return self._t[: self.t_len]
 */

/* Python wrapper */
static PyObject *__pyx_pw_5btdht_4krcp_8BMessage_1t_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_5btdht_4krcp_8BMessage_1t_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_5btdht_4krcp_8BMessage_1t___get__(((struct __pyx_obj_5btdht_4krcp_BMessage *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5btdht_4krcp_8BMessage_1t___get__(struct __pyx_obj_5btdht_4krcp_BMessage *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__get__", 0);

  /* "btdht/krcp.pyx":1493
 *     property t:
 *         def __get__(self):
 *             if self.has_t:             # <<<<<<<<<<<<<<
 *                 return self._t[: self.t_len]
 *             else:
 */
  __pyx_t_1 = (__pyx_v_self->has_t != 0);
  if (__pyx_t_1) {

    /* "btdht/krcp.pyx":1494
 *         def __get__(self):
 *             if self.has_t:
 *                 return self._t[: self.t_len]             # <<<<<<<<<<<<<<
 *             else:
 *                 return None
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_2 = __Pyx_PyBytes_FromStringAndSize(__pyx_v_self->_t + 0, __pyx_v_self->t_len - 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1494, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_r = __pyx_t_2;
    __pyx_t_2 = 0;
    goto __pyx_L0;

    /* "btdht/krcp.pyx":1493
 *     property t:
 *         def __get__(self):
 *             if self.has_t:             # <<<<<<<<<<<<<<
 *                 return self._t[: self.t_len]
 *             else:
 */
  }

  /* "btdht/krcp.pyx":1496
 *                 return self._t[: self.t_len]
 *             else:
 *                 return None             # <<<<<<<<<<<<<<
 *         def __set__(self,char* value):
 *             l = len(value)
 */
  /*else*/ {
    __Pyx_XDECREF(__pyx_r);
    __pyx_r = Py_None; __Pyx_INCREF(Py_None);
    goto __pyx_L0;
  }

  /* "btdht/krcp.pyx":1492
 *     #: The ``t`` key, a random string, transaction id used to match queries and responses together.
 *     property t:
 *         def __get__(self):             # <<<<<<<<<<<<<<
 *             if self.has_t:
 *                 return self._t[: self.t_len]
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_AddTraceback("btdht.krcp.BMessage.t.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "btdht/krcp.pyx":1497
 *             else:
 *                 return None
 *         def __set__(self,char* value):             # <<<<<<<<<<<<<<
 *             l = len(value)
 *             with nogil:
 */

/* Python wrapper */
static int __pyx_pw_5btdht_4krcp_8BMessage_1t_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_arg_value); /*proto*/
static int __pyx_pw_5btdht_4krcp_8BMessage_1t_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_arg_value) {
  char *__pyx_v_value;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__set__ (wrapper)", 0);
  assert(__pyx_arg_value); {
    __pyx_v_value = __Pyx_PyObject_AsWritableString(__pyx_arg_value); if (unlikely((!__pyx_v_value) && PyErr_Occurred())) __PYX_ERR(0, 1497, __pyx_L3_error)
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L3_error:;
  __Pyx_AddTraceback("btdht.krcp.BMessage.t.__set__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return -1;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_5btdht_4krcp_8BMessage_1t_2__set__(((struct __pyx_obj_5btdht_4krcp_BMessage *)__pyx_v_self), ((char *)__pyx_v_value));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static int __pyx_pf_5btdht_4krcp_8BMessage_1t_2__set__(struct __pyx_obj_5btdht_4krcp_BMessage *__pyx_v_self, char *__pyx_v_value) {
  Py_ssize_t __pyx_v_l;
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  size_t __pyx_t_1;
  __Pyx_RefNannySetupContext("__set__", 0);

  /* "btdht/krcp.pyx":1498
 *                 return None
 *         def __set__(self,char* value):
 *             l = len(value)             # <<<<<<<<<<<<<<
 *             with nogil:
 *                 self.set_t(value, l)
 */
  __pyx_t_1 = strlen(__pyx_v_value); 
  __pyx_v_l = __pyx_t_1;

  /* "btdht/krcp.pyx":1499
 *         def __set__(self,char* value):
 *             l = len(value)
 *             with nogil:             # <<<<<<<<<<<<<<
 *                 self.set_t(value, l)
 *         def __del__(self):
 */
  {
      #ifdef WITH_THREAD
      PyThreadState *_save;
      Py_UNBLOCK_THREADS
      __Pyx_FastGIL_Remember();
      #endif
      /*try:*/ {

        /* "btdht/krcp.pyx":1500
 *             l = len(value)
 *             with nogil:
 *                 self.set_t(value, l)             # <<<<<<<<<<<<<<
 *         def __del__(self):
 *             with nogil:
 */
        (void)(((struct __pyx_vtabstruct_5btdht_4krcp_BMessage *)__pyx_v_self->__pyx_vtab)->set_t(__pyx_v_self, __pyx_v_value, __pyx_v_l));
      }

      /* "btdht/krcp.pyx":1499
 *         def __set__(self,char* value):
 *             l = len(value)
 *             with nogil:             # <<<<<<<<<<<<<<
 *                 self.set_t(value, l)
 *         def __del__(self):
 */
      /*finally:*/ {
        /*normal exit:*/{
          #ifdef WITH_THREAD
          __Pyx_FastGIL_Forget();
          Py_BLOCK_THREADS
          #endif
          goto __pyx_L5;
        }
        __pyx_L5:;
      }
  }

  /* "btdht/krcp.pyx":1497
 *             else:
 *                 return None
 *         def __set__(self,char* value):             # <<<<<<<<<<<<<<
 *             l = len(value)
 *             with nogil:
 */

  /* function exit code */
  __pyx_r = 0;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "btdht/krcp.pyx":1501
 *             with nogil:
 *                 self.set_t(value, l)
 *         def __del__(self):             # <<<<<<<<<<<<<<
 *             with nogil:
 *                 self.del_t()
 */

/* Python wrapper */
static int __pyx_pw_5btdht_4krcp_8BMessage_1t_5__del__(PyObject *__pyx_v_self); /*proto*/
static int __pyx_pw_5btdht_4krcp_8BMessage_1t_5__del__(PyObject *__pyx_v_self) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__del__ (wrapper)", 0);
  __pyx_r = __pyx_pf_5btdht_4krcp_8BMessage_1t_4__del__(((struct __pyx_obj_5btdht_4krcp_BMessage *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static int __pyx_pf_5btdht_4krcp_8BMessage_1t_4__del__(struct __pyx_obj_5btdht_4krcp_BMessage *__pyx_v_self) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__del__", 0);

  /* "btdht/krcp.pyx":1502
 *                 self.set_t(value, l)
 *         def __del__(self):
 *             with nogil:             # <<<<<<<<<<<<<<
 *                 self.del_t()
 * 
 */
  {
      #ifdef WITH_THREAD
      PyThreadState *_save;
      Py_UNBLOCK_THREADS
      __Pyx_FastGIL_Remember();
      #endif
      /*try:*/ {

        /* "btdht/krcp.pyx":1503
 *         def __del__(self):
 *             with nogil:
 *                 self.del_t()             # <<<<<<<<<<<<<<
 * 
 *     #: The ``q`` key of the message, should only be define if the message is a query (:attr:`y` is
 */
        ((struct __pyx_vtabstruct_5btdht_4krcp_BMessage *)__pyx_v_self->__pyx_vtab)->del_t(__pyx_v_self);
      }

      /* "btdht/krcp.pyx":1502
 *                 self.set_t(value, l)
 *         def __del__(self):
 *             with nogil:             # <<<<<<<<<<<<<<
 *                 self.del_t()
 * 
 */
      /*finally:*/ {
        /*normal exit:*/{
          #ifdef WITH_THREAD
          __Pyx_FastGIL_Forget();
          Py_BLOCK_THREADS
          #endif
          goto __pyx_L5;
        }
        __pyx_L5:;
      }
  }

  /* "btdht/krcp.pyx":1501
 *             with nogil:
 *                 self.set_t(value, l)
 *         def __del__(self):             # <<<<<<<<<<<<<<
 *             with nogil:
 *                 self.del_t()
 */

  /* function exit code */
  __pyx_r = 0;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "btdht/krcp.pyx":1509
 *     #: ``b'ping'``, ``b'find_node'``, ``b'get_peers'``, ``b'announce_peer'``, ...
 *     property q:
 *         def __get__(self):             # <<<<<<<<<<<<<<
 *             if self.has_q:
 *                 return self._q[: self.q_len]
 */

/* Python wrapper */
static PyObject *__pyx_pw_5btdht_4krcp_8BMessage_1q_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_5btdht_4krcp_8BMessage_1q_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_5btdht_4krcp_8BMessage_1q___get__(((struct __pyx_obj_5btdht_4krcp_BMessage *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5btdht_4krcp_8BMessage_1q___get__(struct __pyx_obj_5btdht_4krcp_BMessage *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__get__", 0);

  /* "btdht/krcp.pyx":1510
 *     property q:
 *         def __get__(self):
 *             if self.has_q:             # <<<<<<<<<<<<<<
 *                 return self._q[: self.q_len]
 *             else:
 */
  __pyx_t_1 = (__pyx_v_self->has_q != 0);
  if (__pyx_t_1) {

    /* "btdht/krcp.pyx":1511
 *         def __get__(self):
 *             if self.has_q:
 *                 return self._q[: self.q_len]             # <<<<<<<<<<<<<<
 *             else:
 *                 return None
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_2 = __Pyx_PyBytes_FromStringAndSize(__pyx_v_self->_q + 0, __pyx_v_self->q_len - 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1511, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_r = __pyx_t_2;
    __pyx_t_2 = 0;
    goto __pyx_L0;

    /* "btdht/krcp.pyx":1510
 *     property q:
 *         def __get__(self):
 *             if self.has_q:             # <<<<<<<<<<<<<<
 *                 return self._q[: self.q_len]
 *             else:
 */
  }

  /* "btdht/krcp.pyx":1513
 *                 return self._q[: self.q_len]
 *             else:
 *                 return None             # <<<<<<<<<<<<<<
 *         def __set__(self,char* value):
 *             l = len(value)
 */
  /*else*/ {
    __Pyx_XDECREF(__pyx_r);
    __pyx_r = Py_None; __Pyx_INCREF(Py_None);
    goto __pyx_L0;
  }

  /* "btdht/krcp.pyx":1509
 *     #: ``b'ping'``, ``b'find_node'``, ``b'get_peers'``, ``b'announce_peer'``, ...
 *     property q:
 *         def __get__(self):             # <<<<<<<<<<<<<<
 *             if self.has_q:
 *                 return self._q[: self.q_len]
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_AddTraceback("btdht.krcp.BMessage.q.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "btdht/krcp.pyx":1514
 *             else:
 *                 return None
 *         def __set__(self,char* value):             # <<<<<<<<<<<<<<
 *             l = len(value)
 *             with nogil:
 */

/* Python wrapper */
static int __pyx_pw_5btdht_4krcp_8BMessage_1q_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_arg_value); /*proto*/
static int __pyx_pw_5btdht_4krcp_8BMessage_1q_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_arg_value) {
  char *__pyx_v_value;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__set__ (wrapper)", 0);
  assert(__pyx_arg_value); {
    __pyx_v_value = __Pyx_PyObject_AsWritableString(__pyx_arg_value); if (unlikely((!__pyx_v_value) && PyErr_Occurred())) __PYX_ERR(0, 1514, __pyx_L3_error)
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L3_error:;
  __Pyx_AddTraceback("btdht.krcp.BMessage.q.__set__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return -1;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_5btdht_4krcp_8BMessage_1q_2__set__(((struct __pyx_obj_5btdht_4krcp_BMessage *)__pyx_v_self), ((char *)__pyx_v_value));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static int __pyx_pf_5btdht_4krcp_8BMessage_1q_2__set__(struct __pyx_obj_5btdht_4krcp_BMessage *__pyx_v_self, char *__pyx_v_value) {
  Py_ssize_t __pyx_v_l;
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  size_t __pyx_t_1;
  __Pyx_RefNannySetupContext("__set__", 0);

  /* "btdht/krcp.pyx":1515
 *                 return None
 *         def __set__(self,char* value):
 *             l = len(value)             # <<<<<<<<<<<<<<
 *             with nogil:
 *                 self.set_q(value, l)
 */
  __pyx_t_1 = strlen(__pyx_v_value); 
  __pyx_v_l = __pyx_t_1;

  /* "btdht/krcp.pyx":1516
 *         def __set__(self,char* value):
 *             l = len(value)
 *             with nogil:             # <<<<<<<<<<<<<<
 *                 self.set_q(value, l)
 *         def __del__(self):
 */
  {
      #ifdef WITH_THREAD
      PyThreadState *_save;
      Py_UNBLOCK_THREADS
      __Pyx_FastGIL_Remember();
      #endif
      /*try:*/ {

        /* "btdht/krcp.pyx":1517
 *             l = len(value)
 *             with nogil:
 *                 self.set_q(value, l)             # <<<<<<<<<<<<<<
 *         def __del__(self):
 *             with nogil:
 */
        (void)(((struct __pyx_vtabstruct_5btdht_4krcp_BMessage *)__pyx_v_self->__pyx_vtab)->set_q(__pyx_v_self, __pyx_v_value, __pyx_v_l));
      }

      /* "btdht/krcp.pyx":1516
 *         def __set__(self,char* value):
 *             l = len(value)
 *             with nogil:             # <<<<<<<<<<<<<<
 *                 self.set_q(value, l)
 *         def __del__(self):
 */
      /*finally:*/ {
        /*normal exit:*/{
          #ifdef WITH_THREAD
          __Pyx_FastGIL_Forget();
          Py_BLOCK_THREADS
          #endif
          goto __pyx_L5;
        }
        __pyx_L5:;
      }
  }

  /* "btdht/krcp.pyx":1514
 *             else:
 *                 return None
 *         def __set__(self,char* value):             # <<<<<<<<<<<<<<
 *             l = len(value)
 *             with nogil:
 */

  /* function exit code */
  __pyx_r = 0;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "btdht/krcp.pyx":1518
 *             with nogil:
 *                 self.set_q(value, l)
 *         def __del__(self):             # <<<<<<<<<<<<<<
 *             with nogil:
 *                 self.del_q()
 */

/* Python wrapper */
static int __pyx_pw_5btdht_4krcp_8BMessage_1q_5__del__(PyObject *__pyx_v_self); /*proto*/
static int __pyx_pw_5btdht_4krcp_8BMessage_1q_5__del__(PyObject *__pyx_v_self) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__del__ (wrapper)", 0);
  __pyx_r = __pyx_pf_5btdht_4krcp_8BMessage_1q_4__del__(((struct __pyx_obj_5btdht_4krcp_BMessage *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static int __pyx_pf_5btdht_4krcp_8BMessage_1q_4__del__(struct __pyx_obj_5btdht_4krcp_BMessage *__pyx_v_self) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__del__", 0);

  /* "btdht/krcp.pyx":1519
 *                 self.set_q(value, l)
 *         def __del__(self):
 *             with nogil:             # <<<<<<<<<<<<<<
 *                 self.del_q()
 * 
 */
  {
      #ifdef WITH_THREAD
      PyThreadState *_save;
      Py_UNBLOCK_THREADS
      __Pyx_FastGIL_Remember();
      #endif
      /*try:*/ {

        /* "btdht/krcp.pyx":1520
 *         def __del__(self):
 *             with nogil:
 *                 self.del_q()             # <<<<<<<<<<<<<<
 * 
 *     #: The ``v`` key of the message. This attribute is not describe in the BEP5 that describe the
 */
        ((struct __pyx_vtabstruct_5btdht_4krcp_BMessage *)__pyx_v_self->__pyx_vtab)->del_q(__pyx_v_self);
      }

      /* "btdht/krcp.pyx":1519
 *                 self.set_q(value, l)
 *         def __del__(self):
 *             with nogil:             # <<<<<<<<<<<<<<
 *                 self.del_q()
 * 
 */
      /*finally:*/ {
        /*normal exit:*/{
          #ifdef WITH_THREAD
          __Pyx_FastGIL_Forget();
          Py_BLOCK_THREADS
          #endif
          goto __pyx_L5;
        }
        __pyx_L5:;
      }
  }

  /* "btdht/krcp.pyx":1518
 *             with nogil:
 *                 self.set_q(value, l)
 *         def __del__(self):             # <<<<<<<<<<<<<<
 *             with nogil:
 *                 self.del_q()
 */

  /* function exit code */
  __pyx_r = 0;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "btdht/krcp.pyx":1526
 *     #: the name and version of the client.
 *     property v:
 *         def __get__(self):             # <<<<<<<<<<<<<<
 *             if self.has_v:
 *                 return self._v[: self.v_len]
 */

/* Python wrapper */
static PyObject *__pyx_pw_5btdht_4krcp_8BMessage_1v_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_5btdht_4krcp_8BMessage_1v_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_5btdht_4krcp_8BMessage_1v___get__(((struct __pyx_obj_5btdht_4krcp_BMessage *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5btdht_4krcp_8BMessage_1v___get__(struct __pyx_obj_5btdht_4krcp_BMessage *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__get__", 0);

  /* "btdht/krcp.pyx":1527
 *     property v:
 *         def __get__(self):
 *             if self.has_v:             # <<<<<<<<<<<<<<
 *                 return self._v[: self.v_len]
 *             else:
 */
  __pyx_t_1 = (__pyx_v_self->has_v != 0);
  if (__pyx_t_1) {

    /* "btdht/krcp.pyx":1528
 *         def __get__(self):
 *             if self.has_v:
 *                 return self._v[: self.v_len]             # <<<<<<<<<<<<<<
 *             else:
 *                 return None
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_2 = __Pyx_PyBytes_FromStringAndSize(__pyx_v_self->_v + 0, __pyx_v_self->v_len - 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1528, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_r = __pyx_t_2;
    __pyx_t_2 = 0;
    goto __pyx_L0;

    /* "btdht/krcp.pyx":1527
 *     property v:
 *         def __get__(self):
 *             if self.has_v:             # <<<<<<<<<<<<<<
 *                 return self._v[: self.v_len]
 *             else:
 */
  }

  /* "btdht/krcp.pyx":1530
 *                 return self._v[: self.v_len]
 *             else:
 *                 return None             # <<<<<<<<<<<<<<
 *         def __set__(self,char* value):
 *             l = len(value)
 */
  /*else*/ {
    __Pyx_XDECREF(__pyx_r);
    __pyx_r = Py_None; __Pyx_INCREF(Py_None);
    goto __pyx_L0;
  }

  /* "btdht/krcp.pyx":1526
 *     #: the name and version of the client.
 *     property v:
 *         def __get__(self):             # <<<<<<<<<<<<<<
 *             if self.has_v:
 *                 return self._v[: self.v_len]
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_AddTraceback("btdht.krcp.BMessage.v.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "btdht/krcp.pyx":1531
 *             else:
 *                 return None
 *         def __set__(self,char* value):             # <<<<<<<<<<<<<<
 *             l = len(value)
 *             with nogil:
 */

/* Python wrapper */
static int __pyx_pw_5btdht_4krcp_8BMessage_1v_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_arg_value); /*proto*/
static int __pyx_pw_5btdht_4krcp_8BMessage_1v_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_arg_value) {
  char *__pyx_v_value;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__set__ (wrapper)", 0);
  assert(__pyx_arg_value); {
    __pyx_v_value = __Pyx_PyObject_AsWritableString(__pyx_arg_value); if (unlikely((!__pyx_v_value) && PyErr_Occurred())) __PYX_ERR(0, 1531, __pyx_L3_error)
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L3_error:;
  __Pyx_AddTraceback("btdht.krcp.BMessage.v.__set__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return -1;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_5btdht_4krcp_8BMessage_1v_2__set__(((struct __pyx_obj_5btdht_4krcp_BMessage *)__pyx_v_self), ((char *)__pyx_v_value));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static int __pyx_pf_5btdht_4krcp_8BMessage_1v_2__set__(struct __pyx_obj_5btdht_4krcp_BMessage *__pyx_v_self, char *__pyx_v_value) {
  Py_ssize_t __pyx_v_l;
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  size_t __pyx_t_1;
  __Pyx_RefNannySetupContext("__set__", 0);

  /* "btdht/krcp.pyx":1532
 *                 return None
 *         def __set__(self,char* value):
 *             l = len(value)             # <<<<<<<<<<<<<<
 *             with nogil:
 *                 self.set_v(value, l)
 */
  __pyx_t_1 = strlen(__pyx_v_value); 
  __pyx_v_l = __pyx_t_1;

  /* "btdht/krcp.pyx":1533
 *         def __set__(self,char* value):
 *             l = len(value)
 *             with nogil:             # <<<<<<<<<<<<<<
 *                 self.set_v(value, l)
 * 
 */
  {
      #ifdef WITH_THREAD
      PyThreadState *_save;
      Py_UNBLOCK_THREADS
      __Pyx_FastGIL_Remember();
      #endif
      /*try:*/ {

        /* "btdht/krcp.pyx":1534
 *             l = len(value)
 *             with nogil:
 *                 self.set_v(value, l)             # <<<<<<<<<<<<<<
 * 
 *         def __del__(self):
 */
        (void)(((struct __pyx_vtabstruct_5btdht_4krcp_BMessage *)__pyx_v_self->__pyx_vtab)->set_v(__pyx_v_self, __pyx_v_value, __pyx_v_l));
      }

      /* "btdht/krcp.pyx":1533
 *         def __set__(self,char* value):
 *             l = len(value)
 *             with nogil:             # <<<<<<<<<<<<<<
 *                 self.set_v(value, l)
 * 
 */
      /*finally:*/ {
        /*normal exit:*/{
          #ifdef WITH_THREAD
          __Pyx_FastGIL_Forget();
          Py_BLOCK_THREADS
          #endif
          goto __pyx_L5;
        }
        __pyx_L5:;
      }
  }

  /* "btdht/krcp.pyx":1531
 *             else:
 *                 return None
 *         def __set__(self,char* value):             # <<<<<<<<<<<<<<
 *             l = len(value)
 *             with nogil:
 */

  /* function exit code */
  __pyx_r = 0;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "btdht/krcp.pyx":1536
 *                 self.set_v(value, l)
 * 
 *         def __del__(self):             # <<<<<<<<<<<<<<
 *             with nogil:
 *                 self.del_v()
 */

/* Python wrapper */
static int __pyx_pw_5btdht_4krcp_8BMessage_1v_5__del__(PyObject *__pyx_v_self); /*proto*/
static int __pyx_pw_5btdht_4krcp_8BMessage_1v_5__del__(PyObject *__pyx_v_self) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__del__ (wrapper)", 0);
  __pyx_r = __pyx_pf_5btdht_4krcp_8BMessage_1v_4__del__(((struct __pyx_obj_5btdht_4krcp_BMessage *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static int __pyx_pf_5btdht_4krcp_8BMessage_1v_4__del__(struct __pyx_obj_5btdht_4krcp_BMessage *__pyx_v_self) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__del__", 0);

  /* "btdht/krcp.pyx":1537
 * 
 *         def __del__(self):
 *             with nogil:             # <<<<<<<<<<<<<<
 *                 self.del_v()
 * 
 */
  {
      #ifdef WITH_THREAD
      PyThreadState *_save;
      Py_UNBLOCK_THREADS
      __Pyx_FastGIL_Remember();
      #endif
      /*try:*/ {

        /* "btdht/krcp.pyx":1538
 *         def __del__(self):
 *             with nogil:
 *                 self.del_v()             # <<<<<<<<<<<<<<
 * 
 *     def __getitem__(self, char* key):
 */
        ((struct __pyx_vtabstruct_5btdht_4krcp_BMessage *)__pyx_v_self->__pyx_vtab)->del_v(__pyx_v_self);
      }

      /* "btdht/krcp.pyx":1537
 * 
 *         def __del__(self):
 *             with nogil:             # <<<<<<<<<<<<<<
 *                 self.del_v()
 * 
 */
      /*finally:*/ {
        /*normal exit:*/{
          #ifdef WITH_THREAD
          __Pyx_FastGIL_Forget();
          Py_BLOCK_THREADS
          #endif
          goto __pyx_L5;
        }
        __pyx_L5:;
      }
  }

  /* "btdht/krcp.pyx":1536
 *                 self.set_v(value, l)
 * 
 *         def __del__(self):             # <<<<<<<<<<<<<<
 *             with nogil:
 *                 self.del_v()
 */

  /* function exit code */
  __pyx_r = 0;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "btdht/krcp.pyx":1540
 *                 self.del_v()
 * 
 *     def __getitem__(self, char* key):             # <<<<<<<<<<<<<<
 *         """
 *             Allow to fetch infos from the secondary dictionnary::
 */

/* Python wrapper */
static PyObject *__pyx_pw_5btdht_4krcp_8BMessage_9__getitem__(PyObject *__pyx_v_self, PyObject *__pyx_arg_key); /*proto*/
static char __pyx_doc_5btdht_4krcp_8BMessage_8__getitem__[] = "\n            Allow to fetch infos from the secondary dictionnary::\n\n                self[b\"id\"] -> b\"...\"\n\n            :param bytes key: The name of an attribute of the secondary dictionnary to retreive.\n            :return: The value store for ``key`` if found\n            :raises KeyError: if ``key`` is not found\n\n            Notes:\n                Possible keys are:\n                  * id\n                  * target\n                  * info_hash\n                  * token\n                  * nodes\n                  * implied_port\n                  * port\n                  * values\n        ";
#if CYTHON_UPDATE_DESCRIPTOR_DOC
struct wrapperbase __pyx_wrapperbase_5btdht_4krcp_8BMessage_8__getitem__;
#endif
static PyObject *__pyx_pw_5btdht_4krcp_8BMessage_9__getitem__(PyObject *__pyx_v_self, PyObject *__pyx_arg_key) {
  char *__pyx_v_key;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__getitem__ (wrapper)", 0);
  assert(__pyx_arg_key); {
    __pyx_v_key = __Pyx_PyObject_AsWritableString(__pyx_arg_key); if (unlikely((!__pyx_v_key) && PyErr_Occurred())) __PYX_ERR(0, 1540, __pyx_L3_error)
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L3_error:;
  __Pyx_AddTraceback("btdht.krcp.BMessage.__getitem__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_5btdht_4krcp_8BMessage_8__getitem__(((struct __pyx_obj_5btdht_4krcp_BMessage *)__pyx_v_self), ((char *)__pyx_v_key));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5btdht_4krcp_8BMessage_8__getitem__(struct __pyx_obj_5btdht_4krcp_BMessage *__pyx_v_self, char *__pyx_v_key) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  int __pyx_t_3;
  PyObject *__pyx_t_4 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__getitem__", 0);

  /* "btdht/krcp.pyx":1561
 *                   * values
 *         """
 *         if key == b"id" and self.has_id:             # <<<<<<<<<<<<<<
 *             return self.id[:20]
 *         elif key == b"target" and self.has_target:
 */
  __pyx_t_2 = __Pyx_PyBytes_FromString(__pyx_v_key); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1561, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = (__Pyx_PyBytes_Equals(__pyx_t_2, __pyx_n_b_id, Py_EQ)); if (unlikely(__pyx_t_3 < 0)) __PYX_ERR(0, 1561, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  if (__pyx_t_3) {
  } else {
    __pyx_t_1 = __pyx_t_3;
    goto __pyx_L4_bool_binop_done;
  }
  __pyx_t_3 = (__pyx_v_self->has_id != 0);
  __pyx_t_1 = __pyx_t_3;
  __pyx_L4_bool_binop_done:;
  if (__pyx_t_1) {

    /* "btdht/krcp.pyx":1562
 *         """
 *         if key == b"id" and self.has_id:
 *             return self.id[:20]             # <<<<<<<<<<<<<<
 *         elif key == b"target" and self.has_target:
 *             return self.target[:20]
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_2 = __Pyx_PyBytes_FromStringAndSize(__pyx_v_self->id + 0, 20 - 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1562, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_r = __pyx_t_2;
    __pyx_t_2 = 0;
    goto __pyx_L0;

    /* "btdht/krcp.pyx":1561
 *                   * values
 *         """
 *         if key == b"id" and self.has_id:             # <<<<<<<<<<<<<<
 *             return self.id[:20]
 *         elif key == b"target" and self.has_target:
 */
  }

  /* "btdht/krcp.pyx":1563
 *         if key == b"id" and self.has_id:
 *             return self.id[:20]
 *         elif key == b"target" and self.has_target:             # <<<<<<<<<<<<<<
 *             return self.target[:20]
 *         elif key == b"info_hash" and self.has_info_hash:
 */
  __pyx_t_2 = __Pyx_PyBytes_FromString(__pyx_v_key); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1563, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = (__Pyx_PyBytes_Equals(__pyx_t_2, __pyx_n_b_target, Py_EQ)); if (unlikely(__pyx_t_3 < 0)) __PYX_ERR(0, 1563, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  if (__pyx_t_3) {
  } else {
    __pyx_t_1 = __pyx_t_3;
    goto __pyx_L6_bool_binop_done;
  }
  __pyx_t_3 = (__pyx_v_self->has_target != 0);
  __pyx_t_1 = __pyx_t_3;
  __pyx_L6_bool_binop_done:;
  if (__pyx_t_1) {

    /* "btdht/krcp.pyx":1564
 *             return self.id[:20]
 *         elif key == b"target" and self.has_target:
 *             return self.target[:20]             # <<<<<<<<<<<<<<
 *         elif key == b"info_hash" and self.has_info_hash:
 *             return self.info_hash[:20]
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_2 = __Pyx_PyBytes_FromStringAndSize(__pyx_v_self->target + 0, 20 - 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1564, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_r = __pyx_t_2;
    __pyx_t_2 = 0;
    goto __pyx_L0;

    /* "btdht/krcp.pyx":1563
 *         if key == b"id" and self.has_id:
 *             return self.id[:20]
 *         elif key == b"target" and self.has_target:             # <<<<<<<<<<<<<<
 *             return self.target[:20]
 *         elif key == b"info_hash" and self.has_info_hash:
 */
  }

  /* "btdht/krcp.pyx":1565
 *         elif key == b"target" and self.has_target:
 *             return self.target[:20]
 *         elif key == b"info_hash" and self.has_info_hash:             # <<<<<<<<<<<<<<
 *             return self.info_hash[:20]
 *         elif key == b"token" and self.has_token:
 */
  __pyx_t_2 = __Pyx_PyBytes_FromString(__pyx_v_key); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1565, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = (__Pyx_PyBytes_Equals(__pyx_t_2, __pyx_n_b_info_hash, Py_EQ)); if (unlikely(__pyx_t_3 < 0)) __PYX_ERR(0, 1565, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  if (__pyx_t_3) {
  } else {
    __pyx_t_1 = __pyx_t_3;
    goto __pyx_L8_bool_binop_done;
  }
  __pyx_t_3 = (__pyx_v_self->has_info_hash != 0);
  __pyx_t_1 = __pyx_t_3;
  __pyx_L8_bool_binop_done:;
  if (__pyx_t_1) {

    /* "btdht/krcp.pyx":1566
 *             return self.target[:20]
 *         elif key == b"info_hash" and self.has_info_hash:
 *             return self.info_hash[:20]             # <<<<<<<<<<<<<<
 *         elif key == b"token" and self.has_token:
 *             return self.token[:self.token_len]
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_2 = __Pyx_PyBytes_FromStringAndSize(__pyx_v_self->info_hash + 0, 20 - 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1566, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_r = __pyx_t_2;
    __pyx_t_2 = 0;
    goto __pyx_L0;

    /* "btdht/krcp.pyx":1565
 *         elif key == b"target" and self.has_target:
 *             return self.target[:20]
 *         elif key == b"info_hash" and self.has_info_hash:             # <<<<<<<<<<<<<<
 *             return self.info_hash[:20]
 *         elif key == b"token" and self.has_token:
 */
  }

  /* "btdht/krcp.pyx":1567
 *         elif key == b"info_hash" and self.has_info_hash:
 *             return self.info_hash[:20]
 *         elif key == b"token" and self.has_token:             # <<<<<<<<<<<<<<
 *             return self.token[:self.token_len]
 *         elif key == b"nodes" and self.has_nodes:
 */
  __pyx_t_2 = __Pyx_PyBytes_FromString(__pyx_v_key); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1567, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = (__Pyx_PyBytes_Equals(__pyx_t_2, __pyx_n_b_token, Py_EQ)); if (unlikely(__pyx_t_3 < 0)) __PYX_ERR(0, 1567, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  if (__pyx_t_3) {
  } else {
    __pyx_t_1 = __pyx_t_3;
    goto __pyx_L10_bool_binop_done;
  }
  __pyx_t_3 = (__pyx_v_self->has_token != 0);
  __pyx_t_1 = __pyx_t_3;
  __pyx_L10_bool_binop_done:;
  if (__pyx_t_1) {

    /* "btdht/krcp.pyx":1568
 *             return self.info_hash[:20]
 *         elif key == b"token" and self.has_token:
 *             return self.token[:self.token_len]             # <<<<<<<<<<<<<<
 *         elif key == b"nodes" and self.has_nodes:
 *             return self.nodes[:self.nodes_len]
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_2 = __Pyx_PyBytes_FromStringAndSize(__pyx_v_self->token + 0, __pyx_v_self->token_len - 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1568, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_r = __pyx_t_2;
    __pyx_t_2 = 0;
    goto __pyx_L0;

    /* "btdht/krcp.pyx":1567
 *         elif key == b"info_hash" and self.has_info_hash:
 *             return self.info_hash[:20]
 *         elif key == b"token" and self.has_token:             # <<<<<<<<<<<<<<
 *             return self.token[:self.token_len]
 *         elif key == b"nodes" and self.has_nodes:
 */
  }

  /* "btdht/krcp.pyx":1569
 *         elif key == b"token" and self.has_token:
 *             return self.token[:self.token_len]
 *         elif key == b"nodes" and self.has_nodes:             # <<<<<<<<<<<<<<
 *             return self.nodes[:self.nodes_len]
 *         elif key == b"implied_port" and self.has_implied_port:
 */
  __pyx_t_2 = __Pyx_PyBytes_FromString(__pyx_v_key); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1569, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = (__Pyx_PyBytes_Equals(__pyx_t_2, __pyx_n_b_nodes, Py_EQ)); if (unlikely(__pyx_t_3 < 0)) __PYX_ERR(0, 1569, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  if (__pyx_t_3) {
  } else {
    __pyx_t_1 = __pyx_t_3;
    goto __pyx_L12_bool_binop_done;
  }
  __pyx_t_3 = (__pyx_v_self->has_nodes != 0);
  __pyx_t_1 = __pyx_t_3;
  __pyx_L12_bool_binop_done:;
  if (__pyx_t_1) {

    /* "btdht/krcp.pyx":1570
 *             return self.token[:self.token_len]
 *         elif key == b"nodes" and self.has_nodes:
 *             return self.nodes[:self.nodes_len]             # <<<<<<<<<<<<<<
 *         elif key == b"implied_port" and self.has_implied_port:
 *             return self.implied_port
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_2 = __Pyx_PyBytes_FromStringAndSize(__pyx_v_self->nodes + 0, __pyx_v_self->nodes_len - 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1570, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_r = __pyx_t_2;
    __pyx_t_2 = 0;
    goto __pyx_L0;

    /* "btdht/krcp.pyx":1569
 *         elif key == b"token" and self.has_token:
 *             return self.token[:self.token_len]
 *         elif key == b"nodes" and self.has_nodes:             # <<<<<<<<<<<<<<
 *             return self.nodes[:self.nodes_len]
 *         elif key == b"implied_port" and self.has_implied_port:
 */
  }

  /* "btdht/krcp.pyx":1571
 *         elif key == b"nodes" and self.has_nodes:
 *             return self.nodes[:self.nodes_len]
 *         elif key == b"implied_port" and self.has_implied_port:             # <<<<<<<<<<<<<<
 *             return self.implied_port
 *         elif key == b"port" and self.has_port:
 */
  __pyx_t_2 = __Pyx_PyBytes_FromString(__pyx_v_key); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1571, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = (__Pyx_PyBytes_Equals(__pyx_t_2, __pyx_n_b_implied_port, Py_EQ)); if (unlikely(__pyx_t_3 < 0)) __PYX_ERR(0, 1571, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  if (__pyx_t_3) {
  } else {
    __pyx_t_1 = __pyx_t_3;
    goto __pyx_L14_bool_binop_done;
  }
  __pyx_t_3 = (__pyx_v_self->has_implied_port != 0);
  __pyx_t_1 = __pyx_t_3;
  __pyx_L14_bool_binop_done:;
  if (__pyx_t_1) {

    /* "btdht/krcp.pyx":1572
 *             return self.nodes[:self.nodes_len]
 *         elif key == b"implied_port" and self.has_implied_port:
 *             return self.implied_port             # <<<<<<<<<<<<<<
 *         elif key == b"port" and self.has_port:
 *             return self.port
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_2 = __Pyx_PyInt_From_int(__pyx_v_self->implied_port); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1572, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_r = __pyx_t_2;
    __pyx_t_2 = 0;
    goto __pyx_L0;

    /* "btdht/krcp.pyx":1571
 *         elif key == b"nodes" and self.has_nodes:
 *             return self.nodes[:self.nodes_len]
 *         elif key == b"implied_port" and self.has_implied_port:             # <<<<<<<<<<<<<<
 *             return self.implied_port
 *         elif key == b"port" and self.has_port:
 */
  }

  /* "btdht/krcp.pyx":1573
 *         elif key == b"implied_port" and self.has_implied_port:
 *             return self.implied_port
 *         elif key == b"port" and self.has_port:             # <<<<<<<<<<<<<<
 *             return self.port
 *         elif key == b"values" and self.has_values:
 */
  __pyx_t_2 = __Pyx_PyBytes_FromString(__pyx_v_key); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1573, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = (__Pyx_PyBytes_Equals(__pyx_t_2, __pyx_n_b_port, Py_EQ)); if (unlikely(__pyx_t_3 < 0)) __PYX_ERR(0, 1573, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  if (__pyx_t_3) {
  } else {
    __pyx_t_1 = __pyx_t_3;
    goto __pyx_L16_bool_binop_done;
  }
  __pyx_t_3 = (__pyx_v_self->has_port != 0);
  __pyx_t_1 = __pyx_t_3;
  __pyx_L16_bool_binop_done:;
  if (__pyx_t_1) {

    /* "btdht/krcp.pyx":1574
 *             return self.implied_port
 *         elif key == b"port" and self.has_port:
 *             return self.port             # <<<<<<<<<<<<<<
 *         elif key == b"values" and self.has_values:
 *             return varray_to_list(self.values, self.values_nb)
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_2 = __Pyx_PyInt_From_int(__pyx_v_self->port); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1574, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_r = __pyx_t_2;
    __pyx_t_2 = 0;
    goto __pyx_L0;

    /* "btdht/krcp.pyx":1573
 *         elif key == b"implied_port" and self.has_implied_port:
 *             return self.implied_port
 *         elif key == b"port" and self.has_port:             # <<<<<<<<<<<<<<
 *             return self.port
 *         elif key == b"values" and self.has_values:
 */
  }

  /* "btdht/krcp.pyx":1575
 *         elif key == b"port" and self.has_port:
 *             return self.port
 *         elif key == b"values" and self.has_values:             # <<<<<<<<<<<<<<
 *             return varray_to_list(self.values, self.values_nb)
 *         else:
 */
  __pyx_t_2 = __Pyx_PyBytes_FromString(__pyx_v_key); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1575, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = (__Pyx_PyBytes_Equals(__pyx_t_2, __pyx_n_b_values, Py_EQ)); if (unlikely(__pyx_t_3 < 0)) __PYX_ERR(0, 1575, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  if (__pyx_t_3) {
  } else {
    __pyx_t_1 = __pyx_t_3;
    goto __pyx_L18_bool_binop_done;
  }
  __pyx_t_3 = (__pyx_v_self->has_values != 0);
  __pyx_t_1 = __pyx_t_3;
  __pyx_L18_bool_binop_done:;
  if (likely(__pyx_t_1)) {

    /* "btdht/krcp.pyx":1576
 *             return self.port
 *         elif key == b"values" and self.has_values:
 *             return varray_to_list(self.values, self.values_nb)             # <<<<<<<<<<<<<<
 *         else:
 *             raise KeyError(key)
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_2 = __Pyx_PyInt_From_int(__pyx_v_self->values_nb); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1576, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_4 = __pyx_f_5btdht_4krcp_varray_to_list(__pyx_v_self->values, __pyx_t_2); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1576, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_r = __pyx_t_4;
    __pyx_t_4 = 0;
    goto __pyx_L0;

    /* "btdht/krcp.pyx":1575
 *         elif key == b"port" and self.has_port:
 *             return self.port
 *         elif key == b"values" and self.has_values:             # <<<<<<<<<<<<<<
 *             return varray_to_list(self.values, self.values_nb)
 *         else:
 */
  }

  /* "btdht/krcp.pyx":1578
 *             return varray_to_list(self.values, self.values_nb)
 *         else:
 *             raise KeyError(key)             # <<<<<<<<<<<<<<
 * 
 *     def __delitem__(self, char* key):
 */
  /*else*/ {
    __pyx_t_4 = __Pyx_PyBytes_FromString(__pyx_v_key); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1578, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_builtin_KeyError, __pyx_t_4); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1578, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_Raise(__pyx_t_2, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __PYX_ERR(0, 1578, __pyx_L1_error)
  }

  /* "btdht/krcp.pyx":1540
 *                 self.del_v()
 * 
 *     def __getitem__(self, char* key):             # <<<<<<<<<<<<<<
 *         """
 *             Allow to fetch infos from the secondary dictionnary::
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_AddTraceback("btdht.krcp.BMessage.__getitem__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "btdht/krcp.pyx":1580
 *             raise KeyError(key)
 * 
 *     def __delitem__(self, char* key):             # <<<<<<<<<<<<<<
 *         """
 *             Allow to unset attributes from the secondary dictionnary::
 */

/* Python wrapper */
static int __pyx_pw_5btdht_4krcp_8BMessage_11__delitem__(PyObject *__pyx_v_self, PyObject *__pyx_arg_key); /*proto*/
static char __pyx_doc_5btdht_4krcp_8BMessage_10__delitem__[] = "\n            Allow to unset attributes from the secondary dictionnary::\n\n                del self[b'id']\n\n            :param :param bytes key: The name of an attribute of the secondary dictionnary to unset\n            :return: ``True`` if ``key`` is found and successfully unset\n            :raise KeyError: if ``key`` is not found\n        ";
#if CYTHON_UPDATE_DESCRIPTOR_DOC
struct wrapperbase __pyx_wrapperbase_5btdht_4krcp_8BMessage_10__delitem__;
#endif
static int __pyx_pw_5btdht_4krcp_8BMessage_11__delitem__(PyObject *__pyx_v_self, PyObject *__pyx_arg_key) {
  char *__pyx_v_key;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__delitem__ (wrapper)", 0);
  assert(__pyx_arg_key); {
    __pyx_v_key = __Pyx_PyObject_AsWritableString(__pyx_arg_key); if (unlikely((!__pyx_v_key) && PyErr_Occurred())) __PYX_ERR(0, 1580, __pyx_L3_error)
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L3_error:;
  __Pyx_AddTraceback("btdht.krcp.BMessage.__delitem__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return -1;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_5btdht_4krcp_8BMessage_10__delitem__(((struct __pyx_obj_5btdht_4krcp_BMessage *)__pyx_v_self), ((char *)__pyx_v_key));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static int __pyx_pf_5btdht_4krcp_8BMessage_10__delitem__(struct __pyx_obj_5btdht_4krcp_BMessage *__pyx_v_self, char *__pyx_v_key) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  int __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__delitem__", 0);

  /* "btdht/krcp.pyx":1590
 *             :raise KeyError: if ``key`` is not found
 *         """
 *         with nogil:             # <<<<<<<<<<<<<<
 *             if self.has_id and strcmp(key, b"id") == 0:
 *                 self.del_id()
 */
  {
      #ifdef WITH_THREAD
      PyThreadState *_save;
      Py_UNBLOCK_THREADS
      __Pyx_FastGIL_Remember();
      #endif
      /*try:*/ {

        /* "btdht/krcp.pyx":1591
 *         """
 *         with nogil:
 *             if self.has_id and strcmp(key, b"id") == 0:             # <<<<<<<<<<<<<<
 *                 self.del_id()
 *             elif self.has_target and strcmp(key, b"target") == 0:
 */
        __pyx_t_2 = (__pyx_v_self->has_id != 0);
        if (__pyx_t_2) {
        } else {
          __pyx_t_1 = __pyx_t_2;
          goto __pyx_L7_bool_binop_done;
        }
        __pyx_t_2 = ((strcmp(__pyx_v_key, ((char const *)"id")) == 0) != 0);
        __pyx_t_1 = __pyx_t_2;
        __pyx_L7_bool_binop_done:;
        if (__pyx_t_1) {

          /* "btdht/krcp.pyx":1592
 *         with nogil:
 *             if self.has_id and strcmp(key, b"id") == 0:
 *                 self.del_id()             # <<<<<<<<<<<<<<
 *             elif self.has_target and strcmp(key, b"target") == 0:
 *                 self.del_target()
 */
          ((struct __pyx_vtabstruct_5btdht_4krcp_BMessage *)__pyx_v_self->__pyx_vtab)->del_id(__pyx_v_self);

          /* "btdht/krcp.pyx":1591
 *         """
 *         with nogil:
 *             if self.has_id and strcmp(key, b"id") == 0:             # <<<<<<<<<<<<<<
 *                 self.del_id()
 *             elif self.has_target and strcmp(key, b"target") == 0:
 */
          goto __pyx_L6;
        }

        /* "btdht/krcp.pyx":1593
 *             if self.has_id and strcmp(key, b"id") == 0:
 *                 self.del_id()
 *             elif self.has_target and strcmp(key, b"target") == 0:             # <<<<<<<<<<<<<<
 *                 self.del_target()
 *             elif self.has_info_hash and strcmp(key, b"info_hash") == 0:
 */
        __pyx_t_2 = (__pyx_v_self->has_target != 0);
        if (__pyx_t_2) {
        } else {
          __pyx_t_1 = __pyx_t_2;
          goto __pyx_L9_bool_binop_done;
        }
        __pyx_t_2 = ((strcmp(__pyx_v_key, ((char const *)"target")) == 0) != 0);
        __pyx_t_1 = __pyx_t_2;
        __pyx_L9_bool_binop_done:;
        if (__pyx_t_1) {

          /* "btdht/krcp.pyx":1594
 *                 self.del_id()
 *             elif self.has_target and strcmp(key, b"target") == 0:
 *                 self.del_target()             # <<<<<<<<<<<<<<
 *             elif self.has_info_hash and strcmp(key, b"info_hash") == 0:
 *                 self.del_info_hash()
 */
          ((struct __pyx_vtabstruct_5btdht_4krcp_BMessage *)__pyx_v_self->__pyx_vtab)->del_target(__pyx_v_self);

          /* "btdht/krcp.pyx":1593
 *             if self.has_id and strcmp(key, b"id") == 0:
 *                 self.del_id()
 *             elif self.has_target and strcmp(key, b"target") == 0:             # <<<<<<<<<<<<<<
 *                 self.del_target()
 *             elif self.has_info_hash and strcmp(key, b"info_hash") == 0:
 */
          goto __pyx_L6;
        }

        /* "btdht/krcp.pyx":1595
 *             elif self.has_target and strcmp(key, b"target") == 0:
 *                 self.del_target()
 *             elif self.has_info_hash and strcmp(key, b"info_hash") == 0:             # <<<<<<<<<<<<<<
 *                 self.del_info_hash()
 *             elif self.has_token and strcmp(key, b"token") == 0:
 */
        __pyx_t_2 = (__pyx_v_self->has_info_hash != 0);
        if (__pyx_t_2) {
        } else {
          __pyx_t_1 = __pyx_t_2;
          goto __pyx_L11_bool_binop_done;
        }
        __pyx_t_2 = ((strcmp(__pyx_v_key, ((char const *)"info_hash")) == 0) != 0);
        __pyx_t_1 = __pyx_t_2;
        __pyx_L11_bool_binop_done:;
        if (__pyx_t_1) {

          /* "btdht/krcp.pyx":1596
 *                 self.del_target()
 *             elif self.has_info_hash and strcmp(key, b"info_hash") == 0:
 *                 self.del_info_hash()             # <<<<<<<<<<<<<<
 *             elif self.has_token and strcmp(key, b"token") == 0:
 *                 self.del_token()
 */
          ((struct __pyx_vtabstruct_5btdht_4krcp_BMessage *)__pyx_v_self->__pyx_vtab)->del_info_hash(__pyx_v_self);

          /* "btdht/krcp.pyx":1595
 *             elif self.has_target and strcmp(key, b"target") == 0:
 *                 self.del_target()
 *             elif self.has_info_hash and strcmp(key, b"info_hash") == 0:             # <<<<<<<<<<<<<<
 *                 self.del_info_hash()
 *             elif self.has_token and strcmp(key, b"token") == 0:
 */
          goto __pyx_L6;
        }

        /* "btdht/krcp.pyx":1597
 *             elif self.has_info_hash and strcmp(key, b"info_hash") == 0:
 *                 self.del_info_hash()
 *             elif self.has_token and strcmp(key, b"token") == 0:             # <<<<<<<<<<<<<<
 *                 self.del_token()
 *             elif self.has_nodes and strcmp(key, b"nodes") == 0:
 */
        __pyx_t_2 = (__pyx_v_self->has_token != 0);
        if (__pyx_t_2) {
        } else {
          __pyx_t_1 = __pyx_t_2;
          goto __pyx_L13_bool_binop_done;
        }
        __pyx_t_2 = ((strcmp(__pyx_v_key, ((char const *)"token")) == 0) != 0);
        __pyx_t_1 = __pyx_t_2;
        __pyx_L13_bool_binop_done:;
        if (__pyx_t_1) {

          /* "btdht/krcp.pyx":1598
 *                 self.del_info_hash()
 *             elif self.has_token and strcmp(key, b"token") == 0:
 *                 self.del_token()             # <<<<<<<<<<<<<<
 *             elif self.has_nodes and strcmp(key, b"nodes") == 0:
 *                 self.del_nodes()
 */
          ((struct __pyx_vtabstruct_5btdht_4krcp_BMessage *)__pyx_v_self->__pyx_vtab)->del_token(__pyx_v_self);

          /* "btdht/krcp.pyx":1597
 *             elif self.has_info_hash and strcmp(key, b"info_hash") == 0:
 *                 self.del_info_hash()
 *             elif self.has_token and strcmp(key, b"token") == 0:             # <<<<<<<<<<<<<<
 *                 self.del_token()
 *             elif self.has_nodes and strcmp(key, b"nodes") == 0:
 */
          goto __pyx_L6;
        }

        /* "btdht/krcp.pyx":1599
 *             elif self.has_token and strcmp(key, b"token") == 0:
 *                 self.del_token()
 *             elif self.has_nodes and strcmp(key, b"nodes") == 0:             # <<<<<<<<<<<<<<
 *                 self.del_nodes()
 *             elif self.has_implied_port and strcmp(key, b"implied_port") == 0:
 */
        __pyx_t_2 = (__pyx_v_self->has_nodes != 0);
        if (__pyx_t_2) {
        } else {
          __pyx_t_1 = __pyx_t_2;
          goto __pyx_L15_bool_binop_done;
        }
        __pyx_t_2 = ((strcmp(__pyx_v_key, ((char const *)"nodes")) == 0) != 0);
        __pyx_t_1 = __pyx_t_2;
        __pyx_L15_bool_binop_done:;
        if (__pyx_t_1) {

          /* "btdht/krcp.pyx":1600
 *                 self.del_token()
 *             elif self.has_nodes and strcmp(key, b"nodes") == 0:
 *                 self.del_nodes()             # <<<<<<<<<<<<<<
 *             elif self.has_implied_port and strcmp(key, b"implied_port") == 0:
 *                 self.del_implied_port()
 */
          (void)(((struct __pyx_vtabstruct_5btdht_4krcp_BMessage *)__pyx_v_self->__pyx_vtab)->del_nodes(__pyx_v_self));

          /* "btdht/krcp.pyx":1599
 *             elif self.has_token and strcmp(key, b"token") == 0:
 *                 self.del_token()
 *             elif self.has_nodes and strcmp(key, b"nodes") == 0:             # <<<<<<<<<<<<<<
 *                 self.del_nodes()
 *             elif self.has_implied_port and strcmp(key, b"implied_port") == 0:
 */
          goto __pyx_L6;
        }

        /* "btdht/krcp.pyx":1601
 *             elif self.has_nodes and strcmp(key, b"nodes") == 0:
 *                 self.del_nodes()
 *             elif self.has_implied_port and strcmp(key, b"implied_port") == 0:             # <<<<<<<<<<<<<<
 *                 self.del_implied_port()
 *             elif self.has_port and strcmp(key, b"port") == 0:
 */
        __pyx_t_2 = (__pyx_v_self->has_implied_port != 0);
        if (__pyx_t_2) {
        } else {
          __pyx_t_1 = __pyx_t_2;
          goto __pyx_L17_bool_binop_done;
        }
        __pyx_t_2 = ((strcmp(__pyx_v_key, ((char const *)"implied_port")) == 0) != 0);
        __pyx_t_1 = __pyx_t_2;
        __pyx_L17_bool_binop_done:;
        if (__pyx_t_1) {

          /* "btdht/krcp.pyx":1602
 *                 self.del_nodes()
 *             elif self.has_implied_port and strcmp(key, b"implied_port") == 0:
 *                 self.del_implied_port()             # <<<<<<<<<<<<<<
 *             elif self.has_port and strcmp(key, b"port") == 0:
 *                 self.del_port()
 */
          ((struct __pyx_vtabstruct_5btdht_4krcp_BMessage *)__pyx_v_self->__pyx_vtab)->del_implied_port(__pyx_v_self);

          /* "btdht/krcp.pyx":1601
 *             elif self.has_nodes and strcmp(key, b"nodes") == 0:
 *                 self.del_nodes()
 *             elif self.has_implied_port and strcmp(key, b"implied_port") == 0:             # <<<<<<<<<<<<<<
 *                 self.del_implied_port()
 *             elif self.has_port and strcmp(key, b"port") == 0:
 */
          goto __pyx_L6;
        }

        /* "btdht/krcp.pyx":1603
 *             elif self.has_implied_port and strcmp(key, b"implied_port") == 0:
 *                 self.del_implied_port()
 *             elif self.has_port and strcmp(key, b"port") == 0:             # <<<<<<<<<<<<<<
 *                 self.del_port()
 *             elif self.has_values and strcmp(key, b"values") == 0:
 */
        __pyx_t_2 = (__pyx_v_self->has_port != 0);
        if (__pyx_t_2) {
        } else {
          __pyx_t_1 = __pyx_t_2;
          goto __pyx_L19_bool_binop_done;
        }
        __pyx_t_2 = ((strcmp(__pyx_v_key, ((char const *)"port")) == 0) != 0);
        __pyx_t_1 = __pyx_t_2;
        __pyx_L19_bool_binop_done:;
        if (__pyx_t_1) {

          /* "btdht/krcp.pyx":1604
 *                 self.del_implied_port()
 *             elif self.has_port and strcmp(key, b"port") == 0:
 *                 self.del_port()             # <<<<<<<<<<<<<<
 *             elif self.has_values and strcmp(key, b"values") == 0:
 *                 self.del_values()
 */
          ((struct __pyx_vtabstruct_5btdht_4krcp_BMessage *)__pyx_v_self->__pyx_vtab)->del_port(__pyx_v_self);

          /* "btdht/krcp.pyx":1603
 *             elif self.has_implied_port and strcmp(key, b"implied_port") == 0:
 *                 self.del_implied_port()
 *             elif self.has_port and strcmp(key, b"port") == 0:             # <<<<<<<<<<<<<<
 *                 self.del_port()
 *             elif self.has_values and strcmp(key, b"values") == 0:
 */
          goto __pyx_L6;
        }

        /* "btdht/krcp.pyx":1605
 *             elif self.has_port and strcmp(key, b"port") == 0:
 *                 self.del_port()
 *             elif self.has_values and strcmp(key, b"values") == 0:             # <<<<<<<<<<<<<<
 *                 self.del_values()
 *             else:
 */
        __pyx_t_2 = (__pyx_v_self->has_values != 0);
        if (__pyx_t_2) {
        } else {
          __pyx_t_1 = __pyx_t_2;
          goto __pyx_L21_bool_binop_done;
        }
        __pyx_t_2 = ((strcmp(__pyx_v_key, ((char const *)"values")) == 0) != 0);
        __pyx_t_1 = __pyx_t_2;
        __pyx_L21_bool_binop_done:;
        if (__pyx_t_1) {

          /* "btdht/krcp.pyx":1606
 *                 self.del_port()
 *             elif self.has_values and strcmp(key, b"values") == 0:
 *                 self.del_values()             # <<<<<<<<<<<<<<
 *             else:
 *                 with gil:
 */
          ((struct __pyx_vtabstruct_5btdht_4krcp_BMessage *)__pyx_v_self->__pyx_vtab)->del_values(__pyx_v_self);

          /* "btdht/krcp.pyx":1605
 *             elif self.has_port and strcmp(key, b"port") == 0:
 *                 self.del_port()
 *             elif self.has_values and strcmp(key, b"values") == 0:             # <<<<<<<<<<<<<<
 *                 self.del_values()
 *             else:
 */
          goto __pyx_L6;
        }

        /* "btdht/krcp.pyx":1608
 *                 self.del_values()
 *             else:
 *                 with gil:             # <<<<<<<<<<<<<<
 *                     raise KeyError(key)
 * 
 */
        /*else*/ {
          {
              #ifdef WITH_THREAD
              PyGILState_STATE __pyx_gilstate_save = __Pyx_PyGILState_Ensure();
              #endif
              /*try:*/ {

                /* "btdht/krcp.pyx":1609
 *             else:
 *                 with gil:
 *                     raise KeyError(key)             # <<<<<<<<<<<<<<
 * 
 *     def __setitem__(self, char* key, value):
 */
                __pyx_t_3 = __Pyx_PyBytes_FromString(__pyx_v_key); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1609, __pyx_L24_error)
                __Pyx_GOTREF(__pyx_t_3);
                __pyx_t_4 = __Pyx_PyObject_CallOneArg(__pyx_builtin_KeyError, __pyx_t_3); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1609, __pyx_L24_error)
                __Pyx_GOTREF(__pyx_t_4);
                __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
                __Pyx_Raise(__pyx_t_4, 0, 0, 0);
                __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
                __PYX_ERR(0, 1609, __pyx_L24_error)
              }

              /* "btdht/krcp.pyx":1608
 *                 self.del_values()
 *             else:
 *                 with gil:             # <<<<<<<<<<<<<<
 *                     raise KeyError(key)
 * 
 */
              /*finally:*/ {
                __pyx_L24_error: {
                  #ifdef WITH_THREAD
                  __Pyx_PyGILState_Release(__pyx_gilstate_save);
                  #endif
                  goto __pyx_L4_error;
                }
              }
          }
        }
        __pyx_L6:;
      }

      /* "btdht/krcp.pyx":1590
 *             :raise KeyError: if ``key`` is not found
 *         """
 *         with nogil:             # <<<<<<<<<<<<<<
 *             if self.has_id and strcmp(key, b"id") == 0:
 *                 self.del_id()
 */
      /*finally:*/ {
        /*normal exit:*/{
          #ifdef WITH_THREAD
          __Pyx_FastGIL_Forget();
          Py_BLOCK_THREADS
          #endif
          goto __pyx_L5;
        }
        __pyx_L4_error: {
          #ifdef WITH_THREAD
          __Pyx_FastGIL_Forget();
          Py_BLOCK_THREADS
          #endif
          goto __pyx_L1_error;
        }
        __pyx_L5:;
      }
  }

  /* "btdht/krcp.pyx":1580
 *             raise KeyError(key)
 * 
 *     def __delitem__(self, char* key):             # <<<<<<<<<<<<<<
 *         """
 *             Allow to unset attributes from the secondary dictionnary::
 */

  /* function exit code */
  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_AddTraceback("btdht.krcp.BMessage.__delitem__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "btdht/krcp.pyx":1611
 *                     raise KeyError(key)
 * 
 *     def __setitem__(self, char* key, value):             # <<<<<<<<<<<<<<
 *         """
 *             Allow to set attributes from the secondary dictionnary::
 */

/* Python wrapper */
static int __pyx_pw_5btdht_4krcp_8BMessage_13__setitem__(PyObject *__pyx_v_self, PyObject *__pyx_arg_key, PyObject *__pyx_v_value); /*proto*/
static char __pyx_doc_5btdht_4krcp_8BMessage_12__setitem__[] = "\n            Allow to set attributes from the secondary dictionnary::\n\n                self[b'id'] = b\"...\"\n\n            :param bytes key: The name of an attribute of the secondary dictionnary to set\n            :param value: The value to set\n            :raises KeyError: if ``key`` is not one of id, target, info_hash, token, nodes,\n                implied_port, port, values.\n            :raises ValueError: if ``value`` is not well formated (length, type, ...)\n        ";
#if CYTHON_UPDATE_DESCRIPTOR_DOC
struct wrapperbase __pyx_wrapperbase_5btdht_4krcp_8BMessage_12__setitem__;
#endif
static int __pyx_pw_5btdht_4krcp_8BMessage_13__setitem__(PyObject *__pyx_v_self, PyObject *__pyx_arg_key, PyObject *__pyx_v_value) {
  char *__pyx_v_key;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__setitem__ (wrapper)", 0);
  assert(__pyx_arg_key); {
    __pyx_v_key = __Pyx_PyObject_AsWritableString(__pyx_arg_key); if (unlikely((!__pyx_v_key) && PyErr_Occurred())) __PYX_ERR(0, 1611, __pyx_L3_error)
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L3_error:;
  __Pyx_AddTraceback("btdht.krcp.BMessage.__setitem__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return -1;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_5btdht_4krcp_8BMessage_12__setitem__(((struct __pyx_obj_5btdht_4krcp_BMessage *)__pyx_v_self), ((char *)__pyx_v_key), ((PyObject *)__pyx_v_value));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static int __pyx_pf_5btdht_4krcp_8BMessage_12__setitem__(struct __pyx_obj_5btdht_4krcp_BMessage *__pyx_v_self, char *__pyx_v_key, PyObject *__pyx_v_value) {
  int __pyx_v_i;
  char *__pyx_v_j;
  char **__pyx_v_v;
  int __pyx_v_l;
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  Py_ssize_t __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  char *__pyx_t_4;
  int __pyx_t_5;
  PyObject *__pyx_t_6 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__setitem__", 0);

  /* "btdht/krcp.pyx":1623
 *             :raises ValueError: if ``value`` is not well formated (length, type, ...)
 *         """
 *         cdef int i = 0             # <<<<<<<<<<<<<<
 *         cdef char * j
 *         cdef char** v
 */
  __pyx_v_i = 0;

  /* "btdht/krcp.pyx":1626
 *         cdef char * j
 *         cdef char** v
 *         cdef int l = 0             # <<<<<<<<<<<<<<
 *         with nogil:
 *             if strcmp(key, b"id") == 0:
 */
  __pyx_v_l = 0;

  /* "btdht/krcp.pyx":1627
 *         cdef char** v
 *         cdef int l = 0
 *         with nogil:             # <<<<<<<<<<<<<<
 *             if strcmp(key, b"id") == 0:
 *                 with gil:
 */
  {
      #ifdef WITH_THREAD
      PyThreadState *_save;
      Py_UNBLOCK_THREADS
      __Pyx_FastGIL_Remember();
      #endif
      /*try:*/ {

        /* "btdht/krcp.pyx":1628
 *         cdef int l = 0
 *         with nogil:
 *             if strcmp(key, b"id") == 0:             # <<<<<<<<<<<<<<
 *                 with gil:
 *                     if len(value) != 20:
 */
        __pyx_t_1 = ((strcmp(__pyx_v_key, ((char const *)"id")) == 0) != 0);
        if (__pyx_t_1) {

          /* "btdht/krcp.pyx":1629
 *         with nogil:
 *             if strcmp(key, b"id") == 0:
 *                 with gil:             # <<<<<<<<<<<<<<
 *                     if len(value) != 20:
 *                         raise ValueError("Can only set strings of length 20B")
 */
          {
              #ifdef WITH_THREAD
              PyGILState_STATE __pyx_gilstate_save = __Pyx_PyGILState_Ensure();
              #endif
              /*try:*/ {

                /* "btdht/krcp.pyx":1630
 *             if strcmp(key, b"id") == 0:
 *                 with gil:
 *                     if len(value) != 20:             # <<<<<<<<<<<<<<
 *                         raise ValueError("Can only set strings of length 20B")
 *                     j = value
 */
                __pyx_t_2 = PyObject_Length(__pyx_v_value); if (unlikely(__pyx_t_2 == ((Py_ssize_t)-1))) __PYX_ERR(0, 1630, __pyx_L8_error)
                __pyx_t_1 = ((__pyx_t_2 != 20) != 0);
                if (unlikely(__pyx_t_1)) {

                  /* "btdht/krcp.pyx":1631
 *                 with gil:
 *                     if len(value) != 20:
 *                         raise ValueError("Can only set strings of length 20B")             # <<<<<<<<<<<<<<
 *                     j = value
 *                 self.set_id(j, 20)
 */
                  __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__4, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1631, __pyx_L8_error)
                  __Pyx_GOTREF(__pyx_t_3);
                  __Pyx_Raise(__pyx_t_3, 0, 0, 0);
                  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
                  __PYX_ERR(0, 1631, __pyx_L8_error)

                  /* "btdht/krcp.pyx":1630
 *             if strcmp(key, b"id") == 0:
 *                 with gil:
 *                     if len(value) != 20:             # <<<<<<<<<<<<<<
 *                         raise ValueError("Can only set strings of length 20B")
 *                     j = value
 */
                }

                /* "btdht/krcp.pyx":1632
 *                     if len(value) != 20:
 *                         raise ValueError("Can only set strings of length 20B")
 *                     j = value             # <<<<<<<<<<<<<<
 *                 self.set_id(j, 20)
 *                 return
 */
                __pyx_t_4 = __Pyx_PyObject_AsWritableString(__pyx_v_value); if (unlikely((!__pyx_t_4) && PyErr_Occurred())) __PYX_ERR(0, 1632, __pyx_L8_error)
                __pyx_v_j = __pyx_t_4;
              }

              /* "btdht/krcp.pyx":1629
 *         with nogil:
 *             if strcmp(key, b"id") == 0:
 *                 with gil:             # <<<<<<<<<<<<<<
 *                     if len(value) != 20:
 *                         raise ValueError("Can only set strings of length 20B")
 */
              /*finally:*/ {
                /*normal exit:*/{
                  #ifdef WITH_THREAD
                  __Pyx_PyGILState_Release(__pyx_gilstate_save);
                  #endif
                  goto __pyx_L9;
                }
                __pyx_L8_error: {
                  #ifdef WITH_THREAD
                  __Pyx_PyGILState_Release(__pyx_gilstate_save);
                  #endif
                  goto __pyx_L4_error;
                }
                __pyx_L9:;
              }
          }

          /* "btdht/krcp.pyx":1633
 *                         raise ValueError("Can only set strings of length 20B")
 *                     j = value
 *                 self.set_id(j, 20)             # <<<<<<<<<<<<<<
 *                 return
 *             elif strcmp(key, b"target") == 0:
 */
          __pyx_t_5 = ((struct __pyx_vtabstruct_5btdht_4krcp_BMessage *)__pyx_v_self->__pyx_vtab)->set_id(__pyx_v_self, __pyx_v_j, 20); if (unlikely(__pyx_t_5 == ((int)-1))) __PYX_ERR(0, 1633, __pyx_L4_error)

          /* "btdht/krcp.pyx":1634
 *                     j = value
 *                 self.set_id(j, 20)
 *                 return             # <<<<<<<<<<<<<<
 *             elif strcmp(key, b"target") == 0:
 *                 self.encoded_uptodate = False
 */
          __pyx_r = 0;
          goto __pyx_L3_return;

          /* "btdht/krcp.pyx":1628
 *         cdef int l = 0
 *         with nogil:
 *             if strcmp(key, b"id") == 0:             # <<<<<<<<<<<<<<
 *                 with gil:
 *                     if len(value) != 20:
 */
        }

        /* "btdht/krcp.pyx":1635
 *                 self.set_id(j, 20)
 *                 return
 *             elif strcmp(key, b"target") == 0:             # <<<<<<<<<<<<<<
 *                 self.encoded_uptodate = False
 *                 with gil:
 */
        __pyx_t_1 = ((strcmp(__pyx_v_key, ((char const *)"target")) == 0) != 0);
        if (__pyx_t_1) {

          /* "btdht/krcp.pyx":1636
 *                 return
 *             elif strcmp(key, b"target") == 0:
 *                 self.encoded_uptodate = False             # <<<<<<<<<<<<<<
 *                 with gil:
 *                     if len(value) != 20:
 */
          __pyx_v_self->encoded_uptodate = 0;

          /* "btdht/krcp.pyx":1637
 *             elif strcmp(key, b"target") == 0:
 *                 self.encoded_uptodate = False
 *                 with gil:             # <<<<<<<<<<<<<<
 *                     if len(value) != 20:
 *                         raise ValueError("Can only set strings of length 20B")
 */
          {
              #ifdef WITH_THREAD
              PyGILState_STATE __pyx_gilstate_save = __Pyx_PyGILState_Ensure();
              #endif
              /*try:*/ {

                /* "btdht/krcp.pyx":1638
 *                 self.encoded_uptodate = False
 *                 with gil:
 *                     if len(value) != 20:             # <<<<<<<<<<<<<<
 *                         raise ValueError("Can only set strings of length 20B")
 *                     j = value
 */
                __pyx_t_2 = PyObject_Length(__pyx_v_value); if (unlikely(__pyx_t_2 == ((Py_ssize_t)-1))) __PYX_ERR(0, 1638, __pyx_L12_error)
                __pyx_t_1 = ((__pyx_t_2 != 20) != 0);
                if (unlikely(__pyx_t_1)) {

                  /* "btdht/krcp.pyx":1639
 *                 with gil:
 *                     if len(value) != 20:
 *                         raise ValueError("Can only set strings of length 20B")             # <<<<<<<<<<<<<<
 *                     j = value
 *                 self.set_target(j, 20)
 */
                  __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__4, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1639, __pyx_L12_error)
                  __Pyx_GOTREF(__pyx_t_3);
                  __Pyx_Raise(__pyx_t_3, 0, 0, 0);
                  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
                  __PYX_ERR(0, 1639, __pyx_L12_error)

                  /* "btdht/krcp.pyx":1638
 *                 self.encoded_uptodate = False
 *                 with gil:
 *                     if len(value) != 20:             # <<<<<<<<<<<<<<
 *                         raise ValueError("Can only set strings of length 20B")
 *                     j = value
 */
                }

                /* "btdht/krcp.pyx":1640
 *                     if len(value) != 20:
 *                         raise ValueError("Can only set strings of length 20B")
 *                     j = value             # <<<<<<<<<<<<<<
 *                 self.set_target(j, 20)
 *                 return
 */
                __pyx_t_4 = __Pyx_PyObject_AsWritableString(__pyx_v_value); if (unlikely((!__pyx_t_4) && PyErr_Occurred())) __PYX_ERR(0, 1640, __pyx_L12_error)
                __pyx_v_j = __pyx_t_4;
              }

              /* "btdht/krcp.pyx":1637
 *             elif strcmp(key, b"target") == 0:
 *                 self.encoded_uptodate = False
 *                 with gil:             # <<<<<<<<<<<<<<
 *                     if len(value) != 20:
 *                         raise ValueError("Can only set strings of length 20B")
 */
              /*finally:*/ {
                /*normal exit:*/{
                  #ifdef WITH_THREAD
                  __Pyx_PyGILState_Release(__pyx_gilstate_save);
                  #endif
                  goto __pyx_L13;
                }
                __pyx_L12_error: {
                  #ifdef WITH_THREAD
                  __Pyx_PyGILState_Release(__pyx_gilstate_save);
                  #endif
                  goto __pyx_L4_error;
                }
                __pyx_L13:;
              }
          }

          /* "btdht/krcp.pyx":1641
 *                         raise ValueError("Can only set strings of length 20B")
 *                     j = value
 *                 self.set_target(j, 20)             # <<<<<<<<<<<<<<
 *                 return
 *             elif strcmp(key, b"info_hash") == 0:
 */
          __pyx_t_5 = ((struct __pyx_vtabstruct_5btdht_4krcp_BMessage *)__pyx_v_self->__pyx_vtab)->set_target(__pyx_v_self, __pyx_v_j, 20); if (unlikely(__pyx_t_5 == ((int)-1))) __PYX_ERR(0, 1641, __pyx_L4_error)

          /* "btdht/krcp.pyx":1642
 *                     j = value
 *                 self.set_target(j, 20)
 *                 return             # <<<<<<<<<<<<<<
 *             elif strcmp(key, b"info_hash") == 0:
 *                 with gil:
 */
          __pyx_r = 0;
          goto __pyx_L3_return;

          /* "btdht/krcp.pyx":1635
 *                 self.set_id(j, 20)
 *                 return
 *             elif strcmp(key, b"target") == 0:             # <<<<<<<<<<<<<<
 *                 self.encoded_uptodate = False
 *                 with gil:
 */
        }

        /* "btdht/krcp.pyx":1643
 *                 self.set_target(j, 20)
 *                 return
 *             elif strcmp(key, b"info_hash") == 0:             # <<<<<<<<<<<<<<
 *                 with gil:
 *                     if len(value) != 20:
 */
        __pyx_t_1 = ((strcmp(__pyx_v_key, ((char const *)"info_hash")) == 0) != 0);
        if (__pyx_t_1) {

          /* "btdht/krcp.pyx":1644
 *                 return
 *             elif strcmp(key, b"info_hash") == 0:
 *                 with gil:             # <<<<<<<<<<<<<<
 *                     if len(value) != 20:
 *                         raise ValueError("Can only set strings of length 20B")
 */
          {
              #ifdef WITH_THREAD
              PyGILState_STATE __pyx_gilstate_save = __Pyx_PyGILState_Ensure();
              #endif
              /*try:*/ {

                /* "btdht/krcp.pyx":1645
 *             elif strcmp(key, b"info_hash") == 0:
 *                 with gil:
 *                     if len(value) != 20:             # <<<<<<<<<<<<<<
 *                         raise ValueError("Can only set strings of length 20B")
 *                     j = value
 */
                __pyx_t_2 = PyObject_Length(__pyx_v_value); if (unlikely(__pyx_t_2 == ((Py_ssize_t)-1))) __PYX_ERR(0, 1645, __pyx_L16_error)
                __pyx_t_1 = ((__pyx_t_2 != 20) != 0);
                if (unlikely(__pyx_t_1)) {

                  /* "btdht/krcp.pyx":1646
 *                 with gil:
 *                     if len(value) != 20:
 *                         raise ValueError("Can only set strings of length 20B")             # <<<<<<<<<<<<<<
 *                     j = value
 *                 self.set_info_hash(j, 20)
 */
                  __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__4, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1646, __pyx_L16_error)
                  __Pyx_GOTREF(__pyx_t_3);
                  __Pyx_Raise(__pyx_t_3, 0, 0, 0);
                  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
                  __PYX_ERR(0, 1646, __pyx_L16_error)

                  /* "btdht/krcp.pyx":1645
 *             elif strcmp(key, b"info_hash") == 0:
 *                 with gil:
 *                     if len(value) != 20:             # <<<<<<<<<<<<<<
 *                         raise ValueError("Can only set strings of length 20B")
 *                     j = value
 */
                }

                /* "btdht/krcp.pyx":1647
 *                     if len(value) != 20:
 *                         raise ValueError("Can only set strings of length 20B")
 *                     j = value             # <<<<<<<<<<<<<<
 *                 self.set_info_hash(j, 20)
 *                 return
 */
                __pyx_t_4 = __Pyx_PyObject_AsWritableString(__pyx_v_value); if (unlikely((!__pyx_t_4) && PyErr_Occurred())) __PYX_ERR(0, 1647, __pyx_L16_error)
                __pyx_v_j = __pyx_t_4;
              }

              /* "btdht/krcp.pyx":1644
 *                 return
 *             elif strcmp(key, b"info_hash") == 0:
 *                 with gil:             # <<<<<<<<<<<<<<
 *                     if len(value) != 20:
 *                         raise ValueError("Can only set strings of length 20B")
 */
              /*finally:*/ {
                /*normal exit:*/{
                  #ifdef WITH_THREAD
                  __Pyx_PyGILState_Release(__pyx_gilstate_save);
                  #endif
                  goto __pyx_L17;
                }
                __pyx_L16_error: {
                  #ifdef WITH_THREAD
                  __Pyx_PyGILState_Release(__pyx_gilstate_save);
                  #endif
                  goto __pyx_L4_error;
                }
                __pyx_L17:;
              }
          }

          /* "btdht/krcp.pyx":1648
 *                         raise ValueError("Can only set strings of length 20B")
 *                     j = value
 *                 self.set_info_hash(j, 20)             # <<<<<<<<<<<<<<
 *                 return
 *             elif strcmp(key, b"token") == 0:
 */
          __pyx_t_5 = ((struct __pyx_vtabstruct_5btdht_4krcp_BMessage *)__pyx_v_self->__pyx_vtab)->set_info_hash(__pyx_v_self, __pyx_v_j, 20); if (unlikely(__pyx_t_5 == ((int)-1))) __PYX_ERR(0, 1648, __pyx_L4_error)

          /* "btdht/krcp.pyx":1649
 *                     j = value
 *                 self.set_info_hash(j, 20)
 *                 return             # <<<<<<<<<<<<<<
 *             elif strcmp(key, b"token") == 0:
 *                 with gil:
 */
          __pyx_r = 0;
          goto __pyx_L3_return;

          /* "btdht/krcp.pyx":1643
 *                 self.set_target(j, 20)
 *                 return
 *             elif strcmp(key, b"info_hash") == 0:             # <<<<<<<<<<<<<<
 *                 with gil:
 *                     if len(value) != 20:
 */
        }

        /* "btdht/krcp.pyx":1650
 *                 self.set_info_hash(j, 20)
 *                 return
 *             elif strcmp(key, b"token") == 0:             # <<<<<<<<<<<<<<
 *                 with gil:
 *                     l = len(value)
 */
        __pyx_t_1 = ((strcmp(__pyx_v_key, ((char const *)"token")) == 0) != 0);
        if (__pyx_t_1) {

          /* "btdht/krcp.pyx":1651
 *                 return
 *             elif strcmp(key, b"token") == 0:
 *                 with gil:             # <<<<<<<<<<<<<<
 *                     l = len(value)
 *                     j = value
 */
          {
              #ifdef WITH_THREAD
              PyGILState_STATE __pyx_gilstate_save = __Pyx_PyGILState_Ensure();
              #endif
              /*try:*/ {

                /* "btdht/krcp.pyx":1652
 *             elif strcmp(key, b"token") == 0:
 *                 with gil:
 *                     l = len(value)             # <<<<<<<<<<<<<<
 *                     j = value
 *                 self.set_token(j, l)
 */
                __pyx_t_2 = PyObject_Length(__pyx_v_value); if (unlikely(__pyx_t_2 == ((Py_ssize_t)-1))) __PYX_ERR(0, 1652, __pyx_L20_error)
                __pyx_v_l = __pyx_t_2;

                /* "btdht/krcp.pyx":1653
 *                 with gil:
 *                     l = len(value)
 *                     j = value             # <<<<<<<<<<<<<<
 *                 self.set_token(j, l)
 *                 return
 */
                __pyx_t_4 = __Pyx_PyObject_AsWritableString(__pyx_v_value); if (unlikely((!__pyx_t_4) && PyErr_Occurred())) __PYX_ERR(0, 1653, __pyx_L20_error)
                __pyx_v_j = __pyx_t_4;
              }

              /* "btdht/krcp.pyx":1651
 *                 return
 *             elif strcmp(key, b"token") == 0:
 *                 with gil:             # <<<<<<<<<<<<<<
 *                     l = len(value)
 *                     j = value
 */
              /*finally:*/ {
                /*normal exit:*/{
                  #ifdef WITH_THREAD
                  __Pyx_PyGILState_Release(__pyx_gilstate_save);
                  #endif
                  goto __pyx_L21;
                }
                __pyx_L20_error: {
                  #ifdef WITH_THREAD
                  __Pyx_PyGILState_Release(__pyx_gilstate_save);
                  #endif
                  goto __pyx_L4_error;
                }
                __pyx_L21:;
              }
          }

          /* "btdht/krcp.pyx":1654
 *                     l = len(value)
 *                     j = value
 *                 self.set_token(j, l)             # <<<<<<<<<<<<<<
 *                 return
 *             elif strcmp(key, b"nodes") == 0:
 */
          (void)(((struct __pyx_vtabstruct_5btdht_4krcp_BMessage *)__pyx_v_self->__pyx_vtab)->set_token(__pyx_v_self, __pyx_v_j, __pyx_v_l));

          /* "btdht/krcp.pyx":1655
 *                     j = value
 *                 self.set_token(j, l)
 *                 return             # <<<<<<<<<<<<<<
 *             elif strcmp(key, b"nodes") == 0:
 *                 with gil:
 */
          __pyx_r = 0;
          goto __pyx_L3_return;

          /* "btdht/krcp.pyx":1650
 *                 self.set_info_hash(j, 20)
 *                 return
 *             elif strcmp(key, b"token") == 0:             # <<<<<<<<<<<<<<
 *                 with gil:
 *                     l = len(value)
 */
        }

        /* "btdht/krcp.pyx":1656
 *                 self.set_token(j, l)
 *                 return
 *             elif strcmp(key, b"nodes") == 0:             # <<<<<<<<<<<<<<
 *                 with gil:
 *                     l = len(value)
 */
        __pyx_t_1 = ((strcmp(__pyx_v_key, ((char const *)"nodes")) == 0) != 0);
        if (__pyx_t_1) {

          /* "btdht/krcp.pyx":1657
 *                 return
 *             elif strcmp(key, b"nodes") == 0:
 *                 with gil:             # <<<<<<<<<<<<<<
 *                     l = len(value)
 *                     j = value
 */
          {
              #ifdef WITH_THREAD
              PyGILState_STATE __pyx_gilstate_save = __Pyx_PyGILState_Ensure();
              #endif
              /*try:*/ {

                /* "btdht/krcp.pyx":1658
 *             elif strcmp(key, b"nodes") == 0:
 *                 with gil:
 *                     l = len(value)             # <<<<<<<<<<<<<<
 *                     j = value
 *                 self.set_nodes(j, l)
 */
                __pyx_t_2 = PyObject_Length(__pyx_v_value); if (unlikely(__pyx_t_2 == ((Py_ssize_t)-1))) __PYX_ERR(0, 1658, __pyx_L23_error)
                __pyx_v_l = __pyx_t_2;

                /* "btdht/krcp.pyx":1659
 *                 with gil:
 *                     l = len(value)
 *                     j = value             # <<<<<<<<<<<<<<
 *                 self.set_nodes(j, l)
 *                 return
 */
                __pyx_t_4 = __Pyx_PyObject_AsWritableString(__pyx_v_value); if (unlikely((!__pyx_t_4) && PyErr_Occurred())) __PYX_ERR(0, 1659, __pyx_L23_error)
                __pyx_v_j = __pyx_t_4;
              }

              /* "btdht/krcp.pyx":1657
 *                 return
 *             elif strcmp(key, b"nodes") == 0:
 *                 with gil:             # <<<<<<<<<<<<<<
 *                     l = len(value)
 *                     j = value
 */
              /*finally:*/ {
                /*normal exit:*/{
                  #ifdef WITH_THREAD
                  __Pyx_PyGILState_Release(__pyx_gilstate_save);
                  #endif
                  goto __pyx_L24;
                }
                __pyx_L23_error: {
                  #ifdef WITH_THREAD
                  __Pyx_PyGILState_Release(__pyx_gilstate_save);
                  #endif
                  goto __pyx_L4_error;
                }
                __pyx_L24:;
              }
          }

          /* "btdht/krcp.pyx":1660
 *                     l = len(value)
 *                     j = value
 *                 self.set_nodes(j, l)             # <<<<<<<<<<<<<<
 *                 return
 *             elif strcmp(key, b"implied_port") == 0:
 */
          (void)(((struct __pyx_vtabstruct_5btdht_4krcp_BMessage *)__pyx_v_self->__pyx_vtab)->set_nodes(__pyx_v_self, __pyx_v_j, __pyx_v_l));

          /* "btdht/krcp.pyx":1661
 *                     j = value
 *                 self.set_nodes(j, l)
 *                 return             # <<<<<<<<<<<<<<
 *             elif strcmp(key, b"implied_port") == 0:
 *                 with gil:
 */
          __pyx_r = 0;
          goto __pyx_L3_return;

          /* "btdht/krcp.pyx":1656
 *                 self.set_token(j, l)
 *                 return
 *             elif strcmp(key, b"nodes") == 0:             # <<<<<<<<<<<<<<
 *                 with gil:
 *                     l = len(value)
 */
        }

        /* "btdht/krcp.pyx":1662
 *                 self.set_nodes(j, l)
 *                 return
 *             elif strcmp(key, b"implied_port") == 0:             # <<<<<<<<<<<<<<
 *                 with gil:
 *                     i = value
 */
        __pyx_t_1 = ((strcmp(__pyx_v_key, ((char const *)"implied_port")) == 0) != 0);
        if (__pyx_t_1) {

          /* "btdht/krcp.pyx":1663
 *                 return
 *             elif strcmp(key, b"implied_port") == 0:
 *                 with gil:             # <<<<<<<<<<<<<<
 *                     i = value
 *                 self.set_implied_port(i)
 */
          {
              #ifdef WITH_THREAD
              PyGILState_STATE __pyx_gilstate_save = __Pyx_PyGILState_Ensure();
              #endif
              /*try:*/ {

                /* "btdht/krcp.pyx":1664
 *             elif strcmp(key, b"implied_port") == 0:
 *                 with gil:
 *                     i = value             # <<<<<<<<<<<<<<
 *                 self.set_implied_port(i)
 *                 return
 */
                __pyx_t_5 = __Pyx_PyInt_As_int(__pyx_v_value); if (unlikely((__pyx_t_5 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 1664, __pyx_L26_error)
                __pyx_v_i = __pyx_t_5;
              }

              /* "btdht/krcp.pyx":1663
 *                 return
 *             elif strcmp(key, b"implied_port") == 0:
 *                 with gil:             # <<<<<<<<<<<<<<
 *                     i = value
 *                 self.set_implied_port(i)
 */
              /*finally:*/ {
                /*normal exit:*/{
                  #ifdef WITH_THREAD
                  __Pyx_PyGILState_Release(__pyx_gilstate_save);
                  #endif
                  goto __pyx_L27;
                }
                __pyx_L26_error: {
                  #ifdef WITH_THREAD
                  __Pyx_PyGILState_Release(__pyx_gilstate_save);
                  #endif
                  goto __pyx_L4_error;
                }
                __pyx_L27:;
              }
          }

          /* "btdht/krcp.pyx":1665
 *                 with gil:
 *                     i = value
 *                 self.set_implied_port(i)             # <<<<<<<<<<<<<<
 *                 return
 *             elif strcmp(key, b"port") == 0:
 */
          (void)(((struct __pyx_vtabstruct_5btdht_4krcp_BMessage *)__pyx_v_self->__pyx_vtab)->set_implied_port(__pyx_v_self, __pyx_v_i));

          /* "btdht/krcp.pyx":1666
 *                     i = value
 *                 self.set_implied_port(i)
 *                 return             # <<<<<<<<<<<<<<
 *             elif strcmp(key, b"port") == 0:
 *                 with gil:
 */
          __pyx_r = 0;
          goto __pyx_L3_return;

          /* "btdht/krcp.pyx":1662
 *                 self.set_nodes(j, l)
 *                 return
 *             elif strcmp(key, b"implied_port") == 0:             # <<<<<<<<<<<<<<
 *                 with gil:
 *                     i = value
 */
        }

        /* "btdht/krcp.pyx":1667
 *                 self.set_implied_port(i)
 *                 return
 *             elif strcmp(key, b"port") == 0:             # <<<<<<<<<<<<<<
 *                 with gil:
 *                     i = value
 */
        __pyx_t_1 = ((strcmp(__pyx_v_key, ((char const *)"port")) == 0) != 0);
        if (__pyx_t_1) {

          /* "btdht/krcp.pyx":1668
 *                 return
 *             elif strcmp(key, b"port") == 0:
 *                 with gil:             # <<<<<<<<<<<<<<
 *                     i = value
 *                 self.set_port(i)
 */
          {
              #ifdef WITH_THREAD
              PyGILState_STATE __pyx_gilstate_save = __Pyx_PyGILState_Ensure();
              #endif
              /*try:*/ {

                /* "btdht/krcp.pyx":1669
 *             elif strcmp(key, b"port") == 0:
 *                 with gil:
 *                     i = value             # <<<<<<<<<<<<<<
 *                 self.set_port(i)
 *                 return
 */
                __pyx_t_5 = __Pyx_PyInt_As_int(__pyx_v_value); if (unlikely((__pyx_t_5 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 1669, __pyx_L29_error)
                __pyx_v_i = __pyx_t_5;
              }

              /* "btdht/krcp.pyx":1668
 *                 return
 *             elif strcmp(key, b"port") == 0:
 *                 with gil:             # <<<<<<<<<<<<<<
 *                     i = value
 *                 self.set_port(i)
 */
              /*finally:*/ {
                /*normal exit:*/{
                  #ifdef WITH_THREAD
                  __Pyx_PyGILState_Release(__pyx_gilstate_save);
                  #endif
                  goto __pyx_L30;
                }
                __pyx_L29_error: {
                  #ifdef WITH_THREAD
                  __Pyx_PyGILState_Release(__pyx_gilstate_save);
                  #endif
                  goto __pyx_L4_error;
                }
                __pyx_L30:;
              }
          }

          /* "btdht/krcp.pyx":1670
 *                 with gil:
 *                     i = value
 *                 self.set_port(i)             # <<<<<<<<<<<<<<
 *                 return
 *             elif strcmp(key, b"values") == 0:
 */
          (void)(((struct __pyx_vtabstruct_5btdht_4krcp_BMessage *)__pyx_v_self->__pyx_vtab)->set_port(__pyx_v_self, __pyx_v_i));

          /* "btdht/krcp.pyx":1671
 *                     i = value
 *                 self.set_port(i)
 *                 return             # <<<<<<<<<<<<<<
 *             elif strcmp(key, b"values") == 0:
 *                 with gil:
 */
          __pyx_r = 0;
          goto __pyx_L3_return;

          /* "btdht/krcp.pyx":1667
 *                 self.set_implied_port(i)
 *                 return
 *             elif strcmp(key, b"port") == 0:             # <<<<<<<<<<<<<<
 *                 with gil:
 *                     i = value
 */
        }

        /* "btdht/krcp.pyx":1672
 *                 self.set_port(i)
 *                 return
 *             elif strcmp(key, b"values") == 0:             # <<<<<<<<<<<<<<
 *                 with gil:
 *                     v = vlist_to_array(value)
 */
        __pyx_t_1 = ((strcmp(__pyx_v_key, ((char const *)"values")) == 0) != 0);
        if (__pyx_t_1) {

          /* "btdht/krcp.pyx":1673
 *                 return
 *             elif strcmp(key, b"values") == 0:
 *                 with gil:             # <<<<<<<<<<<<<<
 *                     v = vlist_to_array(value)
 *                     i = len(value)
 */
          {
              #ifdef WITH_THREAD
              PyGILState_STATE __pyx_gilstate_save = __Pyx_PyGILState_Ensure();
              #endif
              /*try:*/ {

                /* "btdht/krcp.pyx":1674
 *             elif strcmp(key, b"values") == 0:
 *                 with gil:
 *                     v = vlist_to_array(value)             # <<<<<<<<<<<<<<
 *                     i = len(value)
 *                 self.set_values(v, i)
 */
                __pyx_v_v = __pyx_f_5btdht_4krcp_vlist_to_array(__pyx_v_value, NULL);

                /* "btdht/krcp.pyx":1675
 *                 with gil:
 *                     v = vlist_to_array(value)
 *                     i = len(value)             # <<<<<<<<<<<<<<
 *                 self.set_values(v, i)
 *                 return
 */
                __pyx_t_2 = PyObject_Length(__pyx_v_value); if (unlikely(__pyx_t_2 == ((Py_ssize_t)-1))) __PYX_ERR(0, 1675, __pyx_L32_error)
                __pyx_v_i = __pyx_t_2;
              }

              /* "btdht/krcp.pyx":1673
 *                 return
 *             elif strcmp(key, b"values") == 0:
 *                 with gil:             # <<<<<<<<<<<<<<
 *                     v = vlist_to_array(value)
 *                     i = len(value)
 */
              /*finally:*/ {
                /*normal exit:*/{
                  #ifdef WITH_THREAD
                  __Pyx_PyGILState_Release(__pyx_gilstate_save);
                  #endif
                  goto __pyx_L33;
                }
                __pyx_L32_error: {
                  #ifdef WITH_THREAD
                  __Pyx_PyGILState_Release(__pyx_gilstate_save);
                  #endif
                  goto __pyx_L4_error;
                }
                __pyx_L33:;
              }
          }

          /* "btdht/krcp.pyx":1676
 *                     v = vlist_to_array(value)
 *                     i = len(value)
 *                 self.set_values(v, i)             # <<<<<<<<<<<<<<
 *                 return
 *         raise KeyError(key)
 */
          (void)(((struct __pyx_vtabstruct_5btdht_4krcp_BMessage *)__pyx_v_self->__pyx_vtab)->set_values(__pyx_v_self, __pyx_v_v, __pyx_v_i));

          /* "btdht/krcp.pyx":1677
 *                     i = len(value)
 *                 self.set_values(v, i)
 *                 return             # <<<<<<<<<<<<<<
 *         raise KeyError(key)
 * 
 */
          __pyx_r = 0;
          goto __pyx_L3_return;

          /* "btdht/krcp.pyx":1672
 *                 self.set_port(i)
 *                 return
 *             elif strcmp(key, b"values") == 0:             # <<<<<<<<<<<<<<
 *                 with gil:
 *                     v = vlist_to_array(value)
 */
        }
      }

      /* "btdht/krcp.pyx":1627
 *         cdef char** v
 *         cdef int l = 0
 *         with nogil:             # <<<<<<<<<<<<<<
 *             if strcmp(key, b"id") == 0:
 *                 with gil:
 */
      /*finally:*/ {
        /*normal exit:*/{
          #ifdef WITH_THREAD
          __Pyx_FastGIL_Forget();
          Py_BLOCK_THREADS
          #endif
          goto __pyx_L5;
        }
        __pyx_L3_return: {
          #ifdef WITH_THREAD
          __Pyx_FastGIL_Forget();
          Py_BLOCK_THREADS
          #endif
          goto __pyx_L0;
        }
        __pyx_L4_error: {
          #ifdef WITH_THREAD
          __Pyx_FastGIL_Forget();
          Py_BLOCK_THREADS
          #endif
          goto __pyx_L1_error;
        }
        __pyx_L5:;
      }
  }

  /* "btdht/krcp.pyx":1678
 *                 self.set_values(v, i)
 *                 return
 *         raise KeyError(key)             # <<<<<<<<<<<<<<
 * 
 *     def get(self, char* key, default=None):
 */
  __pyx_t_3 = __Pyx_PyBytes_FromString(__pyx_v_key); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1678, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_6 = __Pyx_PyObject_CallOneArg(__pyx_builtin_KeyError, __pyx_t_3); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1678, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __Pyx_Raise(__pyx_t_6, 0, 0, 0);
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __PYX_ERR(0, 1678, __pyx_L1_error)

  /* "btdht/krcp.pyx":1611
 *                     raise KeyError(key)
 * 
 *     def __setitem__(self, char* key, value):             # <<<<<<<<<<<<<<
 *         """
 *             Allow to set attributes from the secondary dictionnary::
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_AddTraceback("btdht.krcp.BMessage.__setitem__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "btdht/krcp.pyx":1680
 *         raise KeyError(key)
 * 
 *     def get(self, char* key, default=None):             # <<<<<<<<<<<<<<
 *         """
 *             :param bytes key: The name of an attribute of the secondary dictionnary to retreive.
 */

/* Python wrapper */
static PyObject *__pyx_pw_5btdht_4krcp_8BMessage_15get(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_5btdht_4krcp_8BMessage_14get[] = "\n            :param bytes key: The name of an attribute of the secondary dictionnary to retreive.\n            :param default: Value to return in case ``key`` is not found. The default is ``None``\n            :return: The value of ``key`` if found, else the value of ``default``.\n        ";
static PyObject *__pyx_pw_5btdht_4krcp_8BMessage_15get(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  char *__pyx_v_key;
  PyObject *__pyx_v_default = 0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("get (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_key,&__pyx_n_s_default,0};
    PyObject* values[2] = {0,0};
    values[1] = ((PyObject *)Py_None);
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_key)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_default);
          if (value) { values[1] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "get") < 0)) __PYX_ERR(0, 1680, __pyx_L3_error)
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    __pyx_v_key = __Pyx_PyObject_AsWritableString(values[0]); if (unlikely((!__pyx_v_key) && PyErr_Occurred())) __PYX_ERR(0, 1680, __pyx_L3_error)
    __pyx_v_default = values[1];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("get", 0, 1, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 1680, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("btdht.krcp.BMessage.get", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_5btdht_4krcp_8BMessage_14get(((struct __pyx_obj_5btdht_4krcp_BMessage *)__pyx_v_self), __pyx_v_key, __pyx_v_default);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5btdht_4krcp_8BMessage_14get(struct __pyx_obj_5btdht_4krcp_BMessage *__pyx_v_self, char *__pyx_v_key, PyObject *__pyx_v_default) {
  CYTHON_UNUSED PyObject *__pyx_v_e = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  int __pyx_t_6;
  PyObject *__pyx_t_7 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("get", 0);

  /* "btdht/krcp.pyx":1686
 *             :return: The value of ``key`` if found, else the value of ``default``.
 *         """
 *         try:             # <<<<<<<<<<<<<<
 *             return self[key]
 *         except KeyError as e:
 */
  {
    __Pyx_PyThreadState_declare
    __Pyx_PyThreadState_assign
    __Pyx_ExceptionSave(&__pyx_t_1, &__pyx_t_2, &__pyx_t_3);
    __Pyx_XGOTREF(__pyx_t_1);
    __Pyx_XGOTREF(__pyx_t_2);
    __Pyx_XGOTREF(__pyx_t_3);
    /*try:*/ {

      /* "btdht/krcp.pyx":1687
 *         """
 *         try:
 *             return self[key]             # <<<<<<<<<<<<<<
 *         except KeyError as e:
 *             return default
 */
      __Pyx_XDECREF(__pyx_r);
      __pyx_t_4 = __Pyx_PyBytes_FromString(__pyx_v_key); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1687, __pyx_L3_error)
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_t_5 = __Pyx_PyObject_GetItem(((PyObject *)__pyx_v_self), __pyx_t_4); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1687, __pyx_L3_error)
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __pyx_r = __pyx_t_5;
      __pyx_t_5 = 0;
      goto __pyx_L7_try_return;

      /* "btdht/krcp.pyx":1686
 *             :return: The value of ``key`` if found, else the value of ``default``.
 *         """
 *         try:             # <<<<<<<<<<<<<<
 *             return self[key]
 *         except KeyError as e:
 */
    }
    __pyx_L3_error:;
    __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;

    /* "btdht/krcp.pyx":1688
 *         try:
 *             return self[key]
 *         except KeyError as e:             # <<<<<<<<<<<<<<
 *             return default
 * 
 */
    __pyx_t_6 = __Pyx_PyErr_ExceptionMatches(__pyx_builtin_KeyError);
    if (__pyx_t_6) {
      __Pyx_AddTraceback("btdht.krcp.BMessage.get", __pyx_clineno, __pyx_lineno, __pyx_filename);
      if (__Pyx_GetException(&__pyx_t_5, &__pyx_t_4, &__pyx_t_7) < 0) __PYX_ERR(0, 1688, __pyx_L5_except_error)
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_GOTREF(__pyx_t_7);
      __Pyx_INCREF(__pyx_t_4);
      __pyx_v_e = __pyx_t_4;

      /* "btdht/krcp.pyx":1689
 *             return self[key]
 *         except KeyError as e:
 *             return default             # <<<<<<<<<<<<<<
 * 
 *     def __dealloc__(self):
 */
      __Pyx_XDECREF(__pyx_r);
      __Pyx_INCREF(__pyx_v_default);
      __pyx_r = __pyx_v_default;
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      goto __pyx_L6_except_return;
    }
    goto __pyx_L5_except_error;
    __pyx_L5_except_error:;

    /* "btdht/krcp.pyx":1686
 *             :return: The value of ``key`` if found, else the value of ``default``.
 *         """
 *         try:             # <<<<<<<<<<<<<<
 *             return self[key]
 *         except KeyError as e:
 */
    __Pyx_XGIVEREF(__pyx_t_1);
    __Pyx_XGIVEREF(__pyx_t_2);
    __Pyx_XGIVEREF(__pyx_t_3);
    __Pyx_ExceptionReset(__pyx_t_1, __pyx_t_2, __pyx_t_3);
    goto __pyx_L1_error;
    __pyx_L7_try_return:;
    __Pyx_XGIVEREF(__pyx_t_1);
    __Pyx_XGIVEREF(__pyx_t_2);
    __Pyx_XGIVEREF(__pyx_t_3);
    __Pyx_ExceptionReset(__pyx_t_1, __pyx_t_2, __pyx_t_3);
    goto __pyx_L0;
    __pyx_L6_except_return:;
    __Pyx_XGIVEREF(__pyx_t_1);
    __Pyx_XGIVEREF(__pyx_t_2);
    __Pyx_XGIVEREF(__pyx_t_3);
    __Pyx_ExceptionReset(__pyx_t_1, __pyx_t_2, __pyx_t_3);
    goto __pyx_L0;
  }

  /* "btdht/krcp.pyx":1680
 *         raise KeyError(key)
 * 
 *     def get(self, char* key, default=None):             # <<<<<<<<<<<<<<
 *         """
 *             :param bytes key: The name of an attribute of the secondary dictionnary to retreive.
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_AddTraceback("btdht.krcp.BMessage.get", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_e);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "btdht/krcp.pyx":1691
 *             return default
 * 
 *     def __dealloc__(self):             # <<<<<<<<<<<<<<
 *         """
 *             Called before removal of the object.
 */

/* Python wrapper */
static void __pyx_pw_5btdht_4krcp_8BMessage_17__dealloc__(PyObject *__pyx_v_self); /*proto*/
static void __pyx_pw_5btdht_4krcp_8BMessage_17__dealloc__(PyObject *__pyx_v_self) {
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__dealloc__ (wrapper)", 0);
  __pyx_pf_5btdht_4krcp_8BMessage_16__dealloc__(((struct __pyx_obj_5btdht_4krcp_BMessage *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
}

static void __pyx_pf_5btdht_4krcp_8BMessage_16__dealloc__(struct __pyx_obj_5btdht_4krcp_BMessage *__pyx_v_self) {
  int __pyx_v_i;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  int __pyx_t_2;
  int __pyx_t_3;
  __Pyx_RefNannySetupContext("__dealloc__", 0);

  /* "btdht/krcp.pyx":1697
 *         """
 *         cdef int i
 *         with nogil:             # <<<<<<<<<<<<<<
 *             free(self._y)
 *             free(self._t)
 */
  {
      #ifdef WITH_THREAD
      PyThreadState *_save;
      Py_UNBLOCK_THREADS
      __Pyx_FastGIL_Remember();
      #endif
      /*try:*/ {

        /* "btdht/krcp.pyx":1698
 *         cdef int i
 *         with nogil:
 *             free(self._y)             # <<<<<<<<<<<<<<
 *             free(self._t)
 *             free(self._q)
 */
        free(__pyx_v_self->_y);

        /* "btdht/krcp.pyx":1699
 *         with nogil:
 *             free(self._y)
 *             free(self._t)             # <<<<<<<<<<<<<<
 *             free(self._q)
 *             free(self._v)
 */
        free(__pyx_v_self->_t);

        /* "btdht/krcp.pyx":1700
 *             free(self._y)
 *             free(self._t)
 *             free(self._q)             # <<<<<<<<<<<<<<
 *             free(self._v)
 *             free(self.id)
 */
        free(__pyx_v_self->_q);

        /* "btdht/krcp.pyx":1701
 *             free(self._t)
 *             free(self._q)
 *             free(self._v)             # <<<<<<<<<<<<<<
 *             free(self.id)
 *             free(self.target)
 */
        free(__pyx_v_self->_v);

        /* "btdht/krcp.pyx":1702
 *             free(self._q)
 *             free(self._v)
 *             free(self.id)             # <<<<<<<<<<<<<<
 *             free(self.target)
 *             free(self.info_hash)
 */
        free(__pyx_v_self->id);

        /* "btdht/krcp.pyx":1703
 *             free(self._v)
 *             free(self.id)
 *             free(self.target)             # <<<<<<<<<<<<<<
 *             free(self.info_hash)
 *             free(self.token)
 */
        free(__pyx_v_self->target);

        /* "btdht/krcp.pyx":1704
 *             free(self.id)
 *             free(self.target)
 *             free(self.info_hash)             # <<<<<<<<<<<<<<
 *             free(self.token)
 *             free(self.nodes)
 */
        free(__pyx_v_self->info_hash);

        /* "btdht/krcp.pyx":1705
 *             free(self.target)
 *             free(self.info_hash)
 *             free(self.token)             # <<<<<<<<<<<<<<
 *             free(self.nodes)
 *             free(self.encoded)
 */
        free(__pyx_v_self->token);

        /* "btdht/krcp.pyx":1706
 *             free(self.info_hash)
 *             free(self.token)
 *             free(self.nodes)             # <<<<<<<<<<<<<<
 *             free(self.encoded)
 *             for i in prange(self.values_nb):
 */
        free(__pyx_v_self->nodes);

        /* "btdht/krcp.pyx":1707
 *             free(self.token)
 *             free(self.nodes)
 *             free(self.encoded)             # <<<<<<<<<<<<<<
 *             for i in prange(self.values_nb):
 *                 free(self.values[i])
 */
        free(__pyx_v_self->encoded);

        /* "btdht/krcp.pyx":1708
 *             free(self.nodes)
 *             free(self.encoded)
 *             for i in prange(self.values_nb):             # <<<<<<<<<<<<<<
 *                 free(self.values[i])
 *             free(self.values)
 */
        __pyx_t_1 = __pyx_v_self->values_nb;
        if ((1 == 0)) abort();
        {
            #if ((defined(__APPLE__) || defined(__OSX__)) && (defined(__GNUC__) && (__GNUC__ > 2 || (__GNUC__ == 2 && (__GNUC_MINOR__ > 95)))))
                #undef likely
                #undef unlikely
                #define likely(x)   (x)
                #define unlikely(x) (x)
            #endif
            __pyx_t_3 = (__pyx_t_1 - 0 + 1 - 1/abs(1)) / 1;
            if (__pyx_t_3 > 0)
            {
                #ifdef _OPENMP
                #pragma omp parallel
                #endif /* _OPENMP */
                {
                    #ifdef _OPENMP
                    #pragma omp for firstprivate(__pyx_v_i) lastprivate(__pyx_v_i)
                    #endif /* _OPENMP */
                    for (__pyx_t_2 = 0; __pyx_t_2 < __pyx_t_3; __pyx_t_2++){
                        {
                            __pyx_v_i = (int)(0 + 1 * __pyx_t_2);

                            /* "btdht/krcp.pyx":1709
 *             free(self.encoded)
 *             for i in prange(self.values_nb):
 *                 free(self.values[i])             # <<<<<<<<<<<<<<
 *             free(self.values)
 *             free(self._errmsg)
 */
                            free((__pyx_v_self->values[__pyx_v_i]));
                        }
                    }
                }
            }
        }
        #if ((defined(__APPLE__) || defined(__OSX__)) && (defined(__GNUC__) && (__GNUC__ > 2 || (__GNUC__ == 2 && (__GNUC_MINOR__ > 95)))))
            #undef likely
            #undef unlikely
            #define likely(x)   __builtin_expect(!!(x), 1)
            #define unlikely(x) __builtin_expect(!!(x), 0)
        #endif

        /* "btdht/krcp.pyx":1710
 *             for i in prange(self.values_nb):
 *                 free(self.values[i])
 *             free(self.values)             # <<<<<<<<<<<<<<
 *             free(self._errmsg)
 * 
 */
        free(__pyx_v_self->values);

        /* "btdht/krcp.pyx":1711
 *                 free(self.values[i])
 *             free(self.values)
 *             free(self._errmsg)             # <<<<<<<<<<<<<<
 * 
 *     cdef int _decode_error(self, char* data, int* i, int max) nogil except -1:
 */
        free(__pyx_v_self->_errmsg);
      }

      /* "btdht/krcp.pyx":1697
 *         """
 *         cdef int i
 *         with nogil:             # <<<<<<<<<<<<<<
 *             free(self._y)
 *             free(self._t)
 */
      /*finally:*/ {
        /*normal exit:*/{
          #ifdef WITH_THREAD
          __Pyx_FastGIL_Forget();
          Py_BLOCK_THREADS
          #endif
          goto __pyx_L5;
        }
        __pyx_L5:;
      }
  }

  /* "btdht/krcp.pyx":1691
 *             return default
 * 
 *     def __dealloc__(self):             # <<<<<<<<<<<<<<
 *         """
 *             Called before removal of the object.
 */

  /* function exit code */
  __Pyx_RefNannyFinishContext();
}

/* "btdht/krcp.pyx":1713
 *             free(self._errmsg)
 * 
 *     cdef int _decode_error(self, char* data, int* i, int max) nogil except -1:             # <<<<<<<<<<<<<<
 *         """
 *             Decode and error bencoded list from ``data[i:]`` and set the message attributes errorno
 */

static int __pyx_f_5btdht_4krcp_8BMessage__decode_error(struct __pyx_obj_5btdht_4krcp_BMessage *__pyx_v_self, char *__pyx_v_data, int *__pyx_v_i, int __pyx_v_max) {
  int __pyx_v_j[1];
  PY_LONG_LONG __pyx_v_ll[1];
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  PyObject *__pyx_t_7 = NULL;
  long __pyx_t_8;
  int __pyx_t_9;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  #ifdef WITH_THREAD
  PyGILState_STATE __pyx_gilstate_save = __Pyx_PyGILState_Ensure();
  #endif
  __Pyx_RefNannySetupContext("_decode_error", 0);
  #ifdef WITH_THREAD
  __Pyx_PyGILState_Release(__pyx_gilstate_save);
  #endif

  /* "btdht/krcp.pyx":1714
 * 
 *     cdef int _decode_error(self, char* data, int* i, int max) nogil except -1:
 *         """             # <<<<<<<<<<<<<<
 *             Decode and error bencoded list from ``data[i:]`` and set the message attributes errorno
 *             and errormsg.
 */
  /*try:*/ {

    /* "btdht/krcp.pyx":1728
 *         cdef int j[1]
 *         cdef long long ll[1]
 *         if i[0] > max:             # <<<<<<<<<<<<<<
 *             with gil:
 *                 raise DecodeError("%s > %s : %r" % (i[0], max, data[:max]))
 */
    __pyx_t_1 = (((__pyx_v_i[0]) > __pyx_v_max) != 0);
    if (__pyx_t_1) {

      /* "btdht/krcp.pyx":1729
 *         cdef long long ll[1]
 *         if i[0] > max:
 *             with gil:             # <<<<<<<<<<<<<<
 *                 raise DecodeError("%s > %s : %r" % (i[0], max, data[:max]))
 *         if data[i[0]] != b'l':
 */
      {
          #ifdef WITH_THREAD
          PyGILState_STATE __pyx_gilstate_save = __Pyx_PyGILState_Ensure();
          #endif
          /*try:*/ {

            /* "btdht/krcp.pyx":1730
 *         if i[0] > max:
 *             with gil:
 *                 raise DecodeError("%s > %s : %r" % (i[0], max, data[:max]))             # <<<<<<<<<<<<<<
 *         if data[i[0]] != b'l':
 *             return False
 */
            __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_DecodeError); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1730, __pyx_L8_error)
            __Pyx_GOTREF(__pyx_t_3);
            __pyx_t_4 = __Pyx_PyInt_From_int((__pyx_v_i[0])); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1730, __pyx_L8_error)
            __Pyx_GOTREF(__pyx_t_4);
            __pyx_t_5 = __Pyx_PyInt_From_int(__pyx_v_max); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1730, __pyx_L8_error)
            __Pyx_GOTREF(__pyx_t_5);
            __pyx_t_6 = __Pyx_PyBytes_FromStringAndSize(__pyx_v_data + 0, __pyx_v_max - 0); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1730, __pyx_L8_error)
            __Pyx_GOTREF(__pyx_t_6);
            __pyx_t_7 = PyTuple_New(3); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1730, __pyx_L8_error)
            __Pyx_GOTREF(__pyx_t_7);
            __Pyx_GIVEREF(__pyx_t_4);
            PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_4);
            __Pyx_GIVEREF(__pyx_t_5);
            PyTuple_SET_ITEM(__pyx_t_7, 1, __pyx_t_5);
            __Pyx_GIVEREF(__pyx_t_6);
            PyTuple_SET_ITEM(__pyx_t_7, 2, __pyx_t_6);
            __pyx_t_4 = 0;
            __pyx_t_5 = 0;
            __pyx_t_6 = 0;
            __pyx_t_6 = __Pyx_PyString_Format(__pyx_kp_s_s_s_r, __pyx_t_7); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1730, __pyx_L8_error)
            __Pyx_GOTREF(__pyx_t_6);
            __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
            __pyx_t_7 = NULL;
            if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
              __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_3);
              if (likely(__pyx_t_7)) {
                PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
                __Pyx_INCREF(__pyx_t_7);
                __Pyx_INCREF(function);
                __Pyx_DECREF_SET(__pyx_t_3, function);
              }
            }
            __pyx_t_2 = (__pyx_t_7) ? __Pyx_PyObject_Call2Args(__pyx_t_3, __pyx_t_7, __pyx_t_6) : __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_6);
            __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
            __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
            if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1730, __pyx_L8_error)
            __Pyx_GOTREF(__pyx_t_2);
            __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
            __Pyx_Raise(__pyx_t_2, 0, 0, 0);
            __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
            __PYX_ERR(0, 1730, __pyx_L8_error)
          }

          /* "btdht/krcp.pyx":1729
 *         cdef long long ll[1]
 *         if i[0] > max:
 *             with gil:             # <<<<<<<<<<<<<<
 *                 raise DecodeError("%s > %s : %r" % (i[0], max, data[:max]))
 *         if data[i[0]] != b'l':
 */
          /*finally:*/ {
            __pyx_L8_error: {
              #ifdef WITH_THREAD
              __Pyx_PyGILState_Release(__pyx_gilstate_save);
              #endif
              goto __pyx_L4_error;
            }
          }
      }

      /* "btdht/krcp.pyx":1728
 *         cdef int j[1]
 *         cdef long long ll[1]
 *         if i[0] > max:             # <<<<<<<<<<<<<<
 *             with gil:
 *                 raise DecodeError("%s > %s : %r" % (i[0], max, data[:max]))
 */
    }

    /* "btdht/krcp.pyx":1731
 *             with gil:
 *                 raise DecodeError("%s > %s : %r" % (i[0], max, data[:max]))
 *         if data[i[0]] != b'l':             # <<<<<<<<<<<<<<
 *             return False
 *         i[0]+=1
 */
    __pyx_t_1 = (((__pyx_v_data[(__pyx_v_i[0])]) != 'l') != 0);
    if (__pyx_t_1) {

      /* "btdht/krcp.pyx":1732
 *                 raise DecodeError("%s > %s : %r" % (i[0], max, data[:max]))
 *         if data[i[0]] != b'l':
 *             return False             # <<<<<<<<<<<<<<
 *         i[0]+=1
 *         if not _decode_int(data, i, max, ll):
 */
      __pyx_r = 0;
      goto __pyx_L3_return;

      /* "btdht/krcp.pyx":1731
 *             with gil:
 *                 raise DecodeError("%s > %s : %r" % (i[0], max, data[:max]))
 *         if data[i[0]] != b'l':             # <<<<<<<<<<<<<<
 *             return False
 *         i[0]+=1
 */
    }

    /* "btdht/krcp.pyx":1733
 *         if data[i[0]] != b'l':
 *             return False
 *         i[0]+=1             # <<<<<<<<<<<<<<
 *         if not _decode_int(data, i, max, ll):
 *             return False
 */
    __pyx_t_8 = 0;
    (__pyx_v_i[__pyx_t_8]) = ((__pyx_v_i[__pyx_t_8]) + 1);

    /* "btdht/krcp.pyx":1734
 *             return False
 *         i[0]+=1
 *         if not _decode_int(data, i, max, ll):             # <<<<<<<<<<<<<<
 *             return False
 *         self.set_errno(ll[0])
 */
    __pyx_t_8 = __pyx_f_5btdht_4krcp__decode_int(__pyx_v_data, __pyx_v_i, __pyx_v_max, __pyx_v_ll); if (unlikely(__pyx_t_8 == ((long)-1L))) __PYX_ERR(0, 1734, __pyx_L4_error)
    __pyx_t_1 = ((!(__pyx_t_8 != 0)) != 0);
    if (__pyx_t_1) {

      /* "btdht/krcp.pyx":1735
 *         i[0]+=1
 *         if not _decode_int(data, i, max, ll):
 *             return False             # <<<<<<<<<<<<<<
 *         self.set_errno(ll[0])
 *         if not _decode_string(data, i, max, j):
 */
      __pyx_r = 0;
      goto __pyx_L3_return;

      /* "btdht/krcp.pyx":1734
 *             return False
 *         i[0]+=1
 *         if not _decode_int(data, i, max, ll):             # <<<<<<<<<<<<<<
 *             return False
 *         self.set_errno(ll[0])
 */
    }

    /* "btdht/krcp.pyx":1736
 *         if not _decode_int(data, i, max, ll):
 *             return False
 *         self.set_errno(ll[0])             # <<<<<<<<<<<<<<
 *         if not _decode_string(data, i, max, j):
 *             return False
 */
    (void)(((struct __pyx_vtabstruct_5btdht_4krcp_BMessage *)__pyx_v_self->__pyx_vtab)->set_errno(__pyx_v_self, (__pyx_v_ll[0])));

    /* "btdht/krcp.pyx":1737
 *             return False
 *         self.set_errno(ll[0])
 *         if not _decode_string(data, i, max, j):             # <<<<<<<<<<<<<<
 *             return False
 *         self.set_errmsg(data + j[0], i[0]-j[0])
 */
    __pyx_t_9 = __pyx_f_5btdht_4krcp__decode_string(__pyx_v_data, __pyx_v_i, __pyx_v_max, __pyx_v_j); if (unlikely(__pyx_t_9 == ((int)-1))) __PYX_ERR(0, 1737, __pyx_L4_error)
    __pyx_t_1 = ((!(__pyx_t_9 != 0)) != 0);
    if (__pyx_t_1) {

      /* "btdht/krcp.pyx":1738
 *         self.set_errno(ll[0])
 *         if not _decode_string(data, i, max, j):
 *             return False             # <<<<<<<<<<<<<<
 *         self.set_errmsg(data + j[0], i[0]-j[0])
 *         if data[i[0]] != b'e':
 */
      __pyx_r = 0;
      goto __pyx_L3_return;

      /* "btdht/krcp.pyx":1737
 *             return False
 *         self.set_errno(ll[0])
 *         if not _decode_string(data, i, max, j):             # <<<<<<<<<<<<<<
 *             return False
 *         self.set_errmsg(data + j[0], i[0]-j[0])
 */
    }

    /* "btdht/krcp.pyx":1739
 *         if not _decode_string(data, i, max, j):
 *             return False
 *         self.set_errmsg(data + j[0], i[0]-j[0])             # <<<<<<<<<<<<<<
 *         if data[i[0]] != b'e':
 *             return False
 */
    (void)(((struct __pyx_vtabstruct_5btdht_4krcp_BMessage *)__pyx_v_self->__pyx_vtab)->set_errmsg(__pyx_v_self, (__pyx_v_data + (__pyx_v_j[0])), ((__pyx_v_i[0]) - (__pyx_v_j[0]))));

    /* "btdht/krcp.pyx":1740
 *             return False
 *         self.set_errmsg(data + j[0], i[0]-j[0])
 *         if data[i[0]] != b'e':             # <<<<<<<<<<<<<<
 *             return False
 *         i[0]+=1
 */
    __pyx_t_1 = (((__pyx_v_data[(__pyx_v_i[0])]) != 'e') != 0);
    if (__pyx_t_1) {

      /* "btdht/krcp.pyx":1741
 *         self.set_errmsg(data + j[0], i[0]-j[0])
 *         if data[i[0]] != b'e':
 *             return False             # <<<<<<<<<<<<<<
 *         i[0]+=1
 *         return True
 */
      __pyx_r = 0;
      goto __pyx_L3_return;

      /* "btdht/krcp.pyx":1740
 *             return False
 *         self.set_errmsg(data + j[0], i[0]-j[0])
 *         if data[i[0]] != b'e':             # <<<<<<<<<<<<<<
 *             return False
 *         i[0]+=1
 */
    }

    /* "btdht/krcp.pyx":1742
 *         if data[i[0]] != b'e':
 *             return False
 *         i[0]+=1             # <<<<<<<<<<<<<<
 *         return True
 * 
 */
    __pyx_t_8 = 0;
    (__pyx_v_i[__pyx_t_8]) = ((__pyx_v_i[__pyx_t_8]) + 1);

    /* "btdht/krcp.pyx":1743
 *             return False
 *         i[0]+=1
 *         return True             # <<<<<<<<<<<<<<
 * 
 *     cdef int _decode_dict_elm(self, char* data, int* i, int max) nogil except -1:
 */
    __pyx_r = 1;
    goto __pyx_L3_return;
  }

  /* "btdht/krcp.pyx":1714
 * 
 *     cdef int _decode_error(self, char* data, int* i, int max) nogil except -1:
 *         """             # <<<<<<<<<<<<<<
 *             Decode and error bencoded list from ``data[i:]`` and set the message attributes errorno
 *             and errormsg.
 */
  /*finally:*/ {
    __pyx_L3_return: {
      #ifdef WITH_THREAD
      __pyx_gilstate_save = __Pyx_PyGILState_Ensure();
      #endif
      goto __pyx_L0;
    }
    __pyx_L4_error: {
      #ifdef WITH_THREAD
      __pyx_gilstate_save = __Pyx_PyGILState_Ensure();
      #endif
      goto __pyx_L1_error;
    }
  }

  /* "btdht/krcp.pyx":1713
 *             free(self._errmsg)
 * 
 *     cdef int _decode_error(self, char* data, int* i, int max) nogil except -1:             # <<<<<<<<<<<<<<
 *         """
 *             Decode and error bencoded list from ``data[i:]`` and set the message attributes errorno
 */

  /* function exit code */
  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_AddTraceback("btdht.krcp.BMessage._decode_error", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  #ifdef WITH_THREAD
  __Pyx_PyGILState_Release(__pyx_gilstate_save);
  #endif
  return __pyx_r;
}

/* "btdht/krcp.pyx":1745
 *         return True
 * 
 *     cdef int _decode_dict_elm(self, char* data, int* i, int max) nogil except -1:             # <<<<<<<<<<<<<<
 *         """
 *             Decode a dictionnary element: a key and a value. Set the corresponding attributes
 */

static int __pyx_f_5btdht_4krcp_8BMessage__decode_dict_elm(struct __pyx_obj_5btdht_4krcp_BMessage *__pyx_v_self, char *__pyx_v_data, int *__pyx_v_i, int __pyx_v_max) {
  int __pyx_v_j[1];
  PY_LONG_LONG __pyx_v_ll[1];
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  int __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  PyObject *__pyx_t_7 = NULL;
  int __pyx_t_8;
  int __pyx_t_9;
  long __pyx_t_10;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  #ifdef WITH_THREAD
  PyGILState_STATE __pyx_gilstate_save = __Pyx_PyGILState_Ensure();
  #endif
  __Pyx_RefNannySetupContext("_decode_dict_elm", 0);
  #ifdef WITH_THREAD
  __Pyx_PyGILState_Release(__pyx_gilstate_save);
  #endif

  /* "btdht/krcp.pyx":1746
 * 
 *     cdef int _decode_dict_elm(self, char* data, int* i, int max) nogil except -1:
 *         """             # <<<<<<<<<<<<<<
 *             Decode a dictionnary element: a key and a value. Set the corresponding attributes
 *             on the message.
 */
  /*try:*/ {

    /* "btdht/krcp.pyx":1769
 *         cdef int j[1]
 *         cdef long long ll[1]
 *         j[0]=0             # <<<<<<<<<<<<<<
 *         if not _decode_string(data, i, max, j):
 *             with gil:
 */
    (__pyx_v_j[0]) = 0;

    /* "btdht/krcp.pyx":1770
 *         cdef long long ll[1]
 *         j[0]=0
 *         if not _decode_string(data, i, max, j):             # <<<<<<<<<<<<<<
 *             with gil:
 *                 raise DecodeError("Fail to decode dict key %d %s" % (i[0], data[:max]))
 */
    __pyx_t_1 = __pyx_f_5btdht_4krcp__decode_string(__pyx_v_data, __pyx_v_i, __pyx_v_max, __pyx_v_j); if (unlikely(__pyx_t_1 == ((int)-1))) __PYX_ERR(0, 1770, __pyx_L4_error)
    __pyx_t_2 = ((!(__pyx_t_1 != 0)) != 0);
    if (__pyx_t_2) {

      /* "btdht/krcp.pyx":1771
 *         j[0]=0
 *         if not _decode_string(data, i, max, j):
 *             with gil:             # <<<<<<<<<<<<<<
 *                 raise DecodeError("Fail to decode dict key %d %s" % (i[0], data[:max]))
 * 
 */
      {
          #ifdef WITH_THREAD
          PyGILState_STATE __pyx_gilstate_save = __Pyx_PyGILState_Ensure();
          #endif
          /*try:*/ {

            /* "btdht/krcp.pyx":1772
 *         if not _decode_string(data, i, max, j):
 *             with gil:
 *                 raise DecodeError("Fail to decode dict key %d %s" % (i[0], data[:max]))             # <<<<<<<<<<<<<<
 * 
 *         if (i[0]-j[0]) == 1 and strncmp(data + j[0], b"a", i[0]-j[0]) == 0:
 */
            __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_DecodeError); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1772, __pyx_L8_error)
            __Pyx_GOTREF(__pyx_t_4);
            __pyx_t_5 = __Pyx_PyInt_From_int((__pyx_v_i[0])); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1772, __pyx_L8_error)
            __Pyx_GOTREF(__pyx_t_5);
            __pyx_t_6 = __Pyx_PyBytes_FromStringAndSize(__pyx_v_data + 0, __pyx_v_max - 0); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1772, __pyx_L8_error)
            __Pyx_GOTREF(__pyx_t_6);
            __pyx_t_7 = PyTuple_New(2); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1772, __pyx_L8_error)
            __Pyx_GOTREF(__pyx_t_7);
            __Pyx_GIVEREF(__pyx_t_5);
            PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_5);
            __Pyx_GIVEREF(__pyx_t_6);
            PyTuple_SET_ITEM(__pyx_t_7, 1, __pyx_t_6);
            __pyx_t_5 = 0;
            __pyx_t_6 = 0;
            __pyx_t_6 = __Pyx_PyString_Format(__pyx_kp_s_Fail_to_decode_dict_key_d_s, __pyx_t_7); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1772, __pyx_L8_error)
            __Pyx_GOTREF(__pyx_t_6);
            __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
            __pyx_t_7 = NULL;
            if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_4))) {
              __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_4);
              if (likely(__pyx_t_7)) {
                PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
                __Pyx_INCREF(__pyx_t_7);
                __Pyx_INCREF(function);
                __Pyx_DECREF_SET(__pyx_t_4, function);
              }
            }
            __pyx_t_3 = (__pyx_t_7) ? __Pyx_PyObject_Call2Args(__pyx_t_4, __pyx_t_7, __pyx_t_6) : __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_6);
            __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
            __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
            if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1772, __pyx_L8_error)
            __Pyx_GOTREF(__pyx_t_3);
            __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
            __Pyx_Raise(__pyx_t_3, 0, 0, 0);
            __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
            __PYX_ERR(0, 1772, __pyx_L8_error)
          }

          /* "btdht/krcp.pyx":1771
 *         j[0]=0
 *         if not _decode_string(data, i, max, j):
 *             with gil:             # <<<<<<<<<<<<<<
 *                 raise DecodeError("Fail to decode dict key %d %s" % (i[0], data[:max]))
 * 
 */
          /*finally:*/ {
            __pyx_L8_error: {
              #ifdef WITH_THREAD
              __Pyx_PyGILState_Release(__pyx_gilstate_save);
              #endif
              goto __pyx_L4_error;
            }
          }
      }

      /* "btdht/krcp.pyx":1770
 *         cdef long long ll[1]
 *         j[0]=0
 *         if not _decode_string(data, i, max, j):             # <<<<<<<<<<<<<<
 *             with gil:
 *                 raise DecodeError("Fail to decode dict key %d %s" % (i[0], data[:max]))
 */
    }

    /* "btdht/krcp.pyx":1774
 *                 raise DecodeError("Fail to decode dict key %d %s" % (i[0], data[:max]))
 * 
 *         if (i[0]-j[0]) == 1 and strncmp(data + j[0], b"a", i[0]-j[0]) == 0:             # <<<<<<<<<<<<<<
 *             return self._decode_dict(data, i, max) and self.set_a(True)
 *         elif (i[0]-j[0]) == 1 and strncmp(data + j[0], b"r", i[0]-j[0]) == 0:
 */
    __pyx_t_8 = ((((__pyx_v_i[0]) - (__pyx_v_j[0])) == 1) != 0);
    if (__pyx_t_8) {
    } else {
      __pyx_t_2 = __pyx_t_8;
      goto __pyx_L11_bool_binop_done;
    }
    __pyx_t_8 = ((strncmp((__pyx_v_data + (__pyx_v_j[0])), ((char const *)"a"), ((__pyx_v_i[0]) - (__pyx_v_j[0]))) == 0) != 0);
    __pyx_t_2 = __pyx_t_8;
    __pyx_L11_bool_binop_done:;
    if (__pyx_t_2) {

      /* "btdht/krcp.pyx":1775
 * 
 *         if (i[0]-j[0]) == 1 and strncmp(data + j[0], b"a", i[0]-j[0]) == 0:
 *             return self._decode_dict(data, i, max) and self.set_a(True)             # <<<<<<<<<<<<<<
 *         elif (i[0]-j[0]) == 1 and strncmp(data + j[0], b"r", i[0]-j[0]) == 0:
 *             return self._decode_dict(data, i, max) and self.set_r(True)
 */
      __pyx_t_9 = ((struct __pyx_vtabstruct_5btdht_4krcp_BMessage *)__pyx_v_self->__pyx_vtab)->_decode_dict(__pyx_v_self, __pyx_v_data, __pyx_v_i, __pyx_v_max); if (unlikely(__pyx_t_9 == ((int)-1))) __PYX_ERR(0, 1775, __pyx_L4_error)
      if (__pyx_t_9) {
      } else {
        __pyx_t_1 = __pyx_t_9;
        goto __pyx_L13_bool_binop_done;
      }
      __pyx_t_9 = ((struct __pyx_vtabstruct_5btdht_4krcp_BMessage *)__pyx_v_self->__pyx_vtab)->set_a(__pyx_v_self, 1);
      __pyx_t_1 = __pyx_t_9;
      __pyx_L13_bool_binop_done:;
      __pyx_r = __pyx_t_1;
      goto __pyx_L3_return;

      /* "btdht/krcp.pyx":1774
 *                 raise DecodeError("Fail to decode dict key %d %s" % (i[0], data[:max]))
 * 
 *         if (i[0]-j[0]) == 1 and strncmp(data + j[0], b"a", i[0]-j[0]) == 0:             # <<<<<<<<<<<<<<
 *             return self._decode_dict(data, i, max) and self.set_a(True)
 *         elif (i[0]-j[0]) == 1 and strncmp(data + j[0], b"r", i[0]-j[0]) == 0:
 */
    }

    /* "btdht/krcp.pyx":1776
 *         if (i[0]-j[0]) == 1 and strncmp(data + j[0], b"a", i[0]-j[0]) == 0:
 *             return self._decode_dict(data, i, max) and self.set_a(True)
 *         elif (i[0]-j[0]) == 1 and strncmp(data + j[0], b"r", i[0]-j[0]) == 0:             # <<<<<<<<<<<<<<
 *             return self._decode_dict(data, i, max) and self.set_r(True)
 *         elif (i[0]-j[0]) == 1 and strncmp(data + j[0], b"e", i[0]-j[0]) == 0:
 */
    __pyx_t_8 = ((((__pyx_v_i[0]) - (__pyx_v_j[0])) == 1) != 0);
    if (__pyx_t_8) {
    } else {
      __pyx_t_2 = __pyx_t_8;
      goto __pyx_L15_bool_binop_done;
    }
    __pyx_t_8 = ((strncmp((__pyx_v_data + (__pyx_v_j[0])), ((char const *)"r"), ((__pyx_v_i[0]) - (__pyx_v_j[0]))) == 0) != 0);
    __pyx_t_2 = __pyx_t_8;
    __pyx_L15_bool_binop_done:;
    if (__pyx_t_2) {

      /* "btdht/krcp.pyx":1777
 *             return self._decode_dict(data, i, max) and self.set_a(True)
 *         elif (i[0]-j[0]) == 1 and strncmp(data + j[0], b"r", i[0]-j[0]) == 0:
 *             return self._decode_dict(data, i, max) and self.set_r(True)             # <<<<<<<<<<<<<<
 *         elif (i[0]-j[0]) == 1 and strncmp(data + j[0], b"e", i[0]-j[0]) == 0:
 *             return self._decode_error(data, i, max) and self.set_e(True)
 */
      __pyx_t_9 = ((struct __pyx_vtabstruct_5btdht_4krcp_BMessage *)__pyx_v_self->__pyx_vtab)->_decode_dict(__pyx_v_self, __pyx_v_data, __pyx_v_i, __pyx_v_max); if (unlikely(__pyx_t_9 == ((int)-1))) __PYX_ERR(0, 1777, __pyx_L4_error)
      if (__pyx_t_9) {
      } else {
        __pyx_t_1 = __pyx_t_9;
        goto __pyx_L17_bool_binop_done;
      }
      __pyx_t_9 = ((struct __pyx_vtabstruct_5btdht_4krcp_BMessage *)__pyx_v_self->__pyx_vtab)->set_r(__pyx_v_self, 1);
      __pyx_t_1 = __pyx_t_9;
      __pyx_L17_bool_binop_done:;
      __pyx_r = __pyx_t_1;
      goto __pyx_L3_return;

      /* "btdht/krcp.pyx":1776
 *         if (i[0]-j[0]) == 1 and strncmp(data + j[0], b"a", i[0]-j[0]) == 0:
 *             return self._decode_dict(data, i, max) and self.set_a(True)
 *         elif (i[0]-j[0]) == 1 and strncmp(data + j[0], b"r", i[0]-j[0]) == 0:             # <<<<<<<<<<<<<<
 *             return self._decode_dict(data, i, max) and self.set_r(True)
 *         elif (i[0]-j[0]) == 1 and strncmp(data + j[0], b"e", i[0]-j[0]) == 0:
 */
    }

    /* "btdht/krcp.pyx":1778
 *         elif (i[0]-j[0]) == 1 and strncmp(data + j[0], b"r", i[0]-j[0]) == 0:
 *             return self._decode_dict(data, i, max) and self.set_r(True)
 *         elif (i[0]-j[0]) == 1 and strncmp(data + j[0], b"e", i[0]-j[0]) == 0:             # <<<<<<<<<<<<<<
 *             return self._decode_error(data, i, max) and self.set_e(True)
 *         elif (i[0]-j[0]) == 1 and strncmp(data + j[0], b"t", i[0]-j[0]) == 0:
 */
    __pyx_t_8 = ((((__pyx_v_i[0]) - (__pyx_v_j[0])) == 1) != 0);
    if (__pyx_t_8) {
    } else {
      __pyx_t_2 = __pyx_t_8;
      goto __pyx_L19_bool_binop_done;
    }
    __pyx_t_8 = ((strncmp((__pyx_v_data + (__pyx_v_j[0])), ((char const *)"e"), ((__pyx_v_i[0]) - (__pyx_v_j[0]))) == 0) != 0);
    __pyx_t_2 = __pyx_t_8;
    __pyx_L19_bool_binop_done:;
    if (__pyx_t_2) {

      /* "btdht/krcp.pyx":1779
 *             return self._decode_dict(data, i, max) and self.set_r(True)
 *         elif (i[0]-j[0]) == 1 and strncmp(data + j[0], b"e", i[0]-j[0]) == 0:
 *             return self._decode_error(data, i, max) and self.set_e(True)             # <<<<<<<<<<<<<<
 *         elif (i[0]-j[0]) == 1 and strncmp(data + j[0], b"t", i[0]-j[0]) == 0:
 *             return _decode_string(data, i, max, j) and self.set_t(data + j[0], i[0]-j[0])
 */
      __pyx_t_9 = ((struct __pyx_vtabstruct_5btdht_4krcp_BMessage *)__pyx_v_self->__pyx_vtab)->_decode_error(__pyx_v_self, __pyx_v_data, __pyx_v_i, __pyx_v_max); if (unlikely(__pyx_t_9 == ((int)-1))) __PYX_ERR(0, 1779, __pyx_L4_error)
      if (__pyx_t_9) {
      } else {
        __pyx_t_1 = __pyx_t_9;
        goto __pyx_L21_bool_binop_done;
      }
      __pyx_t_9 = ((struct __pyx_vtabstruct_5btdht_4krcp_BMessage *)__pyx_v_self->__pyx_vtab)->set_e(__pyx_v_self, 1);
      __pyx_t_1 = __pyx_t_9;
      __pyx_L21_bool_binop_done:;
      __pyx_r = __pyx_t_1;
      goto __pyx_L3_return;

      /* "btdht/krcp.pyx":1778
 *         elif (i[0]-j[0]) == 1 and strncmp(data + j[0], b"r", i[0]-j[0]) == 0:
 *             return self._decode_dict(data, i, max) and self.set_r(True)
 *         elif (i[0]-j[0]) == 1 and strncmp(data + j[0], b"e", i[0]-j[0]) == 0:             # <<<<<<<<<<<<<<
 *             return self._decode_error(data, i, max) and self.set_e(True)
 *         elif (i[0]-j[0]) == 1 and strncmp(data + j[0], b"t", i[0]-j[0]) == 0:
 */
    }

    /* "btdht/krcp.pyx":1780
 *         elif (i[0]-j[0]) == 1 and strncmp(data + j[0], b"e", i[0]-j[0]) == 0:
 *             return self._decode_error(data, i, max) and self.set_e(True)
 *         elif (i[0]-j[0]) == 1 and strncmp(data + j[0], b"t", i[0]-j[0]) == 0:             # <<<<<<<<<<<<<<
 *             return _decode_string(data, i, max, j) and self.set_t(data + j[0], i[0]-j[0])
 *         elif (i[0]-j[0]) == 1 and strncmp(data + j[0], b"v", i[0]-j[0]) == 0:
 */
    __pyx_t_8 = ((((__pyx_v_i[0]) - (__pyx_v_j[0])) == 1) != 0);
    if (__pyx_t_8) {
    } else {
      __pyx_t_2 = __pyx_t_8;
      goto __pyx_L23_bool_binop_done;
    }
    __pyx_t_8 = ((strncmp((__pyx_v_data + (__pyx_v_j[0])), ((char const *)"t"), ((__pyx_v_i[0]) - (__pyx_v_j[0]))) == 0) != 0);
    __pyx_t_2 = __pyx_t_8;
    __pyx_L23_bool_binop_done:;
    if (__pyx_t_2) {

      /* "btdht/krcp.pyx":1781
 *             return self._decode_error(data, i, max) and self.set_e(True)
 *         elif (i[0]-j[0]) == 1 and strncmp(data + j[0], b"t", i[0]-j[0]) == 0:
 *             return _decode_string(data, i, max, j) and self.set_t(data + j[0], i[0]-j[0])             # <<<<<<<<<<<<<<
 *         elif (i[0]-j[0]) == 1 and strncmp(data + j[0], b"v", i[0]-j[0]) == 0:
 *             return _decode_string(data, i, max, j) and self.set_v(data + j[0], i[0]-j[0])
 */
      __pyx_t_9 = __pyx_f_5btdht_4krcp__decode_string(__pyx_v_data, __pyx_v_i, __pyx_v_max, __pyx_v_j); if (unlikely(__pyx_t_9 == ((int)-1))) __PYX_ERR(0, 1781, __pyx_L4_error)
      if (__pyx_t_9) {
      } else {
        __pyx_t_1 = __pyx_t_9;
        goto __pyx_L25_bool_binop_done;
      }
      __pyx_t_9 = ((struct __pyx_vtabstruct_5btdht_4krcp_BMessage *)__pyx_v_self->__pyx_vtab)->set_t(__pyx_v_self, (__pyx_v_data + (__pyx_v_j[0])), ((__pyx_v_i[0]) - (__pyx_v_j[0])));
      __pyx_t_1 = __pyx_t_9;
      __pyx_L25_bool_binop_done:;
      __pyx_r = __pyx_t_1;
      goto __pyx_L3_return;

      /* "btdht/krcp.pyx":1780
 *         elif (i[0]-j[0]) == 1 and strncmp(data + j[0], b"e", i[0]-j[0]) == 0:
 *             return self._decode_error(data, i, max) and self.set_e(True)
 *         elif (i[0]-j[0]) == 1 and strncmp(data + j[0], b"t", i[0]-j[0]) == 0:             # <<<<<<<<<<<<<<
 *             return _decode_string(data, i, max, j) and self.set_t(data + j[0], i[0]-j[0])
 *         elif (i[0]-j[0]) == 1 and strncmp(data + j[0], b"v", i[0]-j[0]) == 0:
 */
    }

    /* "btdht/krcp.pyx":1782
 *         elif (i[0]-j[0]) == 1 and strncmp(data + j[0], b"t", i[0]-j[0]) == 0:
 *             return _decode_string(data, i, max, j) and self.set_t(data + j[0], i[0]-j[0])
 *         elif (i[0]-j[0]) == 1 and strncmp(data + j[0], b"v", i[0]-j[0]) == 0:             # <<<<<<<<<<<<<<
 *             return _decode_string(data, i, max, j) and self.set_v(data + j[0], i[0]-j[0])
 *         elif (i[0]-j[0]) == 1 and strncmp(data + j[0], b"y", i[0]-j[0]) == 0:
 */
    __pyx_t_8 = ((((__pyx_v_i[0]) - (__pyx_v_j[0])) == 1) != 0);
    if (__pyx_t_8) {
    } else {
      __pyx_t_2 = __pyx_t_8;
      goto __pyx_L27_bool_binop_done;
    }
    __pyx_t_8 = ((strncmp((__pyx_v_data + (__pyx_v_j[0])), ((char const *)"v"), ((__pyx_v_i[0]) - (__pyx_v_j[0]))) == 0) != 0);
    __pyx_t_2 = __pyx_t_8;
    __pyx_L27_bool_binop_done:;
    if (__pyx_t_2) {

      /* "btdht/krcp.pyx":1783
 *             return _decode_string(data, i, max, j) and self.set_t(data + j[0], i[0]-j[0])
 *         elif (i[0]-j[0]) == 1 and strncmp(data + j[0], b"v", i[0]-j[0]) == 0:
 *             return _decode_string(data, i, max, j) and self.set_v(data + j[0], i[0]-j[0])             # <<<<<<<<<<<<<<
 *         elif (i[0]-j[0]) == 1 and strncmp(data + j[0], b"y", i[0]-j[0]) == 0:
 *             return _decode_string(data, i, max, j) and self.set_y(data + j[0], i[0]-j[0])
 */
      __pyx_t_9 = __pyx_f_5btdht_4krcp__decode_string(__pyx_v_data, __pyx_v_i, __pyx_v_max, __pyx_v_j); if (unlikely(__pyx_t_9 == ((int)-1))) __PYX_ERR(0, 1783, __pyx_L4_error)
      if (__pyx_t_9) {
      } else {
        __pyx_t_1 = __pyx_t_9;
        goto __pyx_L29_bool_binop_done;
      }
      __pyx_t_9 = ((struct __pyx_vtabstruct_5btdht_4krcp_BMessage *)__pyx_v_self->__pyx_vtab)->set_v(__pyx_v_self, (__pyx_v_data + (__pyx_v_j[0])), ((__pyx_v_i[0]) - (__pyx_v_j[0])));
      __pyx_t_1 = __pyx_t_9;
      __pyx_L29_bool_binop_done:;
      __pyx_r = __pyx_t_1;
      goto __pyx_L3_return;

      /* "btdht/krcp.pyx":1782
 *         elif (i[0]-j[0]) == 1 and strncmp(data + j[0], b"t", i[0]-j[0]) == 0:
 *             return _decode_string(data, i, max, j) and self.set_t(data + j[0], i[0]-j[0])
 *         elif (i[0]-j[0]) == 1 and strncmp(data + j[0], b"v", i[0]-j[0]) == 0:             # <<<<<<<<<<<<<<
 *             return _decode_string(data, i, max, j) and self.set_v(data + j[0], i[0]-j[0])
 *         elif (i[0]-j[0]) == 1 and strncmp(data + j[0], b"y", i[0]-j[0]) == 0:
 */
    }

    /* "btdht/krcp.pyx":1784
 *         elif (i[0]-j[0]) == 1 and strncmp(data + j[0], b"v", i[0]-j[0]) == 0:
 *             return _decode_string(data, i, max, j) and self.set_v(data + j[0], i[0]-j[0])
 *         elif (i[0]-j[0]) == 1 and strncmp(data + j[0], b"y", i[0]-j[0]) == 0:             # <<<<<<<<<<<<<<
 *             return _decode_string(data, i, max, j) and self.set_y(data + j[0], i[0]-j[0])
 *         elif (i[0]-j[0]) == 1 and strncmp(data + j[0], b"q", i[0]-j[0]) == 0:
 */
    __pyx_t_8 = ((((__pyx_v_i[0]) - (__pyx_v_j[0])) == 1) != 0);
    if (__pyx_t_8) {
    } else {
      __pyx_t_2 = __pyx_t_8;
      goto __pyx_L31_bool_binop_done;
    }
    __pyx_t_8 = ((strncmp((__pyx_v_data + (__pyx_v_j[0])), ((char const *)"y"), ((__pyx_v_i[0]) - (__pyx_v_j[0]))) == 0) != 0);
    __pyx_t_2 = __pyx_t_8;
    __pyx_L31_bool_binop_done:;
    if (__pyx_t_2) {

      /* "btdht/krcp.pyx":1785
 *             return _decode_string(data, i, max, j) and self.set_v(data + j[0], i[0]-j[0])
 *         elif (i[0]-j[0]) == 1 and strncmp(data + j[0], b"y", i[0]-j[0]) == 0:
 *             return _decode_string(data, i, max, j) and self.set_y(data + j[0], i[0]-j[0])             # <<<<<<<<<<<<<<
 *         elif (i[0]-j[0]) == 1 and strncmp(data + j[0], b"q", i[0]-j[0]) == 0:
 *             return _decode_string(data, i, max, j) and self.set_q(data + j[0], i[0]-j[0])
 */
      __pyx_t_9 = __pyx_f_5btdht_4krcp__decode_string(__pyx_v_data, __pyx_v_i, __pyx_v_max, __pyx_v_j); if (unlikely(__pyx_t_9 == ((int)-1))) __PYX_ERR(0, 1785, __pyx_L4_error)
      if (__pyx_t_9) {
      } else {
        __pyx_t_1 = __pyx_t_9;
        goto __pyx_L33_bool_binop_done;
      }
      __pyx_t_9 = ((struct __pyx_vtabstruct_5btdht_4krcp_BMessage *)__pyx_v_self->__pyx_vtab)->set_y(__pyx_v_self, (__pyx_v_data + (__pyx_v_j[0])), ((__pyx_v_i[0]) - (__pyx_v_j[0])));
      __pyx_t_1 = __pyx_t_9;
      __pyx_L33_bool_binop_done:;
      __pyx_r = __pyx_t_1;
      goto __pyx_L3_return;

      /* "btdht/krcp.pyx":1784
 *         elif (i[0]-j[0]) == 1 and strncmp(data + j[0], b"v", i[0]-j[0]) == 0:
 *             return _decode_string(data, i, max, j) and self.set_v(data + j[0], i[0]-j[0])
 *         elif (i[0]-j[0]) == 1 and strncmp(data + j[0], b"y", i[0]-j[0]) == 0:             # <<<<<<<<<<<<<<
 *             return _decode_string(data, i, max, j) and self.set_y(data + j[0], i[0]-j[0])
 *         elif (i[0]-j[0]) == 1 and strncmp(data + j[0], b"q", i[0]-j[0]) == 0:
 */
    }

    /* "btdht/krcp.pyx":1786
 *         elif (i[0]-j[0]) == 1 and strncmp(data + j[0], b"y", i[0]-j[0]) == 0:
 *             return _decode_string(data, i, max, j) and self.set_y(data + j[0], i[0]-j[0])
 *         elif (i[0]-j[0]) == 1 and strncmp(data + j[0], b"q", i[0]-j[0]) == 0:             # <<<<<<<<<<<<<<
 *             return _decode_string(data, i, max, j) and self.set_q(data + j[0], i[0]-j[0])
 *         elif (i[0]-j[0]) == 2 and strncmp(data + j[0], b"id", i[0]-j[0]) == 0:
 */
    __pyx_t_8 = ((((__pyx_v_i[0]) - (__pyx_v_j[0])) == 1) != 0);
    if (__pyx_t_8) {
    } else {
      __pyx_t_2 = __pyx_t_8;
      goto __pyx_L35_bool_binop_done;
    }
    __pyx_t_8 = ((strncmp((__pyx_v_data + (__pyx_v_j[0])), ((char const *)"q"), ((__pyx_v_i[0]) - (__pyx_v_j[0]))) == 0) != 0);
    __pyx_t_2 = __pyx_t_8;
    __pyx_L35_bool_binop_done:;
    if (__pyx_t_2) {

      /* "btdht/krcp.pyx":1787
 *             return _decode_string(data, i, max, j) and self.set_y(data + j[0], i[0]-j[0])
 *         elif (i[0]-j[0]) == 1 and strncmp(data + j[0], b"q", i[0]-j[0]) == 0:
 *             return _decode_string(data, i, max, j) and self.set_q(data + j[0], i[0]-j[0])             # <<<<<<<<<<<<<<
 *         elif (i[0]-j[0]) == 2 and strncmp(data + j[0], b"id", i[0]-j[0]) == 0:
 *             if _decode_string(data, i, max, j):
 */
      __pyx_t_9 = __pyx_f_5btdht_4krcp__decode_string(__pyx_v_data, __pyx_v_i, __pyx_v_max, __pyx_v_j); if (unlikely(__pyx_t_9 == ((int)-1))) __PYX_ERR(0, 1787, __pyx_L4_error)
      if (__pyx_t_9) {
      } else {
        __pyx_t_1 = __pyx_t_9;
        goto __pyx_L37_bool_binop_done;
      }
      __pyx_t_9 = ((struct __pyx_vtabstruct_5btdht_4krcp_BMessage *)__pyx_v_self->__pyx_vtab)->set_q(__pyx_v_self, (__pyx_v_data + (__pyx_v_j[0])), ((__pyx_v_i[0]) - (__pyx_v_j[0])));
      __pyx_t_1 = __pyx_t_9;
      __pyx_L37_bool_binop_done:;
      __pyx_r = __pyx_t_1;
      goto __pyx_L3_return;

      /* "btdht/krcp.pyx":1786
 *         elif (i[0]-j[0]) == 1 and strncmp(data + j[0], b"y", i[0]-j[0]) == 0:
 *             return _decode_string(data, i, max, j) and self.set_y(data + j[0], i[0]-j[0])
 *         elif (i[0]-j[0]) == 1 and strncmp(data + j[0], b"q", i[0]-j[0]) == 0:             # <<<<<<<<<<<<<<
 *             return _decode_string(data, i, max, j) and self.set_q(data + j[0], i[0]-j[0])
 *         elif (i[0]-j[0]) == 2 and strncmp(data + j[0], b"id", i[0]-j[0]) == 0:
 */
    }

    /* "btdht/krcp.pyx":1788
 *         elif (i[0]-j[0]) == 1 and strncmp(data + j[0], b"q", i[0]-j[0]) == 0:
 *             return _decode_string(data, i, max, j) and self.set_q(data + j[0], i[0]-j[0])
 *         elif (i[0]-j[0]) == 2 and strncmp(data + j[0], b"id", i[0]-j[0]) == 0:             # <<<<<<<<<<<<<<
 *             if _decode_string(data, i, max, j):
 *                 if i[0]-j[0] != 20:
 */
    __pyx_t_8 = ((((__pyx_v_i[0]) - (__pyx_v_j[0])) == 2) != 0);
    if (__pyx_t_8) {
    } else {
      __pyx_t_2 = __pyx_t_8;
      goto __pyx_L39_bool_binop_done;
    }
    __pyx_t_8 = ((strncmp((__pyx_v_data + (__pyx_v_j[0])), ((char const *)"id"), ((__pyx_v_i[0]) - (__pyx_v_j[0]))) == 0) != 0);
    __pyx_t_2 = __pyx_t_8;
    __pyx_L39_bool_binop_done:;
    if (__pyx_t_2) {

      /* "btdht/krcp.pyx":1789
 *             return _decode_string(data, i, max, j) and self.set_q(data + j[0], i[0]-j[0])
 *         elif (i[0]-j[0]) == 2 and strncmp(data + j[0], b"id", i[0]-j[0]) == 0:
 *             if _decode_string(data, i, max, j):             # <<<<<<<<<<<<<<
 *                 if i[0]-j[0] != 20:
 *                     self.failed = True
 */
      __pyx_t_1 = __pyx_f_5btdht_4krcp__decode_string(__pyx_v_data, __pyx_v_i, __pyx_v_max, __pyx_v_j); if (unlikely(__pyx_t_1 == ((int)-1))) __PYX_ERR(0, 1789, __pyx_L4_error)
      __pyx_t_2 = (__pyx_t_1 != 0);
      if (__pyx_t_2) {

        /* "btdht/krcp.pyx":1790
 *         elif (i[0]-j[0]) == 2 and strncmp(data + j[0], b"id", i[0]-j[0]) == 0:
 *             if _decode_string(data, i, max, j):
 *                 if i[0]-j[0] != 20:             # <<<<<<<<<<<<<<
 *                     self.failed = True
 *                     self.failed_msg = b"id should be of length 20"
 */
        __pyx_t_2 = ((((__pyx_v_i[0]) - (__pyx_v_j[0])) != 20) != 0);
        if (__pyx_t_2) {

          /* "btdht/krcp.pyx":1791
 *             if _decode_string(data, i, max, j):
 *                 if i[0]-j[0] != 20:
 *                     self.failed = True             # <<<<<<<<<<<<<<
 *                     self.failed_msg = b"id should be of length 20"
 *                 return self.set_id(data + j[0], i[0]-j[0])
 */
          __pyx_v_self->failed = 1;

          /* "btdht/krcp.pyx":1792
 *                 if i[0]-j[0] != 20:
 *                     self.failed = True
 *                     self.failed_msg = b"id should be of length 20"             # <<<<<<<<<<<<<<
 *                 return self.set_id(data + j[0], i[0]-j[0])
 *             else:
 */
          __pyx_v_self->failed_msg = ((char *)"id should be of length 20");

          /* "btdht/krcp.pyx":1790
 *         elif (i[0]-j[0]) == 2 and strncmp(data + j[0], b"id", i[0]-j[0]) == 0:
 *             if _decode_string(data, i, max, j):
 *                 if i[0]-j[0] != 20:             # <<<<<<<<<<<<<<
 *                     self.failed = True
 *                     self.failed_msg = b"id should be of length 20"
 */
        }

        /* "btdht/krcp.pyx":1793
 *                     self.failed = True
 *                     self.failed_msg = b"id should be of length 20"
 *                 return self.set_id(data + j[0], i[0]-j[0])             # <<<<<<<<<<<<<<
 *             else:
 *                 return False
 */
        __pyx_t_1 = ((struct __pyx_vtabstruct_5btdht_4krcp_BMessage *)__pyx_v_self->__pyx_vtab)->set_id(__pyx_v_self, (__pyx_v_data + (__pyx_v_j[0])), ((__pyx_v_i[0]) - (__pyx_v_j[0]))); if (unlikely(__pyx_t_1 == ((int)-1))) __PYX_ERR(0, 1793, __pyx_L4_error)
        __pyx_r = __pyx_t_1;
        goto __pyx_L3_return;

        /* "btdht/krcp.pyx":1789
 *             return _decode_string(data, i, max, j) and self.set_q(data + j[0], i[0]-j[0])
 *         elif (i[0]-j[0]) == 2 and strncmp(data + j[0], b"id", i[0]-j[0]) == 0:
 *             if _decode_string(data, i, max, j):             # <<<<<<<<<<<<<<
 *                 if i[0]-j[0] != 20:
 *                     self.failed = True
 */
      }

      /* "btdht/krcp.pyx":1795
 *                 return self.set_id(data + j[0], i[0]-j[0])
 *             else:
 *                 return False             # <<<<<<<<<<<<<<
 *         elif (i[0]-j[0]) == 6 and strncmp(data + j[0], b"target", i[0]-j[0]) == 0:
 *             if _decode_string(data, i, max, j):
 */
      /*else*/ {
        __pyx_r = 0;
        goto __pyx_L3_return;
      }

      /* "btdht/krcp.pyx":1788
 *         elif (i[0]-j[0]) == 1 and strncmp(data + j[0], b"q", i[0]-j[0]) == 0:
 *             return _decode_string(data, i, max, j) and self.set_q(data + j[0], i[0]-j[0])
 *         elif (i[0]-j[0]) == 2 and strncmp(data + j[0], b"id", i[0]-j[0]) == 0:             # <<<<<<<<<<<<<<
 *             if _decode_string(data, i, max, j):
 *                 if i[0]-j[0] != 20:
 */
    }

    /* "btdht/krcp.pyx":1796
 *             else:
 *                 return False
 *         elif (i[0]-j[0]) == 6 and strncmp(data + j[0], b"target", i[0]-j[0]) == 0:             # <<<<<<<<<<<<<<
 *             if _decode_string(data, i, max, j):
 *                 if i[0]-j[0] != 20:
 */
    __pyx_t_8 = ((((__pyx_v_i[0]) - (__pyx_v_j[0])) == 6) != 0);
    if (__pyx_t_8) {
    } else {
      __pyx_t_2 = __pyx_t_8;
      goto __pyx_L43_bool_binop_done;
    }
    __pyx_t_8 = ((strncmp((__pyx_v_data + (__pyx_v_j[0])), ((char const *)"target"), ((__pyx_v_i[0]) - (__pyx_v_j[0]))) == 0) != 0);
    __pyx_t_2 = __pyx_t_8;
    __pyx_L43_bool_binop_done:;
    if (__pyx_t_2) {

      /* "btdht/krcp.pyx":1797
 *                 return False
 *         elif (i[0]-j[0]) == 6 and strncmp(data + j[0], b"target", i[0]-j[0]) == 0:
 *             if _decode_string(data, i, max, j):             # <<<<<<<<<<<<<<
 *                 if i[0]-j[0] != 20:
 *                     self.failed = True
 */
      __pyx_t_1 = __pyx_f_5btdht_4krcp__decode_string(__pyx_v_data, __pyx_v_i, __pyx_v_max, __pyx_v_j); if (unlikely(__pyx_t_1 == ((int)-1))) __PYX_ERR(0, 1797, __pyx_L4_error)
      __pyx_t_2 = (__pyx_t_1 != 0);
      if (__pyx_t_2) {

        /* "btdht/krcp.pyx":1798
 *         elif (i[0]-j[0]) == 6 and strncmp(data + j[0], b"target", i[0]-j[0]) == 0:
 *             if _decode_string(data, i, max, j):
 *                 if i[0]-j[0] != 20:             # <<<<<<<<<<<<<<
 *                     self.failed = True
 *                     self.failed_msg = b"target should be of length 20"
 */
        __pyx_t_2 = ((((__pyx_v_i[0]) - (__pyx_v_j[0])) != 20) != 0);
        if (__pyx_t_2) {

          /* "btdht/krcp.pyx":1799
 *             if _decode_string(data, i, max, j):
 *                 if i[0]-j[0] != 20:
 *                     self.failed = True             # <<<<<<<<<<<<<<
 *                     self.failed_msg = b"target should be of length 20"
 *                 return self.set_target(data + j[0], i[0]-j[0])
 */
          __pyx_v_self->failed = 1;

          /* "btdht/krcp.pyx":1800
 *                 if i[0]-j[0] != 20:
 *                     self.failed = True
 *                     self.failed_msg = b"target should be of length 20"             # <<<<<<<<<<<<<<
 *                 return self.set_target(data + j[0], i[0]-j[0])
 *             else:
 */
          __pyx_v_self->failed_msg = ((char *)"target should be of length 20");

          /* "btdht/krcp.pyx":1798
 *         elif (i[0]-j[0]) == 6 and strncmp(data + j[0], b"target", i[0]-j[0]) == 0:
 *             if _decode_string(data, i, max, j):
 *                 if i[0]-j[0] != 20:             # <<<<<<<<<<<<<<
 *                     self.failed = True
 *                     self.failed_msg = b"target should be of length 20"
 */
        }

        /* "btdht/krcp.pyx":1801
 *                     self.failed = True
 *                     self.failed_msg = b"target should be of length 20"
 *                 return self.set_target(data + j[0], i[0]-j[0])             # <<<<<<<<<<<<<<
 *             else:
 *                 return False
 */
        __pyx_t_1 = ((struct __pyx_vtabstruct_5btdht_4krcp_BMessage *)__pyx_v_self->__pyx_vtab)->set_target(__pyx_v_self, (__pyx_v_data + (__pyx_v_j[0])), ((__pyx_v_i[0]) - (__pyx_v_j[0]))); if (unlikely(__pyx_t_1 == ((int)-1))) __PYX_ERR(0, 1801, __pyx_L4_error)
        __pyx_r = __pyx_t_1;
        goto __pyx_L3_return;

        /* "btdht/krcp.pyx":1797
 *                 return False
 *         elif (i[0]-j[0]) == 6 and strncmp(data + j[0], b"target", i[0]-j[0]) == 0:
 *             if _decode_string(data, i, max, j):             # <<<<<<<<<<<<<<
 *                 if i[0]-j[0] != 20:
 *                     self.failed = True
 */
      }

      /* "btdht/krcp.pyx":1803
 *                 return self.set_target(data + j[0], i[0]-j[0])
 *             else:
 *                 return False             # <<<<<<<<<<<<<<
 *         elif (i[0]-j[0]) == 9 and strncmp(data + j[0], b"info_hash", i[0]-j[0]) == 0:
 *             if _decode_string(data, i, max, j):
 */
      /*else*/ {
        __pyx_r = 0;
        goto __pyx_L3_return;
      }

      /* "btdht/krcp.pyx":1796
 *             else:
 *                 return False
 *         elif (i[0]-j[0]) == 6 and strncmp(data + j[0], b"target", i[0]-j[0]) == 0:             # <<<<<<<<<<<<<<
 *             if _decode_string(data, i, max, j):
 *                 if i[0]-j[0] != 20:
 */
    }

    /* "btdht/krcp.pyx":1804
 *             else:
 *                 return False
 *         elif (i[0]-j[0]) == 9 and strncmp(data + j[0], b"info_hash", i[0]-j[0]) == 0:             # <<<<<<<<<<<<<<
 *             if _decode_string(data, i, max, j):
 *                 if i[0]-j[0] != 20:
 */
    __pyx_t_8 = ((((__pyx_v_i[0]) - (__pyx_v_j[0])) == 9) != 0);
    if (__pyx_t_8) {
    } else {
      __pyx_t_2 = __pyx_t_8;
      goto __pyx_L47_bool_binop_done;
    }
    __pyx_t_8 = ((strncmp((__pyx_v_data + (__pyx_v_j[0])), ((char const *)"info_hash"), ((__pyx_v_i[0]) - (__pyx_v_j[0]))) == 0) != 0);
    __pyx_t_2 = __pyx_t_8;
    __pyx_L47_bool_binop_done:;
    if (__pyx_t_2) {

      /* "btdht/krcp.pyx":1805
 *                 return False
 *         elif (i[0]-j[0]) == 9 and strncmp(data + j[0], b"info_hash", i[0]-j[0]) == 0:
 *             if _decode_string(data, i, max, j):             # <<<<<<<<<<<<<<
 *                 if i[0]-j[0] != 20:
 *                     self.failed = True
 */
      __pyx_t_1 = __pyx_f_5btdht_4krcp__decode_string(__pyx_v_data, __pyx_v_i, __pyx_v_max, __pyx_v_j); if (unlikely(__pyx_t_1 == ((int)-1))) __PYX_ERR(0, 1805, __pyx_L4_error)
      __pyx_t_2 = (__pyx_t_1 != 0);
      if (__pyx_t_2) {

        /* "btdht/krcp.pyx":1806
 *         elif (i[0]-j[0]) == 9 and strncmp(data + j[0], b"info_hash", i[0]-j[0]) == 0:
 *             if _decode_string(data, i, max, j):
 *                 if i[0]-j[0] != 20:             # <<<<<<<<<<<<<<
 *                     self.failed = True
 *                     self.failed_msg = b"info_hash should be of length 20"
 */
        __pyx_t_2 = ((((__pyx_v_i[0]) - (__pyx_v_j[0])) != 20) != 0);
        if (__pyx_t_2) {

          /* "btdht/krcp.pyx":1807
 *             if _decode_string(data, i, max, j):
 *                 if i[0]-j[0] != 20:
 *                     self.failed = True             # <<<<<<<<<<<<<<
 *                     self.failed_msg = b"info_hash should be of length 20"
 *                 return self.set_info_hash(data + j[0], i[0]-j[0])
 */
          __pyx_v_self->failed = 1;

          /* "btdht/krcp.pyx":1808
 *                 if i[0]-j[0] != 20:
 *                     self.failed = True
 *                     self.failed_msg = b"info_hash should be of length 20"             # <<<<<<<<<<<<<<
 *                 return self.set_info_hash(data + j[0], i[0]-j[0])
 *             else:
 */
          __pyx_v_self->failed_msg = ((char *)"info_hash should be of length 20");

          /* "btdht/krcp.pyx":1806
 *         elif (i[0]-j[0]) == 9 and strncmp(data + j[0], b"info_hash", i[0]-j[0]) == 0:
 *             if _decode_string(data, i, max, j):
 *                 if i[0]-j[0] != 20:             # <<<<<<<<<<<<<<
 *                     self.failed = True
 *                     self.failed_msg = b"info_hash should be of length 20"
 */
        }

        /* "btdht/krcp.pyx":1809
 *                     self.failed = True
 *                     self.failed_msg = b"info_hash should be of length 20"
 *                 return self.set_info_hash(data + j[0], i[0]-j[0])             # <<<<<<<<<<<<<<
 *             else:
 *                 return False
 */
        __pyx_t_1 = ((struct __pyx_vtabstruct_5btdht_4krcp_BMessage *)__pyx_v_self->__pyx_vtab)->set_info_hash(__pyx_v_self, (__pyx_v_data + (__pyx_v_j[0])), ((__pyx_v_i[0]) - (__pyx_v_j[0]))); if (unlikely(__pyx_t_1 == ((int)-1))) __PYX_ERR(0, 1809, __pyx_L4_error)
        __pyx_r = __pyx_t_1;
        goto __pyx_L3_return;

        /* "btdht/krcp.pyx":1805
 *                 return False
 *         elif (i[0]-j[0]) == 9 and strncmp(data + j[0], b"info_hash", i[0]-j[0]) == 0:
 *             if _decode_string(data, i, max, j):             # <<<<<<<<<<<<<<
 *                 if i[0]-j[0] != 20:
 *                     self.failed = True
 */
      }

      /* "btdht/krcp.pyx":1811
 *                 return self.set_info_hash(data + j[0], i[0]-j[0])
 *             else:
 *                 return False             # <<<<<<<<<<<<<<
 *         elif (i[0]-j[0]) == 12 and strncmp(data + j[0], b"implied_port", i[0]-j[0]) == 0:
 *             return _decode_int(data, i, max, ll) and self.set_implied_port(ll[0])
 */
      /*else*/ {
        __pyx_r = 0;
        goto __pyx_L3_return;
      }

      /* "btdht/krcp.pyx":1804
 *             else:
 *                 return False
 *         elif (i[0]-j[0]) == 9 and strncmp(data + j[0], b"info_hash", i[0]-j[0]) == 0:             # <<<<<<<<<<<<<<
 *             if _decode_string(data, i, max, j):
 *                 if i[0]-j[0] != 20:
 */
    }

    /* "btdht/krcp.pyx":1812
 *             else:
 *                 return False
 *         elif (i[0]-j[0]) == 12 and strncmp(data + j[0], b"implied_port", i[0]-j[0]) == 0:             # <<<<<<<<<<<<<<
 *             return _decode_int(data, i, max, ll) and self.set_implied_port(ll[0])
 *         elif (i[0]-j[0]) == 4 and strncmp(data + j[0], b"port", i[0]-j[0]) == 0:
 */
    __pyx_t_8 = ((((__pyx_v_i[0]) - (__pyx_v_j[0])) == 12) != 0);
    if (__pyx_t_8) {
    } else {
      __pyx_t_2 = __pyx_t_8;
      goto __pyx_L51_bool_binop_done;
    }
    __pyx_t_8 = ((strncmp((__pyx_v_data + (__pyx_v_j[0])), ((char const *)"implied_port"), ((__pyx_v_i[0]) - (__pyx_v_j[0]))) == 0) != 0);
    __pyx_t_2 = __pyx_t_8;
    __pyx_L51_bool_binop_done:;
    if (__pyx_t_2) {

      /* "btdht/krcp.pyx":1813
 *                 return False
 *         elif (i[0]-j[0]) == 12 and strncmp(data + j[0], b"implied_port", i[0]-j[0]) == 0:
 *             return _decode_int(data, i, max, ll) and self.set_implied_port(ll[0])             # <<<<<<<<<<<<<<
 *         elif (i[0]-j[0]) == 4 and strncmp(data + j[0], b"port", i[0]-j[0]) == 0:
 *             return _decode_int(data, i, max, ll) and self.set_port(ll[0])
 */
      __pyx_t_10 = __pyx_f_5btdht_4krcp__decode_int(__pyx_v_data, __pyx_v_i, __pyx_v_max, __pyx_v_ll); if (unlikely(__pyx_t_10 == ((long)-1L))) __PYX_ERR(0, 1813, __pyx_L4_error)
      if (__pyx_t_10) {
      } else {
        __pyx_t_1 = __pyx_t_10;
        goto __pyx_L53_bool_binop_done;
      }
      __pyx_t_9 = ((struct __pyx_vtabstruct_5btdht_4krcp_BMessage *)__pyx_v_self->__pyx_vtab)->set_implied_port(__pyx_v_self, (__pyx_v_ll[0]));
      __pyx_t_1 = __pyx_t_9;
      __pyx_L53_bool_binop_done:;
      __pyx_r = __pyx_t_1;
      goto __pyx_L3_return;

      /* "btdht/krcp.pyx":1812
 *             else:
 *                 return False
 *         elif (i[0]-j[0]) == 12 and strncmp(data + j[0], b"implied_port", i[0]-j[0]) == 0:             # <<<<<<<<<<<<<<
 *             return _decode_int(data, i, max, ll) and self.set_implied_port(ll[0])
 *         elif (i[0]-j[0]) == 4 and strncmp(data + j[0], b"port", i[0]-j[0]) == 0:
 */
    }

    /* "btdht/krcp.pyx":1814
 *         elif (i[0]-j[0]) == 12 and strncmp(data + j[0], b"implied_port", i[0]-j[0]) == 0:
 *             return _decode_int(data, i, max, ll) and self.set_implied_port(ll[0])
 *         elif (i[0]-j[0]) == 4 and strncmp(data + j[0], b"port", i[0]-j[0]) == 0:             # <<<<<<<<<<<<<<
 *             return _decode_int(data, i, max, ll) and self.set_port(ll[0])
 *         elif (i[0]-j[0]) == 5 and strncmp(data + j[0], b"token", i[0]-j[0]) == 0:
 */
    __pyx_t_8 = ((((__pyx_v_i[0]) - (__pyx_v_j[0])) == 4) != 0);
    if (__pyx_t_8) {
    } else {
      __pyx_t_2 = __pyx_t_8;
      goto __pyx_L55_bool_binop_done;
    }
    __pyx_t_8 = ((strncmp((__pyx_v_data + (__pyx_v_j[0])), ((char const *)"port"), ((__pyx_v_i[0]) - (__pyx_v_j[0]))) == 0) != 0);
    __pyx_t_2 = __pyx_t_8;
    __pyx_L55_bool_binop_done:;
    if (__pyx_t_2) {

      /* "btdht/krcp.pyx":1815
 *             return _decode_int(data, i, max, ll) and self.set_implied_port(ll[0])
 *         elif (i[0]-j[0]) == 4 and strncmp(data + j[0], b"port", i[0]-j[0]) == 0:
 *             return _decode_int(data, i, max, ll) and self.set_port(ll[0])             # <<<<<<<<<<<<<<
 *         elif (i[0]-j[0]) == 5 and strncmp(data + j[0], b"token", i[0]-j[0]) == 0:
 *             return _decode_string(data, i, max, j) and self.set_token(data + j[0], i[0]-j[0])
 */
      __pyx_t_10 = __pyx_f_5btdht_4krcp__decode_int(__pyx_v_data, __pyx_v_i, __pyx_v_max, __pyx_v_ll); if (unlikely(__pyx_t_10 == ((long)-1L))) __PYX_ERR(0, 1815, __pyx_L4_error)
      if (__pyx_t_10) {
      } else {
        __pyx_t_1 = __pyx_t_10;
        goto __pyx_L57_bool_binop_done;
      }
      __pyx_t_9 = ((struct __pyx_vtabstruct_5btdht_4krcp_BMessage *)__pyx_v_self->__pyx_vtab)->set_port(__pyx_v_self, (__pyx_v_ll[0]));
      __pyx_t_1 = __pyx_t_9;
      __pyx_L57_bool_binop_done:;
      __pyx_r = __pyx_t_1;
      goto __pyx_L3_return;

      /* "btdht/krcp.pyx":1814
 *         elif (i[0]-j[0]) == 12 and strncmp(data + j[0], b"implied_port", i[0]-j[0]) == 0:
 *             return _decode_int(data, i, max, ll) and self.set_implied_port(ll[0])
 *         elif (i[0]-j[0]) == 4 and strncmp(data + j[0], b"port", i[0]-j[0]) == 0:             # <<<<<<<<<<<<<<
 *             return _decode_int(data, i, max, ll) and self.set_port(ll[0])
 *         elif (i[0]-j[0]) == 5 and strncmp(data + j[0], b"token", i[0]-j[0]) == 0:
 */
    }

    /* "btdht/krcp.pyx":1816
 *         elif (i[0]-j[0]) == 4 and strncmp(data + j[0], b"port", i[0]-j[0]) == 0:
 *             return _decode_int(data, i, max, ll) and self.set_port(ll[0])
 *         elif (i[0]-j[0]) == 5 and strncmp(data + j[0], b"token", i[0]-j[0]) == 0:             # <<<<<<<<<<<<<<
 *             return _decode_string(data, i, max, j) and self.set_token(data + j[0], i[0]-j[0])
 *         elif (i[0]-j[0]) == 5 and strncmp(data + j[0], b"nodes", i[0]-j[0]) == 0:
 */
    __pyx_t_8 = ((((__pyx_v_i[0]) - (__pyx_v_j[0])) == 5) != 0);
    if (__pyx_t_8) {
    } else {
      __pyx_t_2 = __pyx_t_8;
      goto __pyx_L59_bool_binop_done;
    }
    __pyx_t_8 = ((strncmp((__pyx_v_data + (__pyx_v_j[0])), ((char const *)"token"), ((__pyx_v_i[0]) - (__pyx_v_j[0]))) == 0) != 0);
    __pyx_t_2 = __pyx_t_8;
    __pyx_L59_bool_binop_done:;
    if (__pyx_t_2) {

      /* "btdht/krcp.pyx":1817
 *             return _decode_int(data, i, max, ll) and self.set_port(ll[0])
 *         elif (i[0]-j[0]) == 5 and strncmp(data + j[0], b"token", i[0]-j[0]) == 0:
 *             return _decode_string(data, i, max, j) and self.set_token(data + j[0], i[0]-j[0])             # <<<<<<<<<<<<<<
 *         elif (i[0]-j[0]) == 5 and strncmp(data + j[0], b"nodes", i[0]-j[0]) == 0:
 *             return _decode_string(data, i, max, j) and self.set_nodes(data + j[0], i[0]-j[0])
 */
      __pyx_t_9 = __pyx_f_5btdht_4krcp__decode_string(__pyx_v_data, __pyx_v_i, __pyx_v_max, __pyx_v_j); if (unlikely(__pyx_t_9 == ((int)-1))) __PYX_ERR(0, 1817, __pyx_L4_error)
      if (__pyx_t_9) {
      } else {
        __pyx_t_1 = __pyx_t_9;
        goto __pyx_L61_bool_binop_done;
      }
      __pyx_t_9 = ((struct __pyx_vtabstruct_5btdht_4krcp_BMessage *)__pyx_v_self->__pyx_vtab)->set_token(__pyx_v_self, (__pyx_v_data + (__pyx_v_j[0])), ((__pyx_v_i[0]) - (__pyx_v_j[0])));
      __pyx_t_1 = __pyx_t_9;
      __pyx_L61_bool_binop_done:;
      __pyx_r = __pyx_t_1;
      goto __pyx_L3_return;

      /* "btdht/krcp.pyx":1816
 *         elif (i[0]-j[0]) == 4 and strncmp(data + j[0], b"port", i[0]-j[0]) == 0:
 *             return _decode_int(data, i, max, ll) and self.set_port(ll[0])
 *         elif (i[0]-j[0]) == 5 and strncmp(data + j[0], b"token", i[0]-j[0]) == 0:             # <<<<<<<<<<<<<<
 *             return _decode_string(data, i, max, j) and self.set_token(data + j[0], i[0]-j[0])
 *         elif (i[0]-j[0]) == 5 and strncmp(data + j[0], b"nodes", i[0]-j[0]) == 0:
 */
    }

    /* "btdht/krcp.pyx":1818
 *         elif (i[0]-j[0]) == 5 and strncmp(data + j[0], b"token", i[0]-j[0]) == 0:
 *             return _decode_string(data, i, max, j) and self.set_token(data + j[0], i[0]-j[0])
 *         elif (i[0]-j[0]) == 5 and strncmp(data + j[0], b"nodes", i[0]-j[0]) == 0:             # <<<<<<<<<<<<<<
 *             return _decode_string(data, i, max, j) and self.set_nodes(data + j[0], i[0]-j[0])
 *         elif (i[0]-j[0]) == 6 and strncmp(data + j[0], b"values", i[0]-j[0]) == 0:
 */
    __pyx_t_8 = ((((__pyx_v_i[0]) - (__pyx_v_j[0])) == 5) != 0);
    if (__pyx_t_8) {
    } else {
      __pyx_t_2 = __pyx_t_8;
      goto __pyx_L63_bool_binop_done;
    }
    __pyx_t_8 = ((strncmp((__pyx_v_data + (__pyx_v_j[0])), ((char const *)"nodes"), ((__pyx_v_i[0]) - (__pyx_v_j[0]))) == 0) != 0);
    __pyx_t_2 = __pyx_t_8;
    __pyx_L63_bool_binop_done:;
    if (__pyx_t_2) {

      /* "btdht/krcp.pyx":1819
 *             return _decode_string(data, i, max, j) and self.set_token(data + j[0], i[0]-j[0])
 *         elif (i[0]-j[0]) == 5 and strncmp(data + j[0], b"nodes", i[0]-j[0]) == 0:
 *             return _decode_string(data, i, max, j) and self.set_nodes(data + j[0], i[0]-j[0])             # <<<<<<<<<<<<<<
 *         elif (i[0]-j[0]) == 6 and strncmp(data + j[0], b"values", i[0]-j[0]) == 0:
 *             if self._decode_values(data, i, max):
 */
      __pyx_t_9 = __pyx_f_5btdht_4krcp__decode_string(__pyx_v_data, __pyx_v_i, __pyx_v_max, __pyx_v_j); if (unlikely(__pyx_t_9 == ((int)-1))) __PYX_ERR(0, 1819, __pyx_L4_error)
      if (__pyx_t_9) {
      } else {
        __pyx_t_1 = __pyx_t_9;
        goto __pyx_L65_bool_binop_done;
      }
      __pyx_t_9 = ((struct __pyx_vtabstruct_5btdht_4krcp_BMessage *)__pyx_v_self->__pyx_vtab)->set_nodes(__pyx_v_self, (__pyx_v_data + (__pyx_v_j[0])), ((__pyx_v_i[0]) - (__pyx_v_j[0])));
      __pyx_t_1 = __pyx_t_9;
      __pyx_L65_bool_binop_done:;
      __pyx_r = __pyx_t_1;
      goto __pyx_L3_return;

      /* "btdht/krcp.pyx":1818
 *         elif (i[0]-j[0]) == 5 and strncmp(data + j[0], b"token", i[0]-j[0]) == 0:
 *             return _decode_string(data, i, max, j) and self.set_token(data + j[0], i[0]-j[0])
 *         elif (i[0]-j[0]) == 5 and strncmp(data + j[0], b"nodes", i[0]-j[0]) == 0:             # <<<<<<<<<<<<<<
 *             return _decode_string(data, i, max, j) and self.set_nodes(data + j[0], i[0]-j[0])
 *         elif (i[0]-j[0]) == 6 and strncmp(data + j[0], b"values", i[0]-j[0]) == 0:
 */
    }

    /* "btdht/krcp.pyx":1820
 *         elif (i[0]-j[0]) == 5 and strncmp(data + j[0], b"nodes", i[0]-j[0]) == 0:
 *             return _decode_string(data, i, max, j) and self.set_nodes(data + j[0], i[0]-j[0])
 *         elif (i[0]-j[0]) == 6 and strncmp(data + j[0], b"values", i[0]-j[0]) == 0:             # <<<<<<<<<<<<<<
 *             if self._decode_values(data, i, max):
 *                 return True
 */
    __pyx_t_8 = ((((__pyx_v_i[0]) - (__pyx_v_j[0])) == 6) != 0);
    if (__pyx_t_8) {
    } else {
      __pyx_t_2 = __pyx_t_8;
      goto __pyx_L67_bool_binop_done;
    }
    __pyx_t_8 = ((strncmp((__pyx_v_data + (__pyx_v_j[0])), ((char const *)"values"), ((__pyx_v_i[0]) - (__pyx_v_j[0]))) == 0) != 0);
    __pyx_t_2 = __pyx_t_8;
    __pyx_L67_bool_binop_done:;
    if (__pyx_t_2) {

      /* "btdht/krcp.pyx":1821
 *             return _decode_string(data, i, max, j) and self.set_nodes(data + j[0], i[0]-j[0])
 *         elif (i[0]-j[0]) == 6 and strncmp(data + j[0], b"values", i[0]-j[0]) == 0:
 *             if self._decode_values(data, i, max):             # <<<<<<<<<<<<<<
 *                 return True
 *             else:
 */
      __pyx_t_1 = ((struct __pyx_vtabstruct_5btdht_4krcp_BMessage *)__pyx_v_self->__pyx_vtab)->_decode_values(__pyx_v_self, __pyx_v_data, __pyx_v_i, __pyx_v_max); if (unlikely(__pyx_t_1 == ((int)-1))) __PYX_ERR(0, 1821, __pyx_L4_error)
      __pyx_t_2 = (__pyx_t_1 != 0);
      if (__pyx_t_2) {

        /* "btdht/krcp.pyx":1822
 *         elif (i[0]-j[0]) == 6 and strncmp(data + j[0], b"values", i[0]-j[0]) == 0:
 *             if self._decode_values(data, i, max):
 *                 return True             # <<<<<<<<<<<<<<
 *             else:
 *                 self.failed = True
 */
        __pyx_r = 1;
        goto __pyx_L3_return;

        /* "btdht/krcp.pyx":1821
 *             return _decode_string(data, i, max, j) and self.set_nodes(data + j[0], i[0]-j[0])
 *         elif (i[0]-j[0]) == 6 and strncmp(data + j[0], b"values", i[0]-j[0]) == 0:
 *             if self._decode_values(data, i, max):             # <<<<<<<<<<<<<<
 *                 return True
 *             else:
 */
      }

      /* "btdht/krcp.pyx":1824
 *                 return True
 *             else:
 *                 self.failed = True             # <<<<<<<<<<<<<<
 *                 self.failed_msg = b"values items should be a list"
 *         #if self.debug:
 */
      /*else*/ {
        __pyx_v_self->failed = 1;

        /* "btdht/krcp.pyx":1825
 *             else:
 *                 self.failed = True
 *                 self.failed_msg = b"values items should be a list"             # <<<<<<<<<<<<<<
 *         #if self.debug:
 *         #    error = <char*>malloc((i[0] + 1 - j[0]) * sizeof(char))
 */
        __pyx_v_self->failed_msg = ((char *)"values items should be a list");
      }

      /* "btdht/krcp.pyx":1820
 *         elif (i[0]-j[0]) == 5 and strncmp(data + j[0], b"nodes", i[0]-j[0]) == 0:
 *             return _decode_string(data, i, max, j) and self.set_nodes(data + j[0], i[0]-j[0])
 *         elif (i[0]-j[0]) == 6 and strncmp(data + j[0], b"values", i[0]-j[0]) == 0:             # <<<<<<<<<<<<<<
 *             if self._decode_values(data, i, max):
 *                 return True
 */
    }

    /* "btdht/krcp.pyx":1832
 *         #    printf("error %s\n", error)
 *         #    free(error)
 *         if _decode_string(data, i, max, j):             # <<<<<<<<<<<<<<
 *             return True
 *         if _decode_int(data, i, max, ll):
 */
    __pyx_t_1 = __pyx_f_5btdht_4krcp__decode_string(__pyx_v_data, __pyx_v_i, __pyx_v_max, __pyx_v_j); if (unlikely(__pyx_t_1 == ((int)-1))) __PYX_ERR(0, 1832, __pyx_L4_error)
    __pyx_t_2 = (__pyx_t_1 != 0);
    if (__pyx_t_2) {

      /* "btdht/krcp.pyx":1833
 *         #    free(error)
 *         if _decode_string(data, i, max, j):
 *             return True             # <<<<<<<<<<<<<<
 *         if _decode_int(data, i, max, ll):
 *             return True
 */
      __pyx_r = 1;
      goto __pyx_L3_return;

      /* "btdht/krcp.pyx":1832
 *         #    printf("error %s\n", error)
 *         #    free(error)
 *         if _decode_string(data, i, max, j):             # <<<<<<<<<<<<<<
 *             return True
 *         if _decode_int(data, i, max, ll):
 */
    }

    /* "btdht/krcp.pyx":1834
 *         if _decode_string(data, i, max, j):
 *             return True
 *         if _decode_int(data, i, max, ll):             # <<<<<<<<<<<<<<
 *             return True
 *         if _decode_pass_list(data, i, max):
 */
    __pyx_t_10 = __pyx_f_5btdht_4krcp__decode_int(__pyx_v_data, __pyx_v_i, __pyx_v_max, __pyx_v_ll); if (unlikely(__pyx_t_10 == ((long)-1L))) __PYX_ERR(0, 1834, __pyx_L4_error)
    __pyx_t_2 = (__pyx_t_10 != 0);
    if (__pyx_t_2) {

      /* "btdht/krcp.pyx":1835
 *             return True
 *         if _decode_int(data, i, max, ll):
 *             return True             # <<<<<<<<<<<<<<
 *         if _decode_pass_list(data, i, max):
 *             return True
 */
      __pyx_r = 1;
      goto __pyx_L3_return;

      /* "btdht/krcp.pyx":1834
 *         if _decode_string(data, i, max, j):
 *             return True
 *         if _decode_int(data, i, max, ll):             # <<<<<<<<<<<<<<
 *             return True
 *         if _decode_pass_list(data, i, max):
 */
    }

    /* "btdht/krcp.pyx":1836
 *         if _decode_int(data, i, max, ll):
 *             return True
 *         if _decode_pass_list(data, i, max):             # <<<<<<<<<<<<<<
 *             return True
 *         if _decode_pass_dict(data, i, max):
 */
    __pyx_t_1 = __pyx_f_5btdht_4krcp__decode_pass_list(__pyx_v_data, __pyx_v_i, __pyx_v_max); if (unlikely(__pyx_t_1 == ((int)-1))) __PYX_ERR(0, 1836, __pyx_L4_error)
    __pyx_t_2 = (__pyx_t_1 != 0);
    if (__pyx_t_2) {

      /* "btdht/krcp.pyx":1837
 *             return True
 *         if _decode_pass_list(data, i, max):
 *             return True             # <<<<<<<<<<<<<<
 *         if _decode_pass_dict(data, i, max):
 *             return True
 */
      __pyx_r = 1;
      goto __pyx_L3_return;

      /* "btdht/krcp.pyx":1836
 *         if _decode_int(data, i, max, ll):
 *             return True
 *         if _decode_pass_list(data, i, max):             # <<<<<<<<<<<<<<
 *             return True
 *         if _decode_pass_dict(data, i, max):
 */
    }

    /* "btdht/krcp.pyx":1838
 *         if _decode_pass_list(data, i, max):
 *             return True
 *         if _decode_pass_dict(data, i, max):             # <<<<<<<<<<<<<<
 *             return True
 * 
 */
    __pyx_t_1 = __pyx_f_5btdht_4krcp__decode_pass_dict(__pyx_v_data, __pyx_v_i, __pyx_v_max); if (unlikely(__pyx_t_1 == ((int)-1))) __PYX_ERR(0, 1838, __pyx_L4_error)
    __pyx_t_2 = (__pyx_t_1 != 0);
    if (__pyx_t_2) {

      /* "btdht/krcp.pyx":1839
 *             return True
 *         if _decode_pass_dict(data, i, max):
 *             return True             # <<<<<<<<<<<<<<
 * 
 *         with gil:
 */
      __pyx_r = 1;
      goto __pyx_L3_return;

      /* "btdht/krcp.pyx":1838
 *         if _decode_pass_list(data, i, max):
 *             return True
 *         if _decode_pass_dict(data, i, max):             # <<<<<<<<<<<<<<
 *             return True
 * 
 */
    }

    /* "btdht/krcp.pyx":1841
 *             return True
 * 
 *         with gil:             # <<<<<<<<<<<<<<
 *             raise DecodeError("Unable to decode element of dict at %d %r" % (j[0], data[:max]))
 * 
 */
    {
        #ifdef WITH_THREAD
        PyGILState_STATE __pyx_gilstate_save = __Pyx_PyGILState_Ensure();
        #endif
        /*try:*/ {

          /* "btdht/krcp.pyx":1842
 * 
 *         with gil:
 *             raise DecodeError("Unable to decode element of dict at %d %r" % (j[0], data[:max]))             # <<<<<<<<<<<<<<
 * 
 *     cdef int _decode_values(self, char* data, int *i, int max) nogil except -1:
 */
          __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_DecodeError); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1842, __pyx_L75_error)
          __Pyx_GOTREF(__pyx_t_4);
          __pyx_t_6 = __Pyx_PyInt_From_int((__pyx_v_j[0])); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1842, __pyx_L75_error)
          __Pyx_GOTREF(__pyx_t_6);
          __pyx_t_7 = __Pyx_PyBytes_FromStringAndSize(__pyx_v_data + 0, __pyx_v_max - 0); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1842, __pyx_L75_error)
          __Pyx_GOTREF(__pyx_t_7);
          __pyx_t_5 = PyTuple_New(2); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1842, __pyx_L75_error)
          __Pyx_GOTREF(__pyx_t_5);
          __Pyx_GIVEREF(__pyx_t_6);
          PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_6);
          __Pyx_GIVEREF(__pyx_t_7);
          PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_t_7);
          __pyx_t_6 = 0;
          __pyx_t_7 = 0;
          __pyx_t_7 = __Pyx_PyString_Format(__pyx_kp_s_Unable_to_decode_element_of_dict, __pyx_t_5); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1842, __pyx_L75_error)
          __Pyx_GOTREF(__pyx_t_7);
          __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
          __pyx_t_5 = NULL;
          if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_4))) {
            __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_4);
            if (likely(__pyx_t_5)) {
              PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
              __Pyx_INCREF(__pyx_t_5);
              __Pyx_INCREF(function);
              __Pyx_DECREF_SET(__pyx_t_4, function);
            }
          }
          __pyx_t_3 = (__pyx_t_5) ? __Pyx_PyObject_Call2Args(__pyx_t_4, __pyx_t_5, __pyx_t_7) : __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_7);
          __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
          __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
          if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1842, __pyx_L75_error)
          __Pyx_GOTREF(__pyx_t_3);
          __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
          __Pyx_Raise(__pyx_t_3, 0, 0, 0);
          __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
          __PYX_ERR(0, 1842, __pyx_L75_error)
        }

        /* "btdht/krcp.pyx":1841
 *             return True
 * 
 *         with gil:             # <<<<<<<<<<<<<<
 *             raise DecodeError("Unable to decode element of dict at %d %r" % (j[0], data[:max]))
 * 
 */
        /*finally:*/ {
          __pyx_L75_error: {
            #ifdef WITH_THREAD
            __Pyx_PyGILState_Release(__pyx_gilstate_save);
            #endif
            goto __pyx_L4_error;
          }
        }
    }
  }

  /* "btdht/krcp.pyx":1746
 * 
 *     cdef int _decode_dict_elm(self, char* data, int* i, int max) nogil except -1:
 *         """             # <<<<<<<<<<<<<<
 *             Decode a dictionnary element: a key and a value. Set the corresponding attributes
 *             on the message.
 */
  /*finally:*/ {
    __pyx_L3_return: {
      #ifdef WITH_THREAD
      __pyx_gilstate_save = __Pyx_PyGILState_Ensure();
      #endif
      goto __pyx_L0;
    }
    __pyx_L4_error: {
      #ifdef WITH_THREAD
      __pyx_gilstate_save = __Pyx_PyGILState_Ensure();
      #endif
      goto __pyx_L1_error;
    }
  }

  /* "btdht/krcp.pyx":1745
 *         return True
 * 
 *     cdef int _decode_dict_elm(self, char* data, int* i, int max) nogil except -1:             # <<<<<<<<<<<<<<
 *         """
 *             Decode a dictionnary element: a key and a value. Set the corresponding attributes
 */

  /* function exit code */
  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_AddTraceback("btdht.krcp.BMessage._decode_dict_elm", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  #ifdef WITH_THREAD
  __Pyx_PyGILState_Release(__pyx_gilstate_save);
  #endif
  return __pyx_r;
}

/* "btdht/krcp.pyx":1844
 *             raise DecodeError("Unable to decode element of dict at %d %r" % (j[0], data[:max]))
 * 
 *     cdef int _decode_values(self, char* data, int *i, int max) nogil except -1:             # <<<<<<<<<<<<<<
 *         """
 *             Bdecode a values list of peers in compact forms (6 Bytes, 4 for ip and 2 for port)
 */

static int __pyx_f_5btdht_4krcp_8BMessage__decode_values(struct __pyx_obj_5btdht_4krcp_BMessage *__pyx_v_self, char *__pyx_v_data, int *__pyx_v_i, int __pyx_v_max) {
  int __pyx_v_j[1];
  int __pyx_v_c;
  int __pyx_v_k;
  char **__pyx_v_values;
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  PyObject *__pyx_t_7 = NULL;
  long __pyx_t_8;
  int __pyx_t_9;
  int __pyx_t_10;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  #ifdef WITH_THREAD
  PyGILState_STATE __pyx_gilstate_save = __Pyx_PyGILState_Ensure();
  #endif
  __Pyx_RefNannySetupContext("_decode_values", 0);
  #ifdef WITH_THREAD
  __Pyx_PyGILState_Release(__pyx_gilstate_save);
  #endif

  /* "btdht/krcp.pyx":1845
 * 
 *     cdef int _decode_values(self, char* data, int *i, int max) nogil except -1:
 *         """             # <<<<<<<<<<<<<<
 *             Bdecode a values list of peers in compact forms (6 Bytes, 4 for ip and 2 for port)
 * 
 */
  /*try:*/ {

    /* "btdht/krcp.pyx":1862
 *         """
 *         cdef int j[1]
 *         cdef int c = 0             # <<<<<<<<<<<<<<
 *         cdef int k = i[0] + 1
 *         cdef char** values
 */
    __pyx_v_c = 0;

    /* "btdht/krcp.pyx":1863
 *         cdef int j[1]
 *         cdef int c = 0
 *         cdef int k = i[0] + 1             # <<<<<<<<<<<<<<
 *         cdef char** values
 *         if i[0] >= max:
 */
    __pyx_v_k = ((__pyx_v_i[0]) + 1);

    /* "btdht/krcp.pyx":1865
 *         cdef int k = i[0] + 1
 *         cdef char** values
 *         if i[0] >= max:             # <<<<<<<<<<<<<<
 *             with gil:
 *                 raise DecodeError("%s > %s : %r" % (i[0], max, data[:max]))
 */
    __pyx_t_1 = (((__pyx_v_i[0]) >= __pyx_v_max) != 0);
    if (__pyx_t_1) {

      /* "btdht/krcp.pyx":1866
 *         cdef char** values
 *         if i[0] >= max:
 *             with gil:             # <<<<<<<<<<<<<<
 *                 raise DecodeError("%s > %s : %r" % (i[0], max, data[:max]))
 *         if not data[i[0]] == b'l':
 */
      {
          #ifdef WITH_THREAD
          PyGILState_STATE __pyx_gilstate_save = __Pyx_PyGILState_Ensure();
          #endif
          /*try:*/ {

            /* "btdht/krcp.pyx":1867
 *         if i[0] >= max:
 *             with gil:
 *                 raise DecodeError("%s > %s : %r" % (i[0], max, data[:max]))             # <<<<<<<<<<<<<<
 *         if not data[i[0]] == b'l':
 *             return False
 */
            __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_DecodeError); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1867, __pyx_L8_error)
            __Pyx_GOTREF(__pyx_t_3);
            __pyx_t_4 = __Pyx_PyInt_From_int((__pyx_v_i[0])); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1867, __pyx_L8_error)
            __Pyx_GOTREF(__pyx_t_4);
            __pyx_t_5 = __Pyx_PyInt_From_int(__pyx_v_max); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1867, __pyx_L8_error)
            __Pyx_GOTREF(__pyx_t_5);
            __pyx_t_6 = __Pyx_PyBytes_FromStringAndSize(__pyx_v_data + 0, __pyx_v_max - 0); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1867, __pyx_L8_error)
            __Pyx_GOTREF(__pyx_t_6);
            __pyx_t_7 = PyTuple_New(3); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1867, __pyx_L8_error)
            __Pyx_GOTREF(__pyx_t_7);
            __Pyx_GIVEREF(__pyx_t_4);
            PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_4);
            __Pyx_GIVEREF(__pyx_t_5);
            PyTuple_SET_ITEM(__pyx_t_7, 1, __pyx_t_5);
            __Pyx_GIVEREF(__pyx_t_6);
            PyTuple_SET_ITEM(__pyx_t_7, 2, __pyx_t_6);
            __pyx_t_4 = 0;
            __pyx_t_5 = 0;
            __pyx_t_6 = 0;
            __pyx_t_6 = __Pyx_PyString_Format(__pyx_kp_s_s_s_r, __pyx_t_7); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1867, __pyx_L8_error)
            __Pyx_GOTREF(__pyx_t_6);
            __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
            __pyx_t_7 = NULL;
            if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
              __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_3);
              if (likely(__pyx_t_7)) {
                PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
                __Pyx_INCREF(__pyx_t_7);
                __Pyx_INCREF(function);
                __Pyx_DECREF_SET(__pyx_t_3, function);
              }
            }
            __pyx_t_2 = (__pyx_t_7) ? __Pyx_PyObject_Call2Args(__pyx_t_3, __pyx_t_7, __pyx_t_6) : __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_6);
            __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
            __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
            if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1867, __pyx_L8_error)
            __Pyx_GOTREF(__pyx_t_2);
            __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
            __Pyx_Raise(__pyx_t_2, 0, 0, 0);
            __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
            __PYX_ERR(0, 1867, __pyx_L8_error)
          }

          /* "btdht/krcp.pyx":1866
 *         cdef char** values
 *         if i[0] >= max:
 *             with gil:             # <<<<<<<<<<<<<<
 *                 raise DecodeError("%s > %s : %r" % (i[0], max, data[:max]))
 *         if not data[i[0]] == b'l':
 */
          /*finally:*/ {
            __pyx_L8_error: {
              #ifdef WITH_THREAD
              __Pyx_PyGILState_Release(__pyx_gilstate_save);
              #endif
              goto __pyx_L4_error;
            }
          }
      }

      /* "btdht/krcp.pyx":1865
 *         cdef int k = i[0] + 1
 *         cdef char** values
 *         if i[0] >= max:             # <<<<<<<<<<<<<<
 *             with gil:
 *                 raise DecodeError("%s > %s : %r" % (i[0], max, data[:max]))
 */
    }

    /* "btdht/krcp.pyx":1868
 *             with gil:
 *                 raise DecodeError("%s > %s : %r" % (i[0], max, data[:max]))
 *         if not data[i[0]] == b'l':             # <<<<<<<<<<<<<<
 *             return False
 *         i[0]+=1
 */
    __pyx_t_1 = ((!(((__pyx_v_data[(__pyx_v_i[0])]) == 'l') != 0)) != 0);
    if (__pyx_t_1) {

      /* "btdht/krcp.pyx":1869
 *                 raise DecodeError("%s > %s : %r" % (i[0], max, data[:max]))
 *         if not data[i[0]] == b'l':
 *             return False             # <<<<<<<<<<<<<<
 *         i[0]+=1
 *         while _decode_string(data, i, max, j):
 */
      __pyx_r = 0;
      goto __pyx_L3_return;

      /* "btdht/krcp.pyx":1868
 *             with gil:
 *                 raise DecodeError("%s > %s : %r" % (i[0], max, data[:max]))
 *         if not data[i[0]] == b'l':             # <<<<<<<<<<<<<<
 *             return False
 *         i[0]+=1
 */
    }

    /* "btdht/krcp.pyx":1870
 *         if not data[i[0]] == b'l':
 *             return False
 *         i[0]+=1             # <<<<<<<<<<<<<<
 *         while _decode_string(data, i, max, j):
 *             if (i[0]-j[0]) != 6:
 */
    __pyx_t_8 = 0;
    (__pyx_v_i[__pyx_t_8]) = ((__pyx_v_i[__pyx_t_8]) + 1);

    /* "btdht/krcp.pyx":1871
 *             return False
 *         i[0]+=1
 *         while _decode_string(data, i, max, j):             # <<<<<<<<<<<<<<
 *             if (i[0]-j[0]) != 6:
 *                 self.failed = True
 */
    while (1) {
      __pyx_t_9 = __pyx_f_5btdht_4krcp__decode_string(__pyx_v_data, __pyx_v_i, __pyx_v_max, __pyx_v_j); if (unlikely(__pyx_t_9 == ((int)-1))) __PYX_ERR(0, 1871, __pyx_L4_error)
      __pyx_t_1 = (__pyx_t_9 != 0);
      if (!__pyx_t_1) break;

      /* "btdht/krcp.pyx":1872
 *         i[0]+=1
 *         while _decode_string(data, i, max, j):
 *             if (i[0]-j[0]) != 6:             # <<<<<<<<<<<<<<
 *                 self.failed = True
 *                 self.failed_msg = b"element of values are expected to be of length 6"
 */
      __pyx_t_1 = ((((__pyx_v_i[0]) - (__pyx_v_j[0])) != 6) != 0);
      if (__pyx_t_1) {

        /* "btdht/krcp.pyx":1873
 *         while _decode_string(data, i, max, j):
 *             if (i[0]-j[0]) != 6:
 *                 self.failed = True             # <<<<<<<<<<<<<<
 *                 self.failed_msg = b"element of values are expected to be of length 6"
 *             c+=1
 */
        __pyx_v_self->failed = 1;

        /* "btdht/krcp.pyx":1874
 *             if (i[0]-j[0]) != 6:
 *                 self.failed = True
 *                 self.failed_msg = b"element of values are expected to be of length 6"             # <<<<<<<<<<<<<<
 *             c+=1
 *         if i[0] >=  max or data[i[0]] != b'e':
 */
        __pyx_v_self->failed_msg = ((char *)"element of values are expected to be of length 6");

        /* "btdht/krcp.pyx":1872
 *         i[0]+=1
 *         while _decode_string(data, i, max, j):
 *             if (i[0]-j[0]) != 6:             # <<<<<<<<<<<<<<
 *                 self.failed = True
 *                 self.failed_msg = b"element of values are expected to be of length 6"
 */
      }

      /* "btdht/krcp.pyx":1875
 *                 self.failed = True
 *                 self.failed_msg = b"element of values are expected to be of length 6"
 *             c+=1             # <<<<<<<<<<<<<<
 *         if i[0] >=  max or data[i[0]] != b'e':
 *             with gil:
 */
      __pyx_v_c = (__pyx_v_c + 1);
    }

    /* "btdht/krcp.pyx":1876
 *                 self.failed_msg = b"element of values are expected to be of length 6"
 *             c+=1
 *         if i[0] >=  max or data[i[0]] != b'e':             # <<<<<<<<<<<<<<
 *             with gil:
 *                 raise DecodeError(
 */
    __pyx_t_10 = (((__pyx_v_i[0]) >= __pyx_v_max) != 0);
    if (!__pyx_t_10) {
    } else {
      __pyx_t_1 = __pyx_t_10;
      goto __pyx_L15_bool_binop_done;
    }
    __pyx_t_10 = (((__pyx_v_data[(__pyx_v_i[0])]) != 'e') != 0);
    __pyx_t_1 = __pyx_t_10;
    __pyx_L15_bool_binop_done:;
    if (__pyx_t_1) {

      /* "btdht/krcp.pyx":1877
 *             c+=1
 *         if i[0] >=  max or data[i[0]] != b'e':
 *             with gil:             # <<<<<<<<<<<<<<
 *                 raise DecodeError(
 *                     "End of values list not found %s >= %s found %s elements" % (i[0], max, c)
 */
      {
          #ifdef WITH_THREAD
          PyGILState_STATE __pyx_gilstate_save = __Pyx_PyGILState_Ensure();
          #endif
          /*try:*/ {

            /* "btdht/krcp.pyx":1878
 *         if i[0] >=  max or data[i[0]] != b'e':
 *             with gil:
 *                 raise DecodeError(             # <<<<<<<<<<<<<<
 *                     "End of values list not found %s >= %s found %s elements" % (i[0], max, c)
 *                 )
 */
            __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_DecodeError); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1878, __pyx_L18_error)
            __Pyx_GOTREF(__pyx_t_3);

            /* "btdht/krcp.pyx":1879
 *             with gil:
 *                 raise DecodeError(
 *                     "End of values list not found %s >= %s found %s elements" % (i[0], max, c)             # <<<<<<<<<<<<<<
 *                 )
 *         i[0] = k
 */
            __pyx_t_6 = __Pyx_PyInt_From_int((__pyx_v_i[0])); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1879, __pyx_L18_error)
            __Pyx_GOTREF(__pyx_t_6);
            __pyx_t_7 = __Pyx_PyInt_From_int(__pyx_v_max); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1879, __pyx_L18_error)
            __Pyx_GOTREF(__pyx_t_7);
            __pyx_t_5 = __Pyx_PyInt_From_int(__pyx_v_c); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1879, __pyx_L18_error)
            __Pyx_GOTREF(__pyx_t_5);
            __pyx_t_4 = PyTuple_New(3); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1879, __pyx_L18_error)
            __Pyx_GOTREF(__pyx_t_4);
            __Pyx_GIVEREF(__pyx_t_6);
            PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_6);
            __Pyx_GIVEREF(__pyx_t_7);
            PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_t_7);
            __Pyx_GIVEREF(__pyx_t_5);
            PyTuple_SET_ITEM(__pyx_t_4, 2, __pyx_t_5);
            __pyx_t_6 = 0;
            __pyx_t_7 = 0;
            __pyx_t_5 = 0;
            __pyx_t_5 = __Pyx_PyString_Format(__pyx_kp_s_End_of_values_list_not_found_s_s, __pyx_t_4); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1879, __pyx_L18_error)
            __Pyx_GOTREF(__pyx_t_5);
            __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
            __pyx_t_4 = NULL;
            if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
              __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
              if (likely(__pyx_t_4)) {
                PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
                __Pyx_INCREF(__pyx_t_4);
                __Pyx_INCREF(function);
                __Pyx_DECREF_SET(__pyx_t_3, function);
              }
            }
            __pyx_t_2 = (__pyx_t_4) ? __Pyx_PyObject_Call2Args(__pyx_t_3, __pyx_t_4, __pyx_t_5) : __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_5);
            __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
            __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
            if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1878, __pyx_L18_error)
            __Pyx_GOTREF(__pyx_t_2);
            __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
            __Pyx_Raise(__pyx_t_2, 0, 0, 0);
            __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
            __PYX_ERR(0, 1878, __pyx_L18_error)
          }

          /* "btdht/krcp.pyx":1877
 *             c+=1
 *         if i[0] >=  max or data[i[0]] != b'e':
 *             with gil:             # <<<<<<<<<<<<<<
 *                 raise DecodeError(
 *                     "End of values list not found %s >= %s found %s elements" % (i[0], max, c)
 */
          /*finally:*/ {
            __pyx_L18_error: {
              #ifdef WITH_THREAD
              __Pyx_PyGILState_Release(__pyx_gilstate_save);
              #endif
              goto __pyx_L4_error;
            }
          }
      }

      /* "btdht/krcp.pyx":1876
 *                 self.failed_msg = b"element of values are expected to be of length 6"
 *             c+=1
 *         if i[0] >=  max or data[i[0]] != b'e':             # <<<<<<<<<<<<<<
 *             with gil:
 *                 raise DecodeError(
 */
    }

    /* "btdht/krcp.pyx":1881
 *                     "End of values list not found %s >= %s found %s elements" % (i[0], max, c)
 *                 )
 *         i[0] = k             # <<<<<<<<<<<<<<
 *         values = <char **>malloc(c * sizeof(char*))
 *         c=0
 */
    (__pyx_v_i[0]) = __pyx_v_k;

    /* "btdht/krcp.pyx":1882
 *                 )
 *         i[0] = k
 *         values = <char **>malloc(c * sizeof(char*))             # <<<<<<<<<<<<<<
 *         c=0
 *         while _decode_string(data, i, max, j):
 */
    __pyx_v_values = ((char **)malloc((__pyx_v_c * (sizeof(char *)))));

    /* "btdht/krcp.pyx":1883
 *         i[0] = k
 *         values = <char **>malloc(c * sizeof(char*))
 *         c=0             # <<<<<<<<<<<<<<
 *         while _decode_string(data, i, max, j):
 *            values[c] = <char *>malloc( 6 * sizeof(char))
 */
    __pyx_v_c = 0;

    /* "btdht/krcp.pyx":1884
 *         values = <char **>malloc(c * sizeof(char*))
 *         c=0
 *         while _decode_string(data, i, max, j):             # <<<<<<<<<<<<<<
 *            values[c] = <char *>malloc( 6 * sizeof(char))
 *            strncpy(values[c], data + j[0], 6)
 */
    while (1) {
      __pyx_t_9 = __pyx_f_5btdht_4krcp__decode_string(__pyx_v_data, __pyx_v_i, __pyx_v_max, __pyx_v_j); if (unlikely(__pyx_t_9 == ((int)-1))) __PYX_ERR(0, 1884, __pyx_L4_error)
      __pyx_t_1 = (__pyx_t_9 != 0);
      if (!__pyx_t_1) break;

      /* "btdht/krcp.pyx":1885
 *         c=0
 *         while _decode_string(data, i, max, j):
 *            values[c] = <char *>malloc( 6 * sizeof(char))             # <<<<<<<<<<<<<<
 *            strncpy(values[c], data + j[0], 6)
 *            c+=1
 */
      (__pyx_v_values[__pyx_v_c]) = ((char *)malloc((6 * (sizeof(char)))));

      /* "btdht/krcp.pyx":1886
 *         while _decode_string(data, i, max, j):
 *            values[c] = <char *>malloc( 6 * sizeof(char))
 *            strncpy(values[c], data + j[0], 6)             # <<<<<<<<<<<<<<
 *            c+=1
 *         self.set_values(values, c)
 */
      (void)(strncpy((__pyx_v_values[__pyx_v_c]), (__pyx_v_data + (__pyx_v_j[0])), 6));

      /* "btdht/krcp.pyx":1887
 *            values[c] = <char *>malloc( 6 * sizeof(char))
 *            strncpy(values[c], data + j[0], 6)
 *            c+=1             # <<<<<<<<<<<<<<
 *         self.set_values(values, c)
 *         i[0]+=1
 */
      __pyx_v_c = (__pyx_v_c + 1);
    }

    /* "btdht/krcp.pyx":1888
 *            strncpy(values[c], data + j[0], 6)
 *            c+=1
 *         self.set_values(values, c)             # <<<<<<<<<<<<<<
 *         i[0]+=1
 *         return True
 */
    (void)(((struct __pyx_vtabstruct_5btdht_4krcp_BMessage *)__pyx_v_self->__pyx_vtab)->set_values(__pyx_v_self, __pyx_v_values, __pyx_v_c));

    /* "btdht/krcp.pyx":1889
 *            c+=1
 *         self.set_values(values, c)
 *         i[0]+=1             # <<<<<<<<<<<<<<
 *         return True
 * 
 */
    __pyx_t_8 = 0;
    (__pyx_v_i[__pyx_t_8]) = ((__pyx_v_i[__pyx_t_8]) + 1);

    /* "btdht/krcp.pyx":1890
 *         self.set_values(values, c)
 *         i[0]+=1
 *         return True             # <<<<<<<<<<<<<<
 * 
 *     cdef int _decode_dict(self, char* data, int *i, int max) nogil except -1:
 */
    __pyx_r = 1;
    goto __pyx_L3_return;
  }

  /* "btdht/krcp.pyx":1845
 * 
 *     cdef int _decode_values(self, char* data, int *i, int max) nogil except -1:
 *         """             # <<<<<<<<<<<<<<
 *             Bdecode a values list of peers in compact forms (6 Bytes, 4 for ip and 2 for port)
 * 
 */
  /*finally:*/ {
    __pyx_L3_return: {
      #ifdef WITH_THREAD
      __pyx_gilstate_save = __Pyx_PyGILState_Ensure();
      #endif
      goto __pyx_L0;
    }
    __pyx_L4_error: {
      #ifdef WITH_THREAD
      __pyx_gilstate_save = __Pyx_PyGILState_Ensure();
      #endif
      goto __pyx_L1_error;
    }
  }

  /* "btdht/krcp.pyx":1844
 *             raise DecodeError("Unable to decode element of dict at %d %r" % (j[0], data[:max]))
 * 
 *     cdef int _decode_values(self, char* data, int *i, int max) nogil except -1:             # <<<<<<<<<<<<<<
 *         """
 *             Bdecode a values list of peers in compact forms (6 Bytes, 4 for ip and 2 for port)
 */

  /* function exit code */
  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_AddTraceback("btdht.krcp.BMessage._decode_values", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  #ifdef WITH_THREAD
  __Pyx_PyGILState_Release(__pyx_gilstate_save);
  #endif
  return __pyx_r;
}

/* "btdht/krcp.pyx":1892
 *         return True
 * 
 *     cdef int _decode_dict(self, char* data, int *i, int max) nogil except -1:             # <<<<<<<<<<<<<<
 *         """
 *             Bdecode a dictionnary, element by element.
 */

static int __pyx_f_5btdht_4krcp_8BMessage__decode_dict(struct __pyx_obj_5btdht_4krcp_BMessage *__pyx_v_self, char *__pyx_v_data, int *__pyx_v_i, int __pyx_v_max) {
  int __pyx_v_k;
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  long __pyx_t_2;
  int __pyx_t_3;
  int __pyx_t_4;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  PyObject *__pyx_t_7 = NULL;
  PyObject *__pyx_t_8 = NULL;
  PyObject *__pyx_t_9 = NULL;
  PyObject *__pyx_t_10 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  #ifdef WITH_THREAD
  PyGILState_STATE __pyx_gilstate_save = __Pyx_PyGILState_Ensure();
  #endif
  __Pyx_RefNannySetupContext("_decode_dict", 0);
  #ifdef WITH_THREAD
  __Pyx_PyGILState_Release(__pyx_gilstate_save);
  #endif

  /* "btdht/krcp.pyx":1893
 * 
 *     cdef int _decode_dict(self, char* data, int *i, int max) nogil except -1:
 *         """             # <<<<<<<<<<<<<<
 *             Bdecode a dictionnary, element by element.
 * 
 */
  /*try:*/ {

    /* "btdht/krcp.pyx":1906
 *         """
 *         cdef int k
 *         if data[i[0]] == b'd':             # <<<<<<<<<<<<<<
 *             i[0]+=1
 *             while data[i[0]] != b'e' and i[0] < max:
 */
    __pyx_t_1 = (((__pyx_v_data[(__pyx_v_i[0])]) == 'd') != 0);
    if (__pyx_t_1) {

      /* "btdht/krcp.pyx":1907
 *         cdef int k
 *         if data[i[0]] == b'd':
 *             i[0]+=1             # <<<<<<<<<<<<<<
 *             while data[i[0]] != b'e' and i[0] < max:
 *                 k = i[0]
 */
      __pyx_t_2 = 0;
      (__pyx_v_i[__pyx_t_2]) = ((__pyx_v_i[__pyx_t_2]) + 1);

      /* "btdht/krcp.pyx":1908
 *         if data[i[0]] == b'd':
 *             i[0]+=1
 *             while data[i[0]] != b'e' and i[0] < max:             # <<<<<<<<<<<<<<
 *                 k = i[0]
 *                 if not self._decode_dict_elm(data, i, max):
 */
      while (1) {
        __pyx_t_3 = (((__pyx_v_data[(__pyx_v_i[0])]) != 'e') != 0);
        if (__pyx_t_3) {
        } else {
          __pyx_t_1 = __pyx_t_3;
          goto __pyx_L9_bool_binop_done;
        }
        __pyx_t_3 = (((__pyx_v_i[0]) < __pyx_v_max) != 0);
        __pyx_t_1 = __pyx_t_3;
        __pyx_L9_bool_binop_done:;
        if (!__pyx_t_1) break;

        /* "btdht/krcp.pyx":1909
 *             i[0]+=1
 *             while data[i[0]] != b'e' and i[0] < max:
 *                 k = i[0]             # <<<<<<<<<<<<<<
 *                 if not self._decode_dict_elm(data, i, max):
 *                     with gil:
 */
        __pyx_v_k = (__pyx_v_i[0]);

        /* "btdht/krcp.pyx":1910
 *             while data[i[0]] != b'e' and i[0] < max:
 *                 k = i[0]
 *                 if not self._decode_dict_elm(data, i, max):             # <<<<<<<<<<<<<<
 *                     with gil:
 *                         raise DecodeError("fail to decode dict element %d %r" % (k, data[:max]))
 */
        __pyx_t_4 = ((struct __pyx_vtabstruct_5btdht_4krcp_BMessage *)__pyx_v_self->__pyx_vtab)->_decode_dict_elm(__pyx_v_self, __pyx_v_data, __pyx_v_i, __pyx_v_max); if (unlikely(__pyx_t_4 == ((int)-1))) __PYX_ERR(0, 1910, __pyx_L4_error)
        __pyx_t_1 = ((!(__pyx_t_4 != 0)) != 0);
        if (__pyx_t_1) {

          /* "btdht/krcp.pyx":1911
 *                 k = i[0]
 *                 if not self._decode_dict_elm(data, i, max):
 *                     with gil:             # <<<<<<<<<<<<<<
 *                         raise DecodeError("fail to decode dict element %d %r" % (k, data[:max]))
 *         if data[i[0]] != b'e':
 */
          {
              #ifdef WITH_THREAD
              PyGILState_STATE __pyx_gilstate_save = __Pyx_PyGILState_Ensure();
              #endif
              /*try:*/ {

                /* "btdht/krcp.pyx":1912
 *                 if not self._decode_dict_elm(data, i, max):
 *                     with gil:
 *                         raise DecodeError("fail to decode dict element %d %r" % (k, data[:max]))             # <<<<<<<<<<<<<<
 *         if data[i[0]] != b'e':
 *             with gil:
 */
                __Pyx_GetModuleGlobalName(__pyx_t_6, __pyx_n_s_DecodeError); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1912, __pyx_L15_error)
                __Pyx_GOTREF(__pyx_t_6);
                __pyx_t_7 = __Pyx_PyInt_From_int(__pyx_v_k); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1912, __pyx_L15_error)
                __Pyx_GOTREF(__pyx_t_7);
                __pyx_t_8 = __Pyx_PyBytes_FromStringAndSize(__pyx_v_data + 0, __pyx_v_max - 0); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 1912, __pyx_L15_error)
                __Pyx_GOTREF(__pyx_t_8);
                __pyx_t_9 = PyTuple_New(2); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 1912, __pyx_L15_error)
                __Pyx_GOTREF(__pyx_t_9);
                __Pyx_GIVEREF(__pyx_t_7);
                PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_t_7);
                __Pyx_GIVEREF(__pyx_t_8);
                PyTuple_SET_ITEM(__pyx_t_9, 1, __pyx_t_8);
                __pyx_t_7 = 0;
                __pyx_t_8 = 0;
                __pyx_t_8 = __Pyx_PyString_Format(__pyx_kp_s_fail_to_decode_dict_element_d_r, __pyx_t_9); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 1912, __pyx_L15_error)
                __Pyx_GOTREF(__pyx_t_8);
                __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
                __pyx_t_9 = NULL;
                if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_6))) {
                  __pyx_t_9 = PyMethod_GET_SELF(__pyx_t_6);
                  if (likely(__pyx_t_9)) {
                    PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6);
                    __Pyx_INCREF(__pyx_t_9);
                    __Pyx_INCREF(function);
                    __Pyx_DECREF_SET(__pyx_t_6, function);
                  }
                }
                __pyx_t_5 = (__pyx_t_9) ? __Pyx_PyObject_Call2Args(__pyx_t_6, __pyx_t_9, __pyx_t_8) : __Pyx_PyObject_CallOneArg(__pyx_t_6, __pyx_t_8);
                __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
                __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
                if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1912, __pyx_L15_error)
                __Pyx_GOTREF(__pyx_t_5);
                __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
                __Pyx_Raise(__pyx_t_5, 0, 0, 0);
                __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
                __PYX_ERR(0, 1912, __pyx_L15_error)
              }

              /* "btdht/krcp.pyx":1911
 *                 k = i[0]
 *                 if not self._decode_dict_elm(data, i, max):
 *                     with gil:             # <<<<<<<<<<<<<<
 *                         raise DecodeError("fail to decode dict element %d %r" % (k, data[:max]))
 *         if data[i[0]] != b'e':
 */
              /*finally:*/ {
                __pyx_L15_error: {
                  #ifdef WITH_THREAD
                  __Pyx_PyGILState_Release(__pyx_gilstate_save);
                  #endif
                  goto __pyx_L4_error;
                }
              }
          }

          /* "btdht/krcp.pyx":1910
 *             while data[i[0]] != b'e' and i[0] < max:
 *                 k = i[0]
 *                 if not self._decode_dict_elm(data, i, max):             # <<<<<<<<<<<<<<
 *                     with gil:
 *                         raise DecodeError("fail to decode dict element %d %r" % (k, data[:max]))
 */
        }
      }

      /* "btdht/krcp.pyx":1906
 *         """
 *         cdef int k
 *         if data[i[0]] == b'd':             # <<<<<<<<<<<<<<
 *             i[0]+=1
 *             while data[i[0]] != b'e' and i[0] < max:
 */
    }

    /* "btdht/krcp.pyx":1913
 *                     with gil:
 *                         raise DecodeError("fail to decode dict element %d %r" % (k, data[:max]))
 *         if data[i[0]] != b'e':             # <<<<<<<<<<<<<<
 *             with gil:
 *                 raise DecodeError("End of dict not found %s>=%d %r" % (i[0], max, data[:max]))
 */
    __pyx_t_1 = (((__pyx_v_data[(__pyx_v_i[0])]) != 'e') != 0);
    if (__pyx_t_1) {

      /* "btdht/krcp.pyx":1914
 *                         raise DecodeError("fail to decode dict element %d %r" % (k, data[:max]))
 *         if data[i[0]] != b'e':
 *             with gil:             # <<<<<<<<<<<<<<
 *                 raise DecodeError("End of dict not found %s>=%d %r" % (i[0], max, data[:max]))
 *         else:
 */
      {
          #ifdef WITH_THREAD
          PyGILState_STATE __pyx_gilstate_save = __Pyx_PyGILState_Ensure();
          #endif
          /*try:*/ {

            /* "btdht/krcp.pyx":1915
 *         if data[i[0]] != b'e':
 *             with gil:
 *                 raise DecodeError("End of dict not found %s>=%d %r" % (i[0], max, data[:max]))             # <<<<<<<<<<<<<<
 *         else:
 *             i[0]+=1
 */
            __Pyx_GetModuleGlobalName(__pyx_t_6, __pyx_n_s_DecodeError); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1915, __pyx_L19_error)
            __Pyx_GOTREF(__pyx_t_6);
            __pyx_t_8 = __Pyx_PyInt_From_int((__pyx_v_i[0])); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 1915, __pyx_L19_error)
            __Pyx_GOTREF(__pyx_t_8);
            __pyx_t_9 = __Pyx_PyInt_From_int(__pyx_v_max); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 1915, __pyx_L19_error)
            __Pyx_GOTREF(__pyx_t_9);
            __pyx_t_7 = __Pyx_PyBytes_FromStringAndSize(__pyx_v_data + 0, __pyx_v_max - 0); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1915, __pyx_L19_error)
            __Pyx_GOTREF(__pyx_t_7);
            __pyx_t_10 = PyTuple_New(3); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 1915, __pyx_L19_error)
            __Pyx_GOTREF(__pyx_t_10);
            __Pyx_GIVEREF(__pyx_t_8);
            PyTuple_SET_ITEM(__pyx_t_10, 0, __pyx_t_8);
            __Pyx_GIVEREF(__pyx_t_9);
            PyTuple_SET_ITEM(__pyx_t_10, 1, __pyx_t_9);
            __Pyx_GIVEREF(__pyx_t_7);
            PyTuple_SET_ITEM(__pyx_t_10, 2, __pyx_t_7);
            __pyx_t_8 = 0;
            __pyx_t_9 = 0;
            __pyx_t_7 = 0;
            __pyx_t_7 = __Pyx_PyString_Format(__pyx_kp_s_End_of_dict_not_found_s_d_r, __pyx_t_10); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1915, __pyx_L19_error)
            __Pyx_GOTREF(__pyx_t_7);
            __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
            __pyx_t_10 = NULL;
            if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_6))) {
              __pyx_t_10 = PyMethod_GET_SELF(__pyx_t_6);
              if (likely(__pyx_t_10)) {
                PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6);
                __Pyx_INCREF(__pyx_t_10);
                __Pyx_INCREF(function);
                __Pyx_DECREF_SET(__pyx_t_6, function);
              }
            }
            __pyx_t_5 = (__pyx_t_10) ? __Pyx_PyObject_Call2Args(__pyx_t_6, __pyx_t_10, __pyx_t_7) : __Pyx_PyObject_CallOneArg(__pyx_t_6, __pyx_t_7);
            __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
            __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
            if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1915, __pyx_L19_error)
            __Pyx_GOTREF(__pyx_t_5);
            __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
            __Pyx_Raise(__pyx_t_5, 0, 0, 0);
            __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
            __PYX_ERR(0, 1915, __pyx_L19_error)
          }

          /* "btdht/krcp.pyx":1914
 *                         raise DecodeError("fail to decode dict element %d %r" % (k, data[:max]))
 *         if data[i[0]] != b'e':
 *             with gil:             # <<<<<<<<<<<<<<
 *                 raise DecodeError("End of dict not found %s>=%d %r" % (i[0], max, data[:max]))
 *         else:
 */
          /*finally:*/ {
            __pyx_L19_error: {
              #ifdef WITH_THREAD
              __Pyx_PyGILState_Release(__pyx_gilstate_save);
              #endif
              goto __pyx_L4_error;
            }
          }
      }

      /* "btdht/krcp.pyx":1913
 *                     with gil:
 *                         raise DecodeError("fail to decode dict element %d %r" % (k, data[:max]))
 *         if data[i[0]] != b'e':             # <<<<<<<<<<<<<<
 *             with gil:
 *                 raise DecodeError("End of dict not found %s>=%d %r" % (i[0], max, data[:max]))
 */
    }

    /* "btdht/krcp.pyx":1917
 *                 raise DecodeError("End of dict not found %s>=%d %r" % (i[0], max, data[:max]))
 *         else:
 *             i[0]+=1             # <<<<<<<<<<<<<<
 *             return True
 * 
 */
    /*else*/ {
      __pyx_t_2 = 0;
      (__pyx_v_i[__pyx_t_2]) = ((__pyx_v_i[__pyx_t_2]) + 1);

      /* "btdht/krcp.pyx":1918
 *         else:
 *             i[0]+=1
 *             return True             # <<<<<<<<<<<<<<
 * 
 *     cdef int _decode(self, char* data, int *i, int max) nogil except -1:
 */
      __pyx_r = 1;
      goto __pyx_L3_return;
    }
  }

  /* "btdht/krcp.pyx":1893
 * 
 *     cdef int _decode_dict(self, char* data, int *i, int max) nogil except -1:
 *         """             # <<<<<<<<<<<<<<
 *             Bdecode a dictionnary, element by element.
 * 
 */
  /*finally:*/ {
    __pyx_L3_return: {
      #ifdef WITH_THREAD
      __pyx_gilstate_save = __Pyx_PyGILState_Ensure();
      #endif
      goto __pyx_L0;
    }
    __pyx_L4_error: {
      #ifdef WITH_THREAD
      __pyx_gilstate_save = __Pyx_PyGILState_Ensure();
      #endif
      goto __pyx_L1_error;
    }
  }

  /* "btdht/krcp.pyx":1892
 *         return True
 * 
 *     cdef int _decode_dict(self, char* data, int *i, int max) nogil except -1:             # <<<<<<<<<<<<<<
 *         """
 *             Bdecode a dictionnary, element by element.
 */

  /* function exit code */
  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_XDECREF(__pyx_t_9);
  __Pyx_XDECREF(__pyx_t_10);
  __Pyx_AddTraceback("btdht.krcp.BMessage._decode_dict", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  #ifdef WITH_THREAD
  __Pyx_PyGILState_Release(__pyx_gilstate_save);
  #endif
  return __pyx_r;
}

/* "btdht/krcp.pyx":1920
 *             return True
 * 
 *     cdef int _decode(self, char* data, int *i, int max) nogil except -1:             # <<<<<<<<<<<<<<
 *         """
 *             Bdecode a bencoded message and set the current :class:`BMessage` attributes accordingly
 */

static int __pyx_f_5btdht_4krcp_8BMessage__decode(struct __pyx_obj_5btdht_4krcp_BMessage *__pyx_v_self, char *__pyx_v_data, int *__pyx_v_i, int __pyx_v_max) {
  int __pyx_r;
  int __pyx_t_1;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;

  /* "btdht/krcp.pyx":1931
 *                 This method can be called without the python GIL
 *         """
 *         return self._decode_dict(data, i, max)             # <<<<<<<<<<<<<<
 * 
 *     def  __init__(self, addr=None, debug=False):
 */
  __pyx_t_1 = ((struct __pyx_vtabstruct_5btdht_4krcp_BMessage *)__pyx_v_self->__pyx_vtab)->_decode_dict(__pyx_v_self, __pyx_v_data, __pyx_v_i, __pyx_v_max); if (unlikely(__pyx_t_1 == ((int)-1))) __PYX_ERR(0, 1931, __pyx_L1_error)
  __pyx_r = __pyx_t_1;
  goto __pyx_L0;

  /* "btdht/krcp.pyx":1920
 *             return True
 * 
 *     cdef int _decode(self, char* data, int *i, int max) nogil except -1:             # <<<<<<<<<<<<<<
 *         """
 *             Bdecode a bencoded message and set the current :class:`BMessage` attributes accordingly
 */

  /* function exit code */
  __pyx_L1_error:;
  {
    #ifdef WITH_THREAD
    PyGILState_STATE __pyx_gilstate_save = __Pyx_PyGILState_Ensure();
    #endif
    __Pyx_AddTraceback("btdht.krcp.BMessage._decode", __pyx_clineno, __pyx_lineno, __pyx_filename);
    #ifdef WITH_THREAD
    __Pyx_PyGILState_Release(__pyx_gilstate_save);
    #endif
  }
  __pyx_r = -1;
  __pyx_L0:;
  return __pyx_r;
}

/* "btdht/krcp.pyx":1933
 *         return self._decode_dict(data, i, max)
 * 
 *     def  __init__(self, addr=None, debug=False):             # <<<<<<<<<<<<<<
 *         self.addr = addr
 * 
 */

/* Python wrapper */
static int __pyx_pw_5btdht_4krcp_8BMessage_19__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static int __pyx_pw_5btdht_4krcp_8BMessage_19__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_addr = 0;
  CYTHON_UNUSED PyObject *__pyx_v_debug = 0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__init__ (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_addr,&__pyx_n_s_debug,0};
    PyObject* values[2] = {0,0};
    values[0] = ((PyObject *)Py_None);
    values[1] = ((PyObject *)Py_False);
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_addr);
          if (value) { values[0] = value; kw_args--; }
        }
        CYTHON_FALLTHROUGH;
        case  1:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_debug);
          if (value) { values[1] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__init__") < 0)) __PYX_ERR(0, 1933, __pyx_L3_error)
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    __pyx_v_addr = values[0];
    __pyx_v_debug = values[1];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("__init__", 0, 0, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 1933, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("btdht.krcp.BMessage.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return -1;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_5btdht_4krcp_8BMessage_18__init__(((struct __pyx_obj_5btdht_4krcp_BMessage *)__pyx_v_self), __pyx_v_addr, __pyx_v_debug);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static int __pyx_pf_5btdht_4krcp_8BMessage_18__init__(struct __pyx_obj_5btdht_4krcp_BMessage *__pyx_v_self, PyObject *__pyx_v_addr, CYTHON_UNUSED PyObject *__pyx_v_debug) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__init__", 0);

  /* "btdht/krcp.pyx":1934
 * 
 *     def  __init__(self, addr=None, debug=False):
 *         self.addr = addr             # <<<<<<<<<<<<<<
 * 
 *     def __cinit__(self, addr=None, debug=False):
 */
  if (__Pyx_PyObject_SetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_addr, __pyx_v_addr) < 0) __PYX_ERR(0, 1934, __pyx_L1_error)

  /* "btdht/krcp.pyx":1933
 *         return self._decode_dict(data, i, max)
 * 
 *     def  __init__(self, addr=None, debug=False):             # <<<<<<<<<<<<<<
 *         self.addr = addr
 * 
 */

  /* function exit code */
  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_AddTraceback("btdht.krcp.BMessage.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "btdht/krcp.pyx":1936
 *         self.addr = addr
 * 
 *     def __cinit__(self, addr=None, debug=False):             # <<<<<<<<<<<<<<
 *         self.debug = True if debug else False
 *         with nogil:
 */

/* Python wrapper */
static int __pyx_pw_5btdht_4krcp_8BMessage_21__cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static int __pyx_pw_5btdht_4krcp_8BMessage_21__cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  CYTHON_UNUSED PyObject *__pyx_v_addr = 0;
  PyObject *__pyx_v_debug = 0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__cinit__ (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_addr,&__pyx_n_s_debug,0};
    PyObject* values[2] = {0,0};
    values[0] = ((PyObject *)Py_None);
    values[1] = ((PyObject *)Py_False);
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_addr);
          if (value) { values[0] = value; kw_args--; }
        }
        CYTHON_FALLTHROUGH;
        case  1:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_debug);
          if (value) { values[1] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__cinit__") < 0)) __PYX_ERR(0, 1936, __pyx_L3_error)
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    __pyx_v_addr = values[0];
    __pyx_v_debug = values[1];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("__cinit__", 0, 0, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 1936, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("btdht.krcp.BMessage.__cinit__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return -1;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_5btdht_4krcp_8BMessage_20__cinit__(((struct __pyx_obj_5btdht_4krcp_BMessage *)__pyx_v_self), __pyx_v_addr, __pyx_v_debug);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static int __pyx_pf_5btdht_4krcp_8BMessage_20__cinit__(struct __pyx_obj_5btdht_4krcp_BMessage *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v_addr, PyObject *__pyx_v_debug) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  int __pyx_t_2;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__cinit__", 0);

  /* "btdht/krcp.pyx":1937
 * 
 *     def __cinit__(self, addr=None, debug=False):
 *         self.debug = True if debug else False             # <<<<<<<<<<<<<<
 *         with nogil:
 *             self.values_nb = 0
 */
  __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_v_debug); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(0, 1937, __pyx_L1_error)
  if (__pyx_t_2) {
    __pyx_t_1 = 1;
  } else {
    __pyx_t_1 = 0;
  }
  __pyx_v_self->debug = __pyx_t_1;

  /* "btdht/krcp.pyx":1938
 *     def __cinit__(self, addr=None, debug=False):
 *         self.debug = True if debug else False
 *         with nogil:             # <<<<<<<<<<<<<<
 *             self.values_nb = 0
 *             self.errmsg_len = 0
 */
  {
      #ifdef WITH_THREAD
      PyThreadState *_save;
      Py_UNBLOCK_THREADS
      __Pyx_FastGIL_Remember();
      #endif
      /*try:*/ {

        /* "btdht/krcp.pyx":1939
 *         self.debug = True if debug else False
 *         with nogil:
 *             self.values_nb = 0             # <<<<<<<<<<<<<<
 *             self.errmsg_len = 0
 *             self.encoded_len = 0
 */
        __pyx_v_self->values_nb = 0;

        /* "btdht/krcp.pyx":1940
 *         with nogil:
 *             self.values_nb = 0
 *             self.errmsg_len = 0             # <<<<<<<<<<<<<<
 *             self.encoded_len = 0
 *             self.r = False
 */
        __pyx_v_self->errmsg_len = 0;

        /* "btdht/krcp.pyx":1941
 *             self.values_nb = 0
 *             self.errmsg_len = 0
 *             self.encoded_len = 0             # <<<<<<<<<<<<<<
 *             self.r = False
 *             self.a = False
 */
        __pyx_v_self->encoded_len = 0;

        /* "btdht/krcp.pyx":1942
 *             self.errmsg_len = 0
 *             self.encoded_len = 0
 *             self.r = False             # <<<<<<<<<<<<<<
 *             self.a = False
 *             self.e = False
 */
        __pyx_v_self->r = 0;

        /* "btdht/krcp.pyx":1943
 *             self.encoded_len = 0
 *             self.r = False
 *             self.a = False             # <<<<<<<<<<<<<<
 *             self.e = False
 *             self.failed = False
 */
        __pyx_v_self->a = 0;

        /* "btdht/krcp.pyx":1944
 *             self.r = False
 *             self.a = False
 *             self.e = False             # <<<<<<<<<<<<<<
 *             self.failed = False
 *             self.has_y = False
 */
        __pyx_v_self->e = 0;

        /* "btdht/krcp.pyx":1945
 *             self.a = False
 *             self.e = False
 *             self.failed = False             # <<<<<<<<<<<<<<
 *             self.has_y = False
 *             self.has_t = False
 */
        __pyx_v_self->failed = 0;

        /* "btdht/krcp.pyx":1946
 *             self.e = False
 *             self.failed = False
 *             self.has_y = False             # <<<<<<<<<<<<<<
 *             self.has_t = False
 *             self.has_q = False
 */
        __pyx_v_self->has_y = 0;

        /* "btdht/krcp.pyx":1947
 *             self.failed = False
 *             self.has_y = False
 *             self.has_t = False             # <<<<<<<<<<<<<<
 *             self.has_q = False
 *             self.has_v = False
 */
        __pyx_v_self->has_t = 0;

        /* "btdht/krcp.pyx":1948
 *             self.has_y = False
 *             self.has_t = False
 *             self.has_q = False             # <<<<<<<<<<<<<<
 *             self.has_v = False
 *             self.has_id = False
 */
        __pyx_v_self->has_q = 0;

        /* "btdht/krcp.pyx":1949
 *             self.has_t = False
 *             self.has_q = False
 *             self.has_v = False             # <<<<<<<<<<<<<<
 *             self.has_id = False
 *             self.has_target = False
 */
        __pyx_v_self->has_v = 0;

        /* "btdht/krcp.pyx":1950
 *             self.has_q = False
 *             self.has_v = False
 *             self.has_id = False             # <<<<<<<<<<<<<<
 *             self.has_target = False
 *             self.has_info_hash = False
 */
        __pyx_v_self->has_id = 0;

        /* "btdht/krcp.pyx":1951
 *             self.has_v = False
 *             self.has_id = False
 *             self.has_target = False             # <<<<<<<<<<<<<<
 *             self.has_info_hash = False
 *             self.has_token = False
 */
        __pyx_v_self->has_target = 0;

        /* "btdht/krcp.pyx":1952
 *             self.has_id = False
 *             self.has_target = False
 *             self.has_info_hash = False             # <<<<<<<<<<<<<<
 *             self.has_token = False
 *             self.has_nodes = False
 */
        __pyx_v_self->has_info_hash = 0;

        /* "btdht/krcp.pyx":1953
 *             self.has_target = False
 *             self.has_info_hash = False
 *             self.has_token = False             # <<<<<<<<<<<<<<
 *             self.has_nodes = False
 *             self.has_values = False
 */
        __pyx_v_self->has_token = 0;

        /* "btdht/krcp.pyx":1954
 *             self.has_info_hash = False
 *             self.has_token = False
 *             self.has_nodes = False             # <<<<<<<<<<<<<<
 *             self.has_values = False
 *             self.encoded_uptodate = False
 */
        __pyx_v_self->has_nodes = 0;

        /* "btdht/krcp.pyx":1955
 *             self.has_token = False
 *             self.has_nodes = False
 *             self.has_values = False             # <<<<<<<<<<<<<<
 *             self.encoded_uptodate = False
 * 
 */
        __pyx_v_self->has_values = 0;

        /* "btdht/krcp.pyx":1956
 *             self.has_nodes = False
 *             self.has_values = False
 *             self.encoded_uptodate = False             # <<<<<<<<<<<<<<
 * 
 *     def decode(self, char* data, int datalen):
 */
        __pyx_v_self->encoded_uptodate = 0;
      }

      /* "btdht/krcp.pyx":1938
 *     def __cinit__(self, addr=None, debug=False):
 *         self.debug = True if debug else False
 *         with nogil:             # <<<<<<<<<<<<<<
 *             self.values_nb = 0
 *             self.errmsg_len = 0
 */
      /*finally:*/ {
        /*normal exit:*/{
          #ifdef WITH_THREAD
          __Pyx_FastGIL_Forget();
          Py_BLOCK_THREADS
          #endif
          goto __pyx_L5;
        }
        __pyx_L5:;
      }
  }

  /* "btdht/krcp.pyx":1936
 *         self.addr = addr
 * 
 *     def __cinit__(self, addr=None, debug=False):             # <<<<<<<<<<<<<<
 *         self.debug = True if debug else False
 *         with nogil:
 */

  /* function exit code */
  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_AddTraceback("btdht.krcp.BMessage.__cinit__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "btdht/krcp.pyx":1958
 *             self.encoded_uptodate = False
 * 
 *     def decode(self, char* data, int datalen):             # <<<<<<<<<<<<<<
 *         """
 *             Bdecode a bencoded message and set the current :class:`BMessage` attributes accordingly
 */

/* Python wrapper */
static PyObject *__pyx_pw_5btdht_4krcp_8BMessage_23decode(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_5btdht_4krcp_8BMessage_22decode[] = "\n            Bdecode a bencoded message and set the current :class:`BMessage` attributes accordingly\n\n            :param bytes data: The bencoded message\n            :param int datalen: The length of ``data``\n            :return: The remaining of ``data`` after the first bencoded message of ``data`` has been\n                bdecoded (it may be the empty string if ``data`` contains exactly one bencoded\n                message with no garbade at the end).\n            :raises DecodeError: If we fail to decode the message\n            :raises ProtocolError: If the message is decoded but some attributes are missing of\n                badly formated (length, type, ...).\n            :raises MissingT: If the message do not have a ``b\"t\"`` key. Indeed,\n                accordingly to the BEP5, every message (queries, responses, errors) should have\n                a ``b\"t\"`` key.\n        ";
static PyObject *__pyx_pw_5btdht_4krcp_8BMessage_23decode(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  char *__pyx_v_data;
  int __pyx_v_datalen;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("decode (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_data,&__pyx_n_s_datalen,0};
    PyObject* values[2] = {0,0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_data)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_datalen)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("decode", 1, 2, 2, 1); __PYX_ERR(0, 1958, __pyx_L3_error)
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "decode") < 0)) __PYX_ERR(0, 1958, __pyx_L3_error)
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) != 2) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
    }
    __pyx_v_data = __Pyx_PyObject_AsWritableString(values[0]); if (unlikely((!__pyx_v_data) && PyErr_Occurred())) __PYX_ERR(0, 1958, __pyx_L3_error)
    __pyx_v_datalen = __Pyx_PyInt_As_int(values[1]); if (unlikely((__pyx_v_datalen == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 1958, __pyx_L3_error)
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("decode", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 1958, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("btdht.krcp.BMessage.decode", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_5btdht_4krcp_8BMessage_22decode(((struct __pyx_obj_5btdht_4krcp_BMessage *)__pyx_v_self), __pyx_v_data, __pyx_v_datalen);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5btdht_4krcp_8BMessage_22decode(struct __pyx_obj_5btdht_4krcp_BMessage *__pyx_v_self, char *__pyx_v_data, int __pyx_v_datalen) {
  int __pyx_v_i;
  int __pyx_v_valid;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  int __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  int __pyx_t_6;
  PyObject *__pyx_t_7 = NULL;
  PyObject *__pyx_t_8 = NULL;
  PyObject *__pyx_t_9 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("decode", 0);

  /* "btdht/krcp.pyx":1974
 *                 a ``b"t"`` key.
 *         """
 *         cdef int i = 0             # <<<<<<<<<<<<<<
 *         cdef int valid = False
 *         with nogil:
 */
  __pyx_v_i = 0;

  /* "btdht/krcp.pyx":1975
 *         """
 *         cdef int i = 0
 *         cdef int valid = False             # <<<<<<<<<<<<<<
 *         with nogil:
 *             if datalen > 0:
 */
  __pyx_v_valid = 0;

  /* "btdht/krcp.pyx":1976
 *         cdef int i = 0
 *         cdef int valid = False
 *         with nogil:             # <<<<<<<<<<<<<<
 *             if datalen > 0:
 *                 valid = self._decode(data, &i, datalen)
 */
  {
      #ifdef WITH_THREAD
      PyThreadState *_save;
      Py_UNBLOCK_THREADS
      __Pyx_FastGIL_Remember();
      #endif
      /*try:*/ {

        /* "btdht/krcp.pyx":1977
 *         cdef int valid = False
 *         with nogil:
 *             if datalen > 0:             # <<<<<<<<<<<<<<
 *                 valid = self._decode(data, &i, datalen)
 *                 if not self.has_t:
 */
        __pyx_t_1 = ((__pyx_v_datalen > 0) != 0);
        if (__pyx_t_1) {

          /* "btdht/krcp.pyx":1978
 *         with nogil:
 *             if datalen > 0:
 *                 valid = self._decode(data, &i, datalen)             # <<<<<<<<<<<<<<
 *                 if not self.has_t:
 *                     with gil:
 */
          __pyx_t_2 = ((struct __pyx_vtabstruct_5btdht_4krcp_BMessage *)__pyx_v_self->__pyx_vtab)->_decode(__pyx_v_self, __pyx_v_data, (&__pyx_v_i), __pyx_v_datalen); if (unlikely(__pyx_t_2 == ((int)-1))) __PYX_ERR(0, 1978, __pyx_L4_error)
          __pyx_v_valid = __pyx_t_2;

          /* "btdht/krcp.pyx":1979
 *             if datalen > 0:
 *                 valid = self._decode(data, &i, datalen)
 *                 if not self.has_t:             # <<<<<<<<<<<<<<
 *                     with gil:
 *                         raise MissingT()
 */
          __pyx_t_1 = ((!(__pyx_v_self->has_t != 0)) != 0);
          if (__pyx_t_1) {

            /* "btdht/krcp.pyx":1980
 *                 valid = self._decode(data, &i, datalen)
 *                 if not self.has_t:
 *                     with gil:             # <<<<<<<<<<<<<<
 *                         raise MissingT()
 *                 if self.failed:
 */
            {
                #ifdef WITH_THREAD
                PyGILState_STATE __pyx_gilstate_save = __Pyx_PyGILState_Ensure();
                #endif
                /*try:*/ {

                  /* "btdht/krcp.pyx":1981
 *                 if not self.has_t:
 *                     with gil:
 *                         raise MissingT()             # <<<<<<<<<<<<<<
 *                 if self.failed:
 *                     if self.has_y and strncmp(self._y, b"q", 1):
 */
                  __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_MissingT); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1981, __pyx_L9_error)
                  __Pyx_GOTREF(__pyx_t_4);
                  __pyx_t_5 = NULL;
                  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_4))) {
                    __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_4);
                    if (likely(__pyx_t_5)) {
                      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
                      __Pyx_INCREF(__pyx_t_5);
                      __Pyx_INCREF(function);
                      __Pyx_DECREF_SET(__pyx_t_4, function);
                    }
                  }
                  __pyx_t_3 = (__pyx_t_5) ? __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_5) : __Pyx_PyObject_CallNoArg(__pyx_t_4);
                  __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
                  if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1981, __pyx_L9_error)
                  __Pyx_GOTREF(__pyx_t_3);
                  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
                  __Pyx_Raise(__pyx_t_3, 0, 0, 0);
                  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
                  __PYX_ERR(0, 1981, __pyx_L9_error)
                }

                /* "btdht/krcp.pyx":1980
 *                 valid = self._decode(data, &i, datalen)
 *                 if not self.has_t:
 *                     with gil:             # <<<<<<<<<<<<<<
 *                         raise MissingT()
 *                 if self.failed:
 */
                /*finally:*/ {
                  __pyx_L9_error: {
                    #ifdef WITH_THREAD
                    __Pyx_PyGILState_Release(__pyx_gilstate_save);
                    #endif
                    goto __pyx_L4_error;
                  }
                }
            }

            /* "btdht/krcp.pyx":1979
 *             if datalen > 0:
 *                 valid = self._decode(data, &i, datalen)
 *                 if not self.has_t:             # <<<<<<<<<<<<<<
 *                     with gil:
 *                         raise MissingT()
 */
          }

          /* "btdht/krcp.pyx":1982
 *                     with gil:
 *                         raise MissingT()
 *                 if self.failed:             # <<<<<<<<<<<<<<
 *                     if self.has_y and strncmp(self._y, b"q", 1):
 *                         with gil:
 */
          __pyx_t_1 = (__pyx_v_self->failed != 0);
          if (__pyx_t_1) {

            /* "btdht/krcp.pyx":1983
 *                         raise MissingT()
 *                 if self.failed:
 *                     if self.has_y and strncmp(self._y, b"q", 1):             # <<<<<<<<<<<<<<
 *                         with gil:
 *                             raise ProtocolError(self.t, self.failed_msg)
 */
            __pyx_t_6 = (__pyx_v_self->has_y != 0);
            if (__pyx_t_6) {
            } else {
              __pyx_t_1 = __pyx_t_6;
              goto __pyx_L13_bool_binop_done;
            }
            __pyx_t_6 = (strncmp(__pyx_v_self->_y, ((char const *)"q"), 1) != 0);
            __pyx_t_1 = __pyx_t_6;
            __pyx_L13_bool_binop_done:;
            if (__pyx_t_1) {

              /* "btdht/krcp.pyx":1984
 *                 if self.failed:
 *                     if self.has_y and strncmp(self._y, b"q", 1):
 *                         with gil:             # <<<<<<<<<<<<<<
 *                             raise ProtocolError(self.t, self.failed_msg)
 *                     else:
 */
              {
                  #ifdef WITH_THREAD
                  PyGILState_STATE __pyx_gilstate_save = __Pyx_PyGILState_Ensure();
                  #endif
                  /*try:*/ {

                    /* "btdht/krcp.pyx":1985
 *                     if self.has_y and strncmp(self._y, b"q", 1):
 *                         with gil:
 *                             raise ProtocolError(self.t, self.failed_msg)             # <<<<<<<<<<<<<<
 *                     else:
 *                         with gil:
 */
                    __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_ProtocolError); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1985, __pyx_L16_error)
                    __Pyx_GOTREF(__pyx_t_4);
                    __pyx_t_5 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_t); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1985, __pyx_L16_error)
                    __Pyx_GOTREF(__pyx_t_5);
                    __pyx_t_7 = __Pyx_PyBytes_FromString(__pyx_v_self->failed_msg); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1985, __pyx_L16_error)
                    __Pyx_GOTREF(__pyx_t_7);
                    __pyx_t_8 = NULL;
                    __pyx_t_2 = 0;
                    if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_4))) {
                      __pyx_t_8 = PyMethod_GET_SELF(__pyx_t_4);
                      if (likely(__pyx_t_8)) {
                        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
                        __Pyx_INCREF(__pyx_t_8);
                        __Pyx_INCREF(function);
                        __Pyx_DECREF_SET(__pyx_t_4, function);
                        __pyx_t_2 = 1;
                      }
                    }
                    #if CYTHON_FAST_PYCALL
                    if (PyFunction_Check(__pyx_t_4)) {
                      PyObject *__pyx_temp[3] = {__pyx_t_8, __pyx_t_5, __pyx_t_7};
                      __pyx_t_3 = __Pyx_PyFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_2, 2+__pyx_t_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1985, __pyx_L16_error)
                      __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
                      __Pyx_GOTREF(__pyx_t_3);
                      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
                      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
                    } else
                    #endif
                    #if CYTHON_FAST_PYCCALL
                    if (__Pyx_PyFastCFunction_Check(__pyx_t_4)) {
                      PyObject *__pyx_temp[3] = {__pyx_t_8, __pyx_t_5, __pyx_t_7};
                      __pyx_t_3 = __Pyx_PyCFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_2, 2+__pyx_t_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1985, __pyx_L16_error)
                      __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
                      __Pyx_GOTREF(__pyx_t_3);
                      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
                      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
                    } else
                    #endif
                    {
                      __pyx_t_9 = PyTuple_New(2+__pyx_t_2); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 1985, __pyx_L16_error)
                      __Pyx_GOTREF(__pyx_t_9);
                      if (__pyx_t_8) {
                        __Pyx_GIVEREF(__pyx_t_8); PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_t_8); __pyx_t_8 = NULL;
                      }
                      __Pyx_GIVEREF(__pyx_t_5);
                      PyTuple_SET_ITEM(__pyx_t_9, 0+__pyx_t_2, __pyx_t_5);
                      __Pyx_GIVEREF(__pyx_t_7);
                      PyTuple_SET_ITEM(__pyx_t_9, 1+__pyx_t_2, __pyx_t_7);
                      __pyx_t_5 = 0;
                      __pyx_t_7 = 0;
                      __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_9, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1985, __pyx_L16_error)
                      __Pyx_GOTREF(__pyx_t_3);
                      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
                    }
                    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
                    __Pyx_Raise(__pyx_t_3, 0, 0, 0);
                    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
                    __PYX_ERR(0, 1985, __pyx_L16_error)
                  }

                  /* "btdht/krcp.pyx":1984
 *                 if self.failed:
 *                     if self.has_y and strncmp(self._y, b"q", 1):
 *                         with gil:             # <<<<<<<<<<<<<<
 *                             raise ProtocolError(self.t, self.failed_msg)
 *                     else:
 */
                  /*finally:*/ {
                    __pyx_L16_error: {
                      #ifdef WITH_THREAD
                      __Pyx_PyGILState_Release(__pyx_gilstate_save);
                      #endif
                      goto __pyx_L4_error;
                    }
                  }
              }

              /* "btdht/krcp.pyx":1983
 *                         raise MissingT()
 *                 if self.failed:
 *                     if self.has_y and strncmp(self._y, b"q", 1):             # <<<<<<<<<<<<<<
 *                         with gil:
 *                             raise ProtocolError(self.t, self.failed_msg)
 */
            }

            /* "btdht/krcp.pyx":1987
 *                             raise ProtocolError(self.t, self.failed_msg)
 *                     else:
 *                         with gil:             # <<<<<<<<<<<<<<
 *                           raise DecodeError(self.failed_msg)
 *                 if not valid or not self.has_y:
 */
            /*else*/ {
              {
                  #ifdef WITH_THREAD
                  PyGILState_STATE __pyx_gilstate_save = __Pyx_PyGILState_Ensure();
                  #endif
                  /*try:*/ {

                    /* "btdht/krcp.pyx":1988
 *                     else:
 *                         with gil:
 *                           raise DecodeError(self.failed_msg)             # <<<<<<<<<<<<<<
 *                 if not valid or not self.has_y:
 *                     if self.has_y and strncmp(self._y, b"q", 1):
 */
                    __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_DecodeError); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1988, __pyx_L19_error)
                    __Pyx_GOTREF(__pyx_t_4);
                    __pyx_t_9 = __Pyx_PyBytes_FromString(__pyx_v_self->failed_msg); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 1988, __pyx_L19_error)
                    __Pyx_GOTREF(__pyx_t_9);
                    __pyx_t_7 = NULL;
                    if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_4))) {
                      __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_4);
                      if (likely(__pyx_t_7)) {
                        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
                        __Pyx_INCREF(__pyx_t_7);
                        __Pyx_INCREF(function);
                        __Pyx_DECREF_SET(__pyx_t_4, function);
                      }
                    }
                    __pyx_t_3 = (__pyx_t_7) ? __Pyx_PyObject_Call2Args(__pyx_t_4, __pyx_t_7, __pyx_t_9) : __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_9);
                    __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
                    __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
                    if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1988, __pyx_L19_error)
                    __Pyx_GOTREF(__pyx_t_3);
                    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
                    __Pyx_Raise(__pyx_t_3, 0, 0, 0);
                    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
                    __PYX_ERR(0, 1988, __pyx_L19_error)
                  }

                  /* "btdht/krcp.pyx":1987
 *                             raise ProtocolError(self.t, self.failed_msg)
 *                     else:
 *                         with gil:             # <<<<<<<<<<<<<<
 *                           raise DecodeError(self.failed_msg)
 *                 if not valid or not self.has_y:
 */
                  /*finally:*/ {
                    __pyx_L19_error: {
                      #ifdef WITH_THREAD
                      __Pyx_PyGILState_Release(__pyx_gilstate_save);
                      #endif
                      goto __pyx_L4_error;
                    }
                  }
              }
            }

            /* "btdht/krcp.pyx":1982
 *                     with gil:
 *                         raise MissingT()
 *                 if self.failed:             # <<<<<<<<<<<<<<
 *                     if self.has_y and strncmp(self._y, b"q", 1):
 *                         with gil:
 */
          }

          /* "btdht/krcp.pyx":1989
 *                         with gil:
 *                           raise DecodeError(self.failed_msg)
 *                 if not valid or not self.has_y:             # <<<<<<<<<<<<<<
 *                     if self.has_y and strncmp(self._y, b"q", 1):
 *                         with gil:
 */
          __pyx_t_6 = ((!(__pyx_v_valid != 0)) != 0);
          if (!__pyx_t_6) {
          } else {
            __pyx_t_1 = __pyx_t_6;
            goto __pyx_L22_bool_binop_done;
          }
          __pyx_t_6 = ((!(__pyx_v_self->has_y != 0)) != 0);
          __pyx_t_1 = __pyx_t_6;
          __pyx_L22_bool_binop_done:;
          if (__pyx_t_1) {

            /* "btdht/krcp.pyx":1990
 *                           raise DecodeError(self.failed_msg)
 *                 if not valid or not self.has_y:
 *                     if self.has_y and strncmp(self._y, b"q", 1):             # <<<<<<<<<<<<<<
 *                         with gil:
 *                             raise ProtocolError(self.t)
 */
            __pyx_t_6 = (__pyx_v_self->has_y != 0);
            if (__pyx_t_6) {
            } else {
              __pyx_t_1 = __pyx_t_6;
              goto __pyx_L25_bool_binop_done;
            }
            __pyx_t_6 = (strncmp(__pyx_v_self->_y, ((char const *)"q"), 1) != 0);
            __pyx_t_1 = __pyx_t_6;
            __pyx_L25_bool_binop_done:;
            if (__pyx_t_1) {

              /* "btdht/krcp.pyx":1991
 *                 if not valid or not self.has_y:
 *                     if self.has_y and strncmp(self._y, b"q", 1):
 *                         with gil:             # <<<<<<<<<<<<<<
 *                             raise ProtocolError(self.t)
 *                     else:
 */
              {
                  #ifdef WITH_THREAD
                  PyGILState_STATE __pyx_gilstate_save = __Pyx_PyGILState_Ensure();
                  #endif
                  /*try:*/ {

                    /* "btdht/krcp.pyx":1992
 *                     if self.has_y and strncmp(self._y, b"q", 1):
 *                         with gil:
 *                             raise ProtocolError(self.t)             # <<<<<<<<<<<<<<
 *                     else:
 *                         with gil:
 */
                    __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_ProtocolError); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1992, __pyx_L28_error)
                    __Pyx_GOTREF(__pyx_t_4);
                    __pyx_t_9 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_t); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 1992, __pyx_L28_error)
                    __Pyx_GOTREF(__pyx_t_9);
                    __pyx_t_7 = NULL;
                    if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_4))) {
                      __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_4);
                      if (likely(__pyx_t_7)) {
                        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
                        __Pyx_INCREF(__pyx_t_7);
                        __Pyx_INCREF(function);
                        __Pyx_DECREF_SET(__pyx_t_4, function);
                      }
                    }
                    __pyx_t_3 = (__pyx_t_7) ? __Pyx_PyObject_Call2Args(__pyx_t_4, __pyx_t_7, __pyx_t_9) : __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_9);
                    __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
                    __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
                    if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1992, __pyx_L28_error)
                    __Pyx_GOTREF(__pyx_t_3);
                    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
                    __Pyx_Raise(__pyx_t_3, 0, 0, 0);
                    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
                    __PYX_ERR(0, 1992, __pyx_L28_error)
                  }

                  /* "btdht/krcp.pyx":1991
 *                 if not valid or not self.has_y:
 *                     if self.has_y and strncmp(self._y, b"q", 1):
 *                         with gil:             # <<<<<<<<<<<<<<
 *                             raise ProtocolError(self.t)
 *                     else:
 */
                  /*finally:*/ {
                    __pyx_L28_error: {
                      #ifdef WITH_THREAD
                      __Pyx_PyGILState_Release(__pyx_gilstate_save);
                      #endif
                      goto __pyx_L4_error;
                    }
                  }
              }

              /* "btdht/krcp.pyx":1990
 *                           raise DecodeError(self.failed_msg)
 *                 if not valid or not self.has_y:
 *                     if self.has_y and strncmp(self._y, b"q", 1):             # <<<<<<<<<<<<<<
 *                         with gil:
 *                             raise ProtocolError(self.t)
 */
            }

            /* "btdht/krcp.pyx":1994
 *                             raise ProtocolError(self.t)
 *                     else:
 *                         with gil:             # <<<<<<<<<<<<<<
 *                             raise DecodeError()
 *         return data[i:]
 */
            /*else*/ {
              {
                  #ifdef WITH_THREAD
                  PyGILState_STATE __pyx_gilstate_save = __Pyx_PyGILState_Ensure();
                  #endif
                  /*try:*/ {

                    /* "btdht/krcp.pyx":1995
 *                     else:
 *                         with gil:
 *                             raise DecodeError()             # <<<<<<<<<<<<<<
 *         return data[i:]
 */
                    __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_DecodeError); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1995, __pyx_L31_error)
                    __Pyx_GOTREF(__pyx_t_4);
                    __pyx_t_9 = NULL;
                    if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_4))) {
                      __pyx_t_9 = PyMethod_GET_SELF(__pyx_t_4);
                      if (likely(__pyx_t_9)) {
                        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
                        __Pyx_INCREF(__pyx_t_9);
                        __Pyx_INCREF(function);
                        __Pyx_DECREF_SET(__pyx_t_4, function);
                      }
                    }
                    __pyx_t_3 = (__pyx_t_9) ? __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_9) : __Pyx_PyObject_CallNoArg(__pyx_t_4);
                    __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
                    if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1995, __pyx_L31_error)
                    __Pyx_GOTREF(__pyx_t_3);
                    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
                    __Pyx_Raise(__pyx_t_3, 0, 0, 0);
                    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
                    __PYX_ERR(0, 1995, __pyx_L31_error)
                  }

                  /* "btdht/krcp.pyx":1994
 *                             raise ProtocolError(self.t)
 *                     else:
 *                         with gil:             # <<<<<<<<<<<<<<
 *                             raise DecodeError()
 *         return data[i:]
 */
                  /*finally:*/ {
                    __pyx_L31_error: {
                      #ifdef WITH_THREAD
                      __Pyx_PyGILState_Release(__pyx_gilstate_save);
                      #endif
                      goto __pyx_L4_error;
                    }
                  }
              }
            }

            /* "btdht/krcp.pyx":1989
 *                         with gil:
 *                           raise DecodeError(self.failed_msg)
 *                 if not valid or not self.has_y:             # <<<<<<<<<<<<<<
 *                     if self.has_y and strncmp(self._y, b"q", 1):
 *                         with gil:
 */
          }

          /* "btdht/krcp.pyx":1977
 *         cdef int valid = False
 *         with nogil:
 *             if datalen > 0:             # <<<<<<<<<<<<<<
 *                 valid = self._decode(data, &i, datalen)
 *                 if not self.has_t:
 */
        }
      }

      /* "btdht/krcp.pyx":1976
 *         cdef int i = 0
 *         cdef int valid = False
 *         with nogil:             # <<<<<<<<<<<<<<
 *             if datalen > 0:
 *                 valid = self._decode(data, &i, datalen)
 */
      /*finally:*/ {
        /*normal exit:*/{
          #ifdef WITH_THREAD
          __Pyx_FastGIL_Forget();
          Py_BLOCK_THREADS
          #endif
          goto __pyx_L5;
        }
        __pyx_L4_error: {
          #ifdef WITH_THREAD
          __Pyx_FastGIL_Forget();
          Py_BLOCK_THREADS
          #endif
          goto __pyx_L1_error;
        }
        __pyx_L5:;
      }
  }

  /* "btdht/krcp.pyx":1996
 *                         with gil:
 *                             raise DecodeError()
 *         return data[i:]             # <<<<<<<<<<<<<<
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_3 = __Pyx_PyBytes_FromString(__pyx_v_data + __pyx_v_i); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1996, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_r = __pyx_t_3;
  __pyx_t_3 = 0;
  goto __pyx_L0;

  /* "btdht/krcp.pyx":1958
 *             self.encoded_uptodate = False
 * 
 *     def decode(self, char* data, int datalen):             # <<<<<<<<<<<<<<
 *         """
 *             Bdecode a bencoded message and set the current :class:`BMessage` attributes accordingly
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_XDECREF(__pyx_t_9);
  __Pyx_AddTraceback("btdht.krcp.BMessage.decode", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "(tree fragment)":1
 * def __reduce_cython__(self):             # <<<<<<<<<<<<<<
 *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")
 * def __setstate_cython__(self, __pyx_state):
 */

/* Python wrapper */
static PyObject *__pyx_pw_5btdht_4krcp_8BMessage_25__reduce_cython__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static PyObject *__pyx_pw_5btdht_4krcp_8BMessage_25__reduce_cython__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__reduce_cython__ (wrapper)", 0);
  __pyx_r = __pyx_pf_5btdht_4krcp_8BMessage_24__reduce_cython__(((struct __pyx_obj_5btdht_4krcp_BMessage *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5btdht_4krcp_8BMessage_24__reduce_cython__(CYTHON_UNUSED struct __pyx_obj_5btdht_4krcp_BMessage *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__reduce_cython__", 0);

  /* "(tree fragment)":2
 * def __reduce_cython__(self):
 *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")             # <<<<<<<<<<<<<<
 * def __setstate_cython__(self, __pyx_state):
 *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")
 */
  __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__5, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 2, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_Raise(__pyx_t_1, 0, 0, 0);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __PYX_ERR(1, 2, __pyx_L1_error)

  /* "(tree fragment)":1
 * def __reduce_cython__(self):             # <<<<<<<<<<<<<<
 *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")
 * def __setstate_cython__(self, __pyx_state):
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("btdht.krcp.BMessage.__reduce_cython__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "(tree fragment)":3
 * def __reduce_cython__(self):
 *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")
 * def __setstate_cython__(self, __pyx_state):             # <<<<<<<<<<<<<<
 *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")
 */

/* Python wrapper */
static PyObject *__pyx_pw_5btdht_4krcp_8BMessage_27__setstate_cython__(PyObject *__pyx_v_self, PyObject *__pyx_v___pyx_state); /*proto*/
static PyObject *__pyx_pw_5btdht_4krcp_8BMessage_27__setstate_cython__(PyObject *__pyx_v_self, PyObject *__pyx_v___pyx_state) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__setstate_cython__ (wrapper)", 0);
  __pyx_r = __pyx_pf_5btdht_4krcp_8BMessage_26__setstate_cython__(((struct __pyx_obj_5btdht_4krcp_BMessage *)__pyx_v_self), ((PyObject *)__pyx_v___pyx_state));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5btdht_4krcp_8BMessage_26__setstate_cython__(CYTHON_UNUSED struct __pyx_obj_5btdht_4krcp_BMessage *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v___pyx_state) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__setstate_cython__", 0);

  /* "(tree fragment)":4
 *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")
 * def __setstate_cython__(self, __pyx_state):
 *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")             # <<<<<<<<<<<<<<
 */
  __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__6, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 4, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_Raise(__pyx_t_1, 0, 0, 0);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __PYX_ERR(1, 4, __pyx_L1_error)

  /* "(tree fragment)":3
 * def __reduce_cython__(self):
 *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")
 * def __setstate_cython__(self, __pyx_state):             # <<<<<<<<<<<<<<
 *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("btdht.krcp.BMessage.__setstate_cython__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}
static struct __pyx_vtabstruct_5btdht_4krcp_BMessage __pyx_vtable_5btdht_4krcp_BMessage;

static PyObject *__pyx_tp_new_5btdht_4krcp_BMessage(PyTypeObject *t, PyObject *a, PyObject *k) {
  struct __pyx_obj_5btdht_4krcp_BMessage *p;
  PyObject *o;
  if (likely((t->tp_flags & Py_TPFLAGS_IS_ABSTRACT) == 0)) {
    o = (*t->tp_alloc)(t, 0);
  } else {
    o = (PyObject *) PyBaseObject_Type.tp_new(t, __pyx_empty_tuple, 0);
  }
  if (unlikely(!o)) return 0;
  p = ((struct __pyx_obj_5btdht_4krcp_BMessage *)o);
  p->__pyx_vtab = __pyx_vtabptr_5btdht_4krcp_BMessage;
  p->addr_addr_3 = ((PyObject*)Py_None); Py_INCREF(Py_None);
  p->addr_addr_2 = ((PyObject*)Py_None); Py_INCREF(Py_None);
  if (unlikely(__pyx_pw_5btdht_4krcp_8BMessage_21__cinit__(o, a, k) < 0)) goto bad;
  return o;
  bad:
  Py_DECREF(o); o = 0;
  return NULL;
}

static void __pyx_tp_dealloc_5btdht_4krcp_BMessage(PyObject *o) {
  struct __pyx_obj_5btdht_4krcp_BMessage *p = (struct __pyx_obj_5btdht_4krcp_BMessage *)o;
  #if CYTHON_USE_TP_FINALIZE
  if (unlikely(PyType_HasFeature(Py_TYPE(o), Py_TPFLAGS_HAVE_FINALIZE) && Py_TYPE(o)->tp_finalize) && (!PyType_IS_GC(Py_TYPE(o)) || !_PyGC_FINALIZED(o))) {
    if (PyObject_CallFinalizerFromDealloc(o)) return;
  }
  #endif
  {
    PyObject *etype, *eval, *etb;
    PyErr_Fetch(&etype, &eval, &etb);
    __Pyx_SET_REFCNT(o, Py_REFCNT(o) + 1);
    __pyx_pw_5btdht_4krcp_8BMessage_17__dealloc__(o);
    __Pyx_SET_REFCNT(o, Py_REFCNT(o) - 1);
    PyErr_Restore(etype, eval, etb);
  }
  Py_CLEAR(p->addr_addr_3);
  Py_CLEAR(p->addr_addr_2);
  (*Py_TYPE(o)->tp_free)(o);
}
static PyObject *__pyx_sq_item_5btdht_4krcp_BMessage(PyObject *o, Py_ssize_t i) {
  PyObject *r;
  PyObject *x = PyInt_FromSsize_t(i); if(!x) return 0;
  r = Py_TYPE(o)->tp_as_mapping->mp_subscript(o, x);
  Py_DECREF(x);
  return r;
}

static int __pyx_mp_ass_subscript_5btdht_4krcp_BMessage(PyObject *o, PyObject *i, PyObject *v) {
  if (v) {
    return __pyx_pw_5btdht_4krcp_8BMessage_13__setitem__(o, i, v);
  }
  else {
    return __pyx_pw_5btdht_4krcp_8BMessage_11__delitem__(o, i);
  }
}

static PyObject *__pyx_getprop_5btdht_4krcp_8BMessage_errno(PyObject *o, CYTHON_UNUSED void *x) {
  return __pyx_pw_5btdht_4krcp_8BMessage_5errno_1__get__(o);
}

static int __pyx_setprop_5btdht_4krcp_8BMessage_errno(PyObject *o, PyObject *v, CYTHON_UNUSED void *x) {
  if (v) {
    return __pyx_pw_5btdht_4krcp_8BMessage_5errno_3__set__(o, v);
  }
  else {
    PyErr_SetString(PyExc_NotImplementedError, "__del__");
    return -1;
  }
}

static PyObject *__pyx_getprop_5btdht_4krcp_8BMessage_errmsg(PyObject *o, CYTHON_UNUSED void *x) {
  return __pyx_pw_5btdht_4krcp_8BMessage_6errmsg_1__get__(o);
}

static int __pyx_setprop_5btdht_4krcp_8BMessage_errmsg(PyObject *o, PyObject *v, CYTHON_UNUSED void *x) {
  if (v) {
    return __pyx_pw_5btdht_4krcp_8BMessage_6errmsg_3__set__(o, v);
  }
  else {
    PyErr_SetString(PyExc_NotImplementedError, "__del__");
    return -1;
  }
}

static PyObject *__pyx_getprop_5btdht_4krcp_8BMessage_addr(PyObject *o, CYTHON_UNUSED void *x) {
  return __pyx_pw_5btdht_4krcp_8BMessage_4addr_1__get__(o);
}

static int __pyx_setprop_5btdht_4krcp_8BMessage_addr(PyObject *o, PyObject *v, CYTHON_UNUSED void *x) {
  if (v) {
    return __pyx_pw_5btdht_4krcp_8BMessage_4addr_3__set__(o, v);
  }
  else {
    return __pyx_pw_5btdht_4krcp_8BMessage_4addr_5__del__(o);
  }
}

static PyObject *__pyx_getprop_5btdht_4krcp_8BMessage_y(PyObject *o, CYTHON_UNUSED void *x) {
  return __pyx_pw_5btdht_4krcp_8BMessage_1y_1__get__(o);
}

static int __pyx_setprop_5btdht_4krcp_8BMessage_y(PyObject *o, PyObject *v, CYTHON_UNUSED void *x) {
  if (v) {
    return __pyx_pw_5btdht_4krcp_8BMessage_1y_3__set__(o, v);
  }
  else {
    return __pyx_pw_5btdht_4krcp_8BMessage_1y_5__del__(o);
  }
}

static PyObject *__pyx_getprop_5btdht_4krcp_8BMessage_t(PyObject *o, CYTHON_UNUSED void *x) {
  return __pyx_pw_5btdht_4krcp_8BMessage_1t_1__get__(o);
}

static int __pyx_setprop_5btdht_4krcp_8BMessage_t(PyObject *o, PyObject *v, CYTHON_UNUSED void *x) {
  if (v) {
    return __pyx_pw_5btdht_4krcp_8BMessage_1t_3__set__(o, v);
  }
  else {
    return __pyx_pw_5btdht_4krcp_8BMessage_1t_5__del__(o);
  }
}

static PyObject *__pyx_getprop_5btdht_4krcp_8BMessage_q(PyObject *o, CYTHON_UNUSED void *x) {
  return __pyx_pw_5btdht_4krcp_8BMessage_1q_1__get__(o);
}

static int __pyx_setprop_5btdht_4krcp_8BMessage_q(PyObject *o, PyObject *v, CYTHON_UNUSED void *x) {
  if (v) {
    return __pyx_pw_5btdht_4krcp_8BMessage_1q_3__set__(o, v);
  }
  else {
    return __pyx_pw_5btdht_4krcp_8BMessage_1q_5__del__(o);
  }
}

static PyObject *__pyx_getprop_5btdht_4krcp_8BMessage_v(PyObject *o, CYTHON_UNUSED void *x) {
  return __pyx_pw_5btdht_4krcp_8BMessage_1v_1__get__(o);
}

static int __pyx_setprop_5btdht_4krcp_8BMessage_v(PyObject *o, PyObject *v, CYTHON_UNUSED void *x) {
  if (v) {
    return __pyx_pw_5btdht_4krcp_8BMessage_1v_3__set__(o, v);
  }
  else {
    return __pyx_pw_5btdht_4krcp_8BMessage_1v_5__del__(o);
  }
}

static PyMethodDef __pyx_methods_5btdht_4krcp_BMessage[] = {
  {"response", (PyCFunction)__pyx_pw_5btdht_4krcp_8BMessage_1response, METH_O, __pyx_doc_5btdht_4krcp_8BMessage_response},
  {"encode", (PyCFunction)__pyx_pw_5btdht_4krcp_8BMessage_3encode, METH_NOARGS, __pyx_doc_5btdht_4krcp_8BMessage_2encode},
  {"get", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_5btdht_4krcp_8BMessage_15get, METH_VARARGS|METH_KEYWORDS, __pyx_doc_5btdht_4krcp_8BMessage_14get},
  {"decode", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_5btdht_4krcp_8BMessage_23decode, METH_VARARGS|METH_KEYWORDS, __pyx_doc_5btdht_4krcp_8BMessage_22decode},
  {"__reduce_cython__", (PyCFunction)__pyx_pw_5btdht_4krcp_8BMessage_25__reduce_cython__, METH_NOARGS, 0},
  {"__setstate_cython__", (PyCFunction)__pyx_pw_5btdht_4krcp_8BMessage_27__setstate_cython__, METH_O, 0},
  {0, 0, 0, 0}
};

static struct PyGetSetDef __pyx_getsets_5btdht_4krcp_BMessage[] = {
  {(char *)"errno", __pyx_getprop_5btdht_4krcp_8BMessage_errno, __pyx_setprop_5btdht_4krcp_8BMessage_errno, (char *)0, 0},
  {(char *)"errmsg", __pyx_getprop_5btdht_4krcp_8BMessage_errmsg, __pyx_setprop_5btdht_4krcp_8BMessage_errmsg, (char *)0, 0},
  {(char *)"addr", __pyx_getprop_5btdht_4krcp_8BMessage_addr, __pyx_setprop_5btdht_4krcp_8BMessage_addr, (char *)0, 0},
  {(char *)"y", __pyx_getprop_5btdht_4krcp_8BMessage_y, __pyx_setprop_5btdht_4krcp_8BMessage_y, (char *)0, 0},
  {(char *)"t", __pyx_getprop_5btdht_4krcp_8BMessage_t, __pyx_setprop_5btdht_4krcp_8BMessage_t, (char *)0, 0},
  {(char *)"q", __pyx_getprop_5btdht_4krcp_8BMessage_q, __pyx_setprop_5btdht_4krcp_8BMessage_q, (char *)0, 0},
  {(char *)"v", __pyx_getprop_5btdht_4krcp_8BMessage_v, __pyx_setprop_5btdht_4krcp_8BMessage_v, (char *)0, 0},
  {0, 0, 0, 0, 0}
};

static PySequenceMethods __pyx_tp_as_sequence_BMessage = {
  0, /*sq_length*/
  0, /*sq_concat*/
  0, /*sq_repeat*/
  __pyx_sq_item_5btdht_4krcp_BMessage, /*sq_item*/
  0, /*sq_slice*/
  0, /*sq_ass_item*/
  0, /*sq_ass_slice*/
  0, /*sq_contains*/
  0, /*sq_inplace_concat*/
  0, /*sq_inplace_repeat*/
};

static PyMappingMethods __pyx_tp_as_mapping_BMessage = {
  0, /*mp_length*/
  __pyx_pw_5btdht_4krcp_8BMessage_9__getitem__, /*mp_subscript*/
  __pyx_mp_ass_subscript_5btdht_4krcp_BMessage, /*mp_ass_subscript*/
};

static PyTypeObject __pyx_type_5btdht_4krcp_BMessage = {
  PyVarObject_HEAD_INIT(0, 0)
  "btdht.krcp.BMessage", /*tp_name*/
  sizeof(struct __pyx_obj_5btdht_4krcp_BMessage), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_5btdht_4krcp_BMessage, /*tp_dealloc*/
  #if PY_VERSION_HEX < 0x030800b4
  0, /*tp_print*/
  #endif
  #if PY_VERSION_HEX >= 0x030800b4
  0, /*tp_vectorcall_offset*/
  #endif
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  #if PY_MAJOR_VERSION < 3
  0, /*tp_compare*/
  #endif
  #if PY_MAJOR_VERSION >= 3
  0, /*tp_as_async*/
  #endif
  __pyx_pw_5btdht_4krcp_8BMessage_5__repr__, /*tp_repr*/
  0, /*tp_as_number*/
  &__pyx_tp_as_sequence_BMessage, /*tp_as_sequence*/
  &__pyx_tp_as_mapping_BMessage, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  __pyx_pw_5btdht_4krcp_8BMessage_7__str__, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  0, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE, /*tp_flags*/
  "\n        A bittorrent DHT message. This class is able to bdecode a bittorrent DHT message. It\n        expose then the messages keys ``t``, ``y``, ``q``,  ``errno``, ``errmsg`` and ``v`` as\n        attributes, and behave itself as a dictionnary for the ``a`` or ``r`` keys that contains\n        a secondary dictionnary (see Notes).\n\n        :param tuple addr: An optionnal coupe (ip, port) of the sender of the message\n        :param bool debug: ``True`` for enabling debug message. The default is ``False``\n\n        Notes:\n            A query message is always of the following form with ``y == b'q'``::\n\n                {\n                    \"t\": t,\n                    \"y\": y,\n                    \"q\": q, \n                    \"a\": {...}\n                }\n\n            A response message is always of the following form with ``y == b'r'``::\n\n                {\n                    \"t\": t,\n                    \"y\": y,\n                    \"r\": {...}\n                }\n\n            An error message is always in response of a query message and of the following form\n            with ``y == b'e'``::\n\n                {\n                    \"t\": t,\n                    \"y\": y,\n                    \"e\":[errno, errmsg]\n                }\n\n            The ``t`` key is a random string generated with every query. It is used to match\n            a response to a particular query.\n\n            The ``y`` key is used to differenciate the type of the message. Its value is ``b'q'``\n            for a query, ``b'r'`` for a response, and ``b'e'`` for and error message.\n\n            The ``q`` is only present on query message and contain the name of the query (ping,\n            get_peers, announce_peer, find_node)\n\n            ``errno`` and ``errmsg`` are only defined if the message is an error message. They are\n            respectively the error number (:class:`int`) and the error describing message of the error.\n\n            The ``v`` key i""s set by some DHT clients to the name and version of the client and\n            is totally optionnal in the protocol.\n    ", /*tp_doc*/
  0, /*tp_traverse*/
  0, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  __pyx_methods_5btdht_4krcp_BMessage, /*tp_methods*/
  0, /*tp_members*/
  __pyx_getsets_5btdht_4krcp_BMessage, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  __pyx_pw_5btdht_4krcp_8BMessage_19__init__, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_5btdht_4krcp_BMessage, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
  0, /*tp_del*/
  0, /*tp_version_tag*/
  #if PY_VERSION_HEX >= 0x030400a1
  0, /*tp_finalize*/
  #endif
  #if PY_VERSION_HEX >= 0x030800b1 && (!CYTHON_COMPILING_IN_PYPY || PYPY_VERSION_NUM >= 0x07030800)
  0, /*tp_vectorcall*/
  #endif
  #if PY_VERSION_HEX >= 0x030800b4 && PY_VERSION_HEX < 0x03090000
  0, /*tp_print*/
  #endif
  #if CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX >= 0x03090000
  0, /*tp_pypy_flags*/
  #endif
};

static PyMethodDef __pyx_methods[] = {
  {0, 0, 0, 0}
};

#if PY_MAJOR_VERSION >= 3
#if CYTHON_PEP489_MULTI_PHASE_INIT
static PyObject* __pyx_pymod_create(PyObject *spec, PyModuleDef *def); /*proto*/
static int __pyx_pymod_exec_krcp(PyObject* module); /*proto*/
static PyModuleDef_Slot __pyx_moduledef_slots[] = {
  {Py_mod_create, (void*)__pyx_pymod_create},
  {Py_mod_exec, (void*)__pyx_pymod_exec_krcp},
  {0, NULL}
};
#endif

static struct PyModuleDef __pyx_moduledef = {
    PyModuleDef_HEAD_INIT,
    "krcp",
    0, /* m_doc */
  #if CYTHON_PEP489_MULTI_PHASE_INIT
    0, /* m_size */
  #else
    -1, /* m_size */
  #endif
    __pyx_methods /* m_methods */,
  #if CYTHON_PEP489_MULTI_PHASE_INIT
    __pyx_moduledef_slots, /* m_slots */
  #else
    NULL, /* m_reload */
  #endif
    NULL, /* m_traverse */
    NULL, /* m_clear */
    NULL /* m_free */
};
#endif
#ifndef CYTHON_SMALL_CODE
#if defined(__clang__)
    #define CYTHON_SMALL_CODE
#elif defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3))
    #define CYTHON_SMALL_CODE __attribute__((cold))
#else
    #define CYTHON_SMALL_CODE
#endif
#endif

static __Pyx_StringTabEntry __pyx_string_tab[] = {
  {&__pyx_kp_s_A_Generic_Error_error_code_201, __pyx_k_A_Generic_Error_error_code_201, sizeof(__pyx_k_A_Generic_Error_error_code_201), 0, 0, 1, 0},
  {&__pyx_kp_s_A_Protocol_Error_such_as_a_malf, __pyx_k_A_Protocol_Error_such_as_a_malf, sizeof(__pyx_k_A_Protocol_Error_such_as_a_malf), 0, 0, 1, 0},
  {&__pyx_kp_s_A_Server_Error_error_code_202_p, __pyx_k_A_Server_Error_error_code_202_p, sizeof(__pyx_k_A_Server_Error_error_code_202_p), 0, 0, 1, 0},
  {&__pyx_kp_s_A_base_class_exception_for_all, __pyx_k_A_base_class_exception_for_all, sizeof(__pyx_k_A_base_class_exception_for_all), 0, 0, 1, 0},
  {&__pyx_n_s_BError, __pyx_k_BError, sizeof(__pyx_k_BError), 0, 0, 1, 1},
  {&__pyx_n_s_BError___init, __pyx_k_BError___init, sizeof(__pyx_k_BError___init), 0, 0, 1, 1},
  {&__pyx_n_s_BError___repr, __pyx_k_BError___repr, sizeof(__pyx_k_BError___repr), 0, 0, 1, 1},
  {&__pyx_n_s_BError___str, __pyx_k_BError___str, sizeof(__pyx_k_BError___str), 0, 0, 1, 1},
  {&__pyx_n_s_BError_encode, __pyx_k_BError_encode, sizeof(__pyx_k_BError_encode), 0, 0, 1, 1},
  {&__pyx_n_s_BMessage, __pyx_k_BMessage, sizeof(__pyx_k_BMessage), 0, 0, 1, 1},
  {&__pyx_kp_s_Can_only_set_strings_of_length_2, __pyx_k_Can_only_set_strings_of_length_2, sizeof(__pyx_k_Can_only_set_strings_of_length_2), 0, 0, 1, 0},
  {&__pyx_n_s_DecodeError, __pyx_k_DecodeError, sizeof(__pyx_k_DecodeError), 0, 0, 1, 1},
  {&__pyx_kp_s_End_of_dict_not_found_s_d_r, __pyx_k_End_of_dict_not_found_s_d_r, sizeof(__pyx_k_End_of_dict_not_found_s_d_r), 0, 0, 1, 0},
  {&__pyx_kp_s_End_of_values_list_not_found_s_s, __pyx_k_End_of_values_list_not_found_s_s, sizeof(__pyx_k_End_of_values_list_not_found_s_s), 0, 0, 1, 0},
  {&__pyx_n_s_EnvironmentError, __pyx_k_EnvironmentError, sizeof(__pyx_k_EnvironmentError), 0, 0, 1, 1},
  {&__pyx_kp_s_Fail_to_decode_dict_key_d_s, __pyx_k_Fail_to_decode_dict_key_d_s, sizeof(__pyx_k_Fail_to_decode_dict_key_d_s), 0, 0, 1, 0},
  {&__pyx_n_s_GenericError, __pyx_k_GenericError, sizeof(__pyx_k_GenericError), 0, 0, 1, 1},
  {&__pyx_n_s_GenericError___init, __pyx_k_GenericError___init, sizeof(__pyx_k_GenericError___init), 0, 0, 1, 1},
  {&__pyx_n_s_KeyError, __pyx_k_KeyError, sizeof(__pyx_k_KeyError), 0, 0, 1, 1},
  {&__pyx_n_s_MethodUnknownError, __pyx_k_MethodUnknownError, sizeof(__pyx_k_MethodUnknownError), 0, 0, 1, 1},
  {&__pyx_n_s_MethodUnknownError___init, __pyx_k_MethodUnknownError___init, sizeof(__pyx_k_MethodUnknownError___init), 0, 0, 1, 1},
  {&__pyx_kp_b_Method_Unknow, __pyx_k_Method_Unknow, sizeof(__pyx_k_Method_Unknow), 0, 0, 0, 0},
  {&__pyx_kp_s_Method_Unknown_error_code_204_p, __pyx_k_Method_Unknown_error_code_204_p, sizeof(__pyx_k_Method_Unknown_error_code_204_p), 0, 0, 1, 0},
  {&__pyx_kp_b_Method_s_Unknown, __pyx_k_Method_s_Unknown, sizeof(__pyx_k_Method_s_Unknown), 0, 0, 0, 0},
  {&__pyx_n_s_MissingT, __pyx_k_MissingT, sizeof(__pyx_k_MissingT), 0, 0, 1, 1},
  {&__pyx_n_s_NotImplementedError, __pyx_k_NotImplementedError, sizeof(__pyx_k_NotImplementedError), 0, 0, 1, 1},
  {&__pyx_n_s_PY3, __pyx_k_PY3, sizeof(__pyx_k_PY3), 0, 0, 1, 1},
  {&__pyx_n_s_ProtocolError, __pyx_k_ProtocolError, sizeof(__pyx_k_ProtocolError), 0, 0, 1, 1},
  {&__pyx_n_s_ProtocolError___init, __pyx_k_ProtocolError___init, sizeof(__pyx_k_ProtocolError___init), 0, 0, 1, 1},
  {&__pyx_kp_b_Protocol_Error, __pyx_k_Protocol_Error, sizeof(__pyx_k_Protocol_Error), 0, 0, 0, 0},
  {&__pyx_n_s_ServerError, __pyx_k_ServerError, sizeof(__pyx_k_ServerError), 0, 0, 1, 1},
  {&__pyx_n_s_ServerError___init, __pyx_k_ServerError___init, sizeof(__pyx_k_ServerError___init), 0, 0, 1, 1},
  {&__pyx_kp_b_Server_Error, __pyx_k_Server_Error, sizeof(__pyx_k_Server_Error), 0, 0, 0, 0},
  {&__pyx_kp_s_Trying_to_convert_s_to_long_long, __pyx_k_Trying_to_convert_s_to_long_long, sizeof(__pyx_k_Trying_to_convert_s_to_long_long), 0, 0, 1, 0},
  {&__pyx_n_s_TypeError, __pyx_k_TypeError, sizeof(__pyx_k_TypeError), 0, 0, 1, 1},
  {&__pyx_kp_s_Unable_to_decode_element_of_dict, __pyx_k_Unable_to_decode_element_of_dict, sizeof(__pyx_k_Unable_to_decode_element_of_dict), 0, 0, 1, 0},
  {&__pyx_kp_s_Unable_to_encode_BMessage, __pyx_k_Unable_to_encode_BMessage, sizeof(__pyx_k_Unable_to_encode_BMessage), 0, 0, 1, 0},
  {&__pyx_kp_s_Unable_to_parse_one_of_the_eleme, __pyx_k_Unable_to_parse_one_of_the_eleme, sizeof(__pyx_k_Unable_to_parse_one_of_the_eleme), 0, 0, 1, 0},
  {&__pyx_kp_s_Unable_to_parse_one_of_the_eleme_2, __pyx_k_Unable_to_parse_one_of_the_eleme_2, sizeof(__pyx_k_Unable_to_parse_one_of_the_eleme_2), 0, 0, 1, 0},
  {&__pyx_n_s_ValueError, __pyx_k_ValueError, sizeof(__pyx_k_ValueError), 0, 0, 1, 1},
  {&__pyx_kp_b__2, __pyx_k__2, sizeof(__pyx_k__2), 0, 0, 0, 0},
  {&__pyx_n_s_addr, __pyx_k_addr, sizeof(__pyx_k_addr), 0, 0, 1, 1},
  {&__pyx_n_s_addr_addr, __pyx_k_addr_addr, sizeof(__pyx_k_addr_addr), 0, 0, 1, 1},
  {&__pyx_kp_b_bad_token, __pyx_k_bad_token, sizeof(__pyx_k_bad_token), 0, 0, 0, 0},
  {&__pyx_n_s_bencode, __pyx_k_bencode, sizeof(__pyx_k_bencode), 0, 0, 1, 1},
  {&__pyx_n_s_btdht_krcp, __pyx_k_btdht_krcp, sizeof(__pyx_k_btdht_krcp), 0, 0, 1, 1},
  {&__pyx_kp_s_btdht_krcp_pyx, __pyx_k_btdht_krcp_pyx, sizeof(__pyx_k_btdht_krcp_pyx), 0, 0, 1, 0},
  {&__pyx_n_s_class, __pyx_k_class, sizeof(__pyx_k_class), 0, 0, 1, 1},
  {&__pyx_n_s_cline_in_traceback, __pyx_k_cline_in_traceback, sizeof(__pyx_k_cline_in_traceback), 0, 0, 1, 1},
  {&__pyx_n_s_compact, __pyx_k_compact, sizeof(__pyx_k_compact), 0, 0, 1, 1},
  {&__pyx_n_s_data, __pyx_k_data, sizeof(__pyx_k_data), 0, 0, 1, 1},
  {&__pyx_n_s_datalen, __pyx_k_datalen, sizeof(__pyx_k_datalen), 0, 0, 1, 1},
  {&__pyx_n_s_debug, __pyx_k_debug, sizeof(__pyx_k_debug), 0, 0, 1, 1},
  {&__pyx_n_s_default, __pyx_k_default, sizeof(__pyx_k_default), 0, 0, 1, 1},
  {&__pyx_kp_s_dict_pass_s_s_r, __pyx_k_dict_pass_s_s_r, sizeof(__pyx_k_dict_pass_s_s_r), 0, 0, 1, 0},
  {&__pyx_n_s_doc, __pyx_k_doc, sizeof(__pyx_k_doc), 0, 0, 1, 1},
  {&__pyx_n_b_e, __pyx_k_e, sizeof(__pyx_k_e), 0, 0, 0, 1},
  {&__pyx_n_s_e, __pyx_k_e, sizeof(__pyx_k_e), 0, 0, 1, 1},
  {&__pyx_n_s_encode, __pyx_k_encode, sizeof(__pyx_k_encode), 0, 0, 1, 1},
  {&__pyx_n_s_exceptions, __pyx_k_exceptions, sizeof(__pyx_k_exceptions), 0, 0, 1, 1},
  {&__pyx_kp_s_fail_to_decode_dict_element_d_r, __pyx_k_fail_to_decode_dict_element_d_r, sizeof(__pyx_k_fail_to_decode_dict_element_d_r), 0, 0, 1, 0},
  {&__pyx_n_s_get_closest_nodes, __pyx_k_get_closest_nodes, sizeof(__pyx_k_get_closest_nodes), 0, 0, 1, 1},
  {&__pyx_n_s_get_peers, __pyx_k_get_peers, sizeof(__pyx_k_get_peers), 0, 0, 1, 1},
  {&__pyx_n_s_get_token, __pyx_k_get_token, sizeof(__pyx_k_get_token), 0, 0, 1, 1},
  {&__pyx_n_s_get_valid_token, __pyx_k_get_valid_token, sizeof(__pyx_k_get_valid_token), 0, 0, 1, 1},
  {&__pyx_n_s_getstate, __pyx_k_getstate, sizeof(__pyx_k_getstate), 0, 0, 1, 1},
  {&__pyx_n_b_id, __pyx_k_id, sizeof(__pyx_k_id), 0, 0, 0, 1},
  {&__pyx_n_b_implied_port, __pyx_k_implied_port, sizeof(__pyx_k_implied_port), 0, 0, 0, 1},
  {&__pyx_n_s_import, __pyx_k_import, sizeof(__pyx_k_import), 0, 0, 1, 1},
  {&__pyx_n_b_info_hash, __pyx_k_info_hash, sizeof(__pyx_k_info_hash), 0, 0, 0, 1},
  {&__pyx_kp_b_info_hash_missing, __pyx_k_info_hash_missing, sizeof(__pyx_k_info_hash_missing), 0, 0, 0, 0},
  {&__pyx_n_s_init, __pyx_k_init, sizeof(__pyx_k_init), 0, 0, 1, 1},
  {&__pyx_n_s_key, __pyx_k_key, sizeof(__pyx_k_key), 0, 0, 1, 1},
  {&__pyx_n_s_kwargs, __pyx_k_kwargs, sizeof(__pyx_k_kwargs), 0, 0, 1, 1},
  {&__pyx_kp_s_list_element_should_be_of_length, __pyx_k_list_element_should_be_of_length, sizeof(__pyx_k_list_element_should_be_of_length), 0, 0, 1, 0},
  {&__pyx_kp_s_list_pass_s_s_r, __pyx_k_list_pass_s_s_r, sizeof(__pyx_k_list_pass_s_s_r), 0, 0, 1, 0},
  {&__pyx_n_s_main, __pyx_k_main, sizeof(__pyx_k_main), 0, 0, 1, 1},
  {&__pyx_n_s_metaclass, __pyx_k_metaclass, sizeof(__pyx_k_metaclass), 0, 0, 1, 1},
  {&__pyx_n_s_module, __pyx_k_module, sizeof(__pyx_k_module), 0, 0, 1, 1},
  {&__pyx_n_s_msg, __pyx_k_msg, sizeof(__pyx_k_msg), 0, 0, 1, 1},
  {&__pyx_n_s_myid, __pyx_k_myid, sizeof(__pyx_k_myid), 0, 0, 1, 1},
  {&__pyx_n_s_name, __pyx_k_name, sizeof(__pyx_k_name), 0, 0, 1, 1},
  {&__pyx_kp_s_no_default___reduce___due_to_non, __pyx_k_no_default___reduce___due_to_non, sizeof(__pyx_k_no_default___reduce___due_to_non), 0, 0, 1, 0},
  {&__pyx_n_b_nodes, __pyx_k_nodes, sizeof(__pyx_k_nodes), 0, 0, 0, 1},
  {&__pyx_n_s_os, __pyx_k_os, sizeof(__pyx_k_os), 0, 0, 1, 1},
  {&__pyx_n_b_port, __pyx_k_port, sizeof(__pyx_k_port), 0, 0, 0, 1},
  {&__pyx_kp_b_port_missing, __pyx_k_port_missing, sizeof(__pyx_k_port_missing), 0, 0, 0, 0},
  {&__pyx_n_s_prepare, __pyx_k_prepare, sizeof(__pyx_k_prepare), 0, 0, 1, 1},
  {&__pyx_n_s_pyx_vtable, __pyx_k_pyx_vtable, sizeof(__pyx_k_pyx_vtable), 0, 0, 1, 1},
  {&__pyx_n_s_q, __pyx_k_q, sizeof(__pyx_k_q), 0, 0, 1, 1},
  {&__pyx_n_s_qualname, __pyx_k_qualname, sizeof(__pyx_k_qualname), 0, 0, 1, 1},
  {&__pyx_kp_s_r, __pyx_k_r, sizeof(__pyx_k_r), 0, 0, 1, 0},
  {&__pyx_n_s_range, __pyx_k_range, sizeof(__pyx_k_range), 0, 0, 1, 1},
  {&__pyx_n_s_reduce, __pyx_k_reduce, sizeof(__pyx_k_reduce), 0, 0, 1, 1},
  {&__pyx_n_s_reduce_cython, __pyx_k_reduce_cython, sizeof(__pyx_k_reduce_cython), 0, 0, 1, 1},
  {&__pyx_n_s_reduce_ex, __pyx_k_reduce_ex, sizeof(__pyx_k_reduce_ex), 0, 0, 1, 1},
  {&__pyx_n_s_repr, __pyx_k_repr, sizeof(__pyx_k_repr), 0, 0, 1, 1},
  {&__pyx_kp_s_s_at_s_r, __pyx_k_s_at_s_r, sizeof(__pyx_k_s_at_s_r), 0, 0, 1, 0},
  {&__pyx_kp_s_s_e_at_s_r, __pyx_k_s_e_at_s_r, sizeof(__pyx_k_s_e_at_s_r), 0, 0, 1, 0},
  {&__pyx_kp_s_s_r, __pyx_k_s_r, sizeof(__pyx_k_s_r), 0, 0, 1, 0},
  {&__pyx_kp_s_s_s_r, __pyx_k_s_s_r, sizeof(__pyx_k_s_s_r), 0, 0, 1, 0},
  {&__pyx_n_s_self, __pyx_k_self, sizeof(__pyx_k_self), 0, 0, 1, 1},
  {&__pyx_n_s_setstate, __pyx_k_setstate, sizeof(__pyx_k_setstate), 0, 0, 1, 1},
  {&__pyx_n_s_setstate_cython, __pyx_k_setstate_cython, sizeof(__pyx_k_setstate_cython), 0, 0, 1, 1},
  {&__pyx_n_s_six, __pyx_k_six, sizeof(__pyx_k_six), 0, 0, 1, 1},
  {&__pyx_n_s_str, __pyx_k_str, sizeof(__pyx_k_str), 0, 0, 1, 1},
  {&__pyx_n_s_super, __pyx_k_super, sizeof(__pyx_k_super), 0, 0, 1, 1},
  {&__pyx_n_b_t, __pyx_k_t, sizeof(__pyx_k_t), 0, 0, 0, 1},
  {&__pyx_n_s_t, __pyx_k_t, sizeof(__pyx_k_t), 0, 0, 1, 1},
  {&__pyx_kp_s_t_should_not_be_None, __pyx_k_t_should_not_be_None, sizeof(__pyx_k_t_should_not_be_None), 0, 0, 1, 0},
  {&__pyx_n_b_target, __pyx_k_target, sizeof(__pyx_k_target), 0, 0, 0, 1},
  {&__pyx_kp_b_target_missing, __pyx_k_target_missing, sizeof(__pyx_k_target_missing), 0, 0, 0, 0},
  {&__pyx_n_s_test, __pyx_k_test, sizeof(__pyx_k_test), 0, 0, 1, 1},
  {&__pyx_n_b_token, __pyx_k_token, sizeof(__pyx_k_token), 0, 0, 0, 1},
  {&__pyx_kp_b_token_missing, __pyx_k_token_missing, sizeof(__pyx_k_token_missing), 0, 0, 0, 0},
  {&__pyx_n_s_utils, __pyx_k_utils, sizeof(__pyx_k_utils), 0, 0, 1, 1},
  {&__pyx_n_s_value, __pyx_k_value, sizeof(__pyx_k_value), 0, 0, 1, 1},
  {&__pyx_n_b_values, __pyx_k_values, sizeof(__pyx_k_values), 0, 0, 0, 1},
  {&__pyx_n_b_y, __pyx_k_y, sizeof(__pyx_k_y), 0, 0, 0, 1},
  {&__pyx_n_s_y, __pyx_k_y, sizeof(__pyx_k_y), 0, 0, 1, 1},
  {0, 0, 0, 0, 0, 0, 0}
};
static CYTHON_SMALL_CODE int __Pyx_InitCachedBuiltins(void) {
  __pyx_builtin_EnvironmentError = __Pyx_GetBuiltinName(__pyx_n_s_EnvironmentError); if (!__pyx_builtin_EnvironmentError) __PYX_ERR(0, 67, __pyx_L1_error)
  __pyx_builtin_range = __Pyx_GetBuiltinName(__pyx_n_s_range); if (!__pyx_builtin_range) __PYX_ERR(0, 112, __pyx_L1_error)
  __pyx_builtin_ValueError = __Pyx_GetBuiltinName(__pyx_n_s_ValueError); if (!__pyx_builtin_ValueError) __PYX_ERR(0, 131, __pyx_L1_error)
  __pyx_builtin_super = __Pyx_GetBuiltinName(__pyx_n_s_super); if (!__pyx_builtin_super) __PYX_ERR(0, 389, __pyx_L1_error)
  __pyx_builtin_NotImplementedError = __Pyx_GetBuiltinName(__pyx_n_s_NotImplementedError); if (!__pyx_builtin_NotImplementedError) __PYX_ERR(0, 401, __pyx_L1_error)
  __pyx_builtin_KeyError = __Pyx_GetBuiltinName(__pyx_n_s_KeyError); if (!__pyx_builtin_KeyError) __PYX_ERR(0, 1578, __pyx_L1_error)
  __pyx_builtin_TypeError = __Pyx_GetBuiltinName(__pyx_n_s_TypeError); if (!__pyx_builtin_TypeError) __PYX_ERR(1, 2, __pyx_L1_error)
  return 0;
  __pyx_L1_error:;
  return -1;
}

static CYTHON_SMALL_CODE int __Pyx_InitCachedConstants(void) {
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__Pyx_InitCachedConstants", 0);

  /* "btdht/krcp.pyx":386
 *     def __init__(self, t, e, **kwargs):
 *         if t is None:
 *             raise ValueError("t should not be None")             # <<<<<<<<<<<<<<
 *         self.t = t
 *         self.e = e
 */
  __pyx_tuple_ = PyTuple_Pack(1, __pyx_kp_s_t_should_not_be_None); if (unlikely(!__pyx_tuple_)) __PYX_ERR(0, 386, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple_);
  __Pyx_GIVEREF(__pyx_tuple_);

  /* "btdht/krcp.pyx":1420
 *                 return self.encoded[:self.encoded_len]
 *         else:
 *             raise EnvironmentError("Unable to encode BMessage")             # <<<<<<<<<<<<<<
 * 
 *     def __repr__(self):
 */
  __pyx_tuple__3 = PyTuple_Pack(1, __pyx_kp_s_Unable_to_encode_BMessage); if (unlikely(!__pyx_tuple__3)) __PYX_ERR(0, 1420, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__3);
  __Pyx_GIVEREF(__pyx_tuple__3);

  /* "btdht/krcp.pyx":1631
 *                 with gil:
 *                     if len(value) != 20:
 *                         raise ValueError("Can only set strings of length 20B")             # <<<<<<<<<<<<<<
 *                     j = value
 *                 self.set_id(j, 20)
 */
  __pyx_tuple__4 = PyTuple_Pack(1, __pyx_kp_s_Can_only_set_strings_of_length_2); if (unlikely(!__pyx_tuple__4)) __PYX_ERR(0, 1631, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__4);
  __Pyx_GIVEREF(__pyx_tuple__4);

  /* "(tree fragment)":2
 * def __reduce_cython__(self):
 *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")             # <<<<<<<<<<<<<<
 * def __setstate_cython__(self, __pyx_state):
 *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")
 */
  __pyx_tuple__5 = PyTuple_Pack(1, __pyx_kp_s_no_default___reduce___due_to_non); if (unlikely(!__pyx_tuple__5)) __PYX_ERR(1, 2, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__5);
  __Pyx_GIVEREF(__pyx_tuple__5);

  /* "(tree fragment)":4
 *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")
 * def __setstate_cython__(self, __pyx_state):
 *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")             # <<<<<<<<<<<<<<
 */
  __pyx_tuple__6 = PyTuple_Pack(1, __pyx_kp_s_no_default___reduce___due_to_non); if (unlikely(!__pyx_tuple__6)) __PYX_ERR(1, 4, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__6);
  __Pyx_GIVEREF(__pyx_tuple__6);

  /* "btdht/krcp.pyx":384
 *     # The second element is a string containing the error message
 *     e = None
 *     def __init__(self, t, e, **kwargs):             # <<<<<<<<<<<<<<
 *         if t is None:
 *             raise ValueError("t should not be None")
 */
  __pyx_tuple__7 = PyTuple_Pack(4, __pyx_n_s_self, __pyx_n_s_t, __pyx_n_s_e, __pyx_n_s_kwargs); if (unlikely(!__pyx_tuple__7)) __PYX_ERR(0, 384, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__7);
  __Pyx_GIVEREF(__pyx_tuple__7);
  __pyx_codeobj__8 = (PyObject*)__Pyx_PyCode_New(3, 0, 4, 0, CO_OPTIMIZED|CO_NEWLOCALS|CO_VARKEYWORDS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__7, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_btdht_krcp_pyx, __pyx_n_s_init, 384, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__8)) __PYX_ERR(0, 384, __pyx_L1_error)

  /* "btdht/krcp.pyx":391
 *         super(BError, self).__init__(*e, **kwargs)
 * 
 *     def encode(self):             # <<<<<<<<<<<<<<
 *         """
 *             Bencode the error message
 */
  __pyx_tuple__9 = PyTuple_Pack(1, __pyx_n_s_self); if (unlikely(!__pyx_tuple__9)) __PYX_ERR(0, 391, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__9);
  __Pyx_GIVEREF(__pyx_tuple__9);
  __pyx_codeobj__10 = (PyObject*)__Pyx_PyCode_New(1, 0, 1, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__9, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_btdht_krcp_pyx, __pyx_n_s_encode, 391, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__10)) __PYX_ERR(0, 391, __pyx_L1_error)

  /* "btdht/krcp.pyx":400
 *         return utils.bencode({b"y":self.y, b"t":self.t, b"e":self.e})
 * 
 *     def __str__(self):             # <<<<<<<<<<<<<<
 *         raise NotImplementedError()
 * 
 */
  __pyx_tuple__11 = PyTuple_Pack(1, __pyx_n_s_self); if (unlikely(!__pyx_tuple__11)) __PYX_ERR(0, 400, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__11);
  __Pyx_GIVEREF(__pyx_tuple__11);
  __pyx_codeobj__12 = (PyObject*)__Pyx_PyCode_New(1, 0, 1, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__11, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_btdht_krcp_pyx, __pyx_n_s_str, 400, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__12)) __PYX_ERR(0, 400, __pyx_L1_error)

  /* "btdht/krcp.pyx":403
 *         raise NotImplementedError()
 * 
 *     def __repr__(self):             # <<<<<<<<<<<<<<
 *         return "%s: %r" % (self.__class__.__name__, self.e)
 * 
 */
  __pyx_tuple__13 = PyTuple_Pack(1, __pyx_n_s_self); if (unlikely(!__pyx_tuple__13)) __PYX_ERR(0, 403, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__13);
  __Pyx_GIVEREF(__pyx_tuple__13);
  __pyx_codeobj__14 = (PyObject*)__Pyx_PyCode_New(1, 0, 1, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__13, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_btdht_krcp_pyx, __pyx_n_s_repr, 403, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__14)) __PYX_ERR(0, 403, __pyx_L1_error)

  /* "btdht/krcp.pyx":413
 *         :param bytes msg: An optionnal error message
 *     """
 *     def __init__(self, t, msg=b""):             # <<<<<<<<<<<<<<
 *         super(GenericError, self).__init__(t=t, e=[201, msg])
 * class ServerError(BError):
 */
  __pyx_tuple__15 = PyTuple_Pack(3, __pyx_n_s_self, __pyx_n_s_t, __pyx_n_s_msg); if (unlikely(!__pyx_tuple__15)) __PYX_ERR(0, 413, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__15);
  __Pyx_GIVEREF(__pyx_tuple__15);
  __pyx_codeobj__16 = (PyObject*)__Pyx_PyCode_New(3, 0, 3, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__15, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_btdht_krcp_pyx, __pyx_n_s_init, 413, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__16)) __PYX_ERR(0, 413, __pyx_L1_error)
  __pyx_tuple__17 = PyTuple_Pack(1, ((PyObject*)__pyx_kp_b__2)); if (unlikely(!__pyx_tuple__17)) __PYX_ERR(0, 413, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__17);
  __Pyx_GIVEREF(__pyx_tuple__17);

  /* "btdht/krcp.pyx":422
 *         :param bytes msg: An optionnal error message
 *     """
 *     def __init__(self, t, msg=b"Server Error"):             # <<<<<<<<<<<<<<
 *         super(ServerError, self).__init__(t=t, e=[202, msg])
 * class ProtocolError(BError):
 */
  __pyx_tuple__18 = PyTuple_Pack(3, __pyx_n_s_self, __pyx_n_s_t, __pyx_n_s_msg); if (unlikely(!__pyx_tuple__18)) __PYX_ERR(0, 422, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__18);
  __Pyx_GIVEREF(__pyx_tuple__18);
  __pyx_codeobj__19 = (PyObject*)__Pyx_PyCode_New(3, 0, 3, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__18, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_btdht_krcp_pyx, __pyx_n_s_init, 422, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__19)) __PYX_ERR(0, 422, __pyx_L1_error)
  __pyx_tuple__20 = PyTuple_Pack(1, ((PyObject*)__pyx_kp_b_Server_Error)); if (unlikely(!__pyx_tuple__20)) __PYX_ERR(0, 422, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__20);
  __Pyx_GIVEREF(__pyx_tuple__20);

  /* "btdht/krcp.pyx":432
 *         :param bytes msg: An optionnal error message
 *     """
 *     def __init__(self, t, msg=b"Protocol Error"):             # <<<<<<<<<<<<<<
 *         super(ProtocolError, self).__init__(t=t, e=[203, msg])
 * class MethodUnknownError(BError):
 */
  __pyx_tuple__21 = PyTuple_Pack(3, __pyx_n_s_self, __pyx_n_s_t, __pyx_n_s_msg); if (unlikely(!__pyx_tuple__21)) __PYX_ERR(0, 432, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__21);
  __Pyx_GIVEREF(__pyx_tuple__21);
  __pyx_codeobj__22 = (PyObject*)__Pyx_PyCode_New(3, 0, 3, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__21, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_btdht_krcp_pyx, __pyx_n_s_init, 432, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__22)) __PYX_ERR(0, 432, __pyx_L1_error)
  __pyx_tuple__23 = PyTuple_Pack(1, ((PyObject*)__pyx_kp_b_Protocol_Error)); if (unlikely(!__pyx_tuple__23)) __PYX_ERR(0, 432, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__23);
  __Pyx_GIVEREF(__pyx_tuple__23);

  /* "btdht/krcp.pyx":441
 *         :param bytes msg: An optionnal error message
 *     """
 *     def __init__(self, t, msg=b"Method Unknow"):             # <<<<<<<<<<<<<<
 *         super(MethodUnknownError, self).__init__(t=t, e=[204, msg])
 * 
 */
  __pyx_tuple__24 = PyTuple_Pack(3, __pyx_n_s_self, __pyx_n_s_t, __pyx_n_s_msg); if (unlikely(!__pyx_tuple__24)) __PYX_ERR(0, 441, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__24);
  __Pyx_GIVEREF(__pyx_tuple__24);
  __pyx_codeobj__25 = (PyObject*)__Pyx_PyCode_New(3, 0, 3, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__24, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_btdht_krcp_pyx, __pyx_n_s_init, 441, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__25)) __PYX_ERR(0, 441, __pyx_L1_error)
  __pyx_tuple__26 = PyTuple_Pack(1, ((PyObject*)__pyx_kp_b_Method_Unknow)); if (unlikely(!__pyx_tuple__26)) __PYX_ERR(0, 441, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__26);
  __Pyx_GIVEREF(__pyx_tuple__26);
  __Pyx_RefNannyFinishContext();
  return 0;
  __pyx_L1_error:;
  __Pyx_RefNannyFinishContext();
  return -1;
}

static CYTHON_SMALL_CODE int __Pyx_InitGlobals(void) {
  /* InitThreads.init */
  #if defined(WITH_THREAD) && PY_VERSION_HEX < 0x030700F0
PyEval_InitThreads();
#endif

if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 1, __pyx_L1_error)

  if (__Pyx_InitStrings(__pyx_string_tab) < 0) __PYX_ERR(0, 1, __pyx_L1_error);
  __pyx_int_201 = PyInt_FromLong(201); if (unlikely(!__pyx_int_201)) __PYX_ERR(0, 1, __pyx_L1_error)
  __pyx_int_202 = PyInt_FromLong(202); if (unlikely(!__pyx_int_202)) __PYX_ERR(0, 1, __pyx_L1_error)
  __pyx_int_203 = PyInt_FromLong(203); if (unlikely(!__pyx_int_203)) __PYX_ERR(0, 1, __pyx_L1_error)
  __pyx_int_204 = PyInt_FromLong(204); if (unlikely(!__pyx_int_204)) __PYX_ERR(0, 1, __pyx_L1_error)
  return 0;
  __pyx_L1_error:;
  return -1;
}

static CYTHON_SMALL_CODE int __Pyx_modinit_global_init_code(void); /*proto*/
static CYTHON_SMALL_CODE int __Pyx_modinit_variable_export_code(void); /*proto*/
static CYTHON_SMALL_CODE int __Pyx_modinit_function_export_code(void); /*proto*/
static CYTHON_SMALL_CODE int __Pyx_modinit_type_init_code(void); /*proto*/
static CYTHON_SMALL_CODE int __Pyx_modinit_type_import_code(void); /*proto*/
static CYTHON_SMALL_CODE int __Pyx_modinit_variable_import_code(void); /*proto*/
static CYTHON_SMALL_CODE int __Pyx_modinit_function_import_code(void); /*proto*/

static int __Pyx_modinit_global_init_code(void) {
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__Pyx_modinit_global_init_code", 0);
  /*--- Global init code ---*/
  __Pyx_RefNannyFinishContext();
  return 0;
}

static int __Pyx_modinit_variable_export_code(void) {
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__Pyx_modinit_variable_export_code", 0);
  /*--- Variable export code ---*/
  __Pyx_RefNannyFinishContext();
  return 0;
}

static int __Pyx_modinit_function_export_code(void) {
  __Pyx_RefNannyDeclarations
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__Pyx_modinit_function_export_code", 0);
  /*--- Function export code ---*/
  if (__Pyx_ExportFunction("_decode_int", (void (*)(void))__pyx_f_5btdht_4krcp__decode_int, "long (char *, int *, int, PY_LONG_LONG *)") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  if (__Pyx_ExportFunction("_decode_string", (void (*)(void))__pyx_f_5btdht_4krcp__decode_string, "int (char *, int *, int, int *)") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  __Pyx_RefNannyFinishContext();
  return 0;
  __pyx_L1_error:;
  __Pyx_RefNannyFinishContext();
  return -1;
}

static int __Pyx_modinit_type_init_code(void) {
  __Pyx_RefNannyDeclarations
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__Pyx_modinit_type_init_code", 0);
  /*--- Type init code ---*/
  __pyx_vtabptr_5btdht_4krcp_BMessage = &__pyx_vtable_5btdht_4krcp_BMessage;
  __pyx_vtable_5btdht_4krcp_BMessage.set_r = (int (*)(struct __pyx_obj_5btdht_4krcp_BMessage *, int))__pyx_f_5btdht_4krcp_8BMessage_set_r;
  __pyx_vtable_5btdht_4krcp_BMessage.set_a = (int (*)(struct __pyx_obj_5btdht_4krcp_BMessage *, int))__pyx_f_5btdht_4krcp_8BMessage_set_a;
  __pyx_vtable_5btdht_4krcp_BMessage.set_e = (int (*)(struct __pyx_obj_5btdht_4krcp_BMessage *, int))__pyx_f_5btdht_4krcp_8BMessage_set_e;
  __pyx_vtable_5btdht_4krcp_BMessage.set_t = (int (*)(struct __pyx_obj_5btdht_4krcp_BMessage *, char *, int))__pyx_f_5btdht_4krcp_8BMessage_set_t;
  __pyx_vtable_5btdht_4krcp_BMessage.del_t = (void (*)(struct __pyx_obj_5btdht_4krcp_BMessage *))__pyx_f_5btdht_4krcp_8BMessage_del_t;
  __pyx_vtable_5btdht_4krcp_BMessage.set_v = (int (*)(struct __pyx_obj_5btdht_4krcp_BMessage *, char *, int))__pyx_f_5btdht_4krcp_8BMessage_set_v;
  __pyx_vtable_5btdht_4krcp_BMessage.del_v = (void (*)(struct __pyx_obj_5btdht_4krcp_BMessage *))__pyx_f_5btdht_4krcp_8BMessage_del_v;
  __pyx_vtable_5btdht_4krcp_BMessage.set_y = (int (*)(struct __pyx_obj_5btdht_4krcp_BMessage *, char *, int))__pyx_f_5btdht_4krcp_8BMessage_set_y;
  __pyx_vtable_5btdht_4krcp_BMessage.del_y = (void (*)(struct __pyx_obj_5btdht_4krcp_BMessage *))__pyx_f_5btdht_4krcp_8BMessage_del_y;
  __pyx_vtable_5btdht_4krcp_BMessage.set_q = (int (*)(struct __pyx_obj_5btdht_4krcp_BMessage *, char *, int))__pyx_f_5btdht_4krcp_8BMessage_set_q;
  __pyx_vtable_5btdht_4krcp_BMessage.del_q = (void (*)(struct __pyx_obj_5btdht_4krcp_BMessage *))__pyx_f_5btdht_4krcp_8BMessage_del_q;
  __pyx_vtable_5btdht_4krcp_BMessage.set_id = (int (*)(struct __pyx_obj_5btdht_4krcp_BMessage *, char *, int))__pyx_f_5btdht_4krcp_8BMessage_set_id;
  __pyx_vtable_5btdht_4krcp_BMessage.del_id = (void (*)(struct __pyx_obj_5btdht_4krcp_BMessage *))__pyx_f_5btdht_4krcp_8BMessage_del_id;
  __pyx_vtable_5btdht_4krcp_BMessage.set_target = (int (*)(struct __pyx_obj_5btdht_4krcp_BMessage *, char *, int))__pyx_f_5btdht_4krcp_8BMessage_set_target;
  __pyx_vtable_5btdht_4krcp_BMessage.del_target = (void (*)(struct __pyx_obj_5btdht_4krcp_BMessage *))__pyx_f_5btdht_4krcp_8BMessage_del_target;
  __pyx_vtable_5btdht_4krcp_BMessage.set_info_hash = (int (*)(struct __pyx_obj_5btdht_4krcp_BMessage *, char *, int))__pyx_f_5btdht_4krcp_8BMessage_set_info_hash;
  __pyx_vtable_5btdht_4krcp_BMessage.del_info_hash = (void (*)(struct __pyx_obj_5btdht_4krcp_BMessage *))__pyx_f_5btdht_4krcp_8BMessage_del_info_hash;
  __pyx_vtable_5btdht_4krcp_BMessage.del_implied_port = (void (*)(struct __pyx_obj_5btdht_4krcp_BMessage *))__pyx_f_5btdht_4krcp_8BMessage_del_implied_port;
  __pyx_vtable_5btdht_4krcp_BMessage.set_implied_port = (int (*)(struct __pyx_obj_5btdht_4krcp_BMessage *, int))__pyx_f_5btdht_4krcp_8BMessage_set_implied_port;
  __pyx_vtable_5btdht_4krcp_BMessage.set_port = (int (*)(struct __pyx_obj_5btdht_4krcp_BMessage *, int))__pyx_f_5btdht_4krcp_8BMessage_set_port;
  __pyx_vtable_5btdht_4krcp_BMessage.del_port = (void (*)(struct __pyx_obj_5btdht_4krcp_BMessage *))__pyx_f_5btdht_4krcp_8BMessage_del_port;
  __pyx_vtable_5btdht_4krcp_BMessage.set_token = (int (*)(struct __pyx_obj_5btdht_4krcp_BMessage *, char *, int))__pyx_f_5btdht_4krcp_8BMessage_set_token;
  __pyx_vtable_5btdht_4krcp_BMessage.del_token = (void (*)(struct __pyx_obj_5btdht_4krcp_BMessage *))__pyx_f_5btdht_4krcp_8BMessage_del_token;
  __pyx_vtable_5btdht_4krcp_BMessage.set_nodes = (int (*)(struct __pyx_obj_5btdht_4krcp_BMessage *, char *, int))__pyx_f_5btdht_4krcp_8BMessage_set_nodes;
  __pyx_vtable_5btdht_4krcp_BMessage.del_nodes = (int (*)(struct __pyx_obj_5btdht_4krcp_BMessage *))__pyx_f_5btdht_4krcp_8BMessage_del_nodes;
  __pyx_vtable_5btdht_4krcp_BMessage.set_values = (int (*)(struct __pyx_obj_5btdht_4krcp_BMessage *, char **, int))__pyx_f_5btdht_4krcp_8BMessage_set_values;
  __pyx_vtable_5btdht_4krcp_BMessage.del_values = (void (*)(struct __pyx_obj_5btdht_4krcp_BMessage *))__pyx_f_5btdht_4krcp_8BMessage_del_values;
  __pyx_vtable_5btdht_4krcp_BMessage.set_errmsg = (int (*)(struct __pyx_obj_5btdht_4krcp_BMessage *, char *, int))__pyx_f_5btdht_4krcp_8BMessage_set_errmsg;
  __pyx_vtable_5btdht_4krcp_BMessage.del_errmsg = (void (*)(struct __pyx_obj_5btdht_4krcp_BMessage *))__pyx_f_5btdht_4krcp_8BMessage_del_errmsg;
  __pyx_vtable_5btdht_4krcp_BMessage.set_errno = (int (*)(struct __pyx_obj_5btdht_4krcp_BMessage *, int))__pyx_f_5btdht_4krcp_8BMessage_set_errno;
  __pyx_vtable_5btdht_4krcp_BMessage.del_encoded = (void (*)(struct __pyx_obj_5btdht_4krcp_BMessage *))__pyx_f_5btdht_4krcp_8BMessage_del_encoded;
  __pyx_vtable_5btdht_4krcp_BMessage._encode_values = (int (*)(struct __pyx_obj_5btdht_4krcp_BMessage *, char *, int *, int))__pyx_f_5btdht_4krcp_8BMessage__encode_values;
  __pyx_vtable_5btdht_4krcp_BMessage._encode_secondary_dict = (int (*)(struct __pyx_obj_5btdht_4krcp_BMessage *, char *, int *, int))__pyx_f_5btdht_4krcp_8BMessage__encode_secondary_dict;
  __pyx_vtable_5btdht_4krcp_BMessage._encode_error = (int (*)(struct __pyx_obj_5btdht_4krcp_BMessage *, char *, int *, int))__pyx_f_5btdht_4krcp_8BMessage__encode_error;
  __pyx_vtable_5btdht_4krcp_BMessage._encode_main_dict = (int (*)(struct __pyx_obj_5btdht_4krcp_BMessage *, char *, int *, int))__pyx_f_5btdht_4krcp_8BMessage__encode_main_dict;
  __pyx_vtable_5btdht_4krcp_BMessage._encode = (int (*)(struct __pyx_obj_5btdht_4krcp_BMessage *))__pyx_f_5btdht_4krcp_8BMessage__encode;
  __pyx_vtable_5btdht_4krcp_BMessage._encode_len = (int (*)(struct __pyx_obj_5btdht_4krcp_BMessage *))__pyx_f_5btdht_4krcp_8BMessage__encode_len;
  __pyx_vtable_5btdht_4krcp_BMessage._decode_error = (int (*)(struct __pyx_obj_5btdht_4krcp_BMessage *, char *, int *, int))__pyx_f_5btdht_4krcp_8BMessage__decode_error;
  __pyx_vtable_5btdht_4krcp_BMessage._decode_dict_elm = (int (*)(struct __pyx_obj_5btdht_4krcp_BMessage *, char *, int *, int))__pyx_f_5btdht_4krcp_8BMessage__decode_dict_elm;
  __pyx_vtable_5btdht_4krcp_BMessage._decode_values = (int (*)(struct __pyx_obj_5btdht_4krcp_BMessage *, char *, int *, int))__pyx_f_5btdht_4krcp_8BMessage__decode_values;
  __pyx_vtable_5btdht_4krcp_BMessage._decode_dict = (int (*)(struct __pyx_obj_5btdht_4krcp_BMessage *, char *, int *, int))__pyx_f_5btdht_4krcp_8BMessage__decode_dict;
  __pyx_vtable_5btdht_4krcp_BMessage._decode = (int (*)(struct __pyx_obj_5btdht_4krcp_BMessage *, char *, int *, int))__pyx_f_5btdht_4krcp_8BMessage__decode;
  if (PyType_Ready(&__pyx_type_5btdht_4krcp_BMessage) < 0) __PYX_ERR(0, 445, __pyx_L1_error)
  #if PY_VERSION_HEX < 0x030800B1
  __pyx_type_5btdht_4krcp_BMessage.tp_print = 0;
  #endif
  if ((CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP) && likely(!__pyx_type_5btdht_4krcp_BMessage.tp_dictoffset && __pyx_type_5btdht_4krcp_BMessage.tp_getattro == PyObject_GenericGetAttr)) {
    __pyx_type_5btdht_4krcp_BMessage.tp_getattro = __Pyx_PyObject_GenericGetAttr;
  }
  #if CYTHON_UPDATE_DESCRIPTOR_DOC
  {
    PyObject *wrapper = PyObject_GetAttrString((PyObject *)&__pyx_type_5btdht_4krcp_BMessage, "__getitem__"); if (unlikely(!wrapper)) __PYX_ERR(0, 445, __pyx_L1_error)
    if (Py_TYPE(wrapper) == &PyWrapperDescr_Type) {
      __pyx_wrapperbase_5btdht_4krcp_8BMessage_8__getitem__ = *((PyWrapperDescrObject *)wrapper)->d_base;
      __pyx_wrapperbase_5btdht_4krcp_8BMessage_8__getitem__.doc = __pyx_doc_5btdht_4krcp_8BMessage_8__getitem__;
      ((PyWrapperDescrObject *)wrapper)->d_base = &__pyx_wrapperbase_5btdht_4krcp_8BMessage_8__getitem__;
    }
  }
  #endif
  #if CYTHON_UPDATE_DESCRIPTOR_DOC
  {
    PyObject *wrapper = PyObject_GetAttrString((PyObject *)&__pyx_type_5btdht_4krcp_BMessage, "__delitem__"); if (unlikely(!wrapper)) __PYX_ERR(0, 445, __pyx_L1_error)
    if (Py_TYPE(wrapper) == &PyWrapperDescr_Type) {
      __pyx_wrapperbase_5btdht_4krcp_8BMessage_10__delitem__ = *((PyWrapperDescrObject *)wrapper)->d_base;
      __pyx_wrapperbase_5btdht_4krcp_8BMessage_10__delitem__.doc = __pyx_doc_5btdht_4krcp_8BMessage_10__delitem__;
      ((PyWrapperDescrObject *)wrapper)->d_base = &__pyx_wrapperbase_5btdht_4krcp_8BMessage_10__delitem__;
    }
  }
  #endif
  #if CYTHON_UPDATE_DESCRIPTOR_DOC
  {
    PyObject *wrapper = PyObject_GetAttrString((PyObject *)&__pyx_type_5btdht_4krcp_BMessage, "__setitem__"); if (unlikely(!wrapper)) __PYX_ERR(0, 445, __pyx_L1_error)
    if (Py_TYPE(wrapper) == &PyWrapperDescr_Type) {
      __pyx_wrapperbase_5btdht_4krcp_8BMessage_12__setitem__ = *((PyWrapperDescrObject *)wrapper)->d_base;
      __pyx_wrapperbase_5btdht_4krcp_8BMessage_12__setitem__.doc = __pyx_doc_5btdht_4krcp_8BMessage_12__setitem__;
      ((PyWrapperDescrObject *)wrapper)->d_base = &__pyx_wrapperbase_5btdht_4krcp_8BMessage_12__setitem__;
    }
  }
  #endif
  if (__Pyx_SetVtable(__pyx_type_5btdht_4krcp_BMessage.tp_dict, __pyx_vtabptr_5btdht_4krcp_BMessage) < 0) __PYX_ERR(0, 445, __pyx_L1_error)
  if (PyObject_SetAttr(__pyx_m, __pyx_n_s_BMessage, (PyObject *)&__pyx_type_5btdht_4krcp_BMessage) < 0) __PYX_ERR(0, 445, __pyx_L1_error)
  if (__Pyx_setup_reduce((PyObject*)&__pyx_type_5btdht_4krcp_BMessage) < 0) __PYX_ERR(0, 445, __pyx_L1_error)
  __pyx_ptype_5btdht_4krcp_BMessage = &__pyx_type_5btdht_4krcp_BMessage;
  __Pyx_RefNannyFinishContext();
  return 0;
  __pyx_L1_error:;
  __Pyx_RefNannyFinishContext();
  return -1;
}

static int __Pyx_modinit_type_import_code(void) {
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__Pyx_modinit_type_import_code", 0);
  /*--- Type import code ---*/
  __Pyx_RefNannyFinishContext();
  return 0;
}

static int __Pyx_modinit_variable_import_code(void) {
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__Pyx_modinit_variable_import_code", 0);
  /*--- Variable import code ---*/
  __Pyx_RefNannyFinishContext();
  return 0;
}

static int __Pyx_modinit_function_import_code(void) {
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__Pyx_modinit_function_import_code", 0);
  /*--- Function import code ---*/
  __Pyx_RefNannyFinishContext();
  return 0;
}


#ifndef CYTHON_NO_PYINIT_EXPORT
#define __Pyx_PyMODINIT_FUNC PyMODINIT_FUNC
#elif PY_MAJOR_VERSION < 3
#ifdef __cplusplus
#define __Pyx_PyMODINIT_FUNC extern "C" void
#else
#define __Pyx_PyMODINIT_FUNC void
#endif
#else
#ifdef __cplusplus
#define __Pyx_PyMODINIT_FUNC extern "C" PyObject *
#else
#define __Pyx_PyMODINIT_FUNC PyObject *
#endif
#endif


#if PY_MAJOR_VERSION < 3
__Pyx_PyMODINIT_FUNC initkrcp(void) CYTHON_SMALL_CODE; /*proto*/
__Pyx_PyMODINIT_FUNC initkrcp(void)
#else
__Pyx_PyMODINIT_FUNC PyInit_krcp(void) CYTHON_SMALL_CODE; /*proto*/
__Pyx_PyMODINIT_FUNC PyInit_krcp(void)
#if CYTHON_PEP489_MULTI_PHASE_INIT
{
  return PyModuleDef_Init(&__pyx_moduledef);
}
static CYTHON_SMALL_CODE int __Pyx_check_single_interpreter(void) {
    #if PY_VERSION_HEX >= 0x030700A1
    static PY_INT64_T main_interpreter_id = -1;
    PY_INT64_T current_id = PyInterpreterState_GetID(PyThreadState_Get()->interp);
    if (main_interpreter_id == -1) {
        main_interpreter_id = current_id;
        return (unlikely(current_id == -1)) ? -1 : 0;
    } else if (unlikely(main_interpreter_id != current_id))
    #else
    static PyInterpreterState *main_interpreter = NULL;
    PyInterpreterState *current_interpreter = PyThreadState_Get()->interp;
    if (!main_interpreter) {
        main_interpreter = current_interpreter;
    } else if (unlikely(main_interpreter != current_interpreter))
    #endif
    {
        PyErr_SetString(
            PyExc_ImportError,
            "Interpreter change detected - this module can only be loaded into one interpreter per process.");
        return -1;
    }
    return 0;
}
static CYTHON_SMALL_CODE int __Pyx_copy_spec_to_module(PyObject *spec, PyObject *moddict, const char* from_name, const char* to_name, int allow_none) {
    PyObject *value = PyObject_GetAttrString(spec, from_name);
    int result = 0;
    if (likely(value)) {
        if (allow_none || value != Py_None) {
            result = PyDict_SetItemString(moddict, to_name, value);
        }
        Py_DECREF(value);
    } else if (PyErr_ExceptionMatches(PyExc_AttributeError)) {
        PyErr_Clear();
    } else {
        result = -1;
    }
    return result;
}
static CYTHON_SMALL_CODE PyObject* __pyx_pymod_create(PyObject *spec, CYTHON_UNUSED PyModuleDef *def) {
    PyObject *module = NULL, *moddict, *modname;
    if (__Pyx_check_single_interpreter())
        return NULL;
    if (__pyx_m)
        return __Pyx_NewRef(__pyx_m);
    modname = PyObject_GetAttrString(spec, "name");
    if (unlikely(!modname)) goto bad;
    module = PyModule_NewObject(modname);
    Py_DECREF(modname);
    if (unlikely(!module)) goto bad;
    moddict = PyModule_GetDict(module);
    if (unlikely(!moddict)) goto bad;
    if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "loader", "__loader__", 1) < 0)) goto bad;
    if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "origin", "__file__", 1) < 0)) goto bad;
    if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "parent", "__package__", 1) < 0)) goto bad;
    if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "submodule_search_locations", "__path__", 0) < 0)) goto bad;
    return module;
bad:
    Py_XDECREF(module);
    return NULL;
}


static CYTHON_SMALL_CODE int __pyx_pymod_exec_krcp(PyObject *__pyx_pyinit_module)
#endif
#endif
{
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannyDeclarations
  #if CYTHON_PEP489_MULTI_PHASE_INIT
  if (__pyx_m) {
    if (__pyx_m == __pyx_pyinit_module) return 0;
    PyErr_SetString(PyExc_RuntimeError, "Module 'krcp' has already been imported. Re-initialisation is not supported.");
    return -1;
  }
  #elif PY_MAJOR_VERSION >= 3
  if (__pyx_m) return __Pyx_NewRef(__pyx_m);
  #endif
  #if CYTHON_REFNANNY
__Pyx_RefNanny = __Pyx_RefNannyImportAPI("refnanny");
if (!__Pyx_RefNanny) {
  PyErr_Clear();
  __Pyx_RefNanny = __Pyx_RefNannyImportAPI("Cython.Runtime.refnanny");
  if (!__Pyx_RefNanny)
      Py_FatalError("failed to import 'refnanny' module");
}
#endif
  __Pyx_RefNannySetupContext("__Pyx_PyMODINIT_FUNC PyInit_krcp(void)", 0);
  if (__Pyx_check_binary_version() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  #ifdef __Pxy_PyFrame_Initialize_Offsets
  __Pxy_PyFrame_Initialize_Offsets();
  #endif
  __pyx_empty_tuple = PyTuple_New(0); if (unlikely(!__pyx_empty_tuple)) __PYX_ERR(0, 1, __pyx_L1_error)
  __pyx_empty_bytes = PyBytes_FromStringAndSize("", 0); if (unlikely(!__pyx_empty_bytes)) __PYX_ERR(0, 1, __pyx_L1_error)
  __pyx_empty_unicode = PyUnicode_FromStringAndSize("", 0); if (unlikely(!__pyx_empty_unicode)) __PYX_ERR(0, 1, __pyx_L1_error)
  #ifdef __Pyx_CyFunction_USED
  if (__pyx_CyFunction_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  #endif
  #ifdef __Pyx_FusedFunction_USED
  if (__pyx_FusedFunction_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  #endif
  #ifdef __Pyx_Coroutine_USED
  if (__pyx_Coroutine_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  #endif
  #ifdef __Pyx_Generator_USED
  if (__pyx_Generator_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  #endif
  #ifdef __Pyx_AsyncGen_USED
  if (__pyx_AsyncGen_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  #endif
  #ifdef __Pyx_StopAsyncIteration_USED
  if (__pyx_StopAsyncIteration_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  #endif
  /*--- Library function declarations ---*/
  /*--- Threads initialization code ---*/
  #if defined(WITH_THREAD) && PY_VERSION_HEX < 0x030700F0 && defined(__PYX_FORCE_INIT_THREADS) && __PYX_FORCE_INIT_THREADS
  PyEval_InitThreads();
  #endif
  /*--- Module creation code ---*/
  #if CYTHON_PEP489_MULTI_PHASE_INIT
  __pyx_m = __pyx_pyinit_module;
  Py_INCREF(__pyx_m);
  #else
  #if PY_MAJOR_VERSION < 3
  __pyx_m = Py_InitModule4("krcp", __pyx_methods, 0, 0, PYTHON_API_VERSION); Py_XINCREF(__pyx_m);
  #else
  __pyx_m = PyModule_Create(&__pyx_moduledef);
  #endif
  if (unlikely(!__pyx_m)) __PYX_ERR(0, 1, __pyx_L1_error)
  #endif
  __pyx_d = PyModule_GetDict(__pyx_m); if (unlikely(!__pyx_d)) __PYX_ERR(0, 1, __pyx_L1_error)
  Py_INCREF(__pyx_d);
  __pyx_b = PyImport_AddModule(__Pyx_BUILTIN_MODULE_NAME); if (unlikely(!__pyx_b)) __PYX_ERR(0, 1, __pyx_L1_error)
  Py_INCREF(__pyx_b);
  __pyx_cython_runtime = PyImport_AddModule((char *) "cython_runtime"); if (unlikely(!__pyx_cython_runtime)) __PYX_ERR(0, 1, __pyx_L1_error)
  Py_INCREF(__pyx_cython_runtime);
  if (PyObject_SetAttrString(__pyx_m, "__builtins__", __pyx_b) < 0) __PYX_ERR(0, 1, __pyx_L1_error);
  /*--- Initialize various global constants etc. ---*/
  if (__Pyx_InitGlobals() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  #if PY_MAJOR_VERSION < 3 && (__PYX_DEFAULT_STRING_ENCODING_IS_ASCII || __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT)
  if (__Pyx_init_sys_getdefaultencoding_params() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  #endif
  if (__pyx_module_is_main_btdht__krcp) {
    if (PyObject_SetAttr(__pyx_m, __pyx_n_s_name, __pyx_n_s_main) < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  }
  #if PY_MAJOR_VERSION >= 3
  {
    PyObject *modules = PyImport_GetModuleDict(); if (unlikely(!modules)) __PYX_ERR(0, 1, __pyx_L1_error)
    if (!PyDict_GetItemString(modules, "btdht.krcp")) {
      if (unlikely(PyDict_SetItemString(modules, "btdht.krcp", __pyx_m) < 0)) __PYX_ERR(0, 1, __pyx_L1_error)
    }
  }
  #endif
  /*--- Builtin init code ---*/
  if (__Pyx_InitCachedBuiltins() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  /*--- Constants init code ---*/
  if (__Pyx_InitCachedConstants() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  /*--- Global type/function init code ---*/
  (void)__Pyx_modinit_global_init_code();
  (void)__Pyx_modinit_variable_export_code();
  if (unlikely(__Pyx_modinit_function_export_code() < 0)) __PYX_ERR(0, 1, __pyx_L1_error)
  if (unlikely(__Pyx_modinit_type_init_code() < 0)) __PYX_ERR(0, 1, __pyx_L1_error)
  (void)__Pyx_modinit_type_import_code();
  (void)__Pyx_modinit_variable_import_code();
  (void)__Pyx_modinit_function_import_code();
  /*--- Execution code ---*/
  #if defined(__Pyx_Generator_USED) || defined(__Pyx_Coroutine_USED)
  if (__Pyx_patch_abc() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  #endif

  /* "btdht/krcp.pyx":12
 * #
 * # (c) 2015 Valentin Samir
 * import os             # <<<<<<<<<<<<<<
 * 
 * from libc cimport math
 */
  __pyx_t_1 = __Pyx_Import(__pyx_n_s_os, 0, -1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 12, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_os, __pyx_t_1) < 0) __PYX_ERR(0, 12, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "btdht/krcp.pyx":20
 * from cython.parallel import prange
 * 
 * import six             # <<<<<<<<<<<<<<
 * 
 * import utils
 */
  __pyx_t_1 = __Pyx_Import(__pyx_n_s_six, 0, -1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 20, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_six, __pyx_t_1) < 0) __PYX_ERR(0, 20, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "btdht/krcp.pyx":22
 * import six
 * 
 * import utils             # <<<<<<<<<<<<<<
 * from .exceptions import MissingT, DecodeError
 * 
 */
  __pyx_t_1 = __Pyx_Import(__pyx_n_s_utils, 0, -1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 22, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_utils, __pyx_t_1) < 0) __PYX_ERR(0, 22, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "btdht/krcp.pyx":23
 * 
 * import utils
 * from .exceptions import MissingT, DecodeError             # <<<<<<<<<<<<<<
 * 
 * cdef int str_to_int(char* data, int len) nogil:
 */
  __pyx_t_1 = PyList_New(2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 23, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_INCREF(__pyx_n_s_MissingT);
  __Pyx_GIVEREF(__pyx_n_s_MissingT);
  PyList_SET_ITEM(__pyx_t_1, 0, __pyx_n_s_MissingT);
  __Pyx_INCREF(__pyx_n_s_DecodeError);
  __Pyx_GIVEREF(__pyx_n_s_DecodeError);
  PyList_SET_ITEM(__pyx_t_1, 1, __pyx_n_s_DecodeError);
  __pyx_t_2 = __Pyx_Import(__pyx_n_s_exceptions, __pyx_t_1, 1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 23, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = __Pyx_ImportFrom(__pyx_t_2, __pyx_n_s_MissingT); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 23, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_MissingT, __pyx_t_1) < 0) __PYX_ERR(0, 23, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = __Pyx_ImportFrom(__pyx_t_2, __pyx_n_s_DecodeError); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 23, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_DecodeError, __pyx_t_1) < 0) __PYX_ERR(0, 23, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "btdht/krcp.pyx":369
 *         return False
 * 
 * class BError(Exception):             # <<<<<<<<<<<<<<
 *     """
 *         A base class exception for all bittorrent DHT protocol error exceptions
 */
  __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 369, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_INCREF(((PyObject *)(&((PyTypeObject*)PyExc_Exception)[0])));
  __Pyx_GIVEREF(((PyObject *)(&((PyTypeObject*)PyExc_Exception)[0])));
  PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)(&((PyTypeObject*)PyExc_Exception)[0])));
  __pyx_t_1 = __Pyx_CalculateMetaclass(NULL, __pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 369, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_3 = __Pyx_Py3MetaclassPrepare(__pyx_t_1, __pyx_t_2, __pyx_n_s_BError, __pyx_n_s_BError, (PyObject *) NULL, __pyx_n_s_btdht_krcp, __pyx_kp_s_A_base_class_exception_for_all); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 369, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);

  /* "btdht/krcp.pyx":377
 *     """
 *     #: The ``y`` key of the error message. For an error message, it is always ``b"e"``
 *     y = b"e"             # <<<<<<<<<<<<<<
 *     #: string value representing a transaction ID, must be set to the query transaction ID
 *     #: for which an error is raises.
 */
  if (__Pyx_SetNameInClass(__pyx_t_3, __pyx_n_s_y, __pyx_n_b_e) < 0) __PYX_ERR(0, 377, __pyx_L1_error)

  /* "btdht/krcp.pyx":380
 *     #: string value representing a transaction ID, must be set to the query transaction ID
 *     #: for which an error is raises.
 *     t = None             # <<<<<<<<<<<<<<
 *     # A list. The first element is an :class:`int` representing the error code.
 *     # The second element is a string containing the error message
 */
  if (__Pyx_SetNameInClass(__pyx_t_3, __pyx_n_s_t, Py_None) < 0) __PYX_ERR(0, 380, __pyx_L1_error)

  /* "btdht/krcp.pyx":383
 *     # A list. The first element is an :class:`int` representing the error code.
 *     # The second element is a string containing the error message
 *     e = None             # <<<<<<<<<<<<<<
 *     def __init__(self, t, e, **kwargs):
 *         if t is None:
 */
  if (__Pyx_SetNameInClass(__pyx_t_3, __pyx_n_s_e, Py_None) < 0) __PYX_ERR(0, 383, __pyx_L1_error)

  /* "btdht/krcp.pyx":384
 *     # The second element is a string containing the error message
 *     e = None
 *     def __init__(self, t, e, **kwargs):             # <<<<<<<<<<<<<<
 *         if t is None:
 *             raise ValueError("t should not be None")
 */
  __pyx_t_4 = __Pyx_CyFunction_New(&__pyx_mdef_5btdht_4krcp_6BError_1__init__, 0, __pyx_n_s_BError___init, NULL, __pyx_n_s_btdht_krcp, __pyx_d, ((PyObject *)__pyx_codeobj__8)); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 384, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  if (__Pyx_SetNameInClass(__pyx_t_3, __pyx_n_s_init, __pyx_t_4) < 0) __PYX_ERR(0, 384, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

  /* "btdht/krcp.pyx":391
 *         super(BError, self).__init__(*e, **kwargs)
 * 
 *     def encode(self):             # <<<<<<<<<<<<<<
 *         """
 *             Bencode the error message
 */
  __pyx_t_4 = __Pyx_CyFunction_New(&__pyx_mdef_5btdht_4krcp_6BError_3encode, 0, __pyx_n_s_BError_encode, NULL, __pyx_n_s_btdht_krcp, __pyx_d, ((PyObject *)__pyx_codeobj__10)); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 391, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  if (__Pyx_SetNameInClass(__pyx_t_3, __pyx_n_s_encode, __pyx_t_4) < 0) __PYX_ERR(0, 391, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

  /* "btdht/krcp.pyx":400
 *         return utils.bencode({b"y":self.y, b"t":self.t, b"e":self.e})
 * 
 *     def __str__(self):             # <<<<<<<<<<<<<<
 *         raise NotImplementedError()
 * 
 */
  __pyx_t_4 = __Pyx_CyFunction_New(&__pyx_mdef_5btdht_4krcp_6BError_5__str__, 0, __pyx_n_s_BError___str, NULL, __pyx_n_s_btdht_krcp, __pyx_d, ((PyObject *)__pyx_codeobj__12)); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 400, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  if (__Pyx_SetNameInClass(__pyx_t_3, __pyx_n_s_str, __pyx_t_4) < 0) __PYX_ERR(0, 400, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

  /* "btdht/krcp.pyx":403
 *         raise NotImplementedError()
 * 
 *     def __repr__(self):             # <<<<<<<<<<<<<<
 *         return "%s: %r" % (self.__class__.__name__, self.e)
 * 
 */
  __pyx_t_4 = __Pyx_CyFunction_New(&__pyx_mdef_5btdht_4krcp_6BError_7__repr__, 0, __pyx_n_s_BError___repr, NULL, __pyx_n_s_btdht_krcp, __pyx_d, ((PyObject *)__pyx_codeobj__14)); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 403, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  if (__Pyx_SetNameInClass(__pyx_t_3, __pyx_n_s_repr, __pyx_t_4) < 0) __PYX_ERR(0, 403, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

  /* "btdht/krcp.pyx":369
 *         return False
 * 
 * class BError(Exception):             # <<<<<<<<<<<<<<
 *     """
 *         A base class exception for all bittorrent DHT protocol error exceptions
 */
  __pyx_t_4 = __Pyx_Py3ClassCreate(__pyx_t_1, __pyx_n_s_BError, __pyx_t_2, __pyx_t_3, NULL, 0, 1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 369, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_BError, __pyx_t_4) < 0) __PYX_ERR(0, 369, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "btdht/krcp.pyx":406
 *         return "%s: %r" % (self.__class__.__name__, self.e)
 * 
 * class GenericError(BError):             # <<<<<<<<<<<<<<
 *     """
 *         A Generic Error, error code 201
 */
  __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_BError); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 406, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 406, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_2);
  PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_2);
  __pyx_t_2 = 0;
  __pyx_t_2 = __Pyx_CalculateMetaclass(NULL, __pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 406, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = __Pyx_Py3MetaclassPrepare(__pyx_t_2, __pyx_t_1, __pyx_n_s_GenericError, __pyx_n_s_GenericError, (PyObject *) NULL, __pyx_n_s_btdht_krcp, __pyx_kp_s_A_Generic_Error_error_code_201); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 406, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);

  /* "btdht/krcp.pyx":413
 *         :param bytes msg: An optionnal error message
 *     """
 *     def __init__(self, t, msg=b""):             # <<<<<<<<<<<<<<
 *         super(GenericError, self).__init__(t=t, e=[201, msg])
 * class ServerError(BError):
 */
  __pyx_t_4 = __Pyx_CyFunction_New(&__pyx_mdef_5btdht_4krcp_12GenericError_1__init__, 0, __pyx_n_s_GenericError___init, NULL, __pyx_n_s_btdht_krcp, __pyx_d, ((PyObject *)__pyx_codeobj__16)); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 413, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_CyFunction_SetDefaultsTuple(__pyx_t_4, __pyx_tuple__17);
  if (__Pyx_SetNameInClass(__pyx_t_3, __pyx_n_s_init, __pyx_t_4) < 0) __PYX_ERR(0, 413, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

  /* "btdht/krcp.pyx":406
 *         return "%s: %r" % (self.__class__.__name__, self.e)
 * 
 * class GenericError(BError):             # <<<<<<<<<<<<<<
 *     """
 *         A Generic Error, error code 201
 */
  __pyx_t_4 = __Pyx_Py3ClassCreate(__pyx_t_2, __pyx_n_s_GenericError, __pyx_t_1, __pyx_t_3, NULL, 0, 1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 406, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_GenericError, __pyx_t_4) < 0) __PYX_ERR(0, 406, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "btdht/krcp.pyx":415
 *     def __init__(self, t, msg=b""):
 *         super(GenericError, self).__init__(t=t, e=[201, msg])
 * class ServerError(BError):             # <<<<<<<<<<<<<<
 *     """
 *         A Server Error, error code 202
 */
  __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_BError); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 415, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 415, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_GIVEREF(__pyx_t_1);
  PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_1);
  __pyx_t_1 = 0;
  __pyx_t_1 = __Pyx_CalculateMetaclass(NULL, __pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 415, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_3 = __Pyx_Py3MetaclassPrepare(__pyx_t_1, __pyx_t_2, __pyx_n_s_ServerError, __pyx_n_s_ServerError, (PyObject *) NULL, __pyx_n_s_btdht_krcp, __pyx_kp_s_A_Server_Error_error_code_202_p); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 415, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);

  /* "btdht/krcp.pyx":422
 *         :param bytes msg: An optionnal error message
 *     """
 *     def __init__(self, t, msg=b"Server Error"):             # <<<<<<<<<<<<<<
 *         super(ServerError, self).__init__(t=t, e=[202, msg])
 * class ProtocolError(BError):
 */
  __pyx_t_4 = __Pyx_CyFunction_New(&__pyx_mdef_5btdht_4krcp_11ServerError_1__init__, 0, __pyx_n_s_ServerError___init, NULL, __pyx_n_s_btdht_krcp, __pyx_d, ((PyObject *)__pyx_codeobj__19)); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 422, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_CyFunction_SetDefaultsTuple(__pyx_t_4, __pyx_tuple__20);
  if (__Pyx_SetNameInClass(__pyx_t_3, __pyx_n_s_init, __pyx_t_4) < 0) __PYX_ERR(0, 422, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

  /* "btdht/krcp.pyx":415
 *     def __init__(self, t, msg=b""):
 *         super(GenericError, self).__init__(t=t, e=[201, msg])
 * class ServerError(BError):             # <<<<<<<<<<<<<<
 *     """
 *         A Server Error, error code 202
 */
  __pyx_t_4 = __Pyx_Py3ClassCreate(__pyx_t_1, __pyx_n_s_ServerError, __pyx_t_2, __pyx_t_3, NULL, 0, 1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 415, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_ServerError, __pyx_t_4) < 0) __PYX_ERR(0, 415, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "btdht/krcp.pyx":424
 *     def __init__(self, t, msg=b"Server Error"):
 *         super(ServerError, self).__init__(t=t, e=[202, msg])
 * class ProtocolError(BError):             # <<<<<<<<<<<<<<
 *     """
 *         A Protocol Error, such as a malformed packet, invalid arguments, or bad token,
 */
  __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_BError); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 424, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 424, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_2);
  PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_2);
  __pyx_t_2 = 0;
  __pyx_t_2 = __Pyx_CalculateMetaclass(NULL, __pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 424, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = __Pyx_Py3MetaclassPrepare(__pyx_t_2, __pyx_t_1, __pyx_n_s_ProtocolError, __pyx_n_s_ProtocolError, (PyObject *) NULL, __pyx_n_s_btdht_krcp, __pyx_kp_s_A_Protocol_Error_such_as_a_malf); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 424, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);

  /* "btdht/krcp.pyx":432
 *         :param bytes msg: An optionnal error message
 *     """
 *     def __init__(self, t, msg=b"Protocol Error"):             # <<<<<<<<<<<<<<
 *         super(ProtocolError, self).__init__(t=t, e=[203, msg])
 * class MethodUnknownError(BError):
 */
  __pyx_t_4 = __Pyx_CyFunction_New(&__pyx_mdef_5btdht_4krcp_13ProtocolError_1__init__, 0, __pyx_n_s_ProtocolError___init, NULL, __pyx_n_s_btdht_krcp, __pyx_d, ((PyObject *)__pyx_codeobj__22)); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 432, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_CyFunction_SetDefaultsTuple(__pyx_t_4, __pyx_tuple__23);
  if (__Pyx_SetNameInClass(__pyx_t_3, __pyx_n_s_init, __pyx_t_4) < 0) __PYX_ERR(0, 432, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

  /* "btdht/krcp.pyx":424
 *     def __init__(self, t, msg=b"Server Error"):
 *         super(ServerError, self).__init__(t=t, e=[202, msg])
 * class ProtocolError(BError):             # <<<<<<<<<<<<<<
 *     """
 *         A Protocol Error, such as a malformed packet, invalid arguments, or bad token,
 */
  __pyx_t_4 = __Pyx_Py3ClassCreate(__pyx_t_2, __pyx_n_s_ProtocolError, __pyx_t_1, __pyx_t_3, NULL, 0, 1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 424, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_ProtocolError, __pyx_t_4) < 0) __PYX_ERR(0, 424, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "btdht/krcp.pyx":434
 *     def __init__(self, t, msg=b"Protocol Error"):
 *         super(ProtocolError, self).__init__(t=t, e=[203, msg])
 * class MethodUnknownError(BError):             # <<<<<<<<<<<<<<
 *     """
 *         Method Unknown, error code 204
 */
  __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_BError); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 434, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 434, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_GIVEREF(__pyx_t_1);
  PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_1);
  __pyx_t_1 = 0;
  __pyx_t_1 = __Pyx_CalculateMetaclass(NULL, __pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 434, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_3 = __Pyx_Py3MetaclassPrepare(__pyx_t_1, __pyx_t_2, __pyx_n_s_MethodUnknownError, __pyx_n_s_MethodUnknownError, (PyObject *) NULL, __pyx_n_s_btdht_krcp, __pyx_kp_s_Method_Unknown_error_code_204_p); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 434, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);

  /* "btdht/krcp.pyx":441
 *         :param bytes msg: An optionnal error message
 *     """
 *     def __init__(self, t, msg=b"Method Unknow"):             # <<<<<<<<<<<<<<
 *         super(MethodUnknownError, self).__init__(t=t, e=[204, msg])
 * 
 */
  __pyx_t_4 = __Pyx_CyFunction_New(&__pyx_mdef_5btdht_4krcp_18MethodUnknownError_1__init__, 0, __pyx_n_s_MethodUnknownError___init, NULL, __pyx_n_s_btdht_krcp, __pyx_d, ((PyObject *)__pyx_codeobj__25)); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 441, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_CyFunction_SetDefaultsTuple(__pyx_t_4, __pyx_tuple__26);
  if (__Pyx_SetNameInClass(__pyx_t_3, __pyx_n_s_init, __pyx_t_4) < 0) __PYX_ERR(0, 441, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

  /* "btdht/krcp.pyx":434
 *     def __init__(self, t, msg=b"Protocol Error"):
 *         super(ProtocolError, self).__init__(t=t, e=[203, msg])
 * class MethodUnknownError(BError):             # <<<<<<<<<<<<<<
 *     """
 *         Method Unknown, error code 204
 */
  __pyx_t_4 = __Pyx_Py3ClassCreate(__pyx_t_1, __pyx_n_s_MethodUnknownError, __pyx_t_2, __pyx_t_3, NULL, 0, 1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 434, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_MethodUnknownError, __pyx_t_4) < 0) __PYX_ERR(0, 434, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "btdht/krcp.pyx":1
 * # -*- coding: utf-8 -*-             # <<<<<<<<<<<<<<
 * # This program is distributed in the hope that it will be useful, but WITHOUT
 * # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 */
  __pyx_t_2 = __Pyx_PyDict_NewPresized(0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_test, __pyx_t_2) < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /*--- Wrapped vars code ---*/

  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  if (__pyx_m) {
    if (__pyx_d) {
      __Pyx_AddTraceback("init btdht.krcp", __pyx_clineno, __pyx_lineno, __pyx_filename);
    }
    Py_CLEAR(__pyx_m);
  } else if (!PyErr_Occurred()) {
    PyErr_SetString(PyExc_ImportError, "init btdht.krcp");
  }
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  #if CYTHON_PEP489_MULTI_PHASE_INIT
  return (__pyx_m != NULL) ? 0 : -1;
  #elif PY_MAJOR_VERSION >= 3
  return __pyx_m;
  #else
  return;
  #endif
}

/* --- Runtime support code --- */
/* Refnanny */
#if CYTHON_REFNANNY
static __Pyx_RefNannyAPIStruct *__Pyx_RefNannyImportAPI(const char *modname) {
    PyObject *m = NULL, *p = NULL;
    void *r = NULL;
    m = PyImport_ImportModule(modname);
    if (!m) goto end;
    p = PyObject_GetAttrString(m, "RefNannyAPI");
    if (!p) goto end;
    r = PyLong_AsVoidPtr(p);
end:
    Py_XDECREF(p);
    Py_XDECREF(m);
    return (__Pyx_RefNannyAPIStruct *)r;
}
#endif

/* PyObjectGetAttrStr */
#if CYTHON_USE_TYPE_SLOTS
static CYTHON_INLINE PyObject* __Pyx_PyObject_GetAttrStr(PyObject* obj, PyObject* attr_name) {
    PyTypeObject* tp = Py_TYPE(obj);
    if (likely(tp->tp_getattro))
        return tp->tp_getattro(obj, attr_name);
#if PY_MAJOR_VERSION < 3
    if (likely(tp->tp_getattr))
        return tp->tp_getattr(obj, PyString_AS_STRING(attr_name));
#endif
    return PyObject_GetAttr(obj, attr_name);
}
#endif

/* GetBuiltinName */
static PyObject *__Pyx_GetBuiltinName(PyObject *name) {
    PyObject* result = __Pyx_PyObject_GetAttrStr(__pyx_b, name);
    if (unlikely(!result)) {
        PyErr_Format(PyExc_NameError,
#if PY_MAJOR_VERSION >= 3
            "name '%U' is not defined", name);
#else
            "name '%.200s' is not defined", PyString_AS_STRING(name));
#endif
    }
    return result;
}

/* PyCFunctionFastCall */
#if CYTHON_FAST_PYCCALL
static CYTHON_INLINE PyObject * __Pyx_PyCFunction_FastCall(PyObject *func_obj, PyObject **args, Py_ssize_t nargs) {
    PyCFunctionObject *func = (PyCFunctionObject*)func_obj;
    PyCFunction meth = PyCFunction_GET_FUNCTION(func);
    PyObject *self = PyCFunction_GET_SELF(func);
    int flags = PyCFunction_GET_FLAGS(func);
    assert(PyCFunction_Check(func));
    assert(METH_FASTCALL == (flags & ~(METH_CLASS | METH_STATIC | METH_COEXIST | METH_KEYWORDS | METH_STACKLESS)));
    assert(nargs >= 0);
    assert(nargs == 0 || args != NULL);
    /* _PyCFunction_FastCallDict() must not be called with an exception set,
       because it may clear it (directly or indirectly) and so the
       caller loses its exception */
    assert(!PyErr_Occurred());
    if ((PY_VERSION_HEX < 0x030700A0) || unlikely(flags & METH_KEYWORDS)) {
        return (*((__Pyx_PyCFunctionFastWithKeywords)(void*)meth)) (self, args, nargs, NULL);
    } else {
        return (*((__Pyx_PyCFunctionFast)(void*)meth)) (self, args, nargs);
    }
}
#endif

/* PyFunctionFastCall */
#if CYTHON_FAST_PYCALL
static PyObject* __Pyx_PyFunction_FastCallNoKw(PyCodeObject *co, PyObject **args, Py_ssize_t na,
                                               PyObject *globals) {
    PyFrameObject *f;
    PyThreadState *tstate = __Pyx_PyThreadState_Current;
    PyObject **fastlocals;
    Py_ssize_t i;
    PyObject *result;
    assert(globals != NULL);
    /* XXX Perhaps we should create a specialized
       PyFrame_New() that doesn't take locals, but does
       take builtins without sanity checking them.
       */
    assert(tstate != NULL);
    f = PyFrame_New(tstate, co, globals, NULL);
    if (f == NULL) {
        return NULL;
    }
    fastlocals = __Pyx_PyFrame_GetLocalsplus(f);
    for (i = 0; i < na; i++) {
        Py_INCREF(*args);
        fastlocals[i] = *args++;
    }
    result = PyEval_EvalFrameEx(f,0);
    ++tstate->recursion_depth;
    Py_DECREF(f);
    --tstate->recursion_depth;
    return result;
}
#if 1 || PY_VERSION_HEX < 0x030600B1
static PyObject *__Pyx_PyFunction_FastCallDict(PyObject *func, PyObject **args, Py_ssize_t nargs, PyObject *kwargs) {
    PyCodeObject *co = (PyCodeObject *)PyFunction_GET_CODE(func);
    PyObject *globals = PyFunction_GET_GLOBALS(func);
    PyObject *argdefs = PyFunction_GET_DEFAULTS(func);
    PyObject *closure;
#if PY_MAJOR_VERSION >= 3
    PyObject *kwdefs;
#endif
    PyObject *kwtuple, **k;
    PyObject **d;
    Py_ssize_t nd;
    Py_ssize_t nk;
    PyObject *result;
    assert(kwargs == NULL || PyDict_Check(kwargs));
    nk = kwargs ? PyDict_Size(kwargs) : 0;
    if (Py_EnterRecursiveCall((char*)" while calling a Python object")) {
        return NULL;
    }
    if (
#if PY_MAJOR_VERSION >= 3
            co->co_kwonlyargcount == 0 &&
#endif
            likely(kwargs == NULL || nk == 0) &&
            co->co_flags == (CO_OPTIMIZED | CO_NEWLOCALS | CO_NOFREE)) {
        if (argdefs == NULL && co->co_argcount == nargs) {
            result = __Pyx_PyFunction_FastCallNoKw(co, args, nargs, globals);
            goto done;
        }
        else if (nargs == 0 && argdefs != NULL
                 && co->co_argcount == Py_SIZE(argdefs)) {
            /* function called with no arguments, but all parameters have
               a default value: use default values as arguments .*/
            args = &PyTuple_GET_ITEM(argdefs, 0);
            result =__Pyx_PyFunction_FastCallNoKw(co, args, Py_SIZE(argdefs), globals);
            goto done;
        }
    }
    if (kwargs != NULL) {
        Py_ssize_t pos, i;
        kwtuple = PyTuple_New(2 * nk);
        if (kwtuple == NULL) {
            result = NULL;
            goto done;
        }
        k = &PyTuple_GET_ITEM(kwtuple, 0);
        pos = i = 0;
        while (PyDict_Next(kwargs, &pos, &k[i], &k[i+1])) {
            Py_INCREF(k[i]);
            Py_INCREF(k[i+1]);
            i += 2;
        }
        nk = i / 2;
    }
    else {
        kwtuple = NULL;
        k = NULL;
    }
    closure = PyFunction_GET_CLOSURE(func);
#if PY_MAJOR_VERSION >= 3
    kwdefs = PyFunction_GET_KW_DEFAULTS(func);
#endif
    if (argdefs != NULL) {
        d = &PyTuple_GET_ITEM(argdefs, 0);
        nd = Py_SIZE(argdefs);
    }
    else {
        d = NULL;
        nd = 0;
    }
#if PY_MAJOR_VERSION >= 3
    result = PyEval_EvalCodeEx((PyObject*)co, globals, (PyObject *)NULL,
                               args, (int)nargs,
                               k, (int)nk,
                               d, (int)nd, kwdefs, closure);
#else
    result = PyEval_EvalCodeEx(co, globals, (PyObject *)NULL,
                               args, (int)nargs,
                               k, (int)nk,
                               d, (int)nd, closure);
#endif
    Py_XDECREF(kwtuple);
done:
    Py_LeaveRecursiveCall();
    return result;
}
#endif
#endif

/* PyObjectCall */
#if CYTHON_COMPILING_IN_CPYTHON
static CYTHON_INLINE PyObject* __Pyx_PyObject_Call(PyObject *func, PyObject *arg, PyObject *kw) {
    PyObject *result;
    ternaryfunc call = Py_TYPE(func)->tp_call;
    if (unlikely(!call))
        return PyObject_Call(func, arg, kw);
    if (unlikely(Py_EnterRecursiveCall((char*)" while calling a Python object")))
        return NULL;
    result = (*call)(func, arg, kw);
    Py_LeaveRecursiveCall();
    if (unlikely(!result) && unlikely(!PyErr_Occurred())) {
        PyErr_SetString(
            PyExc_SystemError,
            "NULL result without error in PyObject_Call");
    }
    return result;
}
#endif

/* PyObjectCallMethO */
#if CYTHON_COMPILING_IN_CPYTHON
static CYTHON_INLINE PyObject* __Pyx_PyObject_CallMethO(PyObject *func, PyObject *arg) {
    PyObject *self, *result;
    PyCFunction cfunc;
    cfunc = PyCFunction_GET_FUNCTION(func);
    self = PyCFunction_GET_SELF(func);
    if (unlikely(Py_EnterRecursiveCall((char*)" while calling a Python object")))
        return NULL;
    result = cfunc(self, arg);
    Py_LeaveRecursiveCall();
    if (unlikely(!result) && unlikely(!PyErr_Occurred())) {
        PyErr_SetString(
            PyExc_SystemError,
            "NULL result without error in PyObject_Call");
    }
    return result;
}
#endif

/* PyObjectCallOneArg */
#if CYTHON_COMPILING_IN_CPYTHON
static PyObject* __Pyx__PyObject_CallOneArg(PyObject *func, PyObject *arg) {
    PyObject *result;
    PyObject *args = PyTuple_New(1);
    if (unlikely(!args)) return NULL;
    Py_INCREF(arg);
    PyTuple_SET_ITEM(args, 0, arg);
    result = __Pyx_PyObject_Call(func, args, NULL);
    Py_DECREF(args);
    return result;
}
static CYTHON_INLINE PyObject* __Pyx_PyObject_CallOneArg(PyObject *func, PyObject *arg) {
#if CYTHON_FAST_PYCALL
    if (PyFunction_Check(func)) {
        return __Pyx_PyFunction_FastCall(func, &arg, 1);
    }
#endif
    if (likely(PyCFunction_Check(func))) {
        if (likely(PyCFunction_GET_FLAGS(func) & METH_O)) {
            return __Pyx_PyObject_CallMethO(func, arg);
#if CYTHON_FAST_PYCCALL
        } else if (__Pyx_PyFastCFunction_Check(func)) {
            return __Pyx_PyCFunction_FastCall(func, &arg, 1);
#endif
        }
    }
    return __Pyx__PyObject_CallOneArg(func, arg);
}
#else
static CYTHON_INLINE PyObject* __Pyx_PyObject_CallOneArg(PyObject *func, PyObject *arg) {
    PyObject *result;
    PyObject *args = PyTuple_Pack(1, arg);
    if (unlikely(!args)) return NULL;
    result = __Pyx_PyObject_Call(func, args, NULL);
    Py_DECREF(args);
    return result;
}
#endif

/* PyErrFetchRestore */
#if CYTHON_FAST_THREAD_STATE
static CYTHON_INLINE void __Pyx_ErrRestoreInState(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb) {
    PyObject *tmp_type, *tmp_value, *tmp_tb;
    tmp_type = tstate->curexc_type;
    tmp_value = tstate->curexc_value;
    tmp_tb = tstate->curexc_traceback;
    tstate->curexc_type = type;
    tstate->curexc_value = value;
    tstate->curexc_traceback = tb;
    Py_XDECREF(tmp_type);
    Py_XDECREF(tmp_value);
    Py_XDECREF(tmp_tb);
}
static CYTHON_INLINE void __Pyx_ErrFetchInState(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb) {
    *type = tstate->curexc_type;
    *value = tstate->curexc_value;
    *tb = tstate->curexc_traceback;
    tstate->curexc_type = 0;
    tstate->curexc_value = 0;
    tstate->curexc_traceback = 0;
}
#endif

/* RaiseException */
#if PY_MAJOR_VERSION < 3
static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb,
                        CYTHON_UNUSED PyObject *cause) {
    __Pyx_PyThreadState_declare
    Py_XINCREF(type);
    if (!value || value == Py_None)
        value = NULL;
    else
        Py_INCREF(value);
    if (!tb || tb == Py_None)
        tb = NULL;
    else {
        Py_INCREF(tb);
        if (!PyTraceBack_Check(tb)) {
            PyErr_SetString(PyExc_TypeError,
                "raise: arg 3 must be a traceback or None");
            goto raise_error;
        }
    }
    if (PyType_Check(type)) {
#if CYTHON_COMPILING_IN_PYPY
        if (!value) {
            Py_INCREF(Py_None);
            value = Py_None;
        }
#endif
        PyErr_NormalizeException(&type, &value, &tb);
    } else {
        if (value) {
            PyErr_SetString(PyExc_TypeError,
                "instance exception may not have a separate value");
            goto raise_error;
        }
        value = type;
        type = (PyObject*) Py_TYPE(type);
        Py_INCREF(type);
        if (!PyType_IsSubtype((PyTypeObject *)type, (PyTypeObject *)PyExc_BaseException)) {
            PyErr_SetString(PyExc_TypeError,
                "raise: exception class must be a subclass of BaseException");
            goto raise_error;
        }
    }
    __Pyx_PyThreadState_assign
    __Pyx_ErrRestore(type, value, tb);
    return;
raise_error:
    Py_XDECREF(value);
    Py_XDECREF(type);
    Py_XDECREF(tb);
    return;
}
#else
static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, PyObject *cause) {
    PyObject* owned_instance = NULL;
    if (tb == Py_None) {
        tb = 0;
    } else if (tb && !PyTraceBack_Check(tb)) {
        PyErr_SetString(PyExc_TypeError,
            "raise: arg 3 must be a traceback or None");
        goto bad;
    }
    if (value == Py_None)
        value = 0;
    if (PyExceptionInstance_Check(type)) {
        if (value) {
            PyErr_SetString(PyExc_TypeError,
                "instance exception may not have a separate value");
            goto bad;
        }
        value = type;
        type = (PyObject*) Py_TYPE(value);
    } else if (PyExceptionClass_Check(type)) {
        PyObject *instance_class = NULL;
        if (value && PyExceptionInstance_Check(value)) {
            instance_class = (PyObject*) Py_TYPE(value);
            if (instance_class != type) {
                int is_subclass = PyObject_IsSubclass(instance_class, type);
                if (!is_subclass) {
                    instance_class = NULL;
                } else if (unlikely(is_subclass == -1)) {
                    goto bad;
                } else {
                    type = instance_class;
                }
            }
        }
        if (!instance_class) {
            PyObject *args;
            if (!value)
                args = PyTuple_New(0);
            else if (PyTuple_Check(value)) {
                Py_INCREF(value);
                args = value;
            } else
                args = PyTuple_Pack(1, value);
            if (!args)
                goto bad;
            owned_instance = PyObject_Call(type, args, NULL);
            Py_DECREF(args);
            if (!owned_instance)
                goto bad;
            value = owned_instance;
            if (!PyExceptionInstance_Check(value)) {
                PyErr_Format(PyExc_TypeError,
                             "calling %R should have returned an instance of "
                             "BaseException, not %R",
                             type, Py_TYPE(value));
                goto bad;
            }
        }
    } else {
        PyErr_SetString(PyExc_TypeError,
            "raise: exception class must be a subclass of BaseException");
        goto bad;
    }
    if (cause) {
        PyObject *fixed_cause;
        if (cause == Py_None) {
            fixed_cause = NULL;
        } else if (PyExceptionClass_Check(cause)) {
            fixed_cause = PyObject_CallObject(cause, NULL);
            if (fixed_cause == NULL)
                goto bad;
        } else if (PyExceptionInstance_Check(cause)) {
            fixed_cause = cause;
            Py_INCREF(fixed_cause);
        } else {
            PyErr_SetString(PyExc_TypeError,
                            "exception causes must derive from "
                            "BaseException");
            goto bad;
        }
        PyException_SetCause(value, fixed_cause);
    }
    PyErr_SetObject(type, value);
    if (tb) {
#if CYTHON_COMPILING_IN_PYPY
        PyObject *tmp_type, *tmp_value, *tmp_tb;
        PyErr_Fetch(&tmp_type, &tmp_value, &tmp_tb);
        Py_INCREF(tb);
        PyErr_Restore(tmp_type, tmp_value, tb);
        Py_XDECREF(tmp_tb);
#else
        PyThreadState *tstate = __Pyx_PyThreadState_Current;
        PyObject* tmp_tb = tstate->curexc_traceback;
        if (tb != tmp_tb) {
            Py_INCREF(tb);
            tstate->curexc_traceback = tb;
            Py_XDECREF(tmp_tb);
        }
#endif
    }
bad:
    Py_XDECREF(owned_instance);
    return;
}
#endif

/* WriteUnraisableException */
static void __Pyx_WriteUnraisable(const char *name, CYTHON_UNUSED int clineno,
                                  CYTHON_UNUSED int lineno, CYTHON_UNUSED const char *filename,
                                  int full_traceback, CYTHON_UNUSED int nogil) {
    PyObject *old_exc, *old_val, *old_tb;
    PyObject *ctx;
    __Pyx_PyThreadState_declare
#ifdef WITH_THREAD
    PyGILState_STATE state;
    if (nogil)
        state = PyGILState_Ensure();
#ifdef _MSC_VER
    else state = (PyGILState_STATE)-1;
#endif
#endif
    __Pyx_PyThreadState_assign
    __Pyx_ErrFetch(&old_exc, &old_val, &old_tb);
    if (full_traceback) {
        Py_XINCREF(old_exc);
        Py_XINCREF(old_val);
        Py_XINCREF(old_tb);
        __Pyx_ErrRestore(old_exc, old_val, old_tb);
        PyErr_PrintEx(1);
    }
    #if PY_MAJOR_VERSION < 3
    ctx = PyString_FromString(name);
    #else
    ctx = PyUnicode_FromString(name);
    #endif
    __Pyx_ErrRestore(old_exc, old_val, old_tb);
    if (!ctx) {
        PyErr_WriteUnraisable(Py_None);
    } else {
        PyErr_WriteUnraisable(ctx);
        Py_DECREF(ctx);
    }
#ifdef WITH_THREAD
    if (nogil)
        PyGILState_Release(state);
#endif
}

/* GetItemInt */
static PyObject *__Pyx_GetItemInt_Generic(PyObject *o, PyObject* j) {
    PyObject *r;
    if (!j) return NULL;
    r = PyObject_GetItem(o, j);
    Py_DECREF(j);
    return r;
}
static CYTHON_INLINE PyObject *__Pyx_GetItemInt_List_Fast(PyObject *o, Py_ssize_t i,
                                                              CYTHON_NCP_UNUSED int wraparound,
                                                              CYTHON_NCP_UNUSED int boundscheck) {
#if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
    Py_ssize_t wrapped_i = i;
    if (wraparound & unlikely(i < 0)) {
        wrapped_i += PyList_GET_SIZE(o);
    }
    if ((!boundscheck) || likely(__Pyx_is_valid_index(wrapped_i, PyList_GET_SIZE(o)))) {
        PyObject *r = PyList_GET_ITEM(o, wrapped_i);
        Py_INCREF(r);
        return r;
    }
    return __Pyx_GetItemInt_Generic(o, PyInt_FromSsize_t(i));
#else
    return PySequence_GetItem(o, i);
#endif
}
static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Tuple_Fast(PyObject *o, Py_ssize_t i,
                                                              CYTHON_NCP_UNUSED int wraparound,
                                                              CYTHON_NCP_UNUSED int boundscheck) {
#if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
    Py_ssize_t wrapped_i = i;
    if (wraparound & unlikely(i < 0)) {
        wrapped_i += PyTuple_GET_SIZE(o);
    }
    if ((!boundscheck) || likely(__Pyx_is_valid_index(wrapped_i, PyTuple_GET_SIZE(o)))) {
        PyObject *r = PyTuple_GET_ITEM(o, wrapped_i);
        Py_INCREF(r);
        return r;
    }
    return __Pyx_GetItemInt_Generic(o, PyInt_FromSsize_t(i));
#else
    return PySequence_GetItem(o, i);
#endif
}
static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Fast(PyObject *o, Py_ssize_t i, int is_list,
                                                     CYTHON_NCP_UNUSED int wraparound,
                                                     CYTHON_NCP_UNUSED int boundscheck) {
#if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS && CYTHON_USE_TYPE_SLOTS
    if (is_list || PyList_CheckExact(o)) {
        Py_ssize_t n = ((!wraparound) | likely(i >= 0)) ? i : i + PyList_GET_SIZE(o);
        if ((!boundscheck) || (likely(__Pyx_is_valid_index(n, PyList_GET_SIZE(o))))) {
            PyObject *r = PyList_GET_ITEM(o, n);
            Py_INCREF(r);
            return r;
        }
    }
    else if (PyTuple_CheckExact(o)) {
        Py_ssize_t n = ((!wraparound) | likely(i >= 0)) ? i : i + PyTuple_GET_SIZE(o);
        if ((!boundscheck) || likely(__Pyx_is_valid_index(n, PyTuple_GET_SIZE(o)))) {
            PyObject *r = PyTuple_GET_ITEM(o, n);
            Py_INCREF(r);
            return r;
        }
    } else {
        PySequenceMethods *m = Py_TYPE(o)->tp_as_sequence;
        if (likely(m && m->sq_item)) {
            if (wraparound && unlikely(i < 0) && likely(m->sq_length)) {
                Py_ssize_t l = m->sq_length(o);
                if (likely(l >= 0)) {
                    i += l;
                } else {
                    if (!PyErr_ExceptionMatches(PyExc_OverflowError))
                        return NULL;
                    PyErr_Clear();
                }
            }
            return m->sq_item(o, i);
        }
    }
#else
    if (is_list || PySequence_Check(o)) {
        return PySequence_GetItem(o, i);
    }
#endif
    return __Pyx_GetItemInt_Generic(o, PyInt_FromSsize_t(i));
}

/* PyDictVersioning */
#if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_TYPE_SLOTS
static CYTHON_INLINE PY_UINT64_T __Pyx_get_tp_dict_version(PyObject *obj) {
    PyObject *dict = Py_TYPE(obj)->tp_dict;
    return likely(dict) ? __PYX_GET_DICT_VERSION(dict) : 0;
}
static CYTHON_INLINE PY_UINT64_T __Pyx_get_object_dict_version(PyObject *obj) {
    PyObject **dictptr = NULL;
    Py_ssize_t offset = Py_TYPE(obj)->tp_dictoffset;
    if (offset) {
#if CYTHON_COMPILING_IN_CPYTHON
        dictptr = (likely(offset > 0)) ? (PyObject **) ((char *)obj + offset) : _PyObject_GetDictPtr(obj);
#else
        dictptr = _PyObject_GetDictPtr(obj);
#endif
    }
    return (dictptr && *dictptr) ? __PYX_GET_DICT_VERSION(*dictptr) : 0;
}
static CYTHON_INLINE int __Pyx_object_dict_version_matches(PyObject* obj, PY_UINT64_T tp_dict_version, PY_UINT64_T obj_dict_version) {
    PyObject *dict = Py_TYPE(obj)->tp_dict;
    if (unlikely(!dict) || unlikely(tp_dict_version != __PYX_GET_DICT_VERSION(dict)))
        return 0;
    return obj_dict_version == __Pyx_get_object_dict_version(obj);
}
#endif

/* GetModuleGlobalName */
#if CYTHON_USE_DICT_VERSIONS
static PyObject *__Pyx__GetModuleGlobalName(PyObject *name, PY_UINT64_T *dict_version, PyObject **dict_cached_value)
#else
static CYTHON_INLINE PyObject *__Pyx__GetModuleGlobalName(PyObject *name)
#endif
{
    PyObject *result;
#if !CYTHON_AVOID_BORROWED_REFS
#if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030500A1
    result = _PyDict_GetItem_KnownHash(__pyx_d, name, ((PyASCIIObject *) name)->hash);
    __PYX_UPDATE_DICT_CACHE(__pyx_d, result, *dict_cached_value, *dict_version)
    if (likely(result)) {
        return __Pyx_NewRef(result);
    } else if (unlikely(PyErr_Occurred())) {
        return NULL;
    }
#else
    result = PyDict_GetItem(__pyx_d, name);
    __PYX_UPDATE_DICT_CACHE(__pyx_d, result, *dict_cached_value, *dict_version)
    if (likely(result)) {
        return __Pyx_NewRef(result);
    }
#endif
#else
    result = PyObject_GetItem(__pyx_d, name);
    __PYX_UPDATE_DICT_CACHE(__pyx_d, result, *dict_cached_value, *dict_version)
    if (likely(result)) {
        return __Pyx_NewRef(result);
    }
    PyErr_Clear();
#endif
    return __Pyx_GetBuiltinName(name);
}

/* PyObjectCall2Args */
static CYTHON_UNUSED PyObject* __Pyx_PyObject_Call2Args(PyObject* function, PyObject* arg1, PyObject* arg2) {
    PyObject *args, *result = NULL;
    #if CYTHON_FAST_PYCALL
    if (PyFunction_Check(function)) {
        PyObject *args[2] = {arg1, arg2};
        return __Pyx_PyFunction_FastCall(function, args, 2);
    }
    #endif
    #if CYTHON_FAST_PYCCALL
    if (__Pyx_PyFastCFunction_Check(function)) {
        PyObject *args[2] = {arg1, arg2};
        return __Pyx_PyCFunction_FastCall(function, args, 2);
    }
    #endif
    args = PyTuple_New(2);
    if (unlikely(!args)) goto done;
    Py_INCREF(arg1);
    PyTuple_SET_ITEM(args, 0, arg1);
    Py_INCREF(arg2);
    PyTuple_SET_ITEM(args, 1, arg2);
    Py_INCREF(function);
    result = __Pyx_PyObject_Call(function, args, NULL);
    Py_DECREF(args);
    Py_DECREF(function);
done:
    return result;
}

/* RaiseArgTupleInvalid */
static void __Pyx_RaiseArgtupleInvalid(
    const char* func_name,
    int exact,
    Py_ssize_t num_min,
    Py_ssize_t num_max,
    Py_ssize_t num_found)
{
    Py_ssize_t num_expected;
    const char *more_or_less;
    if (num_found < num_min) {
        num_expected = num_min;
        more_or_less = "at least";
    } else {
        num_expected = num_max;
        more_or_less = "at most";
    }
    if (exact) {
        more_or_less = "exactly";
    }
    PyErr_Format(PyExc_TypeError,
                 "%.200s() takes %.8s %" CYTHON_FORMAT_SSIZE_T "d positional argument%.1s (%" CYTHON_FORMAT_SSIZE_T "d given)",
                 func_name, more_or_less, num_expected,
                 (num_expected == 1) ? "" : "s", num_found);
}

/* RaiseDoubleKeywords */
static void __Pyx_RaiseDoubleKeywordsError(
    const char* func_name,
    PyObject* kw_name)
{
    PyErr_Format(PyExc_TypeError,
        #if PY_MAJOR_VERSION >= 3
        "%s() got multiple values for keyword argument '%U'", func_name, kw_name);
        #else
        "%s() got multiple values for keyword argument '%s'", func_name,
        PyString_AsString(kw_name));
        #endif
}

/* ParseKeywords */
static int __Pyx_ParseOptionalKeywords(
    PyObject *kwds,
    PyObject **argnames[],
    PyObject *kwds2,
    PyObject *values[],
    Py_ssize_t num_pos_args,
    const char* function_name)
{
    PyObject *key = 0, *value = 0;
    Py_ssize_t pos = 0;
    PyObject*** name;
    PyObject*** first_kw_arg = argnames + num_pos_args;
    while (PyDict_Next(kwds, &pos, &key, &value)) {
        name = first_kw_arg;
        while (*name && (**name != key)) name++;
        if (*name) {
            values[name-argnames] = value;
            continue;
        }
        name = first_kw_arg;
        #if PY_MAJOR_VERSION < 3
        if (likely(PyString_Check(key))) {
            while (*name) {
                if ((CYTHON_COMPILING_IN_PYPY || PyString_GET_SIZE(**name) == PyString_GET_SIZE(key))
                        && _PyString_Eq(**name, key)) {
                    values[name-argnames] = value;
                    break;
                }
                name++;
            }
            if (*name) continue;
            else {
                PyObject*** argname = argnames;
                while (argname != first_kw_arg) {
                    if ((**argname == key) || (
                            (CYTHON_COMPILING_IN_PYPY || PyString_GET_SIZE(**argname) == PyString_GET_SIZE(key))
                             && _PyString_Eq(**argname, key))) {
                        goto arg_passed_twice;
                    }
                    argname++;
                }
            }
        } else
        #endif
        if (likely(PyUnicode_Check(key))) {
            while (*name) {
                int cmp = (**name == key) ? 0 :
                #if !CYTHON_COMPILING_IN_PYPY && PY_MAJOR_VERSION >= 3
                    (__Pyx_PyUnicode_GET_LENGTH(**name) != __Pyx_PyUnicode_GET_LENGTH(key)) ? 1 :
                #endif
                    PyUnicode_Compare(**name, key);
                if (cmp < 0 && unlikely(PyErr_Occurred())) goto bad;
                if (cmp == 0) {
                    values[name-argnames] = value;
                    break;
                }
                name++;
            }
            if (*name) continue;
            else {
                PyObject*** argname = argnames;
                while (argname != first_kw_arg) {
                    int cmp = (**argname == key) ? 0 :
                    #if !CYTHON_COMPILING_IN_PYPY && PY_MAJOR_VERSION >= 3
                        (__Pyx_PyUnicode_GET_LENGTH(**argname) != __Pyx_PyUnicode_GET_LENGTH(key)) ? 1 :
                    #endif
                        PyUnicode_Compare(**argname, key);
                    if (cmp < 0 && unlikely(PyErr_Occurred())) goto bad;
                    if (cmp == 0) goto arg_passed_twice;
                    argname++;
                }
            }
        } else
            goto invalid_keyword_type;
        if (kwds2) {
            if (unlikely(PyDict_SetItem(kwds2, key, value))) goto bad;
        } else {
            goto invalid_keyword;
        }
    }
    return 0;
arg_passed_twice:
    __Pyx_RaiseDoubleKeywordsError(function_name, key);
    goto bad;
invalid_keyword_type:
    PyErr_Format(PyExc_TypeError,
        "%.200s() keywords must be strings", function_name);
    goto bad;
invalid_keyword:
    PyErr_Format(PyExc_TypeError,
    #if PY_MAJOR_VERSION < 3
        "%.200s() got an unexpected keyword argument '%.200s'",
        function_name, PyString_AsString(key));
    #else
        "%s() got an unexpected keyword argument '%U'",
        function_name, key);
    #endif
bad:
    return -1;
}

/* PyObjectSetAttrStr */
#if CYTHON_USE_TYPE_SLOTS
static CYTHON_INLINE int __Pyx_PyObject_SetAttrStr(PyObject* obj, PyObject* attr_name, PyObject* value) {
    PyTypeObject* tp = Py_TYPE(obj);
    if (likely(tp->tp_setattro))
        return tp->tp_setattro(obj, attr_name, value);
#if PY_MAJOR_VERSION < 3
    if (likely(tp->tp_setattr))
        return tp->tp_setattr(obj, PyString_AS_STRING(attr_name), value);
#endif
    return PyObject_SetAttr(obj, attr_name, value);
}
#endif

/* PyObjectCallNoArg */
#if CYTHON_COMPILING_IN_CPYTHON
static CYTHON_INLINE PyObject* __Pyx_PyObject_CallNoArg(PyObject *func) {
#if CYTHON_FAST_PYCALL
    if (PyFunction_Check(func)) {
        return __Pyx_PyFunction_FastCall(func, NULL, 0);
    }
#endif
#ifdef __Pyx_CyFunction_USED
    if (likely(PyCFunction_Check(func) || __Pyx_CyFunction_Check(func)))
#else
    if (likely(PyCFunction_Check(func)))
#endif
    {
        if (likely(PyCFunction_GET_FLAGS(func) & METH_NOARGS)) {
            return __Pyx_PyObject_CallMethO(func, NULL);
        }
    }
    return __Pyx_PyObject_Call(func, __pyx_empty_tuple, NULL);
}
#endif

/* ObjectGetItem */
#if CYTHON_USE_TYPE_SLOTS
static PyObject *__Pyx_PyObject_GetIndex(PyObject *obj, PyObject* index) {
    PyObject *runerr;
    Py_ssize_t key_value;
    PySequenceMethods *m = Py_TYPE(obj)->tp_as_sequence;
    if (unlikely(!(m && m->sq_item))) {
        PyErr_Format(PyExc_TypeError, "'%.200s' object is not subscriptable", Py_TYPE(obj)->tp_name);
        return NULL;
    }
    key_value = __Pyx_PyIndex_AsSsize_t(index);
    if (likely(key_value != -1 || !(runerr = PyErr_Occurred()))) {
        return __Pyx_GetItemInt_Fast(obj, key_value, 0, 1, 1);
    }
    if (PyErr_GivenExceptionMatches(runerr, PyExc_OverflowError)) {
        PyErr_Clear();
        PyErr_Format(PyExc_IndexError, "cannot fit '%.200s' into an index-sized integer", Py_TYPE(index)->tp_name);
    }
    return NULL;
}
static PyObject *__Pyx_PyObject_GetItem(PyObject *obj, PyObject* key) {
    PyMappingMethods *m = Py_TYPE(obj)->tp_as_mapping;
    if (likely(m && m->mp_subscript)) {
        return m->mp_subscript(obj, key);
    }
    return __Pyx_PyObject_GetIndex(obj, key);
}
#endif

/* BytesEquals */
static CYTHON_INLINE int __Pyx_PyBytes_Equals(PyObject* s1, PyObject* s2, int equals) {
#if CYTHON_COMPILING_IN_PYPY
    return PyObject_RichCompareBool(s1, s2, equals);
#else
    if (s1 == s2) {
        return (equals == Py_EQ);
    } else if (PyBytes_CheckExact(s1) & PyBytes_CheckExact(s2)) {
        const char *ps1, *ps2;
        Py_ssize_t length = PyBytes_GET_SIZE(s1);
        if (length != PyBytes_GET_SIZE(s2))
            return (equals == Py_NE);
        ps1 = PyBytes_AS_STRING(s1);
        ps2 = PyBytes_AS_STRING(s2);
        if (ps1[0] != ps2[0]) {
            return (equals == Py_NE);
        } else if (length == 1) {
            return (equals == Py_EQ);
        } else {
            int result;
#if CYTHON_USE_UNICODE_INTERNALS && (PY_VERSION_HEX < 0x030B0000)
            Py_hash_t hash1, hash2;
            hash1 = ((PyBytesObject*)s1)->ob_shash;
            hash2 = ((PyBytesObject*)s2)->ob_shash;
            if (hash1 != hash2 && hash1 != -1 && hash2 != -1) {
                return (equals == Py_NE);
            }
#endif
            result = memcmp(ps1, ps2, (size_t)length);
            return (equals == Py_EQ) ? (result == 0) : (result != 0);
        }
    } else if ((s1 == Py_None) & PyBytes_CheckExact(s2)) {
        return (equals == Py_NE);
    } else if ((s2 == Py_None) & PyBytes_CheckExact(s1)) {
        return (equals == Py_NE);
    } else {
        int result;
        PyObject* py_result = PyObject_RichCompare(s1, s2, equals);
        if (!py_result)
            return -1;
        result = __Pyx_PyObject_IsTrue(py_result);
        Py_DECREF(py_result);
        return result;
    }
#endif
}

/* GetTopmostException */
#if CYTHON_USE_EXC_INFO_STACK
static _PyErr_StackItem *
__Pyx_PyErr_GetTopmostException(PyThreadState *tstate)
{
    _PyErr_StackItem *exc_info = tstate->exc_info;
    while ((exc_info->exc_type == NULL || exc_info->exc_type == Py_None) &&
           exc_info->previous_item != NULL)
    {
        exc_info = exc_info->previous_item;
    }
    return exc_info;
}
#endif

/* SaveResetException */
#if CYTHON_FAST_THREAD_STATE
static CYTHON_INLINE void __Pyx__ExceptionSave(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb) {
    #if CYTHON_USE_EXC_INFO_STACK
    _PyErr_StackItem *exc_info = __Pyx_PyErr_GetTopmostException(tstate);
    *type = exc_info->exc_type;
    *value = exc_info->exc_value;
    *tb = exc_info->exc_traceback;
    #else
    *type = tstate->exc_type;
    *value = tstate->exc_value;
    *tb = tstate->exc_traceback;
    #endif
    Py_XINCREF(*type);
    Py_XINCREF(*value);
    Py_XINCREF(*tb);
}
static CYTHON_INLINE void __Pyx__ExceptionReset(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb) {
    PyObject *tmp_type, *tmp_value, *tmp_tb;
    #if CYTHON_USE_EXC_INFO_STACK
    _PyErr_StackItem *exc_info = tstate->exc_info;
    tmp_type = exc_info->exc_type;
    tmp_value = exc_info->exc_value;
    tmp_tb = exc_info->exc_traceback;
    exc_info->exc_type = type;
    exc_info->exc_value = value;
    exc_info->exc_traceback = tb;
    #else
    tmp_type = tstate->exc_type;
    tmp_value = tstate->exc_value;
    tmp_tb = tstate->exc_traceback;
    tstate->exc_type = type;
    tstate->exc_value = value;
    tstate->exc_traceback = tb;
    #endif
    Py_XDECREF(tmp_type);
    Py_XDECREF(tmp_value);
    Py_XDECREF(tmp_tb);
}
#endif

/* PyErrExceptionMatches */
#if CYTHON_FAST_THREAD_STATE
static int __Pyx_PyErr_ExceptionMatchesTuple(PyObject *exc_type, PyObject *tuple) {
    Py_ssize_t i, n;
    n = PyTuple_GET_SIZE(tuple);
#if PY_MAJOR_VERSION >= 3
    for (i=0; i<n; i++) {
        if (exc_type == PyTuple_GET_ITEM(tuple, i)) return 1;
    }
#endif
    for (i=0; i<n; i++) {
        if (__Pyx_PyErr_GivenExceptionMatches(exc_type, PyTuple_GET_ITEM(tuple, i))) return 1;
    }
    return 0;
}
static CYTHON_INLINE int __Pyx_PyErr_ExceptionMatchesInState(PyThreadState* tstate, PyObject* err) {
    PyObject *exc_type = tstate->curexc_type;
    if (exc_type == err) return 1;
    if (unlikely(!exc_type)) return 0;
    if (unlikely(PyTuple_Check(err)))
        return __Pyx_PyErr_ExceptionMatchesTuple(exc_type, err);
    return __Pyx_PyErr_GivenExceptionMatches(exc_type, err);
}
#endif

/* GetException */
#if CYTHON_FAST_THREAD_STATE
static int __Pyx__GetException(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb)
#else
static int __Pyx_GetException(PyObject **type, PyObject **value, PyObject **tb)
#endif
{
    PyObject *local_type, *local_value, *local_tb;
#if CYTHON_FAST_THREAD_STATE
    PyObject *tmp_type, *tmp_value, *tmp_tb;
    local_type = tstate->curexc_type;
    local_value = tstate->curexc_value;
    local_tb = tstate->curexc_traceback;
    tstate->curexc_type = 0;
    tstate->curexc_value = 0;
    tstate->curexc_traceback = 0;
#else
    PyErr_Fetch(&local_type, &local_value, &local_tb);
#endif
    PyErr_NormalizeException(&local_type, &local_value, &local_tb);
#if CYTHON_FAST_THREAD_STATE
    if (unlikely(tstate->curexc_type))
#else
    if (unlikely(PyErr_Occurred()))
#endif
        goto bad;
    #if PY_MAJOR_VERSION >= 3
    if (local_tb) {
        if (unlikely(PyException_SetTraceback(local_value, local_tb) < 0))
            goto bad;
    }
    #endif
    Py_XINCREF(local_tb);
    Py_XINCREF(local_type);
    Py_XINCREF(local_value);
    *type = local_type;
    *value = local_value;
    *tb = local_tb;
#if CYTHON_FAST_THREAD_STATE
    #if CYTHON_USE_EXC_INFO_STACK
    {
        _PyErr_StackItem *exc_info = tstate->exc_info;
        tmp_type = exc_info->exc_type;
        tmp_value = exc_info->exc_value;
        tmp_tb = exc_info->exc_traceback;
        exc_info->exc_type = local_type;
        exc_info->exc_value = local_value;
        exc_info->exc_traceback = local_tb;
    }
    #else
    tmp_type = tstate->exc_type;
    tmp_value = tstate->exc_value;
    tmp_tb = tstate->exc_traceback;
    tstate->exc_type = local_type;
    tstate->exc_value = local_value;
    tstate->exc_traceback = local_tb;
    #endif
    Py_XDECREF(tmp_type);
    Py_XDECREF(tmp_value);
    Py_XDECREF(tmp_tb);
#else
    PyErr_SetExcInfo(local_type, local_value, local_tb);
#endif
    return 0;
bad:
    *type = 0;
    *value = 0;
    *tb = 0;
    Py_XDECREF(local_type);
    Py_XDECREF(local_value);
    Py_XDECREF(local_tb);
    return -1;
}

/* PyObject_GenericGetAttrNoDict */
#if CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP && PY_VERSION_HEX < 0x03070000
static PyObject *__Pyx_RaiseGenericGetAttributeError(PyTypeObject *tp, PyObject *attr_name) {
    PyErr_Format(PyExc_AttributeError,
#if PY_MAJOR_VERSION >= 3
                 "'%.50s' object has no attribute '%U'",
                 tp->tp_name, attr_name);
#else
                 "'%.50s' object has no attribute '%.400s'",
                 tp->tp_name, PyString_AS_STRING(attr_name));
#endif
    return NULL;
}
static CYTHON_INLINE PyObject* __Pyx_PyObject_GenericGetAttrNoDict(PyObject* obj, PyObject* attr_name) {
    PyObject *descr;
    PyTypeObject *tp = Py_TYPE(obj);
    if (unlikely(!PyString_Check(attr_name))) {
        return PyObject_GenericGetAttr(obj, attr_name);
    }
    assert(!tp->tp_dictoffset);
    descr = _PyType_Lookup(tp, attr_name);
    if (unlikely(!descr)) {
        return __Pyx_RaiseGenericGetAttributeError(tp, attr_name);
    }
    Py_INCREF(descr);
    #if PY_MAJOR_VERSION < 3
    if (likely(PyType_HasFeature(Py_TYPE(descr), Py_TPFLAGS_HAVE_CLASS)))
    #endif
    {
        descrgetfunc f = Py_TYPE(descr)->tp_descr_get;
        if (unlikely(f)) {
            PyObject *res = f(descr, obj, (PyObject *)tp);
            Py_DECREF(descr);
            return res;
        }
    }
    return descr;
}
#endif

/* PyObject_GenericGetAttr */
#if CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP && PY_VERSION_HEX < 0x03070000
static PyObject* __Pyx_PyObject_GenericGetAttr(PyObject* obj, PyObject* attr_name) {
    if (unlikely(Py_TYPE(obj)->tp_dictoffset)) {
        return PyObject_GenericGetAttr(obj, attr_name);
    }
    return __Pyx_PyObject_GenericGetAttrNoDict(obj, attr_name);
}
#endif

/* SetVTable */
static int __Pyx_SetVtable(PyObject *dict, void *vtable) {
#if PY_VERSION_HEX >= 0x02070000
    PyObject *ob = PyCapsule_New(vtable, 0, 0);
#else
    PyObject *ob = PyCObject_FromVoidPtr(vtable, 0);
#endif
    if (!ob)
        goto bad;
    if (PyDict_SetItem(dict, __pyx_n_s_pyx_vtable, ob) < 0)
        goto bad;
    Py_DECREF(ob);
    return 0;
bad:
    Py_XDECREF(ob);
    return -1;
}

/* PyObjectGetAttrStrNoError */
static void __Pyx_PyObject_GetAttrStr_ClearAttributeError(void) {
    __Pyx_PyThreadState_declare
    __Pyx_PyThreadState_assign
    if (likely(__Pyx_PyErr_ExceptionMatches(PyExc_AttributeError)))
        __Pyx_PyErr_Clear();
}
static CYTHON_INLINE PyObject* __Pyx_PyObject_GetAttrStrNoError(PyObject* obj, PyObject* attr_name) {
    PyObject *result;
#if CYTHON_COMPILING_IN_CPYTHON && CYTHON_USE_TYPE_SLOTS && PY_VERSION_HEX >= 0x030700B1
    PyTypeObject* tp = Py_TYPE(obj);
    if (likely(tp->tp_getattro == PyObject_GenericGetAttr)) {
        return _PyObject_GenericGetAttrWithDict(obj, attr_name, NULL, 1);
    }
#endif
    result = __Pyx_PyObject_GetAttrStr(obj, attr_name);
    if (unlikely(!result)) {
        __Pyx_PyObject_GetAttrStr_ClearAttributeError();
    }
    return result;
}

/* SetupReduce */
static int __Pyx_setup_reduce_is_named(PyObject* meth, PyObject* name) {
  int ret;
  PyObject *name_attr;
  name_attr = __Pyx_PyObject_GetAttrStr(meth, __pyx_n_s_name);
  if (likely(name_attr)) {
      ret = PyObject_RichCompareBool(name_attr, name, Py_EQ);
  } else {
      ret = -1;
  }
  if (unlikely(ret < 0)) {
      PyErr_Clear();
      ret = 0;
  }
  Py_XDECREF(name_attr);
  return ret;
}
static int __Pyx_setup_reduce(PyObject* type_obj) {
    int ret = 0;
    PyObject *object_reduce = NULL;
    PyObject *object_getstate = NULL;
    PyObject *object_reduce_ex = NULL;
    PyObject *reduce = NULL;
    PyObject *reduce_ex = NULL;
    PyObject *reduce_cython = NULL;
    PyObject *setstate = NULL;
    PyObject *setstate_cython = NULL;
    PyObject *getstate = NULL;
#if CYTHON_USE_PYTYPE_LOOKUP
    getstate = _PyType_Lookup((PyTypeObject*)type_obj, __pyx_n_s_getstate);
#else
    getstate = __Pyx_PyObject_GetAttrStrNoError(type_obj, __pyx_n_s_getstate);
    if (!getstate && PyErr_Occurred()) {
        goto __PYX_BAD;
    }
#endif
    if (getstate) {
#if CYTHON_USE_PYTYPE_LOOKUP
        object_getstate = _PyType_Lookup(&PyBaseObject_Type, __pyx_n_s_getstate);
#else
        object_getstate = __Pyx_PyObject_GetAttrStrNoError((PyObject*)&PyBaseObject_Type, __pyx_n_s_getstate);
        if (!object_getstate && PyErr_Occurred()) {
            goto __PYX_BAD;
        }
#endif
        if (object_getstate != getstate) {
            goto __PYX_GOOD;
        }
    }
#if CYTHON_USE_PYTYPE_LOOKUP
    object_reduce_ex = _PyType_Lookup(&PyBaseObject_Type, __pyx_n_s_reduce_ex); if (!object_reduce_ex) goto __PYX_BAD;
#else
    object_reduce_ex = __Pyx_PyObject_GetAttrStr((PyObject*)&PyBaseObject_Type, __pyx_n_s_reduce_ex); if (!object_reduce_ex) goto __PYX_BAD;
#endif
    reduce_ex = __Pyx_PyObject_GetAttrStr(type_obj, __pyx_n_s_reduce_ex); if (unlikely(!reduce_ex)) goto __PYX_BAD;
    if (reduce_ex == object_reduce_ex) {
#if CYTHON_USE_PYTYPE_LOOKUP
        object_reduce = _PyType_Lookup(&PyBaseObject_Type, __pyx_n_s_reduce); if (!object_reduce) goto __PYX_BAD;
#else
        object_reduce = __Pyx_PyObject_GetAttrStr((PyObject*)&PyBaseObject_Type, __pyx_n_s_reduce); if (!object_reduce) goto __PYX_BAD;
#endif
        reduce = __Pyx_PyObject_GetAttrStr(type_obj, __pyx_n_s_reduce); if (unlikely(!reduce)) goto __PYX_BAD;
        if (reduce == object_reduce || __Pyx_setup_reduce_is_named(reduce, __pyx_n_s_reduce_cython)) {
            reduce_cython = __Pyx_PyObject_GetAttrStrNoError(type_obj, __pyx_n_s_reduce_cython);
            if (likely(reduce_cython)) {
                ret = PyDict_SetItem(((PyTypeObject*)type_obj)->tp_dict, __pyx_n_s_reduce, reduce_cython); if (unlikely(ret < 0)) goto __PYX_BAD;
                ret = PyDict_DelItem(((PyTypeObject*)type_obj)->tp_dict, __pyx_n_s_reduce_cython); if (unlikely(ret < 0)) goto __PYX_BAD;
            } else if (reduce == object_reduce || PyErr_Occurred()) {
                goto __PYX_BAD;
            }
            setstate = __Pyx_PyObject_GetAttrStr(type_obj, __pyx_n_s_setstate);
            if (!setstate) PyErr_Clear();
            if (!setstate || __Pyx_setup_reduce_is_named(setstate, __pyx_n_s_setstate_cython)) {
                setstate_cython = __Pyx_PyObject_GetAttrStrNoError(type_obj, __pyx_n_s_setstate_cython);
                if (likely(setstate_cython)) {
                    ret = PyDict_SetItem(((PyTypeObject*)type_obj)->tp_dict, __pyx_n_s_setstate, setstate_cython); if (unlikely(ret < 0)) goto __PYX_BAD;
                    ret = PyDict_DelItem(((PyTypeObject*)type_obj)->tp_dict, __pyx_n_s_setstate_cython); if (unlikely(ret < 0)) goto __PYX_BAD;
                } else if (!setstate || PyErr_Occurred()) {
                    goto __PYX_BAD;
                }
            }
            PyType_Modified((PyTypeObject*)type_obj);
        }
    }
    goto __PYX_GOOD;
__PYX_BAD:
    if (!PyErr_Occurred())
        PyErr_Format(PyExc_RuntimeError, "Unable to initialize pickling for %s", ((PyTypeObject*)type_obj)->tp_name);
    ret = -1;
__PYX_GOOD:
#if !CYTHON_USE_PYTYPE_LOOKUP
    Py_XDECREF(object_reduce);
    Py_XDECREF(object_reduce_ex);
    Py_XDECREF(object_getstate);
    Py_XDECREF(getstate);
#endif
    Py_XDECREF(reduce);
    Py_XDECREF(reduce_ex);
    Py_XDECREF(reduce_cython);
    Py_XDECREF(setstate);
    Py_XDECREF(setstate_cython);
    return ret;
}

/* Import */
static PyObject *__Pyx_Import(PyObject *name, PyObject *from_list, int level) {
    PyObject *empty_list = 0;
    PyObject *module = 0;
    PyObject *global_dict = 0;
    PyObject *empty_dict = 0;
    PyObject *list;
    #if PY_MAJOR_VERSION < 3
    PyObject *py_import;
    py_import = __Pyx_PyObject_GetAttrStr(__pyx_b, __pyx_n_s_import);
    if (!py_import)
        goto bad;
    #endif
    if (from_list)
        list = from_list;
    else {
        empty_list = PyList_New(0);
        if (!empty_list)
            goto bad;
        list = empty_list;
    }
    global_dict = PyModule_GetDict(__pyx_m);
    if (!global_dict)
        goto bad;
    empty_dict = PyDict_New();
    if (!empty_dict)
        goto bad;
    {
        #if PY_MAJOR_VERSION >= 3
        if (level == -1) {
            if ((1) && (strchr(__Pyx_MODULE_NAME, '.'))) {
                module = PyImport_ImportModuleLevelObject(
                    name, global_dict, empty_dict, list, 1);
                if (!module) {
                    if (!PyErr_ExceptionMatches(PyExc_ImportError))
                        goto bad;
                    PyErr_Clear();
                }
            }
            level = 0;
        }
        #endif
        if (!module) {
            #if PY_MAJOR_VERSION < 3
            PyObject *py_level = PyInt_FromLong(level);
            if (!py_level)
                goto bad;
            module = PyObject_CallFunctionObjArgs(py_import,
                name, global_dict, empty_dict, list, py_level, (PyObject *)NULL);
            Py_DECREF(py_level);
            #else
            module = PyImport_ImportModuleLevelObject(
                name, global_dict, empty_dict, list, level);
            #endif
        }
    }
bad:
    #if PY_MAJOR_VERSION < 3
    Py_XDECREF(py_import);
    #endif
    Py_XDECREF(empty_list);
    Py_XDECREF(empty_dict);
    return module;
}

/* ImportFrom */
static PyObject* __Pyx_ImportFrom(PyObject* module, PyObject* name) {
    PyObject* value = __Pyx_PyObject_GetAttrStr(module, name);
    if (unlikely(!value) && PyErr_ExceptionMatches(PyExc_AttributeError)) {
        PyErr_Format(PyExc_ImportError,
        #if PY_MAJOR_VERSION < 3
            "cannot import name %.230s", PyString_AS_STRING(name));
        #else
            "cannot import name %S", name);
        #endif
    }
    return value;
}

/* CalculateMetaclass */
static PyObject *__Pyx_CalculateMetaclass(PyTypeObject *metaclass, PyObject *bases) {
    Py_ssize_t i, nbases = PyTuple_GET_SIZE(bases);
    for (i=0; i < nbases; i++) {
        PyTypeObject *tmptype;
        PyObject *tmp = PyTuple_GET_ITEM(bases, i);
        tmptype = Py_TYPE(tmp);
#if PY_MAJOR_VERSION < 3
        if (tmptype == &PyClass_Type)
            continue;
#endif
        if (!metaclass) {
            metaclass = tmptype;
            continue;
        }
        if (PyType_IsSubtype(metaclass, tmptype))
            continue;
        if (PyType_IsSubtype(tmptype, metaclass)) {
            metaclass = tmptype;
            continue;
        }
        PyErr_SetString(PyExc_TypeError,
                        "metaclass conflict: "
                        "the metaclass of a derived class "
                        "must be a (non-strict) subclass "
                        "of the metaclasses of all its bases");
        return NULL;
    }
    if (!metaclass) {
#if PY_MAJOR_VERSION < 3
        metaclass = &PyClass_Type;
#else
        metaclass = &PyType_Type;
#endif
    }
    Py_INCREF((PyObject*) metaclass);
    return (PyObject*) metaclass;
}

/* FetchCommonType */
static PyTypeObject* __Pyx_FetchCommonType(PyTypeObject* type) {
    PyObject* fake_module;
    PyTypeObject* cached_type = NULL;
    fake_module = PyImport_AddModule((char*) "_cython_" CYTHON_ABI);
    if (!fake_module) return NULL;
    Py_INCREF(fake_module);
    cached_type = (PyTypeObject*) PyObject_GetAttrString(fake_module, type->tp_name);
    if (cached_type) {
        if (!PyType_Check((PyObject*)cached_type)) {
            PyErr_Format(PyExc_TypeError,
                "Shared Cython type %.200s is not a type object",
                type->tp_name);
            goto bad;
        }
        if (cached_type->tp_basicsize != type->tp_basicsize) {
            PyErr_Format(PyExc_TypeError,
                "Shared Cython type %.200s has the wrong size, try recompiling",
                type->tp_name);
            goto bad;
        }
    } else {
        if (!PyErr_ExceptionMatches(PyExc_AttributeError)) goto bad;
        PyErr_Clear();
        if (PyType_Ready(type) < 0) goto bad;
        if (PyObject_SetAttrString(fake_module, type->tp_name, (PyObject*) type) < 0)
            goto bad;
        Py_INCREF(type);
        cached_type = type;
    }
done:
    Py_DECREF(fake_module);
    return cached_type;
bad:
    Py_XDECREF(cached_type);
    cached_type = NULL;
    goto done;
}

/* CythonFunctionShared */
#include <structmember.h>
static PyObject *
__Pyx_CyFunction_get_doc(__pyx_CyFunctionObject *op, CYTHON_UNUSED void *closure)
{
    if (unlikely(op->func_doc == NULL)) {
        if (op->func.m_ml->ml_doc) {
#if PY_MAJOR_VERSION >= 3
            op->func_doc = PyUnicode_FromString(op->func.m_ml->ml_doc);
#else
            op->func_doc = PyString_FromString(op->func.m_ml->ml_doc);
#endif
            if (unlikely(op->func_doc == NULL))
                return NULL;
        } else {
            Py_INCREF(Py_None);
            return Py_None;
        }
    }
    Py_INCREF(op->func_doc);
    return op->func_doc;
}
static int
__Pyx_CyFunction_set_doc(__pyx_CyFunctionObject *op, PyObject *value, CYTHON_UNUSED void *context)
{
    PyObject *tmp = op->func_doc;
    if (value == NULL) {
        value = Py_None;
    }
    Py_INCREF(value);
    op->func_doc = value;
    Py_XDECREF(tmp);
    return 0;
}
static PyObject *
__Pyx_CyFunction_get_name(__pyx_CyFunctionObject *op, CYTHON_UNUSED void *context)
{
    if (unlikely(op->func_name == NULL)) {
#if PY_MAJOR_VERSION >= 3
        op->func_name = PyUnicode_InternFromString(op->func.m_ml->ml_name);
#else
        op->func_name = PyString_InternFromString(op->func.m_ml->ml_name);
#endif
        if (unlikely(op->func_name == NULL))
            return NULL;
    }
    Py_INCREF(op->func_name);
    return op->func_name;
}
static int
__Pyx_CyFunction_set_name(__pyx_CyFunctionObject *op, PyObject *value, CYTHON_UNUSED void *context)
{
    PyObject *tmp;
#if PY_MAJOR_VERSION >= 3
    if (unlikely(value == NULL || !PyUnicode_Check(value)))
#else
    if (unlikely(value == NULL || !PyString_Check(value)))
#endif
    {
        PyErr_SetString(PyExc_TypeError,
                        "__name__ must be set to a string object");
        return -1;
    }
    tmp = op->func_name;
    Py_INCREF(value);
    op->func_name = value;
    Py_XDECREF(tmp);
    return 0;
}
static PyObject *
__Pyx_CyFunction_get_qualname(__pyx_CyFunctionObject *op, CYTHON_UNUSED void *context)
{
    Py_INCREF(op->func_qualname);
    return op->func_qualname;
}
static int
__Pyx_CyFunction_set_qualname(__pyx_CyFunctionObject *op, PyObject *value, CYTHON_UNUSED void *context)
{
    PyObject *tmp;
#if PY_MAJOR_VERSION >= 3
    if (unlikely(value == NULL || !PyUnicode_Check(value)))
#else
    if (unlikely(value == NULL || !PyString_Check(value)))
#endif
    {
        PyErr_SetString(PyExc_TypeError,
                        "__qualname__ must be set to a string object");
        return -1;
    }
    tmp = op->func_qualname;
    Py_INCREF(value);
    op->func_qualname = value;
    Py_XDECREF(tmp);
    return 0;
}
static PyObject *
__Pyx_CyFunction_get_self(__pyx_CyFunctionObject *m, CYTHON_UNUSED void *closure)
{
    PyObject *self;
    self = m->func_closure;
    if (self == NULL)
        self = Py_None;
    Py_INCREF(self);
    return self;
}
static PyObject *
__Pyx_CyFunction_get_dict(__pyx_CyFunctionObject *op, CYTHON_UNUSED void *context)
{
    if (unlikely(op->func_dict == NULL)) {
        op->func_dict = PyDict_New();
        if (unlikely(op->func_dict == NULL))
            return NULL;
    }
    Py_INCREF(op->func_dict);
    return op->func_dict;
}
static int
__Pyx_CyFunction_set_dict(__pyx_CyFunctionObject *op, PyObject *value, CYTHON_UNUSED void *context)
{
    PyObject *tmp;
    if (unlikely(value == NULL)) {
        PyErr_SetString(PyExc_TypeError,
               "function's dictionary may not be deleted");
        return -1;
    }
    if (unlikely(!PyDict_Check(value))) {
        PyErr_SetString(PyExc_TypeError,
               "setting function's dictionary to a non-dict");
        return -1;
    }
    tmp = op->func_dict;
    Py_INCREF(value);
    op->func_dict = value;
    Py_XDECREF(tmp);
    return 0;
}
static PyObject *
__Pyx_CyFunction_get_globals(__pyx_CyFunctionObject *op, CYTHON_UNUSED void *context)
{
    Py_INCREF(op->func_globals);
    return op->func_globals;
}
static PyObject *
__Pyx_CyFunction_get_closure(CYTHON_UNUSED __pyx_CyFunctionObject *op, CYTHON_UNUSED void *context)
{
    Py_INCREF(Py_None);
    return Py_None;
}
static PyObject *
__Pyx_CyFunction_get_code(__pyx_CyFunctionObject *op, CYTHON_UNUSED void *context)
{
    PyObject* result = (op->func_code) ? op->func_code : Py_None;
    Py_INCREF(result);
    return result;
}
static int
__Pyx_CyFunction_init_defaults(__pyx_CyFunctionObject *op) {
    int result = 0;
    PyObject *res = op->defaults_getter((PyObject *) op);
    if (unlikely(!res))
        return -1;
    #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
    op->defaults_tuple = PyTuple_GET_ITEM(res, 0);
    Py_INCREF(op->defaults_tuple);
    op->defaults_kwdict = PyTuple_GET_ITEM(res, 1);
    Py_INCREF(op->defaults_kwdict);
    #else
    op->defaults_tuple = PySequence_ITEM(res, 0);
    if (unlikely(!op->defaults_tuple)) result = -1;
    else {
        op->defaults_kwdict = PySequence_ITEM(res, 1);
        if (unlikely(!op->defaults_kwdict)) result = -1;
    }
    #endif
    Py_DECREF(res);
    return result;
}
static int
__Pyx_CyFunction_set_defaults(__pyx_CyFunctionObject *op, PyObject* value, CYTHON_UNUSED void *context) {
    PyObject* tmp;
    if (!value) {
        value = Py_None;
    } else if (value != Py_None && !PyTuple_Check(value)) {
        PyErr_SetString(PyExc_TypeError,
                        "__defaults__ must be set to a tuple object");
        return -1;
    }
    Py_INCREF(value);
    tmp = op->defaults_tuple;
    op->defaults_tuple = value;
    Py_XDECREF(tmp);
    return 0;
}
static PyObject *
__Pyx_CyFunction_get_defaults(__pyx_CyFunctionObject *op, CYTHON_UNUSED void *context) {
    PyObject* result = op->defaults_tuple;
    if (unlikely(!result)) {
        if (op->defaults_getter) {
            if (__Pyx_CyFunction_init_defaults(op) < 0) return NULL;
            result = op->defaults_tuple;
        } else {
            result = Py_None;
        }
    }
    Py_INCREF(result);
    return result;
}
static int
__Pyx_CyFunction_set_kwdefaults(__pyx_CyFunctionObject *op, PyObject* value, CYTHON_UNUSED void *context) {
    PyObject* tmp;
    if (!value) {
        value = Py_None;
    } else if (value != Py_None && !PyDict_Check(value)) {
        PyErr_SetString(PyExc_TypeError,
                        "__kwdefaults__ must be set to a dict object");
        return -1;
    }
    Py_INCREF(value);
    tmp = op->defaults_kwdict;
    op->defaults_kwdict = value;
    Py_XDECREF(tmp);
    return 0;
}
static PyObject *
__Pyx_CyFunction_get_kwdefaults(__pyx_CyFunctionObject *op, CYTHON_UNUSED void *context) {
    PyObject* result = op->defaults_kwdict;
    if (unlikely(!result)) {
        if (op->defaults_getter) {
            if (__Pyx_CyFunction_init_defaults(op) < 0) return NULL;
            result = op->defaults_kwdict;
        } else {
            result = Py_None;
        }
    }
    Py_INCREF(result);
    return result;
}
static int
__Pyx_CyFunction_set_annotations(__pyx_CyFunctionObject *op, PyObject* value, CYTHON_UNUSED void *context) {
    PyObject* tmp;
    if (!value || value == Py_None) {
        value = NULL;
    } else if (!PyDict_Check(value)) {
        PyErr_SetString(PyExc_TypeError,
                        "__annotations__ must be set to a dict object");
        return -1;
    }
    Py_XINCREF(value);
    tmp = op->func_annotations;
    op->func_annotations = value;
    Py_XDECREF(tmp);
    return 0;
}
static PyObject *
__Pyx_CyFunction_get_annotations(__pyx_CyFunctionObject *op, CYTHON_UNUSED void *context) {
    PyObject* result = op->func_annotations;
    if (unlikely(!result)) {
        result = PyDict_New();
        if (unlikely(!result)) return NULL;
        op->func_annotations = result;
    }
    Py_INCREF(result);
    return result;
}
static PyGetSetDef __pyx_CyFunction_getsets[] = {
    {(char *) "func_doc", (getter)__Pyx_CyFunction_get_doc, (setter)__Pyx_CyFunction_set_doc, 0, 0},
    {(char *) "__doc__",  (getter)__Pyx_CyFunction_get_doc, (setter)__Pyx_CyFunction_set_doc, 0, 0},
    {(char *) "func_name", (getter)__Pyx_CyFunction_get_name, (setter)__Pyx_CyFunction_set_name, 0, 0},
    {(char *) "__name__", (getter)__Pyx_CyFunction_get_name, (setter)__Pyx_CyFunction_set_name, 0, 0},
    {(char *) "__qualname__", (getter)__Pyx_CyFunction_get_qualname, (setter)__Pyx_CyFunction_set_qualname, 0, 0},
    {(char *) "__self__", (getter)__Pyx_CyFunction_get_self, 0, 0, 0},
    {(char *) "func_dict", (getter)__Pyx_CyFunction_get_dict, (setter)__Pyx_CyFunction_set_dict, 0, 0},
    {(char *) "__dict__", (getter)__Pyx_CyFunction_get_dict, (setter)__Pyx_CyFunction_set_dict, 0, 0},
    {(char *) "func_globals", (getter)__Pyx_CyFunction_get_globals, 0, 0, 0},
    {(char *) "__globals__", (getter)__Pyx_CyFunction_get_globals, 0, 0, 0},
    {(char *) "func_closure", (getter)__Pyx_CyFunction_get_closure, 0, 0, 0},
    {(char *) "__closure__", (getter)__Pyx_CyFunction_get_closure, 0, 0, 0},
    {(char *) "func_code", (getter)__Pyx_CyFunction_get_code, 0, 0, 0},
    {(char *) "__code__", (getter)__Pyx_CyFunction_get_code, 0, 0, 0},
    {(char *) "func_defaults", (getter)__Pyx_CyFunction_get_defaults, (setter)__Pyx_CyFunction_set_defaults, 0, 0},
    {(char *) "__defaults__", (getter)__Pyx_CyFunction_get_defaults, (setter)__Pyx_CyFunction_set_defaults, 0, 0},
    {(char *) "__kwdefaults__", (getter)__Pyx_CyFunction_get_kwdefaults, (setter)__Pyx_CyFunction_set_kwdefaults, 0, 0},
    {(char *) "__annotations__", (getter)__Pyx_CyFunction_get_annotations, (setter)__Pyx_CyFunction_set_annotations, 0, 0},
    {0, 0, 0, 0, 0}
};
static PyMemberDef __pyx_CyFunction_members[] = {
    {(char *) "__module__", T_OBJECT, offsetof(PyCFunctionObject, m_module), PY_WRITE_RESTRICTED, 0},
    {0, 0, 0,  0, 0}
};
static PyObject *
__Pyx_CyFunction_reduce(__pyx_CyFunctionObject *m, CYTHON_UNUSED PyObject *args)
{
#if PY_MAJOR_VERSION >= 3
    Py_INCREF(m->func_qualname);
    return m->func_qualname;
#else
    return PyString_FromString(m->func.m_ml->ml_name);
#endif
}
static PyMethodDef __pyx_CyFunction_methods[] = {
    {"__reduce__", (PyCFunction)__Pyx_CyFunction_reduce, METH_VARARGS, 0},
    {0, 0, 0, 0}
};
#if PY_VERSION_HEX < 0x030500A0
#define __Pyx_CyFunction_weakreflist(cyfunc) ((cyfunc)->func_weakreflist)
#else
#define __Pyx_CyFunction_weakreflist(cyfunc) ((cyfunc)->func.m_weakreflist)
#endif
static PyObject *__Pyx_CyFunction_Init(__pyx_CyFunctionObject *op, PyMethodDef *ml, int flags, PyObject* qualname,
                                       PyObject *closure, PyObject *module, PyObject* globals, PyObject* code) {
    if (unlikely(op == NULL))
        return NULL;
    op->flags = flags;
    __Pyx_CyFunction_weakreflist(op) = NULL;
    op->func.m_ml = ml;
    op->func.m_self = (PyObject *) op;
    Py_XINCREF(closure);
    op->func_closure = closure;
    Py_XINCREF(module);
    op->func.m_module = module;
    op->func_dict = NULL;
    op->func_name = NULL;
    Py_INCREF(qualname);
    op->func_qualname = qualname;
    op->func_doc = NULL;
    op->func_classobj = NULL;
    op->func_globals = globals;
    Py_INCREF(op->func_globals);
    Py_XINCREF(code);
    op->func_code = code;
    op->defaults_pyobjects = 0;
    op->defaults_size = 0;
    op->defaults = NULL;
    op->defaults_tuple = NULL;
    op->defaults_kwdict = NULL;
    op->defaults_getter = NULL;
    op->func_annotations = NULL;
    return (PyObject *) op;
}
static int
__Pyx_CyFunction_clear(__pyx_CyFunctionObject *m)
{
    Py_CLEAR(m->func_closure);
    Py_CLEAR(m->func.m_module);
    Py_CLEAR(m->func_dict);
    Py_CLEAR(m->func_name);
    Py_CLEAR(m->func_qualname);
    Py_CLEAR(m->func_doc);
    Py_CLEAR(m->func_globals);
    Py_CLEAR(m->func_code);
    Py_CLEAR(m->func_classobj);
    Py_CLEAR(m->defaults_tuple);
    Py_CLEAR(m->defaults_kwdict);
    Py_CLEAR(m->func_annotations);
    if (m->defaults) {
        PyObject **pydefaults = __Pyx_CyFunction_Defaults(PyObject *, m);
        int i;
        for (i = 0; i < m->defaults_pyobjects; i++)
            Py_XDECREF(pydefaults[i]);
        PyObject_Free(m->defaults);
        m->defaults = NULL;
    }
    return 0;
}
static void __Pyx__CyFunction_dealloc(__pyx_CyFunctionObject *m)
{
    if (__Pyx_CyFunction_weakreflist(m) != NULL)
        PyObject_ClearWeakRefs((PyObject *) m);
    __Pyx_CyFunction_clear(m);
    PyObject_GC_Del(m);
}
static void __Pyx_CyFunction_dealloc(__pyx_CyFunctionObject *m)
{
    PyObject_GC_UnTrack(m);
    __Pyx__CyFunction_dealloc(m);
}
static int __Pyx_CyFunction_traverse(__pyx_CyFunctionObject *m, visitproc visit, void *arg)
{
    Py_VISIT(m->func_closure);
    Py_VISIT(m->func.m_module);
    Py_VISIT(m->func_dict);
    Py_VISIT(m->func_name);
    Py_VISIT(m->func_qualname);
    Py_VISIT(m->func_doc);
    Py_VISIT(m->func_globals);
    Py_VISIT(m->func_code);
    Py_VISIT(m->func_classobj);
    Py_VISIT(m->defaults_tuple);
    Py_VISIT(m->defaults_kwdict);
    if (m->defaults) {
        PyObject **pydefaults = __Pyx_CyFunction_Defaults(PyObject *, m);
        int i;
        for (i = 0; i < m->defaults_pyobjects; i++)
            Py_VISIT(pydefaults[i]);
    }
    return 0;
}
static PyObject *__Pyx_CyFunction_descr_get(PyObject *func, PyObject *obj, PyObject *type)
{
#if PY_MAJOR_VERSION < 3
    __pyx_CyFunctionObject *m = (__pyx_CyFunctionObject *) func;
    if (m->flags & __Pyx_CYFUNCTION_STATICMETHOD) {
        Py_INCREF(func);
        return func;
    }
    if (m->flags & __Pyx_CYFUNCTION_CLASSMETHOD) {
        if (type == NULL)
            type = (PyObject *)(Py_TYPE(obj));
        return __Pyx_PyMethod_New(func, type, (PyObject *)(Py_TYPE(type)));
    }
    if (obj == Py_None)
        obj = NULL;
#endif
    return __Pyx_PyMethod_New(func, obj, type);
}
static PyObject*
__Pyx_CyFunction_repr(__pyx_CyFunctionObject *op)
{
#if PY_MAJOR_VERSION >= 3
    return PyUnicode_FromFormat("<cyfunction %U at %p>",
                                op->func_qualname, (void *)op);
#else
    return PyString_FromFormat("<cyfunction %s at %p>",
                               PyString_AsString(op->func_qualname), (void *)op);
#endif
}
static PyObject * __Pyx_CyFunction_CallMethod(PyObject *func, PyObject *self, PyObject *arg, PyObject *kw) {
    PyCFunctionObject* f = (PyCFunctionObject*)func;
    PyCFunction meth = f->m_ml->ml_meth;
    Py_ssize_t size;
    switch (f->m_ml->ml_flags & (METH_VARARGS | METH_KEYWORDS | METH_NOARGS | METH_O)) {
    case METH_VARARGS:
        if (likely(kw == NULL || PyDict_Size(kw) == 0))
            return (*meth)(self, arg);
        break;
    case METH_VARARGS | METH_KEYWORDS:
        return (*(PyCFunctionWithKeywords)(void*)meth)(self, arg, kw);
    case METH_NOARGS:
        if (likely(kw == NULL || PyDict_Size(kw) == 0)) {
            size = PyTuple_GET_SIZE(arg);
            if (likely(size == 0))
                return (*meth)(self, NULL);
            PyErr_Format(PyExc_TypeError,
                "%.200s() takes no arguments (%" CYTHON_FORMAT_SSIZE_T "d given)",
                f->m_ml->ml_name, size);
            return NULL;
        }
        break;
    case METH_O:
        if (likely(kw == NULL || PyDict_Size(kw) == 0)) {
            size = PyTuple_GET_SIZE(arg);
            if (likely(size == 1)) {
                PyObject *result, *arg0;
                #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
                arg0 = PyTuple_GET_ITEM(arg, 0);
                #else
                arg0 = PySequence_ITEM(arg, 0); if (unlikely(!arg0)) return NULL;
                #endif
                result = (*meth)(self, arg0);
                #if !(CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS)
                Py_DECREF(arg0);
                #endif
                return result;
            }
            PyErr_Format(PyExc_TypeError,
                "%.200s() takes exactly one argument (%" CYTHON_FORMAT_SSIZE_T "d given)",
                f->m_ml->ml_name, size);
            return NULL;
        }
        break;
    default:
        PyErr_SetString(PyExc_SystemError, "Bad call flags in "
                        "__Pyx_CyFunction_Call. METH_OLDARGS is no "
                        "longer supported!");
        return NULL;
    }
    PyErr_Format(PyExc_TypeError, "%.200s() takes no keyword arguments",
                 f->m_ml->ml_name);
    return NULL;
}
static CYTHON_INLINE PyObject *__Pyx_CyFunction_Call(PyObject *func, PyObject *arg, PyObject *kw) {
    return __Pyx_CyFunction_CallMethod(func, ((PyCFunctionObject*)func)->m_self, arg, kw);
}
static PyObject *__Pyx_CyFunction_CallAsMethod(PyObject *func, PyObject *args, PyObject *kw) {
    PyObject *result;
    __pyx_CyFunctionObject *cyfunc = (__pyx_CyFunctionObject *) func;
    if ((cyfunc->flags & __Pyx_CYFUNCTION_CCLASS) && !(cyfunc->flags & __Pyx_CYFUNCTION_STATICMETHOD)) {
        Py_ssize_t argc;
        PyObject *new_args;
        PyObject *self;
        argc = PyTuple_GET_SIZE(args);
        new_args = PyTuple_GetSlice(args, 1, argc);
        if (unlikely(!new_args))
            return NULL;
        self = PyTuple_GetItem(args, 0);
        if (unlikely(!self)) {
            Py_DECREF(new_args);
            PyErr_Format(PyExc_TypeError,
                         "unbound method %.200S() needs an argument",
                         cyfunc->func_qualname);
            return NULL;
        }
        result = __Pyx_CyFunction_CallMethod(func, self, new_args, kw);
        Py_DECREF(new_args);
    } else {
        result = __Pyx_CyFunction_Call(func, args, kw);
    }
    return result;
}
static PyTypeObject __pyx_CyFunctionType_type = {
    PyVarObject_HEAD_INIT(0, 0)
    "cython_function_or_method",
    sizeof(__pyx_CyFunctionObject),
    0,
    (destructor) __Pyx_CyFunction_dealloc,
    0,
    0,
    0,
#if PY_MAJOR_VERSION < 3
    0,
#else
    0,
#endif
    (reprfunc) __Pyx_CyFunction_repr,
    0,
    0,
    0,
    0,
    __Pyx_CyFunction_CallAsMethod,
    0,
    0,
    0,
    0,
    Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC,
    0,
    (traverseproc) __Pyx_CyFunction_traverse,
    (inquiry) __Pyx_CyFunction_clear,
    0,
#if PY_VERSION_HEX < 0x030500A0
    offsetof(__pyx_CyFunctionObject, func_weakreflist),
#else
    offsetof(PyCFunctionObject, m_weakreflist),
#endif
    0,
    0,
    __pyx_CyFunction_methods,
    __pyx_CyFunction_members,
    __pyx_CyFunction_getsets,
    0,
    0,
    __Pyx_CyFunction_descr_get,
    0,
    offsetof(__pyx_CyFunctionObject, func_dict),
    0,
    0,
    0,
    0,
    0,
    0,
    0,
    0,
    0,
    0,
    0,
    0,
#if PY_VERSION_HEX >= 0x030400a1
    0,
#endif
#if PY_VERSION_HEX >= 0x030800b1 && (!CYTHON_COMPILING_IN_PYPY || PYPY_VERSION_NUM >= 0x07030800)
    0,
#endif
#if PY_VERSION_HEX >= 0x030800b4 && PY_VERSION_HEX < 0x03090000
    0,
#endif
#if CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX >= 0x03090000
    0,
#endif
};
static int __pyx_CyFunction_init(void) {
    __pyx_CyFunctionType = __Pyx_FetchCommonType(&__pyx_CyFunctionType_type);
    if (unlikely(__pyx_CyFunctionType == NULL)) {
        return -1;
    }
    return 0;
}
static CYTHON_INLINE void *__Pyx_CyFunction_InitDefaults(PyObject *func, size_t size, int pyobjects) {
    __pyx_CyFunctionObject *m = (__pyx_CyFunctionObject *) func;
    m->defaults = PyObject_Malloc(size);
    if (unlikely(!m->defaults))
        return PyErr_NoMemory();
    memset(m->defaults, 0, size);
    m->defaults_pyobjects = pyobjects;
    m->defaults_size = size;
    return m->defaults;
}
static CYTHON_INLINE void __Pyx_CyFunction_SetDefaultsTuple(PyObject *func, PyObject *tuple) {
    __pyx_CyFunctionObject *m = (__pyx_CyFunctionObject *) func;
    m->defaults_tuple = tuple;
    Py_INCREF(tuple);
}
static CYTHON_INLINE void __Pyx_CyFunction_SetDefaultsKwDict(PyObject *func, PyObject *dict) {
    __pyx_CyFunctionObject *m = (__pyx_CyFunctionObject *) func;
    m->defaults_kwdict = dict;
    Py_INCREF(dict);
}
static CYTHON_INLINE void __Pyx_CyFunction_SetAnnotationsDict(PyObject *func, PyObject *dict) {
    __pyx_CyFunctionObject *m = (__pyx_CyFunctionObject *) func;
    m->func_annotations = dict;
    Py_INCREF(dict);
}

/* CythonFunction */
static PyObject *__Pyx_CyFunction_New(PyMethodDef *ml, int flags, PyObject* qualname,
                                      PyObject *closure, PyObject *module, PyObject* globals, PyObject* code) {
    PyObject *op = __Pyx_CyFunction_Init(
        PyObject_GC_New(__pyx_CyFunctionObject, __pyx_CyFunctionType),
        ml, flags, qualname, closure, module, globals, code
    );
    if (likely(op)) {
        PyObject_GC_Track(op);
    }
    return op;
}

/* Py3ClassCreate */
static PyObject *__Pyx_Py3MetaclassPrepare(PyObject *metaclass, PyObject *bases, PyObject *name,
                                           PyObject *qualname, PyObject *mkw, PyObject *modname, PyObject *doc) {
    PyObject *ns;
    if (metaclass) {
        PyObject *prep = __Pyx_PyObject_GetAttrStr(metaclass, __pyx_n_s_prepare);
        if (prep) {
            PyObject *pargs = PyTuple_Pack(2, name, bases);
            if (unlikely(!pargs)) {
                Py_DECREF(prep);
                return NULL;
            }
            ns = PyObject_Call(prep, pargs, mkw);
            Py_DECREF(prep);
            Py_DECREF(pargs);
        } else {
            if (unlikely(!PyErr_ExceptionMatches(PyExc_AttributeError)))
                return NULL;
            PyErr_Clear();
            ns = PyDict_New();
        }
    } else {
        ns = PyDict_New();
    }
    if (unlikely(!ns))
        return NULL;
    if (unlikely(PyObject_SetItem(ns, __pyx_n_s_module, modname) < 0)) goto bad;
    if (unlikely(PyObject_SetItem(ns, __pyx_n_s_qualname, qualname) < 0)) goto bad;
    if (unlikely(doc && PyObject_SetItem(ns, __pyx_n_s_doc, doc) < 0)) goto bad;
    return ns;
bad:
    Py_DECREF(ns);
    return NULL;
}
static PyObject *__Pyx_Py3ClassCreate(PyObject *metaclass, PyObject *name, PyObject *bases,
                                      PyObject *dict, PyObject *mkw,
                                      int calculate_metaclass, int allow_py2_metaclass) {
    PyObject *result, *margs;
    PyObject *owned_metaclass = NULL;
    if (allow_py2_metaclass) {
        owned_metaclass = PyObject_GetItem(dict, __pyx_n_s_metaclass);
        if (owned_metaclass) {
            metaclass = owned_metaclass;
        } else if (likely(PyErr_ExceptionMatches(PyExc_KeyError))) {
            PyErr_Clear();
        } else {
            return NULL;
        }
    }
    if (calculate_metaclass && (!metaclass || PyType_Check(metaclass))) {
        metaclass = __Pyx_CalculateMetaclass((PyTypeObject*) metaclass, bases);
        Py_XDECREF(owned_metaclass);
        if (unlikely(!metaclass))
            return NULL;
        owned_metaclass = metaclass;
    }
    margs = PyTuple_Pack(3, name, bases, dict);
    if (unlikely(!margs)) {
        result = NULL;
    } else {
        result = PyObject_Call(metaclass, margs, mkw);
        Py_DECREF(margs);
    }
    Py_XDECREF(owned_metaclass);
    return result;
}

/* CLineInTraceback */
#ifndef CYTHON_CLINE_IN_TRACEBACK
static int __Pyx_CLineForTraceback(CYTHON_NCP_UNUSED PyThreadState *tstate, int c_line) {
    PyObject *use_cline;
    PyObject *ptype, *pvalue, *ptraceback;
#if CYTHON_COMPILING_IN_CPYTHON
    PyObject **cython_runtime_dict;
#endif
    if (unlikely(!__pyx_cython_runtime)) {
        return c_line;
    }
    __Pyx_ErrFetchInState(tstate, &ptype, &pvalue, &ptraceback);
#if CYTHON_COMPILING_IN_CPYTHON
    cython_runtime_dict = _PyObject_GetDictPtr(__pyx_cython_runtime);
    if (likely(cython_runtime_dict)) {
        __PYX_PY_DICT_LOOKUP_IF_MODIFIED(
            use_cline, *cython_runtime_dict,
            __Pyx_PyDict_GetItemStr(*cython_runtime_dict, __pyx_n_s_cline_in_traceback))
    } else
#endif
    {
      PyObject *use_cline_obj = __Pyx_PyObject_GetAttrStr(__pyx_cython_runtime, __pyx_n_s_cline_in_traceback);
      if (use_cline_obj) {
        use_cline = PyObject_Not(use_cline_obj) ? Py_False : Py_True;
        Py_DECREF(use_cline_obj);
      } else {
        PyErr_Clear();
        use_cline = NULL;
      }
    }
    if (!use_cline) {
        c_line = 0;
        (void) PyObject_SetAttr(__pyx_cython_runtime, __pyx_n_s_cline_in_traceback, Py_False);
    }
    else if (use_cline == Py_False || (use_cline != Py_True && PyObject_Not(use_cline) != 0)) {
        c_line = 0;
    }
    __Pyx_ErrRestoreInState(tstate, ptype, pvalue, ptraceback);
    return c_line;
}
#endif

/* CodeObjectCache */
static int __pyx_bisect_code_objects(__Pyx_CodeObjectCacheEntry* entries, int count, int code_line) {
    int start = 0, mid = 0, end = count - 1;
    if (end >= 0 && code_line > entries[end].code_line) {
        return count;
    }
    while (start < end) {
        mid = start + (end - start) / 2;
        if (code_line < entries[mid].code_line) {
            end = mid;
        } else if (code_line > entries[mid].code_line) {
             start = mid + 1;
        } else {
            return mid;
        }
    }
    if (code_line <= entries[mid].code_line) {
        return mid;
    } else {
        return mid + 1;
    }
}
static PyCodeObject *__pyx_find_code_object(int code_line) {
    PyCodeObject* code_object;
    int pos;
    if (unlikely(!code_line) || unlikely(!__pyx_code_cache.entries)) {
        return NULL;
    }
    pos = __pyx_bisect_code_objects(__pyx_code_cache.entries, __pyx_code_cache.count, code_line);
    if (unlikely(pos >= __pyx_code_cache.count) || unlikely(__pyx_code_cache.entries[pos].code_line != code_line)) {
        return NULL;
    }
    code_object = __pyx_code_cache.entries[pos].code_object;
    Py_INCREF(code_object);
    return code_object;
}
static void __pyx_insert_code_object(int code_line, PyCodeObject* code_object) {
    int pos, i;
    __Pyx_CodeObjectCacheEntry* entries = __pyx_code_cache.entries;
    if (unlikely(!code_line)) {
        return;
    }
    if (unlikely(!entries)) {
        entries = (__Pyx_CodeObjectCacheEntry*)PyMem_Malloc(64*sizeof(__Pyx_CodeObjectCacheEntry));
        if (likely(entries)) {
            __pyx_code_cache.entries = entries;
            __pyx_code_cache.max_count = 64;
            __pyx_code_cache.count = 1;
            entries[0].code_line = code_line;
            entries[0].code_object = code_object;
            Py_INCREF(code_object);
        }
        return;
    }
    pos = __pyx_bisect_code_objects(__pyx_code_cache.entries, __pyx_code_cache.count, code_line);
    if ((pos < __pyx_code_cache.count) && unlikely(__pyx_code_cache.entries[pos].code_line == code_line)) {
        PyCodeObject* tmp = entries[pos].code_object;
        entries[pos].code_object = code_object;
        Py_DECREF(tmp);
        return;
    }
    if (__pyx_code_cache.count == __pyx_code_cache.max_count) {
        int new_max = __pyx_code_cache.max_count + 64;
        entries = (__Pyx_CodeObjectCacheEntry*)PyMem_Realloc(
            __pyx_code_cache.entries, ((size_t)new_max) * sizeof(__Pyx_CodeObjectCacheEntry));
        if (unlikely(!entries)) {
            return;
        }
        __pyx_code_cache.entries = entries;
        __pyx_code_cache.max_count = new_max;
    }
    for (i=__pyx_code_cache.count; i>pos; i--) {
        entries[i] = entries[i-1];
    }
    entries[pos].code_line = code_line;
    entries[pos].code_object = code_object;
    __pyx_code_cache.count++;
    Py_INCREF(code_object);
}

/* AddTraceback */
#include "compile.h"
#include "frameobject.h"
#include "traceback.h"
#if PY_VERSION_HEX >= 0x030b00a6
  #ifndef Py_BUILD_CORE
    #define Py_BUILD_CORE 1
  #endif
  #include "internal/pycore_frame.h"
#endif
static PyCodeObject* __Pyx_CreateCodeObjectForTraceback(
            const char *funcname, int c_line,
            int py_line, const char *filename) {
    PyCodeObject *py_code = NULL;
    PyObject *py_funcname = NULL;
    #if PY_MAJOR_VERSION < 3
    PyObject *py_srcfile = NULL;
    py_srcfile = PyString_FromString(filename);
    if (!py_srcfile) goto bad;
    #endif
    if (c_line) {
        #if PY_MAJOR_VERSION < 3
        py_funcname = PyString_FromFormat( "%s (%s:%d)", funcname, __pyx_cfilenm, c_line);
        if (!py_funcname) goto bad;
        #else
        py_funcname = PyUnicode_FromFormat( "%s (%s:%d)", funcname, __pyx_cfilenm, c_line);
        if (!py_funcname) goto bad;
        funcname = PyUnicode_AsUTF8(py_funcname);
        if (!funcname) goto bad;
        #endif
    }
    else {
        #if PY_MAJOR_VERSION < 3
        py_funcname = PyString_FromString(funcname);
        if (!py_funcname) goto bad;
        #endif
    }
    #if PY_MAJOR_VERSION < 3
    py_code = __Pyx_PyCode_New(
        0,
        0,
        0,
        0,
        0,
        __pyx_empty_bytes, /*PyObject *code,*/
        __pyx_empty_tuple, /*PyObject *consts,*/
        __pyx_empty_tuple, /*PyObject *names,*/
        __pyx_empty_tuple, /*PyObject *varnames,*/
        __pyx_empty_tuple, /*PyObject *freevars,*/
        __pyx_empty_tuple, /*PyObject *cellvars,*/
        py_srcfile,   /*PyObject *filename,*/
        py_funcname,  /*PyObject *name,*/
        py_line,
        __pyx_empty_bytes  /*PyObject *lnotab*/
    );
    Py_DECREF(py_srcfile);
    #else
    py_code = PyCode_NewEmpty(filename, funcname, py_line);
    #endif
    Py_XDECREF(py_funcname);  // XDECREF since it's only set on Py3 if cline
    return py_code;
bad:
    Py_XDECREF(py_funcname);
    #if PY_MAJOR_VERSION < 3
    Py_XDECREF(py_srcfile);
    #endif
    return NULL;
}
static void __Pyx_AddTraceback(const char *funcname, int c_line,
                               int py_line, const char *filename) {
    PyCodeObject *py_code = 0;
    PyFrameObject *py_frame = 0;
    PyThreadState *tstate = __Pyx_PyThreadState_Current;
    PyObject *ptype, *pvalue, *ptraceback;
    if (c_line) {
        c_line = __Pyx_CLineForTraceback(tstate, c_line);
    }
    py_code = __pyx_find_code_object(c_line ? -c_line : py_line);
    if (!py_code) {
        __Pyx_ErrFetchInState(tstate, &ptype, &pvalue, &ptraceback);
        py_code = __Pyx_CreateCodeObjectForTraceback(
            funcname, c_line, py_line, filename);
        if (!py_code) {
            /* If the code object creation fails, then we should clear the
               fetched exception references and propagate the new exception */
            Py_XDECREF(ptype);
            Py_XDECREF(pvalue);
            Py_XDECREF(ptraceback);
            goto bad;
        }
        __Pyx_ErrRestoreInState(tstate, ptype, pvalue, ptraceback);
        __pyx_insert_code_object(c_line ? -c_line : py_line, py_code);
    }
    py_frame = PyFrame_New(
        tstate,            /*PyThreadState *tstate,*/
        py_code,           /*PyCodeObject *code,*/
        __pyx_d,    /*PyObject *globals,*/
        0                  /*PyObject *locals*/
    );
    if (!py_frame) goto bad;
    __Pyx_PyFrame_SetLineNumber(py_frame, py_line);
    PyTraceBack_Here(py_frame);
bad:
    Py_XDECREF(py_code);
    Py_XDECREF(py_frame);
}

/* CIntFromPyVerify */
#define __PYX_VERIFY_RETURN_INT(target_type, func_type, func_value)\
    __PYX__VERIFY_RETURN_INT(target_type, func_type, func_value, 0)
#define __PYX_VERIFY_RETURN_INT_EXC(target_type, func_type, func_value)\
    __PYX__VERIFY_RETURN_INT(target_type, func_type, func_value, 1)
#define __PYX__VERIFY_RETURN_INT(target_type, func_type, func_value, exc)\
    {\
        func_type value = func_value;\
        if (sizeof(target_type) < sizeof(func_type)) {\
            if (unlikely(value != (func_type) (target_type) value)) {\
                func_type zero = 0;\
                if (exc && unlikely(value == (func_type)-1 && PyErr_Occurred()))\
                    return (target_type) -1;\
                if (is_unsigned && unlikely(value < zero))\
                    goto raise_neg_overflow;\
                else\
                    goto raise_overflow;\
            }\
        }\
        return (target_type) value;\
    }

/* CIntFromPy */
static CYTHON_INLINE int __Pyx_PyInt_As_int(PyObject *x) {
#ifdef __Pyx_HAS_GCC_DIAGNOSTIC
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wconversion"
#endif
    const int neg_one = (int) -1, const_zero = (int) 0;
#ifdef __Pyx_HAS_GCC_DIAGNOSTIC
#pragma GCC diagnostic pop
#endif
    const int is_unsigned = neg_one > const_zero;
#if PY_MAJOR_VERSION < 3
    if (likely(PyInt_Check(x))) {
        if (sizeof(int) < sizeof(long)) {
            __PYX_VERIFY_RETURN_INT(int, long, PyInt_AS_LONG(x))
        } else {
            long val = PyInt_AS_LONG(x);
            if (is_unsigned && unlikely(val < 0)) {
                goto raise_neg_overflow;
            }
            return (int) val;
        }
    } else
#endif
    if (likely(PyLong_Check(x))) {
        if (is_unsigned) {
#if CYTHON_USE_PYLONG_INTERNALS
            const digit* digits = ((PyLongObject*)x)->ob_digit;
            switch (Py_SIZE(x)) {
                case  0: return (int) 0;
                case  1: __PYX_VERIFY_RETURN_INT(int, digit, digits[0])
                case 2:
                    if (8 * sizeof(int) > 1 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(int) >= 2 * PyLong_SHIFT) {
                            return (int) (((((int)digits[1]) << PyLong_SHIFT) | (int)digits[0]));
                        }
                    }
                    break;
                case 3:
                    if (8 * sizeof(int) > 2 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(int) >= 3 * PyLong_SHIFT) {
                            return (int) (((((((int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0]));
                        }
                    }
                    break;
                case 4:
                    if (8 * sizeof(int) > 3 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(int) >= 4 * PyLong_SHIFT) {
                            return (int) (((((((((int)digits[3]) << PyLong_SHIFT) | (int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0]));
                        }
                    }
                    break;
            }
#endif
#if CYTHON_COMPILING_IN_CPYTHON
            if (unlikely(Py_SIZE(x) < 0)) {
                goto raise_neg_overflow;
            }
#else
            {
                int result = PyObject_RichCompareBool(x, Py_False, Py_LT);
                if (unlikely(result < 0))
                    return (int) -1;
                if (unlikely(result == 1))
                    goto raise_neg_overflow;
            }
#endif
            if (sizeof(int) <= sizeof(unsigned long)) {
                __PYX_VERIFY_RETURN_INT_EXC(int, unsigned long, PyLong_AsUnsignedLong(x))
#ifdef HAVE_LONG_LONG
            } else if (sizeof(int) <= sizeof(unsigned PY_LONG_LONG)) {
                __PYX_VERIFY_RETURN_INT_EXC(int, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x))
#endif
            }
        } else {
#if CYTHON_USE_PYLONG_INTERNALS
            const digit* digits = ((PyLongObject*)x)->ob_digit;
            switch (Py_SIZE(x)) {
                case  0: return (int) 0;
                case -1: __PYX_VERIFY_RETURN_INT(int, sdigit, (sdigit) (-(sdigit)digits[0]))
                case  1: __PYX_VERIFY_RETURN_INT(int,  digit, +digits[0])
                case -2:
                    if (8 * sizeof(int) - 1 > 1 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(int, long, -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(int) - 1 > 2 * PyLong_SHIFT) {
                            return (int) (((int)-1)*(((((int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
                        }
                    }
                    break;
                case 2:
                    if (8 * sizeof(int) > 1 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(int) - 1 > 2 * PyLong_SHIFT) {
                            return (int) ((((((int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
                        }
                    }
                    break;
                case -3:
                    if (8 * sizeof(int) - 1 > 2 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(int, long, -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(int) - 1 > 3 * PyLong_SHIFT) {
                            return (int) (((int)-1)*(((((((int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
                        }
                    }
                    break;
                case 3:
                    if (8 * sizeof(int) > 2 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(int) - 1 > 3 * PyLong_SHIFT) {
                            return (int) ((((((((int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
                        }
                    }
                    break;
                case -4:
                    if (8 * sizeof(int) - 1 > 3 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(int, long, -(long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(int) - 1 > 4 * PyLong_SHIFT) {
                            return (int) (((int)-1)*(((((((((int)digits[3]) << PyLong_SHIFT) | (int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
                        }
                    }
                    break;
                case 4:
                    if (8 * sizeof(int) > 3 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(int) - 1 > 4 * PyLong_SHIFT) {
                            return (int) ((((((((((int)digits[3]) << PyLong_SHIFT) | (int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
                        }
                    }
                    break;
            }
#endif
            if (sizeof(int) <= sizeof(long)) {
                __PYX_VERIFY_RETURN_INT_EXC(int, long, PyLong_AsLong(x))
#ifdef HAVE_LONG_LONG
            } else if (sizeof(int) <= sizeof(PY_LONG_LONG)) {
                __PYX_VERIFY_RETURN_INT_EXC(int, PY_LONG_LONG, PyLong_AsLongLong(x))
#endif
            }
        }
        {
#if CYTHON_COMPILING_IN_PYPY && !defined(_PyLong_AsByteArray)
            PyErr_SetString(PyExc_RuntimeError,
                            "_PyLong_AsByteArray() not available in PyPy, cannot convert large numbers");
#else
            int val;
            PyObject *v = __Pyx_PyNumber_IntOrLong(x);
 #if PY_MAJOR_VERSION < 3
            if (likely(v) && !PyLong_Check(v)) {
                PyObject *tmp = v;
                v = PyNumber_Long(tmp);
                Py_DECREF(tmp);
            }
 #endif
            if (likely(v)) {
                int one = 1; int is_little = (int)*(unsigned char *)&one;
                unsigned char *bytes = (unsigned char *)&val;
                int ret = _PyLong_AsByteArray((PyLongObject *)v,
                                              bytes, sizeof(val),
                                              is_little, !is_unsigned);
                Py_DECREF(v);
                if (likely(!ret))
                    return val;
            }
#endif
            return (int) -1;
        }
    } else {
        int val;
        PyObject *tmp = __Pyx_PyNumber_IntOrLong(x);
        if (!tmp) return (int) -1;
        val = __Pyx_PyInt_As_int(tmp);
        Py_DECREF(tmp);
        return val;
    }
raise_overflow:
    PyErr_SetString(PyExc_OverflowError,
        "value too large to convert to int");
    return (int) -1;
raise_neg_overflow:
    PyErr_SetString(PyExc_OverflowError,
        "can't convert negative value to int");
    return (int) -1;
}

/* CIntToPy */
static CYTHON_INLINE PyObject* __Pyx_PyInt_From_int(int value) {
#ifdef __Pyx_HAS_GCC_DIAGNOSTIC
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wconversion"
#endif
    const int neg_one = (int) -1, const_zero = (int) 0;
#ifdef __Pyx_HAS_GCC_DIAGNOSTIC
#pragma GCC diagnostic pop
#endif
    const int is_unsigned = neg_one > const_zero;
    if (is_unsigned) {
        if (sizeof(int) < sizeof(long)) {
            return PyInt_FromLong((long) value);
        } else if (sizeof(int) <= sizeof(unsigned long)) {
            return PyLong_FromUnsignedLong((unsigned long) value);
#ifdef HAVE_LONG_LONG
        } else if (sizeof(int) <= sizeof(unsigned PY_LONG_LONG)) {
            return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG) value);
#endif
        }
    } else {
        if (sizeof(int) <= sizeof(long)) {
            return PyInt_FromLong((long) value);
#ifdef HAVE_LONG_LONG
        } else if (sizeof(int) <= sizeof(PY_LONG_LONG)) {
            return PyLong_FromLongLong((PY_LONG_LONG) value);
#endif
        }
    }
    {
        int one = 1; int little = (int)*(unsigned char *)&one;
        unsigned char *bytes = (unsigned char *)&value;
        return _PyLong_FromByteArray(bytes, sizeof(int),
                                     little, !is_unsigned);
    }
}

/* CIntToPy */
static CYTHON_INLINE PyObject* __Pyx_PyInt_From_char(char value) {
#ifdef __Pyx_HAS_GCC_DIAGNOSTIC
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wconversion"
#endif
    const char neg_one = (char) -1, const_zero = (char) 0;
#ifdef __Pyx_HAS_GCC_DIAGNOSTIC
#pragma GCC diagnostic pop
#endif
    const int is_unsigned = neg_one > const_zero;
    if (is_unsigned) {
        if (sizeof(char) < sizeof(long)) {
            return PyInt_FromLong((long) value);
        } else if (sizeof(char) <= sizeof(unsigned long)) {
            return PyLong_FromUnsignedLong((unsigned long) value);
#ifdef HAVE_LONG_LONG
        } else if (sizeof(char) <= sizeof(unsigned PY_LONG_LONG)) {
            return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG) value);
#endif
        }
    } else {
        if (sizeof(char) <= sizeof(long)) {
            return PyInt_FromLong((long) value);
#ifdef HAVE_LONG_LONG
        } else if (sizeof(char) <= sizeof(PY_LONG_LONG)) {
            return PyLong_FromLongLong((PY_LONG_LONG) value);
#endif
        }
    }
    {
        int one = 1; int little = (int)*(unsigned char *)&one;
        unsigned char *bytes = (unsigned char *)&value;
        return _PyLong_FromByteArray(bytes, sizeof(char),
                                     little, !is_unsigned);
    }
}

/* CIntToPy */
static CYTHON_INLINE PyObject* __Pyx_PyInt_From_long(long value) {
#ifdef __Pyx_HAS_GCC_DIAGNOSTIC
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wconversion"
#endif
    const long neg_one = (long) -1, const_zero = (long) 0;
#ifdef __Pyx_HAS_GCC_DIAGNOSTIC
#pragma GCC diagnostic pop
#endif
    const int is_unsigned = neg_one > const_zero;
    if (is_unsigned) {
        if (sizeof(long) < sizeof(long)) {
            return PyInt_FromLong((long) value);
        } else if (sizeof(long) <= sizeof(unsigned long)) {
            return PyLong_FromUnsignedLong((unsigned long) value);
#ifdef HAVE_LONG_LONG
        } else if (sizeof(long) <= sizeof(unsigned PY_LONG_LONG)) {
            return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG) value);
#endif
        }
    } else {
        if (sizeof(long) <= sizeof(long)) {
            return PyInt_FromLong((long) value);
#ifdef HAVE_LONG_LONG
        } else if (sizeof(long) <= sizeof(PY_LONG_LONG)) {
            return PyLong_FromLongLong((PY_LONG_LONG) value);
#endif
        }
    }
    {
        int one = 1; int little = (int)*(unsigned char *)&one;
        unsigned char *bytes = (unsigned char *)&value;
        return _PyLong_FromByteArray(bytes, sizeof(long),
                                     little, !is_unsigned);
    }
}

/* CIntFromPy */
static CYTHON_INLINE long __Pyx_PyInt_As_long(PyObject *x) {
#ifdef __Pyx_HAS_GCC_DIAGNOSTIC
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wconversion"
#endif
    const long neg_one = (long) -1, const_zero = (long) 0;
#ifdef __Pyx_HAS_GCC_DIAGNOSTIC
#pragma GCC diagnostic pop
#endif
    const int is_unsigned = neg_one > const_zero;
#if PY_MAJOR_VERSION < 3
    if (likely(PyInt_Check(x))) {
        if (sizeof(long) < sizeof(long)) {
            __PYX_VERIFY_RETURN_INT(long, long, PyInt_AS_LONG(x))
        } else {
            long val = PyInt_AS_LONG(x);
            if (is_unsigned && unlikely(val < 0)) {
                goto raise_neg_overflow;
            }
            return (long) val;
        }
    } else
#endif
    if (likely(PyLong_Check(x))) {
        if (is_unsigned) {
#if CYTHON_USE_PYLONG_INTERNALS
            const digit* digits = ((PyLongObject*)x)->ob_digit;
            switch (Py_SIZE(x)) {
                case  0: return (long) 0;
                case  1: __PYX_VERIFY_RETURN_INT(long, digit, digits[0])
                case 2:
                    if (8 * sizeof(long) > 1 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(long) >= 2 * PyLong_SHIFT) {
                            return (long) (((((long)digits[1]) << PyLong_SHIFT) | (long)digits[0]));
                        }
                    }
                    break;
                case 3:
                    if (8 * sizeof(long) > 2 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(long) >= 3 * PyLong_SHIFT) {
                            return (long) (((((((long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0]));
                        }
                    }
                    break;
                case 4:
                    if (8 * sizeof(long) > 3 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(long) >= 4 * PyLong_SHIFT) {
                            return (long) (((((((((long)digits[3]) << PyLong_SHIFT) | (long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0]));
                        }
                    }
                    break;
            }
#endif
#if CYTHON_COMPILING_IN_CPYTHON
            if (unlikely(Py_SIZE(x) < 0)) {
                goto raise_neg_overflow;
            }
#else
            {
                int result = PyObject_RichCompareBool(x, Py_False, Py_LT);
                if (unlikely(result < 0))
                    return (long) -1;
                if (unlikely(result == 1))
                    goto raise_neg_overflow;
            }
#endif
            if (sizeof(long) <= sizeof(unsigned long)) {
                __PYX_VERIFY_RETURN_INT_EXC(long, unsigned long, PyLong_AsUnsignedLong(x))
#ifdef HAVE_LONG_LONG
            } else if (sizeof(long) <= sizeof(unsigned PY_LONG_LONG)) {
                __PYX_VERIFY_RETURN_INT_EXC(long, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x))
#endif
            }
        } else {
#if CYTHON_USE_PYLONG_INTERNALS
            const digit* digits = ((PyLongObject*)x)->ob_digit;
            switch (Py_SIZE(x)) {
                case  0: return (long) 0;
                case -1: __PYX_VERIFY_RETURN_INT(long, sdigit, (sdigit) (-(sdigit)digits[0]))
                case  1: __PYX_VERIFY_RETURN_INT(long,  digit, +digits[0])
                case -2:
                    if (8 * sizeof(long) - 1 > 1 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(long, long, -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) {
                            return (long) (((long)-1)*(((((long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
                        }
                    }
                    break;
                case 2:
                    if (8 * sizeof(long) > 1 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) {
                            return (long) ((((((long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
                        }
                    }
                    break;
                case -3:
                    if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(long, long, -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) {
                            return (long) (((long)-1)*(((((((long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
                        }
                    }
                    break;
                case 3:
                    if (8 * sizeof(long) > 2 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) {
                            return (long) ((((((((long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
                        }
                    }
                    break;
                case -4:
                    if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(long, long, -(long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(long) - 1 > 4 * PyLong_SHIFT) {
                            return (long) (((long)-1)*(((((((((long)digits[3]) << PyLong_SHIFT) | (long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
                        }
                    }
                    break;
                case 4:
                    if (8 * sizeof(long) > 3 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(long) - 1 > 4 * PyLong_SHIFT) {
                            return (long) ((((((((((long)digits[3]) << PyLong_SHIFT) | (long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
                        }
                    }
                    break;
            }
#endif
            if (sizeof(long) <= sizeof(long)) {
                __PYX_VERIFY_RETURN_INT_EXC(long, long, PyLong_AsLong(x))
#ifdef HAVE_LONG_LONG
            } else if (sizeof(long) <= sizeof(PY_LONG_LONG)) {
                __PYX_VERIFY_RETURN_INT_EXC(long, PY_LONG_LONG, PyLong_AsLongLong(x))
#endif
            }
        }
        {
#if CYTHON_COMPILING_IN_PYPY && !defined(_PyLong_AsByteArray)
            PyErr_SetString(PyExc_RuntimeError,
                            "_PyLong_AsByteArray() not available in PyPy, cannot convert large numbers");
#else
            long val;
            PyObject *v = __Pyx_PyNumber_IntOrLong(x);
 #if PY_MAJOR_VERSION < 3
            if (likely(v) && !PyLong_Check(v)) {
                PyObject *tmp = v;
                v = PyNumber_Long(tmp);
                Py_DECREF(tmp);
            }
 #endif
            if (likely(v)) {
                int one = 1; int is_little = (int)*(unsigned char *)&one;
                unsigned char *bytes = (unsigned char *)&val;
                int ret = _PyLong_AsByteArray((PyLongObject *)v,
                                              bytes, sizeof(val),
                                              is_little, !is_unsigned);
                Py_DECREF(v);
                if (likely(!ret))
                    return val;
            }
#endif
            return (long) -1;
        }
    } else {
        long val;
        PyObject *tmp = __Pyx_PyNumber_IntOrLong(x);
        if (!tmp) return (long) -1;
        val = __Pyx_PyInt_As_long(tmp);
        Py_DECREF(tmp);
        return val;
    }
raise_overflow:
    PyErr_SetString(PyExc_OverflowError,
        "value too large to convert to long");
    return (long) -1;
raise_neg_overflow:
    PyErr_SetString(PyExc_OverflowError,
        "can't convert negative value to long");
    return (long) -1;
}

/* FastTypeChecks */
#if CYTHON_COMPILING_IN_CPYTHON
static int __Pyx_InBases(PyTypeObject *a, PyTypeObject *b) {
    while (a) {
        a = a->tp_base;
        if (a == b)
            return 1;
    }
    return b == &PyBaseObject_Type;
}
static CYTHON_INLINE int __Pyx_IsSubtype(PyTypeObject *a, PyTypeObject *b) {
    PyObject *mro;
    if (a == b) return 1;
    mro = a->tp_mro;
    if (likely(mro)) {
        Py_ssize_t i, n;
        n = PyTuple_GET_SIZE(mro);
        for (i = 0; i < n; i++) {
            if (PyTuple_GET_ITEM(mro, i) == (PyObject *)b)
                return 1;
        }
        return 0;
    }
    return __Pyx_InBases(a, b);
}
#if PY_MAJOR_VERSION == 2
static int __Pyx_inner_PyErr_GivenExceptionMatches2(PyObject *err, PyObject* exc_type1, PyObject* exc_type2) {
    PyObject *exception, *value, *tb;
    int res;
    __Pyx_PyThreadState_declare
    __Pyx_PyThreadState_assign
    __Pyx_ErrFetch(&exception, &value, &tb);
    res = exc_type1 ? PyObject_IsSubclass(err, exc_type1) : 0;
    if (unlikely(res == -1)) {
        PyErr_WriteUnraisable(err);
        res = 0;
    }
    if (!res) {
        res = PyObject_IsSubclass(err, exc_type2);
        if (unlikely(res == -1)) {
            PyErr_WriteUnraisable(err);
            res = 0;
        }
    }
    __Pyx_ErrRestore(exception, value, tb);
    return res;
}
#else
static CYTHON_INLINE int __Pyx_inner_PyErr_GivenExceptionMatches2(PyObject *err, PyObject* exc_type1, PyObject *exc_type2) {
    int res = exc_type1 ? __Pyx_IsSubtype((PyTypeObject*)err, (PyTypeObject*)exc_type1) : 0;
    if (!res) {
        res = __Pyx_IsSubtype((PyTypeObject*)err, (PyTypeObject*)exc_type2);
    }
    return res;
}
#endif
static int __Pyx_PyErr_GivenExceptionMatchesTuple(PyObject *exc_type, PyObject *tuple) {
    Py_ssize_t i, n;
    assert(PyExceptionClass_Check(exc_type));
    n = PyTuple_GET_SIZE(tuple);
#if PY_MAJOR_VERSION >= 3
    for (i=0; i<n; i++) {
        if (exc_type == PyTuple_GET_ITEM(tuple, i)) return 1;
    }
#endif
    for (i=0; i<n; i++) {
        PyObject *t = PyTuple_GET_ITEM(tuple, i);
        #if PY_MAJOR_VERSION < 3
        if (likely(exc_type == t)) return 1;
        #endif
        if (likely(PyExceptionClass_Check(t))) {
            if (__Pyx_inner_PyErr_GivenExceptionMatches2(exc_type, NULL, t)) return 1;
        } else {
        }
    }
    return 0;
}
static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches(PyObject *err, PyObject* exc_type) {
    if (likely(err == exc_type)) return 1;
    if (likely(PyExceptionClass_Check(err))) {
        if (likely(PyExceptionClass_Check(exc_type))) {
            return __Pyx_inner_PyErr_GivenExceptionMatches2(err, NULL, exc_type);
        } else if (likely(PyTuple_Check(exc_type))) {
            return __Pyx_PyErr_GivenExceptionMatchesTuple(err, exc_type);
        } else {
        }
    }
    return PyErr_GivenExceptionMatches(err, exc_type);
}
static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches2(PyObject *err, PyObject *exc_type1, PyObject *exc_type2) {
    assert(PyExceptionClass_Check(exc_type1));
    assert(PyExceptionClass_Check(exc_type2));
    if (likely(err == exc_type1 || err == exc_type2)) return 1;
    if (likely(PyExceptionClass_Check(err))) {
        return __Pyx_inner_PyErr_GivenExceptionMatches2(err, exc_type1, exc_type2);
    }
    return (PyErr_GivenExceptionMatches(err, exc_type1) || PyErr_GivenExceptionMatches(err, exc_type2));
}
#endif

/* CheckBinaryVersion */
static int __Pyx_check_binary_version(void) {
    char ctversion[5];
    int same=1, i, found_dot;
    const char* rt_from_call = Py_GetVersion();
    PyOS_snprintf(ctversion, 5, "%d.%d", PY_MAJOR_VERSION, PY_MINOR_VERSION);
    found_dot = 0;
    for (i = 0; i < 4; i++) {
        if (!ctversion[i]) {
            same = (rt_from_call[i] < '0' || rt_from_call[i] > '9');
            break;
        }
        if (rt_from_call[i] != ctversion[i]) {
            same = 0;
            break;
        }
    }
    if (!same) {
        char rtversion[5] = {'\0'};
        char message[200];
        for (i=0; i<4; ++i) {
            if (rt_from_call[i] == '.') {
                if (found_dot) break;
                found_dot = 1;
            } else if (rt_from_call[i] < '0' || rt_from_call[i] > '9') {
                break;
            }
            rtversion[i] = rt_from_call[i];
        }
        PyOS_snprintf(message, sizeof(message),
                      "compiletime version %s of module '%.100s' "
                      "does not match runtime version %s",
                      ctversion, __Pyx_MODULE_NAME, rtversion);
        return PyErr_WarnEx(NULL, message, 1);
    }
    return 0;
}

/* FunctionExport */
static int __Pyx_ExportFunction(const char *name, void (*f)(void), const char *sig) {
    PyObject *d = 0;
    PyObject *cobj = 0;
    union {
        void (*fp)(void);
        void *p;
    } tmp;
    d = PyObject_GetAttrString(__pyx_m, (char *)"__pyx_capi__");
    if (!d) {
        PyErr_Clear();
        d = PyDict_New();
        if (!d)
            goto bad;
        Py_INCREF(d);
        if (PyModule_AddObject(__pyx_m, (char *)"__pyx_capi__", d) < 0)
            goto bad;
    }
    tmp.fp = f;
#if PY_VERSION_HEX >= 0x02070000
    cobj = PyCapsule_New(tmp.p, sig, 0);
#else
    cobj = PyCObject_FromVoidPtrAndDesc(tmp.p, (void *)sig, 0);
#endif
    if (!cobj)
        goto bad;
    if (PyDict_SetItemString(d, name, cobj) < 0)
        goto bad;
    Py_DECREF(cobj);
    Py_DECREF(d);
    return 0;
bad:
    Py_XDECREF(cobj);
    Py_XDECREF(d);
    return -1;
}

/* InitStrings */
static int __Pyx_InitStrings(__Pyx_StringTabEntry *t) {
    while (t->p) {
        #if PY_MAJOR_VERSION < 3
        if (t->is_unicode) {
            *t->p = PyUnicode_DecodeUTF8(t->s, t->n - 1, NULL);
        } else if (t->intern) {
            *t->p = PyString_InternFromString(t->s);
        } else {
            *t->p = PyString_FromStringAndSize(t->s, t->n - 1);
        }
        #else
        if (t->is_unicode | t->is_str) {
            if (t->intern) {
                *t->p = PyUnicode_InternFromString(t->s);
            } else if (t->encoding) {
                *t->p = PyUnicode_Decode(t->s, t->n - 1, t->encoding, NULL);
            } else {
                *t->p = PyUnicode_FromStringAndSize(t->s, t->n - 1);
            }
        } else {
            *t->p = PyBytes_FromStringAndSize(t->s, t->n - 1);
        }
        #endif
        if (!*t->p)
            return -1;
        if (PyObject_Hash(*t->p) == -1)
            return -1;
        ++t;
    }
    return 0;
}

static CYTHON_INLINE PyObject* __Pyx_PyUnicode_FromString(const char* c_str) {
    return __Pyx_PyUnicode_FromStringAndSize(c_str, (Py_ssize_t)strlen(c_str));
}
static CYTHON_INLINE const char* __Pyx_PyObject_AsString(PyObject* o) {
    Py_ssize_t ignore;
    return __Pyx_PyObject_AsStringAndSize(o, &ignore);
}
#if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII || __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT
#if !CYTHON_PEP393_ENABLED
static const char* __Pyx_PyUnicode_AsStringAndSize(PyObject* o, Py_ssize_t *length) {
    char* defenc_c;
    PyObject* defenc = _PyUnicode_AsDefaultEncodedString(o, NULL);
    if (!defenc) return NULL;
    defenc_c = PyBytes_AS_STRING(defenc);
#if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII
    {
        char* end = defenc_c + PyBytes_GET_SIZE(defenc);
        char* c;
        for (c = defenc_c; c < end; c++) {
            if ((unsigned char) (*c) >= 128) {
                PyUnicode_AsASCIIString(o);
                return NULL;
            }
        }
    }
#endif
    *length = PyBytes_GET_SIZE(defenc);
    return defenc_c;
}
#else
static CYTHON_INLINE const char* __Pyx_PyUnicode_AsStringAndSize(PyObject* o, Py_ssize_t *length) {
    if (unlikely(__Pyx_PyUnicode_READY(o) == -1)) return NULL;
#if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII
    if (likely(PyUnicode_IS_ASCII(o))) {
        *length = PyUnicode_GET_LENGTH(o);
        return PyUnicode_AsUTF8(o);
    } else {
        PyUnicode_AsASCIIString(o);
        return NULL;
    }
#else
    return PyUnicode_AsUTF8AndSize(o, length);
#endif
}
#endif
#endif
static CYTHON_INLINE const char* __Pyx_PyObject_AsStringAndSize(PyObject* o, Py_ssize_t *length) {
#if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII || __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT
    if (
#if PY_MAJOR_VERSION < 3 && __PYX_DEFAULT_STRING_ENCODING_IS_ASCII
            __Pyx_sys_getdefaultencoding_not_ascii &&
#endif
            PyUnicode_Check(o)) {
        return __Pyx_PyUnicode_AsStringAndSize(o, length);
    } else
#endif
#if (!CYTHON_COMPILING_IN_PYPY) || (defined(PyByteArray_AS_STRING) && defined(PyByteArray_GET_SIZE))
    if (PyByteArray_Check(o)) {
        *length = PyByteArray_GET_SIZE(o);
        return PyByteArray_AS_STRING(o);
    } else
#endif
    {
        char* result;
        int r = PyBytes_AsStringAndSize(o, &result, length);
        if (unlikely(r < 0)) {
            return NULL;
        } else {
            return result;
        }
    }
}
static CYTHON_INLINE int __Pyx_PyObject_IsTrue(PyObject* x) {
   int is_true = x == Py_True;
   if (is_true | (x == Py_False) | (x == Py_None)) return is_true;
   else return PyObject_IsTrue(x);
}
static CYTHON_INLINE int __Pyx_PyObject_IsTrueAndDecref(PyObject* x) {
    int retval;
    if (unlikely(!x)) return -1;
    retval = __Pyx_PyObject_IsTrue(x);
    Py_DECREF(x);
    return retval;
}
static PyObject* __Pyx_PyNumber_IntOrLongWrongResultType(PyObject* result, const char* type_name) {
#if PY_MAJOR_VERSION >= 3
    if (PyLong_Check(result)) {
        if (PyErr_WarnFormat(PyExc_DeprecationWarning, 1,
                "__int__ returned non-int (type %.200s).  "
                "The ability to return an instance of a strict subclass of int "
                "is deprecated, and may be removed in a future version of Python.",
                Py_TYPE(result)->tp_name)) {
            Py_DECREF(result);
            return NULL;
        }
        return result;
    }
#endif
    PyErr_Format(PyExc_TypeError,
                 "__%.4s__ returned non-%.4s (type %.200s)",
                 type_name, type_name, Py_TYPE(result)->tp_name);
    Py_DECREF(result);
    return NULL;
}
static CYTHON_INLINE PyObject* __Pyx_PyNumber_IntOrLong(PyObject* x) {
#if CYTHON_USE_TYPE_SLOTS
  PyNumberMethods *m;
#endif
  const char *name = NULL;
  PyObject *res = NULL;
#if PY_MAJOR_VERSION < 3
  if (likely(PyInt_Check(x) || PyLong_Check(x)))
#else
  if (likely(PyLong_Check(x)))
#endif
    return __Pyx_NewRef(x);
#if CYTHON_USE_TYPE_SLOTS
  m = Py_TYPE(x)->tp_as_number;
  #if PY_MAJOR_VERSION < 3
  if (m && m->nb_int) {
    name = "int";
    res = m->nb_int(x);
  }
  else if (m && m->nb_long) {
    name = "long";
    res = m->nb_long(x);
  }
  #else
  if (likely(m && m->nb_int)) {
    name = "int";
    res = m->nb_int(x);
  }
  #endif
#else
  if (!PyBytes_CheckExact(x) && !PyUnicode_CheckExact(x)) {
    res = PyNumber_Int(x);
  }
#endif
  if (likely(res)) {
#if PY_MAJOR_VERSION < 3
    if (unlikely(!PyInt_Check(res) && !PyLong_Check(res))) {
#else
    if (unlikely(!PyLong_CheckExact(res))) {
#endif
        return __Pyx_PyNumber_IntOrLongWrongResultType(res, name);
    }
  }
  else if (!PyErr_Occurred()) {
    PyErr_SetString(PyExc_TypeError,
                    "an integer is required");
  }
  return res;
}
static CYTHON_INLINE Py_ssize_t __Pyx_PyIndex_AsSsize_t(PyObject* b) {
  Py_ssize_t ival;
  PyObject *x;
#if PY_MAJOR_VERSION < 3
  if (likely(PyInt_CheckExact(b))) {
    if (sizeof(Py_ssize_t) >= sizeof(long))
        return PyInt_AS_LONG(b);
    else
        return PyInt_AsSsize_t(b);
  }
#endif
  if (likely(PyLong_CheckExact(b))) {
    #if CYTHON_USE_PYLONG_INTERNALS
    const digit* digits = ((PyLongObject*)b)->ob_digit;
    const Py_ssize_t size = Py_SIZE(b);
    if (likely(__Pyx_sst_abs(size) <= 1)) {
        ival = likely(size) ? digits[0] : 0;
        if (size == -1) ival = -ival;
        return ival;
    } else {
      switch (size) {
         case 2:
           if (8 * sizeof(Py_ssize_t) > 2 * PyLong_SHIFT) {
             return (Py_ssize_t) (((((size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
           }
           break;
         case -2:
           if (8 * sizeof(Py_ssize_t) > 2 * PyLong_SHIFT) {
             return -(Py_ssize_t) (((((size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
           }
           break;
         case 3:
           if (8 * sizeof(Py_ssize_t) > 3 * PyLong_SHIFT) {
             return (Py_ssize_t) (((((((size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
           }
           break;
         case -3:
           if (8 * sizeof(Py_ssize_t) > 3 * PyLong_SHIFT) {
             return -(Py_ssize_t) (((((((size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
           }
           break;
         case 4:
           if (8 * sizeof(Py_ssize_t) > 4 * PyLong_SHIFT) {
             return (Py_ssize_t) (((((((((size_t)digits[3]) << PyLong_SHIFT) | (size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
           }
           break;
         case -4:
           if (8 * sizeof(Py_ssize_t) > 4 * PyLong_SHIFT) {
             return -(Py_ssize_t) (((((((((size_t)digits[3]) << PyLong_SHIFT) | (size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
           }
           break;
      }
    }
    #endif
    return PyLong_AsSsize_t(b);
  }
  x = PyNumber_Index(b);
  if (!x) return -1;
  ival = PyInt_AsSsize_t(x);
  Py_DECREF(x);
  return ival;
}
static CYTHON_INLINE Py_hash_t __Pyx_PyIndex_AsHash_t(PyObject* o) {
  if (sizeof(Py_hash_t) == sizeof(Py_ssize_t)) {
    return (Py_hash_t) __Pyx_PyIndex_AsSsize_t(o);
#if PY_MAJOR_VERSION < 3
  } else if (likely(PyInt_CheckExact(o))) {
    return PyInt_AS_LONG(o);
#endif
  } else {
    Py_ssize_t ival;
    PyObject *x;
    x = PyNumber_Index(o);
    if (!x) return -1;
    ival = PyInt_AsLong(x);
    Py_DECREF(x);
    return ival;
  }
}
static CYTHON_INLINE PyObject * __Pyx_PyBool_FromLong(long b) {
  return b ? __Pyx_NewRef(Py_True) : __Pyx_NewRef(Py_False);
}
static CYTHON_INLINE PyObject * __Pyx_PyInt_FromSize_t(size_t ival) {
    return PyInt_FromSize_t(ival);
}


#endif /* Py_PYTHON_H */
