/* Generated by Cython 0.29.28 */

/* BEGIN: Cython Metadata
{
    "distutils": {
        "define_macros": [
            [
                "CYTHON_CLINE_IN_TRACEBACK",
                0
            ]
        ],
        "depends": [
            "/home/runner/work/lupa/lupa/third-party/lua/lauxlib.h",
            "/home/runner/work/lupa/lupa/third-party/lua/lua.h",
            "/home/runner/work/lupa/lupa/third-party/lua/lualib.h"
        ],
        "include_dirs": [
            "/home/runner/work/lupa/lupa/third-party/lua"
        ],
        "name": "lupa._lupa",
        "sources": [
            "lupa/_lupa.pyx"
        ]
    },
    "module_name": "lupa._lupa"
}
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_28"
#define CYTHON_HEX_VERSION 0x001D1CF0
#define CYTHON_FUTURE_DIVISION 1
#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
  #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
#elif defined(PYSTON_VERSION)
  #define CYTHON_COMPILING_IN_PYPY 0
  #define CYTHON_COMPILING_IN_PYSTON 1
  #define CYTHON_COMPILING_IN_CPYTHON 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
#else
  #define CYTHON_COMPILING_IN_PYPY 0
  #define CYTHON_COMPILING_IN_PYSTON 0
  #define CYTHON_COMPILING_IN_CPYTHON 1
  #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 < 0x030B00A1)
  #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
#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(MS_WINDOWS)
  #define _USE_MATH_DEFINES
#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__lupa___lupa
#define __PYX_HAVE_API__lupa___lupa
/* Early includes */
#include <string.h>
#include "lua.h"
#include "lauxlib.h"
#include "lualib.h"

    #if LUA_VERSION_NUM >= 504
    #define __lupa_lua_resume lua_resume
    #else
    LUA_API int __lupa_lua_resume (lua_State *L, lua_State *from, int nargs, int* nresults) {
    #if LUA_VERSION_NUM >= 502
        int status = lua_resume(L, from, nargs);
    #else
        int status = lua_resume(L, nargs);
    #endif
        *nresults = lua_gettop(L);
        return status;
    }
    #endif

    #if LUA_VERSION_NUM >= 502
    #define lua_objlen(L, i) lua_rawlen(L, (i))
    #endif

    #if LUA_VERSION_NUM >= 504
    #define read_lua_version(L)  ((int) lua_version(L))
    #elif LUA_VERSION_NUM >= 502
    #define read_lua_version(L)  ((int) *lua_version(L))
    #elif LUA_VERSION_NUM >= 501
    #define read_lua_version(L)  ((int) LUA_VERSION_NUM)
    #else
    #error Lupa requires at least Lua 5.1 or LuaJIT 2.x
    #endif
    
#include <stdio.h>

    #if PY_VERSION_HEX < 0x03040000 && defined(_MSC_VER)
        #ifndef _MSC_STDINT_H_
            #ifdef _WIN64 // [
               typedef unsigned __int64  uintptr_t;
            #else // _WIN64 ][
               typedef _W64 unsigned int uintptr_t;
            #endif // _WIN64 ]
        #endif
    #else
        #include <stdint.h>
    #endif
    

    #define IS_PY2 (PY_MAJOR_VERSION == 2)
    
#include "pythread.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[] = {
  "lupa/_lupa.pyx",
  "lupa/lock.pxi",
  "stringsource",
  "type.pxd",
  "bool.pxd",
  "complex.pxd",
};
/* 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()

/* ForceInitThreads.proto */
#ifndef __PYX_FORCE_INIT_THREADS
  #define __PYX_FORCE_INIT_THREADS 0
#endif


/*--- Type declarations ---*/
struct __pyx_obj_4lupa_5_lupa_FastRLock;
struct __pyx_obj_4lupa_5_lupa_LuaRuntime;
struct __pyx_obj_4lupa_5_lupa__LuaObject;
struct __pyx_obj_4lupa_5_lupa__LuaTable;
struct __pyx_obj_4lupa_5_lupa__LuaFunction;
struct __pyx_obj_4lupa_5_lupa__LuaCoroutineFunction;
struct __pyx_obj_4lupa_5_lupa__LuaThread;
struct __pyx_obj_4lupa_5_lupa__LuaIter;
struct __pyx_obj_4lupa_5_lupa__PyProtocolWrapper;
struct __pyx_obj_4lupa_5_lupa___pyx_scope_struct__unpacks_lua_table;
struct __pyx_obj_4lupa_5_lupa___pyx_scope_struct_1_unpacks_lua_table_method;
struct __pyx_t_4lupa_5_lupa_py_object;
struct __pyx_opt_args_4lupa_5_lupa_py_to_lua;
struct __pyx_opt_args_4lupa_5_lupa_push_lua_arguments;

/* "lupa/_lupa.pyx":72
 *     int IS_PY2
 * 
 * cdef enum WrappedObjectFlags:             # <<<<<<<<<<<<<<
 *     # flags that determine the behaviour of a wrapped object:
 *     OBJ_AS_INDEX = 1 # prefers the getitem protocol (over getattr)
 */
enum __pyx_t_4lupa_5_lupa_WrappedObjectFlags {
  __pyx_e_4lupa_5_lupa_OBJ_AS_INDEX = 1,
  __pyx_e_4lupa_5_lupa_OBJ_UNPACK_TUPLE = 2,
  __pyx_e_4lupa_5_lupa_OBJ_ENUMERATOR = 4
};

/* "lupa/_lupa.pyx":981
 * 
 * 
 * cdef enum:             # <<<<<<<<<<<<<<
 *     KEYS = 1
 *     VALUES = 2
 */
enum  {
  __pyx_e_4lupa_5_lupa_KEYS = 1,
  __pyx_e_4lupa_5_lupa_VALUES = 2,
  __pyx_e_4lupa_5_lupa_ITEMS = 3
};

/* "lupa/_lupa.pyx":78
 *     OBJ_ENUMERATOR = 4 # iteration uses native enumerate() implementation
 * 
 * cdef struct py_object:             # <<<<<<<<<<<<<<
 *     PyObject* obj
 *     PyObject* runtime
 */
struct __pyx_t_4lupa_5_lupa_py_object {
  PyObject *obj;
  PyObject *runtime;
  int type_flags;
};

/* "lupa/_lupa.pyx":1185
 *      return py_to_lua(runtime, L, o)
 * 
 * cdef int py_to_lua(LuaRuntime runtime, lua_State *L, object o, bint wrap_none=False) except -1:             # <<<<<<<<<<<<<<
 *     cdef int pushed_values_count = 0
 *     cdef int type_flags = 0
 */
struct __pyx_opt_args_4lupa_5_lupa_py_to_lua {
  int __pyx_n;
  int wrap_none;
};

/* "lupa/_lupa.pyx":1362
 *     return results
 * 
 * cdef int push_lua_arguments(LuaRuntime runtime, lua_State *L,             # <<<<<<<<<<<<<<
 *                             tuple args, bint first_may_be_nil=True) except -1:
 *     cdef int i
 */
struct __pyx_opt_args_4lupa_5_lupa_push_lua_arguments {
  int __pyx_n;
  int first_may_be_nil;
};

/* "lupa/lock.pxi":5
 * 
 * 
 * cdef class FastRLock:             # <<<<<<<<<<<<<<
 *     """Fast, re-entrant locking.
 * 
 */
struct __pyx_obj_4lupa_5_lupa_FastRLock {
  PyObject_HEAD
  PyThread_type_lock _real_lock;
  long _owner;
  int _count;
  int _pending_requests;
  int _is_locked;
};


/* "lupa/_lupa.pyx":136
 * 
 * @cython.no_gc_clear
 * cdef class LuaRuntime:             # <<<<<<<<<<<<<<
 *     """The main entry point to the Lua runtime.
 * 
 */
struct __pyx_obj_4lupa_5_lupa_LuaRuntime {
  PyObject_HEAD
  struct __pyx_vtabstruct_4lupa_5_lupa_LuaRuntime *__pyx_vtab;
  lua_State *_state;
  struct __pyx_obj_4lupa_5_lupa_FastRLock *_lock;
  PyObject *_pyrefs_in_lua;
  PyObject *_raised_exception;
  PyObject *_encoding;
  PyObject *_source_encoding;
  PyObject *_attribute_filter;
  PyObject *_attribute_getter;
  PyObject *_attribute_setter;
  int _unpack_returned_tuples;
};


/* "lupa/_lupa.pyx":549
 * @cython.no_gc_clear
 * @cython.freelist(16)
 * cdef class _LuaObject:             # <<<<<<<<<<<<<<
 *     """A wrapper around a Lua object such as a table or function.
 *     """
 */
struct __pyx_obj_4lupa_5_lupa__LuaObject {
  PyObject_HEAD
  struct __pyx_vtabstruct_4lupa_5_lupa__LuaObject *__pyx_vtab;
  struct __pyx_obj_4lupa_5_lupa_LuaRuntime *_runtime;
  lua_State *_state;
  int _ref;
};


/* "lupa/_lupa.pyx":732
 * @cython.internal
 * @cython.no_gc_clear
 * cdef class _LuaTable(_LuaObject):             # <<<<<<<<<<<<<<
 *     def __iter__(self):
 *         return _LuaIter(self, KEYS)
 */
struct __pyx_obj_4lupa_5_lupa__LuaTable {
  struct __pyx_obj_4lupa_5_lupa__LuaObject __pyx_base;
};


/* "lupa/_lupa.pyx":823
 * @cython.internal
 * @cython.no_gc_clear
 * cdef class _LuaFunction(_LuaObject):             # <<<<<<<<<<<<<<
 *     """A Lua function (which may become a coroutine).
 *     """
 */
struct __pyx_obj_4lupa_5_lupa__LuaFunction {
  struct __pyx_obj_4lupa_5_lupa__LuaObject __pyx_base;
};


/* "lupa/_lupa.pyx":862
 * @cython.internal
 * @cython.no_gc_clear
 * cdef class _LuaCoroutineFunction(_LuaFunction):             # <<<<<<<<<<<<<<
 *     """A function that returns a new coroutine when called.
 *     """
 */
struct __pyx_obj_4lupa_5_lupa__LuaCoroutineFunction {
  struct __pyx_obj_4lupa_5_lupa__LuaFunction __pyx_base;
};


/* "lupa/_lupa.pyx":877
 * @cython.internal
 * @cython.no_gc_clear   # FIXME: get rid if this
 * cdef class _LuaThread(_LuaObject):             # <<<<<<<<<<<<<<
 *     """A Lua thread (coroutine).
 *     """
 */
struct __pyx_obj_4lupa_5_lupa__LuaThread {
  struct __pyx_obj_4lupa_5_lupa__LuaObject __pyx_base;
  lua_State *_co_state;
  PyObject *_arguments;
};


/* "lupa/_lupa.pyx":990
 * @cython.internal
 * @cython.no_gc_clear
 * cdef class _LuaIter:             # <<<<<<<<<<<<<<
 *     cdef LuaRuntime _runtime
 *     cdef _LuaObject _obj
 */
struct __pyx_obj_4lupa_5_lupa__LuaIter {
  PyObject_HEAD
  struct __pyx_obj_4lupa_5_lupa_LuaRuntime *_runtime;
  struct __pyx_obj_4lupa_5_lupa__LuaObject *_obj;
  lua_State *_state;
  int _refiter;
  char _what;
};


/* "lupa/_lupa.pyx":1101
 * @cython.internal
 * @cython.freelist(8)
 * cdef class _PyProtocolWrapper:             # <<<<<<<<<<<<<<
 *     cdef object _obj
 *     cdef int _type_flags
 */
struct __pyx_obj_4lupa_5_lupa__PyProtocolWrapper {
  PyObject_HEAD
  PyObject *_obj;
  int _type_flags;
};


/* "lupa/_lupa.pyx":462
 * # from Lua scripts
 * 
 * def unpacks_lua_table(func):             # <<<<<<<<<<<<<<
 *     """
 *     A decorator to make the decorated function receive kwargs
 */
struct __pyx_obj_4lupa_5_lupa___pyx_scope_struct__unpacks_lua_table {
  PyObject_HEAD
  PyObject *__pyx_v_func;
};


/* "lupa/_lupa.pyx":488
 * 
 * 
 * def unpacks_lua_table_method(meth):             # <<<<<<<<<<<<<<
 *     """
 *     This is :func:`unpacks_lua_table` for methods
 */
struct __pyx_obj_4lupa_5_lupa___pyx_scope_struct_1_unpacks_lua_table_method {
  PyObject_HEAD
  PyObject *__pyx_v_meth;
};



/* "lupa/_lupa.pyx":136
 * 
 * @cython.no_gc_clear
 * cdef class LuaRuntime:             # <<<<<<<<<<<<<<
 *     """The main entry point to the Lua runtime.
 * 
 */

struct __pyx_vtabstruct_4lupa_5_lupa_LuaRuntime {
  int (*reraise_on_exception)(struct __pyx_obj_4lupa_5_lupa_LuaRuntime *);
  int (*store_raised_exception)(struct __pyx_obj_4lupa_5_lupa_LuaRuntime *, lua_State *, PyObject *);
  int (*register_py_object)(struct __pyx_obj_4lupa_5_lupa_LuaRuntime *, PyObject *, PyObject *, PyObject *);
  int (*init_python_lib)(struct __pyx_obj_4lupa_5_lupa_LuaRuntime *, int, int);
};
static struct __pyx_vtabstruct_4lupa_5_lupa_LuaRuntime *__pyx_vtabptr_4lupa_5_lupa_LuaRuntime;
static int __pyx_f_4lupa_5_lupa_10LuaRuntime_reraise_on_exception(struct __pyx_obj_4lupa_5_lupa_LuaRuntime *);
static int __pyx_f_4lupa_5_lupa_10LuaRuntime_store_raised_exception(struct __pyx_obj_4lupa_5_lupa_LuaRuntime *, lua_State *, PyObject *);
static int __pyx_f_4lupa_5_lupa_10LuaRuntime_register_py_object(struct __pyx_obj_4lupa_5_lupa_LuaRuntime *, PyObject *, PyObject *, PyObject *);
static int __pyx_f_4lupa_5_lupa_10LuaRuntime_init_python_lib(struct __pyx_obj_4lupa_5_lupa_LuaRuntime *, int, int);


/* "lupa/_lupa.pyx":549
 * @cython.no_gc_clear
 * @cython.freelist(16)
 * cdef class _LuaObject:             # <<<<<<<<<<<<<<
 *     """A wrapper around a Lua object such as a table or function.
 *     """
 */

struct __pyx_vtabstruct_4lupa_5_lupa__LuaObject {
  int (*push_lua_object)(struct __pyx_obj_4lupa_5_lupa__LuaObject *);
  size_t (*_len)(struct __pyx_obj_4lupa_5_lupa__LuaObject *);
  PyObject *(*_getitem)(struct __pyx_obj_4lupa_5_lupa__LuaObject *, PyObject *, int);
};
static struct __pyx_vtabstruct_4lupa_5_lupa__LuaObject *__pyx_vtabptr_4lupa_5_lupa__LuaObject;
static CYTHON_INLINE int __pyx_f_4lupa_5_lupa_10_LuaObject_push_lua_object(struct __pyx_obj_4lupa_5_lupa__LuaObject *);
static size_t __pyx_f_4lupa_5_lupa_10_LuaObject__len(struct __pyx_obj_4lupa_5_lupa__LuaObject *);
static PyObject *__pyx_f_4lupa_5_lupa_10_LuaObject__getitem(struct __pyx_obj_4lupa_5_lupa__LuaObject *, PyObject *, int);


/* "lupa/_lupa.pyx":732
 * @cython.internal
 * @cython.no_gc_clear
 * cdef class _LuaTable(_LuaObject):             # <<<<<<<<<<<<<<
 *     def __iter__(self):
 *         return _LuaIter(self, KEYS)
 */

struct __pyx_vtabstruct_4lupa_5_lupa__LuaTable {
  struct __pyx_vtabstruct_4lupa_5_lupa__LuaObject __pyx_base;
  int (*_setitem)(struct __pyx_obj_4lupa_5_lupa__LuaTable *, PyObject *, PyObject *);
  PyObject *(*_delitem)(struct __pyx_obj_4lupa_5_lupa__LuaTable *, PyObject *);
};
static struct __pyx_vtabstruct_4lupa_5_lupa__LuaTable *__pyx_vtabptr_4lupa_5_lupa__LuaTable;
static int __pyx_f_4lupa_5_lupa_9_LuaTable__setitem(struct __pyx_obj_4lupa_5_lupa__LuaTable *, PyObject *, PyObject *);
static PyObject *__pyx_f_4lupa_5_lupa_9_LuaTable__delitem(struct __pyx_obj_4lupa_5_lupa__LuaTable *, PyObject *);


/* "lupa/_lupa.pyx":823
 * @cython.internal
 * @cython.no_gc_clear
 * cdef class _LuaFunction(_LuaObject):             # <<<<<<<<<<<<<<
 *     """A Lua function (which may become a coroutine).
 *     """
 */

struct __pyx_vtabstruct_4lupa_5_lupa__LuaFunction {
  struct __pyx_vtabstruct_4lupa_5_lupa__LuaObject __pyx_base;
};
static struct __pyx_vtabstruct_4lupa_5_lupa__LuaFunction *__pyx_vtabptr_4lupa_5_lupa__LuaFunction;


/* "lupa/_lupa.pyx":862
 * @cython.internal
 * @cython.no_gc_clear
 * cdef class _LuaCoroutineFunction(_LuaFunction):             # <<<<<<<<<<<<<<
 *     """A function that returns a new coroutine when called.
 *     """
 */

struct __pyx_vtabstruct_4lupa_5_lupa__LuaCoroutineFunction {
  struct __pyx_vtabstruct_4lupa_5_lupa__LuaFunction __pyx_base;
};
static struct __pyx_vtabstruct_4lupa_5_lupa__LuaCoroutineFunction *__pyx_vtabptr_4lupa_5_lupa__LuaCoroutineFunction;


/* "lupa/_lupa.pyx":877
 * @cython.internal
 * @cython.no_gc_clear   # FIXME: get rid if this
 * cdef class _LuaThread(_LuaObject):             # <<<<<<<<<<<<<<
 *     """A Lua thread (coroutine).
 *     """
 */

struct __pyx_vtabstruct_4lupa_5_lupa__LuaThread {
  struct __pyx_vtabstruct_4lupa_5_lupa__LuaObject __pyx_base;
};
static struct __pyx_vtabstruct_4lupa_5_lupa__LuaThread *__pyx_vtabptr_4lupa_5_lupa__LuaThread;

/* --- 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);

/* 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);

/* KeywordStringCheck.proto */
static int __Pyx_CheckKeywordStrings(PyObject *kwdict, const char* function_name, int kw_allowed);

/* 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);

/* 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

/* 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);

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

/* decode_c_string_utf16.proto */
static CYTHON_INLINE PyObject *__Pyx_PyUnicode_DecodeUTF16(const char *s, Py_ssize_t size, const char *errors) {
    int byteorder = 0;
    return PyUnicode_DecodeUTF16(s, size, errors, &byteorder);
}
static CYTHON_INLINE PyObject *__Pyx_PyUnicode_DecodeUTF16LE(const char *s, Py_ssize_t size, const char *errors) {
    int byteorder = -1;
    return PyUnicode_DecodeUTF16(s, size, errors, &byteorder);
}
static CYTHON_INLINE PyObject *__Pyx_PyUnicode_DecodeUTF16BE(const char *s, Py_ssize_t size, const char *errors) {
    int byteorder = 1;
    return PyUnicode_DecodeUTF16(s, size, errors, &byteorder);
}

/* decode_c_string.proto */
static CYTHON_INLINE PyObject* __Pyx_decode_c_string(
         const char* cstring, Py_ssize_t start, Py_ssize_t stop,
         const char* encoding, const char* errors,
         PyObject* (*decode_func)(const char *s, Py_ssize_t size, const char *errors));

/* 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

/* SwapException.proto */
#if CYTHON_FAST_THREAD_STATE
#define __Pyx_ExceptionSwap(type, value, tb)  __Pyx__ExceptionSwap(__pyx_tstate, type, value, tb)
static CYTHON_INLINE void __Pyx__ExceptionSwap(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb);
#else
static CYTHON_INLINE void __Pyx_ExceptionSwap(PyObject **type, PyObject **value, PyObject **tb);
#endif

/* 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

/* 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

/* 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"
  #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

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

/* 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);

/* 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

/* CallableCheck.proto */
#if CYTHON_USE_TYPE_SLOTS && PY_MAJOR_VERSION >= 3
#define __Pyx_PyCallable_Check(obj)   (Py_TYPE(obj)->tp_call != NULL)
#else
#define __Pyx_PyCallable_Check(obj)   PyCallable_Check(obj)
#endif

/* RaiseTooManyValuesToUnpack.proto */
static CYTHON_INLINE void __Pyx_RaiseTooManyValuesError(Py_ssize_t expected);

/* RaiseNeedMoreValuesToUnpack.proto */
static CYTHON_INLINE void __Pyx_RaiseNeedMoreValuesError(Py_ssize_t index);

/* IterFinish.proto */
static CYTHON_INLINE int __Pyx_IterFinish(void);

/* UnpackItemEndCheck.proto */
static int __Pyx_IternextUnpackEndCheck(PyObject *retval, Py_ssize_t expected);

/* 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

/* None.proto */
static CYTHON_INLINE void __Pyx_RaiseUnboundLocalError(const char *varname);

/* DivInt[long].proto */
static CYTHON_INLINE long __Pyx_div_long(long, long);

/* ModInt[long].proto */
static CYTHON_INLINE long __Pyx_mod_long(long, long);

/* 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);

/* PyObjectGetMethod.proto */
static int __Pyx_PyObject_GetMethod(PyObject *obj, PyObject *name, PyObject **method);

/* PyObjectCallMethod0.proto */
static PyObject* __Pyx_PyObject_CallMethod0(PyObject* obj, PyObject* method_name);

/* RaiseNoneIterError.proto */
static CYTHON_INLINE void __Pyx_RaiseNoneNotIterableError(void);

/* UnpackTupleError.proto */
static void __Pyx_UnpackTupleError(PyObject *, Py_ssize_t index);

/* UnpackTuple2.proto */
#define __Pyx_unpack_tuple2(tuple, value1, value2, is_tuple, has_known_size, decref_tuple)\
    (likely(is_tuple || PyTuple_Check(tuple)) ?\
        (likely(has_known_size || PyTuple_GET_SIZE(tuple) == 2) ?\
            __Pyx_unpack_tuple2_exact(tuple, value1, value2, decref_tuple) :\
            (__Pyx_UnpackTupleError(tuple, 2), -1)) :\
        __Pyx_unpack_tuple2_generic(tuple, value1, value2, has_known_size, decref_tuple))
static CYTHON_INLINE int __Pyx_unpack_tuple2_exact(
    PyObject* tuple, PyObject** value1, PyObject** value2, int decref_tuple);
static int __Pyx_unpack_tuple2_generic(
    PyObject* tuple, PyObject** value1, PyObject** value2, int has_known_size, int decref_tuple);

/* dict_iter.proto */
static CYTHON_INLINE PyObject* __Pyx_dict_iterator(PyObject* dict, int is_dict, PyObject* method_name,
                                                   Py_ssize_t* p_orig_length, int* p_is_dict);
static CYTHON_INLINE int __Pyx_dict_iter_next(PyObject* dict_or_iter, Py_ssize_t orig_length, Py_ssize_t* ppos,
                                              PyObject** pkey, PyObject** pvalue, PyObject** pitem, int is_dict);

/* 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

/* None.proto */
static CYTHON_INLINE void __Pyx_RaiseClosureNameError(const char *varname);

/* 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);

/* ListCompAppend.proto */
#if CYTHON_USE_PYLIST_INTERNALS && CYTHON_ASSUME_SAFE_MACROS
static CYTHON_INLINE int __Pyx_ListComp_Append(PyObject* list, PyObject* x) {
    PyListObject* L = (PyListObject*) list;
    Py_ssize_t len = Py_SIZE(list);
    if (likely(L->allocated > len)) {
        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_ListComp_Append(L,x) PyList_Append(L,x)
#endif

/* decode_c_bytes.proto */
static CYTHON_INLINE PyObject* __Pyx_decode_c_bytes(
         const char* cstring, Py_ssize_t length, Py_ssize_t start, Py_ssize_t stop,
         const char* encoding, const char* errors,
         PyObject* (*decode_func)(const char *s, Py_ssize_t size, const char *errors));

/* decode_bytes.proto */
static CYTHON_INLINE PyObject* __Pyx_decode_bytes(
         PyObject* string, Py_ssize_t start, Py_ssize_t stop,
         const char* encoding, const char* errors,
         PyObject* (*decode_func)(const char *s, Py_ssize_t size, const char *errors)) {
    return __Pyx_decode_c_bytes(
        PyBytes_AS_STRING(string), PyBytes_GET_SIZE(string),
        start, stop, encoding, errors, decode_func);
}

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

/* PyIntBinop.proto */
#if !CYTHON_COMPILING_IN_PYPY
static PyObject* __Pyx_PyInt_AddObjC(PyObject *op1, PyObject *op2, long intval, int inplace, int zerodivision_check);
#else
#define __Pyx_PyInt_AddObjC(op1, op2, intval, inplace, zerodivision_check)\
    (inplace ? PyNumber_InPlaceAdd(op1, op2) : PyNumber_Add(op1, op2))
#endif

/* unicode_tailmatch.proto */
static int __Pyx_PyUnicode_Tailmatch(
    PyObject* s, PyObject* substr, Py_ssize_t start, Py_ssize_t end, int direction);

/* bytes_tailmatch.proto */
static int __Pyx_PyBytes_SingleTailmatch(PyObject* self, PyObject* arg,
                                         Py_ssize_t start, Py_ssize_t end, int direction);
static int __Pyx_PyBytes_Tailmatch(PyObject* self, PyObject* substr,
                                   Py_ssize_t start, Py_ssize_t end, int direction);

/* ArgTypeTest.proto */
#define __Pyx_ArgTypeTest(obj, type, none_allowed, name, exact)\
    ((likely((Py_TYPE(obj) == type) | (none_allowed && (obj == Py_None)))) ? 1 :\
        __Pyx__ArgTypeTest(obj, type, name, exact))
static int __Pyx__ArgTypeTest(PyObject *obj, PyTypeObject *type, const char *name, int exact);

/* GetAttr.proto */
static CYTHON_INLINE PyObject *__Pyx_GetAttr(PyObject *, PyObject *);

/* HasAttr.proto */
static CYTHON_INLINE int __Pyx_HasAttr(PyObject *, PyObject *);

/* PyDictContains.proto */
static CYTHON_INLINE int __Pyx_PyDict_ContainsTF(PyObject* item, PyObject* dict, int eq) {
    int result = PyDict_Contains(dict, item);
    return unlikely(result < 0) ? result : (result == (eq == Py_EQ));
}

/* 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

/* PyObjectCallMethod1.proto */
static PyObject* __Pyx_PyObject_CallMethod1(PyObject* obj, PyObject* method_name, PyObject* arg);

/* append.proto */
static CYTHON_INLINE int __Pyx_PyObject_Append(PyObject* L, PyObject* x);

/* DictGetItem.proto */
#if PY_MAJOR_VERSION >= 3 && !CYTHON_COMPILING_IN_PYPY
static PyObject *__Pyx_PyDict_GetItem(PyObject *d, PyObject* key);
#define __Pyx_PyObject_Dict_GetItem(obj, name)\
    (likely(PyDict_CheckExact(obj)) ?\
     __Pyx_PyDict_GetItem(obj, name) : PyObject_GetItem(obj, name))
#else
#define __Pyx_PyDict_GetItem(d, key) PyObject_GetItem(d, key)
#define __Pyx_PyObject_Dict_GetItem(obj, name)  PyObject_GetItem(obj, name)
#endif

/* pop.proto */
static CYTHON_INLINE PyObject* __Pyx__PyObject_Pop(PyObject* L);
#if CYTHON_USE_PYLIST_INTERNALS && CYTHON_ASSUME_SAFE_MACROS
static CYTHON_INLINE PyObject* __Pyx_PyList_Pop(PyObject* L);
#define __Pyx_PyObject_Pop(L) (likely(PyList_CheckExact(L)) ?\
    __Pyx_PyList_Pop(L) : __Pyx__PyObject_Pop(L))
#else
#define __Pyx_PyList_Pop(L)  __Pyx__PyObject_Pop(L)
#define __Pyx_PyObject_Pop(L)  __Pyx__PyObject_Pop(L)
#endif

/* UnpackUnboundCMethod.proto */
typedef struct {
    PyObject *type;
    PyObject **method_name;
    PyCFunction func;
    PyObject *method;
    int flag;
} __Pyx_CachedCFunction;

/* CallUnboundCMethod0.proto */
static PyObject* __Pyx__CallUnboundCMethod0(__Pyx_CachedCFunction* cfunc, PyObject* self);
#if CYTHON_COMPILING_IN_CPYTHON
#define __Pyx_CallUnboundCMethod0(cfunc, self)\
    (likely((cfunc)->func) ?\
        (likely((cfunc)->flag == METH_NOARGS) ?  (*((cfunc)->func))(self, NULL) :\
         (PY_VERSION_HEX >= 0x030600B1 && likely((cfunc)->flag == METH_FASTCALL) ?\
            (PY_VERSION_HEX >= 0x030700A0 ?\
                (*(__Pyx_PyCFunctionFast)(void*)(PyCFunction)(cfunc)->func)(self, &__pyx_empty_tuple, 0) :\
                (*(__Pyx_PyCFunctionFastWithKeywords)(void*)(PyCFunction)(cfunc)->func)(self, &__pyx_empty_tuple, 0, NULL)) :\
          (PY_VERSION_HEX >= 0x030700A0 && (cfunc)->flag == (METH_FASTCALL | METH_KEYWORDS) ?\
            (*(__Pyx_PyCFunctionFastWithKeywords)(void*)(PyCFunction)(cfunc)->func)(self, &__pyx_empty_tuple, 0, NULL) :\
            (likely((cfunc)->flag == (METH_VARARGS | METH_KEYWORDS)) ?  ((*(PyCFunctionWithKeywords)(void*)(PyCFunction)(cfunc)->func)(self, __pyx_empty_tuple, NULL)) :\
               ((cfunc)->flag == METH_VARARGS ?  (*((cfunc)->func))(self, __pyx_empty_tuple) :\
               __Pyx__CallUnboundCMethod0(cfunc, self)))))) :\
        __Pyx__CallUnboundCMethod0(cfunc, self))
#else
#define __Pyx_CallUnboundCMethod0(cfunc, self)  __Pyx__CallUnboundCMethod0(cfunc, self)
#endif

/* IterNext.proto */
#define __Pyx_PyIter_Next(obj) __Pyx_PyIter_Next2(obj, NULL)
static CYTHON_INLINE PyObject *__Pyx_PyIter_Next2(PyObject *, PyObject *);

/* 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

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

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

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

/* TypeImport.proto */
#ifndef __PYX_HAVE_RT_ImportType_proto
#define __PYX_HAVE_RT_ImportType_proto
enum __Pyx_ImportType_CheckSize {
   __Pyx_ImportType_CheckSize_Error = 0,
   __Pyx_ImportType_CheckSize_Warn = 1,
   __Pyx_ImportType_CheckSize_Ignore = 2
};
static PyTypeObject *__Pyx_ImportType(PyObject* module, const char *module_name, const char *class_name, size_t size, enum __Pyx_ImportType_CheckSize check_size);
#endif

/* 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);

/* 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

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

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

/* CIntFromPy.proto */
static CYTHON_INLINE size_t __Pyx_PyInt_As_size_t(PyObject *);

/* CIntToPy.proto */
static CYTHON_INLINE PyObject* __Pyx_PyInt_From_int(int 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);

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

static int __pyx_f_4lupa_5_lupa_10LuaRuntime_reraise_on_exception(struct __pyx_obj_4lupa_5_lupa_LuaRuntime *__pyx_v_self); /* proto*/
static int __pyx_f_4lupa_5_lupa_10LuaRuntime_store_raised_exception(struct __pyx_obj_4lupa_5_lupa_LuaRuntime *__pyx_v_self, lua_State *__pyx_v_L, PyObject *__pyx_v_lua_error_msg); /* proto*/
static int __pyx_f_4lupa_5_lupa_10LuaRuntime_register_py_object(struct __pyx_obj_4lupa_5_lupa_LuaRuntime *__pyx_v_self, PyObject *__pyx_v_cname, PyObject *__pyx_v_pyname, PyObject *__pyx_v_obj); /* proto*/
static int __pyx_f_4lupa_5_lupa_10LuaRuntime_init_python_lib(struct __pyx_obj_4lupa_5_lupa_LuaRuntime *__pyx_v_self, int __pyx_v_register_eval, int __pyx_v_register_builtins); /* proto*/
static CYTHON_INLINE int __pyx_f_4lupa_5_lupa_10_LuaObject_push_lua_object(struct __pyx_obj_4lupa_5_lupa__LuaObject *__pyx_v_self); /* proto*/
static size_t __pyx_f_4lupa_5_lupa_10_LuaObject__len(struct __pyx_obj_4lupa_5_lupa__LuaObject *__pyx_v_self); /* proto*/
static PyObject *__pyx_f_4lupa_5_lupa_10_LuaObject__getitem(struct __pyx_obj_4lupa_5_lupa__LuaObject *__pyx_v_self, PyObject *__pyx_v_name, int __pyx_v_is_attr_access); /* proto*/
static int __pyx_f_4lupa_5_lupa_9_LuaTable__setitem(struct __pyx_obj_4lupa_5_lupa__LuaTable *__pyx_v_self, PyObject *__pyx_v_name, PyObject *__pyx_v_value); /* proto*/
static PyObject *__pyx_f_4lupa_5_lupa_9_LuaTable__delitem(struct __pyx_obj_4lupa_5_lupa__LuaTable *__pyx_v_self, PyObject *__pyx_v_name); /* proto*/

/* Module declarations from 'cython' */

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

/* Module declarations from 'lupa' */

/* Module declarations from 'lupa.lua' */

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

/* Module declarations from '__builtin__' */

/* Module declarations from 'cpython.type' */
static PyTypeObject *__pyx_ptype_7cpython_4type_type = 0;

/* Module declarations from 'cpython.tuple' */

/* Module declarations from 'cpython.float' */

/* Module declarations from 'cpython.long' */

/* Module declarations from 'cpython.version' */

/* Module declarations from 'cpython.exc' */

/* Module declarations from 'cpython.module' */

/* Module declarations from 'cpython.mem' */

/* Module declarations from 'cpython.list' */

/* Module declarations from 'cpython.sequence' */

/* Module declarations from 'cpython.mapping' */

/* Module declarations from 'cpython.iterator' */

/* Module declarations from 'cpython.number' */

/* Module declarations from 'cpython.int' */

/* Module declarations from '__builtin__' */

/* Module declarations from 'cpython.bool' */
static PyTypeObject *__pyx_ptype_7cpython_4bool_bool = 0;

/* Module declarations from '__builtin__' */

/* Module declarations from 'cpython.complex' */
static PyTypeObject *__pyx_ptype_7cpython_7complex_complex = 0;

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

/* Module declarations from 'cpython.unicode' */

/* Module declarations from 'cpython.dict' */

/* Module declarations from 'cpython.instance' */

/* Module declarations from 'cpython.function' */

/* Module declarations from 'cpython.method' */

/* Module declarations from 'cpython.weakref' */

/* Module declarations from 'cpython.getargs' */

/* Module declarations from 'cpython.pythread' */

/* Module declarations from 'cpython.pystate' */

/* Module declarations from 'cpython.cobject' */

/* Module declarations from 'cpython.oldbuffer' */

/* Module declarations from 'cpython.set' */

/* Module declarations from 'cpython.buffer' */

/* Module declarations from 'cpython.bytes' */

/* Module declarations from 'cpython.pycapsule' */

/* Module declarations from 'cpython' */

/* Module declarations from 'cpython.object' */

/* Module declarations from 'cpython.ref' */

/* Module declarations from 'lupa._lupa' */
static PyTypeObject *__pyx_ptype_4lupa_5_lupa_FastRLock = 0;
static PyTypeObject *__pyx_ptype_4lupa_5_lupa_LuaRuntime = 0;
static PyTypeObject *__pyx_ptype_4lupa_5_lupa__LuaObject = 0;
static PyTypeObject *__pyx_ptype_4lupa_5_lupa__LuaTable = 0;
static PyTypeObject *__pyx_ptype_4lupa_5_lupa__LuaFunction = 0;
static PyTypeObject *__pyx_ptype_4lupa_5_lupa__LuaCoroutineFunction = 0;
static PyTypeObject *__pyx_ptype_4lupa_5_lupa__LuaThread = 0;
static PyTypeObject *__pyx_ptype_4lupa_5_lupa__LuaIter = 0;
static PyTypeObject *__pyx_ptype_4lupa_5_lupa__PyProtocolWrapper = 0;
static PyTypeObject *__pyx_ptype_4lupa_5_lupa___pyx_scope_struct__unpacks_lua_table = 0;
static PyTypeObject *__pyx_ptype_4lupa_5_lupa___pyx_scope_struct_1_unpacks_lua_table_method = 0;
static PyObject *__pyx_v_4lupa_5_lupa_exc_info = 0;
static PyObject *__pyx_v_4lupa_5_lupa_Mapping = 0;
static PyObject *__pyx_v_4lupa_5_lupa_wraps = 0;
static PyObject *__pyx_v_4lupa_5_lupa_builtins = 0;
static int __pyx_v_4lupa_5_lupa__LUA_VERSION;
static luaL_Reg *__pyx_v_4lupa_5_lupa_py_object_lib;
static luaL_Reg *__pyx_v_4lupa_5_lupa_py_lib;
static CYTHON_INLINE int __pyx_f_4lupa_5_lupa_lock_lock(struct __pyx_obj_4lupa_5_lupa_FastRLock *, long, int); /*proto*/
static int __pyx_f_4lupa_5_lupa__acquire_lock(struct __pyx_obj_4lupa_5_lupa_FastRLock *, long, int); /*proto*/
static CYTHON_INLINE void __pyx_f_4lupa_5_lupa_unlock_lock(struct __pyx_obj_4lupa_5_lupa_FastRLock *); /*proto*/
static PyObject *__pyx_f_4lupa_5_lupa__fix_args_kwargs(PyObject *); /*proto*/
static CYTHON_INLINE int __pyx_f_4lupa_5_lupa_lock_runtime(struct __pyx_obj_4lupa_5_lupa_LuaRuntime *); /*proto*/
static CYTHON_INLINE void __pyx_f_4lupa_5_lupa_unlock_runtime(struct __pyx_obj_4lupa_5_lupa_LuaRuntime *); /*proto*/
static struct __pyx_obj_4lupa_5_lupa__LuaObject *__pyx_f_4lupa_5_lupa_new_lua_object(struct __pyx_obj_4lupa_5_lupa_LuaRuntime *, lua_State *, int); /*proto*/
static void __pyx_f_4lupa_5_lupa_init_lua_object(struct __pyx_obj_4lupa_5_lupa__LuaObject *, struct __pyx_obj_4lupa_5_lupa_LuaRuntime *, lua_State *, int); /*proto*/
static PyObject *__pyx_f_4lupa_5_lupa_lua_object_repr(lua_State *, PyObject *); /*proto*/
static struct __pyx_obj_4lupa_5_lupa__LuaTable *__pyx_f_4lupa_5_lupa_new_lua_table(struct __pyx_obj_4lupa_5_lupa_LuaRuntime *, lua_State *, int); /*proto*/
static struct __pyx_obj_4lupa_5_lupa__LuaFunction *__pyx_f_4lupa_5_lupa_new_lua_function(struct __pyx_obj_4lupa_5_lupa_LuaRuntime *, lua_State *, int); /*proto*/
static struct __pyx_obj_4lupa_5_lupa__LuaCoroutineFunction *__pyx_f_4lupa_5_lupa_new_lua_coroutine_function(struct __pyx_obj_4lupa_5_lupa_LuaRuntime *, lua_State *, int); /*proto*/
static struct __pyx_obj_4lupa_5_lupa__LuaThread *__pyx_f_4lupa_5_lupa_new_lua_thread(struct __pyx_obj_4lupa_5_lupa_LuaRuntime *, lua_State *, int); /*proto*/
static struct __pyx_obj_4lupa_5_lupa__LuaObject *__pyx_f_4lupa_5_lupa_new_lua_thread_or_function(struct __pyx_obj_4lupa_5_lupa_LuaRuntime *, lua_State *, int); /*proto*/
static PyObject *__pyx_f_4lupa_5_lupa_resume_lua_thread(struct __pyx_obj_4lupa_5_lupa__LuaThread *, PyObject *); /*proto*/
static int __pyx_f_4lupa_5_lupa_py_asfunc_call(lua_State *); /*proto*/
static struct __pyx_t_4lupa_5_lupa_py_object *__pyx_f_4lupa_5_lupa_unpack_wrapped_pyfunction(lua_State *, int); /*proto*/
static PyObject *__pyx_f_4lupa_5_lupa_py_from_lua(struct __pyx_obj_4lupa_5_lupa_LuaRuntime *, lua_State *, int); /*proto*/
static struct __pyx_t_4lupa_5_lupa_py_object *__pyx_f_4lupa_5_lupa_unpack_userdata(lua_State *, int); /*proto*/
static int __pyx_f_4lupa_5_lupa_py_function_result_to_lua(struct __pyx_obj_4lupa_5_lupa_LuaRuntime *, lua_State *, PyObject *); /*proto*/
static int __pyx_f_4lupa_5_lupa_py_to_lua(struct __pyx_obj_4lupa_5_lupa_LuaRuntime *, lua_State *, PyObject *, struct __pyx_opt_args_4lupa_5_lupa_py_to_lua *__pyx_optional_args); /*proto*/
static int __pyx_f_4lupa_5_lupa_push_encoded_unicode_string(struct __pyx_obj_4lupa_5_lupa_LuaRuntime *, lua_State *, PyObject *); /*proto*/
static int __pyx_f_4lupa_5_lupa_py_to_lua_custom(struct __pyx_obj_4lupa_5_lupa_LuaRuntime *, lua_State *, PyObject *, int); /*proto*/
static CYTHON_INLINE int __pyx_f_4lupa_5_lupa__isascii(unsigned char *); /*proto*/
static PyObject *__pyx_f_4lupa_5_lupa__asciiOrNone(PyObject *); /*proto*/
static int __pyx_f_4lupa_5_lupa_raise_lua_error(struct __pyx_obj_4lupa_5_lupa_LuaRuntime *, lua_State *, int); /*proto*/
static PyObject *__pyx_f_4lupa_5_lupa_build_lua_error_message(struct __pyx_obj_4lupa_5_lupa_LuaRuntime *, lua_State *, PyObject *, int); /*proto*/
static PyObject *__pyx_f_4lupa_5_lupa_run_lua(struct __pyx_obj_4lupa_5_lupa_LuaRuntime *, PyObject *, PyObject *); /*proto*/
static PyObject *__pyx_f_4lupa_5_lupa_call_lua(struct __pyx_obj_4lupa_5_lupa_LuaRuntime *, lua_State *, PyObject *); /*proto*/
static PyObject *__pyx_f_4lupa_5_lupa_execute_lua_call(struct __pyx_obj_4lupa_5_lupa_LuaRuntime *, lua_State *, Py_ssize_t); /*proto*/
static int __pyx_f_4lupa_5_lupa_push_lua_arguments(struct __pyx_obj_4lupa_5_lupa_LuaRuntime *, lua_State *, PyObject *, struct __pyx_opt_args_4lupa_5_lupa_push_lua_arguments *__pyx_optional_args); /*proto*/
static CYTHON_INLINE PyObject *__pyx_f_4lupa_5_lupa_unpack_lua_results(struct __pyx_obj_4lupa_5_lupa_LuaRuntime *, lua_State *); /*proto*/
static PyObject *__pyx_f_4lupa_5_lupa_unpack_multiple_lua_results(struct __pyx_obj_4lupa_5_lupa_LuaRuntime *, lua_State *, int); /*proto*/
static int __pyx_f_4lupa_5_lupa_decref_with_gil(struct __pyx_t_4lupa_5_lupa_py_object *, lua_State *); /*proto*/
static int __pyx_f_4lupa_5_lupa_py_object_gc(lua_State *); /*proto*/
static int __pyx_f_4lupa_5_lupa_call_python(struct __pyx_obj_4lupa_5_lupa_LuaRuntime *, lua_State *, struct __pyx_t_4lupa_5_lupa_py_object *); /*proto*/
static int __pyx_f_4lupa_5_lupa_py_call_with_gil(lua_State *, struct __pyx_t_4lupa_5_lupa_py_object *); /*proto*/
static int __pyx_f_4lupa_5_lupa_py_object_call(lua_State *); /*proto*/
static int __pyx_f_4lupa_5_lupa_py_str_with_gil(lua_State *, struct __pyx_t_4lupa_5_lupa_py_object *); /*proto*/
static int __pyx_f_4lupa_5_lupa_py_object_str(lua_State *); /*proto*/
static int __pyx_f_4lupa_5_lupa_getitem_for_lua(struct __pyx_obj_4lupa_5_lupa_LuaRuntime *, lua_State *, struct __pyx_t_4lupa_5_lupa_py_object *, int); /*proto*/
static int __pyx_f_4lupa_5_lupa_setitem_for_lua(struct __pyx_obj_4lupa_5_lupa_LuaRuntime *, lua_State *, struct __pyx_t_4lupa_5_lupa_py_object *, int, int); /*proto*/
static int __pyx_f_4lupa_5_lupa_getattr_for_lua(struct __pyx_obj_4lupa_5_lupa_LuaRuntime *, lua_State *, struct __pyx_t_4lupa_5_lupa_py_object *, int); /*proto*/
static int __pyx_f_4lupa_5_lupa_setattr_for_lua(struct __pyx_obj_4lupa_5_lupa_LuaRuntime *, lua_State *, struct __pyx_t_4lupa_5_lupa_py_object *, int, int); /*proto*/
static int __pyx_f_4lupa_5_lupa_py_object_getindex_with_gil(lua_State *, struct __pyx_t_4lupa_5_lupa_py_object *); /*proto*/
static int __pyx_f_4lupa_5_lupa_py_object_getindex(lua_State *); /*proto*/
static int __pyx_f_4lupa_5_lupa_py_object_setindex_with_gil(lua_State *, struct __pyx_t_4lupa_5_lupa_py_object *); /*proto*/
static int __pyx_f_4lupa_5_lupa_py_object_setindex(lua_State *); /*proto*/
static CYTHON_INLINE struct __pyx_t_4lupa_5_lupa_py_object *__pyx_f_4lupa_5_lupa_unpack_single_python_argument_or_jump(lua_State *); /*proto*/
static struct __pyx_t_4lupa_5_lupa_py_object *__pyx_f_4lupa_5_lupa_unwrap_lua_object(lua_State *, int); /*proto*/
static int __pyx_f_4lupa_5_lupa_py_wrap_object_protocol_with_gil(lua_State *, struct __pyx_t_4lupa_5_lupa_py_object *, int); /*proto*/
static int __pyx_f_4lupa_5_lupa_py_wrap_object_protocol(lua_State *, int); /*proto*/
static int __pyx_f_4lupa_5_lupa_py_as_attrgetter(lua_State *); /*proto*/
static int __pyx_f_4lupa_5_lupa_py_as_itemgetter(lua_State *); /*proto*/
static int __pyx_f_4lupa_5_lupa_py_as_function(lua_State *); /*proto*/
static int __pyx_f_4lupa_5_lupa_py_iter(lua_State *); /*proto*/
static int __pyx_f_4lupa_5_lupa_py_iterex(lua_State *); /*proto*/
static int __pyx_f_4lupa_5_lupa_py_enumerate(lua_State *); /*proto*/
static int __pyx_f_4lupa_5_lupa_py_enumerate_with_gil(lua_State *, struct __pyx_t_4lupa_5_lupa_py_object *, double); /*proto*/
static int __pyx_f_4lupa_5_lupa_py_iter_with_gil(lua_State *, struct __pyx_t_4lupa_5_lupa_py_object *, int); /*proto*/
static int __pyx_f_4lupa_5_lupa_py_push_iterator(struct __pyx_obj_4lupa_5_lupa_LuaRuntime *, lua_State *, PyObject *, int, lua_Number); /*proto*/
static int __pyx_f_4lupa_5_lupa_py_iter_next(lua_State *); /*proto*/
static int __pyx_f_4lupa_5_lupa_py_iter_next_with_gil(lua_State *, struct __pyx_t_4lupa_5_lupa_py_object *); /*proto*/
static void __pyx_f_4lupa_5_lupa_luaL_setfuncs(lua_State *, luaL_Reg const *, int); /*proto*/
static int __pyx_f_4lupa_5_lupa_libsize(luaL_Reg const *); /*proto*/
static char const *__pyx_f_4lupa_5_lupa_luaL_findtable(lua_State *, int, char const *, int); /*proto*/
static void __pyx_f_4lupa_5_lupa_luaL_pushmodule(lua_State *, char const *, int); /*proto*/
static void __pyx_f_4lupa_5_lupa_luaL_openlib(lua_State *, char const *, luaL_Reg const *, int); /*proto*/
#define __Pyx_MODULE_NAME "lupa._lupa"
extern int __pyx_module_is_main_lupa___lupa;
int __pyx_module_is_main_lupa___lupa = 0;

/* Implementation of 'lupa._lupa' */
static PyObject *__pyx_builtin_ImportError;
static PyObject *__pyx_builtin_MemoryError;
static PyObject *__pyx_builtin_RuntimeError;
static PyObject *__pyx_builtin_TypeError;
static PyObject *__pyx_builtin_ValueError;
static PyObject *__pyx_builtin_eval;
static PyObject *__pyx_builtin_range;
static PyObject *__pyx_builtin_UnicodeDecodeError;
static PyObject *__pyx_builtin_object;
static PyObject *__pyx_builtin_AttributeError;
static PyObject *__pyx_builtin_StopIteration;
static PyObject *__pyx_builtin_BaseException;
static PyObject *__pyx_builtin_enumerate;
static PyObject *__pyx_builtin_KeyError;
static const char __pyx_k_L[] = "L";
static const char __pyx_k_i[] = "i";
static const char __pyx_k_t[] = "t";
static const char __pyx_k_v[] = "v";
static const char __pyx_k_co[] = "co";
static const char __pyx_k_tb[] = "tb";
static const char __pyx_k__16[] = "__";
static const char __pyx_k_all[] = "__all__";
static const char __pyx_k_arg[] = "arg";
static const char __pyx_k_doc[] = "__doc__";
static const char __pyx_k_err[] = "err";
static const char __pyx_k_key[] = "key";
static const char __pyx_k_obj[] = "obj";
static const char __pyx_k_pop[] = "pop";
static const char __pyx_k_sys[] = "sys";
static const char __pyx_k_args[] = "args";
static const char __pyx_k_eval[] = "eval";
static const char __pyx_k_exit[] = "__exit__";
static const char __pyx_k_func[] = "func";
static const char __pyx_k_keys[] = "keys";
static const char __pyx_k_main[] = "__main__";
static const char __pyx_k_meth[] = "meth";
static const char __pyx_k_name[] = "__name__";
static const char __pyx_k_none[] = "none";
static const char __pyx_k_self[] = "self";
static const char __pyx_k_send[] = "send";
static const char __pyx_k_size[] = "size";
static const char __pyx_k_test[] = "__test__";
static const char __pyx_k_what[] = "what";
static const char __pyx_k_wrap[] = "wrap";
static const char __pyx_k_UTF_8[] = "UTF-8";
static const char __pyx_k_enter[] = "__enter__";
static const char __pyx_k_error[] = "error";
static const char __pyx_k_items[] = "items";
static const char __pyx_k_ltype[] = "ltype";
static const char __pyx_k_range[] = "range";
static const char __pyx_k_table[] = "table";
static const char __pyx_k_value[] = "value";
static const char __pyx_k_wraps[] = "wraps";
static const char __pyx_k_append[] = "append";
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_name_2[] = "name";
static const char __pyx_k_object[] = "object";
static const char __pyx_k_oldtop[] = "oldtop";
static const char __pyx_k_reduce[] = "__reduce__";
static const char __pyx_k_return[] = "return ";
static const char __pyx_k_status[] = "status";
static const char __pyx_k_thread[] = "thread";
static const char __pyx_k_values[] = "values";
static const char __pyx_k_Mapping[] = "Mapping";
static const char __pyx_k_Py_None[] = "Py_None";
static const char __pyx_k_acquire[] = "acquire";
static const char __pyx_k_builtin[] = "__builtin__";
static const char __pyx_k_compile[] = "compile";
static const char __pyx_k_delattr[] = "__delattr__";
static const char __pyx_k_execute[] = "execute";
static const char __pyx_k_getattr[] = "__getattr__";
static const char __pyx_k_getitem[] = "__getitem__";
static const char __pyx_k_globals[] = "globals";
static const char __pyx_k_old_top[] = "old_top";
static const char __pyx_k_prepare[] = "__prepare__";
static const char __pyx_k_release[] = "release";
static const char __pyx_k_require[] = "require";
static const char __pyx_k_setattr[] = "__setattr__";
static const char __pyx_k_wrapper[] = "wrapper";
static const char __pyx_k_KeyError[] = "KeyError";
static const char __pyx_k_LuaError[] = "LuaError";
static const char __pyx_k_blocking[] = "blocking";
static const char __pyx_k_builtins[] = "builtins";
static const char __pyx_k_encoding[] = "encoding";
static const char __pyx_k_exc_info[] = "exc_info";
static const char __pyx_k_function[] = "function";
static const char __pyx_k_getstate[] = "__getstate__";
static const char __pyx_k_is_owned[] = "_is_owned";
static const char __pyx_k_lua_code[] = "lua_code";
static const char __pyx_k_lua_type[] = "lua_type";
static const char __pyx_k_qualname[] = "__qualname__";
static const char __pyx_k_setstate[] = "__setstate__";
static const char __pyx_k_userdata[] = "userdata";
static const char __pyx_k_FastRLock[] = "FastRLock";
static const char __pyx_k_LuaIter_r[] = "LuaIter(%r)";
static const char __pyx_k_TypeError[] = "TypeError";
static const char __pyx_k_coroutine[] = "coroutine";
static const char __pyx_k_enumerate[] = "enumerate";
static const char __pyx_k_functools[] = "functools";
static const char __pyx_k_iteritems[] = "iteritems";
static const char __pyx_k_metaclass[] = "__metaclass__";
static const char __pyx_k_pyx_state[] = "__pyx_state";
static const char __pyx_k_reduce_ex[] = "__reduce_ex__";
static const char __pyx_k_LuaRuntime[] = "LuaRuntime";
static const char __pyx_k_ValueError[] = "ValueError";
static const char __pyx_k_lua_object[] = "lua_object";
static const char __pyx_k_lupa__lupa[] = "lupa._lupa";
static const char __pyx_k_modulename[] = "modulename";
static const char __pyx_k_pyx_vtable[] = "__pyx_vtable__";
static const char __pyx_k_table_from[] = "table_from";
static const char __pyx_k_ImportError[] = "ImportError";
static const char __pyx_k_LUA_VERSION[] = "LUA_VERSION";
static const char __pyx_k_MemoryError[] = "MemoryError";
static const char __pyx_k_collections[] = "collections";
static const char __pyx_k_RuntimeError[] = "RuntimeError";
static const char __pyx_k_stringsource[] = "stringsource";
static const char __pyx_k_BaseException[] = "BaseException";
static const char __pyx_k_LuaTable_keys[] = "_LuaTable.keys";
static const char __pyx_k_StopIteration[] = "StopIteration";
static const char __pyx_k_as_attrgetter[] = "as_attrgetter";
static const char __pyx_k_as_itemgetter[] = "as_itemgetter";
static const char __pyx_k_lua_type_name[] = "lua_type_name";
static const char __pyx_k_lupa_lock_pxi[] = "lupa/lock.pxi";
static const char __pyx_k_reduce_cython[] = "__reduce_cython__";
static const char __pyx_k_register_eval[] = "register_eval";
static const char __pyx_k_AttributeError[] = "AttributeError";
static const char __pyx_k_LuaSyntaxError[] = "LuaSyntaxError";
static const char __pyx_k_LuaTable_items[] = "_LuaTable.items";
static const char __pyx_k_LuaThread_send[] = "_LuaThread.send";
static const char __pyx_k_lost_reference[] = "lost reference";
static const char __pyx_k_lupa__lupa_pyx[] = "lupa/_lupa.pyx";
static const char __pyx_k_LuaRuntime_eval[] = "LuaRuntime.eval";
static const char __pyx_k_LuaTable_values[] = "_LuaTable.values";
static const char __pyx_k_collections_abc[] = "collections.abc";
static const char __pyx_k_setstate_cython[] = "__setstate_cython__";
static const char __pyx_k_source_encoding[] = "source_encoding";
static const char __pyx_k_FastRLock___exit[] = "FastRLock.__exit__";
static const char __pyx_k_LuaRuntime_table[] = "LuaRuntime.table";
static const char __pyx_k_attribute_filter[] = "attribute_filter";
static const char __pyx_k_FastRLock___enter[] = "FastRLock.__enter__";
static const char __pyx_k_FastRLock_acquire[] = "FastRLock.acquire";
static const char __pyx_k_FastRLock_release[] = "FastRLock.release";
static const char __pyx_k_register_builtins[] = "register_builtins";
static const char __pyx_k_unpacks_lua_table[] = "unpacks_lua_table";
static const char __pyx_k_LuaRuntime_compile[] = "LuaRuntime.compile";
static const char __pyx_k_LuaRuntime_execute[] = "LuaRuntime.execute";
static const char __pyx_k_LuaRuntime_globals[] = "LuaRuntime.globals";
static const char __pyx_k_LuaRuntime_require[] = "LuaRuntime.require";
static const char __pyx_k_UnicodeDecodeError[] = "UnicodeDecodeError";
static const char __pyx_k_attribute_handlers[] = "attribute_handlers";
static const char __pyx_k_cline_in_traceback[] = "cline_in_traceback";
static const char __pyx_k_FastRLock__is_owned[] = "FastRLock._is_owned";
static const char __pyx_k_globals_not_defined[] = "globals not defined";
static const char __pyx_k_not_a_python_object[] = "not a python object";
static const char __pyx_k_error_loading_code_s[] = "error loading code: %s";
static const char __pyx_k_LuaFunction_coroutine[] = "_LuaFunction.coroutine";
static const char __pyx_k_LuaRuntime_table_from[] = "LuaRuntime.table_from";
static const char __pyx_k_expected_string_got_s[] = "expected string, got %s";
static const char __pyx_k_require_is_not_defined[] = "require is not defined";
static const char __pyx_k_unpack_returned_tuples[] = "unpack_returned_tuples";
static const char __pyx_k_LuaIter___reduce_cython[] = "_LuaIter.__reduce_cython__";
static const char __pyx_k_LuaTable___reduce_cython[] = "_LuaTable.__reduce_cython__";
static const char __pyx_k_Syntax_error_in_Lua_code[] = "Syntax error in Lua code.\n    ";
static const char __pyx_k_error_during_Python_call[] = "error during Python call";
static const char __pyx_k_unpacks_lua_table_method[] = "unpacks_lua_table_method";
static const char __pyx_k_FastRLock___reduce_cython[] = "FastRLock.__reduce_cython__";
static const char __pyx_k_LuaIter___setstate_cython[] = "_LuaIter.__setstate_cython__";
static const char __pyx_k_LuaObject___reduce_cython[] = "_LuaObject.__reduce_cython__";
static const char __pyx_k_LuaThread___reduce_cython[] = "_LuaThread.__reduce_cython__";
static const char __pyx_k_LuaRuntime___reduce_cython[] = "LuaRuntime.__reduce_cython__";
static const char __pyx_k_LuaTable___setstate_cython[] = "_LuaTable.__setstate_cython__";
static const char __pyx_k_error_creating_an_iterator[] = "error creating an iterator";
static const char __pyx_k_failed_to_convert_s_object[] = "failed to convert %s object";
static const char __pyx_k_FastRLock___setstate_cython[] = "FastRLock.__setstate_cython__";
static const char __pyx_k_LuaFunction___reduce_cython[] = "_LuaFunction.__reduce_cython__";
static const char __pyx_k_LuaObject___setstate_cython[] = "_LuaObject.__setstate_cython__";
static const char __pyx_k_LuaThread___setstate_cython[] = "_LuaThread.__setstate_cython__";
static const char __pyx_k_modulename_must_be_a_string[] = "modulename must be a string";
static const char __pyx_k_LuaRuntime___setstate_cython[] = "LuaRuntime.__setstate_cython__";
static const char __pyx_k_Lua_object_is_not_a_function[] = "Lua object is not a function";
static const char __pyx_k_error_during_Python_str_call[] = "error during Python str() call";
static const char __pyx_k_Failed_to_acquire_thread_lock[] = "Failed to acquire thread lock";
static const char __pyx_k_LuaFunction___setstate_cython[] = "_LuaFunction.__setstate_cython__";
static const char __pyx_k_A_fast_Python_wrapper_around_Lu[] = "\nA fast Python wrapper around Lua and LuaJIT2.\n";
static const char __pyx_k_LuaCoroutineFunction___reduce_c[] = "_LuaCoroutineFunction.__reduce_cython__";
static const char __pyx_k_LuaCoroutineFunction___setstate[] = "_LuaCoroutineFunction.__setstate_cython__";
static const char __pyx_k_PyProtocolWrapper___reduce_cyth[] = "_PyProtocolWrapper.__reduce_cython__";
static const char __pyx_k_PyProtocolWrapper___setstate_cy[] = "_PyProtocolWrapper.__setstate_cython__";
static const char __pyx_k_cannot_release_un_acquired_lock[] = "cannot release un-acquired lock";
static const char __pyx_k_error_creating_an_iterator_with[] = "error creating an iterator with enumerate()";
static const char __pyx_k_function_if_type_jit_table_then[] = "(function ()     if type(jit) == 'table' then return jit.version else return _VERSION end end)()";
static const char __pyx_k_iteration_is_only_supported_for[] = "iteration is only supported for tables";
static const char __pyx_k_self__state_cannot_be_converted[] = "self._state cannot be converted to a Python object for pickling";
static const char __pyx_k_unpacks_lua_table_method_locals[] = "unpacks_lua_table_method.<locals>.wrapper";
static const char __pyx_k_Base_class_for_errors_in_the_Lua[] = "Base class for errors in the Lua runtime.\n    ";
static const char __pyx_k_Failed_to_initialise_Lua_runtime[] = "Failed to initialise Lua runtime";
static const char __pyx_k_Type_cannot_be_instantiated_from[] = "Type cannot be instantiated from Python";
static const char __pyx_k_Type_cannot_be_instantiated_manu[] = "Type cannot be instantiated manually";
static const char __pyx_k_attribute_filter_and_attribute_h[] = "attribute_filter and attribute_handlers are mutually exclusive";
static const char __pyx_k_attribute_filter_must_be_callabl[] = "attribute_filter must be callable";
static const char __pyx_k_attribute_handlers_must_be_a_seq[] = "attribute_handlers must be a sequence of two callables";
static const char __pyx_k_byte_string_input_has_unknown_en[] = "byte string input has unknown encoding, only ASCII is allowed";
static const char __pyx_k_can_t_send_non_None_value_to_a_j[] = "can't send non-None value to a just-started generator";
static const char __pyx_k_cannot_iterate_over_non_table_fo[] = "cannot iterate over non-table (found %r)";
static const char __pyx_k_cannot_mix_objects_from_differen[] = "cannot mix objects from different Lua runtimes";
static const char __pyx_k_error_reading_Python_attribute_i[] = "error reading Python attribute/item";
static const char __pyx_k_error_while_calling_next_iterato[] = "error while calling next(iterator)";
static const char __pyx_k_error_while_cleaning_up_a_Python[] = "error while cleaning up a Python object";
static const char __pyx_k_error_writing_Python_attribute_i[] = "error writing Python attribute/item";
static const char __pyx_k_failed_to_convert_argument_at_in[] = "failed to convert argument at index %d";
static const char __pyx_k_item_attribute_access_not_suppor[] = "item/attribute access not supported on functions";
static const char __pyx_k_no_default___reduce___due_to_non[] = "no default __reduce__ due to non-trivial __cinit__";
static const char __pyx_k_self__co_state_self__state_canno[] = "self._co_state,self._state cannot be converted to a Python object for pickling";
static const char __pyx_k_unpacks_lua_table_locals_wrapper[] = "unpacks_lua_table.<locals>.wrapper";
static PyObject *__pyx_n_s_AttributeError;
static PyObject *__pyx_n_s_BaseException;
static PyObject *__pyx_kp_s_Base_class_for_errors_in_the_Lua;
static PyObject *__pyx_kp_s_Failed_to_acquire_thread_lock;
static PyObject *__pyx_kp_s_Failed_to_initialise_Lua_runtime;
static PyObject *__pyx_n_s_FastRLock;
static PyObject *__pyx_n_s_FastRLock___enter;
static PyObject *__pyx_n_s_FastRLock___exit;
static PyObject *__pyx_n_s_FastRLock___reduce_cython;
static PyObject *__pyx_n_s_FastRLock___setstate_cython;
static PyObject *__pyx_n_s_FastRLock__is_owned;
static PyObject *__pyx_n_s_FastRLock_acquire;
static PyObject *__pyx_n_s_FastRLock_release;
static PyObject *__pyx_n_s_ImportError;
static PyObject *__pyx_n_s_KeyError;
static PyObject *__pyx_n_s_L;
static PyObject *__pyx_n_s_LUA_VERSION;
static PyObject *__pyx_n_s_LuaCoroutineFunction___reduce_c;
static PyObject *__pyx_n_s_LuaCoroutineFunction___setstate;
static PyObject *__pyx_n_s_LuaError;
static PyObject *__pyx_n_s_LuaFunction___reduce_cython;
static PyObject *__pyx_n_s_LuaFunction___setstate_cython;
static PyObject *__pyx_n_s_LuaFunction_coroutine;
static PyObject *__pyx_n_s_LuaIter___reduce_cython;
static PyObject *__pyx_n_s_LuaIter___setstate_cython;
static PyObject *__pyx_kp_u_LuaIter_r;
static PyObject *__pyx_n_s_LuaObject___reduce_cython;
static PyObject *__pyx_n_s_LuaObject___setstate_cython;
static PyObject *__pyx_n_s_LuaRuntime;
static PyObject *__pyx_n_s_LuaRuntime___reduce_cython;
static PyObject *__pyx_n_s_LuaRuntime___setstate_cython;
static PyObject *__pyx_n_s_LuaRuntime_compile;
static PyObject *__pyx_n_s_LuaRuntime_eval;
static PyObject *__pyx_n_s_LuaRuntime_execute;
static PyObject *__pyx_n_s_LuaRuntime_globals;
static PyObject *__pyx_n_s_LuaRuntime_require;
static PyObject *__pyx_n_s_LuaRuntime_table;
static PyObject *__pyx_n_s_LuaRuntime_table_from;
static PyObject *__pyx_n_s_LuaSyntaxError;
static PyObject *__pyx_n_s_LuaTable___reduce_cython;
static PyObject *__pyx_n_s_LuaTable___setstate_cython;
static PyObject *__pyx_n_s_LuaTable_items;
static PyObject *__pyx_n_s_LuaTable_keys;
static PyObject *__pyx_n_s_LuaTable_values;
static PyObject *__pyx_n_s_LuaThread___reduce_cython;
static PyObject *__pyx_n_s_LuaThread___setstate_cython;
static PyObject *__pyx_n_s_LuaThread_send;
static PyObject *__pyx_kp_s_Lua_object_is_not_a_function;
static PyObject *__pyx_n_s_Mapping;
static PyObject *__pyx_n_s_MemoryError;
static PyObject *__pyx_n_s_PyProtocolWrapper___reduce_cyth;
static PyObject *__pyx_n_s_PyProtocolWrapper___setstate_cy;
static PyObject *__pyx_n_b_Py_None;
static PyObject *__pyx_n_s_RuntimeError;
static PyObject *__pyx_n_s_StopIteration;
static PyObject *__pyx_kp_s_Syntax_error_in_Lua_code;
static PyObject *__pyx_n_s_TypeError;
static PyObject *__pyx_kp_s_Type_cannot_be_instantiated_from;
static PyObject *__pyx_kp_s_Type_cannot_be_instantiated_manu;
static PyObject *__pyx_kp_b_UTF_8;
static PyObject *__pyx_kp_s_UTF_8;
static PyObject *__pyx_n_s_UnicodeDecodeError;
static PyObject *__pyx_n_s_ValueError;
static PyObject *__pyx_n_b__16;
static PyObject *__pyx_n_u__16;
static PyObject *__pyx_n_s_acquire;
static PyObject *__pyx_n_s_all;
static PyObject *__pyx_n_s_append;
static PyObject *__pyx_n_s_arg;
static PyObject *__pyx_n_s_args;
static PyObject *__pyx_n_s_as_attrgetter;
static PyObject *__pyx_n_s_as_itemgetter;
static PyObject *__pyx_n_s_attribute_filter;
static PyObject *__pyx_kp_s_attribute_filter_and_attribute_h;
static PyObject *__pyx_kp_s_attribute_filter_must_be_callabl;
static PyObject *__pyx_n_s_attribute_handlers;
static PyObject *__pyx_kp_s_attribute_handlers_must_be_a_seq;
static PyObject *__pyx_n_s_blocking;
static PyObject *__pyx_n_s_builtin;
static PyObject *__pyx_n_b_builtins;
static PyObject *__pyx_n_s_builtins;
static PyObject *__pyx_kp_s_byte_string_input_has_unknown_en;
static PyObject *__pyx_kp_s_can_t_send_non_None_value_to_a_j;
static PyObject *__pyx_kp_s_cannot_iterate_over_non_table_fo;
static PyObject *__pyx_kp_s_cannot_mix_objects_from_differen;
static PyObject *__pyx_kp_s_cannot_release_un_acquired_lock;
static PyObject *__pyx_n_s_cline_in_traceback;
static PyObject *__pyx_n_s_co;
static PyObject *__pyx_n_s_collections;
static PyObject *__pyx_n_s_collections_abc;
static PyObject *__pyx_n_s_compile;
static PyObject *__pyx_n_s_coroutine;
static PyObject *__pyx_n_s_delattr;
static PyObject *__pyx_n_s_doc;
static PyObject *__pyx_n_s_encoding;
static PyObject *__pyx_n_s_enter;
static PyObject *__pyx_n_s_enumerate;
static PyObject *__pyx_n_s_err;
static PyObject *__pyx_n_s_error;
static PyObject *__pyx_kp_b_error_creating_an_iterator;
static PyObject *__pyx_kp_b_error_creating_an_iterator_with;
static PyObject *__pyx_kp_b_error_during_Python_call;
static PyObject *__pyx_kp_b_error_during_Python_str_call;
static PyObject *__pyx_kp_u_error_loading_code_s;
static PyObject *__pyx_kp_b_error_reading_Python_attribute_i;
static PyObject *__pyx_kp_b_error_while_calling_next_iterato;
static PyObject *__pyx_kp_b_error_while_cleaning_up_a_Python;
static PyObject *__pyx_kp_b_error_writing_Python_attribute_i;
static PyObject *__pyx_n_b_eval;
static PyObject *__pyx_n_s_eval;
static PyObject *__pyx_n_s_exc_info;
static PyObject *__pyx_n_s_execute;
static PyObject *__pyx_n_s_exit;
static PyObject *__pyx_kp_s_expected_string_got_s;
static PyObject *__pyx_kp_s_failed_to_convert_argument_at_in;
static PyObject *__pyx_kp_s_failed_to_convert_s_object;
static PyObject *__pyx_n_s_func;
static PyObject *__pyx_n_s_function;
static PyObject *__pyx_kp_s_function_if_type_jit_table_then;
static PyObject *__pyx_n_s_functools;
static PyObject *__pyx_n_s_getattr;
static PyObject *__pyx_n_s_getitem;
static PyObject *__pyx_n_s_getstate;
static PyObject *__pyx_n_s_globals;
static PyObject *__pyx_kp_s_globals_not_defined;
static PyObject *__pyx_n_s_i;
static PyObject *__pyx_n_s_import;
static PyObject *__pyx_n_s_is_owned;
static PyObject *__pyx_kp_s_item_attribute_access_not_suppor;
static PyObject *__pyx_n_s_items;
static PyObject *__pyx_kp_s_iteration_is_only_supported_for;
static PyObject *__pyx_n_s_iteritems;
static PyObject *__pyx_n_s_key;
static PyObject *__pyx_n_s_keys;
static PyObject *__pyx_n_s_kwargs;
static PyObject *__pyx_kp_s_lost_reference;
static PyObject *__pyx_n_s_ltype;
static PyObject *__pyx_n_s_lua_code;
static PyObject *__pyx_n_s_lua_object;
static PyObject *__pyx_n_s_lua_type;
static PyObject *__pyx_n_s_lua_type_name;
static PyObject *__pyx_n_s_lupa__lupa;
static PyObject *__pyx_kp_s_lupa__lupa_pyx;
static PyObject *__pyx_kp_s_lupa_lock_pxi;
static PyObject *__pyx_n_s_main;
static PyObject *__pyx_n_s_metaclass;
static PyObject *__pyx_n_s_meth;
static PyObject *__pyx_n_s_module;
static PyObject *__pyx_n_s_modulename;
static PyObject *__pyx_kp_s_modulename_must_be_a_string;
static PyObject *__pyx_n_s_name;
static PyObject *__pyx_n_s_name_2;
static PyObject *__pyx_kp_s_no_default___reduce___due_to_non;
static PyObject *__pyx_n_b_none;
static PyObject *__pyx_kp_s_not_a_python_object;
static PyObject *__pyx_n_s_obj;
static PyObject *__pyx_n_s_object;
static PyObject *__pyx_n_s_old_top;
static PyObject *__pyx_n_s_oldtop;
static PyObject *__pyx_n_s_pop;
static PyObject *__pyx_n_s_prepare;
static PyObject *__pyx_n_s_pyx_state;
static PyObject *__pyx_n_s_pyx_vtable;
static PyObject *__pyx_n_s_qualname;
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_register_builtins;
static PyObject *__pyx_n_s_register_eval;
static PyObject *__pyx_n_s_release;
static PyObject *__pyx_n_s_require;
static PyObject *__pyx_kp_s_require_is_not_defined;
static PyObject *__pyx_kp_b_return;
static PyObject *__pyx_n_s_self;
static PyObject *__pyx_kp_s_self__co_state_self__state_canno;
static PyObject *__pyx_kp_s_self__state_cannot_be_converted;
static PyObject *__pyx_n_s_send;
static PyObject *__pyx_n_s_setattr;
static PyObject *__pyx_n_s_setstate;
static PyObject *__pyx_n_s_setstate_cython;
static PyObject *__pyx_n_s_size;
static PyObject *__pyx_n_s_source_encoding;
static PyObject *__pyx_n_s_status;
static PyObject *__pyx_kp_s_stringsource;
static PyObject *__pyx_n_s_sys;
static PyObject *__pyx_n_s_t;
static PyObject *__pyx_n_s_table;
static PyObject *__pyx_n_s_table_from;
static PyObject *__pyx_n_s_tb;
static PyObject *__pyx_n_s_test;
static PyObject *__pyx_n_s_thread;
static PyObject *__pyx_n_s_unpack_returned_tuples;
static PyObject *__pyx_n_s_unpacks_lua_table;
static PyObject *__pyx_n_s_unpacks_lua_table_locals_wrapper;
static PyObject *__pyx_n_s_unpacks_lua_table_method;
static PyObject *__pyx_n_s_unpacks_lua_table_method_locals;
static PyObject *__pyx_n_s_userdata;
static PyObject *__pyx_n_s_v;
static PyObject *__pyx_n_s_value;
static PyObject *__pyx_n_s_values;
static PyObject *__pyx_n_s_what;
static PyObject *__pyx_n_s_wrap;
static PyObject *__pyx_n_s_wrapper;
static PyObject *__pyx_n_s_wraps;
static int __pyx_pf_4lupa_5_lupa_9FastRLock___cinit__(struct __pyx_obj_4lupa_5_lupa_FastRLock *__pyx_v_self); /* proto */
static void __pyx_pf_4lupa_5_lupa_9FastRLock_2__dealloc__(struct __pyx_obj_4lupa_5_lupa_FastRLock *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_4lupa_5_lupa_9FastRLock_4acquire(struct __pyx_obj_4lupa_5_lupa_FastRLock *__pyx_v_self, int __pyx_v_blocking); /* proto */
static PyObject *__pyx_pf_4lupa_5_lupa_9FastRLock_6release(struct __pyx_obj_4lupa_5_lupa_FastRLock *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_4lupa_5_lupa_9FastRLock_8__enter__(struct __pyx_obj_4lupa_5_lupa_FastRLock *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_4lupa_5_lupa_9FastRLock_10__exit__(struct __pyx_obj_4lupa_5_lupa_FastRLock *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v_t, CYTHON_UNUSED PyObject *__pyx_v_v, CYTHON_UNUSED PyObject *__pyx_v_tb); /* proto */
static PyObject *__pyx_pf_4lupa_5_lupa_9FastRLock_12_is_owned(struct __pyx_obj_4lupa_5_lupa_FastRLock *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_4lupa_5_lupa_9FastRLock_14__reduce_cython__(CYTHON_UNUSED struct __pyx_obj_4lupa_5_lupa_FastRLock *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_4lupa_5_lupa_9FastRLock_16__setstate_cython__(CYTHON_UNUSED struct __pyx_obj_4lupa_5_lupa_FastRLock *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v___pyx_state); /* proto */
static PyObject *__pyx_pf_4lupa_5_lupa_lua_type(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_obj); /* proto */
static int __pyx_pf_4lupa_5_lupa_10LuaRuntime___cinit__(struct __pyx_obj_4lupa_5_lupa_LuaRuntime *__pyx_v_self, PyObject *__pyx_v_encoding, PyObject *__pyx_v_source_encoding, PyObject *__pyx_v_attribute_filter, PyObject *__pyx_v_attribute_handlers, int __pyx_v_register_eval, int __pyx_v_unpack_returned_tuples, int __pyx_v_register_builtins); /* proto */
static void __pyx_pf_4lupa_5_lupa_10LuaRuntime_2__dealloc__(struct __pyx_obj_4lupa_5_lupa_LuaRuntime *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_4lupa_5_lupa_10LuaRuntime_11lua_version___get__(struct __pyx_obj_4lupa_5_lupa_LuaRuntime *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_4lupa_5_lupa_10LuaRuntime_18lua_implementation___get__(struct __pyx_obj_4lupa_5_lupa_LuaRuntime *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_4lupa_5_lupa_10LuaRuntime_4eval(struct __pyx_obj_4lupa_5_lupa_LuaRuntime *__pyx_v_self, PyObject *__pyx_v_lua_code, PyObject *__pyx_v_args); /* proto */
static PyObject *__pyx_pf_4lupa_5_lupa_10LuaRuntime_6execute(struct __pyx_obj_4lupa_5_lupa_LuaRuntime *__pyx_v_self, PyObject *__pyx_v_lua_code, PyObject *__pyx_v_args); /* proto */
static PyObject *__pyx_pf_4lupa_5_lupa_10LuaRuntime_8compile(struct __pyx_obj_4lupa_5_lupa_LuaRuntime *__pyx_v_self, PyObject *__pyx_v_lua_code); /* proto */
static PyObject *__pyx_pf_4lupa_5_lupa_10LuaRuntime_10require(struct __pyx_obj_4lupa_5_lupa_LuaRuntime *__pyx_v_self, PyObject *__pyx_v_modulename); /* proto */
static PyObject *__pyx_pf_4lupa_5_lupa_10LuaRuntime_12globals(struct __pyx_obj_4lupa_5_lupa_LuaRuntime *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_4lupa_5_lupa_10LuaRuntime_14table(struct __pyx_obj_4lupa_5_lupa_LuaRuntime *__pyx_v_self, PyObject *__pyx_v_items, PyObject *__pyx_v_kwargs); /* proto */
static PyObject *__pyx_pf_4lupa_5_lupa_10LuaRuntime_16table_from(struct __pyx_obj_4lupa_5_lupa_LuaRuntime *__pyx_v_self, PyObject *__pyx_v_args); /* proto */
static PyObject *__pyx_pf_4lupa_5_lupa_10LuaRuntime_18__reduce_cython__(CYTHON_UNUSED struct __pyx_obj_4lupa_5_lupa_LuaRuntime *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_4lupa_5_lupa_10LuaRuntime_20__setstate_cython__(CYTHON_UNUSED struct __pyx_obj_4lupa_5_lupa_LuaRuntime *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v___pyx_state); /* proto */
static PyObject *__pyx_pf_4lupa_5_lupa_17unpacks_lua_table_wrapper(PyObject *__pyx_self, PyObject *__pyx_v_args); /* proto */
static PyObject *__pyx_pf_4lupa_5_lupa_2unpacks_lua_table(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_func); /* proto */
static PyObject *__pyx_pf_4lupa_5_lupa_24unpacks_lua_table_method_wrapper(PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_args); /* proto */
static PyObject *__pyx_pf_4lupa_5_lupa_4unpacks_lua_table_method(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_meth); /* proto */
static int __pyx_pf_4lupa_5_lupa_10_LuaObject___init__(CYTHON_UNUSED struct __pyx_obj_4lupa_5_lupa__LuaObject *__pyx_v_self); /* proto */
static void __pyx_pf_4lupa_5_lupa_10_LuaObject_2__dealloc__(struct __pyx_obj_4lupa_5_lupa__LuaObject *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_4lupa_5_lupa_10_LuaObject_4__call__(struct __pyx_obj_4lupa_5_lupa__LuaObject *__pyx_v_self, PyObject *__pyx_v_args); /* proto */
static Py_ssize_t __pyx_pf_4lupa_5_lupa_10_LuaObject_6__len__(struct __pyx_obj_4lupa_5_lupa__LuaObject *__pyx_v_self); /* proto */
static int __pyx_pf_4lupa_5_lupa_10_LuaObject_8__nonzero__(CYTHON_UNUSED struct __pyx_obj_4lupa_5_lupa__LuaObject *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_4lupa_5_lupa_10_LuaObject_10__iter__(CYTHON_UNUSED struct __pyx_obj_4lupa_5_lupa__LuaObject *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_4lupa_5_lupa_10_LuaObject_12__repr__(struct __pyx_obj_4lupa_5_lupa__LuaObject *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_4lupa_5_lupa_10_LuaObject_14__str__(struct __pyx_obj_4lupa_5_lupa__LuaObject *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_4lupa_5_lupa_10_LuaObject_16__getattr__(struct __pyx_obj_4lupa_5_lupa__LuaObject *__pyx_v_self, PyObject *__pyx_v_name); /* proto */
static PyObject *__pyx_pf_4lupa_5_lupa_10_LuaObject_18__getitem__(struct __pyx_obj_4lupa_5_lupa__LuaObject *__pyx_v_self, PyObject *__pyx_v_index_or_name); /* proto */
static PyObject *__pyx_pf_4lupa_5_lupa_10_LuaObject_20__reduce_cython__(CYTHON_UNUSED struct __pyx_obj_4lupa_5_lupa__LuaObject *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_4lupa_5_lupa_10_LuaObject_22__setstate_cython__(CYTHON_UNUSED struct __pyx_obj_4lupa_5_lupa__LuaObject *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v___pyx_state); /* proto */
static PyObject *__pyx_pf_4lupa_5_lupa_9_LuaTable___iter__(struct __pyx_obj_4lupa_5_lupa__LuaTable *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_4lupa_5_lupa_9_LuaTable_2keys(struct __pyx_obj_4lupa_5_lupa__LuaTable *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_4lupa_5_lupa_9_LuaTable_4values(struct __pyx_obj_4lupa_5_lupa__LuaTable *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_4lupa_5_lupa_9_LuaTable_6items(struct __pyx_obj_4lupa_5_lupa__LuaTable *__pyx_v_self); /* proto */
static int __pyx_pf_4lupa_5_lupa_9_LuaTable_8__setattr__(struct __pyx_obj_4lupa_5_lupa__LuaTable *__pyx_v_self, PyObject *__pyx_v_name, PyObject *__pyx_v_value); /* proto */
static int __pyx_pf_4lupa_5_lupa_9_LuaTable_10__setitem__(struct __pyx_obj_4lupa_5_lupa__LuaTable *__pyx_v_self, PyObject *__pyx_v_index_or_name, PyObject *__pyx_v_value); /* proto */
static int __pyx_pf_4lupa_5_lupa_9_LuaTable_12__delattr__(struct __pyx_obj_4lupa_5_lupa__LuaTable *__pyx_v_self, PyObject *__pyx_v_item); /* proto */
static int __pyx_pf_4lupa_5_lupa_9_LuaTable_14__delitem__(struct __pyx_obj_4lupa_5_lupa__LuaTable *__pyx_v_self, PyObject *__pyx_v_key); /* proto */
static PyObject *__pyx_pf_4lupa_5_lupa_9_LuaTable_16__reduce_cython__(CYTHON_UNUSED struct __pyx_obj_4lupa_5_lupa__LuaTable *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_4lupa_5_lupa_9_LuaTable_18__setstate_cython__(CYTHON_UNUSED struct __pyx_obj_4lupa_5_lupa__LuaTable *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v___pyx_state); /* proto */
static PyObject *__pyx_pf_4lupa_5_lupa_12_LuaFunction_coroutine(struct __pyx_obj_4lupa_5_lupa__LuaFunction *__pyx_v_self, PyObject *__pyx_v_args); /* proto */
static PyObject *__pyx_pf_4lupa_5_lupa_12_LuaFunction_2__reduce_cython__(CYTHON_UNUSED struct __pyx_obj_4lupa_5_lupa__LuaFunction *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_4lupa_5_lupa_12_LuaFunction_4__setstate_cython__(CYTHON_UNUSED struct __pyx_obj_4lupa_5_lupa__LuaFunction *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v___pyx_state); /* proto */
static PyObject *__pyx_pf_4lupa_5_lupa_21_LuaCoroutineFunction___call__(struct __pyx_obj_4lupa_5_lupa__LuaCoroutineFunction *__pyx_v_self, PyObject *__pyx_v_args); /* proto */
static PyObject *__pyx_pf_4lupa_5_lupa_21_LuaCoroutineFunction_2__reduce_cython__(CYTHON_UNUSED struct __pyx_obj_4lupa_5_lupa__LuaCoroutineFunction *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_4lupa_5_lupa_21_LuaCoroutineFunction_4__setstate_cython__(CYTHON_UNUSED struct __pyx_obj_4lupa_5_lupa__LuaCoroutineFunction *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v___pyx_state); /* proto */
static PyObject *__pyx_pf_4lupa_5_lupa_10_LuaThread___iter__(struct __pyx_obj_4lupa_5_lupa__LuaThread *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_4lupa_5_lupa_10_LuaThread_2__next__(struct __pyx_obj_4lupa_5_lupa__LuaThread *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_4lupa_5_lupa_10_LuaThread_4send(struct __pyx_obj_4lupa_5_lupa__LuaThread *__pyx_v_self, PyObject *__pyx_v_value); /* proto */
static int __pyx_pf_4lupa_5_lupa_10_LuaThread_6__bool__(struct __pyx_obj_4lupa_5_lupa__LuaThread *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_4lupa_5_lupa_10_LuaThread_8__reduce_cython__(CYTHON_UNUSED struct __pyx_obj_4lupa_5_lupa__LuaThread *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_4lupa_5_lupa_10_LuaThread_10__setstate_cython__(CYTHON_UNUSED struct __pyx_obj_4lupa_5_lupa__LuaThread *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v___pyx_state); /* proto */
static int __pyx_pf_4lupa_5_lupa_8_LuaIter___cinit__(struct __pyx_obj_4lupa_5_lupa__LuaIter *__pyx_v_self, struct __pyx_obj_4lupa_5_lupa__LuaObject *__pyx_v_obj, int __pyx_v_what); /* proto */
static void __pyx_pf_4lupa_5_lupa_8_LuaIter_2__dealloc__(struct __pyx_obj_4lupa_5_lupa__LuaIter *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_4lupa_5_lupa_8_LuaIter_4__repr__(struct __pyx_obj_4lupa_5_lupa__LuaIter *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_4lupa_5_lupa_8_LuaIter_6__iter__(struct __pyx_obj_4lupa_5_lupa__LuaIter *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_4lupa_5_lupa_8_LuaIter_8__next__(struct __pyx_obj_4lupa_5_lupa__LuaIter *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_4lupa_5_lupa_8_LuaIter_10__reduce_cython__(CYTHON_UNUSED struct __pyx_obj_4lupa_5_lupa__LuaIter *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_4lupa_5_lupa_8_LuaIter_12__setstate_cython__(CYTHON_UNUSED struct __pyx_obj_4lupa_5_lupa__LuaIter *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v___pyx_state); /* proto */
static int __pyx_pf_4lupa_5_lupa_18_PyProtocolWrapper___cinit__(struct __pyx_obj_4lupa_5_lupa__PyProtocolWrapper *__pyx_v_self); /* proto */
static int __pyx_pf_4lupa_5_lupa_18_PyProtocolWrapper_2__init__(CYTHON_UNUSED struct __pyx_obj_4lupa_5_lupa__PyProtocolWrapper *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_4lupa_5_lupa_18_PyProtocolWrapper_4__reduce_cython__(CYTHON_UNUSED struct __pyx_obj_4lupa_5_lupa__PyProtocolWrapper *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_4lupa_5_lupa_18_PyProtocolWrapper_6__setstate_cython__(CYTHON_UNUSED struct __pyx_obj_4lupa_5_lupa__PyProtocolWrapper *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v___pyx_state); /* proto */
static PyObject *__pyx_pf_4lupa_5_lupa_6as_attrgetter(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_obj); /* proto */
static PyObject *__pyx_pf_4lupa_5_lupa_8as_itemgetter(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_obj); /* proto */
static PyObject *__pyx_tp_new_4lupa_5_lupa_FastRLock(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
static PyObject *__pyx_tp_new_4lupa_5_lupa_LuaRuntime(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
static PyObject *__pyx_tp_new_4lupa_5_lupa__LuaObject(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
static PyObject *__pyx_tp_new_4lupa_5_lupa__LuaTable(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
static PyObject *__pyx_tp_new_4lupa_5_lupa__LuaFunction(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
static PyObject *__pyx_tp_new_4lupa_5_lupa__LuaCoroutineFunction(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
static PyObject *__pyx_tp_new_4lupa_5_lupa__LuaThread(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
static PyObject *__pyx_tp_new_4lupa_5_lupa__LuaIter(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
static PyObject *__pyx_tp_new_4lupa_5_lupa__PyProtocolWrapper(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
static PyObject *__pyx_tp_new_4lupa_5_lupa___pyx_scope_struct__unpacks_lua_table(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
static PyObject *__pyx_tp_new_4lupa_5_lupa___pyx_scope_struct_1_unpacks_lua_table_method(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
static __Pyx_CachedCFunction __pyx_umethod_PyList_Type_pop = {0, &__pyx_n_s_pop, 0, 0, 0};
static PyObject *__pyx_int_1;
static PyObject *__pyx_tuple_;
static PyObject *__pyx_tuple__2;
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__8;
static PyObject *__pyx_tuple__9;
static PyObject *__pyx_tuple__10;
static PyObject *__pyx_tuple__12;
static PyObject *__pyx_tuple__14;
static PyObject *__pyx_tuple__15;
static PyObject *__pyx_tuple__17;
static PyObject *__pyx_tuple__18;
static PyObject *__pyx_tuple__19;
static PyObject *__pyx_tuple__20;
static PyObject *__pyx_tuple__21;
static PyObject *__pyx_tuple__22;
static PyObject *__pyx_tuple__23;
static PyObject *__pyx_tuple__24;
static PyObject *__pyx_tuple__25;
static PyObject *__pyx_tuple__26;
static PyObject *__pyx_tuple__27;
static PyObject *__pyx_tuple__28;
static PyObject *__pyx_tuple__29;
static PyObject *__pyx_tuple__30;
static PyObject *__pyx_tuple__31;
static PyObject *__pyx_tuple__32;
static PyObject *__pyx_tuple__33;
static PyObject *__pyx_tuple__34;
static PyObject *__pyx_tuple__35;
static PyObject *__pyx_tuple__36;
static PyObject *__pyx_tuple__38;
static PyObject *__pyx_tuple__40;
static PyObject *__pyx_tuple__42;
static PyObject *__pyx_tuple__44;
static PyObject *__pyx_tuple__46;
static PyObject *__pyx_tuple__48;
static PyObject *__pyx_tuple__50;
static PyObject *__pyx_tuple__52;
static PyObject *__pyx_tuple__54;
static PyObject *__pyx_tuple__56;
static PyObject *__pyx_tuple__58;
static PyObject *__pyx_tuple__60;
static PyObject *__pyx_tuple__62;
static PyObject *__pyx_tuple__64;
static PyObject *__pyx_tuple__66;
static PyObject *__pyx_tuple__68;
static PyObject *__pyx_tuple__70;
static PyObject *__pyx_tuple__72;
static PyObject *__pyx_tuple__74;
static PyObject *__pyx_tuple__76;
static PyObject *__pyx_tuple__78;
static PyObject *__pyx_tuple__80;
static PyObject *__pyx_tuple__82;
static PyObject *__pyx_tuple__84;
static PyObject *__pyx_tuple__86;
static PyObject *__pyx_tuple__88;
static PyObject *__pyx_tuple__90;
static PyObject *__pyx_tuple__92;
static PyObject *__pyx_tuple__94;
static PyObject *__pyx_tuple__96;
static PyObject *__pyx_tuple__98;
static PyObject *__pyx_tuple__100;
static PyObject *__pyx_tuple__102;
static PyObject *__pyx_tuple__104;
static PyObject *__pyx_tuple__106;
static PyObject *__pyx_tuple__108;
static PyObject *__pyx_tuple__110;
static PyObject *__pyx_tuple__112;
static PyObject *__pyx_tuple__114;
static PyObject *__pyx_codeobj__11;
static PyObject *__pyx_codeobj__13;
static PyObject *__pyx_codeobj__37;
static PyObject *__pyx_codeobj__39;
static PyObject *__pyx_codeobj__41;
static PyObject *__pyx_codeobj__43;
static PyObject *__pyx_codeobj__45;
static PyObject *__pyx_codeobj__47;
static PyObject *__pyx_codeobj__49;
static PyObject *__pyx_codeobj__51;
static PyObject *__pyx_codeobj__53;
static PyObject *__pyx_codeobj__55;
static PyObject *__pyx_codeobj__57;
static PyObject *__pyx_codeobj__59;
static PyObject *__pyx_codeobj__61;
static PyObject *__pyx_codeobj__63;
static PyObject *__pyx_codeobj__65;
static PyObject *__pyx_codeobj__67;
static PyObject *__pyx_codeobj__69;
static PyObject *__pyx_codeobj__71;
static PyObject *__pyx_codeobj__73;
static PyObject *__pyx_codeobj__75;
static PyObject *__pyx_codeobj__77;
static PyObject *__pyx_codeobj__79;
static PyObject *__pyx_codeobj__81;
static PyObject *__pyx_codeobj__83;
static PyObject *__pyx_codeobj__85;
static PyObject *__pyx_codeobj__87;
static PyObject *__pyx_codeobj__89;
static PyObject *__pyx_codeobj__91;
static PyObject *__pyx_codeobj__93;
static PyObject *__pyx_codeobj__95;
static PyObject *__pyx_codeobj__97;
static PyObject *__pyx_codeobj__99;
static PyObject *__pyx_codeobj__101;
static PyObject *__pyx_codeobj__103;
static PyObject *__pyx_codeobj__105;
static PyObject *__pyx_codeobj__107;
static PyObject *__pyx_codeobj__109;
static PyObject *__pyx_codeobj__111;
static PyObject *__pyx_codeobj__113;
static PyObject *__pyx_codeobj__115;
/* Late includes */

/* "lupa/lock.pxi":20
 *     cdef bint _is_locked        # whether the real lock is acquired
 * 
 *     def __cinit__(self):             # <<<<<<<<<<<<<<
 *         self._owner = -1
 *         self._count = 0
 */

/* Python wrapper */
static int __pyx_pw_4lupa_5_lupa_9FastRLock_1__cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static int __pyx_pw_4lupa_5_lupa_9FastRLock_1__cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__cinit__ (wrapper)", 0);
  if (unlikely(PyTuple_GET_SIZE(__pyx_args) > 0)) {
    __Pyx_RaiseArgtupleInvalid("__cinit__", 1, 0, 0, PyTuple_GET_SIZE(__pyx_args)); return -1;}
  if (unlikely(__pyx_kwds) && unlikely(PyDict_Size(__pyx_kwds) > 0) && unlikely(!__Pyx_CheckKeywordStrings(__pyx_kwds, "__cinit__", 0))) return -1;
  __pyx_r = __pyx_pf_4lupa_5_lupa_9FastRLock___cinit__(((struct __pyx_obj_4lupa_5_lupa_FastRLock *)__pyx_v_self));

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

static int __pyx_pf_4lupa_5_lupa_9FastRLock___cinit__(struct __pyx_obj_4lupa_5_lupa_FastRLock *__pyx_v_self) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__cinit__", 0);

  /* "lupa/lock.pxi":21
 * 
 *     def __cinit__(self):
 *         self._owner = -1             # <<<<<<<<<<<<<<
 *         self._count = 0
 *         self._is_locked = False
 */
  __pyx_v_self->_owner = -1L;

  /* "lupa/lock.pxi":22
 *     def __cinit__(self):
 *         self._owner = -1
 *         self._count = 0             # <<<<<<<<<<<<<<
 *         self._is_locked = False
 *         self._pending_requests = 0
 */
  __pyx_v_self->_count = 0;

  /* "lupa/lock.pxi":23
 *         self._owner = -1
 *         self._count = 0
 *         self._is_locked = False             # <<<<<<<<<<<<<<
 *         self._pending_requests = 0
 *         self._real_lock = pythread.PyThread_allocate_lock()
 */
  __pyx_v_self->_is_locked = 0;

  /* "lupa/lock.pxi":24
 *         self._count = 0
 *         self._is_locked = False
 *         self._pending_requests = 0             # <<<<<<<<<<<<<<
 *         self._real_lock = pythread.PyThread_allocate_lock()
 *         if self._real_lock is NULL:
 */
  __pyx_v_self->_pending_requests = 0;

  /* "lupa/lock.pxi":25
 *         self._is_locked = False
 *         self._pending_requests = 0
 *         self._real_lock = pythread.PyThread_allocate_lock()             # <<<<<<<<<<<<<<
 *         if self._real_lock is NULL:
 *             raise MemoryError
 */
  __pyx_v_self->_real_lock = PyThread_allocate_lock();

  /* "lupa/lock.pxi":26
 *         self._pending_requests = 0
 *         self._real_lock = pythread.PyThread_allocate_lock()
 *         if self._real_lock is NULL:             # <<<<<<<<<<<<<<
 *             raise MemoryError
 * 
 */
  __pyx_t_1 = ((__pyx_v_self->_real_lock == NULL) != 0);
  if (unlikely(__pyx_t_1)) {

    /* "lupa/lock.pxi":27
 *         self._real_lock = pythread.PyThread_allocate_lock()
 *         if self._real_lock is NULL:
 *             raise MemoryError             # <<<<<<<<<<<<<<
 * 
 *     def __dealloc__(self):
 */
    PyErr_NoMemory(); __PYX_ERR(1, 27, __pyx_L1_error)

    /* "lupa/lock.pxi":26
 *         self._pending_requests = 0
 *         self._real_lock = pythread.PyThread_allocate_lock()
 *         if self._real_lock is NULL:             # <<<<<<<<<<<<<<
 *             raise MemoryError
 * 
 */
  }

  /* "lupa/lock.pxi":20
 *     cdef bint _is_locked        # whether the real lock is acquired
 * 
 *     def __cinit__(self):             # <<<<<<<<<<<<<<
 *         self._owner = -1
 *         self._count = 0
 */

  /* function exit code */
  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_AddTraceback("lupa._lupa.FastRLock.__cinit__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lupa/lock.pxi":29
 *             raise MemoryError
 * 
 *     def __dealloc__(self):             # <<<<<<<<<<<<<<
 *         if self._real_lock is not NULL:
 *             pythread.PyThread_free_lock(self._real_lock)
 */

/* Python wrapper */
static void __pyx_pw_4lupa_5_lupa_9FastRLock_3__dealloc__(PyObject *__pyx_v_self); /*proto*/
static void __pyx_pw_4lupa_5_lupa_9FastRLock_3__dealloc__(PyObject *__pyx_v_self) {
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__dealloc__ (wrapper)", 0);
  __pyx_pf_4lupa_5_lupa_9FastRLock_2__dealloc__(((struct __pyx_obj_4lupa_5_lupa_FastRLock *)__pyx_v_self));

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

static void __pyx_pf_4lupa_5_lupa_9FastRLock_2__dealloc__(struct __pyx_obj_4lupa_5_lupa_FastRLock *__pyx_v_self) {
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  __Pyx_RefNannySetupContext("__dealloc__", 0);

  /* "lupa/lock.pxi":30
 * 
 *     def __dealloc__(self):
 *         if self._real_lock is not NULL:             # <<<<<<<<<<<<<<
 *             pythread.PyThread_free_lock(self._real_lock)
 *             self._real_lock = NULL
 */
  __pyx_t_1 = ((__pyx_v_self->_real_lock != NULL) != 0);
  if (__pyx_t_1) {

    /* "lupa/lock.pxi":31
 *     def __dealloc__(self):
 *         if self._real_lock is not NULL:
 *             pythread.PyThread_free_lock(self._real_lock)             # <<<<<<<<<<<<<<
 *             self._real_lock = NULL
 * 
 */
    PyThread_free_lock(__pyx_v_self->_real_lock);

    /* "lupa/lock.pxi":32
 *         if self._real_lock is not NULL:
 *             pythread.PyThread_free_lock(self._real_lock)
 *             self._real_lock = NULL             # <<<<<<<<<<<<<<
 * 
 *     def acquire(self, bint blocking=True):
 */
    __pyx_v_self->_real_lock = NULL;

    /* "lupa/lock.pxi":30
 * 
 *     def __dealloc__(self):
 *         if self._real_lock is not NULL:             # <<<<<<<<<<<<<<
 *             pythread.PyThread_free_lock(self._real_lock)
 *             self._real_lock = NULL
 */
  }

  /* "lupa/lock.pxi":29
 *             raise MemoryError
 * 
 *     def __dealloc__(self):             # <<<<<<<<<<<<<<
 *         if self._real_lock is not NULL:
 *             pythread.PyThread_free_lock(self._real_lock)
 */

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

/* "lupa/lock.pxi":34
 *             self._real_lock = NULL
 * 
 *     def acquire(self, bint blocking=True):             # <<<<<<<<<<<<<<
 *         return lock_lock(self, pythread.PyThread_get_thread_ident(), blocking)
 * 
 */

/* Python wrapper */
static PyObject *__pyx_pw_4lupa_5_lupa_9FastRLock_5acquire(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4lupa_5_lupa_9FastRLock_4acquire[] = "FastRLock.acquire(self, bool blocking=True)";
static PyMethodDef __pyx_mdef_4lupa_5_lupa_9FastRLock_5acquire = {"acquire", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_4lupa_5_lupa_9FastRLock_5acquire, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4lupa_5_lupa_9FastRLock_4acquire};
static PyObject *__pyx_pw_4lupa_5_lupa_9FastRLock_5acquire(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  int __pyx_v_blocking;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("acquire (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_blocking,0};
    PyObject* values[1] = {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  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_blocking);
          if (value) { values[0] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "acquire") < 0)) __PYX_ERR(1, 34, __pyx_L3_error)
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    if (values[0]) {
      __pyx_v_blocking = __Pyx_PyObject_IsTrue(values[0]); if (unlikely((__pyx_v_blocking == (int)-1) && PyErr_Occurred())) __PYX_ERR(1, 34, __pyx_L3_error)
    } else {
      __pyx_v_blocking = ((int)1);
    }
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("acquire", 0, 0, 1, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(1, 34, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("lupa._lupa.FastRLock.acquire", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_4lupa_5_lupa_9FastRLock_4acquire(((struct __pyx_obj_4lupa_5_lupa_FastRLock *)__pyx_v_self), __pyx_v_blocking);

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

static PyObject *__pyx_pf_4lupa_5_lupa_9FastRLock_4acquire(struct __pyx_obj_4lupa_5_lupa_FastRLock *__pyx_v_self, int __pyx_v_blocking) {
  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("acquire", 0);

  /* "lupa/lock.pxi":35
 * 
 *     def acquire(self, bint blocking=True):
 *         return lock_lock(self, pythread.PyThread_get_thread_ident(), blocking)             # <<<<<<<<<<<<<<
 * 
 *     def release(self):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __Pyx_PyBool_FromLong(__pyx_f_4lupa_5_lupa_lock_lock(__pyx_v_self, PyThread_get_thread_ident(), __pyx_v_blocking)); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 35, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "lupa/lock.pxi":34
 *             self._real_lock = NULL
 * 
 *     def acquire(self, bint blocking=True):             # <<<<<<<<<<<<<<
 *         return lock_lock(self, pythread.PyThread_get_thread_ident(), blocking)
 * 
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("lupa._lupa.FastRLock.acquire", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lupa/lock.pxi":37
 *         return lock_lock(self, pythread.PyThread_get_thread_ident(), blocking)
 * 
 *     def release(self):             # <<<<<<<<<<<<<<
 *         if self._owner != pythread.PyThread_get_thread_ident():
 *             raise RuntimeError("cannot release un-acquired lock")
 */

/* Python wrapper */
static PyObject *__pyx_pw_4lupa_5_lupa_9FastRLock_7release(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static char __pyx_doc_4lupa_5_lupa_9FastRLock_6release[] = "FastRLock.release(self)";
static PyMethodDef __pyx_mdef_4lupa_5_lupa_9FastRLock_7release = {"release", (PyCFunction)__pyx_pw_4lupa_5_lupa_9FastRLock_7release, METH_NOARGS, __pyx_doc_4lupa_5_lupa_9FastRLock_6release};
static PyObject *__pyx_pw_4lupa_5_lupa_9FastRLock_7release(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("release (wrapper)", 0);
  __pyx_r = __pyx_pf_4lupa_5_lupa_9FastRLock_6release(((struct __pyx_obj_4lupa_5_lupa_FastRLock *)__pyx_v_self));

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

static PyObject *__pyx_pf_4lupa_5_lupa_9FastRLock_6release(struct __pyx_obj_4lupa_5_lupa_FastRLock *__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("release", 0);

  /* "lupa/lock.pxi":38
 * 
 *     def release(self):
 *         if self._owner != pythread.PyThread_get_thread_ident():             # <<<<<<<<<<<<<<
 *             raise RuntimeError("cannot release un-acquired lock")
 *         unlock_lock(self)
 */
  __pyx_t_1 = ((__pyx_v_self->_owner != PyThread_get_thread_ident()) != 0);
  if (unlikely(__pyx_t_1)) {

    /* "lupa/lock.pxi":39
 *     def release(self):
 *         if self._owner != pythread.PyThread_get_thread_ident():
 *             raise RuntimeError("cannot release un-acquired lock")             # <<<<<<<<<<<<<<
 *         unlock_lock(self)
 * 
 */
    __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_RuntimeError, __pyx_tuple_, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 39, __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(1, 39, __pyx_L1_error)

    /* "lupa/lock.pxi":38
 * 
 *     def release(self):
 *         if self._owner != pythread.PyThread_get_thread_ident():             # <<<<<<<<<<<<<<
 *             raise RuntimeError("cannot release un-acquired lock")
 *         unlock_lock(self)
 */
  }

  /* "lupa/lock.pxi":40
 *         if self._owner != pythread.PyThread_get_thread_ident():
 *             raise RuntimeError("cannot release un-acquired lock")
 *         unlock_lock(self)             # <<<<<<<<<<<<<<
 * 
 *     # compatibility with RLock
 */
  __pyx_f_4lupa_5_lupa_unlock_lock(__pyx_v_self);

  /* "lupa/lock.pxi":37
 *         return lock_lock(self, pythread.PyThread_get_thread_ident(), blocking)
 * 
 *     def release(self):             # <<<<<<<<<<<<<<
 *         if self._owner != pythread.PyThread_get_thread_ident():
 *             raise RuntimeError("cannot release un-acquired lock")
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_AddTraceback("lupa._lupa.FastRLock.release", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lupa/lock.pxi":44
 *     # compatibility with RLock
 * 
 *     def __enter__(self):             # <<<<<<<<<<<<<<
 *         # self.acquire()
 *         return lock_lock(self, pythread.PyThread_get_thread_ident(), True)
 */

/* Python wrapper */
static PyObject *__pyx_pw_4lupa_5_lupa_9FastRLock_9__enter__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static char __pyx_doc_4lupa_5_lupa_9FastRLock_8__enter__[] = "FastRLock.__enter__(self)";
static PyMethodDef __pyx_mdef_4lupa_5_lupa_9FastRLock_9__enter__ = {"__enter__", (PyCFunction)__pyx_pw_4lupa_5_lupa_9FastRLock_9__enter__, METH_NOARGS, __pyx_doc_4lupa_5_lupa_9FastRLock_8__enter__};
static PyObject *__pyx_pw_4lupa_5_lupa_9FastRLock_9__enter__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__enter__ (wrapper)", 0);
  __pyx_r = __pyx_pf_4lupa_5_lupa_9FastRLock_8__enter__(((struct __pyx_obj_4lupa_5_lupa_FastRLock *)__pyx_v_self));

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

static PyObject *__pyx_pf_4lupa_5_lupa_9FastRLock_8__enter__(struct __pyx_obj_4lupa_5_lupa_FastRLock *__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("__enter__", 0);

  /* "lupa/lock.pxi":46
 *     def __enter__(self):
 *         # self.acquire()
 *         return lock_lock(self, pythread.PyThread_get_thread_ident(), True)             # <<<<<<<<<<<<<<
 * 
 *     def __exit__(self, t, v, tb):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __Pyx_PyBool_FromLong(__pyx_f_4lupa_5_lupa_lock_lock(__pyx_v_self, PyThread_get_thread_ident(), 1)); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 46, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "lupa/lock.pxi":44
 *     # compatibility with RLock
 * 
 *     def __enter__(self):             # <<<<<<<<<<<<<<
 *         # self.acquire()
 *         return lock_lock(self, pythread.PyThread_get_thread_ident(), True)
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("lupa._lupa.FastRLock.__enter__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lupa/lock.pxi":48
 *         return lock_lock(self, pythread.PyThread_get_thread_ident(), True)
 * 
 *     def __exit__(self, t, v, tb):             # <<<<<<<<<<<<<<
 *         # self.release()
 *         if self._owner != pythread.PyThread_get_thread_ident():
 */

/* Python wrapper */
static PyObject *__pyx_pw_4lupa_5_lupa_9FastRLock_11__exit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4lupa_5_lupa_9FastRLock_10__exit__[] = "FastRLock.__exit__(self, t, v, tb)";
static PyMethodDef __pyx_mdef_4lupa_5_lupa_9FastRLock_11__exit__ = {"__exit__", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_4lupa_5_lupa_9FastRLock_11__exit__, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4lupa_5_lupa_9FastRLock_10__exit__};
static PyObject *__pyx_pw_4lupa_5_lupa_9FastRLock_11__exit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  CYTHON_UNUSED PyObject *__pyx_v_t = 0;
  CYTHON_UNUSED PyObject *__pyx_v_v = 0;
  CYTHON_UNUSED PyObject *__pyx_v_tb = 0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__exit__ (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_t,&__pyx_n_s_v,&__pyx_n_s_tb,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_t)) != 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_v)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("__exit__", 1, 3, 3, 1); __PYX_ERR(1, 48, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  2:
        if (likely((values[2] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_tb)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("__exit__", 1, 3, 3, 2); __PYX_ERR(1, 48, __pyx_L3_error)
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__exit__") < 0)) __PYX_ERR(1, 48, __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_t = values[0];
    __pyx_v_v = values[1];
    __pyx_v_tb = values[2];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("__exit__", 1, 3, 3, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(1, 48, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("lupa._lupa.FastRLock.__exit__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_4lupa_5_lupa_9FastRLock_10__exit__(((struct __pyx_obj_4lupa_5_lupa_FastRLock *)__pyx_v_self), __pyx_v_t, __pyx_v_v, __pyx_v_tb);

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

static PyObject *__pyx_pf_4lupa_5_lupa_9FastRLock_10__exit__(struct __pyx_obj_4lupa_5_lupa_FastRLock *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v_t, CYTHON_UNUSED PyObject *__pyx_v_v, CYTHON_UNUSED PyObject *__pyx_v_tb) {
  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("__exit__", 0);

  /* "lupa/lock.pxi":50
 *     def __exit__(self, t, v, tb):
 *         # self.release()
 *         if self._owner != pythread.PyThread_get_thread_ident():             # <<<<<<<<<<<<<<
 *             raise RuntimeError("cannot release un-acquired lock")
 *         unlock_lock(self)
 */
  __pyx_t_1 = ((__pyx_v_self->_owner != PyThread_get_thread_ident()) != 0);
  if (unlikely(__pyx_t_1)) {

    /* "lupa/lock.pxi":51
 *         # self.release()
 *         if self._owner != pythread.PyThread_get_thread_ident():
 *             raise RuntimeError("cannot release un-acquired lock")             # <<<<<<<<<<<<<<
 *         unlock_lock(self)
 * 
 */
    __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_RuntimeError, __pyx_tuple_, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 51, __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(1, 51, __pyx_L1_error)

    /* "lupa/lock.pxi":50
 *     def __exit__(self, t, v, tb):
 *         # self.release()
 *         if self._owner != pythread.PyThread_get_thread_ident():             # <<<<<<<<<<<<<<
 *             raise RuntimeError("cannot release un-acquired lock")
 *         unlock_lock(self)
 */
  }

  /* "lupa/lock.pxi":52
 *         if self._owner != pythread.PyThread_get_thread_ident():
 *             raise RuntimeError("cannot release un-acquired lock")
 *         unlock_lock(self)             # <<<<<<<<<<<<<<
 * 
 *     def _is_owned(self):
 */
  __pyx_f_4lupa_5_lupa_unlock_lock(__pyx_v_self);

  /* "lupa/lock.pxi":48
 *         return lock_lock(self, pythread.PyThread_get_thread_ident(), True)
 * 
 *     def __exit__(self, t, v, tb):             # <<<<<<<<<<<<<<
 *         # self.release()
 *         if self._owner != pythread.PyThread_get_thread_ident():
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_AddTraceback("lupa._lupa.FastRLock.__exit__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lupa/lock.pxi":54
 *         unlock_lock(self)
 * 
 *     def _is_owned(self):             # <<<<<<<<<<<<<<
 *         return self._owner == pythread.PyThread_get_thread_ident()
 * 
 */

/* Python wrapper */
static PyObject *__pyx_pw_4lupa_5_lupa_9FastRLock_13_is_owned(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static char __pyx_doc_4lupa_5_lupa_9FastRLock_12_is_owned[] = "FastRLock._is_owned(self)";
static PyMethodDef __pyx_mdef_4lupa_5_lupa_9FastRLock_13_is_owned = {"_is_owned", (PyCFunction)__pyx_pw_4lupa_5_lupa_9FastRLock_13_is_owned, METH_NOARGS, __pyx_doc_4lupa_5_lupa_9FastRLock_12_is_owned};
static PyObject *__pyx_pw_4lupa_5_lupa_9FastRLock_13_is_owned(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("_is_owned (wrapper)", 0);
  __pyx_r = __pyx_pf_4lupa_5_lupa_9FastRLock_12_is_owned(((struct __pyx_obj_4lupa_5_lupa_FastRLock *)__pyx_v_self));

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

static PyObject *__pyx_pf_4lupa_5_lupa_9FastRLock_12_is_owned(struct __pyx_obj_4lupa_5_lupa_FastRLock *__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("_is_owned", 0);

  /* "lupa/lock.pxi":55
 * 
 *     def _is_owned(self):
 *         return self._owner == pythread.PyThread_get_thread_ident()             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __Pyx_PyBool_FromLong((__pyx_v_self->_owner == PyThread_get_thread_ident())); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 55, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "lupa/lock.pxi":54
 *         unlock_lock(self)
 * 
 *     def _is_owned(self):             # <<<<<<<<<<<<<<
 *         return self._owner == pythread.PyThread_get_thread_ident()
 * 
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("lupa._lupa.FastRLock._is_owned", __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_4lupa_5_lupa_9FastRLock_15__reduce_cython__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static char __pyx_doc_4lupa_5_lupa_9FastRLock_14__reduce_cython__[] = "FastRLock.__reduce_cython__(self)";
static PyMethodDef __pyx_mdef_4lupa_5_lupa_9FastRLock_15__reduce_cython__ = {"__reduce_cython__", (PyCFunction)__pyx_pw_4lupa_5_lupa_9FastRLock_15__reduce_cython__, METH_NOARGS, __pyx_doc_4lupa_5_lupa_9FastRLock_14__reduce_cython__};
static PyObject *__pyx_pw_4lupa_5_lupa_9FastRLock_15__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_4lupa_5_lupa_9FastRLock_14__reduce_cython__(((struct __pyx_obj_4lupa_5_lupa_FastRLock *)__pyx_v_self));

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

static PyObject *__pyx_pf_4lupa_5_lupa_9FastRLock_14__reduce_cython__(CYTHON_UNUSED struct __pyx_obj_4lupa_5_lupa_FastRLock *__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__2, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 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(2, 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("lupa._lupa.FastRLock.__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_4lupa_5_lupa_9FastRLock_17__setstate_cython__(PyObject *__pyx_v_self, PyObject *__pyx_v___pyx_state); /*proto*/
static char __pyx_doc_4lupa_5_lupa_9FastRLock_16__setstate_cython__[] = "FastRLock.__setstate_cython__(self, __pyx_state)";
static PyMethodDef __pyx_mdef_4lupa_5_lupa_9FastRLock_17__setstate_cython__ = {"__setstate_cython__", (PyCFunction)__pyx_pw_4lupa_5_lupa_9FastRLock_17__setstate_cython__, METH_O, __pyx_doc_4lupa_5_lupa_9FastRLock_16__setstate_cython__};
static PyObject *__pyx_pw_4lupa_5_lupa_9FastRLock_17__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_4lupa_5_lupa_9FastRLock_16__setstate_cython__(((struct __pyx_obj_4lupa_5_lupa_FastRLock *)__pyx_v_self), ((PyObject *)__pyx_v___pyx_state));

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

static PyObject *__pyx_pf_4lupa_5_lupa_9FastRLock_16__setstate_cython__(CYTHON_UNUSED struct __pyx_obj_4lupa_5_lupa_FastRLock *__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__3, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 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(2, 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("lupa._lupa.FastRLock.__setstate_cython__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lupa/lock.pxi":58
 * 
 * 
 * cdef inline bint lock_lock(FastRLock lock, long current_thread, bint blocking) nogil:             # <<<<<<<<<<<<<<
 *     # Note that this function *must* hold the GIL when being called.
 *     # We just use 'nogil' in the signature to make sure that no Python
 */

static CYTHON_INLINE int __pyx_f_4lupa_5_lupa_lock_lock(struct __pyx_obj_4lupa_5_lupa_FastRLock *__pyx_v_lock, long __pyx_v_current_thread, int __pyx_v_blocking) {
  int __pyx_r;
  int __pyx_t_1;
  int __pyx_t_2;

  /* "lupa/lock.pxi":63
 *     # code execution slips in that might free the GIL
 * 
 *     if lock._count:             # <<<<<<<<<<<<<<
 *         # locked! - by myself?
 *         if current_thread == lock._owner:
 */
  __pyx_t_1 = (__pyx_v_lock->_count != 0);
  if (__pyx_t_1) {

    /* "lupa/lock.pxi":65
 *     if lock._count:
 *         # locked! - by myself?
 *         if current_thread == lock._owner:             # <<<<<<<<<<<<<<
 *             lock._count += 1
 *             return 1
 */
    __pyx_t_1 = ((__pyx_v_current_thread == __pyx_v_lock->_owner) != 0);
    if (__pyx_t_1) {

      /* "lupa/lock.pxi":66
 *         # locked! - by myself?
 *         if current_thread == lock._owner:
 *             lock._count += 1             # <<<<<<<<<<<<<<
 *             return 1
 *     elif not lock._pending_requests:
 */
      __pyx_v_lock->_count = (__pyx_v_lock->_count + 1);

      /* "lupa/lock.pxi":67
 *         if current_thread == lock._owner:
 *             lock._count += 1
 *             return 1             # <<<<<<<<<<<<<<
 *     elif not lock._pending_requests:
 *         # not locked, not requested - go!
 */
      __pyx_r = 1;
      goto __pyx_L0;

      /* "lupa/lock.pxi":65
 *     if lock._count:
 *         # locked! - by myself?
 *         if current_thread == lock._owner:             # <<<<<<<<<<<<<<
 *             lock._count += 1
 *             return 1
 */
    }

    /* "lupa/lock.pxi":63
 *     # code execution slips in that might free the GIL
 * 
 *     if lock._count:             # <<<<<<<<<<<<<<
 *         # locked! - by myself?
 *         if current_thread == lock._owner:
 */
    goto __pyx_L3;
  }

  /* "lupa/lock.pxi":68
 *             lock._count += 1
 *             return 1
 *     elif not lock._pending_requests:             # <<<<<<<<<<<<<<
 *         # not locked, not requested - go!
 *         lock._owner = current_thread
 */
  __pyx_t_1 = ((!(__pyx_v_lock->_pending_requests != 0)) != 0);
  if (__pyx_t_1) {

    /* "lupa/lock.pxi":70
 *     elif not lock._pending_requests:
 *         # not locked, not requested - go!
 *         lock._owner = current_thread             # <<<<<<<<<<<<<<
 *         lock._count = 1
 *         return 1
 */
    __pyx_v_lock->_owner = __pyx_v_current_thread;

    /* "lupa/lock.pxi":71
 *         # not locked, not requested - go!
 *         lock._owner = current_thread
 *         lock._count = 1             # <<<<<<<<<<<<<<
 *         return 1
 *     # need to get the real lock
 */
    __pyx_v_lock->_count = 1;

    /* "lupa/lock.pxi":72
 *         lock._owner = current_thread
 *         lock._count = 1
 *         return 1             # <<<<<<<<<<<<<<
 *     # need to get the real lock
 *     return _acquire_lock(
 */
    __pyx_r = 1;
    goto __pyx_L0;

    /* "lupa/lock.pxi":68
 *             lock._count += 1
 *             return 1
 *     elif not lock._pending_requests:             # <<<<<<<<<<<<<<
 *         # not locked, not requested - go!
 *         lock._owner = current_thread
 */
  }
  __pyx_L3:;

  /* "lupa/lock.pxi":76
 *     return _acquire_lock(
 *         lock, current_thread,
 *         pythread.WAIT_LOCK if blocking else pythread.NOWAIT_LOCK)             # <<<<<<<<<<<<<<
 * 
 * cdef bint _acquire_lock(FastRLock lock, long current_thread, int wait) nogil:
 */
  if ((__pyx_v_blocking != 0)) {
    __pyx_t_2 = WAIT_LOCK;
  } else {
    __pyx_t_2 = NOWAIT_LOCK;
  }

  /* "lupa/lock.pxi":74
 *         return 1
 *     # need to get the real lock
 *     return _acquire_lock(             # <<<<<<<<<<<<<<
 *         lock, current_thread,
 *         pythread.WAIT_LOCK if blocking else pythread.NOWAIT_LOCK)
 */
  __pyx_r = __pyx_f_4lupa_5_lupa__acquire_lock(__pyx_v_lock, __pyx_v_current_thread, __pyx_t_2);
  goto __pyx_L0;

  /* "lupa/lock.pxi":58
 * 
 * 
 * cdef inline bint lock_lock(FastRLock lock, long current_thread, bint blocking) nogil:             # <<<<<<<<<<<<<<
 *     # Note that this function *must* hold the GIL when being called.
 *     # We just use 'nogil' in the signature to make sure that no Python
 */

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

/* "lupa/lock.pxi":78
 *         pythread.WAIT_LOCK if blocking else pythread.NOWAIT_LOCK)
 * 
 * cdef bint _acquire_lock(FastRLock lock, long current_thread, int wait) nogil:             # <<<<<<<<<<<<<<
 *     # Note that this function *must* hold the GIL when being called.
 *     # We just use 'nogil' in the signature to make sure that no Python
 */

static int __pyx_f_4lupa_5_lupa__acquire_lock(struct __pyx_obj_4lupa_5_lupa_FastRLock *__pyx_v_lock, long __pyx_v_current_thread, int __pyx_v_wait) {
  int __pyx_v_locked;
  int __pyx_r;
  int __pyx_t_1;
  int __pyx_t_2;

  /* "lupa/lock.pxi":83
 *     # code execution slips in that might free the GIL
 * 
 *     if not lock._is_locked and not lock._pending_requests:             # <<<<<<<<<<<<<<
 *         # someone owns it but didn't acquire the real lock - do that
 *         # now and tell the owner to release it when done. Note that we
 */
  __pyx_t_2 = ((!(__pyx_v_lock->_is_locked != 0)) != 0);
  if (__pyx_t_2) {
  } else {
    __pyx_t_1 = __pyx_t_2;
    goto __pyx_L4_bool_binop_done;
  }
  __pyx_t_2 = ((!(__pyx_v_lock->_pending_requests != 0)) != 0);
  __pyx_t_1 = __pyx_t_2;
  __pyx_L4_bool_binop_done:;
  if (__pyx_t_1) {

    /* "lupa/lock.pxi":88
 *         # do not release the GIL here as we must absolutely be the one
 *         # who acquires the lock now.
 *         if not pythread.PyThread_acquire_lock(lock._real_lock, wait):             # <<<<<<<<<<<<<<
 *             return 0
 *         #assert not lock._is_locked
 */
    __pyx_t_1 = ((!(PyThread_acquire_lock(__pyx_v_lock->_real_lock, __pyx_v_wait) != 0)) != 0);
    if (__pyx_t_1) {

      /* "lupa/lock.pxi":89
 *         # who acquires the lock now.
 *         if not pythread.PyThread_acquire_lock(lock._real_lock, wait):
 *             return 0             # <<<<<<<<<<<<<<
 *         #assert not lock._is_locked
 *         lock._is_locked = True
 */
      __pyx_r = 0;
      goto __pyx_L0;

      /* "lupa/lock.pxi":88
 *         # do not release the GIL here as we must absolutely be the one
 *         # who acquires the lock now.
 *         if not pythread.PyThread_acquire_lock(lock._real_lock, wait):             # <<<<<<<<<<<<<<
 *             return 0
 *         #assert not lock._is_locked
 */
    }

    /* "lupa/lock.pxi":91
 *             return 0
 *         #assert not lock._is_locked
 *         lock._is_locked = True             # <<<<<<<<<<<<<<
 *     lock._pending_requests += 1
 *     with nogil:
 */
    __pyx_v_lock->_is_locked = 1;

    /* "lupa/lock.pxi":83
 *     # code execution slips in that might free the GIL
 * 
 *     if not lock._is_locked and not lock._pending_requests:             # <<<<<<<<<<<<<<
 *         # someone owns it but didn't acquire the real lock - do that
 *         # now and tell the owner to release it when done. Note that we
 */
  }

  /* "lupa/lock.pxi":92
 *         #assert not lock._is_locked
 *         lock._is_locked = True
 *     lock._pending_requests += 1             # <<<<<<<<<<<<<<
 *     with nogil:
 *         # wait for the lock owning thread to release it
 */
  __pyx_v_lock->_pending_requests = (__pyx_v_lock->_pending_requests + 1);

  /* "lupa/lock.pxi":93
 *         lock._is_locked = True
 *     lock._pending_requests += 1
 *     with nogil:             # <<<<<<<<<<<<<<
 *         # wait for the lock owning thread to release it
 *         locked = pythread.PyThread_acquire_lock(lock._real_lock, wait)
 */
  {
      #ifdef WITH_THREAD
      PyThreadState *_save;
      Py_UNBLOCK_THREADS
      __Pyx_FastGIL_Remember();
      #endif
      /*try:*/ {

        /* "lupa/lock.pxi":95
 *     with nogil:
 *         # wait for the lock owning thread to release it
 *         locked = pythread.PyThread_acquire_lock(lock._real_lock, wait)             # <<<<<<<<<<<<<<
 *     lock._pending_requests -= 1
 *     #assert not lock._is_locked
 */
        __pyx_v_locked = PyThread_acquire_lock(__pyx_v_lock->_real_lock, __pyx_v_wait);
      }

      /* "lupa/lock.pxi":93
 *         lock._is_locked = True
 *     lock._pending_requests += 1
 *     with nogil:             # <<<<<<<<<<<<<<
 *         # wait for the lock owning thread to release it
 *         locked = pythread.PyThread_acquire_lock(lock._real_lock, wait)
 */
      /*finally:*/ {
        /*normal exit:*/{
          #ifdef WITH_THREAD
          __Pyx_FastGIL_Forget();
          Py_BLOCK_THREADS
          #endif
          goto __pyx_L9;
        }
        __pyx_L9:;
      }
  }

  /* "lupa/lock.pxi":96
 *         # wait for the lock owning thread to release it
 *         locked = pythread.PyThread_acquire_lock(lock._real_lock, wait)
 *     lock._pending_requests -= 1             # <<<<<<<<<<<<<<
 *     #assert not lock._is_locked
 *     #assert lock._count == 0
 */
  __pyx_v_lock->_pending_requests = (__pyx_v_lock->_pending_requests - 1);

  /* "lupa/lock.pxi":99
 *     #assert not lock._is_locked
 *     #assert lock._count == 0
 *     if not locked:             # <<<<<<<<<<<<<<
 *         return 0
 *     lock._is_locked = True
 */
  __pyx_t_1 = ((!(__pyx_v_locked != 0)) != 0);
  if (__pyx_t_1) {

    /* "lupa/lock.pxi":100
 *     #assert lock._count == 0
 *     if not locked:
 *         return 0             # <<<<<<<<<<<<<<
 *     lock._is_locked = True
 *     lock._owner = current_thread
 */
    __pyx_r = 0;
    goto __pyx_L0;

    /* "lupa/lock.pxi":99
 *     #assert not lock._is_locked
 *     #assert lock._count == 0
 *     if not locked:             # <<<<<<<<<<<<<<
 *         return 0
 *     lock._is_locked = True
 */
  }

  /* "lupa/lock.pxi":101
 *     if not locked:
 *         return 0
 *     lock._is_locked = True             # <<<<<<<<<<<<<<
 *     lock._owner = current_thread
 *     lock._count = 1
 */
  __pyx_v_lock->_is_locked = 1;

  /* "lupa/lock.pxi":102
 *         return 0
 *     lock._is_locked = True
 *     lock._owner = current_thread             # <<<<<<<<<<<<<<
 *     lock._count = 1
 *     return 1
 */
  __pyx_v_lock->_owner = __pyx_v_current_thread;

  /* "lupa/lock.pxi":103
 *     lock._is_locked = True
 *     lock._owner = current_thread
 *     lock._count = 1             # <<<<<<<<<<<<<<
 *     return 1
 * 
 */
  __pyx_v_lock->_count = 1;

  /* "lupa/lock.pxi":104
 *     lock._owner = current_thread
 *     lock._count = 1
 *     return 1             # <<<<<<<<<<<<<<
 * 
 * cdef inline void unlock_lock(FastRLock lock) nogil:
 */
  __pyx_r = 1;
  goto __pyx_L0;

  /* "lupa/lock.pxi":78
 *         pythread.WAIT_LOCK if blocking else pythread.NOWAIT_LOCK)
 * 
 * cdef bint _acquire_lock(FastRLock lock, long current_thread, int wait) nogil:             # <<<<<<<<<<<<<<
 *     # Note that this function *must* hold the GIL when being called.
 *     # We just use 'nogil' in the signature to make sure that no Python
 */

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

/* "lupa/lock.pxi":106
 *     return 1
 * 
 * cdef inline void unlock_lock(FastRLock lock) nogil:             # <<<<<<<<<<<<<<
 *     # Note that this function *must* hold the GIL when being called.
 *     # We just use 'nogil' in the signature to make sure that no Python
 */

static CYTHON_INLINE void __pyx_f_4lupa_5_lupa_unlock_lock(struct __pyx_obj_4lupa_5_lupa_FastRLock *__pyx_v_lock) {
  int __pyx_t_1;

  /* "lupa/lock.pxi":113
 *     #assert lock._owner == pythread.PyThread_get_thread_ident()
 *     #assert lock._count > 0
 *     lock._count -= 1             # <<<<<<<<<<<<<<
 *     if lock._count == 0:
 *         lock._owner = -1
 */
  __pyx_v_lock->_count = (__pyx_v_lock->_count - 1);

  /* "lupa/lock.pxi":114
 *     #assert lock._count > 0
 *     lock._count -= 1
 *     if lock._count == 0:             # <<<<<<<<<<<<<<
 *         lock._owner = -1
 *         if lock._is_locked:
 */
  __pyx_t_1 = ((__pyx_v_lock->_count == 0) != 0);
  if (__pyx_t_1) {

    /* "lupa/lock.pxi":115
 *     lock._count -= 1
 *     if lock._count == 0:
 *         lock._owner = -1             # <<<<<<<<<<<<<<
 *         if lock._is_locked:
 *             pythread.PyThread_release_lock(lock._real_lock)
 */
    __pyx_v_lock->_owner = -1L;

    /* "lupa/lock.pxi":116
 *     if lock._count == 0:
 *         lock._owner = -1
 *         if lock._is_locked:             # <<<<<<<<<<<<<<
 *             pythread.PyThread_release_lock(lock._real_lock)
 *             lock._is_locked = False
 */
    __pyx_t_1 = (__pyx_v_lock->_is_locked != 0);
    if (__pyx_t_1) {

      /* "lupa/lock.pxi":117
 *         lock._owner = -1
 *         if lock._is_locked:
 *             pythread.PyThread_release_lock(lock._real_lock)             # <<<<<<<<<<<<<<
 *             lock._is_locked = False
 */
      PyThread_release_lock(__pyx_v_lock->_real_lock);

      /* "lupa/lock.pxi":118
 *         if lock._is_locked:
 *             pythread.PyThread_release_lock(lock._real_lock)
 *             lock._is_locked = False             # <<<<<<<<<<<<<<
 */
      __pyx_v_lock->_is_locked = 0;

      /* "lupa/lock.pxi":116
 *     if lock._count == 0:
 *         lock._owner = -1
 *         if lock._is_locked:             # <<<<<<<<<<<<<<
 *             pythread.PyThread_release_lock(lock._real_lock)
 *             lock._is_locked = False
 */
    }

    /* "lupa/lock.pxi":114
 *     #assert lock._count > 0
 *     lock._count -= 1
 *     if lock._count == 0:             # <<<<<<<<<<<<<<
 *         lock._owner = -1
 *         if lock._is_locked:
 */
  }

  /* "lupa/lock.pxi":106
 *     return 1
 * 
 * cdef inline void unlock_lock(FastRLock lock) nogil:             # <<<<<<<<<<<<<<
 *     # Note that this function *must* hold the GIL when being called.
 *     # We just use 'nogil' in the signature to make sure that no Python
 */

  /* function exit code */
}

/* "lupa/_lupa.pyx":101
 * 
 * 
 * def lua_type(obj):             # <<<<<<<<<<<<<<
 *     """
 *     Return the Lua type name of a wrapped object as string, as provided
 */

/* Python wrapper */
static PyObject *__pyx_pw_4lupa_5_lupa_1lua_type(PyObject *__pyx_self, PyObject *__pyx_v_obj); /*proto*/
static char __pyx_doc_4lupa_5_lupa_lua_type[] = "lua_type(obj)\n\n    Return the Lua type name of a wrapped object as string, as provided\n    by Lua's type() function.\n\n    For non-wrapper objects (i.e. normal Python objects), returns None.\n    ";
static PyMethodDef __pyx_mdef_4lupa_5_lupa_1lua_type = {"lua_type", (PyCFunction)__pyx_pw_4lupa_5_lupa_1lua_type, METH_O, __pyx_doc_4lupa_5_lupa_lua_type};
static PyObject *__pyx_pw_4lupa_5_lupa_1lua_type(PyObject *__pyx_self, PyObject *__pyx_v_obj) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("lua_type (wrapper)", 0);
  __pyx_r = __pyx_pf_4lupa_5_lupa_lua_type(__pyx_self, ((PyObject *)__pyx_v_obj));

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

static PyObject *__pyx_pf_4lupa_5_lupa_lua_type(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_obj) {
  struct __pyx_obj_4lupa_5_lupa__LuaObject *__pyx_v_lua_object = NULL;
  lua_State *__pyx_v_L;
  int __pyx_v_old_top;
  char const *__pyx_v_lua_type_name;
  int __pyx_v_ltype;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  int __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  int __pyx_t_4;
  lua_State *__pyx_t_5;
  PyObject *__pyx_t_6 = NULL;
  int __pyx_t_7;
  char const *__pyx_t_8;
  PyObject *__pyx_t_9 = NULL;
  PyObject *__pyx_t_10 = NULL;
  PyObject *__pyx_t_11 = NULL;
  PyObject *__pyx_t_12 = NULL;
  PyObject *__pyx_t_13 = NULL;
  PyObject *__pyx_t_14 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("lua_type", 0);

  /* "lupa/_lupa.pyx":108
 *     For non-wrapper objects (i.e. normal Python objects), returns None.
 *     """
 *     if not isinstance(obj, _LuaObject):             # <<<<<<<<<<<<<<
 *         return None
 *     lua_object = <_LuaObject>obj
 */
  __pyx_t_1 = __Pyx_TypeCheck(__pyx_v_obj, __pyx_ptype_4lupa_5_lupa__LuaObject); 
  __pyx_t_2 = ((!(__pyx_t_1 != 0)) != 0);
  if (__pyx_t_2) {

    /* "lupa/_lupa.pyx":109
 *     """
 *     if not isinstance(obj, _LuaObject):
 *         return None             # <<<<<<<<<<<<<<
 *     lua_object = <_LuaObject>obj
 *     assert lua_object._runtime is not None
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_r = Py_None; __Pyx_INCREF(Py_None);
    goto __pyx_L0;

    /* "lupa/_lupa.pyx":108
 *     For non-wrapper objects (i.e. normal Python objects), returns None.
 *     """
 *     if not isinstance(obj, _LuaObject):             # <<<<<<<<<<<<<<
 *         return None
 *     lua_object = <_LuaObject>obj
 */
  }

  /* "lupa/_lupa.pyx":110
 *     if not isinstance(obj, _LuaObject):
 *         return None
 *     lua_object = <_LuaObject>obj             # <<<<<<<<<<<<<<
 *     assert lua_object._runtime is not None
 *     lock_runtime(lua_object._runtime)
 */
  __pyx_t_3 = __pyx_v_obj;
  __Pyx_INCREF(__pyx_t_3);
  __pyx_v_lua_object = ((struct __pyx_obj_4lupa_5_lupa__LuaObject *)__pyx_t_3);
  __pyx_t_3 = 0;

  /* "lupa/_lupa.pyx":111
 *         return None
 *     lua_object = <_LuaObject>obj
 *     assert lua_object._runtime is not None             # <<<<<<<<<<<<<<
 *     lock_runtime(lua_object._runtime)
 *     L = lua_object._state
 */
  #ifndef CYTHON_WITHOUT_ASSERTIONS
  if (unlikely(!Py_OptimizeFlag)) {
    __pyx_t_2 = (((PyObject *)__pyx_v_lua_object->_runtime) != Py_None);
    if (unlikely(!(__pyx_t_2 != 0))) {
      PyErr_SetNone(PyExc_AssertionError);
      __PYX_ERR(0, 111, __pyx_L1_error)
    }
  }
  #endif

  /* "lupa/_lupa.pyx":112
 *     lua_object = <_LuaObject>obj
 *     assert lua_object._runtime is not None
 *     lock_runtime(lua_object._runtime)             # <<<<<<<<<<<<<<
 *     L = lua_object._state
 *     old_top = lua.lua_gettop(L)
 */
  __pyx_t_3 = ((PyObject *)__pyx_v_lua_object->_runtime);
  __Pyx_INCREF(__pyx_t_3);
  __pyx_t_4 = __pyx_f_4lupa_5_lupa_lock_runtime(((struct __pyx_obj_4lupa_5_lupa_LuaRuntime *)__pyx_t_3)); if (unlikely(__pyx_t_4 == ((int)-1))) __PYX_ERR(0, 112, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

  /* "lupa/_lupa.pyx":113
 *     assert lua_object._runtime is not None
 *     lock_runtime(lua_object._runtime)
 *     L = lua_object._state             # <<<<<<<<<<<<<<
 *     old_top = lua.lua_gettop(L)
 *     cdef const char* lua_type_name
 */
  __pyx_t_5 = __pyx_v_lua_object->_state;
  __pyx_v_L = __pyx_t_5;

  /* "lupa/_lupa.pyx":114
 *     lock_runtime(lua_object._runtime)
 *     L = lua_object._state
 *     old_top = lua.lua_gettop(L)             # <<<<<<<<<<<<<<
 *     cdef const char* lua_type_name
 *     try:
 */
  __pyx_v_old_top = lua_gettop(__pyx_v_L);

  /* "lupa/_lupa.pyx":116
 *     old_top = lua.lua_gettop(L)
 *     cdef const char* lua_type_name
 *     try:             # <<<<<<<<<<<<<<
 *         lua.lua_rawgeti(L, lua.LUA_REGISTRYINDEX, lua_object._ref)
 *         ltype = lua.lua_type(L, -1)
 */
  /*try:*/ {

    /* "lupa/_lupa.pyx":117
 *     cdef const char* lua_type_name
 *     try:
 *         lua.lua_rawgeti(L, lua.LUA_REGISTRYINDEX, lua_object._ref)             # <<<<<<<<<<<<<<
 *         ltype = lua.lua_type(L, -1)
 *         if ltype == lua.LUA_TTABLE:
 */
    lua_rawgeti(__pyx_v_L, LUA_REGISTRYINDEX, __pyx_v_lua_object->_ref);

    /* "lupa/_lupa.pyx":118
 *     try:
 *         lua.lua_rawgeti(L, lua.LUA_REGISTRYINDEX, lua_object._ref)
 *         ltype = lua.lua_type(L, -1)             # <<<<<<<<<<<<<<
 *         if ltype == lua.LUA_TTABLE:
 *             return 'table'
 */
    __pyx_v_ltype = lua_type(__pyx_v_L, -1);

    /* "lupa/_lupa.pyx":119
 *         lua.lua_rawgeti(L, lua.LUA_REGISTRYINDEX, lua_object._ref)
 *         ltype = lua.lua_type(L, -1)
 *         if ltype == lua.LUA_TTABLE:             # <<<<<<<<<<<<<<
 *             return 'table'
 *         elif ltype == lua.LUA_TFUNCTION:
 */
    switch (__pyx_v_ltype) {
      case LUA_TTABLE:

      /* "lupa/_lupa.pyx":120
 *         ltype = lua.lua_type(L, -1)
 *         if ltype == lua.LUA_TTABLE:
 *             return 'table'             # <<<<<<<<<<<<<<
 *         elif ltype == lua.LUA_TFUNCTION:
 *             return 'function'
 */
      __Pyx_XDECREF(__pyx_r);
      __Pyx_INCREF(__pyx_n_s_table);
      __pyx_r = __pyx_n_s_table;
      goto __pyx_L4_return;

      /* "lupa/_lupa.pyx":119
 *         lua.lua_rawgeti(L, lua.LUA_REGISTRYINDEX, lua_object._ref)
 *         ltype = lua.lua_type(L, -1)
 *         if ltype == lua.LUA_TTABLE:             # <<<<<<<<<<<<<<
 *             return 'table'
 *         elif ltype == lua.LUA_TFUNCTION:
 */
      break;
      case LUA_TFUNCTION:

      /* "lupa/_lupa.pyx":122
 *             return 'table'
 *         elif ltype == lua.LUA_TFUNCTION:
 *             return 'function'             # <<<<<<<<<<<<<<
 *         elif ltype == lua.LUA_TTHREAD:
 *             return 'thread'
 */
      __Pyx_XDECREF(__pyx_r);
      __Pyx_INCREF(__pyx_n_s_function);
      __pyx_r = __pyx_n_s_function;
      goto __pyx_L4_return;

      /* "lupa/_lupa.pyx":121
 *         if ltype == lua.LUA_TTABLE:
 *             return 'table'
 *         elif ltype == lua.LUA_TFUNCTION:             # <<<<<<<<<<<<<<
 *             return 'function'
 *         elif ltype == lua.LUA_TTHREAD:
 */
      break;
      case LUA_TTHREAD:

      /* "lupa/_lupa.pyx":124
 *             return 'function'
 *         elif ltype == lua.LUA_TTHREAD:
 *             return 'thread'             # <<<<<<<<<<<<<<
 *         elif ltype in (lua.LUA_TUSERDATA, lua.LUA_TLIGHTUSERDATA):
 *             return 'userdata'
 */
      __Pyx_XDECREF(__pyx_r);
      __Pyx_INCREF(__pyx_n_s_thread);
      __pyx_r = __pyx_n_s_thread;
      goto __pyx_L4_return;

      /* "lupa/_lupa.pyx":123
 *         elif ltype == lua.LUA_TFUNCTION:
 *             return 'function'
 *         elif ltype == lua.LUA_TTHREAD:             # <<<<<<<<<<<<<<
 *             return 'thread'
 *         elif ltype in (lua.LUA_TUSERDATA, lua.LUA_TLIGHTUSERDATA):
 */
      break;
      case LUA_TUSERDATA:

      /* "lupa/_lupa.pyx":125
 *         elif ltype == lua.LUA_TTHREAD:
 *             return 'thread'
 *         elif ltype in (lua.LUA_TUSERDATA, lua.LUA_TLIGHTUSERDATA):             # <<<<<<<<<<<<<<
 *             return 'userdata'
 *         else:
 */
      case LUA_TLIGHTUSERDATA:

      /* "lupa/_lupa.pyx":126
 *             return 'thread'
 *         elif ltype in (lua.LUA_TUSERDATA, lua.LUA_TLIGHTUSERDATA):
 *             return 'userdata'             # <<<<<<<<<<<<<<
 *         else:
 *             lua_type_name = lua.lua_typename(L, ltype)
 */
      __Pyx_XDECREF(__pyx_r);
      __Pyx_INCREF(__pyx_n_s_userdata);
      __pyx_r = __pyx_n_s_userdata;
      goto __pyx_L4_return;

      /* "lupa/_lupa.pyx":125
 *         elif ltype == lua.LUA_TTHREAD:
 *             return 'thread'
 *         elif ltype in (lua.LUA_TUSERDATA, lua.LUA_TLIGHTUSERDATA):             # <<<<<<<<<<<<<<
 *             return 'userdata'
 *         else:
 */
      break;
      default:

      /* "lupa/_lupa.pyx":128
 *             return 'userdata'
 *         else:
 *             lua_type_name = lua.lua_typename(L, ltype)             # <<<<<<<<<<<<<<
 *             return lua_type_name if IS_PY2 else lua_type_name.decode('ascii')
 *     finally:
 */
      __pyx_v_lua_type_name = lua_typename(__pyx_v_L, __pyx_v_ltype);

      /* "lupa/_lupa.pyx":129
 *         else:
 *             lua_type_name = lua.lua_typename(L, ltype)
 *             return lua_type_name if IS_PY2 else lua_type_name.decode('ascii')             # <<<<<<<<<<<<<<
 *     finally:
 *         lua.lua_settop(L, old_top)
 */
      __Pyx_XDECREF(__pyx_r);
      if ((IS_PY2 != 0)) {
        __pyx_t_6 = __Pyx_PyBytes_FromString(__pyx_v_lua_type_name); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 129, __pyx_L5_error)
        __Pyx_GOTREF(__pyx_t_6);
        __pyx_t_3 = __pyx_t_6;
        __pyx_t_6 = 0;
      } else {
        __pyx_t_6 = __Pyx_decode_c_string(__pyx_v_lua_type_name, 0, strlen(__pyx_v_lua_type_name), NULL, NULL, PyUnicode_DecodeASCII); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 129, __pyx_L5_error)
        __Pyx_GOTREF(__pyx_t_6);
        __pyx_t_3 = __pyx_t_6;
        __pyx_t_6 = 0;
      }
      __pyx_r = __pyx_t_3;
      __pyx_t_3 = 0;
      goto __pyx_L4_return;
      break;
    }
  }

  /* "lupa/_lupa.pyx":131
 *             return lua_type_name if IS_PY2 else lua_type_name.decode('ascii')
 *     finally:
 *         lua.lua_settop(L, old_top)             # <<<<<<<<<<<<<<
 *         unlock_runtime(lua_object._runtime)
 * 
 */
  /*finally:*/ {
    __pyx_L5_error:;
    /*exception exit:*/{
      __Pyx_PyThreadState_declare
      __Pyx_PyThreadState_assign
      __pyx_t_9 = 0; __pyx_t_10 = 0; __pyx_t_11 = 0; __pyx_t_12 = 0; __pyx_t_13 = 0; __pyx_t_14 = 0;
      __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
      if (PY_MAJOR_VERSION >= 3) __Pyx_ExceptionSwap(&__pyx_t_12, &__pyx_t_13, &__pyx_t_14);
      if ((PY_MAJOR_VERSION < 3) || unlikely(__Pyx_GetException(&__pyx_t_9, &__pyx_t_10, &__pyx_t_11) < 0)) __Pyx_ErrFetch(&__pyx_t_9, &__pyx_t_10, &__pyx_t_11);
      __Pyx_XGOTREF(__pyx_t_9);
      __Pyx_XGOTREF(__pyx_t_10);
      __Pyx_XGOTREF(__pyx_t_11);
      __Pyx_XGOTREF(__pyx_t_12);
      __Pyx_XGOTREF(__pyx_t_13);
      __Pyx_XGOTREF(__pyx_t_14);
      __pyx_t_4 = __pyx_lineno; __pyx_t_7 = __pyx_clineno; __pyx_t_8 = __pyx_filename;
      {
        lua_settop(__pyx_v_L, __pyx_v_old_top);

        /* "lupa/_lupa.pyx":132
 *     finally:
 *         lua.lua_settop(L, old_top)
 *         unlock_runtime(lua_object._runtime)             # <<<<<<<<<<<<<<
 * 
 * 
 */
        __pyx_t_3 = ((PyObject *)__pyx_v_lua_object->_runtime);
        __Pyx_INCREF(__pyx_t_3);
        __pyx_f_4lupa_5_lupa_unlock_runtime(((struct __pyx_obj_4lupa_5_lupa_LuaRuntime *)__pyx_t_3));
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      }
      if (PY_MAJOR_VERSION >= 3) {
        __Pyx_XGIVEREF(__pyx_t_12);
        __Pyx_XGIVEREF(__pyx_t_13);
        __Pyx_XGIVEREF(__pyx_t_14);
        __Pyx_ExceptionReset(__pyx_t_12, __pyx_t_13, __pyx_t_14);
      }
      __Pyx_XGIVEREF(__pyx_t_9);
      __Pyx_XGIVEREF(__pyx_t_10);
      __Pyx_XGIVEREF(__pyx_t_11);
      __Pyx_ErrRestore(__pyx_t_9, __pyx_t_10, __pyx_t_11);
      __pyx_t_9 = 0; __pyx_t_10 = 0; __pyx_t_11 = 0; __pyx_t_12 = 0; __pyx_t_13 = 0; __pyx_t_14 = 0;
      __pyx_lineno = __pyx_t_4; __pyx_clineno = __pyx_t_7; __pyx_filename = __pyx_t_8;
      goto __pyx_L1_error;
    }
    __pyx_L4_return: {
      __pyx_t_14 = __pyx_r;
      __pyx_r = 0;

      /* "lupa/_lupa.pyx":131
 *             return lua_type_name if IS_PY2 else lua_type_name.decode('ascii')
 *     finally:
 *         lua.lua_settop(L, old_top)             # <<<<<<<<<<<<<<
 *         unlock_runtime(lua_object._runtime)
 * 
 */
      lua_settop(__pyx_v_L, __pyx_v_old_top);

      /* "lupa/_lupa.pyx":132
 *     finally:
 *         lua.lua_settop(L, old_top)
 *         unlock_runtime(lua_object._runtime)             # <<<<<<<<<<<<<<
 * 
 * 
 */
      __pyx_t_3 = ((PyObject *)__pyx_v_lua_object->_runtime);
      __Pyx_INCREF(__pyx_t_3);
      __pyx_f_4lupa_5_lupa_unlock_runtime(((struct __pyx_obj_4lupa_5_lupa_LuaRuntime *)__pyx_t_3));
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_r = __pyx_t_14;
      __pyx_t_14 = 0;
      goto __pyx_L0;
    }
  }

  /* "lupa/_lupa.pyx":101
 * 
 * 
 * def lua_type(obj):             # <<<<<<<<<<<<<<
 *     """
 *     Return the Lua type name of a wrapped object as string, as provided
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_AddTraceback("lupa._lupa.lua_type", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_lua_object);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lupa/_lupa.pyx":213
 *     cdef bint _unpack_returned_tuples
 * 
 *     def __cinit__(self, encoding='UTF-8', source_encoding=None,             # <<<<<<<<<<<<<<
 *                   attribute_filter=None, attribute_handlers=None,
 *                   bint register_eval=True, bint unpack_returned_tuples=False,
 */

/* Python wrapper */
static int __pyx_pw_4lupa_5_lupa_10LuaRuntime_1__cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static int __pyx_pw_4lupa_5_lupa_10LuaRuntime_1__cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_encoding = 0;
  PyObject *__pyx_v_source_encoding = 0;
  PyObject *__pyx_v_attribute_filter = 0;
  PyObject *__pyx_v_attribute_handlers = 0;
  int __pyx_v_register_eval;
  int __pyx_v_unpack_returned_tuples;
  int __pyx_v_register_builtins;
  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_encoding,&__pyx_n_s_source_encoding,&__pyx_n_s_attribute_filter,&__pyx_n_s_attribute_handlers,&__pyx_n_s_register_eval,&__pyx_n_s_unpack_returned_tuples,&__pyx_n_s_register_builtins,0};
    PyObject* values[7] = {0,0,0,0,0,0,0};
    values[0] = ((PyObject *)__pyx_kp_s_UTF_8);
    values[1] = ((PyObject *)Py_None);

    /* "lupa/_lupa.pyx":214
 * 
 *     def __cinit__(self, encoding='UTF-8', source_encoding=None,
 *                   attribute_filter=None, attribute_handlers=None,             # <<<<<<<<<<<<<<
 *                   bint register_eval=True, bint unpack_returned_tuples=False,
 *                   bint register_builtins=True):
 */
    values[2] = ((PyObject *)Py_None);
    values[3] = ((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  7: values[6] = PyTuple_GET_ITEM(__pyx_args, 6);
        CYTHON_FALLTHROUGH;
        case  6: values[5] = PyTuple_GET_ITEM(__pyx_args, 5);
        CYTHON_FALLTHROUGH;
        case  5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
        CYTHON_FALLTHROUGH;
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        CYTHON_FALLTHROUGH;
        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 (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_encoding);
          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_source_encoding);
          if (value) { values[1] = value; kw_args--; }
        }
        CYTHON_FALLTHROUGH;
        case  2:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_attribute_filter);
          if (value) { values[2] = value; kw_args--; }
        }
        CYTHON_FALLTHROUGH;
        case  3:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_attribute_handlers);
          if (value) { values[3] = value; kw_args--; }
        }
        CYTHON_FALLTHROUGH;
        case  4:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_register_eval);
          if (value) { values[4] = value; kw_args--; }
        }
        CYTHON_FALLTHROUGH;
        case  5:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_unpack_returned_tuples);
          if (value) { values[5] = value; kw_args--; }
        }
        CYTHON_FALLTHROUGH;
        case  6:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_register_builtins);
          if (value) { values[6] = 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, 213, __pyx_L3_error)
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  7: values[6] = PyTuple_GET_ITEM(__pyx_args, 6);
        CYTHON_FALLTHROUGH;
        case  6: values[5] = PyTuple_GET_ITEM(__pyx_args, 5);
        CYTHON_FALLTHROUGH;
        case  5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
        CYTHON_FALLTHROUGH;
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        CYTHON_FALLTHROUGH;
        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;
      }
    }
    __pyx_v_encoding = values[0];
    __pyx_v_source_encoding = values[1];
    __pyx_v_attribute_filter = values[2];
    __pyx_v_attribute_handlers = values[3];
    if (values[4]) {
      __pyx_v_register_eval = __Pyx_PyObject_IsTrue(values[4]); if (unlikely((__pyx_v_register_eval == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 215, __pyx_L3_error)
    } else {

      /* "lupa/_lupa.pyx":215
 *     def __cinit__(self, encoding='UTF-8', source_encoding=None,
 *                   attribute_filter=None, attribute_handlers=None,
 *                   bint register_eval=True, bint unpack_returned_tuples=False,             # <<<<<<<<<<<<<<
 *                   bint register_builtins=True):
 *         cdef lua_State* L = lua.luaL_newstate()
 */
      __pyx_v_register_eval = ((int)1);
    }
    if (values[5]) {
      __pyx_v_unpack_returned_tuples = __Pyx_PyObject_IsTrue(values[5]); if (unlikely((__pyx_v_unpack_returned_tuples == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 215, __pyx_L3_error)
    } else {
      __pyx_v_unpack_returned_tuples = ((int)0);
    }
    if (values[6]) {
      __pyx_v_register_builtins = __Pyx_PyObject_IsTrue(values[6]); if (unlikely((__pyx_v_register_builtins == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 216, __pyx_L3_error)
    } else {

      /* "lupa/_lupa.pyx":216
 *                   attribute_filter=None, attribute_handlers=None,
 *                   bint register_eval=True, bint unpack_returned_tuples=False,
 *                   bint register_builtins=True):             # <<<<<<<<<<<<<<
 *         cdef lua_State* L = lua.luaL_newstate()
 *         if L is NULL:
 */
      __pyx_v_register_builtins = ((int)1);
    }
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("__cinit__", 0, 0, 7, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 213, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("lupa._lupa.LuaRuntime.__cinit__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return -1;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_4lupa_5_lupa_10LuaRuntime___cinit__(((struct __pyx_obj_4lupa_5_lupa_LuaRuntime *)__pyx_v_self), __pyx_v_encoding, __pyx_v_source_encoding, __pyx_v_attribute_filter, __pyx_v_attribute_handlers, __pyx_v_register_eval, __pyx_v_unpack_returned_tuples, __pyx_v_register_builtins);

  /* "lupa/_lupa.pyx":213
 *     cdef bint _unpack_returned_tuples
 * 
 *     def __cinit__(self, encoding='UTF-8', source_encoding=None,             # <<<<<<<<<<<<<<
 *                   attribute_filter=None, attribute_handlers=None,
 *                   bint register_eval=True, bint unpack_returned_tuples=False,
 */

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

static int __pyx_pf_4lupa_5_lupa_10LuaRuntime___cinit__(struct __pyx_obj_4lupa_5_lupa_LuaRuntime *__pyx_v_self, PyObject *__pyx_v_encoding, PyObject *__pyx_v_source_encoding, PyObject *__pyx_v_attribute_filter, PyObject *__pyx_v_attribute_handlers, int __pyx_v_register_eval, int __pyx_v_unpack_returned_tuples, int __pyx_v_register_builtins) {
  lua_State *__pyx_v_L;
  int __pyx_v_raise_error;
  PyObject *__pyx_v_getter = NULL;
  PyObject *__pyx_v_setter = NULL;
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  int __pyx_t_5;
  int __pyx_t_6;
  PyObject *__pyx_t_7 = NULL;
  PyObject *__pyx_t_8 = NULL;
  PyObject *__pyx_t_9 = NULL;
  PyObject *(*__pyx_t_10)(PyObject *);
  int __pyx_t_11;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__cinit__", 0);

  /* "lupa/_lupa.pyx":217
 *                   bint register_eval=True, bint unpack_returned_tuples=False,
 *                   bint register_builtins=True):
 *         cdef lua_State* L = lua.luaL_newstate()             # <<<<<<<<<<<<<<
 *         if L is NULL:
 *             raise LuaError("Failed to initialise Lua runtime")
 */
  __pyx_v_L = luaL_newstate();

  /* "lupa/_lupa.pyx":218
 *                   bint register_builtins=True):
 *         cdef lua_State* L = lua.luaL_newstate()
 *         if L is NULL:             # <<<<<<<<<<<<<<
 *             raise LuaError("Failed to initialise Lua runtime")
 *         self._state = L
 */
  __pyx_t_1 = ((__pyx_v_L == NULL) != 0);
  if (unlikely(__pyx_t_1)) {

    /* "lupa/_lupa.pyx":219
 *         cdef lua_State* L = lua.luaL_newstate()
 *         if L is NULL:
 *             raise LuaError("Failed to initialise Lua runtime")             # <<<<<<<<<<<<<<
 *         self._state = L
 *         self._lock = FastRLock()
 */
    __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_LuaError); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 219, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __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_kp_s_Failed_to_initialise_Lua_runtime) : __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_kp_s_Failed_to_initialise_Lua_runtime);
    __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
    if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 219, __pyx_L1_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, 219, __pyx_L1_error)

    /* "lupa/_lupa.pyx":218
 *                   bint register_builtins=True):
 *         cdef lua_State* L = lua.luaL_newstate()
 *         if L is NULL:             # <<<<<<<<<<<<<<
 *             raise LuaError("Failed to initialise Lua runtime")
 *         self._state = L
 */
  }

  /* "lupa/_lupa.pyx":220
 *         if L is NULL:
 *             raise LuaError("Failed to initialise Lua runtime")
 *         self._state = L             # <<<<<<<<<<<<<<
 *         self._lock = FastRLock()
 *         self._pyrefs_in_lua = {}
 */
  __pyx_v_self->_state = __pyx_v_L;

  /* "lupa/_lupa.pyx":221
 *             raise LuaError("Failed to initialise Lua runtime")
 *         self._state = L
 *         self._lock = FastRLock()             # <<<<<<<<<<<<<<
 *         self._pyrefs_in_lua = {}
 *         self._encoding = _asciiOrNone(encoding)
 */
  __pyx_t_2 = __Pyx_PyObject_CallNoArg(((PyObject *)__pyx_ptype_4lupa_5_lupa_FastRLock)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 221, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_GIVEREF(__pyx_t_2);
  __Pyx_GOTREF(__pyx_v_self->_lock);
  __Pyx_DECREF(((PyObject *)__pyx_v_self->_lock));
  __pyx_v_self->_lock = ((struct __pyx_obj_4lupa_5_lupa_FastRLock *)__pyx_t_2);
  __pyx_t_2 = 0;

  /* "lupa/_lupa.pyx":222
 *         self._state = L
 *         self._lock = FastRLock()
 *         self._pyrefs_in_lua = {}             # <<<<<<<<<<<<<<
 *         self._encoding = _asciiOrNone(encoding)
 *         self._source_encoding = _asciiOrNone(source_encoding) or self._encoding or b'UTF-8'
 */
  __pyx_t_2 = __Pyx_PyDict_NewPresized(0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 222, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_GIVEREF(__pyx_t_2);
  __Pyx_GOTREF(__pyx_v_self->_pyrefs_in_lua);
  __Pyx_DECREF(__pyx_v_self->_pyrefs_in_lua);
  __pyx_v_self->_pyrefs_in_lua = ((PyObject*)__pyx_t_2);
  __pyx_t_2 = 0;

  /* "lupa/_lupa.pyx":223
 *         self._lock = FastRLock()
 *         self._pyrefs_in_lua = {}
 *         self._encoding = _asciiOrNone(encoding)             # <<<<<<<<<<<<<<
 *         self._source_encoding = _asciiOrNone(source_encoding) or self._encoding or b'UTF-8'
 *         if attribute_filter is not None and not callable(attribute_filter):
 */
  __pyx_t_2 = __pyx_f_4lupa_5_lupa__asciiOrNone(__pyx_v_encoding); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 223, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_GIVEREF(__pyx_t_2);
  __Pyx_GOTREF(__pyx_v_self->_encoding);
  __Pyx_DECREF(__pyx_v_self->_encoding);
  __pyx_v_self->_encoding = ((PyObject*)__pyx_t_2);
  __pyx_t_2 = 0;

  /* "lupa/_lupa.pyx":224
 *         self._pyrefs_in_lua = {}
 *         self._encoding = _asciiOrNone(encoding)
 *         self._source_encoding = _asciiOrNone(source_encoding) or self._encoding or b'UTF-8'             # <<<<<<<<<<<<<<
 *         if attribute_filter is not None and not callable(attribute_filter):
 *             raise ValueError("attribute_filter must be callable")
 */
  __pyx_t_3 = __pyx_f_4lupa_5_lupa__asciiOrNone(__pyx_v_source_encoding); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 224, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_1 < 0)) __PYX_ERR(0, 224, __pyx_L1_error)
  if (!__pyx_t_1) {
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  } else {
    __Pyx_INCREF(__pyx_t_3);
    __pyx_t_2 = __pyx_t_3;
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    goto __pyx_L4_bool_binop_done;
  }
  __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_v_self->_encoding); if (unlikely(__pyx_t_1 < 0)) __PYX_ERR(0, 224, __pyx_L1_error)
  if (!__pyx_t_1) {
  } else {
    __Pyx_INCREF(__pyx_v_self->_encoding);
    __pyx_t_2 = __pyx_v_self->_encoding;
    goto __pyx_L4_bool_binop_done;
  }
  __Pyx_INCREF(__pyx_kp_b_UTF_8);
  __pyx_t_2 = __pyx_kp_b_UTF_8;
  __pyx_L4_bool_binop_done:;
  __Pyx_GIVEREF(__pyx_t_2);
  __Pyx_GOTREF(__pyx_v_self->_source_encoding);
  __Pyx_DECREF(__pyx_v_self->_source_encoding);
  __pyx_v_self->_source_encoding = ((PyObject*)__pyx_t_2);
  __pyx_t_2 = 0;

  /* "lupa/_lupa.pyx":225
 *         self._encoding = _asciiOrNone(encoding)
 *         self._source_encoding = _asciiOrNone(source_encoding) or self._encoding or b'UTF-8'
 *         if attribute_filter is not None and not callable(attribute_filter):             # <<<<<<<<<<<<<<
 *             raise ValueError("attribute_filter must be callable")
 *         self._attribute_filter = attribute_filter
 */
  __pyx_t_5 = (__pyx_v_attribute_filter != Py_None);
  __pyx_t_6 = (__pyx_t_5 != 0);
  if (__pyx_t_6) {
  } else {
    __pyx_t_1 = __pyx_t_6;
    goto __pyx_L8_bool_binop_done;
  }
  __pyx_t_6 = __Pyx_PyCallable_Check(__pyx_v_attribute_filter); if (unlikely(__pyx_t_6 == ((int)-1))) __PYX_ERR(0, 225, __pyx_L1_error)
  __pyx_t_5 = ((!(__pyx_t_6 != 0)) != 0);
  __pyx_t_1 = __pyx_t_5;
  __pyx_L8_bool_binop_done:;
  if (unlikely(__pyx_t_1)) {

    /* "lupa/_lupa.pyx":226
 *         self._source_encoding = _asciiOrNone(source_encoding) or self._encoding or b'UTF-8'
 *         if attribute_filter is not None and not callable(attribute_filter):
 *             raise ValueError("attribute_filter must be callable")             # <<<<<<<<<<<<<<
 *         self._attribute_filter = attribute_filter
 *         self._unpack_returned_tuples = unpack_returned_tuples
 */
    __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__4, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 226, __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, 226, __pyx_L1_error)

    /* "lupa/_lupa.pyx":225
 *         self._encoding = _asciiOrNone(encoding)
 *         self._source_encoding = _asciiOrNone(source_encoding) or self._encoding or b'UTF-8'
 *         if attribute_filter is not None and not callable(attribute_filter):             # <<<<<<<<<<<<<<
 *             raise ValueError("attribute_filter must be callable")
 *         self._attribute_filter = attribute_filter
 */
  }

  /* "lupa/_lupa.pyx":227
 *         if attribute_filter is not None and not callable(attribute_filter):
 *             raise ValueError("attribute_filter must be callable")
 *         self._attribute_filter = attribute_filter             # <<<<<<<<<<<<<<
 *         self._unpack_returned_tuples = unpack_returned_tuples
 * 
 */
  __Pyx_INCREF(__pyx_v_attribute_filter);
  __Pyx_GIVEREF(__pyx_v_attribute_filter);
  __Pyx_GOTREF(__pyx_v_self->_attribute_filter);
  __Pyx_DECREF(__pyx_v_self->_attribute_filter);
  __pyx_v_self->_attribute_filter = __pyx_v_attribute_filter;

  /* "lupa/_lupa.pyx":228
 *             raise ValueError("attribute_filter must be callable")
 *         self._attribute_filter = attribute_filter
 *         self._unpack_returned_tuples = unpack_returned_tuples             # <<<<<<<<<<<<<<
 * 
 *         if attribute_handlers:
 */
  __pyx_v_self->_unpack_returned_tuples = __pyx_v_unpack_returned_tuples;

  /* "lupa/_lupa.pyx":230
 *         self._unpack_returned_tuples = unpack_returned_tuples
 * 
 *         if attribute_handlers:             # <<<<<<<<<<<<<<
 *             raise_error = False
 *             try:
 */
  __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_v_attribute_handlers); if (unlikely(__pyx_t_1 < 0)) __PYX_ERR(0, 230, __pyx_L1_error)
  if (__pyx_t_1) {

    /* "lupa/_lupa.pyx":231
 * 
 *         if attribute_handlers:
 *             raise_error = False             # <<<<<<<<<<<<<<
 *             try:
 *                 getter, setter = attribute_handlers
 */
    __pyx_v_raise_error = 0;

    /* "lupa/_lupa.pyx":232
 *         if attribute_handlers:
 *             raise_error = False
 *             try:             # <<<<<<<<<<<<<<
 *                 getter, setter = attribute_handlers
 *             except (ValueError, TypeError):
 */
    {
      __Pyx_PyThreadState_declare
      __Pyx_PyThreadState_assign
      __Pyx_ExceptionSave(&__pyx_t_7, &__pyx_t_8, &__pyx_t_9);
      __Pyx_XGOTREF(__pyx_t_7);
      __Pyx_XGOTREF(__pyx_t_8);
      __Pyx_XGOTREF(__pyx_t_9);
      /*try:*/ {

        /* "lupa/_lupa.pyx":233
 *             raise_error = False
 *             try:
 *                 getter, setter = attribute_handlers             # <<<<<<<<<<<<<<
 *             except (ValueError, TypeError):
 *                 raise_error = True
 */
        if ((likely(PyTuple_CheckExact(__pyx_v_attribute_handlers))) || (PyList_CheckExact(__pyx_v_attribute_handlers))) {
          PyObject* sequence = __pyx_v_attribute_handlers;
          Py_ssize_t size = __Pyx_PySequence_SIZE(sequence);
          if (unlikely(size != 2)) {
            if (size > 2) __Pyx_RaiseTooManyValuesError(2);
            else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
            __PYX_ERR(0, 233, __pyx_L11_error)
          }
          #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
          if (likely(PyTuple_CheckExact(sequence))) {
            __pyx_t_2 = PyTuple_GET_ITEM(sequence, 0); 
            __pyx_t_3 = PyTuple_GET_ITEM(sequence, 1); 
          } else {
            __pyx_t_2 = PyList_GET_ITEM(sequence, 0); 
            __pyx_t_3 = PyList_GET_ITEM(sequence, 1); 
          }
          __Pyx_INCREF(__pyx_t_2);
          __Pyx_INCREF(__pyx_t_3);
          #else
          __pyx_t_2 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 233, __pyx_L11_error)
          __Pyx_GOTREF(__pyx_t_2);
          __pyx_t_3 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 233, __pyx_L11_error)
          __Pyx_GOTREF(__pyx_t_3);
          #endif
        } else {
          Py_ssize_t index = -1;
          __pyx_t_4 = PyObject_GetIter(__pyx_v_attribute_handlers); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 233, __pyx_L11_error)
          __Pyx_GOTREF(__pyx_t_4);
          __pyx_t_10 = Py_TYPE(__pyx_t_4)->tp_iternext;
          index = 0; __pyx_t_2 = __pyx_t_10(__pyx_t_4); if (unlikely(!__pyx_t_2)) goto __pyx_L17_unpacking_failed;
          __Pyx_GOTREF(__pyx_t_2);
          index = 1; __pyx_t_3 = __pyx_t_10(__pyx_t_4); if (unlikely(!__pyx_t_3)) goto __pyx_L17_unpacking_failed;
          __Pyx_GOTREF(__pyx_t_3);
          if (__Pyx_IternextUnpackEndCheck(__pyx_t_10(__pyx_t_4), 2) < 0) __PYX_ERR(0, 233, __pyx_L11_error)
          __pyx_t_10 = NULL;
          __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
          goto __pyx_L18_unpacking_done;
          __pyx_L17_unpacking_failed:;
          __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
          __pyx_t_10 = NULL;
          if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
          __PYX_ERR(0, 233, __pyx_L11_error)
          __pyx_L18_unpacking_done:;
        }
        __pyx_v_getter = __pyx_t_2;
        __pyx_t_2 = 0;
        __pyx_v_setter = __pyx_t_3;
        __pyx_t_3 = 0;

        /* "lupa/_lupa.pyx":232
 *         if attribute_handlers:
 *             raise_error = False
 *             try:             # <<<<<<<<<<<<<<
 *                 getter, setter = attribute_handlers
 *             except (ValueError, TypeError):
 */
      }

      /* "lupa/_lupa.pyx":237
 *                 raise_error = True
 *             else:
 *                 if (getter is not None and not callable(getter) or             # <<<<<<<<<<<<<<
 *                         setter is not None and not callable(setter)):
 *                     raise_error = True
 */
      /*else:*/ {
        __pyx_t_5 = (__pyx_v_getter != Py_None);
        __pyx_t_6 = (__pyx_t_5 != 0);
        if (!__pyx_t_6) {
          goto __pyx_L21_next_or;
        } else {
        }
        __pyx_t_6 = __Pyx_PyCallable_Check(__pyx_v_getter); if (unlikely(__pyx_t_6 == ((int)-1))) __PYX_ERR(0, 237, __pyx_L13_except_error)
        __pyx_t_5 = ((!(__pyx_t_6 != 0)) != 0);
        if (!__pyx_t_5) {
        } else {
          __pyx_t_1 = __pyx_t_5;
          goto __pyx_L20_bool_binop_done;
        }
        __pyx_L21_next_or:;

        /* "lupa/_lupa.pyx":238
 *             else:
 *                 if (getter is not None and not callable(getter) or
 *                         setter is not None and not callable(setter)):             # <<<<<<<<<<<<<<
 *                     raise_error = True
 *             if raise_error:
 */
        __pyx_t_5 = (__pyx_v_setter != Py_None);
        __pyx_t_6 = (__pyx_t_5 != 0);
        if (__pyx_t_6) {
        } else {
          __pyx_t_1 = __pyx_t_6;
          goto __pyx_L20_bool_binop_done;
        }
        __pyx_t_6 = __Pyx_PyCallable_Check(__pyx_v_setter); if (unlikely(__pyx_t_6 == ((int)-1))) __PYX_ERR(0, 238, __pyx_L13_except_error)
        __pyx_t_5 = ((!(__pyx_t_6 != 0)) != 0);
        __pyx_t_1 = __pyx_t_5;
        __pyx_L20_bool_binop_done:;

        /* "lupa/_lupa.pyx":237
 *                 raise_error = True
 *             else:
 *                 if (getter is not None and not callable(getter) or             # <<<<<<<<<<<<<<
 *                         setter is not None and not callable(setter)):
 *                     raise_error = True
 */
        if (__pyx_t_1) {

          /* "lupa/_lupa.pyx":239
 *                 if (getter is not None and not callable(getter) or
 *                         setter is not None and not callable(setter)):
 *                     raise_error = True             # <<<<<<<<<<<<<<
 *             if raise_error:
 *                 raise ValueError("attribute_handlers must be a sequence of two callables")
 */
          __pyx_v_raise_error = 1;

          /* "lupa/_lupa.pyx":237
 *                 raise_error = True
 *             else:
 *                 if (getter is not None and not callable(getter) or             # <<<<<<<<<<<<<<
 *                         setter is not None and not callable(setter)):
 *                     raise_error = True
 */
        }
      }
      __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
      __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
      __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
      goto __pyx_L16_try_end;
      __pyx_L11_error:;
      __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;

      /* "lupa/_lupa.pyx":234
 *             try:
 *                 getter, setter = attribute_handlers
 *             except (ValueError, TypeError):             # <<<<<<<<<<<<<<
 *                 raise_error = True
 *             else:
 */
      __pyx_t_11 = __Pyx_PyErr_ExceptionMatches(__pyx_builtin_ValueError) || __Pyx_PyErr_ExceptionMatches(__pyx_builtin_TypeError);
      if (__pyx_t_11) {
        __Pyx_AddTraceback("lupa._lupa.LuaRuntime.__cinit__", __pyx_clineno, __pyx_lineno, __pyx_filename);
        if (__Pyx_GetException(&__pyx_t_3, &__pyx_t_2, &__pyx_t_4) < 0) __PYX_ERR(0, 234, __pyx_L13_except_error)
        __Pyx_GOTREF(__pyx_t_3);
        __Pyx_GOTREF(__pyx_t_2);
        __Pyx_GOTREF(__pyx_t_4);

        /* "lupa/_lupa.pyx":235
 *                 getter, setter = attribute_handlers
 *             except (ValueError, TypeError):
 *                 raise_error = True             # <<<<<<<<<<<<<<
 *             else:
 *                 if (getter is not None and not callable(getter) or
 */
        __pyx_v_raise_error = 1;
        __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
        __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
        __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
        goto __pyx_L12_exception_handled;
      }
      goto __pyx_L13_except_error;
      __pyx_L13_except_error:;

      /* "lupa/_lupa.pyx":232
 *         if attribute_handlers:
 *             raise_error = False
 *             try:             # <<<<<<<<<<<<<<
 *                 getter, setter = attribute_handlers
 *             except (ValueError, TypeError):
 */
      __Pyx_XGIVEREF(__pyx_t_7);
      __Pyx_XGIVEREF(__pyx_t_8);
      __Pyx_XGIVEREF(__pyx_t_9);
      __Pyx_ExceptionReset(__pyx_t_7, __pyx_t_8, __pyx_t_9);
      goto __pyx_L1_error;
      __pyx_L12_exception_handled:;
      __Pyx_XGIVEREF(__pyx_t_7);
      __Pyx_XGIVEREF(__pyx_t_8);
      __Pyx_XGIVEREF(__pyx_t_9);
      __Pyx_ExceptionReset(__pyx_t_7, __pyx_t_8, __pyx_t_9);
      __pyx_L16_try_end:;
    }

    /* "lupa/_lupa.pyx":240
 *                         setter is not None and not callable(setter)):
 *                     raise_error = True
 *             if raise_error:             # <<<<<<<<<<<<<<
 *                 raise ValueError("attribute_handlers must be a sequence of two callables")
 *             if attribute_filter and (getter is not None or setter is not None):
 */
    __pyx_t_1 = (__pyx_v_raise_error != 0);
    if (unlikely(__pyx_t_1)) {

      /* "lupa/_lupa.pyx":241
 *                     raise_error = True
 *             if raise_error:
 *                 raise ValueError("attribute_handlers must be a sequence of two callables")             # <<<<<<<<<<<<<<
 *             if attribute_filter and (getter is not None or setter is not None):
 *                 raise ValueError("attribute_filter and attribute_handlers are mutually exclusive")
 */
      __pyx_t_4 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__5, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 241, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_Raise(__pyx_t_4, 0, 0, 0);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __PYX_ERR(0, 241, __pyx_L1_error)

      /* "lupa/_lupa.pyx":240
 *                         setter is not None and not callable(setter)):
 *                     raise_error = True
 *             if raise_error:             # <<<<<<<<<<<<<<
 *                 raise ValueError("attribute_handlers must be a sequence of two callables")
 *             if attribute_filter and (getter is not None or setter is not None):
 */
    }

    /* "lupa/_lupa.pyx":242
 *             if raise_error:
 *                 raise ValueError("attribute_handlers must be a sequence of two callables")
 *             if attribute_filter and (getter is not None or setter is not None):             # <<<<<<<<<<<<<<
 *                 raise ValueError("attribute_filter and attribute_handlers are mutually exclusive")
 *             self._attribute_getter, self._attribute_setter = getter, setter
 */
    __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_v_attribute_filter); if (unlikely(__pyx_t_5 < 0)) __PYX_ERR(0, 242, __pyx_L1_error)
    if (__pyx_t_5) {
    } else {
      __pyx_t_1 = __pyx_t_5;
      goto __pyx_L28_bool_binop_done;
    }
    if (unlikely(!__pyx_v_getter)) { __Pyx_RaiseUnboundLocalError("getter"); __PYX_ERR(0, 242, __pyx_L1_error) }
    __pyx_t_5 = (__pyx_v_getter != Py_None);
    __pyx_t_6 = (__pyx_t_5 != 0);
    if (!__pyx_t_6) {
    } else {
      __pyx_t_1 = __pyx_t_6;
      goto __pyx_L28_bool_binop_done;
    }
    if (unlikely(!__pyx_v_setter)) { __Pyx_RaiseUnboundLocalError("setter"); __PYX_ERR(0, 242, __pyx_L1_error) }
    __pyx_t_6 = (__pyx_v_setter != Py_None);
    __pyx_t_5 = (__pyx_t_6 != 0);
    __pyx_t_1 = __pyx_t_5;
    __pyx_L28_bool_binop_done:;
    if (unlikely(__pyx_t_1)) {

      /* "lupa/_lupa.pyx":243
 *                 raise ValueError("attribute_handlers must be a sequence of two callables")
 *             if attribute_filter and (getter is not None or setter is not None):
 *                 raise ValueError("attribute_filter and attribute_handlers are mutually exclusive")             # <<<<<<<<<<<<<<
 *             self._attribute_getter, self._attribute_setter = getter, setter
 * 
 */
      __pyx_t_4 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__6, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 243, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_Raise(__pyx_t_4, 0, 0, 0);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __PYX_ERR(0, 243, __pyx_L1_error)

      /* "lupa/_lupa.pyx":242
 *             if raise_error:
 *                 raise ValueError("attribute_handlers must be a sequence of two callables")
 *             if attribute_filter and (getter is not None or setter is not None):             # <<<<<<<<<<<<<<
 *                 raise ValueError("attribute_filter and attribute_handlers are mutually exclusive")
 *             self._attribute_getter, self._attribute_setter = getter, setter
 */
    }

    /* "lupa/_lupa.pyx":244
 *             if attribute_filter and (getter is not None or setter is not None):
 *                 raise ValueError("attribute_filter and attribute_handlers are mutually exclusive")
 *             self._attribute_getter, self._attribute_setter = getter, setter             # <<<<<<<<<<<<<<
 * 
 *         lua.luaL_openlibs(L)
 */
    if (unlikely(!__pyx_v_getter)) { __Pyx_RaiseUnboundLocalError("getter"); __PYX_ERR(0, 244, __pyx_L1_error) }
    __pyx_t_4 = __pyx_v_getter;
    __Pyx_INCREF(__pyx_t_4);
    if (unlikely(!__pyx_v_setter)) { __Pyx_RaiseUnboundLocalError("setter"); __PYX_ERR(0, 244, __pyx_L1_error) }
    __pyx_t_2 = __pyx_v_setter;
    __Pyx_INCREF(__pyx_t_2);
    __Pyx_GIVEREF(__pyx_t_4);
    __Pyx_GOTREF(__pyx_v_self->_attribute_getter);
    __Pyx_DECREF(__pyx_v_self->_attribute_getter);
    __pyx_v_self->_attribute_getter = __pyx_t_4;
    __pyx_t_4 = 0;
    __Pyx_GIVEREF(__pyx_t_2);
    __Pyx_GOTREF(__pyx_v_self->_attribute_setter);
    __Pyx_DECREF(__pyx_v_self->_attribute_setter);
    __pyx_v_self->_attribute_setter = __pyx_t_2;
    __pyx_t_2 = 0;

    /* "lupa/_lupa.pyx":230
 *         self._unpack_returned_tuples = unpack_returned_tuples
 * 
 *         if attribute_handlers:             # <<<<<<<<<<<<<<
 *             raise_error = False
 *             try:
 */
  }

  /* "lupa/_lupa.pyx":246
 *             self._attribute_getter, self._attribute_setter = getter, setter
 * 
 *         lua.luaL_openlibs(L)             # <<<<<<<<<<<<<<
 *         self.init_python_lib(register_eval, register_builtins)
 *         lua.lua_settop(L, 0)
 */
  luaL_openlibs(__pyx_v_L);

  /* "lupa/_lupa.pyx":247
 * 
 *         lua.luaL_openlibs(L)
 *         self.init_python_lib(register_eval, register_builtins)             # <<<<<<<<<<<<<<
 *         lua.lua_settop(L, 0)
 *         lua.lua_atpanic(L, <lua.lua_CFunction>1)
 */
  __pyx_t_11 = __pyx_f_4lupa_5_lupa_10LuaRuntime_init_python_lib(__pyx_v_self, __pyx_v_register_eval, __pyx_v_register_builtins); if (unlikely(__pyx_t_11 == ((int)-1))) __PYX_ERR(0, 247, __pyx_L1_error)

  /* "lupa/_lupa.pyx":248
 *         lua.luaL_openlibs(L)
 *         self.init_python_lib(register_eval, register_builtins)
 *         lua.lua_settop(L, 0)             # <<<<<<<<<<<<<<
 *         lua.lua_atpanic(L, <lua.lua_CFunction>1)
 * 
 */
  lua_settop(__pyx_v_L, 0);

  /* "lupa/_lupa.pyx":249
 *         self.init_python_lib(register_eval, register_builtins)
 *         lua.lua_settop(L, 0)
 *         lua.lua_atpanic(L, <lua.lua_CFunction>1)             # <<<<<<<<<<<<<<
 * 
 *     def __dealloc__(self):
 */
  (void)(lua_atpanic(__pyx_v_L, ((lua_CFunction)1)));

  /* "lupa/_lupa.pyx":213
 *     cdef bint _unpack_returned_tuples
 * 
 *     def __cinit__(self, encoding='UTF-8', source_encoding=None,             # <<<<<<<<<<<<<<
 *                   attribute_filter=None, attribute_handlers=None,
 *                   bint register_eval=True, bint unpack_returned_tuples=False,
 */

  /* 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_AddTraceback("lupa._lupa.LuaRuntime.__cinit__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_getter);
  __Pyx_XDECREF(__pyx_v_setter);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lupa/_lupa.pyx":251
 *         lua.lua_atpanic(L, <lua.lua_CFunction>1)
 * 
 *     def __dealloc__(self):             # <<<<<<<<<<<<<<
 *         if self._state is not NULL:
 *             lua.lua_close(self._state)
 */

/* Python wrapper */
static void __pyx_pw_4lupa_5_lupa_10LuaRuntime_3__dealloc__(PyObject *__pyx_v_self); /*proto*/
static void __pyx_pw_4lupa_5_lupa_10LuaRuntime_3__dealloc__(PyObject *__pyx_v_self) {
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__dealloc__ (wrapper)", 0);
  __pyx_pf_4lupa_5_lupa_10LuaRuntime_2__dealloc__(((struct __pyx_obj_4lupa_5_lupa_LuaRuntime *)__pyx_v_self));

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

static void __pyx_pf_4lupa_5_lupa_10LuaRuntime_2__dealloc__(struct __pyx_obj_4lupa_5_lupa_LuaRuntime *__pyx_v_self) {
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  __Pyx_RefNannySetupContext("__dealloc__", 0);

  /* "lupa/_lupa.pyx":252
 * 
 *     def __dealloc__(self):
 *         if self._state is not NULL:             # <<<<<<<<<<<<<<
 *             lua.lua_close(self._state)
 *             self._state = NULL
 */
  __pyx_t_1 = ((__pyx_v_self->_state != NULL) != 0);
  if (__pyx_t_1) {

    /* "lupa/_lupa.pyx":253
 *     def __dealloc__(self):
 *         if self._state is not NULL:
 *             lua.lua_close(self._state)             # <<<<<<<<<<<<<<
 *             self._state = NULL
 * 
 */
    lua_close(__pyx_v_self->_state);

    /* "lupa/_lupa.pyx":254
 *         if self._state is not NULL:
 *             lua.lua_close(self._state)
 *             self._state = NULL             # <<<<<<<<<<<<<<
 * 
 *     @property
 */
    __pyx_v_self->_state = NULL;

    /* "lupa/_lupa.pyx":252
 * 
 *     def __dealloc__(self):
 *         if self._state is not NULL:             # <<<<<<<<<<<<<<
 *             lua.lua_close(self._state)
 *             self._state = NULL
 */
  }

  /* "lupa/_lupa.pyx":251
 *         lua.lua_atpanic(L, <lua.lua_CFunction>1)
 * 
 *     def __dealloc__(self):             # <<<<<<<<<<<<<<
 *         if self._state is not NULL:
 *             lua.lua_close(self._state)
 */

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

/* "lupa/_lupa.pyx":257
 * 
 *     @property
 *     def lua_version(self):             # <<<<<<<<<<<<<<
 *         """
 *         The Lua runtime/language version as tuple, e.g. (5, 3) for Lua 5.3.
 */

/* Python wrapper */
static PyObject *__pyx_pw_4lupa_5_lupa_10LuaRuntime_11lua_version_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_4lupa_5_lupa_10LuaRuntime_11lua_version_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_4lupa_5_lupa_10LuaRuntime_11lua_version___get__(((struct __pyx_obj_4lupa_5_lupa_LuaRuntime *)__pyx_v_self));

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

static PyObject *__pyx_pf_4lupa_5_lupa_10LuaRuntime_11lua_version___get__(struct __pyx_obj_4lupa_5_lupa_LuaRuntime *__pyx_v_self) {
  int __pyx_v_version;
  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("__get__", 0);

  /* "lupa/_lupa.pyx":261
 *         The Lua runtime/language version as tuple, e.g. (5, 3) for Lua 5.3.
 *         """
 *         cdef int version = lua.read_lua_version(self._state)             # <<<<<<<<<<<<<<
 *         return (version // 100, version % 100)
 * 
 */
  __pyx_v_version = read_lua_version(__pyx_v_self->_state);

  /* "lupa/_lupa.pyx":262
 *         """
 *         cdef int version = lua.read_lua_version(self._state)
 *         return (version // 100, version % 100)             # <<<<<<<<<<<<<<
 * 
 *     @property
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __Pyx_PyInt_From_long(__Pyx_div_long(__pyx_v_version, 0x64)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 262, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyInt_From_long(__Pyx_mod_long(__pyx_v_version, 0x64)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 262, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 262, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_GIVEREF(__pyx_t_1);
  PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_2);
  PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_t_2);
  __pyx_t_1 = 0;
  __pyx_t_2 = 0;
  __pyx_r = __pyx_t_3;
  __pyx_t_3 = 0;
  goto __pyx_L0;

  /* "lupa/_lupa.pyx":257
 * 
 *     @property
 *     def lua_version(self):             # <<<<<<<<<<<<<<
 *         """
 *         The Lua runtime/language version as tuple, e.g. (5, 3) for Lua 5.3.
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("lupa._lupa.LuaRuntime.lua_version.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lupa/_lupa.pyx":265
 * 
 *     @property
 *     def lua_implementation(self):             # <<<<<<<<<<<<<<
 *         """
 *         The Lua implementation version string, e.g. "Lua 5.3" or "LuaJIT 2.0.1".
 */

/* Python wrapper */
static PyObject *__pyx_pw_4lupa_5_lupa_10LuaRuntime_18lua_implementation_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_4lupa_5_lupa_10LuaRuntime_18lua_implementation_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_4lupa_5_lupa_10LuaRuntime_18lua_implementation___get__(((struct __pyx_obj_4lupa_5_lupa_LuaRuntime *)__pyx_v_self));

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

static PyObject *__pyx_pf_4lupa_5_lupa_10LuaRuntime_18lua_implementation___get__(struct __pyx_obj_4lupa_5_lupa_LuaRuntime *__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("__get__", 0);

  /* "lupa/_lupa.pyx":270
 *         May execute Lua code.
 *         """
 *         return self.eval(             # <<<<<<<<<<<<<<
 *             "(function () "
 *             "    if type(jit) == 'table' then return jit.version else return _VERSION end "
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_eval); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 270, __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_Call2Args(__pyx_t_2, __pyx_t_3, __pyx_kp_s_function_if_type_jit_table_then) : __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_kp_s_function_if_type_jit_table_then);
  __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 270, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "lupa/_lupa.pyx":265
 * 
 *     @property
 *     def lua_implementation(self):             # <<<<<<<<<<<<<<
 *         """
 *         The Lua implementation version string, e.g. "Lua 5.3" or "LuaJIT 2.0.1".
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("lupa._lupa.LuaRuntime.lua_implementation.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lupa/_lupa.pyx":277
 * 
 *     @cython.final
 *     cdef int reraise_on_exception(self) except -1:             # <<<<<<<<<<<<<<
 *         if self._raised_exception is not None:
 *             exception = self._raised_exception
 */

static int __pyx_f_4lupa_5_lupa_10LuaRuntime_reraise_on_exception(struct __pyx_obj_4lupa_5_lupa_LuaRuntime *__pyx_v_self) {
  PyObject *__pyx_v_exception = NULL;
  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;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("reraise_on_exception", 0);

  /* "lupa/_lupa.pyx":278
 *     @cython.final
 *     cdef int reraise_on_exception(self) except -1:
 *         if self._raised_exception is not None:             # <<<<<<<<<<<<<<
 *             exception = self._raised_exception
 *             self._raised_exception = None
 */
  __pyx_t_1 = (__pyx_v_self->_raised_exception != ((PyObject*)Py_None));
  __pyx_t_2 = (__pyx_t_1 != 0);
  if (unlikely(__pyx_t_2)) {

    /* "lupa/_lupa.pyx":279
 *     cdef int reraise_on_exception(self) except -1:
 *         if self._raised_exception is not None:
 *             exception = self._raised_exception             # <<<<<<<<<<<<<<
 *             self._raised_exception = None
 *             raise exception[0], exception[1], exception[2]
 */
    __pyx_t_3 = __pyx_v_self->_raised_exception;
    __Pyx_INCREF(__pyx_t_3);
    __pyx_v_exception = ((PyObject*)__pyx_t_3);
    __pyx_t_3 = 0;

    /* "lupa/_lupa.pyx":280
 *         if self._raised_exception is not None:
 *             exception = self._raised_exception
 *             self._raised_exception = None             # <<<<<<<<<<<<<<
 *             raise exception[0], exception[1], exception[2]
 *         return 0
 */
    __Pyx_INCREF(Py_None);
    __Pyx_GIVEREF(Py_None);
    __Pyx_GOTREF(__pyx_v_self->_raised_exception);
    __Pyx_DECREF(__pyx_v_self->_raised_exception);
    __pyx_v_self->_raised_exception = ((PyObject*)Py_None);

    /* "lupa/_lupa.pyx":281
 *             exception = self._raised_exception
 *             self._raised_exception = None
 *             raise exception[0], exception[1], exception[2]             # <<<<<<<<<<<<<<
 *         return 0
 * 
 */
    if (unlikely(__pyx_v_exception == Py_None)) {
      PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
      __PYX_ERR(0, 281, __pyx_L1_error)
    }
    __pyx_t_3 = __Pyx_GetItemInt_Tuple(__pyx_v_exception, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 281, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    if (unlikely(__pyx_v_exception == Py_None)) {
      PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
      __PYX_ERR(0, 281, __pyx_L1_error)
    }
    __pyx_t_4 = __Pyx_GetItemInt_Tuple(__pyx_v_exception, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 281, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    if (unlikely(__pyx_v_exception == Py_None)) {
      PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
      __PYX_ERR(0, 281, __pyx_L1_error)
    }
    __pyx_t_5 = __Pyx_GetItemInt_Tuple(__pyx_v_exception, 2, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 281, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_Raise(__pyx_t_3, __pyx_t_4, __pyx_t_5, 0);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __PYX_ERR(0, 281, __pyx_L1_error)

    /* "lupa/_lupa.pyx":278
 *     @cython.final
 *     cdef int reraise_on_exception(self) except -1:
 *         if self._raised_exception is not None:             # <<<<<<<<<<<<<<
 *             exception = self._raised_exception
 *             self._raised_exception = None
 */
  }

  /* "lupa/_lupa.pyx":282
 *             self._raised_exception = None
 *             raise exception[0], exception[1], exception[2]
 *         return 0             # <<<<<<<<<<<<<<
 * 
 *     @cython.final
 */
  __pyx_r = 0;
  goto __pyx_L0;

  /* "lupa/_lupa.pyx":277
 * 
 *     @cython.final
 *     cdef int reraise_on_exception(self) except -1:             # <<<<<<<<<<<<<<
 *         if self._raised_exception is not None:
 *             exception = self._raised_exception
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_AddTraceback("lupa._lupa.LuaRuntime.reraise_on_exception", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_exception);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lupa/_lupa.pyx":285
 * 
 *     @cython.final
 *     cdef int store_raised_exception(self, lua_State* L, bytes lua_error_msg) except -1:             # <<<<<<<<<<<<<<
 *         try:
 *             self._raised_exception = tuple(exc_info())
 */

static int __pyx_f_4lupa_5_lupa_10LuaRuntime_store_raised_exception(struct __pyx_obj_4lupa_5_lupa_LuaRuntime *__pyx_v_self, lua_State *__pyx_v_L, PyObject *__pyx_v_lua_error_msg) {
  int __pyx_r;
  __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;
  PyObject *__pyx_t_6 = NULL;
  int __pyx_t_7;
  char *__pyx_t_8;
  Py_ssize_t __pyx_t_9;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("store_raised_exception", 0);

  /* "lupa/_lupa.pyx":286
 *     @cython.final
 *     cdef int store_raised_exception(self, lua_State* L, bytes lua_error_msg) except -1:
 *         try:             # <<<<<<<<<<<<<<
 *             self._raised_exception = tuple(exc_info())
 *             py_to_lua(self, L, self._raised_exception[1])
 */
  {
    __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:*/ {

      /* "lupa/_lupa.pyx":287
 *     cdef int store_raised_exception(self, lua_State* L, bytes lua_error_msg) except -1:
 *         try:
 *             self._raised_exception = tuple(exc_info())             # <<<<<<<<<<<<<<
 *             py_to_lua(self, L, self._raised_exception[1])
 *         except:
 */
      __Pyx_INCREF(__pyx_v_4lupa_5_lupa_exc_info);
      __pyx_t_5 = __pyx_v_4lupa_5_lupa_exc_info; __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_CallOneArg(__pyx_t_5, __pyx_t_6) : __Pyx_PyObject_CallNoArg(__pyx_t_5);
      __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
      if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 287, __pyx_L3_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __pyx_t_5 = __Pyx_PySequence_Tuple(__pyx_t_4); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 287, __pyx_L3_error)
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __Pyx_GIVEREF(__pyx_t_5);
      __Pyx_GOTREF(__pyx_v_self->_raised_exception);
      __Pyx_DECREF(__pyx_v_self->_raised_exception);
      __pyx_v_self->_raised_exception = ((PyObject*)__pyx_t_5);
      __pyx_t_5 = 0;

      /* "lupa/_lupa.pyx":288
 *         try:
 *             self._raised_exception = tuple(exc_info())
 *             py_to_lua(self, L, self._raised_exception[1])             # <<<<<<<<<<<<<<
 *         except:
 *             lua.lua_pushlstring(L, lua_error_msg, len(lua_error_msg))
 */
      if (unlikely(__pyx_v_self->_raised_exception == Py_None)) {
        PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
        __PYX_ERR(0, 288, __pyx_L3_error)
      }
      __pyx_t_5 = __Pyx_GetItemInt_Tuple(__pyx_v_self->_raised_exception, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 288, __pyx_L3_error)
      __Pyx_GOTREF(__pyx_t_5);
      __pyx_t_7 = __pyx_f_4lupa_5_lupa_py_to_lua(__pyx_v_self, __pyx_v_L, __pyx_t_5, NULL); if (unlikely(__pyx_t_7 == ((int)-1))) __PYX_ERR(0, 288, __pyx_L3_error)
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

      /* "lupa/_lupa.pyx":286
 *     @cython.final
 *     cdef int store_raised_exception(self, lua_State* L, bytes lua_error_msg) except -1:
 *         try:             # <<<<<<<<<<<<<<
 *             self._raised_exception = tuple(exc_info())
 *             py_to_lua(self, L, self._raised_exception[1])
 */
    }
    __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
    goto __pyx_L8_try_end;
    __pyx_L3_error:;
    __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;

    /* "lupa/_lupa.pyx":289
 *             self._raised_exception = tuple(exc_info())
 *             py_to_lua(self, L, self._raised_exception[1])
 *         except:             # <<<<<<<<<<<<<<
 *             lua.lua_pushlstring(L, lua_error_msg, len(lua_error_msg))
 *             raise
 */
    /*except:*/ {
      __Pyx_AddTraceback("lupa._lupa.LuaRuntime.store_raised_exception", __pyx_clineno, __pyx_lineno, __pyx_filename);
      if (__Pyx_GetException(&__pyx_t_5, &__pyx_t_4, &__pyx_t_6) < 0) __PYX_ERR(0, 289, __pyx_L5_except_error)
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_GOTREF(__pyx_t_6);

      /* "lupa/_lupa.pyx":290
 *             py_to_lua(self, L, self._raised_exception[1])
 *         except:
 *             lua.lua_pushlstring(L, lua_error_msg, len(lua_error_msg))             # <<<<<<<<<<<<<<
 *             raise
 *         return 0
 */
      if (unlikely(__pyx_v_lua_error_msg == Py_None)) {
        PyErr_SetString(PyExc_TypeError, "expected bytes, NoneType found");
        __PYX_ERR(0, 290, __pyx_L5_except_error)
      }
      __pyx_t_8 = __Pyx_PyBytes_AsWritableString(__pyx_v_lua_error_msg); if (unlikely((!__pyx_t_8) && PyErr_Occurred())) __PYX_ERR(0, 290, __pyx_L5_except_error)
      if (unlikely(__pyx_v_lua_error_msg == Py_None)) {
        PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()");
        __PYX_ERR(0, 290, __pyx_L5_except_error)
      }
      __pyx_t_9 = PyBytes_GET_SIZE(__pyx_v_lua_error_msg); if (unlikely(__pyx_t_9 == ((Py_ssize_t)-1))) __PYX_ERR(0, 290, __pyx_L5_except_error)
      lua_pushlstring(__pyx_v_L, __pyx_t_8, __pyx_t_9);

      /* "lupa/_lupa.pyx":291
 *         except:
 *             lua.lua_pushlstring(L, lua_error_msg, len(lua_error_msg))
 *             raise             # <<<<<<<<<<<<<<
 *         return 0
 * 
 */
      __Pyx_GIVEREF(__pyx_t_5);
      __Pyx_GIVEREF(__pyx_t_4);
      __Pyx_XGIVEREF(__pyx_t_6);
      __Pyx_ErrRestoreWithState(__pyx_t_5, __pyx_t_4, __pyx_t_6);
      __pyx_t_5 = 0; __pyx_t_4 = 0; __pyx_t_6 = 0; 
      __PYX_ERR(0, 291, __pyx_L5_except_error)
    }
    __pyx_L5_except_error:;

    /* "lupa/_lupa.pyx":286
 *     @cython.final
 *     cdef int store_raised_exception(self, lua_State* L, bytes lua_error_msg) except -1:
 *         try:             # <<<<<<<<<<<<<<
 *             self._raised_exception = tuple(exc_info())
 *             py_to_lua(self, L, self._raised_exception[1])
 */
    __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_L8_try_end:;
  }

  /* "lupa/_lupa.pyx":292
 *             lua.lua_pushlstring(L, lua_error_msg, len(lua_error_msg))
 *             raise
 *         return 0             # <<<<<<<<<<<<<<
 * 
 *     def eval(self, lua_code, *args):
 */
  __pyx_r = 0;
  goto __pyx_L0;

  /* "lupa/_lupa.pyx":285
 * 
 *     @cython.final
 *     cdef int store_raised_exception(self, lua_State* L, bytes lua_error_msg) except -1:             # <<<<<<<<<<<<<<
 *         try:
 *             self._raised_exception = tuple(exc_info())
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_AddTraceback("lupa._lupa.LuaRuntime.store_raised_exception", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lupa/_lupa.pyx":294
 *         return 0
 * 
 *     def eval(self, lua_code, *args):             # <<<<<<<<<<<<<<
 *         """Evaluate a Lua expression passed in a string.
 *         """
 */

/* Python wrapper */
static PyObject *__pyx_pw_4lupa_5_lupa_10LuaRuntime_5eval(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4lupa_5_lupa_10LuaRuntime_4eval[] = "LuaRuntime.eval(self, lua_code, *args)\nEvaluate a Lua expression passed in a string.\n        ";
static PyMethodDef __pyx_mdef_4lupa_5_lupa_10LuaRuntime_5eval = {"eval", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_4lupa_5_lupa_10LuaRuntime_5eval, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4lupa_5_lupa_10LuaRuntime_4eval};
static PyObject *__pyx_pw_4lupa_5_lupa_10LuaRuntime_5eval(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_lua_code = 0;
  PyObject *__pyx_v_args = 0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("eval (wrapper)", 0);
  if (PyTuple_GET_SIZE(__pyx_args) > 1) {
    __pyx_v_args = PyTuple_GetSlice(__pyx_args, 1, PyTuple_GET_SIZE(__pyx_args));
    if (unlikely(!__pyx_v_args)) {
      __Pyx_RefNannyFinishContext();
      return NULL;
    }
    __Pyx_GOTREF(__pyx_v_args);
  } else {
    __pyx_v_args = __pyx_empty_tuple; __Pyx_INCREF(__pyx_empty_tuple);
  }
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_lua_code,0};
    PyObject* values[1] = {0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        default:
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_lua_code)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
      }
      if (unlikely(kw_args > 0)) {
        const Py_ssize_t used_pos_args = (pos_args < 1) ? pos_args : 1;
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, used_pos_args, "eval") < 0)) __PYX_ERR(0, 294, __pyx_L3_error)
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) < 1) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
    }
    __pyx_v_lua_code = values[0];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("eval", 0, 1, 1, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 294, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_DECREF(__pyx_v_args); __pyx_v_args = 0;
  __Pyx_AddTraceback("lupa._lupa.LuaRuntime.eval", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_4lupa_5_lupa_10LuaRuntime_4eval(((struct __pyx_obj_4lupa_5_lupa_LuaRuntime *)__pyx_v_self), __pyx_v_lua_code, __pyx_v_args);

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

static PyObject *__pyx_pf_4lupa_5_lupa_10LuaRuntime_4eval(struct __pyx_obj_4lupa_5_lupa_LuaRuntime *__pyx_v_self, PyObject *__pyx_v_lua_code, PyObject *__pyx_v_args) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  int __pyx_t_2;
  char const *__pyx_t_3;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("eval", 0);
  __Pyx_INCREF(__pyx_v_lua_code);

  /* "lupa/_lupa.pyx":297
 *         """Evaluate a Lua expression passed in a string.
 *         """
 *         assert self._state is not NULL             # <<<<<<<<<<<<<<
 *         if isinstance(lua_code, unicode):
 *             lua_code = (<unicode>lua_code).encode(self._source_encoding)
 */
  #ifndef CYTHON_WITHOUT_ASSERTIONS
  if (unlikely(!Py_OptimizeFlag)) {
    if (unlikely(!((__pyx_v_self->_state != NULL) != 0))) {
      PyErr_SetNone(PyExc_AssertionError);
      __PYX_ERR(0, 297, __pyx_L1_error)
    }
  }
  #endif

  /* "lupa/_lupa.pyx":298
 *         """
 *         assert self._state is not NULL
 *         if isinstance(lua_code, unicode):             # <<<<<<<<<<<<<<
 *             lua_code = (<unicode>lua_code).encode(self._source_encoding)
 *         return run_lua(self, b'return ' + lua_code, args)
 */
  __pyx_t_1 = PyUnicode_Check(__pyx_v_lua_code); 
  __pyx_t_2 = (__pyx_t_1 != 0);
  if (__pyx_t_2) {

    /* "lupa/_lupa.pyx":299
 *         assert self._state is not NULL
 *         if isinstance(lua_code, unicode):
 *             lua_code = (<unicode>lua_code).encode(self._source_encoding)             # <<<<<<<<<<<<<<
 *         return run_lua(self, b'return ' + lua_code, args)
 * 
 */
    if (unlikely(__pyx_v_lua_code == Py_None)) {
      PyErr_Format(PyExc_AttributeError, "'NoneType' object has no attribute '%.30s'", "encode");
      __PYX_ERR(0, 299, __pyx_L1_error)
    }
    if (unlikely(__pyx_v_self->_source_encoding == Py_None)) {
      PyErr_SetString(PyExc_TypeError, "expected bytes, NoneType found");
      __PYX_ERR(0, 299, __pyx_L1_error)
    }
    __pyx_t_3 = __Pyx_PyBytes_AsString(__pyx_v_self->_source_encoding); if (unlikely((!__pyx_t_3) && PyErr_Occurred())) __PYX_ERR(0, 299, __pyx_L1_error)
    __pyx_t_4 = PyUnicode_AsEncodedString(((PyObject*)__pyx_v_lua_code), __pyx_t_3, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 299, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF_SET(__pyx_v_lua_code, __pyx_t_4);
    __pyx_t_4 = 0;

    /* "lupa/_lupa.pyx":298
 *         """
 *         assert self._state is not NULL
 *         if isinstance(lua_code, unicode):             # <<<<<<<<<<<<<<
 *             lua_code = (<unicode>lua_code).encode(self._source_encoding)
 *         return run_lua(self, b'return ' + lua_code, args)
 */
  }

  /* "lupa/_lupa.pyx":300
 *         if isinstance(lua_code, unicode):
 *             lua_code = (<unicode>lua_code).encode(self._source_encoding)
 *         return run_lua(self, b'return ' + lua_code, args)             # <<<<<<<<<<<<<<
 * 
 *     def execute(self, lua_code, *args):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_4 = PyNumber_Add(__pyx_kp_b_return, __pyx_v_lua_code); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 300, __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, 300, __pyx_L1_error)
  __pyx_t_5 = __pyx_f_4lupa_5_lupa_run_lua(__pyx_v_self, ((PyObject*)__pyx_t_4), __pyx_v_args); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 300, __pyx_L1_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_L0;

  /* "lupa/_lupa.pyx":294
 *         return 0
 * 
 *     def eval(self, lua_code, *args):             # <<<<<<<<<<<<<<
 *         """Evaluate a Lua expression passed in a string.
 *         """
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_AddTraceback("lupa._lupa.LuaRuntime.eval", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_lua_code);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lupa/_lupa.pyx":302
 *         return run_lua(self, b'return ' + lua_code, args)
 * 
 *     def execute(self, lua_code, *args):             # <<<<<<<<<<<<<<
 *         """Execute a Lua program passed in a string.
 *         """
 */

/* Python wrapper */
static PyObject *__pyx_pw_4lupa_5_lupa_10LuaRuntime_7execute(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4lupa_5_lupa_10LuaRuntime_6execute[] = "LuaRuntime.execute(self, lua_code, *args)\nExecute a Lua program passed in a string.\n        ";
static PyMethodDef __pyx_mdef_4lupa_5_lupa_10LuaRuntime_7execute = {"execute", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_4lupa_5_lupa_10LuaRuntime_7execute, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4lupa_5_lupa_10LuaRuntime_6execute};
static PyObject *__pyx_pw_4lupa_5_lupa_10LuaRuntime_7execute(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_lua_code = 0;
  PyObject *__pyx_v_args = 0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("execute (wrapper)", 0);
  if (PyTuple_GET_SIZE(__pyx_args) > 1) {
    __pyx_v_args = PyTuple_GetSlice(__pyx_args, 1, PyTuple_GET_SIZE(__pyx_args));
    if (unlikely(!__pyx_v_args)) {
      __Pyx_RefNannyFinishContext();
      return NULL;
    }
    __Pyx_GOTREF(__pyx_v_args);
  } else {
    __pyx_v_args = __pyx_empty_tuple; __Pyx_INCREF(__pyx_empty_tuple);
  }
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_lua_code,0};
    PyObject* values[1] = {0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        default:
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_lua_code)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
      }
      if (unlikely(kw_args > 0)) {
        const Py_ssize_t used_pos_args = (pos_args < 1) ? pos_args : 1;
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, used_pos_args, "execute") < 0)) __PYX_ERR(0, 302, __pyx_L3_error)
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) < 1) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
    }
    __pyx_v_lua_code = values[0];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("execute", 0, 1, 1, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 302, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_DECREF(__pyx_v_args); __pyx_v_args = 0;
  __Pyx_AddTraceback("lupa._lupa.LuaRuntime.execute", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_4lupa_5_lupa_10LuaRuntime_6execute(((struct __pyx_obj_4lupa_5_lupa_LuaRuntime *)__pyx_v_self), __pyx_v_lua_code, __pyx_v_args);

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

static PyObject *__pyx_pf_4lupa_5_lupa_10LuaRuntime_6execute(struct __pyx_obj_4lupa_5_lupa_LuaRuntime *__pyx_v_self, PyObject *__pyx_v_lua_code, PyObject *__pyx_v_args) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  int __pyx_t_2;
  char const *__pyx_t_3;
  PyObject *__pyx_t_4 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("execute", 0);
  __Pyx_INCREF(__pyx_v_lua_code);

  /* "lupa/_lupa.pyx":305
 *         """Execute a Lua program passed in a string.
 *         """
 *         assert self._state is not NULL             # <<<<<<<<<<<<<<
 *         if isinstance(lua_code, unicode):
 *             lua_code = (<unicode>lua_code).encode(self._source_encoding)
 */
  #ifndef CYTHON_WITHOUT_ASSERTIONS
  if (unlikely(!Py_OptimizeFlag)) {
    if (unlikely(!((__pyx_v_self->_state != NULL) != 0))) {
      PyErr_SetNone(PyExc_AssertionError);
      __PYX_ERR(0, 305, __pyx_L1_error)
    }
  }
  #endif

  /* "lupa/_lupa.pyx":306
 *         """
 *         assert self._state is not NULL
 *         if isinstance(lua_code, unicode):             # <<<<<<<<<<<<<<
 *             lua_code = (<unicode>lua_code).encode(self._source_encoding)
 *         return run_lua(self, lua_code, args)
 */
  __pyx_t_1 = PyUnicode_Check(__pyx_v_lua_code); 
  __pyx_t_2 = (__pyx_t_1 != 0);
  if (__pyx_t_2) {

    /* "lupa/_lupa.pyx":307
 *         assert self._state is not NULL
 *         if isinstance(lua_code, unicode):
 *             lua_code = (<unicode>lua_code).encode(self._source_encoding)             # <<<<<<<<<<<<<<
 *         return run_lua(self, lua_code, args)
 * 
 */
    if (unlikely(__pyx_v_lua_code == Py_None)) {
      PyErr_Format(PyExc_AttributeError, "'NoneType' object has no attribute '%.30s'", "encode");
      __PYX_ERR(0, 307, __pyx_L1_error)
    }
    if (unlikely(__pyx_v_self->_source_encoding == Py_None)) {
      PyErr_SetString(PyExc_TypeError, "expected bytes, NoneType found");
      __PYX_ERR(0, 307, __pyx_L1_error)
    }
    __pyx_t_3 = __Pyx_PyBytes_AsString(__pyx_v_self->_source_encoding); if (unlikely((!__pyx_t_3) && PyErr_Occurred())) __PYX_ERR(0, 307, __pyx_L1_error)
    __pyx_t_4 = PyUnicode_AsEncodedString(((PyObject*)__pyx_v_lua_code), __pyx_t_3, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 307, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF_SET(__pyx_v_lua_code, __pyx_t_4);
    __pyx_t_4 = 0;

    /* "lupa/_lupa.pyx":306
 *         """
 *         assert self._state is not NULL
 *         if isinstance(lua_code, unicode):             # <<<<<<<<<<<<<<
 *             lua_code = (<unicode>lua_code).encode(self._source_encoding)
 *         return run_lua(self, lua_code, args)
 */
  }

  /* "lupa/_lupa.pyx":308
 *         if isinstance(lua_code, unicode):
 *             lua_code = (<unicode>lua_code).encode(self._source_encoding)
 *         return run_lua(self, lua_code, args)             # <<<<<<<<<<<<<<
 * 
 *     def compile(self, lua_code):
 */
  __Pyx_XDECREF(__pyx_r);
  if (!(likely(PyBytes_CheckExact(__pyx_v_lua_code))||((__pyx_v_lua_code) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "bytes", Py_TYPE(__pyx_v_lua_code)->tp_name), 0))) __PYX_ERR(0, 308, __pyx_L1_error)
  __pyx_t_4 = __pyx_f_4lupa_5_lupa_run_lua(__pyx_v_self, ((PyObject*)__pyx_v_lua_code), __pyx_v_args); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 308, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_r = __pyx_t_4;
  __pyx_t_4 = 0;
  goto __pyx_L0;

  /* "lupa/_lupa.pyx":302
 *         return run_lua(self, b'return ' + lua_code, args)
 * 
 *     def execute(self, lua_code, *args):             # <<<<<<<<<<<<<<
 *         """Execute a Lua program passed in a string.
 *         """
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_AddTraceback("lupa._lupa.LuaRuntime.execute", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_lua_code);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lupa/_lupa.pyx":310
 *         return run_lua(self, lua_code, args)
 * 
 *     def compile(self, lua_code):             # <<<<<<<<<<<<<<
 *         """Compile a Lua program into a callable Lua function.
 *         """
 */

/* Python wrapper */
static PyObject *__pyx_pw_4lupa_5_lupa_10LuaRuntime_9compile(PyObject *__pyx_v_self, PyObject *__pyx_v_lua_code); /*proto*/
static char __pyx_doc_4lupa_5_lupa_10LuaRuntime_8compile[] = "LuaRuntime.compile(self, lua_code)\nCompile a Lua program into a callable Lua function.\n        ";
static PyMethodDef __pyx_mdef_4lupa_5_lupa_10LuaRuntime_9compile = {"compile", (PyCFunction)__pyx_pw_4lupa_5_lupa_10LuaRuntime_9compile, METH_O, __pyx_doc_4lupa_5_lupa_10LuaRuntime_8compile};
static PyObject *__pyx_pw_4lupa_5_lupa_10LuaRuntime_9compile(PyObject *__pyx_v_self, PyObject *__pyx_v_lua_code) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("compile (wrapper)", 0);
  __pyx_r = __pyx_pf_4lupa_5_lupa_10LuaRuntime_8compile(((struct __pyx_obj_4lupa_5_lupa_LuaRuntime *)__pyx_v_self), ((PyObject *)__pyx_v_lua_code));

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

static PyObject *__pyx_pf_4lupa_5_lupa_10LuaRuntime_8compile(struct __pyx_obj_4lupa_5_lupa_LuaRuntime *__pyx_v_self, PyObject *__pyx_v_lua_code) {
  char const *__pyx_v_err;
  lua_State *__pyx_v_L;
  int __pyx_v_oldtop;
  size_t __pyx_v_size;
  int __pyx_v_status;
  PyObject *__pyx_v_error = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  int __pyx_t_2;
  char const *__pyx_t_3;
  PyObject *__pyx_t_4 = NULL;
  lua_State *__pyx_t_5;
  int __pyx_t_6;
  char *__pyx_t_7;
  Py_ssize_t __pyx_t_8;
  PyObject *__pyx_t_9 = NULL;
  PyObject *__pyx_t_10 = NULL;
  int __pyx_t_11;
  char const *__pyx_t_12;
  PyObject *__pyx_t_13 = NULL;
  PyObject *__pyx_t_14 = NULL;
  PyObject *__pyx_t_15 = NULL;
  PyObject *__pyx_t_16 = NULL;
  PyObject *__pyx_t_17 = NULL;
  PyObject *__pyx_t_18 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("compile", 0);
  __Pyx_INCREF(__pyx_v_lua_code);

  /* "lupa/_lupa.pyx":314
 *         """
 *         cdef const char *err
 *         if isinstance(lua_code, unicode):             # <<<<<<<<<<<<<<
 *             lua_code = (<unicode>lua_code).encode(self._source_encoding)
 *         L = self._state
 */
  __pyx_t_1 = PyUnicode_Check(__pyx_v_lua_code); 
  __pyx_t_2 = (__pyx_t_1 != 0);
  if (__pyx_t_2) {

    /* "lupa/_lupa.pyx":315
 *         cdef const char *err
 *         if isinstance(lua_code, unicode):
 *             lua_code = (<unicode>lua_code).encode(self._source_encoding)             # <<<<<<<<<<<<<<
 *         L = self._state
 *         lock_runtime(self)
 */
    if (unlikely(__pyx_v_lua_code == Py_None)) {
      PyErr_Format(PyExc_AttributeError, "'NoneType' object has no attribute '%.30s'", "encode");
      __PYX_ERR(0, 315, __pyx_L1_error)
    }
    if (unlikely(__pyx_v_self->_source_encoding == Py_None)) {
      PyErr_SetString(PyExc_TypeError, "expected bytes, NoneType found");
      __PYX_ERR(0, 315, __pyx_L1_error)
    }
    __pyx_t_3 = __Pyx_PyBytes_AsString(__pyx_v_self->_source_encoding); if (unlikely((!__pyx_t_3) && PyErr_Occurred())) __PYX_ERR(0, 315, __pyx_L1_error)
    __pyx_t_4 = PyUnicode_AsEncodedString(((PyObject*)__pyx_v_lua_code), __pyx_t_3, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 315, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF_SET(__pyx_v_lua_code, __pyx_t_4);
    __pyx_t_4 = 0;

    /* "lupa/_lupa.pyx":314
 *         """
 *         cdef const char *err
 *         if isinstance(lua_code, unicode):             # <<<<<<<<<<<<<<
 *             lua_code = (<unicode>lua_code).encode(self._source_encoding)
 *         L = self._state
 */
  }

  /* "lupa/_lupa.pyx":316
 *         if isinstance(lua_code, unicode):
 *             lua_code = (<unicode>lua_code).encode(self._source_encoding)
 *         L = self._state             # <<<<<<<<<<<<<<
 *         lock_runtime(self)
 *         oldtop = lua.lua_gettop(L)
 */
  __pyx_t_5 = __pyx_v_self->_state;
  __pyx_v_L = __pyx_t_5;

  /* "lupa/_lupa.pyx":317
 *             lua_code = (<unicode>lua_code).encode(self._source_encoding)
 *         L = self._state
 *         lock_runtime(self)             # <<<<<<<<<<<<<<
 *         oldtop = lua.lua_gettop(L)
 *         cdef size_t size
 */
  __pyx_t_6 = __pyx_f_4lupa_5_lupa_lock_runtime(__pyx_v_self); if (unlikely(__pyx_t_6 == ((int)-1))) __PYX_ERR(0, 317, __pyx_L1_error)

  /* "lupa/_lupa.pyx":318
 *         L = self._state
 *         lock_runtime(self)
 *         oldtop = lua.lua_gettop(L)             # <<<<<<<<<<<<<<
 *         cdef size_t size
 *         try:
 */
  __pyx_v_oldtop = lua_gettop(__pyx_v_L);

  /* "lupa/_lupa.pyx":320
 *         oldtop = lua.lua_gettop(L)
 *         cdef size_t size
 *         try:             # <<<<<<<<<<<<<<
 *             status = lua.luaL_loadbuffer(L, lua_code, len(lua_code), b'<python>')
 *             if status == 0:
 */
  /*try:*/ {

    /* "lupa/_lupa.pyx":321
 *         cdef size_t size
 *         try:
 *             status = lua.luaL_loadbuffer(L, lua_code, len(lua_code), b'<python>')             # <<<<<<<<<<<<<<
 *             if status == 0:
 *                 return py_from_lua(self, L, -1)
 */
    __pyx_t_7 = __Pyx_PyObject_AsWritableString(__pyx_v_lua_code); if (unlikely((!__pyx_t_7) && PyErr_Occurred())) __PYX_ERR(0, 321, __pyx_L5_error)
    __pyx_t_8 = PyObject_Length(__pyx_v_lua_code); if (unlikely(__pyx_t_8 == ((Py_ssize_t)-1))) __PYX_ERR(0, 321, __pyx_L5_error)
    __pyx_v_status = luaL_loadbuffer(__pyx_v_L, __pyx_t_7, __pyx_t_8, ((char *)"<python>"));

    /* "lupa/_lupa.pyx":322
 *         try:
 *             status = lua.luaL_loadbuffer(L, lua_code, len(lua_code), b'<python>')
 *             if status == 0:             # <<<<<<<<<<<<<<
 *                 return py_from_lua(self, L, -1)
 *             else:
 */
    __pyx_t_2 = ((__pyx_v_status == 0) != 0);
    if (likely(__pyx_t_2)) {

      /* "lupa/_lupa.pyx":323
 *             status = lua.luaL_loadbuffer(L, lua_code, len(lua_code), b'<python>')
 *             if status == 0:
 *                 return py_from_lua(self, L, -1)             # <<<<<<<<<<<<<<
 *             else:
 *                 err = lua.lua_tolstring(L, -1, &size)
 */
      __Pyx_XDECREF(__pyx_r);
      __pyx_t_4 = __pyx_f_4lupa_5_lupa_py_from_lua(__pyx_v_self, __pyx_v_L, -1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 323, __pyx_L5_error)
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_r = __pyx_t_4;
      __pyx_t_4 = 0;
      goto __pyx_L4_return;

      /* "lupa/_lupa.pyx":322
 *         try:
 *             status = lua.luaL_loadbuffer(L, lua_code, len(lua_code), b'<python>')
 *             if status == 0:             # <<<<<<<<<<<<<<
 *                 return py_from_lua(self, L, -1)
 *             else:
 */
    }

    /* "lupa/_lupa.pyx":325
 *                 return py_from_lua(self, L, -1)
 *             else:
 *                 err = lua.lua_tolstring(L, -1, &size)             # <<<<<<<<<<<<<<
 *                 error = err[:size] if self._encoding is None else err[:size].decode(self._encoding)
 *                 raise LuaSyntaxError(error)
 */
    /*else*/ {
      __pyx_v_err = lua_tolstring(__pyx_v_L, -1, (&__pyx_v_size));

      /* "lupa/_lupa.pyx":326
 *             else:
 *                 err = lua.lua_tolstring(L, -1, &size)
 *                 error = err[:size] if self._encoding is None else err[:size].decode(self._encoding)             # <<<<<<<<<<<<<<
 *                 raise LuaSyntaxError(error)
 *         finally:
 */
      __pyx_t_2 = (__pyx_v_self->_encoding == ((PyObject*)Py_None));
      if ((__pyx_t_2 != 0)) {
        __pyx_t_9 = __Pyx_PyBytes_FromStringAndSize(__pyx_v_err + 0, __pyx_v_size - 0); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 326, __pyx_L5_error)
        __Pyx_GOTREF(__pyx_t_9);
        __pyx_t_4 = __pyx_t_9;
        __pyx_t_9 = 0;
      } else {
        if (unlikely(__pyx_v_self->_encoding == Py_None)) {
          PyErr_SetString(PyExc_TypeError, "expected bytes, NoneType found");
          __PYX_ERR(0, 326, __pyx_L5_error)
        }
        __pyx_t_3 = __Pyx_PyBytes_AsString(__pyx_v_self->_encoding); if (unlikely((!__pyx_t_3) && PyErr_Occurred())) __PYX_ERR(0, 326, __pyx_L5_error)
        __pyx_t_9 = __Pyx_decode_c_string(__pyx_v_err, 0, __pyx_v_size, __pyx_t_3, NULL, NULL); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 326, __pyx_L5_error)
        __Pyx_GOTREF(__pyx_t_9);
        __pyx_t_4 = __pyx_t_9;
        __pyx_t_9 = 0;
      }
      __pyx_v_error = __pyx_t_4;
      __pyx_t_4 = 0;

      /* "lupa/_lupa.pyx":327
 *                 err = lua.lua_tolstring(L, -1, &size)
 *                 error = err[:size] if self._encoding is None else err[:size].decode(self._encoding)
 *                 raise LuaSyntaxError(error)             # <<<<<<<<<<<<<<
 *         finally:
 *             lua.lua_settop(L, oldtop)
 */
      __Pyx_GetModuleGlobalName(__pyx_t_9, __pyx_n_s_LuaSyntaxError); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 327, __pyx_L5_error)
      __Pyx_GOTREF(__pyx_t_9);
      __pyx_t_10 = NULL;
      if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_9))) {
        __pyx_t_10 = PyMethod_GET_SELF(__pyx_t_9);
        if (likely(__pyx_t_10)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_9);
          __Pyx_INCREF(__pyx_t_10);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_9, function);
        }
      }
      __pyx_t_4 = (__pyx_t_10) ? __Pyx_PyObject_Call2Args(__pyx_t_9, __pyx_t_10, __pyx_v_error) : __Pyx_PyObject_CallOneArg(__pyx_t_9, __pyx_v_error);
      __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
      if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 327, __pyx_L5_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
      __Pyx_Raise(__pyx_t_4, 0, 0, 0);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __PYX_ERR(0, 327, __pyx_L5_error)
    }
  }

  /* "lupa/_lupa.pyx":329
 *                 raise LuaSyntaxError(error)
 *         finally:
 *             lua.lua_settop(L, oldtop)             # <<<<<<<<<<<<<<
 *             unlock_runtime(self)
 * 
 */
  /*finally:*/ {
    __pyx_L5_error:;
    /*exception exit:*/{
      __Pyx_PyThreadState_declare
      __Pyx_PyThreadState_assign
      __pyx_t_13 = 0; __pyx_t_14 = 0; __pyx_t_15 = 0; __pyx_t_16 = 0; __pyx_t_17 = 0; __pyx_t_18 = 0;
      __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
      __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
      __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
      if (PY_MAJOR_VERSION >= 3) __Pyx_ExceptionSwap(&__pyx_t_16, &__pyx_t_17, &__pyx_t_18);
      if ((PY_MAJOR_VERSION < 3) || unlikely(__Pyx_GetException(&__pyx_t_13, &__pyx_t_14, &__pyx_t_15) < 0)) __Pyx_ErrFetch(&__pyx_t_13, &__pyx_t_14, &__pyx_t_15);
      __Pyx_XGOTREF(__pyx_t_13);
      __Pyx_XGOTREF(__pyx_t_14);
      __Pyx_XGOTREF(__pyx_t_15);
      __Pyx_XGOTREF(__pyx_t_16);
      __Pyx_XGOTREF(__pyx_t_17);
      __Pyx_XGOTREF(__pyx_t_18);
      __pyx_t_6 = __pyx_lineno; __pyx_t_11 = __pyx_clineno; __pyx_t_12 = __pyx_filename;
      {
        lua_settop(__pyx_v_L, __pyx_v_oldtop);

        /* "lupa/_lupa.pyx":330
 *         finally:
 *             lua.lua_settop(L, oldtop)
 *             unlock_runtime(self)             # <<<<<<<<<<<<<<
 * 
 *     def require(self, modulename):
 */
        __pyx_f_4lupa_5_lupa_unlock_runtime(__pyx_v_self);
      }
      if (PY_MAJOR_VERSION >= 3) {
        __Pyx_XGIVEREF(__pyx_t_16);
        __Pyx_XGIVEREF(__pyx_t_17);
        __Pyx_XGIVEREF(__pyx_t_18);
        __Pyx_ExceptionReset(__pyx_t_16, __pyx_t_17, __pyx_t_18);
      }
      __Pyx_XGIVEREF(__pyx_t_13);
      __Pyx_XGIVEREF(__pyx_t_14);
      __Pyx_XGIVEREF(__pyx_t_15);
      __Pyx_ErrRestore(__pyx_t_13, __pyx_t_14, __pyx_t_15);
      __pyx_t_13 = 0; __pyx_t_14 = 0; __pyx_t_15 = 0; __pyx_t_16 = 0; __pyx_t_17 = 0; __pyx_t_18 = 0;
      __pyx_lineno = __pyx_t_6; __pyx_clineno = __pyx_t_11; __pyx_filename = __pyx_t_12;
      goto __pyx_L1_error;
    }
    __pyx_L4_return: {
      __pyx_t_18 = __pyx_r;
      __pyx_r = 0;

      /* "lupa/_lupa.pyx":329
 *                 raise LuaSyntaxError(error)
 *         finally:
 *             lua.lua_settop(L, oldtop)             # <<<<<<<<<<<<<<
 *             unlock_runtime(self)
 * 
 */
      lua_settop(__pyx_v_L, __pyx_v_oldtop);

      /* "lupa/_lupa.pyx":330
 *         finally:
 *             lua.lua_settop(L, oldtop)
 *             unlock_runtime(self)             # <<<<<<<<<<<<<<
 * 
 *     def require(self, modulename):
 */
      __pyx_f_4lupa_5_lupa_unlock_runtime(__pyx_v_self);
      __pyx_r = __pyx_t_18;
      __pyx_t_18 = 0;
      goto __pyx_L0;
    }
  }

  /* "lupa/_lupa.pyx":310
 *         return run_lua(self, lua_code, args)
 * 
 *     def compile(self, lua_code):             # <<<<<<<<<<<<<<
 *         """Compile a Lua program into a callable Lua function.
 *         """
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_9);
  __Pyx_XDECREF(__pyx_t_10);
  __Pyx_AddTraceback("lupa._lupa.LuaRuntime.compile", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_error);
  __Pyx_XDECREF(__pyx_v_lua_code);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lupa/_lupa.pyx":332
 *             unlock_runtime(self)
 * 
 *     def require(self, modulename):             # <<<<<<<<<<<<<<
 *         """Load a Lua library into the runtime.
 *         """
 */

/* Python wrapper */
static PyObject *__pyx_pw_4lupa_5_lupa_10LuaRuntime_11require(PyObject *__pyx_v_self, PyObject *__pyx_v_modulename); /*proto*/
static char __pyx_doc_4lupa_5_lupa_10LuaRuntime_10require[] = "LuaRuntime.require(self, modulename)\nLoad a Lua library into the runtime.\n        ";
static PyMethodDef __pyx_mdef_4lupa_5_lupa_10LuaRuntime_11require = {"require", (PyCFunction)__pyx_pw_4lupa_5_lupa_10LuaRuntime_11require, METH_O, __pyx_doc_4lupa_5_lupa_10LuaRuntime_10require};
static PyObject *__pyx_pw_4lupa_5_lupa_10LuaRuntime_11require(PyObject *__pyx_v_self, PyObject *__pyx_v_modulename) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("require (wrapper)", 0);
  __pyx_r = __pyx_pf_4lupa_5_lupa_10LuaRuntime_10require(((struct __pyx_obj_4lupa_5_lupa_LuaRuntime *)__pyx_v_self), ((PyObject *)__pyx_v_modulename));

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

static PyObject *__pyx_pf_4lupa_5_lupa_10LuaRuntime_10require(struct __pyx_obj_4lupa_5_lupa_LuaRuntime *__pyx_v_self, PyObject *__pyx_v_modulename) {
  lua_State *__pyx_v_L;
  int __pyx_v_old_top;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  lua_State *__pyx_t_1;
  int __pyx_t_2;
  int __pyx_t_3;
  int __pyx_t_4;
  PyObject *__pyx_t_5 = NULL;
  int __pyx_t_6;
  PyObject *__pyx_t_7 = NULL;
  PyObject *__pyx_t_8 = NULL;
  int __pyx_t_9;
  char const *__pyx_t_10;
  PyObject *__pyx_t_11 = NULL;
  PyObject *__pyx_t_12 = NULL;
  PyObject *__pyx_t_13 = NULL;
  PyObject *__pyx_t_14 = NULL;
  PyObject *__pyx_t_15 = NULL;
  PyObject *__pyx_t_16 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("require", 0);

  /* "lupa/_lupa.pyx":335
 *         """Load a Lua library into the runtime.
 *         """
 *         assert self._state is not NULL             # <<<<<<<<<<<<<<
 *         cdef lua_State *L = self._state
 *         if not isinstance(modulename, (bytes, unicode)):
 */
  #ifndef CYTHON_WITHOUT_ASSERTIONS
  if (unlikely(!Py_OptimizeFlag)) {
    if (unlikely(!((__pyx_v_self->_state != NULL) != 0))) {
      PyErr_SetNone(PyExc_AssertionError);
      __PYX_ERR(0, 335, __pyx_L1_error)
    }
  }
  #endif

  /* "lupa/_lupa.pyx":336
 *         """
 *         assert self._state is not NULL
 *         cdef lua_State *L = self._state             # <<<<<<<<<<<<<<
 *         if not isinstance(modulename, (bytes, unicode)):
 *             raise TypeError("modulename must be a string")
 */
  __pyx_t_1 = __pyx_v_self->_state;
  __pyx_v_L = __pyx_t_1;

  /* "lupa/_lupa.pyx":337
 *         assert self._state is not NULL
 *         cdef lua_State *L = self._state
 *         if not isinstance(modulename, (bytes, unicode)):             # <<<<<<<<<<<<<<
 *             raise TypeError("modulename must be a string")
 *         lock_runtime(self)
 */
  __pyx_t_3 = PyBytes_Check(__pyx_v_modulename); 
  __pyx_t_4 = (__pyx_t_3 != 0);
  if (!__pyx_t_4) {
  } else {
    __pyx_t_2 = __pyx_t_4;
    goto __pyx_L4_bool_binop_done;
  }
  __pyx_t_4 = PyUnicode_Check(__pyx_v_modulename); 
  __pyx_t_3 = (__pyx_t_4 != 0);
  __pyx_t_2 = __pyx_t_3;
  __pyx_L4_bool_binop_done:;
  __pyx_t_3 = ((!(__pyx_t_2 != 0)) != 0);
  if (unlikely(__pyx_t_3)) {

    /* "lupa/_lupa.pyx":338
 *         cdef lua_State *L = self._state
 *         if not isinstance(modulename, (bytes, unicode)):
 *             raise TypeError("modulename must be a string")             # <<<<<<<<<<<<<<
 *         lock_runtime(self)
 *         old_top = lua.lua_gettop(L)
 */
    __pyx_t_5 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__7, NULL); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 338, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_Raise(__pyx_t_5, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __PYX_ERR(0, 338, __pyx_L1_error)

    /* "lupa/_lupa.pyx":337
 *         assert self._state is not NULL
 *         cdef lua_State *L = self._state
 *         if not isinstance(modulename, (bytes, unicode)):             # <<<<<<<<<<<<<<
 *             raise TypeError("modulename must be a string")
 *         lock_runtime(self)
 */
  }

  /* "lupa/_lupa.pyx":339
 *         if not isinstance(modulename, (bytes, unicode)):
 *             raise TypeError("modulename must be a string")
 *         lock_runtime(self)             # <<<<<<<<<<<<<<
 *         old_top = lua.lua_gettop(L)
 *         try:
 */
  __pyx_t_6 = __pyx_f_4lupa_5_lupa_lock_runtime(__pyx_v_self); if (unlikely(__pyx_t_6 == ((int)-1))) __PYX_ERR(0, 339, __pyx_L1_error)

  /* "lupa/_lupa.pyx":340
 *             raise TypeError("modulename must be a string")
 *         lock_runtime(self)
 *         old_top = lua.lua_gettop(L)             # <<<<<<<<<<<<<<
 *         try:
 *             lua.lua_getglobal(L, 'require')
 */
  __pyx_v_old_top = lua_gettop(__pyx_v_L);

  /* "lupa/_lupa.pyx":341
 *         lock_runtime(self)
 *         old_top = lua.lua_gettop(L)
 *         try:             # <<<<<<<<<<<<<<
 *             lua.lua_getglobal(L, 'require')
 *             if lua.lua_isnil(L, -1):
 */
  /*try:*/ {

    /* "lupa/_lupa.pyx":342
 *         old_top = lua.lua_gettop(L)
 *         try:
 *             lua.lua_getglobal(L, 'require')             # <<<<<<<<<<<<<<
 *             if lua.lua_isnil(L, -1):
 *                 raise LuaError("require is not defined")
 */
    lua_getglobal(__pyx_v_L, ((char *)"require"));

    /* "lupa/_lupa.pyx":343
 *         try:
 *             lua.lua_getglobal(L, 'require')
 *             if lua.lua_isnil(L, -1):             # <<<<<<<<<<<<<<
 *                 raise LuaError("require is not defined")
 *             return call_lua(self, L, (modulename,))
 */
    __pyx_t_3 = (lua_isnil(__pyx_v_L, -1) != 0);
    if (unlikely(__pyx_t_3)) {

      /* "lupa/_lupa.pyx":344
 *             lua.lua_getglobal(L, 'require')
 *             if lua.lua_isnil(L, -1):
 *                 raise LuaError("require is not defined")             # <<<<<<<<<<<<<<
 *             return call_lua(self, L, (modulename,))
 *         finally:
 */
      __Pyx_GetModuleGlobalName(__pyx_t_7, __pyx_n_s_LuaError); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 344, __pyx_L7_error)
      __Pyx_GOTREF(__pyx_t_7);
      __pyx_t_8 = NULL;
      if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_7))) {
        __pyx_t_8 = PyMethod_GET_SELF(__pyx_t_7);
        if (likely(__pyx_t_8)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_7);
          __Pyx_INCREF(__pyx_t_8);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_7, function);
        }
      }
      __pyx_t_5 = (__pyx_t_8) ? __Pyx_PyObject_Call2Args(__pyx_t_7, __pyx_t_8, __pyx_kp_s_require_is_not_defined) : __Pyx_PyObject_CallOneArg(__pyx_t_7, __pyx_kp_s_require_is_not_defined);
      __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
      if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 344, __pyx_L7_error)
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      __Pyx_Raise(__pyx_t_5, 0, 0, 0);
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __PYX_ERR(0, 344, __pyx_L7_error)

      /* "lupa/_lupa.pyx":343
 *         try:
 *             lua.lua_getglobal(L, 'require')
 *             if lua.lua_isnil(L, -1):             # <<<<<<<<<<<<<<
 *                 raise LuaError("require is not defined")
 *             return call_lua(self, L, (modulename,))
 */
    }

    /* "lupa/_lupa.pyx":345
 *             if lua.lua_isnil(L, -1):
 *                 raise LuaError("require is not defined")
 *             return call_lua(self, L, (modulename,))             # <<<<<<<<<<<<<<
 *         finally:
 *             lua.lua_settop(L, old_top)
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_5 = PyTuple_New(1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 345, __pyx_L7_error)
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_INCREF(__pyx_v_modulename);
    __Pyx_GIVEREF(__pyx_v_modulename);
    PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_v_modulename);
    __pyx_t_7 = __pyx_f_4lupa_5_lupa_call_lua(__pyx_v_self, __pyx_v_L, ((PyObject*)__pyx_t_5)); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 345, __pyx_L7_error)
    __Pyx_GOTREF(__pyx_t_7);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __pyx_r = __pyx_t_7;
    __pyx_t_7 = 0;
    goto __pyx_L6_return;
  }

  /* "lupa/_lupa.pyx":347
 *             return call_lua(self, L, (modulename,))
 *         finally:
 *             lua.lua_settop(L, old_top)             # <<<<<<<<<<<<<<
 *             unlock_runtime(self)
 * 
 */
  /*finally:*/ {
    __pyx_L7_error:;
    /*exception exit:*/{
      __Pyx_PyThreadState_declare
      __Pyx_PyThreadState_assign
      __pyx_t_11 = 0; __pyx_t_12 = 0; __pyx_t_13 = 0; __pyx_t_14 = 0; __pyx_t_15 = 0; __pyx_t_16 = 0;
      __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
      __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
      __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
      if (PY_MAJOR_VERSION >= 3) __Pyx_ExceptionSwap(&__pyx_t_14, &__pyx_t_15, &__pyx_t_16);
      if ((PY_MAJOR_VERSION < 3) || unlikely(__Pyx_GetException(&__pyx_t_11, &__pyx_t_12, &__pyx_t_13) < 0)) __Pyx_ErrFetch(&__pyx_t_11, &__pyx_t_12, &__pyx_t_13);
      __Pyx_XGOTREF(__pyx_t_11);
      __Pyx_XGOTREF(__pyx_t_12);
      __Pyx_XGOTREF(__pyx_t_13);
      __Pyx_XGOTREF(__pyx_t_14);
      __Pyx_XGOTREF(__pyx_t_15);
      __Pyx_XGOTREF(__pyx_t_16);
      __pyx_t_6 = __pyx_lineno; __pyx_t_9 = __pyx_clineno; __pyx_t_10 = __pyx_filename;
      {
        lua_settop(__pyx_v_L, __pyx_v_old_top);

        /* "lupa/_lupa.pyx":348
 *         finally:
 *             lua.lua_settop(L, old_top)
 *             unlock_runtime(self)             # <<<<<<<<<<<<<<
 * 
 *     def globals(self):
 */
        __pyx_f_4lupa_5_lupa_unlock_runtime(__pyx_v_self);
      }
      if (PY_MAJOR_VERSION >= 3) {
        __Pyx_XGIVEREF(__pyx_t_14);
        __Pyx_XGIVEREF(__pyx_t_15);
        __Pyx_XGIVEREF(__pyx_t_16);
        __Pyx_ExceptionReset(__pyx_t_14, __pyx_t_15, __pyx_t_16);
      }
      __Pyx_XGIVEREF(__pyx_t_11);
      __Pyx_XGIVEREF(__pyx_t_12);
      __Pyx_XGIVEREF(__pyx_t_13);
      __Pyx_ErrRestore(__pyx_t_11, __pyx_t_12, __pyx_t_13);
      __pyx_t_11 = 0; __pyx_t_12 = 0; __pyx_t_13 = 0; __pyx_t_14 = 0; __pyx_t_15 = 0; __pyx_t_16 = 0;
      __pyx_lineno = __pyx_t_6; __pyx_clineno = __pyx_t_9; __pyx_filename = __pyx_t_10;
      goto __pyx_L1_error;
    }
    __pyx_L6_return: {
      __pyx_t_16 = __pyx_r;
      __pyx_r = 0;

      /* "lupa/_lupa.pyx":347
 *             return call_lua(self, L, (modulename,))
 *         finally:
 *             lua.lua_settop(L, old_top)             # <<<<<<<<<<<<<<
 *             unlock_runtime(self)
 * 
 */
      lua_settop(__pyx_v_L, __pyx_v_old_top);

      /* "lupa/_lupa.pyx":348
 *         finally:
 *             lua.lua_settop(L, old_top)
 *             unlock_runtime(self)             # <<<<<<<<<<<<<<
 * 
 *     def globals(self):
 */
      __pyx_f_4lupa_5_lupa_unlock_runtime(__pyx_v_self);
      __pyx_r = __pyx_t_16;
      __pyx_t_16 = 0;
      goto __pyx_L0;
    }
  }

  /* "lupa/_lupa.pyx":332
 *             unlock_runtime(self)
 * 
 *     def require(self, modulename):             # <<<<<<<<<<<<<<
 *         """Load a Lua library into the runtime.
 *         """
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_AddTraceback("lupa._lupa.LuaRuntime.require", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lupa/_lupa.pyx":350
 *             unlock_runtime(self)
 * 
 *     def globals(self):             # <<<<<<<<<<<<<<
 *         """Return the globals defined in this Lua runtime as a Lua
 *         table.
 */

/* Python wrapper */
static PyObject *__pyx_pw_4lupa_5_lupa_10LuaRuntime_13globals(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static char __pyx_doc_4lupa_5_lupa_10LuaRuntime_12globals[] = "LuaRuntime.globals(self)\nReturn the globals defined in this Lua runtime as a Lua\n        table.\n        ";
static PyMethodDef __pyx_mdef_4lupa_5_lupa_10LuaRuntime_13globals = {"globals", (PyCFunction)__pyx_pw_4lupa_5_lupa_10LuaRuntime_13globals, METH_NOARGS, __pyx_doc_4lupa_5_lupa_10LuaRuntime_12globals};
static PyObject *__pyx_pw_4lupa_5_lupa_10LuaRuntime_13globals(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("globals (wrapper)", 0);
  __pyx_r = __pyx_pf_4lupa_5_lupa_10LuaRuntime_12globals(((struct __pyx_obj_4lupa_5_lupa_LuaRuntime *)__pyx_v_self));

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

static PyObject *__pyx_pf_4lupa_5_lupa_10LuaRuntime_12globals(struct __pyx_obj_4lupa_5_lupa_LuaRuntime *__pyx_v_self) {
  lua_State *__pyx_v_L;
  int __pyx_v_old_top;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  lua_State *__pyx_t_1;
  int __pyx_t_2;
  int __pyx_t_3;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  int __pyx_t_7;
  char const *__pyx_t_8;
  PyObject *__pyx_t_9 = NULL;
  PyObject *__pyx_t_10 = NULL;
  PyObject *__pyx_t_11 = NULL;
  PyObject *__pyx_t_12 = NULL;
  PyObject *__pyx_t_13 = NULL;
  PyObject *__pyx_t_14 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("globals", 0);

  /* "lupa/_lupa.pyx":354
 *         table.
 *         """
 *         assert self._state is not NULL             # <<<<<<<<<<<<<<
 *         cdef lua_State *L = self._state
 *         lock_runtime(self)
 */
  #ifndef CYTHON_WITHOUT_ASSERTIONS
  if (unlikely(!Py_OptimizeFlag)) {
    if (unlikely(!((__pyx_v_self->_state != NULL) != 0))) {
      PyErr_SetNone(PyExc_AssertionError);
      __PYX_ERR(0, 354, __pyx_L1_error)
    }
  }
  #endif

  /* "lupa/_lupa.pyx":355
 *         """
 *         assert self._state is not NULL
 *         cdef lua_State *L = self._state             # <<<<<<<<<<<<<<
 *         lock_runtime(self)
 *         old_top = lua.lua_gettop(L)
 */
  __pyx_t_1 = __pyx_v_self->_state;
  __pyx_v_L = __pyx_t_1;

  /* "lupa/_lupa.pyx":356
 *         assert self._state is not NULL
 *         cdef lua_State *L = self._state
 *         lock_runtime(self)             # <<<<<<<<<<<<<<
 *         old_top = lua.lua_gettop(L)
 *         try:
 */
  __pyx_t_2 = __pyx_f_4lupa_5_lupa_lock_runtime(__pyx_v_self); if (unlikely(__pyx_t_2 == ((int)-1))) __PYX_ERR(0, 356, __pyx_L1_error)

  /* "lupa/_lupa.pyx":357
 *         cdef lua_State *L = self._state
 *         lock_runtime(self)
 *         old_top = lua.lua_gettop(L)             # <<<<<<<<<<<<<<
 *         try:
 *             lua.lua_getglobal(L, '_G')
 */
  __pyx_v_old_top = lua_gettop(__pyx_v_L);

  /* "lupa/_lupa.pyx":358
 *         lock_runtime(self)
 *         old_top = lua.lua_gettop(L)
 *         try:             # <<<<<<<<<<<<<<
 *             lua.lua_getglobal(L, '_G')
 *             if lua.lua_isnil(L, -1):
 */
  /*try:*/ {

    /* "lupa/_lupa.pyx":359
 *         old_top = lua.lua_gettop(L)
 *         try:
 *             lua.lua_getglobal(L, '_G')             # <<<<<<<<<<<<<<
 *             if lua.lua_isnil(L, -1):
 *                 raise LuaError("globals not defined")
 */
    lua_getglobal(__pyx_v_L, ((char *)"_G"));

    /* "lupa/_lupa.pyx":360
 *         try:
 *             lua.lua_getglobal(L, '_G')
 *             if lua.lua_isnil(L, -1):             # <<<<<<<<<<<<<<
 *                 raise LuaError("globals not defined")
 *             return py_from_lua(self, L, -1)
 */
    __pyx_t_3 = (lua_isnil(__pyx_v_L, -1) != 0);
    if (unlikely(__pyx_t_3)) {

      /* "lupa/_lupa.pyx":361
 *             lua.lua_getglobal(L, '_G')
 *             if lua.lua_isnil(L, -1):
 *                 raise LuaError("globals not defined")             # <<<<<<<<<<<<<<
 *             return py_from_lua(self, L, -1)
 *         finally:
 */
      __Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_n_s_LuaError); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 361, __pyx_L4_error)
      __Pyx_GOTREF(__pyx_t_5);
      __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_kp_s_globals_not_defined) : __Pyx_PyObject_CallOneArg(__pyx_t_5, __pyx_kp_s_globals_not_defined);
      __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
      if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 361, __pyx_L4_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, 361, __pyx_L4_error)

      /* "lupa/_lupa.pyx":360
 *         try:
 *             lua.lua_getglobal(L, '_G')
 *             if lua.lua_isnil(L, -1):             # <<<<<<<<<<<<<<
 *                 raise LuaError("globals not defined")
 *             return py_from_lua(self, L, -1)
 */
    }

    /* "lupa/_lupa.pyx":362
 *             if lua.lua_isnil(L, -1):
 *                 raise LuaError("globals not defined")
 *             return py_from_lua(self, L, -1)             # <<<<<<<<<<<<<<
 *         finally:
 *             lua.lua_settop(L, old_top)
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_4 = __pyx_f_4lupa_5_lupa_py_from_lua(__pyx_v_self, __pyx_v_L, -1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 362, __pyx_L4_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_r = __pyx_t_4;
    __pyx_t_4 = 0;
    goto __pyx_L3_return;
  }

  /* "lupa/_lupa.pyx":364
 *             return py_from_lua(self, L, -1)
 *         finally:
 *             lua.lua_settop(L, old_top)             # <<<<<<<<<<<<<<
 *             unlock_runtime(self)
 * 
 */
  /*finally:*/ {
    __pyx_L4_error:;
    /*exception exit:*/{
      __Pyx_PyThreadState_declare
      __Pyx_PyThreadState_assign
      __pyx_t_9 = 0; __pyx_t_10 = 0; __pyx_t_11 = 0; __pyx_t_12 = 0; __pyx_t_13 = 0; __pyx_t_14 = 0;
      __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
      __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
      __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
      if (PY_MAJOR_VERSION >= 3) __Pyx_ExceptionSwap(&__pyx_t_12, &__pyx_t_13, &__pyx_t_14);
      if ((PY_MAJOR_VERSION < 3) || unlikely(__Pyx_GetException(&__pyx_t_9, &__pyx_t_10, &__pyx_t_11) < 0)) __Pyx_ErrFetch(&__pyx_t_9, &__pyx_t_10, &__pyx_t_11);
      __Pyx_XGOTREF(__pyx_t_9);
      __Pyx_XGOTREF(__pyx_t_10);
      __Pyx_XGOTREF(__pyx_t_11);
      __Pyx_XGOTREF(__pyx_t_12);
      __Pyx_XGOTREF(__pyx_t_13);
      __Pyx_XGOTREF(__pyx_t_14);
      __pyx_t_2 = __pyx_lineno; __pyx_t_7 = __pyx_clineno; __pyx_t_8 = __pyx_filename;
      {
        lua_settop(__pyx_v_L, __pyx_v_old_top);

        /* "lupa/_lupa.pyx":365
 *         finally:
 *             lua.lua_settop(L, old_top)
 *             unlock_runtime(self)             # <<<<<<<<<<<<<<
 * 
 *     def table(self, *items, **kwargs):
 */
        __pyx_f_4lupa_5_lupa_unlock_runtime(__pyx_v_self);
      }
      if (PY_MAJOR_VERSION >= 3) {
        __Pyx_XGIVEREF(__pyx_t_12);
        __Pyx_XGIVEREF(__pyx_t_13);
        __Pyx_XGIVEREF(__pyx_t_14);
        __Pyx_ExceptionReset(__pyx_t_12, __pyx_t_13, __pyx_t_14);
      }
      __Pyx_XGIVEREF(__pyx_t_9);
      __Pyx_XGIVEREF(__pyx_t_10);
      __Pyx_XGIVEREF(__pyx_t_11);
      __Pyx_ErrRestore(__pyx_t_9, __pyx_t_10, __pyx_t_11);
      __pyx_t_9 = 0; __pyx_t_10 = 0; __pyx_t_11 = 0; __pyx_t_12 = 0; __pyx_t_13 = 0; __pyx_t_14 = 0;
      __pyx_lineno = __pyx_t_2; __pyx_clineno = __pyx_t_7; __pyx_filename = __pyx_t_8;
      goto __pyx_L1_error;
    }
    __pyx_L3_return: {
      __pyx_t_14 = __pyx_r;
      __pyx_r = 0;

      /* "lupa/_lupa.pyx":364
 *             return py_from_lua(self, L, -1)
 *         finally:
 *             lua.lua_settop(L, old_top)             # <<<<<<<<<<<<<<
 *             unlock_runtime(self)
 * 
 */
      lua_settop(__pyx_v_L, __pyx_v_old_top);

      /* "lupa/_lupa.pyx":365
 *         finally:
 *             lua.lua_settop(L, old_top)
 *             unlock_runtime(self)             # <<<<<<<<<<<<<<
 * 
 *     def table(self, *items, **kwargs):
 */
      __pyx_f_4lupa_5_lupa_unlock_runtime(__pyx_v_self);
      __pyx_r = __pyx_t_14;
      __pyx_t_14 = 0;
      goto __pyx_L0;
    }
  }

  /* "lupa/_lupa.pyx":350
 *             unlock_runtime(self)
 * 
 *     def globals(self):             # <<<<<<<<<<<<<<
 *         """Return the globals defined in this Lua runtime as a Lua
 *         table.
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_AddTraceback("lupa._lupa.LuaRuntime.globals", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lupa/_lupa.pyx":367
 *             unlock_runtime(self)
 * 
 *     def table(self, *items, **kwargs):             # <<<<<<<<<<<<<<
 *         """Create a new table with the provided items.  Positional
 *         arguments are placed in the table in order, keyword arguments
 */

/* Python wrapper */
static PyObject *__pyx_pw_4lupa_5_lupa_10LuaRuntime_15table(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4lupa_5_lupa_10LuaRuntime_14table[] = "LuaRuntime.table(self, *items, **kwargs)\nCreate a new table with the provided items.  Positional\n        arguments are placed in the table in order, keyword arguments\n        are set as key-value pairs.\n        ";
static PyMethodDef __pyx_mdef_4lupa_5_lupa_10LuaRuntime_15table = {"table", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_4lupa_5_lupa_10LuaRuntime_15table, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4lupa_5_lupa_10LuaRuntime_14table};
static PyObject *__pyx_pw_4lupa_5_lupa_10LuaRuntime_15table(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_items = 0;
  PyObject *__pyx_v_kwargs = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("table (wrapper)", 0);
  if (unlikely(__pyx_kwds) && unlikely(!__Pyx_CheckKeywordStrings(__pyx_kwds, "table", 1))) return NULL;
  __pyx_v_kwargs = (__pyx_kwds) ? PyDict_Copy(__pyx_kwds) : PyDict_New(); if (unlikely(!__pyx_v_kwargs)) return NULL;
  __Pyx_GOTREF(__pyx_v_kwargs);
  __Pyx_INCREF(__pyx_args);
  __pyx_v_items = __pyx_args;
  __pyx_r = __pyx_pf_4lupa_5_lupa_10LuaRuntime_14table(((struct __pyx_obj_4lupa_5_lupa_LuaRuntime *)__pyx_v_self), __pyx_v_items, __pyx_v_kwargs);

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

static PyObject *__pyx_pf_4lupa_5_lupa_10LuaRuntime_14table(struct __pyx_obj_4lupa_5_lupa_LuaRuntime *__pyx_v_self, PyObject *__pyx_v_items, PyObject *__pyx_v_kwargs) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  int __pyx_t_4;
  PyObject *__pyx_t_5 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("table", 0);

  /* "lupa/_lupa.pyx":372
 *         are set as key-value pairs.
 *         """
 *         return self.table_from(items, kwargs)             # <<<<<<<<<<<<<<
 * 
 *     def table_from(self, *args):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_table_from); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 372, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = NULL;
  __pyx_t_4 = 0;
  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_4 = 1;
    }
  }
  #if CYTHON_FAST_PYCALL
  if (PyFunction_Check(__pyx_t_2)) {
    PyObject *__pyx_temp[3] = {__pyx_t_3, __pyx_v_items, __pyx_v_kwargs};
    __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_4, 2+__pyx_t_4); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 372, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_GOTREF(__pyx_t_1);
  } else
  #endif
  #if CYTHON_FAST_PYCCALL
  if (__Pyx_PyFastCFunction_Check(__pyx_t_2)) {
    PyObject *__pyx_temp[3] = {__pyx_t_3, __pyx_v_items, __pyx_v_kwargs};
    __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_4, 2+__pyx_t_4); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 372, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_GOTREF(__pyx_t_1);
  } else
  #endif
  {
    __pyx_t_5 = PyTuple_New(2+__pyx_t_4); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 372, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    if (__pyx_t_3) {
      __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_3); __pyx_t_3 = NULL;
    }
    __Pyx_INCREF(__pyx_v_items);
    __Pyx_GIVEREF(__pyx_v_items);
    PyTuple_SET_ITEM(__pyx_t_5, 0+__pyx_t_4, __pyx_v_items);
    __Pyx_INCREF(__pyx_v_kwargs);
    __Pyx_GIVEREF(__pyx_v_kwargs);
    PyTuple_SET_ITEM(__pyx_t_5, 1+__pyx_t_4, __pyx_v_kwargs);
    __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_5, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 372, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  }
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "lupa/_lupa.pyx":367
 *             unlock_runtime(self)
 * 
 *     def table(self, *items, **kwargs):             # <<<<<<<<<<<<<<
 *         """Create a new table with the provided items.  Positional
 *         arguments are placed in the table in order, keyword arguments
 */

  /* 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_5);
  __Pyx_AddTraceback("lupa._lupa.LuaRuntime.table", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lupa/_lupa.pyx":374
 *         return self.table_from(items, kwargs)
 * 
 *     def table_from(self, *args):             # <<<<<<<<<<<<<<
 *         """Create a new table from Python mapping or iterable.
 * 
 */

/* Python wrapper */
static PyObject *__pyx_pw_4lupa_5_lupa_10LuaRuntime_17table_from(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4lupa_5_lupa_10LuaRuntime_16table_from[] = "LuaRuntime.table_from(self, *args)\nCreate a new table from Python mapping or iterable.\n\n        table_from() accepts either a dict/mapping or an iterable with items.\n        Items from dicts are set as key-value pairs; items from iterables\n        are placed in the table in order.\n\n        Nested mappings / iterables are passed to Lua as userdata\n        (wrapped Python objects); they are not converted to Lua tables.\n        ";
static PyMethodDef __pyx_mdef_4lupa_5_lupa_10LuaRuntime_17table_from = {"table_from", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_4lupa_5_lupa_10LuaRuntime_17table_from, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4lupa_5_lupa_10LuaRuntime_16table_from};
static PyObject *__pyx_pw_4lupa_5_lupa_10LuaRuntime_17table_from(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_args = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("table_from (wrapper)", 0);
  if (unlikely(__pyx_kwds) && unlikely(PyDict_Size(__pyx_kwds) > 0) && unlikely(!__Pyx_CheckKeywordStrings(__pyx_kwds, "table_from", 0))) return NULL;
  __Pyx_INCREF(__pyx_args);
  __pyx_v_args = __pyx_args;
  __pyx_r = __pyx_pf_4lupa_5_lupa_10LuaRuntime_16table_from(((struct __pyx_obj_4lupa_5_lupa_LuaRuntime *)__pyx_v_self), __pyx_v_args);

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

static PyObject *__pyx_pf_4lupa_5_lupa_10LuaRuntime_16table_from(struct __pyx_obj_4lupa_5_lupa_LuaRuntime *__pyx_v_self, PyObject *__pyx_v_args) {
  lua_State *__pyx_v_L;
  int __pyx_v_i;
  int __pyx_v_old_top;
  PyObject *__pyx_v_obj = NULL;
  PyObject *__pyx_v_key = NULL;
  PyObject *__pyx_v_value = NULL;
  PyObject *__pyx_v_arg = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  lua_State *__pyx_t_1;
  int __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  Py_ssize_t __pyx_t_4;
  PyObject *__pyx_t_5 = NULL;
  int __pyx_t_6;
  int __pyx_t_7;
  Py_ssize_t __pyx_t_8;
  Py_ssize_t __pyx_t_9;
  PyObject *__pyx_t_10 = NULL;
  PyObject *__pyx_t_11 = NULL;
  int __pyx_t_12;
  PyObject *(*__pyx_t_13)(PyObject *);
  char const *__pyx_t_14;
  PyObject *__pyx_t_15 = NULL;
  PyObject *__pyx_t_16 = NULL;
  PyObject *__pyx_t_17 = NULL;
  PyObject *__pyx_t_18 = NULL;
  PyObject *__pyx_t_19 = NULL;
  PyObject *__pyx_t_20 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("table_from", 0);

  /* "lupa/_lupa.pyx":384
 *         (wrapped Python objects); they are not converted to Lua tables.
 *         """
 *         assert self._state is not NULL             # <<<<<<<<<<<<<<
 *         cdef lua_State *L = self._state
 *         cdef int i = 1
 */
  #ifndef CYTHON_WITHOUT_ASSERTIONS
  if (unlikely(!Py_OptimizeFlag)) {
    if (unlikely(!((__pyx_v_self->_state != NULL) != 0))) {
      PyErr_SetNone(PyExc_AssertionError);
      __PYX_ERR(0, 384, __pyx_L1_error)
    }
  }
  #endif

  /* "lupa/_lupa.pyx":385
 *         """
 *         assert self._state is not NULL
 *         cdef lua_State *L = self._state             # <<<<<<<<<<<<<<
 *         cdef int i = 1
 *         lock_runtime(self)
 */
  __pyx_t_1 = __pyx_v_self->_state;
  __pyx_v_L = __pyx_t_1;

  /* "lupa/_lupa.pyx":386
 *         assert self._state is not NULL
 *         cdef lua_State *L = self._state
 *         cdef int i = 1             # <<<<<<<<<<<<<<
 *         lock_runtime(self)
 *         old_top = lua.lua_gettop(L)
 */
  __pyx_v_i = 1;

  /* "lupa/_lupa.pyx":387
 *         cdef lua_State *L = self._state
 *         cdef int i = 1
 *         lock_runtime(self)             # <<<<<<<<<<<<<<
 *         old_top = lua.lua_gettop(L)
 *         try:
 */
  __pyx_t_2 = __pyx_f_4lupa_5_lupa_lock_runtime(__pyx_v_self); if (unlikely(__pyx_t_2 == ((int)-1))) __PYX_ERR(0, 387, __pyx_L1_error)

  /* "lupa/_lupa.pyx":388
 *         cdef int i = 1
 *         lock_runtime(self)
 *         old_top = lua.lua_gettop(L)             # <<<<<<<<<<<<<<
 *         try:
 *             lua.lua_newtable(L)
 */
  __pyx_v_old_top = lua_gettop(__pyx_v_L);

  /* "lupa/_lupa.pyx":389
 *         lock_runtime(self)
 *         old_top = lua.lua_gettop(L)
 *         try:             # <<<<<<<<<<<<<<
 *             lua.lua_newtable(L)
 *             # FIXME: how to check for failure?
 */
  /*try:*/ {

    /* "lupa/_lupa.pyx":390
 *         old_top = lua.lua_gettop(L)
 *         try:
 *             lua.lua_newtable(L)             # <<<<<<<<<<<<<<
 *             # FIXME: how to check for failure?
 *             for obj in args:
 */
    lua_newtable(__pyx_v_L);

    /* "lupa/_lupa.pyx":392
 *             lua.lua_newtable(L)
 *             # FIXME: how to check for failure?
 *             for obj in args:             # <<<<<<<<<<<<<<
 *                 if isinstance(obj, dict):
 *                     for key, value in obj.iteritems():
 */
    __pyx_t_3 = __pyx_v_args; __Pyx_INCREF(__pyx_t_3); __pyx_t_4 = 0;
    for (;;) {
      if (__pyx_t_4 >= PyTuple_GET_SIZE(__pyx_t_3)) break;
      #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
      __pyx_t_5 = PyTuple_GET_ITEM(__pyx_t_3, __pyx_t_4); __Pyx_INCREF(__pyx_t_5); __pyx_t_4++; if (unlikely(0 < 0)) __PYX_ERR(0, 392, __pyx_L4_error)
      #else
      __pyx_t_5 = PySequence_ITEM(__pyx_t_3, __pyx_t_4); __pyx_t_4++; if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 392, __pyx_L4_error)
      __Pyx_GOTREF(__pyx_t_5);
      #endif
      __Pyx_XDECREF_SET(__pyx_v_obj, __pyx_t_5);
      __pyx_t_5 = 0;

      /* "lupa/_lupa.pyx":393
 *             # FIXME: how to check for failure?
 *             for obj in args:
 *                 if isinstance(obj, dict):             # <<<<<<<<<<<<<<
 *                     for key, value in obj.iteritems():
 *                         py_to_lua(self, L, key)
 */
      __pyx_t_6 = PyDict_Check(__pyx_v_obj); 
      __pyx_t_7 = (__pyx_t_6 != 0);
      if (__pyx_t_7) {

        /* "lupa/_lupa.pyx":394
 *             for obj in args:
 *                 if isinstance(obj, dict):
 *                     for key, value in obj.iteritems():             # <<<<<<<<<<<<<<
 *                         py_to_lua(self, L, key)
 *                         py_to_lua(self, L, value)
 */
        __pyx_t_8 = 0;
        if (unlikely(__pyx_v_obj == Py_None)) {
          PyErr_Format(PyExc_AttributeError, "'NoneType' object has no attribute '%.30s'", "iteritems");
          __PYX_ERR(0, 394, __pyx_L4_error)
        }
        __pyx_t_10 = __Pyx_dict_iterator(__pyx_v_obj, 0, __pyx_n_s_iteritems, (&__pyx_t_9), (&__pyx_t_2)); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 394, __pyx_L4_error)
        __Pyx_GOTREF(__pyx_t_10);
        __Pyx_XDECREF(__pyx_t_5);
        __pyx_t_5 = __pyx_t_10;
        __pyx_t_10 = 0;
        while (1) {
          __pyx_t_12 = __Pyx_dict_iter_next(__pyx_t_5, __pyx_t_9, &__pyx_t_8, &__pyx_t_10, &__pyx_t_11, NULL, __pyx_t_2);
          if (unlikely(__pyx_t_12 == 0)) break;
          if (unlikely(__pyx_t_12 == -1)) __PYX_ERR(0, 394, __pyx_L4_error)
          __Pyx_GOTREF(__pyx_t_10);
          __Pyx_GOTREF(__pyx_t_11);
          __Pyx_XDECREF_SET(__pyx_v_key, __pyx_t_10);
          __pyx_t_10 = 0;
          __Pyx_XDECREF_SET(__pyx_v_value, __pyx_t_11);
          __pyx_t_11 = 0;

          /* "lupa/_lupa.pyx":395
 *                 if isinstance(obj, dict):
 *                     for key, value in obj.iteritems():
 *                         py_to_lua(self, L, key)             # <<<<<<<<<<<<<<
 *                         py_to_lua(self, L, value)
 *                         lua.lua_rawset(L, -3)
 */
          __pyx_t_12 = __pyx_f_4lupa_5_lupa_py_to_lua(__pyx_v_self, __pyx_v_L, __pyx_v_key, NULL); if (unlikely(__pyx_t_12 == ((int)-1))) __PYX_ERR(0, 395, __pyx_L4_error)

          /* "lupa/_lupa.pyx":396
 *                     for key, value in obj.iteritems():
 *                         py_to_lua(self, L, key)
 *                         py_to_lua(self, L, value)             # <<<<<<<<<<<<<<
 *                         lua.lua_rawset(L, -3)
 * 
 */
          __pyx_t_12 = __pyx_f_4lupa_5_lupa_py_to_lua(__pyx_v_self, __pyx_v_L, __pyx_v_value, NULL); if (unlikely(__pyx_t_12 == ((int)-1))) __PYX_ERR(0, 396, __pyx_L4_error)

          /* "lupa/_lupa.pyx":397
 *                         py_to_lua(self, L, key)
 *                         py_to_lua(self, L, value)
 *                         lua.lua_rawset(L, -3)             # <<<<<<<<<<<<<<
 * 
 *                 elif isinstance(obj, _LuaTable):
 */
          lua_rawset(__pyx_v_L, -3);
        }
        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

        /* "lupa/_lupa.pyx":393
 *             # FIXME: how to check for failure?
 *             for obj in args:
 *                 if isinstance(obj, dict):             # <<<<<<<<<<<<<<
 *                     for key, value in obj.iteritems():
 *                         py_to_lua(self, L, key)
 */
        goto __pyx_L8;
      }

      /* "lupa/_lupa.pyx":399
 *                         lua.lua_rawset(L, -3)
 * 
 *                 elif isinstance(obj, _LuaTable):             # <<<<<<<<<<<<<<
 *                     # Stack:                            # tbl
 *                     (<_LuaObject>obj).push_lua_object() # tbl, obj
 */
      __pyx_t_7 = __Pyx_TypeCheck(__pyx_v_obj, __pyx_ptype_4lupa_5_lupa__LuaTable); 
      __pyx_t_6 = (__pyx_t_7 != 0);
      if (__pyx_t_6) {

        /* "lupa/_lupa.pyx":401
 *                 elif isinstance(obj, _LuaTable):
 *                     # Stack:                            # tbl
 *                     (<_LuaObject>obj).push_lua_object() # tbl, obj             # <<<<<<<<<<<<<<
 *                     lua.lua_pushnil(L)                  # tbl, obj, nil       // iterate over obj (-2)
 *                     while lua.lua_next(L, -2):          # tbl, obj, k, v
 */
        __pyx_t_2 = __pyx_f_4lupa_5_lupa_10_LuaObject_push_lua_object(((struct __pyx_obj_4lupa_5_lupa__LuaObject *)__pyx_v_obj)); if (unlikely(__pyx_t_2 == ((int)-1))) __PYX_ERR(0, 401, __pyx_L4_error)

        /* "lupa/_lupa.pyx":402
 *                     # Stack:                            # tbl
 *                     (<_LuaObject>obj).push_lua_object() # tbl, obj
 *                     lua.lua_pushnil(L)                  # tbl, obj, nil       // iterate over obj (-2)             # <<<<<<<<<<<<<<
 *                     while lua.lua_next(L, -2):          # tbl, obj, k, v
 *                         lua.lua_pushvalue(L, -2)        # tbl, obj, k, v, k   // copy key (because
 */
        lua_pushnil(__pyx_v_L);

        /* "lupa/_lupa.pyx":403
 *                     (<_LuaObject>obj).push_lua_object() # tbl, obj
 *                     lua.lua_pushnil(L)                  # tbl, obj, nil       // iterate over obj (-2)
 *                     while lua.lua_next(L, -2):          # tbl, obj, k, v             # <<<<<<<<<<<<<<
 *                         lua.lua_pushvalue(L, -2)        # tbl, obj, k, v, k   // copy key (because
 *                         lua.lua_insert(L, -2)           # tbl, obj, k, k, v   // lua_next needs a key for iteration)
 */
        while (1) {
          __pyx_t_6 = (lua_next(__pyx_v_L, -2) != 0);
          if (!__pyx_t_6) break;

          /* "lupa/_lupa.pyx":404
 *                     lua.lua_pushnil(L)                  # tbl, obj, nil       // iterate over obj (-2)
 *                     while lua.lua_next(L, -2):          # tbl, obj, k, v
 *                         lua.lua_pushvalue(L, -2)        # tbl, obj, k, v, k   // copy key (because             # <<<<<<<<<<<<<<
 *                         lua.lua_insert(L, -2)           # tbl, obj, k, k, v   // lua_next needs a key for iteration)
 *                         lua.lua_settable(L, -5)         # tbl, obj, k         // tbl[k] = v
 */
          lua_pushvalue(__pyx_v_L, -2);

          /* "lupa/_lupa.pyx":405
 *                     while lua.lua_next(L, -2):          # tbl, obj, k, v
 *                         lua.lua_pushvalue(L, -2)        # tbl, obj, k, v, k   // copy key (because
 *                         lua.lua_insert(L, -2)           # tbl, obj, k, k, v   // lua_next needs a key for iteration)             # <<<<<<<<<<<<<<
 *                         lua.lua_settable(L, -5)         # tbl, obj, k         // tbl[k] = v
 *                     lua.lua_pop(L, 1)                   # tbl                 // remove obj from stack
 */
          lua_insert(__pyx_v_L, -2);

          /* "lupa/_lupa.pyx":406
 *                         lua.lua_pushvalue(L, -2)        # tbl, obj, k, v, k   // copy key (because
 *                         lua.lua_insert(L, -2)           # tbl, obj, k, k, v   // lua_next needs a key for iteration)
 *                         lua.lua_settable(L, -5)         # tbl, obj, k         // tbl[k] = v             # <<<<<<<<<<<<<<
 *                     lua.lua_pop(L, 1)                   # tbl                 // remove obj from stack
 * 
 */
          lua_settable(__pyx_v_L, -5);
        }

        /* "lupa/_lupa.pyx":407
 *                         lua.lua_insert(L, -2)           # tbl, obj, k, k, v   // lua_next needs a key for iteration)
 *                         lua.lua_settable(L, -5)         # tbl, obj, k         // tbl[k] = v
 *                     lua.lua_pop(L, 1)                   # tbl                 // remove obj from stack             # <<<<<<<<<<<<<<
 * 
 *                 elif isinstance(obj, Mapping):
 */
        lua_pop(__pyx_v_L, 1);

        /* "lupa/_lupa.pyx":399
 *                         lua.lua_rawset(L, -3)
 * 
 *                 elif isinstance(obj, _LuaTable):             # <<<<<<<<<<<<<<
 *                     # Stack:                            # tbl
 *                     (<_LuaObject>obj).push_lua_object() # tbl, obj
 */
        goto __pyx_L8;
      }

      /* "lupa/_lupa.pyx":409
 *                     lua.lua_pop(L, 1)                   # tbl                 // remove obj from stack
 * 
 *                 elif isinstance(obj, Mapping):             # <<<<<<<<<<<<<<
 *                     for key in obj:
 *                         value = obj[key]
 */
      __pyx_t_5 = __pyx_v_4lupa_5_lupa_Mapping;
      __Pyx_INCREF(__pyx_t_5);
      __pyx_t_6 = PyObject_IsInstance(__pyx_v_obj, __pyx_t_5); if (unlikely(__pyx_t_6 == ((int)-1))) __PYX_ERR(0, 409, __pyx_L4_error)
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __pyx_t_7 = (__pyx_t_6 != 0);
      if (__pyx_t_7) {

        /* "lupa/_lupa.pyx":410
 * 
 *                 elif isinstance(obj, Mapping):
 *                     for key in obj:             # <<<<<<<<<<<<<<
 *                         value = obj[key]
 *                         py_to_lua(self, L, key)
 */
        if (likely(PyList_CheckExact(__pyx_v_obj)) || PyTuple_CheckExact(__pyx_v_obj)) {
          __pyx_t_5 = __pyx_v_obj; __Pyx_INCREF(__pyx_t_5); __pyx_t_9 = 0;
          __pyx_t_13 = NULL;
        } else {
          __pyx_t_9 = -1; __pyx_t_5 = PyObject_GetIter(__pyx_v_obj); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 410, __pyx_L4_error)
          __Pyx_GOTREF(__pyx_t_5);
          __pyx_t_13 = Py_TYPE(__pyx_t_5)->tp_iternext; if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 410, __pyx_L4_error)
        }
        for (;;) {
          if (likely(!__pyx_t_13)) {
            if (likely(PyList_CheckExact(__pyx_t_5))) {
              if (__pyx_t_9 >= PyList_GET_SIZE(__pyx_t_5)) break;
              #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
              __pyx_t_11 = PyList_GET_ITEM(__pyx_t_5, __pyx_t_9); __Pyx_INCREF(__pyx_t_11); __pyx_t_9++; if (unlikely(0 < 0)) __PYX_ERR(0, 410, __pyx_L4_error)
              #else
              __pyx_t_11 = PySequence_ITEM(__pyx_t_5, __pyx_t_9); __pyx_t_9++; if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 410, __pyx_L4_error)
              __Pyx_GOTREF(__pyx_t_11);
              #endif
            } else {
              if (__pyx_t_9 >= PyTuple_GET_SIZE(__pyx_t_5)) break;
              #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
              __pyx_t_11 = PyTuple_GET_ITEM(__pyx_t_5, __pyx_t_9); __Pyx_INCREF(__pyx_t_11); __pyx_t_9++; if (unlikely(0 < 0)) __PYX_ERR(0, 410, __pyx_L4_error)
              #else
              __pyx_t_11 = PySequence_ITEM(__pyx_t_5, __pyx_t_9); __pyx_t_9++; if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 410, __pyx_L4_error)
              __Pyx_GOTREF(__pyx_t_11);
              #endif
            }
          } else {
            __pyx_t_11 = __pyx_t_13(__pyx_t_5);
            if (unlikely(!__pyx_t_11)) {
              PyObject* exc_type = PyErr_Occurred();
              if (exc_type) {
                if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
                else __PYX_ERR(0, 410, __pyx_L4_error)
              }
              break;
            }
            __Pyx_GOTREF(__pyx_t_11);
          }
          __Pyx_XDECREF_SET(__pyx_v_key, __pyx_t_11);
          __pyx_t_11 = 0;

          /* "lupa/_lupa.pyx":411
 *                 elif isinstance(obj, Mapping):
 *                     for key in obj:
 *                         value = obj[key]             # <<<<<<<<<<<<<<
 *                         py_to_lua(self, L, key)
 *                         py_to_lua(self, L, value)
 */
          __pyx_t_11 = __Pyx_PyObject_GetItem(__pyx_v_obj, __pyx_v_key); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 411, __pyx_L4_error)
          __Pyx_GOTREF(__pyx_t_11);
          __Pyx_XDECREF_SET(__pyx_v_value, __pyx_t_11);
          __pyx_t_11 = 0;

          /* "lupa/_lupa.pyx":412
 *                     for key in obj:
 *                         value = obj[key]
 *                         py_to_lua(self, L, key)             # <<<<<<<<<<<<<<
 *                         py_to_lua(self, L, value)
 *                         lua.lua_rawset(L, -3)
 */
          __pyx_t_2 = __pyx_f_4lupa_5_lupa_py_to_lua(__pyx_v_self, __pyx_v_L, __pyx_v_key, NULL); if (unlikely(__pyx_t_2 == ((int)-1))) __PYX_ERR(0, 412, __pyx_L4_error)

          /* "lupa/_lupa.pyx":413
 *                         value = obj[key]
 *                         py_to_lua(self, L, key)
 *                         py_to_lua(self, L, value)             # <<<<<<<<<<<<<<
 *                         lua.lua_rawset(L, -3)
 *                 else:
 */
          __pyx_t_2 = __pyx_f_4lupa_5_lupa_py_to_lua(__pyx_v_self, __pyx_v_L, __pyx_v_value, NULL); if (unlikely(__pyx_t_2 == ((int)-1))) __PYX_ERR(0, 413, __pyx_L4_error)

          /* "lupa/_lupa.pyx":414
 *                         py_to_lua(self, L, key)
 *                         py_to_lua(self, L, value)
 *                         lua.lua_rawset(L, -3)             # <<<<<<<<<<<<<<
 *                 else:
 *                     for arg in obj:
 */
          lua_rawset(__pyx_v_L, -3);

          /* "lupa/_lupa.pyx":410
 * 
 *                 elif isinstance(obj, Mapping):
 *                     for key in obj:             # <<<<<<<<<<<<<<
 *                         value = obj[key]
 *                         py_to_lua(self, L, key)
 */
        }
        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

        /* "lupa/_lupa.pyx":409
 *                     lua.lua_pop(L, 1)                   # tbl                 // remove obj from stack
 * 
 *                 elif isinstance(obj, Mapping):             # <<<<<<<<<<<<<<
 *                     for key in obj:
 *                         value = obj[key]
 */
        goto __pyx_L8;
      }

      /* "lupa/_lupa.pyx":416
 *                         lua.lua_rawset(L, -3)
 *                 else:
 *                     for arg in obj:             # <<<<<<<<<<<<<<
 *                         py_to_lua(self, L, arg)
 *                         lua.lua_rawseti(L, -2, i)
 */
      /*else*/ {
        if (likely(PyList_CheckExact(__pyx_v_obj)) || PyTuple_CheckExact(__pyx_v_obj)) {
          __pyx_t_5 = __pyx_v_obj; __Pyx_INCREF(__pyx_t_5); __pyx_t_9 = 0;
          __pyx_t_13 = NULL;
        } else {
          __pyx_t_9 = -1; __pyx_t_5 = PyObject_GetIter(__pyx_v_obj); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 416, __pyx_L4_error)
          __Pyx_GOTREF(__pyx_t_5);
          __pyx_t_13 = Py_TYPE(__pyx_t_5)->tp_iternext; if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 416, __pyx_L4_error)
        }
        for (;;) {
          if (likely(!__pyx_t_13)) {
            if (likely(PyList_CheckExact(__pyx_t_5))) {
              if (__pyx_t_9 >= PyList_GET_SIZE(__pyx_t_5)) break;
              #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
              __pyx_t_11 = PyList_GET_ITEM(__pyx_t_5, __pyx_t_9); __Pyx_INCREF(__pyx_t_11); __pyx_t_9++; if (unlikely(0 < 0)) __PYX_ERR(0, 416, __pyx_L4_error)
              #else
              __pyx_t_11 = PySequence_ITEM(__pyx_t_5, __pyx_t_9); __pyx_t_9++; if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 416, __pyx_L4_error)
              __Pyx_GOTREF(__pyx_t_11);
              #endif
            } else {
              if (__pyx_t_9 >= PyTuple_GET_SIZE(__pyx_t_5)) break;
              #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
              __pyx_t_11 = PyTuple_GET_ITEM(__pyx_t_5, __pyx_t_9); __Pyx_INCREF(__pyx_t_11); __pyx_t_9++; if (unlikely(0 < 0)) __PYX_ERR(0, 416, __pyx_L4_error)
              #else
              __pyx_t_11 = PySequence_ITEM(__pyx_t_5, __pyx_t_9); __pyx_t_9++; if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 416, __pyx_L4_error)
              __Pyx_GOTREF(__pyx_t_11);
              #endif
            }
          } else {
            __pyx_t_11 = __pyx_t_13(__pyx_t_5);
            if (unlikely(!__pyx_t_11)) {
              PyObject* exc_type = PyErr_Occurred();
              if (exc_type) {
                if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
                else __PYX_ERR(0, 416, __pyx_L4_error)
              }
              break;
            }
            __Pyx_GOTREF(__pyx_t_11);
          }
          __Pyx_XDECREF_SET(__pyx_v_arg, __pyx_t_11);
          __pyx_t_11 = 0;

          /* "lupa/_lupa.pyx":417
 *                 else:
 *                     for arg in obj:
 *                         py_to_lua(self, L, arg)             # <<<<<<<<<<<<<<
 *                         lua.lua_rawseti(L, -2, i)
 *                         i += 1
 */
          __pyx_t_2 = __pyx_f_4lupa_5_lupa_py_to_lua(__pyx_v_self, __pyx_v_L, __pyx_v_arg, NULL); if (unlikely(__pyx_t_2 == ((int)-1))) __PYX_ERR(0, 417, __pyx_L4_error)

          /* "lupa/_lupa.pyx":418
 *                     for arg in obj:
 *                         py_to_lua(self, L, arg)
 *                         lua.lua_rawseti(L, -2, i)             # <<<<<<<<<<<<<<
 *                         i += 1
 *             return py_from_lua(self, L, -1)
 */
          lua_rawseti(__pyx_v_L, -2, __pyx_v_i);

          /* "lupa/_lupa.pyx":419
 *                         py_to_lua(self, L, arg)
 *                         lua.lua_rawseti(L, -2, i)
 *                         i += 1             # <<<<<<<<<<<<<<
 *             return py_from_lua(self, L, -1)
 *         finally:
 */
          __pyx_v_i = (__pyx_v_i + 1);

          /* "lupa/_lupa.pyx":416
 *                         lua.lua_rawset(L, -3)
 *                 else:
 *                     for arg in obj:             # <<<<<<<<<<<<<<
 *                         py_to_lua(self, L, arg)
 *                         lua.lua_rawseti(L, -2, i)
 */
        }
        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      }
      __pyx_L8:;

      /* "lupa/_lupa.pyx":392
 *             lua.lua_newtable(L)
 *             # FIXME: how to check for failure?
 *             for obj in args:             # <<<<<<<<<<<<<<
 *                 if isinstance(obj, dict):
 *                     for key, value in obj.iteritems():
 */
    }
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

    /* "lupa/_lupa.pyx":420
 *                         lua.lua_rawseti(L, -2, i)
 *                         i += 1
 *             return py_from_lua(self, L, -1)             # <<<<<<<<<<<<<<
 *         finally:
 *             lua.lua_settop(L, old_top)
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_3 = __pyx_f_4lupa_5_lupa_py_from_lua(__pyx_v_self, __pyx_v_L, -1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 420, __pyx_L4_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_r = __pyx_t_3;
    __pyx_t_3 = 0;
    goto __pyx_L3_return;
  }

  /* "lupa/_lupa.pyx":422
 *             return py_from_lua(self, L, -1)
 *         finally:
 *             lua.lua_settop(L, old_top)             # <<<<<<<<<<<<<<
 *             unlock_runtime(self)
 * 
 */
  /*finally:*/ {
    __pyx_L4_error:;
    /*exception exit:*/{
      __Pyx_PyThreadState_declare
      __Pyx_PyThreadState_assign
      __pyx_t_15 = 0; __pyx_t_16 = 0; __pyx_t_17 = 0; __pyx_t_18 = 0; __pyx_t_19 = 0; __pyx_t_20 = 0;
      __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
      __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0;
      __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
      if (PY_MAJOR_VERSION >= 3) __Pyx_ExceptionSwap(&__pyx_t_18, &__pyx_t_19, &__pyx_t_20);
      if ((PY_MAJOR_VERSION < 3) || unlikely(__Pyx_GetException(&__pyx_t_15, &__pyx_t_16, &__pyx_t_17) < 0)) __Pyx_ErrFetch(&__pyx_t_15, &__pyx_t_16, &__pyx_t_17);
      __Pyx_XGOTREF(__pyx_t_15);
      __Pyx_XGOTREF(__pyx_t_16);
      __Pyx_XGOTREF(__pyx_t_17);
      __Pyx_XGOTREF(__pyx_t_18);
      __Pyx_XGOTREF(__pyx_t_19);
      __Pyx_XGOTREF(__pyx_t_20);
      __pyx_t_2 = __pyx_lineno; __pyx_t_12 = __pyx_clineno; __pyx_t_14 = __pyx_filename;
      {
        lua_settop(__pyx_v_L, __pyx_v_old_top);

        /* "lupa/_lupa.pyx":423
 *         finally:
 *             lua.lua_settop(L, old_top)
 *             unlock_runtime(self)             # <<<<<<<<<<<<<<
 * 
 *     @cython.final
 */
        __pyx_f_4lupa_5_lupa_unlock_runtime(__pyx_v_self);
      }
      if (PY_MAJOR_VERSION >= 3) {
        __Pyx_XGIVEREF(__pyx_t_18);
        __Pyx_XGIVEREF(__pyx_t_19);
        __Pyx_XGIVEREF(__pyx_t_20);
        __Pyx_ExceptionReset(__pyx_t_18, __pyx_t_19, __pyx_t_20);
      }
      __Pyx_XGIVEREF(__pyx_t_15);
      __Pyx_XGIVEREF(__pyx_t_16);
      __Pyx_XGIVEREF(__pyx_t_17);
      __Pyx_ErrRestore(__pyx_t_15, __pyx_t_16, __pyx_t_17);
      __pyx_t_15 = 0; __pyx_t_16 = 0; __pyx_t_17 = 0; __pyx_t_18 = 0; __pyx_t_19 = 0; __pyx_t_20 = 0;
      __pyx_lineno = __pyx_t_2; __pyx_clineno = __pyx_t_12; __pyx_filename = __pyx_t_14;
      goto __pyx_L1_error;
    }
    __pyx_L3_return: {
      __pyx_t_20 = __pyx_r;
      __pyx_r = 0;

      /* "lupa/_lupa.pyx":422
 *             return py_from_lua(self, L, -1)
 *         finally:
 *             lua.lua_settop(L, old_top)             # <<<<<<<<<<<<<<
 *             unlock_runtime(self)
 * 
 */
      lua_settop(__pyx_v_L, __pyx_v_old_top);

      /* "lupa/_lupa.pyx":423
 *         finally:
 *             lua.lua_settop(L, old_top)
 *             unlock_runtime(self)             # <<<<<<<<<<<<<<
 * 
 *     @cython.final
 */
      __pyx_f_4lupa_5_lupa_unlock_runtime(__pyx_v_self);
      __pyx_r = __pyx_t_20;
      __pyx_t_20 = 0;
      goto __pyx_L0;
    }
  }

  /* "lupa/_lupa.pyx":374
 *         return self.table_from(items, kwargs)
 * 
 *     def table_from(self, *args):             # <<<<<<<<<<<<<<
 *         """Create a new table from Python mapping or iterable.
 * 
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_10);
  __Pyx_XDECREF(__pyx_t_11);
  __Pyx_AddTraceback("lupa._lupa.LuaRuntime.table_from", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_obj);
  __Pyx_XDECREF(__pyx_v_key);
  __Pyx_XDECREF(__pyx_v_value);
  __Pyx_XDECREF(__pyx_v_arg);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lupa/_lupa.pyx":426
 * 
 *     @cython.final
 *     cdef int register_py_object(self, bytes cname, bytes pyname, object obj) except -1:             # <<<<<<<<<<<<<<
 *         cdef lua_State *L = self._state
 *         lua.lua_pushlstring(L, cname, len(cname))
 */

static int __pyx_f_4lupa_5_lupa_10LuaRuntime_register_py_object(struct __pyx_obj_4lupa_5_lupa_LuaRuntime *__pyx_v_self, PyObject *__pyx_v_cname, PyObject *__pyx_v_pyname, PyObject *__pyx_v_obj) {
  lua_State *__pyx_v_L;
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  lua_State *__pyx_t_1;
  char *__pyx_t_2;
  Py_ssize_t __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;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("register_py_object", 0);

  /* "lupa/_lupa.pyx":427
 *     @cython.final
 *     cdef int register_py_object(self, bytes cname, bytes pyname, object obj) except -1:
 *         cdef lua_State *L = self._state             # <<<<<<<<<<<<<<
 *         lua.lua_pushlstring(L, cname, len(cname))
 *         if not py_to_lua_custom(self, L, obj, 0):
 */
  __pyx_t_1 = __pyx_v_self->_state;
  __pyx_v_L = __pyx_t_1;

  /* "lupa/_lupa.pyx":428
 *     cdef int register_py_object(self, bytes cname, bytes pyname, object obj) except -1:
 *         cdef lua_State *L = self._state
 *         lua.lua_pushlstring(L, cname, len(cname))             # <<<<<<<<<<<<<<
 *         if not py_to_lua_custom(self, L, obj, 0):
 *             lua.lua_pop(L, 1)
 */
  if (unlikely(__pyx_v_cname == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "expected bytes, NoneType found");
    __PYX_ERR(0, 428, __pyx_L1_error)
  }
  __pyx_t_2 = __Pyx_PyBytes_AsWritableString(__pyx_v_cname); if (unlikely((!__pyx_t_2) && PyErr_Occurred())) __PYX_ERR(0, 428, __pyx_L1_error)
  if (unlikely(__pyx_v_cname == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()");
    __PYX_ERR(0, 428, __pyx_L1_error)
  }
  __pyx_t_3 = PyBytes_GET_SIZE(__pyx_v_cname); if (unlikely(__pyx_t_3 == ((Py_ssize_t)-1))) __PYX_ERR(0, 428, __pyx_L1_error)
  lua_pushlstring(__pyx_v_L, __pyx_t_2, __pyx_t_3);

  /* "lupa/_lupa.pyx":429
 *         cdef lua_State *L = self._state
 *         lua.lua_pushlstring(L, cname, len(cname))
 *         if not py_to_lua_custom(self, L, obj, 0):             # <<<<<<<<<<<<<<
 *             lua.lua_pop(L, 1)
 *             raise LuaError("failed to convert %s object" % pyname)
 */
  __pyx_t_4 = ((!(__pyx_f_4lupa_5_lupa_py_to_lua_custom(__pyx_v_self, __pyx_v_L, __pyx_v_obj, 0) != 0)) != 0);
  if (unlikely(__pyx_t_4)) {

    /* "lupa/_lupa.pyx":430
 *         lua.lua_pushlstring(L, cname, len(cname))
 *         if not py_to_lua_custom(self, L, obj, 0):
 *             lua.lua_pop(L, 1)             # <<<<<<<<<<<<<<
 *             raise LuaError("failed to convert %s object" % pyname)
 *         lua.lua_pushlstring(L, pyname, len(pyname))
 */
    lua_pop(__pyx_v_L, 1);

    /* "lupa/_lupa.pyx":431
 *         if not py_to_lua_custom(self, L, obj, 0):
 *             lua.lua_pop(L, 1)
 *             raise LuaError("failed to convert %s object" % pyname)             # <<<<<<<<<<<<<<
 *         lua.lua_pushlstring(L, pyname, len(pyname))
 *         lua.lua_pushvalue(L, -2)
 */
    __Pyx_GetModuleGlobalName(__pyx_t_6, __pyx_n_s_LuaError); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 431, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_t_7 = __Pyx_PyString_Format(__pyx_kp_s_failed_to_convert_s_object, __pyx_v_pyname); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 431, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    __pyx_t_8 = NULL;
    if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_6))) {
      __pyx_t_8 = PyMethod_GET_SELF(__pyx_t_6);
      if (likely(__pyx_t_8)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6);
        __Pyx_INCREF(__pyx_t_8);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_6, function);
      }
    }
    __pyx_t_5 = (__pyx_t_8) ? __Pyx_PyObject_Call2Args(__pyx_t_6, __pyx_t_8, __pyx_t_7) : __Pyx_PyObject_CallOneArg(__pyx_t_6, __pyx_t_7);
    __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 431, __pyx_L1_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, 431, __pyx_L1_error)

    /* "lupa/_lupa.pyx":429
 *         cdef lua_State *L = self._state
 *         lua.lua_pushlstring(L, cname, len(cname))
 *         if not py_to_lua_custom(self, L, obj, 0):             # <<<<<<<<<<<<<<
 *             lua.lua_pop(L, 1)
 *             raise LuaError("failed to convert %s object" % pyname)
 */
  }

  /* "lupa/_lupa.pyx":432
 *             lua.lua_pop(L, 1)
 *             raise LuaError("failed to convert %s object" % pyname)
 *         lua.lua_pushlstring(L, pyname, len(pyname))             # <<<<<<<<<<<<<<
 *         lua.lua_pushvalue(L, -2)
 *         lua.lua_rawset(L, -5)
 */
  if (unlikely(__pyx_v_pyname == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "expected bytes, NoneType found");
    __PYX_ERR(0, 432, __pyx_L1_error)
  }
  __pyx_t_2 = __Pyx_PyBytes_AsWritableString(__pyx_v_pyname); if (unlikely((!__pyx_t_2) && PyErr_Occurred())) __PYX_ERR(0, 432, __pyx_L1_error)
  if (unlikely(__pyx_v_pyname == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()");
    __PYX_ERR(0, 432, __pyx_L1_error)
  }
  __pyx_t_3 = PyBytes_GET_SIZE(__pyx_v_pyname); if (unlikely(__pyx_t_3 == ((Py_ssize_t)-1))) __PYX_ERR(0, 432, __pyx_L1_error)
  lua_pushlstring(__pyx_v_L, __pyx_t_2, __pyx_t_3);

  /* "lupa/_lupa.pyx":433
 *             raise LuaError("failed to convert %s object" % pyname)
 *         lua.lua_pushlstring(L, pyname, len(pyname))
 *         lua.lua_pushvalue(L, -2)             # <<<<<<<<<<<<<<
 *         lua.lua_rawset(L, -5)
 *         lua.lua_rawset(L, lua.LUA_REGISTRYINDEX)
 */
  lua_pushvalue(__pyx_v_L, -2);

  /* "lupa/_lupa.pyx":434
 *         lua.lua_pushlstring(L, pyname, len(pyname))
 *         lua.lua_pushvalue(L, -2)
 *         lua.lua_rawset(L, -5)             # <<<<<<<<<<<<<<
 *         lua.lua_rawset(L, lua.LUA_REGISTRYINDEX)
 *         return 0
 */
  lua_rawset(__pyx_v_L, -5);

  /* "lupa/_lupa.pyx":435
 *         lua.lua_pushvalue(L, -2)
 *         lua.lua_rawset(L, -5)
 *         lua.lua_rawset(L, lua.LUA_REGISTRYINDEX)             # <<<<<<<<<<<<<<
 *         return 0
 * 
 */
  lua_rawset(__pyx_v_L, LUA_REGISTRYINDEX);

  /* "lupa/_lupa.pyx":436
 *         lua.lua_rawset(L, -5)
 *         lua.lua_rawset(L, lua.LUA_REGISTRYINDEX)
 *         return 0             # <<<<<<<<<<<<<<
 * 
 *     @cython.final
 */
  __pyx_r = 0;
  goto __pyx_L0;

  /* "lupa/_lupa.pyx":426
 * 
 *     @cython.final
 *     cdef int register_py_object(self, bytes cname, bytes pyname, object obj) except -1:             # <<<<<<<<<<<<<<
 *         cdef lua_State *L = self._state
 *         lua.lua_pushlstring(L, cname, len(cname))
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_AddTraceback("lupa._lupa.LuaRuntime.register_py_object", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lupa/_lupa.pyx":439
 * 
 *     @cython.final
 *     cdef int init_python_lib(self, bint register_eval, bint register_builtins) except -1:             # <<<<<<<<<<<<<<
 *         cdef lua_State *L = self._state
 * 
 */

static int __pyx_f_4lupa_5_lupa_10LuaRuntime_init_python_lib(struct __pyx_obj_4lupa_5_lupa_LuaRuntime *__pyx_v_self, int __pyx_v_register_eval, int __pyx_v_register_builtins) {
  lua_State *__pyx_v_L;
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  lua_State *__pyx_t_1;
  int __pyx_t_2;
  int __pyx_t_3;
  PyObject *__pyx_t_4 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("init_python_lib", 0);

  /* "lupa/_lupa.pyx":440
 *     @cython.final
 *     cdef int init_python_lib(self, bint register_eval, bint register_builtins) except -1:
 *         cdef lua_State *L = self._state             # <<<<<<<<<<<<<<
 * 
 *         # create 'python' lib and register our own object metatable
 */
  __pyx_t_1 = __pyx_v_self->_state;
  __pyx_v_L = __pyx_t_1;

  /* "lupa/_lupa.pyx":443
 * 
 *         # create 'python' lib and register our own object metatable
 *         luaL_openlib(L, "python", py_lib, 0)             # <<<<<<<<<<<<<<
 *         lua.luaL_newmetatable(L, POBJECT)
 *         luaL_openlib(L, NULL, py_object_lib, 0)
 */
  __pyx_f_4lupa_5_lupa_luaL_openlib(__pyx_v_L, ((char const *)"python"), __pyx_v_4lupa_5_lupa_py_lib, 0);

  /* "lupa/_lupa.pyx":444
 *         # create 'python' lib and register our own object metatable
 *         luaL_openlib(L, "python", py_lib, 0)
 *         lua.luaL_newmetatable(L, POBJECT)             # <<<<<<<<<<<<<<
 *         luaL_openlib(L, NULL, py_object_lib, 0)
 *         lua.lua_pop(L, 1)
 */
  (void)(luaL_newmetatable(__pyx_v_L, ((char *)"POBJECT")));

  /* "lupa/_lupa.pyx":445
 *         luaL_openlib(L, "python", py_lib, 0)
 *         lua.luaL_newmetatable(L, POBJECT)
 *         luaL_openlib(L, NULL, py_object_lib, 0)             # <<<<<<<<<<<<<<
 *         lua.lua_pop(L, 1)
 * 
 */
  __pyx_f_4lupa_5_lupa_luaL_openlib(__pyx_v_L, NULL, __pyx_v_4lupa_5_lupa_py_object_lib, 0);

  /* "lupa/_lupa.pyx":446
 *         lua.luaL_newmetatable(L, POBJECT)
 *         luaL_openlib(L, NULL, py_object_lib, 0)
 *         lua.lua_pop(L, 1)             # <<<<<<<<<<<<<<
 * 
 *         # register global names in the module
 */
  lua_pop(__pyx_v_L, 1);

  /* "lupa/_lupa.pyx":449
 * 
 *         # register global names in the module
 *         self.register_py_object(b'Py_None',  b'none', None)             # <<<<<<<<<<<<<<
 *         if register_eval:
 *             self.register_py_object(b'eval',     b'eval', eval)
 */
  __pyx_t_2 = __pyx_f_4lupa_5_lupa_10LuaRuntime_register_py_object(__pyx_v_self, __pyx_n_b_Py_None, __pyx_n_b_none, Py_None); if (unlikely(__pyx_t_2 == ((int)-1))) __PYX_ERR(0, 449, __pyx_L1_error)

  /* "lupa/_lupa.pyx":450
 *         # register global names in the module
 *         self.register_py_object(b'Py_None',  b'none', None)
 *         if register_eval:             # <<<<<<<<<<<<<<
 *             self.register_py_object(b'eval',     b'eval', eval)
 *         if register_builtins:
 */
  __pyx_t_3 = (__pyx_v_register_eval != 0);
  if (__pyx_t_3) {

    /* "lupa/_lupa.pyx":451
 *         self.register_py_object(b'Py_None',  b'none', None)
 *         if register_eval:
 *             self.register_py_object(b'eval',     b'eval', eval)             # <<<<<<<<<<<<<<
 *         if register_builtins:
 *             self.register_py_object(b'builtins', b'builtins', builtins)
 */
    __pyx_t_2 = __pyx_f_4lupa_5_lupa_10LuaRuntime_register_py_object(__pyx_v_self, __pyx_n_b_eval, __pyx_n_b_eval, __pyx_builtin_eval); if (unlikely(__pyx_t_2 == ((int)-1))) __PYX_ERR(0, 451, __pyx_L1_error)

    /* "lupa/_lupa.pyx":450
 *         # register global names in the module
 *         self.register_py_object(b'Py_None',  b'none', None)
 *         if register_eval:             # <<<<<<<<<<<<<<
 *             self.register_py_object(b'eval',     b'eval', eval)
 *         if register_builtins:
 */
  }

  /* "lupa/_lupa.pyx":452
 *         if register_eval:
 *             self.register_py_object(b'eval',     b'eval', eval)
 *         if register_builtins:             # <<<<<<<<<<<<<<
 *             self.register_py_object(b'builtins', b'builtins', builtins)
 * 
 */
  __pyx_t_3 = (__pyx_v_register_builtins != 0);
  if (__pyx_t_3) {

    /* "lupa/_lupa.pyx":453
 *             self.register_py_object(b'eval',     b'eval', eval)
 *         if register_builtins:
 *             self.register_py_object(b'builtins', b'builtins', builtins)             # <<<<<<<<<<<<<<
 * 
 *         return 0  # nothing left to return on the stack
 */
    __pyx_t_4 = __pyx_v_4lupa_5_lupa_builtins;
    __Pyx_INCREF(__pyx_t_4);
    __pyx_t_2 = __pyx_f_4lupa_5_lupa_10LuaRuntime_register_py_object(__pyx_v_self, __pyx_n_b_builtins, __pyx_n_b_builtins, __pyx_t_4); if (unlikely(__pyx_t_2 == ((int)-1))) __PYX_ERR(0, 453, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

    /* "lupa/_lupa.pyx":452
 *         if register_eval:
 *             self.register_py_object(b'eval',     b'eval', eval)
 *         if register_builtins:             # <<<<<<<<<<<<<<
 *             self.register_py_object(b'builtins', b'builtins', builtins)
 * 
 */
  }

  /* "lupa/_lupa.pyx":455
 *             self.register_py_object(b'builtins', b'builtins', builtins)
 * 
 *         return 0  # nothing left to return on the stack             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_r = 0;
  goto __pyx_L0;

  /* "lupa/_lupa.pyx":439
 * 
 *     @cython.final
 *     cdef int init_python_lib(self, bint register_eval, bint register_builtins) except -1:             # <<<<<<<<<<<<<<
 *         cdef lua_State *L = self._state
 * 
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_AddTraceback("lupa._lupa.LuaRuntime.init_python_lib", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  __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_4lupa_5_lupa_10LuaRuntime_19__reduce_cython__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static char __pyx_doc_4lupa_5_lupa_10LuaRuntime_18__reduce_cython__[] = "LuaRuntime.__reduce_cython__(self)";
static PyMethodDef __pyx_mdef_4lupa_5_lupa_10LuaRuntime_19__reduce_cython__ = {"__reduce_cython__", (PyCFunction)__pyx_pw_4lupa_5_lupa_10LuaRuntime_19__reduce_cython__, METH_NOARGS, __pyx_doc_4lupa_5_lupa_10LuaRuntime_18__reduce_cython__};
static PyObject *__pyx_pw_4lupa_5_lupa_10LuaRuntime_19__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_4lupa_5_lupa_10LuaRuntime_18__reduce_cython__(((struct __pyx_obj_4lupa_5_lupa_LuaRuntime *)__pyx_v_self));

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

static PyObject *__pyx_pf_4lupa_5_lupa_10LuaRuntime_18__reduce_cython__(CYTHON_UNUSED struct __pyx_obj_4lupa_5_lupa_LuaRuntime *__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__8, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 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(2, 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("lupa._lupa.LuaRuntime.__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_4lupa_5_lupa_10LuaRuntime_21__setstate_cython__(PyObject *__pyx_v_self, PyObject *__pyx_v___pyx_state); /*proto*/
static char __pyx_doc_4lupa_5_lupa_10LuaRuntime_20__setstate_cython__[] = "LuaRuntime.__setstate_cython__(self, __pyx_state)";
static PyMethodDef __pyx_mdef_4lupa_5_lupa_10LuaRuntime_21__setstate_cython__ = {"__setstate_cython__", (PyCFunction)__pyx_pw_4lupa_5_lupa_10LuaRuntime_21__setstate_cython__, METH_O, __pyx_doc_4lupa_5_lupa_10LuaRuntime_20__setstate_cython__};
static PyObject *__pyx_pw_4lupa_5_lupa_10LuaRuntime_21__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_4lupa_5_lupa_10LuaRuntime_20__setstate_cython__(((struct __pyx_obj_4lupa_5_lupa_LuaRuntime *)__pyx_v_self), ((PyObject *)__pyx_v___pyx_state));

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

static PyObject *__pyx_pf_4lupa_5_lupa_10LuaRuntime_20__setstate_cython__(CYTHON_UNUSED struct __pyx_obj_4lupa_5_lupa_LuaRuntime *__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__9, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 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(2, 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("lupa._lupa.LuaRuntime.__setstate_cython__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lupa/_lupa.pyx":462
 * # from Lua scripts
 * 
 * def unpacks_lua_table(func):             # <<<<<<<<<<<<<<
 *     """
 *     A decorator to make the decorated function receive kwargs
 */

/* Python wrapper */
static PyObject *__pyx_pw_4lupa_5_lupa_3unpacks_lua_table(PyObject *__pyx_self, PyObject *__pyx_v_func); /*proto*/
static char __pyx_doc_4lupa_5_lupa_2unpacks_lua_table[] = "unpacks_lua_table(func)\n\n    A decorator to make the decorated function receive kwargs\n    when it is called from Lua with a single Lua table argument.\n\n    Python functions wrapped in this decorator can be called from Lua code\n    as ``func(foo, bar)``, ``func{foo=foo, bar=bar}`` and ``func{foo, bar=bar}``.\n\n    See also: http://lua-users.org/wiki/NamedParameters\n\n    WARNING: avoid using this decorator for functions where the\n    first argument can be a Lua table.\n\n    WARNING: be careful with ``nil`` values.  Depending on the context,\n    passing ``nil`` as a parameter can mean either \"omit a parameter\"\n    or \"pass None\".  This even depends on the Lua version.  It is\n    possible to use ``python.none`` instead of ``nil`` to pass None values\n    robustly.\n    ";
static PyMethodDef __pyx_mdef_4lupa_5_lupa_3unpacks_lua_table = {"unpacks_lua_table", (PyCFunction)__pyx_pw_4lupa_5_lupa_3unpacks_lua_table, METH_O, __pyx_doc_4lupa_5_lupa_2unpacks_lua_table};
static PyObject *__pyx_pw_4lupa_5_lupa_3unpacks_lua_table(PyObject *__pyx_self, PyObject *__pyx_v_func) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("unpacks_lua_table (wrapper)", 0);
  __pyx_r = __pyx_pf_4lupa_5_lupa_2unpacks_lua_table(__pyx_self, ((PyObject *)__pyx_v_func));

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

/* "lupa/_lupa.pyx":482
 *     """
 *     @wraps(func)
 *     def wrapper(*args):             # <<<<<<<<<<<<<<
 *         args, kwargs = _fix_args_kwargs(args)
 *         return func(*args, **kwargs)
 */

/* Python wrapper */
static PyObject *__pyx_pw_4lupa_5_lupa_17unpacks_lua_table_1wrapper(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyMethodDef __pyx_mdef_4lupa_5_lupa_17unpacks_lua_table_1wrapper = {"wrapper", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_4lupa_5_lupa_17unpacks_lua_table_1wrapper, METH_VARARGS|METH_KEYWORDS, 0};
static PyObject *__pyx_pw_4lupa_5_lupa_17unpacks_lua_table_1wrapper(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_args = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("wrapper (wrapper)", 0);
  if (unlikely(__pyx_kwds) && unlikely(PyDict_Size(__pyx_kwds) > 0) && unlikely(!__Pyx_CheckKeywordStrings(__pyx_kwds, "wrapper", 0))) return NULL;
  __Pyx_INCREF(__pyx_args);
  __pyx_v_args = __pyx_args;
  __pyx_r = __pyx_pf_4lupa_5_lupa_17unpacks_lua_table_wrapper(__pyx_self, __pyx_v_args);

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

static PyObject *__pyx_pf_4lupa_5_lupa_17unpacks_lua_table_wrapper(PyObject *__pyx_self, PyObject *__pyx_v_args) {
  struct __pyx_obj_4lupa_5_lupa___pyx_scope_struct__unpacks_lua_table *__pyx_cur_scope;
  struct __pyx_obj_4lupa_5_lupa___pyx_scope_struct__unpacks_lua_table *__pyx_outer_scope;
  PyObject *__pyx_v_kwargs = NULL;
  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("wrapper", 0);
  __pyx_outer_scope = (struct __pyx_obj_4lupa_5_lupa___pyx_scope_struct__unpacks_lua_table *) __Pyx_CyFunction_GetClosure(__pyx_self);
  __pyx_cur_scope = __pyx_outer_scope;
  __Pyx_INCREF(__pyx_v_args);

  /* "lupa/_lupa.pyx":483
 *     @wraps(func)
 *     def wrapper(*args):
 *         args, kwargs = _fix_args_kwargs(args)             # <<<<<<<<<<<<<<
 *         return func(*args, **kwargs)
 *     return wrapper
 */
  if (!(likely(PyTuple_CheckExact(__pyx_v_args))||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "tuple", Py_TYPE(__pyx_v_args)->tp_name), 0))) __PYX_ERR(0, 483, __pyx_L1_error)
  __pyx_t_1 = __pyx_f_4lupa_5_lupa__fix_args_kwargs(((PyObject*)__pyx_v_args)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 483, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (likely(__pyx_t_1 != Py_None)) {
    PyObject* sequence = __pyx_t_1;
    Py_ssize_t size = __Pyx_PySequence_SIZE(sequence);
    if (unlikely(size != 2)) {
      if (size > 2) __Pyx_RaiseTooManyValuesError(2);
      else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
      __PYX_ERR(0, 483, __pyx_L1_error)
    }
    #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
    __pyx_t_2 = PyTuple_GET_ITEM(sequence, 0); 
    __pyx_t_3 = PyTuple_GET_ITEM(sequence, 1); 
    __Pyx_INCREF(__pyx_t_2);
    __Pyx_INCREF(__pyx_t_3);
    #else
    __pyx_t_2 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 483, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_3 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 483, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    #endif
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  } else {
    __Pyx_RaiseNoneNotIterableError(); __PYX_ERR(0, 483, __pyx_L1_error)
  }
  __Pyx_DECREF_SET(__pyx_v_args, __pyx_t_2);
  __pyx_t_2 = 0;
  __pyx_v_kwargs = __pyx_t_3;
  __pyx_t_3 = 0;

  /* "lupa/_lupa.pyx":484
 *     def wrapper(*args):
 *         args, kwargs = _fix_args_kwargs(args)
 *         return func(*args, **kwargs)             # <<<<<<<<<<<<<<
 *     return wrapper
 * 
 */
  __Pyx_XDECREF(__pyx_r);
  if (unlikely(!__pyx_cur_scope->__pyx_v_func)) { __Pyx_RaiseClosureNameError("func"); __PYX_ERR(0, 484, __pyx_L1_error) }
  __pyx_t_1 = __Pyx_PySequence_Tuple(__pyx_v_args); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 484, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (unlikely(__pyx_v_kwargs == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "argument after ** must be a mapping, not NoneType");
    __PYX_ERR(0, 484, __pyx_L1_error)
  }
  if (likely(PyDict_CheckExact(__pyx_v_kwargs))) {
    __pyx_t_3 = PyDict_Copy(__pyx_v_kwargs); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 484, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
  } else {
    __pyx_t_3 = PyObject_CallFunctionObjArgs((PyObject*)&PyDict_Type, __pyx_v_kwargs, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 484, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
  }
  __pyx_t_2 = __Pyx_PyObject_Call(__pyx_cur_scope->__pyx_v_func, __pyx_t_1, __pyx_t_3); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 484, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_r = __pyx_t_2;
  __pyx_t_2 = 0;
  goto __pyx_L0;

  /* "lupa/_lupa.pyx":482
 *     """
 *     @wraps(func)
 *     def wrapper(*args):             # <<<<<<<<<<<<<<
 *         args, kwargs = _fix_args_kwargs(args)
 *         return func(*args, **kwargs)
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("lupa._lupa.unpacks_lua_table.wrapper", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_args);
  __Pyx_XDECREF(__pyx_v_kwargs);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lupa/_lupa.pyx":462
 * # from Lua scripts
 * 
 * def unpacks_lua_table(func):             # <<<<<<<<<<<<<<
 *     """
 *     A decorator to make the decorated function receive kwargs
 */

static PyObject *__pyx_pf_4lupa_5_lupa_2unpacks_lua_table(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_func) {
  struct __pyx_obj_4lupa_5_lupa___pyx_scope_struct__unpacks_lua_table *__pyx_cur_scope;
  PyObject *__pyx_v_wrapper = 0;
  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("unpacks_lua_table", 0);
  __pyx_cur_scope = (struct __pyx_obj_4lupa_5_lupa___pyx_scope_struct__unpacks_lua_table *)__pyx_tp_new_4lupa_5_lupa___pyx_scope_struct__unpacks_lua_table(__pyx_ptype_4lupa_5_lupa___pyx_scope_struct__unpacks_lua_table, __pyx_empty_tuple, NULL);
  if (unlikely(!__pyx_cur_scope)) {
    __pyx_cur_scope = ((struct __pyx_obj_4lupa_5_lupa___pyx_scope_struct__unpacks_lua_table *)Py_None);
    __Pyx_INCREF(Py_None);
    __PYX_ERR(0, 462, __pyx_L1_error)
  } else {
    __Pyx_GOTREF(__pyx_cur_scope);
  }
  __pyx_cur_scope->__pyx_v_func = __pyx_v_func;
  __Pyx_INCREF(__pyx_cur_scope->__pyx_v_func);
  __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_func);

  /* "lupa/_lupa.pyx":481
 *     robustly.
 *     """
 *     @wraps(func)             # <<<<<<<<<<<<<<
 *     def wrapper(*args):
 *         args, kwargs = _fix_args_kwargs(args)
 */
  __Pyx_INCREF(__pyx_v_4lupa_5_lupa_wraps);
  __pyx_t_3 = __pyx_v_4lupa_5_lupa_wraps; __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_cur_scope->__pyx_v_func) : __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_cur_scope->__pyx_v_func);
  __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
  if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 481, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

  /* "lupa/_lupa.pyx":482
 *     """
 *     @wraps(func)
 *     def wrapper(*args):             # <<<<<<<<<<<<<<
 *         args, kwargs = _fix_args_kwargs(args)
 *         return func(*args, **kwargs)
 */
  __pyx_t_3 = __Pyx_CyFunction_New(&__pyx_mdef_4lupa_5_lupa_17unpacks_lua_table_1wrapper, 0, __pyx_n_s_unpacks_lua_table_locals_wrapper, ((PyObject*)__pyx_cur_scope), __pyx_n_s_lupa__lupa, __pyx_d, ((PyObject *)__pyx_codeobj__11)); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 482, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = NULL;
  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_2))) {
    __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_2);
    if (likely(__pyx_t_4)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_4);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_2, function);
    }
  }
  __pyx_t_1 = (__pyx_t_4) ? __Pyx_PyObject_Call2Args(__pyx_t_2, __pyx_t_4, __pyx_t_3) : __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 481, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_v_wrapper = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "lupa/_lupa.pyx":485
 *         args, kwargs = _fix_args_kwargs(args)
 *         return func(*args, **kwargs)
 *     return wrapper             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v_wrapper);
  __pyx_r = __pyx_v_wrapper;
  goto __pyx_L0;

  /* "lupa/_lupa.pyx":462
 * # from Lua scripts
 * 
 * def unpacks_lua_table(func):             # <<<<<<<<<<<<<<
 *     """
 *     A decorator to make the decorated function receive kwargs
 */

  /* 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("lupa._lupa.unpacks_lua_table", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_wrapper);
  __Pyx_DECREF(((PyObject *)__pyx_cur_scope));
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lupa/_lupa.pyx":488
 * 
 * 
 * def unpacks_lua_table_method(meth):             # <<<<<<<<<<<<<<
 *     """
 *     This is :func:`unpacks_lua_table` for methods
 */

/* Python wrapper */
static PyObject *__pyx_pw_4lupa_5_lupa_5unpacks_lua_table_method(PyObject *__pyx_self, PyObject *__pyx_v_meth); /*proto*/
static char __pyx_doc_4lupa_5_lupa_4unpacks_lua_table_method[] = "unpacks_lua_table_method(meth)\n\n    This is :func:`unpacks_lua_table` for methods\n    (i.e. it knows about the 'self' argument).\n    ";
static PyMethodDef __pyx_mdef_4lupa_5_lupa_5unpacks_lua_table_method = {"unpacks_lua_table_method", (PyCFunction)__pyx_pw_4lupa_5_lupa_5unpacks_lua_table_method, METH_O, __pyx_doc_4lupa_5_lupa_4unpacks_lua_table_method};
static PyObject *__pyx_pw_4lupa_5_lupa_5unpacks_lua_table_method(PyObject *__pyx_self, PyObject *__pyx_v_meth) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("unpacks_lua_table_method (wrapper)", 0);
  __pyx_r = __pyx_pf_4lupa_5_lupa_4unpacks_lua_table_method(__pyx_self, ((PyObject *)__pyx_v_meth));

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

/* "lupa/_lupa.pyx":494
 *     """
 *     @wraps(meth)
 *     def wrapper(self, *args):             # <<<<<<<<<<<<<<
 *         args, kwargs = _fix_args_kwargs(args)
 *         return meth(self, *args, **kwargs)
 */

/* Python wrapper */
static PyObject *__pyx_pw_4lupa_5_lupa_24unpacks_lua_table_method_1wrapper(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyMethodDef __pyx_mdef_4lupa_5_lupa_24unpacks_lua_table_method_1wrapper = {"wrapper", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_4lupa_5_lupa_24unpacks_lua_table_method_1wrapper, METH_VARARGS|METH_KEYWORDS, 0};
static PyObject *__pyx_pw_4lupa_5_lupa_24unpacks_lua_table_method_1wrapper(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_self = 0;
  PyObject *__pyx_v_args = 0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("wrapper (wrapper)", 0);
  if (PyTuple_GET_SIZE(__pyx_args) > 1) {
    __pyx_v_args = PyTuple_GetSlice(__pyx_args, 1, PyTuple_GET_SIZE(__pyx_args));
    if (unlikely(!__pyx_v_args)) {
      __Pyx_RefNannyFinishContext();
      return NULL;
    }
    __Pyx_GOTREF(__pyx_v_args);
  } else {
    __pyx_v_args = __pyx_empty_tuple; __Pyx_INCREF(__pyx_empty_tuple);
  }
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_self,0};
    PyObject* values[1] = {0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        default:
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
      }
      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;
      }
      if (unlikely(kw_args > 0)) {
        const Py_ssize_t used_pos_args = (pos_args < 1) ? pos_args : 1;
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, used_pos_args, "wrapper") < 0)) __PYX_ERR(0, 494, __pyx_L3_error)
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) < 1) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
    }
    __pyx_v_self = values[0];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("wrapper", 0, 1, 1, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 494, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_DECREF(__pyx_v_args); __pyx_v_args = 0;
  __Pyx_AddTraceback("lupa._lupa.unpacks_lua_table_method.wrapper", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_4lupa_5_lupa_24unpacks_lua_table_method_wrapper(__pyx_self, __pyx_v_self, __pyx_v_args);

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

static PyObject *__pyx_pf_4lupa_5_lupa_24unpacks_lua_table_method_wrapper(PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_args) {
  struct __pyx_obj_4lupa_5_lupa___pyx_scope_struct_1_unpacks_lua_table_method *__pyx_cur_scope;
  struct __pyx_obj_4lupa_5_lupa___pyx_scope_struct_1_unpacks_lua_table_method *__pyx_outer_scope;
  PyObject *__pyx_v_kwargs = NULL;
  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("wrapper", 0);
  __pyx_outer_scope = (struct __pyx_obj_4lupa_5_lupa___pyx_scope_struct_1_unpacks_lua_table_method *) __Pyx_CyFunction_GetClosure(__pyx_self);
  __pyx_cur_scope = __pyx_outer_scope;
  __Pyx_INCREF(__pyx_v_args);

  /* "lupa/_lupa.pyx":495
 *     @wraps(meth)
 *     def wrapper(self, *args):
 *         args, kwargs = _fix_args_kwargs(args)             # <<<<<<<<<<<<<<
 *         return meth(self, *args, **kwargs)
 *     return wrapper
 */
  if (!(likely(PyTuple_CheckExact(__pyx_v_args))||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "tuple", Py_TYPE(__pyx_v_args)->tp_name), 0))) __PYX_ERR(0, 495, __pyx_L1_error)
  __pyx_t_1 = __pyx_f_4lupa_5_lupa__fix_args_kwargs(((PyObject*)__pyx_v_args)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 495, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (likely(__pyx_t_1 != Py_None)) {
    PyObject* sequence = __pyx_t_1;
    Py_ssize_t size = __Pyx_PySequence_SIZE(sequence);
    if (unlikely(size != 2)) {
      if (size > 2) __Pyx_RaiseTooManyValuesError(2);
      else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
      __PYX_ERR(0, 495, __pyx_L1_error)
    }
    #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
    __pyx_t_2 = PyTuple_GET_ITEM(sequence, 0); 
    __pyx_t_3 = PyTuple_GET_ITEM(sequence, 1); 
    __Pyx_INCREF(__pyx_t_2);
    __Pyx_INCREF(__pyx_t_3);
    #else
    __pyx_t_2 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 495, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_3 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 495, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    #endif
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  } else {
    __Pyx_RaiseNoneNotIterableError(); __PYX_ERR(0, 495, __pyx_L1_error)
  }
  __Pyx_DECREF_SET(__pyx_v_args, __pyx_t_2);
  __pyx_t_2 = 0;
  __pyx_v_kwargs = __pyx_t_3;
  __pyx_t_3 = 0;

  /* "lupa/_lupa.pyx":496
 *     def wrapper(self, *args):
 *         args, kwargs = _fix_args_kwargs(args)
 *         return meth(self, *args, **kwargs)             # <<<<<<<<<<<<<<
 *     return wrapper
 * 
 */
  __Pyx_XDECREF(__pyx_r);
  if (unlikely(!__pyx_cur_scope->__pyx_v_meth)) { __Pyx_RaiseClosureNameError("meth"); __PYX_ERR(0, 496, __pyx_L1_error) }
  __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 496, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_INCREF(__pyx_v_self);
  __Pyx_GIVEREF(__pyx_v_self);
  PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_self);
  __pyx_t_3 = __Pyx_PySequence_Tuple(__pyx_v_args); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 496, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_2 = PyNumber_Add(__pyx_t_1, __pyx_t_3); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 496, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (unlikely(__pyx_v_kwargs == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "argument after ** must be a mapping, not NoneType");
    __PYX_ERR(0, 496, __pyx_L1_error)
  }
  if (likely(PyDict_CheckExact(__pyx_v_kwargs))) {
    __pyx_t_3 = PyDict_Copy(__pyx_v_kwargs); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 496, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
  } else {
    __pyx_t_3 = PyObject_CallFunctionObjArgs((PyObject*)&PyDict_Type, __pyx_v_kwargs, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 496, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
  }
  __pyx_t_1 = __Pyx_PyObject_Call(__pyx_cur_scope->__pyx_v_meth, __pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 496, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "lupa/_lupa.pyx":494
 *     """
 *     @wraps(meth)
 *     def wrapper(self, *args):             # <<<<<<<<<<<<<<
 *         args, kwargs = _fix_args_kwargs(args)
 *         return meth(self, *args, **kwargs)
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("lupa._lupa.unpacks_lua_table_method.wrapper", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_args);
  __Pyx_XDECREF(__pyx_v_kwargs);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lupa/_lupa.pyx":488
 * 
 * 
 * def unpacks_lua_table_method(meth):             # <<<<<<<<<<<<<<
 *     """
 *     This is :func:`unpacks_lua_table` for methods
 */

static PyObject *__pyx_pf_4lupa_5_lupa_4unpacks_lua_table_method(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_meth) {
  struct __pyx_obj_4lupa_5_lupa___pyx_scope_struct_1_unpacks_lua_table_method *__pyx_cur_scope;
  PyObject *__pyx_v_wrapper = 0;
  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("unpacks_lua_table_method", 0);
  __pyx_cur_scope = (struct __pyx_obj_4lupa_5_lupa___pyx_scope_struct_1_unpacks_lua_table_method *)__pyx_tp_new_4lupa_5_lupa___pyx_scope_struct_1_unpacks_lua_table_method(__pyx_ptype_4lupa_5_lupa___pyx_scope_struct_1_unpacks_lua_table_method, __pyx_empty_tuple, NULL);
  if (unlikely(!__pyx_cur_scope)) {
    __pyx_cur_scope = ((struct __pyx_obj_4lupa_5_lupa___pyx_scope_struct_1_unpacks_lua_table_method *)Py_None);
    __Pyx_INCREF(Py_None);
    __PYX_ERR(0, 488, __pyx_L1_error)
  } else {
    __Pyx_GOTREF(__pyx_cur_scope);
  }
  __pyx_cur_scope->__pyx_v_meth = __pyx_v_meth;
  __Pyx_INCREF(__pyx_cur_scope->__pyx_v_meth);
  __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_meth);

  /* "lupa/_lupa.pyx":493
 *     (i.e. it knows about the 'self' argument).
 *     """
 *     @wraps(meth)             # <<<<<<<<<<<<<<
 *     def wrapper(self, *args):
 *         args, kwargs = _fix_args_kwargs(args)
 */
  __Pyx_INCREF(__pyx_v_4lupa_5_lupa_wraps);
  __pyx_t_3 = __pyx_v_4lupa_5_lupa_wraps; __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_cur_scope->__pyx_v_meth) : __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_cur_scope->__pyx_v_meth);
  __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
  if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 493, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

  /* "lupa/_lupa.pyx":494
 *     """
 *     @wraps(meth)
 *     def wrapper(self, *args):             # <<<<<<<<<<<<<<
 *         args, kwargs = _fix_args_kwargs(args)
 *         return meth(self, *args, **kwargs)
 */
  __pyx_t_3 = __Pyx_CyFunction_New(&__pyx_mdef_4lupa_5_lupa_24unpacks_lua_table_method_1wrapper, 0, __pyx_n_s_unpacks_lua_table_method_locals, ((PyObject*)__pyx_cur_scope), __pyx_n_s_lupa__lupa, __pyx_d, ((PyObject *)__pyx_codeobj__13)); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 494, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = NULL;
  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_2))) {
    __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_2);
    if (likely(__pyx_t_4)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_4);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_2, function);
    }
  }
  __pyx_t_1 = (__pyx_t_4) ? __Pyx_PyObject_Call2Args(__pyx_t_2, __pyx_t_4, __pyx_t_3) : __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 493, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_v_wrapper = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "lupa/_lupa.pyx":497
 *         args, kwargs = _fix_args_kwargs(args)
 *         return meth(self, *args, **kwargs)
 *     return wrapper             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v_wrapper);
  __pyx_r = __pyx_v_wrapper;
  goto __pyx_L0;

  /* "lupa/_lupa.pyx":488
 * 
 * 
 * def unpacks_lua_table_method(meth):             # <<<<<<<<<<<<<<
 *     """
 *     This is :func:`unpacks_lua_table` for methods
 */

  /* 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("lupa._lupa.unpacks_lua_table_method", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_wrapper);
  __Pyx_DECREF(((PyObject *)__pyx_cur_scope));
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lupa/_lupa.pyx":500
 * 
 * 
 * cdef tuple _fix_args_kwargs(tuple args):             # <<<<<<<<<<<<<<
 *     """
 *     Extract named arguments from args passed to a Python function by Lua
 */

static PyObject *__pyx_f_4lupa_5_lupa__fix_args_kwargs(PyObject *__pyx_v_args) {
  PyObject *__pyx_v_arg = NULL;
  struct __pyx_obj_4lupa_5_lupa__LuaTable *__pyx_v_table = NULL;
  PyObject *__pyx_v_encoding = NULL;
  PyObject *__pyx_v_new_args = NULL;
  PyObject *__pyx_v_new_kwargs = NULL;
  size_t __pyx_7genexpr__pyx_v_key;
  PyObject *__pyx_8genexpr1__pyx_v_key = NULL;
  PyObject *__pyx_8genexpr1__pyx_v_value = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  Py_ssize_t __pyx_t_1;
  int __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  int __pyx_t_5;
  size_t __pyx_t_6;
  size_t __pyx_t_7;
  size_t __pyx_t_8;
  PyObject *__pyx_t_9 = NULL;
  PyObject *(*__pyx_t_10)(PyObject *);
  PyObject *__pyx_t_11 = NULL;
  PyObject *__pyx_t_12 = NULL;
  PyObject *__pyx_t_13 = NULL;
  PyObject *(*__pyx_t_14)(PyObject *);
  int __pyx_t_15;
  char const *__pyx_t_16;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("_fix_args_kwargs", 0);

  /* "lupa/_lupa.pyx":506
 *     it is a table.
 *     """
 *     if len(args) != 1:             # <<<<<<<<<<<<<<
 *         return args, {}
 * 
 */
  if (unlikely(__pyx_v_args == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()");
    __PYX_ERR(0, 506, __pyx_L1_error)
  }
  __pyx_t_1 = PyTuple_GET_SIZE(__pyx_v_args); if (unlikely(__pyx_t_1 == ((Py_ssize_t)-1))) __PYX_ERR(0, 506, __pyx_L1_error)
  __pyx_t_2 = ((__pyx_t_1 != 1) != 0);
  if (__pyx_t_2) {

    /* "lupa/_lupa.pyx":507
 *     """
 *     if len(args) != 1:
 *         return args, {}             # <<<<<<<<<<<<<<
 * 
 *     arg = args[0]
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_3 = __Pyx_PyDict_NewPresized(0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 507, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_4 = PyTuple_New(2); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 507, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_INCREF(__pyx_v_args);
    __Pyx_GIVEREF(__pyx_v_args);
    PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_v_args);
    __Pyx_GIVEREF(__pyx_t_3);
    PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_t_3);
    __pyx_t_3 = 0;
    __pyx_r = ((PyObject*)__pyx_t_4);
    __pyx_t_4 = 0;
    goto __pyx_L0;

    /* "lupa/_lupa.pyx":506
 *     it is a table.
 *     """
 *     if len(args) != 1:             # <<<<<<<<<<<<<<
 *         return args, {}
 * 
 */
  }

  /* "lupa/_lupa.pyx":509
 *         return args, {}
 * 
 *     arg = args[0]             # <<<<<<<<<<<<<<
 *     if not isinstance(arg, _LuaTable):
 *         return args, {}
 */
  if (unlikely(__pyx_v_args == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(0, 509, __pyx_L1_error)
  }
  __pyx_t_4 = __Pyx_GetItemInt_Tuple(__pyx_v_args, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 509, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_v_arg = __pyx_t_4;
  __pyx_t_4 = 0;

  /* "lupa/_lupa.pyx":510
 * 
 *     arg = args[0]
 *     if not isinstance(arg, _LuaTable):             # <<<<<<<<<<<<<<
 *         return args, {}
 * 
 */
  __pyx_t_2 = __Pyx_TypeCheck(__pyx_v_arg, __pyx_ptype_4lupa_5_lupa__LuaTable); 
  __pyx_t_5 = ((!(__pyx_t_2 != 0)) != 0);
  if (__pyx_t_5) {

    /* "lupa/_lupa.pyx":511
 *     arg = args[0]
 *     if not isinstance(arg, _LuaTable):
 *         return args, {}             # <<<<<<<<<<<<<<
 * 
 *     table = <_LuaTable>arg
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_4 = __Pyx_PyDict_NewPresized(0); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 511, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 511, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_INCREF(__pyx_v_args);
    __Pyx_GIVEREF(__pyx_v_args);
    PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_v_args);
    __Pyx_GIVEREF(__pyx_t_4);
    PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_t_4);
    __pyx_t_4 = 0;
    __pyx_r = ((PyObject*)__pyx_t_3);
    __pyx_t_3 = 0;
    goto __pyx_L0;

    /* "lupa/_lupa.pyx":510
 * 
 *     arg = args[0]
 *     if not isinstance(arg, _LuaTable):             # <<<<<<<<<<<<<<
 *         return args, {}
 * 
 */
  }

  /* "lupa/_lupa.pyx":513
 *         return args, {}
 * 
 *     table = <_LuaTable>arg             # <<<<<<<<<<<<<<
 *     encoding = table._runtime._source_encoding
 * 
 */
  __pyx_t_3 = __pyx_v_arg;
  __Pyx_INCREF(__pyx_t_3);
  __pyx_v_table = ((struct __pyx_obj_4lupa_5_lupa__LuaTable *)__pyx_t_3);
  __pyx_t_3 = 0;

  /* "lupa/_lupa.pyx":514
 * 
 *     table = <_LuaTable>arg
 *     encoding = table._runtime._source_encoding             # <<<<<<<<<<<<<<
 * 
 *     # arguments with keys from 1 to #tbl are passed as positional
 */
  __pyx_t_3 = __pyx_v_table->__pyx_base._runtime->_source_encoding;
  __Pyx_INCREF(__pyx_t_3);
  __pyx_v_encoding = ((PyObject*)__pyx_t_3);
  __pyx_t_3 = 0;

  /* "lupa/_lupa.pyx":517
 * 
 *     # arguments with keys from 1 to #tbl are passed as positional
 *     new_args = [             # <<<<<<<<<<<<<<
 *         table._getitem(key, is_attr_access=False)
 *         for key in range(1, table._len() + 1)
 */
  { /* enter inner scope */
    __pyx_t_3 = PyList_New(0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 517, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);

    /* "lupa/_lupa.pyx":519
 *     new_args = [
 *         table._getitem(key, is_attr_access=False)
 *         for key in range(1, table._len() + 1)             # <<<<<<<<<<<<<<
 *     ]
 * 
 */
    __pyx_t_6 = (__pyx_f_4lupa_5_lupa_10_LuaObject__len(((struct __pyx_obj_4lupa_5_lupa__LuaObject *)__pyx_v_table)) + 1);
    __pyx_t_7 = __pyx_t_6;
    for (__pyx_t_8 = 1; __pyx_t_8 < __pyx_t_7; __pyx_t_8+=1) {
      __pyx_7genexpr__pyx_v_key = __pyx_t_8;

      /* "lupa/_lupa.pyx":518
 *     # arguments with keys from 1 to #tbl are passed as positional
 *     new_args = [
 *         table._getitem(key, is_attr_access=False)             # <<<<<<<<<<<<<<
 *         for key in range(1, table._len() + 1)
 *     ]
 */
      __pyx_t_4 = __Pyx_PyInt_FromSize_t(__pyx_7genexpr__pyx_v_key); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 518, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_t_9 = __pyx_f_4lupa_5_lupa_10_LuaObject__getitem(((struct __pyx_obj_4lupa_5_lupa__LuaObject *)__pyx_v_table), __pyx_t_4, 0); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 518, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_9);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      if (unlikely(__Pyx_ListComp_Append(__pyx_t_3, (PyObject*)__pyx_t_9))) __PYX_ERR(0, 517, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
    }
  } /* exit inner scope */
  __pyx_v_new_args = ((PyObject*)__pyx_t_3);
  __pyx_t_3 = 0;

  /* "lupa/_lupa.pyx":523
 * 
 *     # arguments with non-integer keys are passed as named
 *     new_kwargs = {             # <<<<<<<<<<<<<<
 *         (<bytes>key).decode(encoding) if not IS_PY2 and isinstance(key, bytes) else key: value
 *         for key, value in _LuaIter(table, ITEMS)
 */
  { /* enter inner scope */
    __pyx_t_3 = PyDict_New(); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 523, __pyx_L9_error)
    __Pyx_GOTREF(__pyx_t_3);

    /* "lupa/_lupa.pyx":525
 *     new_kwargs = {
 *         (<bytes>key).decode(encoding) if not IS_PY2 and isinstance(key, bytes) else key: value
 *         for key, value in _LuaIter(table, ITEMS)             # <<<<<<<<<<<<<<
 *         if not isinstance(key, (int, long))
 *     }
 */
    __pyx_t_9 = __Pyx_PyInt_From_int(__pyx_e_4lupa_5_lupa_ITEMS); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 525, __pyx_L9_error)
    __Pyx_GOTREF(__pyx_t_9);
    __pyx_t_4 = PyTuple_New(2); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 525, __pyx_L9_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_INCREF(((PyObject *)__pyx_v_table));
    __Pyx_GIVEREF(((PyObject *)__pyx_v_table));
    PyTuple_SET_ITEM(__pyx_t_4, 0, ((PyObject *)__pyx_v_table));
    __Pyx_GIVEREF(__pyx_t_9);
    PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_t_9);
    __pyx_t_9 = 0;
    __pyx_t_9 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_4lupa_5_lupa__LuaIter), __pyx_t_4, NULL); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 525, __pyx_L9_error)
    __Pyx_GOTREF(__pyx_t_9);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    if (likely(PyList_CheckExact(__pyx_t_9)) || PyTuple_CheckExact(__pyx_t_9)) {
      __pyx_t_4 = __pyx_t_9; __Pyx_INCREF(__pyx_t_4); __pyx_t_1 = 0;
      __pyx_t_10 = NULL;
    } else {
      __pyx_t_1 = -1; __pyx_t_4 = PyObject_GetIter(__pyx_t_9); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 525, __pyx_L9_error)
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_t_10 = Py_TYPE(__pyx_t_4)->tp_iternext; if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 525, __pyx_L9_error)
    }
    __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
    for (;;) {
      if (likely(!__pyx_t_10)) {
        if (likely(PyList_CheckExact(__pyx_t_4))) {
          if (__pyx_t_1 >= PyList_GET_SIZE(__pyx_t_4)) break;
          #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
          __pyx_t_9 = PyList_GET_ITEM(__pyx_t_4, __pyx_t_1); __Pyx_INCREF(__pyx_t_9); __pyx_t_1++; if (unlikely(0 < 0)) __PYX_ERR(0, 525, __pyx_L9_error)
          #else
          __pyx_t_9 = PySequence_ITEM(__pyx_t_4, __pyx_t_1); __pyx_t_1++; if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 525, __pyx_L9_error)
          __Pyx_GOTREF(__pyx_t_9);
          #endif
        } else {
          if (__pyx_t_1 >= PyTuple_GET_SIZE(__pyx_t_4)) break;
          #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
          __pyx_t_9 = PyTuple_GET_ITEM(__pyx_t_4, __pyx_t_1); __Pyx_INCREF(__pyx_t_9); __pyx_t_1++; if (unlikely(0 < 0)) __PYX_ERR(0, 525, __pyx_L9_error)
          #else
          __pyx_t_9 = PySequence_ITEM(__pyx_t_4, __pyx_t_1); __pyx_t_1++; if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 525, __pyx_L9_error)
          __Pyx_GOTREF(__pyx_t_9);
          #endif
        }
      } else {
        __pyx_t_9 = __pyx_t_10(__pyx_t_4);
        if (unlikely(!__pyx_t_9)) {
          PyObject* exc_type = PyErr_Occurred();
          if (exc_type) {
            if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
            else __PYX_ERR(0, 525, __pyx_L9_error)
          }
          break;
        }
        __Pyx_GOTREF(__pyx_t_9);
      }
      if ((likely(PyTuple_CheckExact(__pyx_t_9))) || (PyList_CheckExact(__pyx_t_9))) {
        PyObject* sequence = __pyx_t_9;
        Py_ssize_t size = __Pyx_PySequence_SIZE(sequence);
        if (unlikely(size != 2)) {
          if (size > 2) __Pyx_RaiseTooManyValuesError(2);
          else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
          __PYX_ERR(0, 525, __pyx_L9_error)
        }
        #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
        if (likely(PyTuple_CheckExact(sequence))) {
          __pyx_t_11 = PyTuple_GET_ITEM(sequence, 0); 
          __pyx_t_12 = PyTuple_GET_ITEM(sequence, 1); 
        } else {
          __pyx_t_11 = PyList_GET_ITEM(sequence, 0); 
          __pyx_t_12 = PyList_GET_ITEM(sequence, 1); 
        }
        __Pyx_INCREF(__pyx_t_11);
        __Pyx_INCREF(__pyx_t_12);
        #else
        __pyx_t_11 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 525, __pyx_L9_error)
        __Pyx_GOTREF(__pyx_t_11);
        __pyx_t_12 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 525, __pyx_L9_error)
        __Pyx_GOTREF(__pyx_t_12);
        #endif
        __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
      } else {
        Py_ssize_t index = -1;
        __pyx_t_13 = PyObject_GetIter(__pyx_t_9); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 525, __pyx_L9_error)
        __Pyx_GOTREF(__pyx_t_13);
        __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
        __pyx_t_14 = Py_TYPE(__pyx_t_13)->tp_iternext;
        index = 0; __pyx_t_11 = __pyx_t_14(__pyx_t_13); if (unlikely(!__pyx_t_11)) goto __pyx_L12_unpacking_failed;
        __Pyx_GOTREF(__pyx_t_11);
        index = 1; __pyx_t_12 = __pyx_t_14(__pyx_t_13); if (unlikely(!__pyx_t_12)) goto __pyx_L12_unpacking_failed;
        __Pyx_GOTREF(__pyx_t_12);
        if (__Pyx_IternextUnpackEndCheck(__pyx_t_14(__pyx_t_13), 2) < 0) __PYX_ERR(0, 525, __pyx_L9_error)
        __pyx_t_14 = NULL;
        __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
        goto __pyx_L13_unpacking_done;
        __pyx_L12_unpacking_failed:;
        __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
        __pyx_t_14 = NULL;
        if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
        __PYX_ERR(0, 525, __pyx_L9_error)
        __pyx_L13_unpacking_done:;
      }
      __Pyx_XDECREF_SET(__pyx_8genexpr1__pyx_v_key, __pyx_t_11);
      __pyx_t_11 = 0;
      __Pyx_XDECREF_SET(__pyx_8genexpr1__pyx_v_value, __pyx_t_12);
      __pyx_t_12 = 0;

      /* "lupa/_lupa.pyx":526
 *         (<bytes>key).decode(encoding) if not IS_PY2 and isinstance(key, bytes) else key: value
 *         for key, value in _LuaIter(table, ITEMS)
 *         if not isinstance(key, (int, long))             # <<<<<<<<<<<<<<
 *     }
 *     return new_args, new_kwargs
 */
      __pyx_t_2 = PyInt_Check(__pyx_8genexpr1__pyx_v_key); 
      __pyx_t_15 = (__pyx_t_2 != 0);
      if (!__pyx_t_15) {
      } else {
        __pyx_t_5 = __pyx_t_15;
        goto __pyx_L15_bool_binop_done;
      }
      __pyx_t_15 = PyLong_Check(__pyx_8genexpr1__pyx_v_key); 
      __pyx_t_2 = (__pyx_t_15 != 0);
      __pyx_t_5 = __pyx_t_2;
      __pyx_L15_bool_binop_done:;
      __pyx_t_2 = ((!(__pyx_t_5 != 0)) != 0);
      if (__pyx_t_2) {

        /* "lupa/_lupa.pyx":524
 *     # arguments with non-integer keys are passed as named
 *     new_kwargs = {
 *         (<bytes>key).decode(encoding) if not IS_PY2 and isinstance(key, bytes) else key: value             # <<<<<<<<<<<<<<
 *         for key, value in _LuaIter(table, ITEMS)
 *         if not isinstance(key, (int, long))
 */
        __pyx_t_5 = ((!(IS_PY2 != 0)) != 0);
        if (__pyx_t_5) {
        } else {
          __pyx_t_2 = __pyx_t_5;
          goto __pyx_L17_bool_binop_done;
        }
        __pyx_t_5 = PyBytes_Check(__pyx_8genexpr1__pyx_v_key); 
        __pyx_t_15 = (__pyx_t_5 != 0);
        __pyx_t_2 = __pyx_t_15;
        __pyx_L17_bool_binop_done:;
        if (__pyx_t_2) {
          if (unlikely(__pyx_8genexpr1__pyx_v_key == Py_None)) {
            PyErr_Format(PyExc_AttributeError, "'NoneType' object has no attribute '%.30s'", "decode");
            __PYX_ERR(0, 524, __pyx_L9_error)
          }
          if (unlikely(__pyx_v_encoding == Py_None)) {
            PyErr_SetString(PyExc_TypeError, "expected bytes, NoneType found");
            __PYX_ERR(0, 524, __pyx_L9_error)
          }
          __pyx_t_16 = __Pyx_PyBytes_AsString(__pyx_v_encoding); if (unlikely((!__pyx_t_16) && PyErr_Occurred())) __PYX_ERR(0, 524, __pyx_L9_error)
          __pyx_t_12 = __Pyx_decode_bytes(((PyObject*)__pyx_8genexpr1__pyx_v_key), 0, PY_SSIZE_T_MAX, __pyx_t_16, NULL, NULL); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 524, __pyx_L9_error)
          __Pyx_GOTREF(__pyx_t_12);
          __pyx_t_9 = __pyx_t_12;
          __pyx_t_12 = 0;
        } else {
          __Pyx_INCREF(__pyx_8genexpr1__pyx_v_key);
          __pyx_t_9 = __pyx_8genexpr1__pyx_v_key;
        }
        if (unlikely(PyDict_SetItem(__pyx_t_3, (PyObject*)__pyx_t_9, (PyObject*)__pyx_8genexpr1__pyx_v_value))) __PYX_ERR(0, 524, __pyx_L9_error)
        __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;

        /* "lupa/_lupa.pyx":526
 *         (<bytes>key).decode(encoding) if not IS_PY2 and isinstance(key, bytes) else key: value
 *         for key, value in _LuaIter(table, ITEMS)
 *         if not isinstance(key, (int, long))             # <<<<<<<<<<<<<<
 *     }
 *     return new_args, new_kwargs
 */
      }

      /* "lupa/_lupa.pyx":525
 *     new_kwargs = {
 *         (<bytes>key).decode(encoding) if not IS_PY2 and isinstance(key, bytes) else key: value
 *         for key, value in _LuaIter(table, ITEMS)             # <<<<<<<<<<<<<<
 *         if not isinstance(key, (int, long))
 *     }
 */
    }
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_XDECREF(__pyx_8genexpr1__pyx_v_key); __pyx_8genexpr1__pyx_v_key = 0;
    __Pyx_XDECREF(__pyx_8genexpr1__pyx_v_value); __pyx_8genexpr1__pyx_v_value = 0;
    goto __pyx_L19_exit_scope;
    __pyx_L9_error:;
    __Pyx_XDECREF(__pyx_8genexpr1__pyx_v_key); __pyx_8genexpr1__pyx_v_key = 0;
    __Pyx_XDECREF(__pyx_8genexpr1__pyx_v_value); __pyx_8genexpr1__pyx_v_value = 0;
    goto __pyx_L1_error;
    __pyx_L19_exit_scope:;
  } /* exit inner scope */
  __pyx_v_new_kwargs = ((PyObject*)__pyx_t_3);
  __pyx_t_3 = 0;

  /* "lupa/_lupa.pyx":528
 *         if not isinstance(key, (int, long))
 *     }
 *     return new_args, new_kwargs             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 528, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_INCREF(__pyx_v_new_args);
  __Pyx_GIVEREF(__pyx_v_new_args);
  PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_v_new_args);
  __Pyx_INCREF(__pyx_v_new_kwargs);
  __Pyx_GIVEREF(__pyx_v_new_kwargs);
  PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_v_new_kwargs);
  __pyx_r = ((PyObject*)__pyx_t_3);
  __pyx_t_3 = 0;
  goto __pyx_L0;

  /* "lupa/_lupa.pyx":500
 * 
 * 
 * cdef tuple _fix_args_kwargs(tuple args):             # <<<<<<<<<<<<<<
 *     """
 *     Extract named arguments from args passed to a Python function by Lua
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_9);
  __Pyx_XDECREF(__pyx_t_11);
  __Pyx_XDECREF(__pyx_t_12);
  __Pyx_XDECREF(__pyx_t_13);
  __Pyx_AddTraceback("lupa._lupa._fix_args_kwargs", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_arg);
  __Pyx_XDECREF((PyObject *)__pyx_v_table);
  __Pyx_XDECREF(__pyx_v_encoding);
  __Pyx_XDECREF(__pyx_v_new_args);
  __Pyx_XDECREF(__pyx_v_new_kwargs);
  __Pyx_XDECREF(__pyx_8genexpr1__pyx_v_key);
  __Pyx_XDECREF(__pyx_8genexpr1__pyx_v_value);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lupa/_lupa.pyx":534
 * # fast, re-entrant runtime locking
 * 
 * cdef inline int lock_runtime(LuaRuntime runtime) except -1:             # <<<<<<<<<<<<<<
 *     if not lock_lock(runtime._lock, pythread.PyThread_get_thread_ident(), True):
 *         raise LuaError("Failed to acquire thread lock")
 */

static CYTHON_INLINE int __pyx_f_4lupa_5_lupa_lock_runtime(struct __pyx_obj_4lupa_5_lupa_LuaRuntime *__pyx_v_runtime) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  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("lock_runtime", 0);

  /* "lupa/_lupa.pyx":535
 * 
 * cdef inline int lock_runtime(LuaRuntime runtime) except -1:
 *     if not lock_lock(runtime._lock, pythread.PyThread_get_thread_ident(), True):             # <<<<<<<<<<<<<<
 *         raise LuaError("Failed to acquire thread lock")
 *     return 0
 */
  __pyx_t_1 = ((PyObject *)__pyx_v_runtime->_lock);
  __Pyx_INCREF(__pyx_t_1);
  __pyx_t_2 = ((!(__pyx_f_4lupa_5_lupa_lock_lock(((struct __pyx_obj_4lupa_5_lupa_FastRLock *)__pyx_t_1), PyThread_get_thread_ident(), 1) != 0)) != 0);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (unlikely(__pyx_t_2)) {

    /* "lupa/_lupa.pyx":536
 * cdef inline int lock_runtime(LuaRuntime runtime) except -1:
 *     if not lock_lock(runtime._lock, pythread.PyThread_get_thread_ident(), True):
 *         raise LuaError("Failed to acquire thread lock")             # <<<<<<<<<<<<<<
 *     return 0
 * 
 */
    __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_LuaError); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 536, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __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_kp_s_Failed_to_acquire_thread_lock) : __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_kp_s_Failed_to_acquire_thread_lock);
    __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
    if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 536, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_Raise(__pyx_t_1, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __PYX_ERR(0, 536, __pyx_L1_error)

    /* "lupa/_lupa.pyx":535
 * 
 * cdef inline int lock_runtime(LuaRuntime runtime) except -1:
 *     if not lock_lock(runtime._lock, pythread.PyThread_get_thread_ident(), True):             # <<<<<<<<<<<<<<
 *         raise LuaError("Failed to acquire thread lock")
 *     return 0
 */
  }

  /* "lupa/_lupa.pyx":537
 *     if not lock_lock(runtime._lock, pythread.PyThread_get_thread_ident(), True):
 *         raise LuaError("Failed to acquire thread lock")
 *     return 0             # <<<<<<<<<<<<<<
 * 
 * cdef inline void unlock_runtime(LuaRuntime runtime) nogil:
 */
  __pyx_r = 0;
  goto __pyx_L0;

  /* "lupa/_lupa.pyx":534
 * # fast, re-entrant runtime locking
 * 
 * cdef inline int lock_runtime(LuaRuntime runtime) except -1:             # <<<<<<<<<<<<<<
 *     if not lock_lock(runtime._lock, pythread.PyThread_get_thread_ident(), True):
 *         raise LuaError("Failed to acquire thread lock")
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_AddTraceback("lupa._lupa.lock_runtime", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lupa/_lupa.pyx":539
 *     return 0
 * 
 * cdef inline void unlock_runtime(LuaRuntime runtime) nogil:             # <<<<<<<<<<<<<<
 *     unlock_lock(runtime._lock)
 * 
 */

static CYTHON_INLINE void __pyx_f_4lupa_5_lupa_unlock_runtime(struct __pyx_obj_4lupa_5_lupa_LuaRuntime *__pyx_v_runtime) {

  /* "lupa/_lupa.pyx":540
 * 
 * cdef inline void unlock_runtime(LuaRuntime runtime) nogil:
 *     unlock_lock(runtime._lock)             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_f_4lupa_5_lupa_unlock_lock(__pyx_v_runtime->_lock);

  /* "lupa/_lupa.pyx":539
 *     return 0
 * 
 * cdef inline void unlock_runtime(LuaRuntime runtime) nogil:             # <<<<<<<<<<<<<<
 *     unlock_lock(runtime._lock)
 * 
 */

  /* function exit code */
}

/* "lupa/_lupa.pyx":556
 *     cdef int _ref
 * 
 *     def __init__(self):             # <<<<<<<<<<<<<<
 *         raise TypeError("Type cannot be instantiated manually")
 * 
 */

/* Python wrapper */
static int __pyx_pw_4lupa_5_lupa_10_LuaObject_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static int __pyx_pw_4lupa_5_lupa_10_LuaObject_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__init__ (wrapper)", 0);
  if (unlikely(PyTuple_GET_SIZE(__pyx_args) > 0)) {
    __Pyx_RaiseArgtupleInvalid("__init__", 1, 0, 0, PyTuple_GET_SIZE(__pyx_args)); return -1;}
  if (unlikely(__pyx_kwds) && unlikely(PyDict_Size(__pyx_kwds) > 0) && unlikely(!__Pyx_CheckKeywordStrings(__pyx_kwds, "__init__", 0))) return -1;
  __pyx_r = __pyx_pf_4lupa_5_lupa_10_LuaObject___init__(((struct __pyx_obj_4lupa_5_lupa__LuaObject *)__pyx_v_self));

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

static int __pyx_pf_4lupa_5_lupa_10_LuaObject___init__(CYTHON_UNUSED struct __pyx_obj_4lupa_5_lupa__LuaObject *__pyx_v_self) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__init__", 0);

  /* "lupa/_lupa.pyx":557
 * 
 *     def __init__(self):
 *         raise TypeError("Type cannot be instantiated manually")             # <<<<<<<<<<<<<<
 * 
 *     def __dealloc__(self):
 */
  __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__14, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 557, __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, 557, __pyx_L1_error)

  /* "lupa/_lupa.pyx":556
 *     cdef int _ref
 * 
 *     def __init__(self):             # <<<<<<<<<<<<<<
 *         raise TypeError("Type cannot be instantiated manually")
 * 
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("lupa._lupa._LuaObject.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lupa/_lupa.pyx":559
 *         raise TypeError("Type cannot be instantiated manually")
 * 
 *     def __dealloc__(self):             # <<<<<<<<<<<<<<
 *         if self._runtime is None:
 *             return
 */

/* Python wrapper */
static void __pyx_pw_4lupa_5_lupa_10_LuaObject_3__dealloc__(PyObject *__pyx_v_self); /*proto*/
static void __pyx_pw_4lupa_5_lupa_10_LuaObject_3__dealloc__(PyObject *__pyx_v_self) {
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__dealloc__ (wrapper)", 0);
  __pyx_pf_4lupa_5_lupa_10_LuaObject_2__dealloc__(((struct __pyx_obj_4lupa_5_lupa__LuaObject *)__pyx_v_self));

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

static void __pyx_pf_4lupa_5_lupa_10_LuaObject_2__dealloc__(struct __pyx_obj_4lupa_5_lupa__LuaObject *__pyx_v_self) {
  lua_State *__pyx_v_L;
  int __pyx_v_locked;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  int __pyx_t_2;
  lua_State *__pyx_t_3;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  PyObject *__pyx_t_7 = NULL;
  int __pyx_t_8;
  PyObject *__pyx_t_9 = NULL;
  PyObject *__pyx_t_10 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__dealloc__", 0);

  /* "lupa/_lupa.pyx":560
 * 
 *     def __dealloc__(self):
 *         if self._runtime is None:             # <<<<<<<<<<<<<<
 *             return
 *         cdef lua_State* L = self._state
 */
  __pyx_t_1 = (((PyObject *)__pyx_v_self->_runtime) == Py_None);
  __pyx_t_2 = (__pyx_t_1 != 0);
  if (__pyx_t_2) {

    /* "lupa/_lupa.pyx":561
 *     def __dealloc__(self):
 *         if self._runtime is None:
 *             return             # <<<<<<<<<<<<<<
 *         cdef lua_State* L = self._state
 *         try:
 */
    goto __pyx_L0;

    /* "lupa/_lupa.pyx":560
 * 
 *     def __dealloc__(self):
 *         if self._runtime is None:             # <<<<<<<<<<<<<<
 *             return
 *         cdef lua_State* L = self._state
 */
  }

  /* "lupa/_lupa.pyx":562
 *         if self._runtime is None:
 *             return
 *         cdef lua_State* L = self._state             # <<<<<<<<<<<<<<
 *         try:
 *             lock_runtime(self._runtime)
 */
  __pyx_t_3 = __pyx_v_self->_state;
  __pyx_v_L = __pyx_t_3;

  /* "lupa/_lupa.pyx":563
 *             return
 *         cdef lua_State* L = self._state
 *         try:             # <<<<<<<<<<<<<<
 *             lock_runtime(self._runtime)
 *             locked = True
 */
  {
    __Pyx_PyThreadState_declare
    __Pyx_PyThreadState_assign
    __Pyx_ExceptionSave(&__pyx_t_4, &__pyx_t_5, &__pyx_t_6);
    __Pyx_XGOTREF(__pyx_t_4);
    __Pyx_XGOTREF(__pyx_t_5);
    __Pyx_XGOTREF(__pyx_t_6);
    /*try:*/ {

      /* "lupa/_lupa.pyx":564
 *         cdef lua_State* L = self._state
 *         try:
 *             lock_runtime(self._runtime)             # <<<<<<<<<<<<<<
 *             locked = True
 *         except:
 */
      __pyx_t_7 = ((PyObject *)__pyx_v_self->_runtime);
      __Pyx_INCREF(__pyx_t_7);
      __pyx_t_8 = __pyx_f_4lupa_5_lupa_lock_runtime(((struct __pyx_obj_4lupa_5_lupa_LuaRuntime *)__pyx_t_7)); if (unlikely(__pyx_t_8 == ((int)-1))) __PYX_ERR(0, 564, __pyx_L4_error)
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;

      /* "lupa/_lupa.pyx":565
 *         try:
 *             lock_runtime(self._runtime)
 *             locked = True             # <<<<<<<<<<<<<<
 *         except:
 *             locked = False
 */
      __pyx_v_locked = 1;

      /* "lupa/_lupa.pyx":563
 *             return
 *         cdef lua_State* L = self._state
 *         try:             # <<<<<<<<<<<<<<
 *             lock_runtime(self._runtime)
 *             locked = True
 */
    }
    __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
    goto __pyx_L9_try_end;
    __pyx_L4_error:;
    __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;

    /* "lupa/_lupa.pyx":566
 *             lock_runtime(self._runtime)
 *             locked = True
 *         except:             # <<<<<<<<<<<<<<
 *             locked = False
 *         lua.luaL_unref(L, lua.LUA_REGISTRYINDEX, self._ref)
 */
    /*except:*/ {
      __Pyx_AddTraceback("lupa._lupa._LuaObject.__dealloc__", __pyx_clineno, __pyx_lineno, __pyx_filename);
      if (__Pyx_GetException(&__pyx_t_7, &__pyx_t_9, &__pyx_t_10) < 0) __PYX_ERR(0, 566, __pyx_L6_except_error)
      __Pyx_GOTREF(__pyx_t_7);
      __Pyx_GOTREF(__pyx_t_9);
      __Pyx_GOTREF(__pyx_t_10);

      /* "lupa/_lupa.pyx":567
 *             locked = True
 *         except:
 *             locked = False             # <<<<<<<<<<<<<<
 *         lua.luaL_unref(L, lua.LUA_REGISTRYINDEX, self._ref)
 *         if locked:
 */
      __pyx_v_locked = 0;
      __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
      __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
      __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
      goto __pyx_L5_exception_handled;
    }
    __pyx_L6_except_error:;

    /* "lupa/_lupa.pyx":563
 *             return
 *         cdef lua_State* L = self._state
 *         try:             # <<<<<<<<<<<<<<
 *             lock_runtime(self._runtime)
 *             locked = True
 */
    __Pyx_XGIVEREF(__pyx_t_4);
    __Pyx_XGIVEREF(__pyx_t_5);
    __Pyx_XGIVEREF(__pyx_t_6);
    __Pyx_ExceptionReset(__pyx_t_4, __pyx_t_5, __pyx_t_6);
    goto __pyx_L1_error;
    __pyx_L5_exception_handled:;
    __Pyx_XGIVEREF(__pyx_t_4);
    __Pyx_XGIVEREF(__pyx_t_5);
    __Pyx_XGIVEREF(__pyx_t_6);
    __Pyx_ExceptionReset(__pyx_t_4, __pyx_t_5, __pyx_t_6);
    __pyx_L9_try_end:;
  }

  /* "lupa/_lupa.pyx":568
 *         except:
 *             locked = False
 *         lua.luaL_unref(L, lua.LUA_REGISTRYINDEX, self._ref)             # <<<<<<<<<<<<<<
 *         if locked:
 *             unlock_runtime(self._runtime)
 */
  luaL_unref(__pyx_v_L, LUA_REGISTRYINDEX, __pyx_v_self->_ref);

  /* "lupa/_lupa.pyx":569
 *             locked = False
 *         lua.luaL_unref(L, lua.LUA_REGISTRYINDEX, self._ref)
 *         if locked:             # <<<<<<<<<<<<<<
 *             unlock_runtime(self._runtime)
 * 
 */
  __pyx_t_2 = (__pyx_v_locked != 0);
  if (__pyx_t_2) {

    /* "lupa/_lupa.pyx":570
 *         lua.luaL_unref(L, lua.LUA_REGISTRYINDEX, self._ref)
 *         if locked:
 *             unlock_runtime(self._runtime)             # <<<<<<<<<<<<<<
 * 
 *     @cython.final
 */
    __pyx_t_10 = ((PyObject *)__pyx_v_self->_runtime);
    __Pyx_INCREF(__pyx_t_10);
    __pyx_f_4lupa_5_lupa_unlock_runtime(((struct __pyx_obj_4lupa_5_lupa_LuaRuntime *)__pyx_t_10));
    __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;

    /* "lupa/_lupa.pyx":569
 *             locked = False
 *         lua.luaL_unref(L, lua.LUA_REGISTRYINDEX, self._ref)
 *         if locked:             # <<<<<<<<<<<<<<
 *             unlock_runtime(self._runtime)
 * 
 */
  }

  /* "lupa/_lupa.pyx":559
 *         raise TypeError("Type cannot be instantiated manually")
 * 
 *     def __dealloc__(self):             # <<<<<<<<<<<<<<
 *         if self._runtime is None:
 *             return
 */

  /* function exit code */
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_XDECREF(__pyx_t_9);
  __Pyx_XDECREF(__pyx_t_10);
  __Pyx_WriteUnraisable("lupa._lupa._LuaObject.__dealloc__", __pyx_clineno, __pyx_lineno, __pyx_filename, 1, 0);
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
}

/* "lupa/_lupa.pyx":573
 * 
 *     @cython.final
 *     cdef inline int push_lua_object(self) except -1:             # <<<<<<<<<<<<<<
 *         cdef lua_State* L = self._state
 *         lua.lua_rawgeti(L, lua.LUA_REGISTRYINDEX, self._ref)
 */

static CYTHON_INLINE int __pyx_f_4lupa_5_lupa_10_LuaObject_push_lua_object(struct __pyx_obj_4lupa_5_lupa__LuaObject *__pyx_v_self) {
  lua_State *__pyx_v_L;
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  lua_State *__pyx_t_1;
  int __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("push_lua_object", 0);

  /* "lupa/_lupa.pyx":574
 *     @cython.final
 *     cdef inline int push_lua_object(self) except -1:
 *         cdef lua_State* L = self._state             # <<<<<<<<<<<<<<
 *         lua.lua_rawgeti(L, lua.LUA_REGISTRYINDEX, self._ref)
 *         if lua.lua_isnil(L, -1):
 */
  __pyx_t_1 = __pyx_v_self->_state;
  __pyx_v_L = __pyx_t_1;

  /* "lupa/_lupa.pyx":575
 *     cdef inline int push_lua_object(self) except -1:
 *         cdef lua_State* L = self._state
 *         lua.lua_rawgeti(L, lua.LUA_REGISTRYINDEX, self._ref)             # <<<<<<<<<<<<<<
 *         if lua.lua_isnil(L, -1):
 *             lua.lua_pop(L, 1)
 */
  lua_rawgeti(__pyx_v_L, LUA_REGISTRYINDEX, __pyx_v_self->_ref);

  /* "lupa/_lupa.pyx":576
 *         cdef lua_State* L = self._state
 *         lua.lua_rawgeti(L, lua.LUA_REGISTRYINDEX, self._ref)
 *         if lua.lua_isnil(L, -1):             # <<<<<<<<<<<<<<
 *             lua.lua_pop(L, 1)
 *             raise LuaError("lost reference")
 */
  __pyx_t_2 = (lua_isnil(__pyx_v_L, -1) != 0);
  if (unlikely(__pyx_t_2)) {

    /* "lupa/_lupa.pyx":577
 *         lua.lua_rawgeti(L, lua.LUA_REGISTRYINDEX, self._ref)
 *         if lua.lua_isnil(L, -1):
 *             lua.lua_pop(L, 1)             # <<<<<<<<<<<<<<
 *             raise LuaError("lost reference")
 * 
 */
    lua_pop(__pyx_v_L, 1);

    /* "lupa/_lupa.pyx":578
 *         if lua.lua_isnil(L, -1):
 *             lua.lua_pop(L, 1)
 *             raise LuaError("lost reference")             # <<<<<<<<<<<<<<
 * 
 *     def __call__(self, *args):
 */
    __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_LuaError); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 578, __pyx_L1_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_Call2Args(__pyx_t_4, __pyx_t_5, __pyx_kp_s_lost_reference) : __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_kp_s_lost_reference);
    __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
    if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 578, __pyx_L1_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, 578, __pyx_L1_error)

    /* "lupa/_lupa.pyx":576
 *         cdef lua_State* L = self._state
 *         lua.lua_rawgeti(L, lua.LUA_REGISTRYINDEX, self._ref)
 *         if lua.lua_isnil(L, -1):             # <<<<<<<<<<<<<<
 *             lua.lua_pop(L, 1)
 *             raise LuaError("lost reference")
 */
  }

  /* "lupa/_lupa.pyx":573
 * 
 *     @cython.final
 *     cdef inline int push_lua_object(self) except -1:             # <<<<<<<<<<<<<<
 *         cdef lua_State* L = self._state
 *         lua.lua_rawgeti(L, lua.LUA_REGISTRYINDEX, self._ref)
 */

  /* 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_AddTraceback("lupa._lupa._LuaObject.push_lua_object", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lupa/_lupa.pyx":580
 *             raise LuaError("lost reference")
 * 
 *     def __call__(self, *args):             # <<<<<<<<<<<<<<
 *         assert self._runtime is not None
 *         cdef lua_State* L = self._state
 */

/* Python wrapper */
static PyObject *__pyx_pw_4lupa_5_lupa_10_LuaObject_5__call__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_pw_4lupa_5_lupa_10_LuaObject_5__call__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_args = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__call__ (wrapper)", 0);
  if (unlikely(__pyx_kwds) && unlikely(PyDict_Size(__pyx_kwds) > 0) && unlikely(!__Pyx_CheckKeywordStrings(__pyx_kwds, "__call__", 0))) return NULL;
  __Pyx_INCREF(__pyx_args);
  __pyx_v_args = __pyx_args;
  __pyx_r = __pyx_pf_4lupa_5_lupa_10_LuaObject_4__call__(((struct __pyx_obj_4lupa_5_lupa__LuaObject *)__pyx_v_self), __pyx_v_args);

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

static PyObject *__pyx_pf_4lupa_5_lupa_10_LuaObject_4__call__(struct __pyx_obj_4lupa_5_lupa__LuaObject *__pyx_v_self, PyObject *__pyx_v_args) {
  lua_State *__pyx_v_L;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  lua_State *__pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  int __pyx_t_4;
  PyObject *__pyx_t_5 = NULL;
  int __pyx_t_6;
  char const *__pyx_t_7;
  PyObject *__pyx_t_8 = NULL;
  PyObject *__pyx_t_9 = NULL;
  PyObject *__pyx_t_10 = NULL;
  PyObject *__pyx_t_11 = NULL;
  PyObject *__pyx_t_12 = NULL;
  PyObject *__pyx_t_13 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__call__", 0);

  /* "lupa/_lupa.pyx":581
 * 
 *     def __call__(self, *args):
 *         assert self._runtime is not None             # <<<<<<<<<<<<<<
 *         cdef lua_State* L = self._state
 *         lock_runtime(self._runtime)
 */
  #ifndef CYTHON_WITHOUT_ASSERTIONS
  if (unlikely(!Py_OptimizeFlag)) {
    __pyx_t_1 = (((PyObject *)__pyx_v_self->_runtime) != Py_None);
    if (unlikely(!(__pyx_t_1 != 0))) {
      PyErr_SetNone(PyExc_AssertionError);
      __PYX_ERR(0, 581, __pyx_L1_error)
    }
  }
  #endif

  /* "lupa/_lupa.pyx":582
 *     def __call__(self, *args):
 *         assert self._runtime is not None
 *         cdef lua_State* L = self._state             # <<<<<<<<<<<<<<
 *         lock_runtime(self._runtime)
 *         try:
 */
  __pyx_t_2 = __pyx_v_self->_state;
  __pyx_v_L = __pyx_t_2;

  /* "lupa/_lupa.pyx":583
 *         assert self._runtime is not None
 *         cdef lua_State* L = self._state
 *         lock_runtime(self._runtime)             # <<<<<<<<<<<<<<
 *         try:
 *             lua.lua_settop(L, 0)
 */
  __pyx_t_3 = ((PyObject *)__pyx_v_self->_runtime);
  __Pyx_INCREF(__pyx_t_3);
  __pyx_t_4 = __pyx_f_4lupa_5_lupa_lock_runtime(((struct __pyx_obj_4lupa_5_lupa_LuaRuntime *)__pyx_t_3)); if (unlikely(__pyx_t_4 == ((int)-1))) __PYX_ERR(0, 583, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

  /* "lupa/_lupa.pyx":584
 *         cdef lua_State* L = self._state
 *         lock_runtime(self._runtime)
 *         try:             # <<<<<<<<<<<<<<
 *             lua.lua_settop(L, 0)
 *             self.push_lua_object()
 */
  /*try:*/ {

    /* "lupa/_lupa.pyx":585
 *         lock_runtime(self._runtime)
 *         try:
 *             lua.lua_settop(L, 0)             # <<<<<<<<<<<<<<
 *             self.push_lua_object()
 *             return call_lua(self._runtime, L, args)
 */
    lua_settop(__pyx_v_L, 0);

    /* "lupa/_lupa.pyx":586
 *         try:
 *             lua.lua_settop(L, 0)
 *             self.push_lua_object()             # <<<<<<<<<<<<<<
 *             return call_lua(self._runtime, L, args)
 *         finally:
 */
    __pyx_t_4 = __pyx_f_4lupa_5_lupa_10_LuaObject_push_lua_object(__pyx_v_self); if (unlikely(__pyx_t_4 == ((int)-1))) __PYX_ERR(0, 586, __pyx_L4_error)

    /* "lupa/_lupa.pyx":587
 *             lua.lua_settop(L, 0)
 *             self.push_lua_object()
 *             return call_lua(self._runtime, L, args)             # <<<<<<<<<<<<<<
 *         finally:
 *             lua.lua_settop(L, 0)
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_3 = ((PyObject *)__pyx_v_self->_runtime);
    __Pyx_INCREF(__pyx_t_3);
    __pyx_t_5 = __pyx_f_4lupa_5_lupa_call_lua(((struct __pyx_obj_4lupa_5_lupa_LuaRuntime *)__pyx_t_3), __pyx_v_L, __pyx_v_args); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 587, __pyx_L4_error)
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_r = __pyx_t_5;
    __pyx_t_5 = 0;
    goto __pyx_L3_return;
  }

  /* "lupa/_lupa.pyx":589
 *             return call_lua(self._runtime, L, args)
 *         finally:
 *             lua.lua_settop(L, 0)             # <<<<<<<<<<<<<<
 *             unlock_runtime(self._runtime)
 * 
 */
  /*finally:*/ {
    __pyx_L4_error:;
    /*exception exit:*/{
      __Pyx_PyThreadState_declare
      __Pyx_PyThreadState_assign
      __pyx_t_8 = 0; __pyx_t_9 = 0; __pyx_t_10 = 0; __pyx_t_11 = 0; __pyx_t_12 = 0; __pyx_t_13 = 0;
      __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
      if (PY_MAJOR_VERSION >= 3) __Pyx_ExceptionSwap(&__pyx_t_11, &__pyx_t_12, &__pyx_t_13);
      if ((PY_MAJOR_VERSION < 3) || unlikely(__Pyx_GetException(&__pyx_t_8, &__pyx_t_9, &__pyx_t_10) < 0)) __Pyx_ErrFetch(&__pyx_t_8, &__pyx_t_9, &__pyx_t_10);
      __Pyx_XGOTREF(__pyx_t_8);
      __Pyx_XGOTREF(__pyx_t_9);
      __Pyx_XGOTREF(__pyx_t_10);
      __Pyx_XGOTREF(__pyx_t_11);
      __Pyx_XGOTREF(__pyx_t_12);
      __Pyx_XGOTREF(__pyx_t_13);
      __pyx_t_4 = __pyx_lineno; __pyx_t_6 = __pyx_clineno; __pyx_t_7 = __pyx_filename;
      {
        lua_settop(__pyx_v_L, 0);

        /* "lupa/_lupa.pyx":590
 *         finally:
 *             lua.lua_settop(L, 0)
 *             unlock_runtime(self._runtime)             # <<<<<<<<<<<<<<
 * 
 *     def __len__(self):
 */
        __pyx_t_5 = ((PyObject *)__pyx_v_self->_runtime);
        __Pyx_INCREF(__pyx_t_5);
        __pyx_f_4lupa_5_lupa_unlock_runtime(((struct __pyx_obj_4lupa_5_lupa_LuaRuntime *)__pyx_t_5));
        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      }
      if (PY_MAJOR_VERSION >= 3) {
        __Pyx_XGIVEREF(__pyx_t_11);
        __Pyx_XGIVEREF(__pyx_t_12);
        __Pyx_XGIVEREF(__pyx_t_13);
        __Pyx_ExceptionReset(__pyx_t_11, __pyx_t_12, __pyx_t_13);
      }
      __Pyx_XGIVEREF(__pyx_t_8);
      __Pyx_XGIVEREF(__pyx_t_9);
      __Pyx_XGIVEREF(__pyx_t_10);
      __Pyx_ErrRestore(__pyx_t_8, __pyx_t_9, __pyx_t_10);
      __pyx_t_8 = 0; __pyx_t_9 = 0; __pyx_t_10 = 0; __pyx_t_11 = 0; __pyx_t_12 = 0; __pyx_t_13 = 0;
      __pyx_lineno = __pyx_t_4; __pyx_clineno = __pyx_t_6; __pyx_filename = __pyx_t_7;
      goto __pyx_L1_error;
    }
    __pyx_L3_return: {
      __pyx_t_13 = __pyx_r;
      __pyx_r = 0;

      /* "lupa/_lupa.pyx":589
 *             return call_lua(self._runtime, L, args)
 *         finally:
 *             lua.lua_settop(L, 0)             # <<<<<<<<<<<<<<
 *             unlock_runtime(self._runtime)
 * 
 */
      lua_settop(__pyx_v_L, 0);

      /* "lupa/_lupa.pyx":590
 *         finally:
 *             lua.lua_settop(L, 0)
 *             unlock_runtime(self._runtime)             # <<<<<<<<<<<<<<
 * 
 *     def __len__(self):
 */
      __pyx_t_5 = ((PyObject *)__pyx_v_self->_runtime);
      __Pyx_INCREF(__pyx_t_5);
      __pyx_f_4lupa_5_lupa_unlock_runtime(((struct __pyx_obj_4lupa_5_lupa_LuaRuntime *)__pyx_t_5));
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __pyx_r = __pyx_t_13;
      __pyx_t_13 = 0;
      goto __pyx_L0;
    }
  }

  /* "lupa/_lupa.pyx":580
 *             raise LuaError("lost reference")
 * 
 *     def __call__(self, *args):             # <<<<<<<<<<<<<<
 *         assert self._runtime is not None
 *         cdef lua_State* L = self._state
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_AddTraceback("lupa._lupa._LuaObject.__call__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lupa/_lupa.pyx":592
 *             unlock_runtime(self._runtime)
 * 
 *     def __len__(self):             # <<<<<<<<<<<<<<
 *         return self._len()
 * 
 */

/* Python wrapper */
static Py_ssize_t __pyx_pw_4lupa_5_lupa_10_LuaObject_7__len__(PyObject *__pyx_v_self); /*proto*/
static Py_ssize_t __pyx_pw_4lupa_5_lupa_10_LuaObject_7__len__(PyObject *__pyx_v_self) {
  Py_ssize_t __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__len__ (wrapper)", 0);
  __pyx_r = __pyx_pf_4lupa_5_lupa_10_LuaObject_6__len__(((struct __pyx_obj_4lupa_5_lupa__LuaObject *)__pyx_v_self));

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

static Py_ssize_t __pyx_pf_4lupa_5_lupa_10_LuaObject_6__len__(struct __pyx_obj_4lupa_5_lupa__LuaObject *__pyx_v_self) {
  Py_ssize_t __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__len__", 0);

  /* "lupa/_lupa.pyx":593
 * 
 *     def __len__(self):
 *         return self._len()             # <<<<<<<<<<<<<<
 * 
 *     @cython.final
 */
  __pyx_r = __pyx_f_4lupa_5_lupa_10_LuaObject__len(__pyx_v_self);
  goto __pyx_L0;

  /* "lupa/_lupa.pyx":592
 *             unlock_runtime(self._runtime)
 * 
 *     def __len__(self):             # <<<<<<<<<<<<<<
 *         return self._len()
 * 
 */

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

/* "lupa/_lupa.pyx":596
 * 
 *     @cython.final
 *     cdef size_t _len(self):             # <<<<<<<<<<<<<<
 *         assert self._runtime is not None
 *         cdef lua_State* L = self._state
 */

static size_t __pyx_f_4lupa_5_lupa_10_LuaObject__len(struct __pyx_obj_4lupa_5_lupa__LuaObject *__pyx_v_self) {
  lua_State *__pyx_v_L;
  size_t __pyx_v_size;
  size_t __pyx_r;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  lua_State *__pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  int __pyx_t_4;
  int __pyx_t_5;
  char const *__pyx_t_6;
  PyObject *__pyx_t_7 = NULL;
  PyObject *__pyx_t_8 = NULL;
  PyObject *__pyx_t_9 = NULL;
  PyObject *__pyx_t_10 = NULL;
  PyObject *__pyx_t_11 = NULL;
  PyObject *__pyx_t_12 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("_len", 0);

  /* "lupa/_lupa.pyx":597
 *     @cython.final
 *     cdef size_t _len(self):
 *         assert self._runtime is not None             # <<<<<<<<<<<<<<
 *         cdef lua_State* L = self._state
 *         lock_runtime(self._runtime)
 */
  #ifndef CYTHON_WITHOUT_ASSERTIONS
  if (unlikely(!Py_OptimizeFlag)) {
    __pyx_t_1 = (((PyObject *)__pyx_v_self->_runtime) != Py_None);
    if (unlikely(!(__pyx_t_1 != 0))) {
      PyErr_SetNone(PyExc_AssertionError);
      __PYX_ERR(0, 597, __pyx_L1_error)
    }
  }
  #endif

  /* "lupa/_lupa.pyx":598
 *     cdef size_t _len(self):
 *         assert self._runtime is not None
 *         cdef lua_State* L = self._state             # <<<<<<<<<<<<<<
 *         lock_runtime(self._runtime)
 *         size = 0
 */
  __pyx_t_2 = __pyx_v_self->_state;
  __pyx_v_L = __pyx_t_2;

  /* "lupa/_lupa.pyx":599
 *         assert self._runtime is not None
 *         cdef lua_State* L = self._state
 *         lock_runtime(self._runtime)             # <<<<<<<<<<<<<<
 *         size = 0
 *         try:
 */
  __pyx_t_3 = ((PyObject *)__pyx_v_self->_runtime);
  __Pyx_INCREF(__pyx_t_3);
  __pyx_t_4 = __pyx_f_4lupa_5_lupa_lock_runtime(((struct __pyx_obj_4lupa_5_lupa_LuaRuntime *)__pyx_t_3)); if (unlikely(__pyx_t_4 == ((int)-1))) __PYX_ERR(0, 599, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

  /* "lupa/_lupa.pyx":600
 *         cdef lua_State* L = self._state
 *         lock_runtime(self._runtime)
 *         size = 0             # <<<<<<<<<<<<<<
 *         try:
 *             self.push_lua_object()
 */
  __pyx_v_size = 0;

  /* "lupa/_lupa.pyx":601
 *         lock_runtime(self._runtime)
 *         size = 0
 *         try:             # <<<<<<<<<<<<<<
 *             self.push_lua_object()
 *             size = lua.lua_objlen(L, -1)
 */
  /*try:*/ {

    /* "lupa/_lupa.pyx":602
 *         size = 0
 *         try:
 *             self.push_lua_object()             # <<<<<<<<<<<<<<
 *             size = lua.lua_objlen(L, -1)
 *             lua.lua_pop(L, 1)
 */
    __pyx_t_4 = __pyx_f_4lupa_5_lupa_10_LuaObject_push_lua_object(__pyx_v_self); if (unlikely(__pyx_t_4 == ((int)-1))) __PYX_ERR(0, 602, __pyx_L4_error)

    /* "lupa/_lupa.pyx":603
 *         try:
 *             self.push_lua_object()
 *             size = lua.lua_objlen(L, -1)             # <<<<<<<<<<<<<<
 *             lua.lua_pop(L, 1)
 *         finally:
 */
    __pyx_v_size = lua_objlen(__pyx_v_L, -1);

    /* "lupa/_lupa.pyx":604
 *             self.push_lua_object()
 *             size = lua.lua_objlen(L, -1)
 *             lua.lua_pop(L, 1)             # <<<<<<<<<<<<<<
 *         finally:
 *             unlock_runtime(self._runtime)
 */
    lua_pop(__pyx_v_L, 1);
  }

  /* "lupa/_lupa.pyx":606
 *             lua.lua_pop(L, 1)
 *         finally:
 *             unlock_runtime(self._runtime)             # <<<<<<<<<<<<<<
 *         return size
 * 
 */
  /*finally:*/ {
    /*normal exit:*/{
      __pyx_t_3 = ((PyObject *)__pyx_v_self->_runtime);
      __Pyx_INCREF(__pyx_t_3);
      __pyx_f_4lupa_5_lupa_unlock_runtime(((struct __pyx_obj_4lupa_5_lupa_LuaRuntime *)__pyx_t_3));
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      goto __pyx_L5;
    }
    __pyx_L4_error:;
    /*exception exit:*/{
      __Pyx_PyThreadState_declare
      __Pyx_PyThreadState_assign
      __pyx_t_7 = 0; __pyx_t_8 = 0; __pyx_t_9 = 0; __pyx_t_10 = 0; __pyx_t_11 = 0; __pyx_t_12 = 0;
      __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
      if (PY_MAJOR_VERSION >= 3) __Pyx_ExceptionSwap(&__pyx_t_10, &__pyx_t_11, &__pyx_t_12);
      if ((PY_MAJOR_VERSION < 3) || unlikely(__Pyx_GetException(&__pyx_t_7, &__pyx_t_8, &__pyx_t_9) < 0)) __Pyx_ErrFetch(&__pyx_t_7, &__pyx_t_8, &__pyx_t_9);
      __Pyx_XGOTREF(__pyx_t_7);
      __Pyx_XGOTREF(__pyx_t_8);
      __Pyx_XGOTREF(__pyx_t_9);
      __Pyx_XGOTREF(__pyx_t_10);
      __Pyx_XGOTREF(__pyx_t_11);
      __Pyx_XGOTREF(__pyx_t_12);
      __pyx_t_4 = __pyx_lineno; __pyx_t_5 = __pyx_clineno; __pyx_t_6 = __pyx_filename;
      {
        __pyx_t_3 = ((PyObject *)__pyx_v_self->_runtime);
        __Pyx_INCREF(__pyx_t_3);
        __pyx_f_4lupa_5_lupa_unlock_runtime(((struct __pyx_obj_4lupa_5_lupa_LuaRuntime *)__pyx_t_3));
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      }
      if (PY_MAJOR_VERSION >= 3) {
        __Pyx_XGIVEREF(__pyx_t_10);
        __Pyx_XGIVEREF(__pyx_t_11);
        __Pyx_XGIVEREF(__pyx_t_12);
        __Pyx_ExceptionReset(__pyx_t_10, __pyx_t_11, __pyx_t_12);
      }
      __Pyx_XGIVEREF(__pyx_t_7);
      __Pyx_XGIVEREF(__pyx_t_8);
      __Pyx_XGIVEREF(__pyx_t_9);
      __Pyx_ErrRestore(__pyx_t_7, __pyx_t_8, __pyx_t_9);
      __pyx_t_7 = 0; __pyx_t_8 = 0; __pyx_t_9 = 0; __pyx_t_10 = 0; __pyx_t_11 = 0; __pyx_t_12 = 0;
      __pyx_lineno = __pyx_t_4; __pyx_clineno = __pyx_t_5; __pyx_filename = __pyx_t_6;
      goto __pyx_L1_error;
    }
    __pyx_L5:;
  }

  /* "lupa/_lupa.pyx":607
 *         finally:
 *             unlock_runtime(self._runtime)
 *         return size             # <<<<<<<<<<<<<<
 * 
 *     def __nonzero__(self):
 */
  __pyx_r = __pyx_v_size;
  goto __pyx_L0;

  /* "lupa/_lupa.pyx":596
 * 
 *     @cython.final
 *     cdef size_t _len(self):             # <<<<<<<<<<<<<<
 *         assert self._runtime is not None
 *         cdef lua_State* L = self._state
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_WriteUnraisable("lupa._lupa._LuaObject._len", __pyx_clineno, __pyx_lineno, __pyx_filename, 1, 0);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lupa/_lupa.pyx":609
 *         return size
 * 
 *     def __nonzero__(self):             # <<<<<<<<<<<<<<
 *         return True
 * 
 */

/* Python wrapper */
static int __pyx_pw_4lupa_5_lupa_10_LuaObject_9__nonzero__(PyObject *__pyx_v_self); /*proto*/
static int __pyx_pw_4lupa_5_lupa_10_LuaObject_9__nonzero__(PyObject *__pyx_v_self) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__nonzero__ (wrapper)", 0);
  __pyx_r = __pyx_pf_4lupa_5_lupa_10_LuaObject_8__nonzero__(((struct __pyx_obj_4lupa_5_lupa__LuaObject *)__pyx_v_self));

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

static int __pyx_pf_4lupa_5_lupa_10_LuaObject_8__nonzero__(CYTHON_UNUSED struct __pyx_obj_4lupa_5_lupa__LuaObject *__pyx_v_self) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__nonzero__", 0);

  /* "lupa/_lupa.pyx":610
 * 
 *     def __nonzero__(self):
 *         return True             # <<<<<<<<<<<<<<
 * 
 *     def __iter__(self):
 */
  __pyx_r = 1;
  goto __pyx_L0;

  /* "lupa/_lupa.pyx":609
 *         return size
 * 
 *     def __nonzero__(self):             # <<<<<<<<<<<<<<
 *         return True
 * 
 */

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

/* "lupa/_lupa.pyx":612
 *         return True
 * 
 *     def __iter__(self):             # <<<<<<<<<<<<<<
 *         # if not provided, iteration will try item access and call into Lua
 *         raise TypeError("iteration is only supported for tables")
 */

/* Python wrapper */
static PyObject *__pyx_pw_4lupa_5_lupa_10_LuaObject_11__iter__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_4lupa_5_lupa_10_LuaObject_11__iter__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__iter__ (wrapper)", 0);
  __pyx_r = __pyx_pf_4lupa_5_lupa_10_LuaObject_10__iter__(((struct __pyx_obj_4lupa_5_lupa__LuaObject *)__pyx_v_self));

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

static PyObject *__pyx_pf_4lupa_5_lupa_10_LuaObject_10__iter__(CYTHON_UNUSED struct __pyx_obj_4lupa_5_lupa__LuaObject *__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("__iter__", 0);

  /* "lupa/_lupa.pyx":614
 *     def __iter__(self):
 *         # if not provided, iteration will try item access and call into Lua
 *         raise TypeError("iteration is only supported for tables")             # <<<<<<<<<<<<<<
 * 
 *     def __repr__(self):
 */
  __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__15, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 614, __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, 614, __pyx_L1_error)

  /* "lupa/_lupa.pyx":612
 *         return True
 * 
 *     def __iter__(self):             # <<<<<<<<<<<<<<
 *         # if not provided, iteration will try item access and call into Lua
 *         raise TypeError("iteration is only supported for tables")
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("lupa._lupa._LuaObject.__iter__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lupa/_lupa.pyx":616
 *         raise TypeError("iteration is only supported for tables")
 * 
 *     def __repr__(self):             # <<<<<<<<<<<<<<
 *         assert self._runtime is not None
 *         cdef lua_State* L = self._state
 */

/* Python wrapper */
static PyObject *__pyx_pw_4lupa_5_lupa_10_LuaObject_13__repr__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_4lupa_5_lupa_10_LuaObject_13__repr__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__repr__ (wrapper)", 0);
  __pyx_r = __pyx_pf_4lupa_5_lupa_10_LuaObject_12__repr__(((struct __pyx_obj_4lupa_5_lupa__LuaObject *)__pyx_v_self));

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

static PyObject *__pyx_pf_4lupa_5_lupa_10_LuaObject_12__repr__(struct __pyx_obj_4lupa_5_lupa__LuaObject *__pyx_v_self) {
  lua_State *__pyx_v_L;
  PyObject *__pyx_v_encoding = 0;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  lua_State *__pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  int __pyx_t_4;
  int __pyx_t_5;
  char const *__pyx_t_6;
  PyObject *__pyx_t_7 = NULL;
  PyObject *__pyx_t_8 = NULL;
  PyObject *__pyx_t_9 = NULL;
  PyObject *__pyx_t_10 = NULL;
  PyObject *__pyx_t_11 = NULL;
  PyObject *__pyx_t_12 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__repr__", 0);

  /* "lupa/_lupa.pyx":617
 * 
 *     def __repr__(self):
 *         assert self._runtime is not None             # <<<<<<<<<<<<<<
 *         cdef lua_State* L = self._state
 *         cdef bytes encoding = self._runtime._encoding or b'UTF-8'
 */
  #ifndef CYTHON_WITHOUT_ASSERTIONS
  if (unlikely(!Py_OptimizeFlag)) {
    __pyx_t_1 = (((PyObject *)__pyx_v_self->_runtime) != Py_None);
    if (unlikely(!(__pyx_t_1 != 0))) {
      PyErr_SetNone(PyExc_AssertionError);
      __PYX_ERR(0, 617, __pyx_L1_error)
    }
  }
  #endif

  /* "lupa/_lupa.pyx":618
 *     def __repr__(self):
 *         assert self._runtime is not None
 *         cdef lua_State* L = self._state             # <<<<<<<<<<<<<<
 *         cdef bytes encoding = self._runtime._encoding or b'UTF-8'
 *         lock_runtime(self._runtime)
 */
  __pyx_t_2 = __pyx_v_self->_state;
  __pyx_v_L = __pyx_t_2;

  /* "lupa/_lupa.pyx":619
 *         assert self._runtime is not None
 *         cdef lua_State* L = self._state
 *         cdef bytes encoding = self._runtime._encoding or b'UTF-8'             # <<<<<<<<<<<<<<
 *         lock_runtime(self._runtime)
 *         try:
 */
  __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_v_self->_runtime->_encoding); if (unlikely(__pyx_t_1 < 0)) __PYX_ERR(0, 619, __pyx_L1_error)
  if (!__pyx_t_1) {
  } else {
    __Pyx_INCREF(__pyx_v_self->_runtime->_encoding);
    __pyx_t_3 = __pyx_v_self->_runtime->_encoding;
    goto __pyx_L3_bool_binop_done;
  }
  __Pyx_INCREF(__pyx_kp_b_UTF_8);
  __pyx_t_3 = __pyx_kp_b_UTF_8;
  __pyx_L3_bool_binop_done:;
  __pyx_v_encoding = ((PyObject*)__pyx_t_3);
  __pyx_t_3 = 0;

  /* "lupa/_lupa.pyx":620
 *         cdef lua_State* L = self._state
 *         cdef bytes encoding = self._runtime._encoding or b'UTF-8'
 *         lock_runtime(self._runtime)             # <<<<<<<<<<<<<<
 *         try:
 *             self.push_lua_object()
 */
  __pyx_t_3 = ((PyObject *)__pyx_v_self->_runtime);
  __Pyx_INCREF(__pyx_t_3);
  __pyx_t_4 = __pyx_f_4lupa_5_lupa_lock_runtime(((struct __pyx_obj_4lupa_5_lupa_LuaRuntime *)__pyx_t_3)); if (unlikely(__pyx_t_4 == ((int)-1))) __PYX_ERR(0, 620, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

  /* "lupa/_lupa.pyx":621
 *         cdef bytes encoding = self._runtime._encoding or b'UTF-8'
 *         lock_runtime(self._runtime)
 *         try:             # <<<<<<<<<<<<<<
 *             self.push_lua_object()
 *             return lua_object_repr(L, encoding)
 */
  /*try:*/ {

    /* "lupa/_lupa.pyx":622
 *         lock_runtime(self._runtime)
 *         try:
 *             self.push_lua_object()             # <<<<<<<<<<<<<<
 *             return lua_object_repr(L, encoding)
 *         finally:
 */
    __pyx_t_4 = __pyx_f_4lupa_5_lupa_10_LuaObject_push_lua_object(__pyx_v_self); if (unlikely(__pyx_t_4 == ((int)-1))) __PYX_ERR(0, 622, __pyx_L6_error)

    /* "lupa/_lupa.pyx":623
 *         try:
 *             self.push_lua_object()
 *             return lua_object_repr(L, encoding)             # <<<<<<<<<<<<<<
 *         finally:
 *             lua.lua_pop(L, 1)
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_3 = __pyx_f_4lupa_5_lupa_lua_object_repr(__pyx_v_L, __pyx_v_encoding); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 623, __pyx_L6_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_r = __pyx_t_3;
    __pyx_t_3 = 0;
    goto __pyx_L5_return;
  }

  /* "lupa/_lupa.pyx":625
 *             return lua_object_repr(L, encoding)
 *         finally:
 *             lua.lua_pop(L, 1)             # <<<<<<<<<<<<<<
 *             unlock_runtime(self._runtime)
 * 
 */
  /*finally:*/ {
    __pyx_L6_error:;
    /*exception exit:*/{
      __Pyx_PyThreadState_declare
      __Pyx_PyThreadState_assign
      __pyx_t_7 = 0; __pyx_t_8 = 0; __pyx_t_9 = 0; __pyx_t_10 = 0; __pyx_t_11 = 0; __pyx_t_12 = 0;
      __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
      if (PY_MAJOR_VERSION >= 3) __Pyx_ExceptionSwap(&__pyx_t_10, &__pyx_t_11, &__pyx_t_12);
      if ((PY_MAJOR_VERSION < 3) || unlikely(__Pyx_GetException(&__pyx_t_7, &__pyx_t_8, &__pyx_t_9) < 0)) __Pyx_ErrFetch(&__pyx_t_7, &__pyx_t_8, &__pyx_t_9);
      __Pyx_XGOTREF(__pyx_t_7);
      __Pyx_XGOTREF(__pyx_t_8);
      __Pyx_XGOTREF(__pyx_t_9);
      __Pyx_XGOTREF(__pyx_t_10);
      __Pyx_XGOTREF(__pyx_t_11);
      __Pyx_XGOTREF(__pyx_t_12);
      __pyx_t_4 = __pyx_lineno; __pyx_t_5 = __pyx_clineno; __pyx_t_6 = __pyx_filename;
      {
        lua_pop(__pyx_v_L, 1);

        /* "lupa/_lupa.pyx":626
 *         finally:
 *             lua.lua_pop(L, 1)
 *             unlock_runtime(self._runtime)             # <<<<<<<<<<<<<<
 * 
 *     def __str__(self):
 */
        __pyx_t_3 = ((PyObject *)__pyx_v_self->_runtime);
        __Pyx_INCREF(__pyx_t_3);
        __pyx_f_4lupa_5_lupa_unlock_runtime(((struct __pyx_obj_4lupa_5_lupa_LuaRuntime *)__pyx_t_3));
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      }
      if (PY_MAJOR_VERSION >= 3) {
        __Pyx_XGIVEREF(__pyx_t_10);
        __Pyx_XGIVEREF(__pyx_t_11);
        __Pyx_XGIVEREF(__pyx_t_12);
        __Pyx_ExceptionReset(__pyx_t_10, __pyx_t_11, __pyx_t_12);
      }
      __Pyx_XGIVEREF(__pyx_t_7);
      __Pyx_XGIVEREF(__pyx_t_8);
      __Pyx_XGIVEREF(__pyx_t_9);
      __Pyx_ErrRestore(__pyx_t_7, __pyx_t_8, __pyx_t_9);
      __pyx_t_7 = 0; __pyx_t_8 = 0; __pyx_t_9 = 0; __pyx_t_10 = 0; __pyx_t_11 = 0; __pyx_t_12 = 0;
      __pyx_lineno = __pyx_t_4; __pyx_clineno = __pyx_t_5; __pyx_filename = __pyx_t_6;
      goto __pyx_L1_error;
    }
    __pyx_L5_return: {
      __pyx_t_12 = __pyx_r;
      __pyx_r = 0;

      /* "lupa/_lupa.pyx":625
 *             return lua_object_repr(L, encoding)
 *         finally:
 *             lua.lua_pop(L, 1)             # <<<<<<<<<<<<<<
 *             unlock_runtime(self._runtime)
 * 
 */
      lua_pop(__pyx_v_L, 1);

      /* "lupa/_lupa.pyx":626
 *         finally:
 *             lua.lua_pop(L, 1)
 *             unlock_runtime(self._runtime)             # <<<<<<<<<<<<<<
 * 
 *     def __str__(self):
 */
      __pyx_t_3 = ((PyObject *)__pyx_v_self->_runtime);
      __Pyx_INCREF(__pyx_t_3);
      __pyx_f_4lupa_5_lupa_unlock_runtime(((struct __pyx_obj_4lupa_5_lupa_LuaRuntime *)__pyx_t_3));
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_r = __pyx_t_12;
      __pyx_t_12 = 0;
      goto __pyx_L0;
    }
  }

  /* "lupa/_lupa.pyx":616
 *         raise TypeError("iteration is only supported for tables")
 * 
 *     def __repr__(self):             # <<<<<<<<<<<<<<
 *         assert self._runtime is not None
 *         cdef lua_State* L = self._state
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("lupa._lupa._LuaObject.__repr__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_encoding);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lupa/_lupa.pyx":628
 *             unlock_runtime(self._runtime)
 * 
 *     def __str__(self):             # <<<<<<<<<<<<<<
 *         assert self._runtime is not None
 *         cdef lua_State* L = self._state
 */

/* Python wrapper */
static PyObject *__pyx_pw_4lupa_5_lupa_10_LuaObject_15__str__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_4lupa_5_lupa_10_LuaObject_15__str__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__str__ (wrapper)", 0);
  __pyx_r = __pyx_pf_4lupa_5_lupa_10_LuaObject_14__str__(((struct __pyx_obj_4lupa_5_lupa__LuaObject *)__pyx_v_self));

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

static PyObject *__pyx_pf_4lupa_5_lupa_10_LuaObject_14__str__(struct __pyx_obj_4lupa_5_lupa__LuaObject *__pyx_v_self) {
  lua_State *__pyx_v_L;
  PyObject *__pyx_v_py_string = 0;
  char const *__pyx_v_s;
  size_t __pyx_v_size;
  PyObject *__pyx_v_encoding = 0;
  PyObject *__pyx_v_old_top = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  lua_State *__pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  int __pyx_t_4;
  int __pyx_t_5;
  PyObject *__pyx_t_6 = NULL;
  PyObject *__pyx_t_7 = NULL;
  PyObject *__pyx_t_8 = NULL;
  char const *__pyx_t_9;
  PyObject *__pyx_t_10 = NULL;
  PyObject *__pyx_t_11 = NULL;
  PyObject *__pyx_t_12 = NULL;
  int __pyx_t_13;
  char const *__pyx_t_14;
  PyObject *__pyx_t_15 = NULL;
  PyObject *__pyx_t_16 = NULL;
  PyObject *__pyx_t_17 = NULL;
  int __pyx_t_18;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__str__", 0);

  /* "lupa/_lupa.pyx":629
 * 
 *     def __str__(self):
 *         assert self._runtime is not None             # <<<<<<<<<<<<<<
 *         cdef lua_State* L = self._state
 *         cdef unicode py_string = None
 */
  #ifndef CYTHON_WITHOUT_ASSERTIONS
  if (unlikely(!Py_OptimizeFlag)) {
    __pyx_t_1 = (((PyObject *)__pyx_v_self->_runtime) != Py_None);
    if (unlikely(!(__pyx_t_1 != 0))) {
      PyErr_SetNone(PyExc_AssertionError);
      __PYX_ERR(0, 629, __pyx_L1_error)
    }
  }
  #endif

  /* "lupa/_lupa.pyx":630
 *     def __str__(self):
 *         assert self._runtime is not None
 *         cdef lua_State* L = self._state             # <<<<<<<<<<<<<<
 *         cdef unicode py_string = None
 *         cdef const char *s
 */
  __pyx_t_2 = __pyx_v_self->_state;
  __pyx_v_L = __pyx_t_2;

  /* "lupa/_lupa.pyx":631
 *         assert self._runtime is not None
 *         cdef lua_State* L = self._state
 *         cdef unicode py_string = None             # <<<<<<<<<<<<<<
 *         cdef const char *s
 *         cdef size_t size = 0
 */
  __Pyx_INCREF(Py_None);
  __pyx_v_py_string = ((PyObject*)Py_None);

  /* "lupa/_lupa.pyx":633
 *         cdef unicode py_string = None
 *         cdef const char *s
 *         cdef size_t size = 0             # <<<<<<<<<<<<<<
 *         cdef bytes encoding = self._runtime._encoding or b'UTF-8'
 *         lock_runtime(self._runtime)
 */
  __pyx_v_size = 0;

  /* "lupa/_lupa.pyx":634
 *         cdef const char *s
 *         cdef size_t size = 0
 *         cdef bytes encoding = self._runtime._encoding or b'UTF-8'             # <<<<<<<<<<<<<<
 *         lock_runtime(self._runtime)
 *         old_top = lua.lua_gettop(L)
 */
  __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_v_self->_runtime->_encoding); if (unlikely(__pyx_t_1 < 0)) __PYX_ERR(0, 634, __pyx_L1_error)
  if (!__pyx_t_1) {
  } else {
    __Pyx_INCREF(__pyx_v_self->_runtime->_encoding);
    __pyx_t_3 = __pyx_v_self->_runtime->_encoding;
    goto __pyx_L3_bool_binop_done;
  }
  __Pyx_INCREF(__pyx_kp_b_UTF_8);
  __pyx_t_3 = __pyx_kp_b_UTF_8;
  __pyx_L3_bool_binop_done:;
  __pyx_v_encoding = ((PyObject*)__pyx_t_3);
  __pyx_t_3 = 0;

  /* "lupa/_lupa.pyx":635
 *         cdef size_t size = 0
 *         cdef bytes encoding = self._runtime._encoding or b'UTF-8'
 *         lock_runtime(self._runtime)             # <<<<<<<<<<<<<<
 *         old_top = lua.lua_gettop(L)
 *         try:
 */
  __pyx_t_3 = ((PyObject *)__pyx_v_self->_runtime);
  __Pyx_INCREF(__pyx_t_3);
  __pyx_t_4 = __pyx_f_4lupa_5_lupa_lock_runtime(((struct __pyx_obj_4lupa_5_lupa_LuaRuntime *)__pyx_t_3)); if (unlikely(__pyx_t_4 == ((int)-1))) __PYX_ERR(0, 635, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

  /* "lupa/_lupa.pyx":636
 *         cdef bytes encoding = self._runtime._encoding or b'UTF-8'
 *         lock_runtime(self._runtime)
 *         old_top = lua.lua_gettop(L)             # <<<<<<<<<<<<<<
 *         try:
 *             self.push_lua_object()
 */
  __pyx_t_3 = __Pyx_PyInt_From_int(lua_gettop(__pyx_v_L)); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 636, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_v_old_top = __pyx_t_3;
  __pyx_t_3 = 0;

  /* "lupa/_lupa.pyx":637
 *         lock_runtime(self._runtime)
 *         old_top = lua.lua_gettop(L)
 *         try:             # <<<<<<<<<<<<<<
 *             self.push_lua_object()
 *             # lookup and call "__tostring" metatable method manually to catch any errors
 */
  /*try:*/ {

    /* "lupa/_lupa.pyx":638
 *         old_top = lua.lua_gettop(L)
 *         try:
 *             self.push_lua_object()             # <<<<<<<<<<<<<<
 *             # lookup and call "__tostring" metatable method manually to catch any errors
 *             if lua.lua_getmetatable(L, -1):
 */
    __pyx_t_4 = __pyx_f_4lupa_5_lupa_10_LuaObject_push_lua_object(__pyx_v_self); if (unlikely(__pyx_t_4 == ((int)-1))) __PYX_ERR(0, 638, __pyx_L6_error)

    /* "lupa/_lupa.pyx":640
 *             self.push_lua_object()
 *             # lookup and call "__tostring" metatable method manually to catch any errors
 *             if lua.lua_getmetatable(L, -1):             # <<<<<<<<<<<<<<
 *                 lua.lua_pushlstring(L, "__tostring", 10)
 *                 lua.lua_rawget(L, -2)
 */
    __pyx_t_1 = (lua_getmetatable(__pyx_v_L, -1) != 0);
    if (__pyx_t_1) {

      /* "lupa/_lupa.pyx":641
 *             # lookup and call "__tostring" metatable method manually to catch any errors
 *             if lua.lua_getmetatable(L, -1):
 *                 lua.lua_pushlstring(L, "__tostring", 10)             # <<<<<<<<<<<<<<
 *                 lua.lua_rawget(L, -2)
 *                 if not lua.lua_isnil(L, -1) and lua.lua_pcall(L, 1, 1, 0) == 0:
 */
      lua_pushlstring(__pyx_v_L, ((char *)"__tostring"), 10);

      /* "lupa/_lupa.pyx":642
 *             if lua.lua_getmetatable(L, -1):
 *                 lua.lua_pushlstring(L, "__tostring", 10)
 *                 lua.lua_rawget(L, -2)             # <<<<<<<<<<<<<<
 *                 if not lua.lua_isnil(L, -1) and lua.lua_pcall(L, 1, 1, 0) == 0:
 *                     s = lua.lua_tolstring(L, -1, &size)
 */
      lua_rawget(__pyx_v_L, -2);

      /* "lupa/_lupa.pyx":643
 *                 lua.lua_pushlstring(L, "__tostring", 10)
 *                 lua.lua_rawget(L, -2)
 *                 if not lua.lua_isnil(L, -1) and lua.lua_pcall(L, 1, 1, 0) == 0:             # <<<<<<<<<<<<<<
 *                     s = lua.lua_tolstring(L, -1, &size)
 *                     if s:
 */
      __pyx_t_5 = ((!(lua_isnil(__pyx_v_L, -1) != 0)) != 0);
      if (__pyx_t_5) {
      } else {
        __pyx_t_1 = __pyx_t_5;
        goto __pyx_L10_bool_binop_done;
      }
      __pyx_t_5 = ((lua_pcall(__pyx_v_L, 1, 1, 0) == 0) != 0);
      __pyx_t_1 = __pyx_t_5;
      __pyx_L10_bool_binop_done:;
      if (__pyx_t_1) {

        /* "lupa/_lupa.pyx":644
 *                 lua.lua_rawget(L, -2)
 *                 if not lua.lua_isnil(L, -1) and lua.lua_pcall(L, 1, 1, 0) == 0:
 *                     s = lua.lua_tolstring(L, -1, &size)             # <<<<<<<<<<<<<<
 *                     if s:
 *                         try:
 */
        __pyx_v_s = lua_tolstring(__pyx_v_L, -1, (&__pyx_v_size));

        /* "lupa/_lupa.pyx":645
 *                 if not lua.lua_isnil(L, -1) and lua.lua_pcall(L, 1, 1, 0) == 0:
 *                     s = lua.lua_tolstring(L, -1, &size)
 *                     if s:             # <<<<<<<<<<<<<<
 *                         try:
 *                             py_string = s[:size].decode(encoding)
 */
        __pyx_t_1 = (__pyx_v_s != 0);
        if (__pyx_t_1) {

          /* "lupa/_lupa.pyx":646
 *                     s = lua.lua_tolstring(L, -1, &size)
 *                     if s:
 *                         try:             # <<<<<<<<<<<<<<
 *                             py_string = s[:size].decode(encoding)
 *                         except UnicodeDecodeError:
 */
          {
            __Pyx_PyThreadState_declare
            __Pyx_PyThreadState_assign
            __Pyx_ExceptionSave(&__pyx_t_6, &__pyx_t_7, &__pyx_t_8);
            __Pyx_XGOTREF(__pyx_t_6);
            __Pyx_XGOTREF(__pyx_t_7);
            __Pyx_XGOTREF(__pyx_t_8);
            /*try:*/ {

              /* "lupa/_lupa.pyx":647
 *                     if s:
 *                         try:
 *                             py_string = s[:size].decode(encoding)             # <<<<<<<<<<<<<<
 *                         except UnicodeDecodeError:
 *                             # safe 'decode'
 */
              if (unlikely(__pyx_v_encoding == Py_None)) {
                PyErr_SetString(PyExc_TypeError, "expected bytes, NoneType found");
                __PYX_ERR(0, 647, __pyx_L13_error)
              }
              __pyx_t_9 = __Pyx_PyBytes_AsString(__pyx_v_encoding); if (unlikely((!__pyx_t_9) && PyErr_Occurred())) __PYX_ERR(0, 647, __pyx_L13_error)
              __pyx_t_3 = __Pyx_decode_c_string(__pyx_v_s, 0, __pyx_v_size, __pyx_t_9, NULL, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 647, __pyx_L13_error)
              __Pyx_GOTREF(__pyx_t_3);
              __Pyx_DECREF_SET(__pyx_v_py_string, ((PyObject*)__pyx_t_3));
              __pyx_t_3 = 0;

              /* "lupa/_lupa.pyx":646
 *                     s = lua.lua_tolstring(L, -1, &size)
 *                     if s:
 *                         try:             # <<<<<<<<<<<<<<
 *                             py_string = s[:size].decode(encoding)
 *                         except UnicodeDecodeError:
 */
            }
            __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
            __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
            __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
            goto __pyx_L18_try_end;
            __pyx_L13_error:;
            __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;

            /* "lupa/_lupa.pyx":648
 *                         try:
 *                             py_string = s[:size].decode(encoding)
 *                         except UnicodeDecodeError:             # <<<<<<<<<<<<<<
 *                             # safe 'decode'
 *                             py_string = s[:size].decode('ISO-8859-1')
 */
            __pyx_t_4 = __Pyx_PyErr_ExceptionMatches(__pyx_builtin_UnicodeDecodeError);
            if (__pyx_t_4) {
              __Pyx_AddTraceback("lupa._lupa._LuaObject.__str__", __pyx_clineno, __pyx_lineno, __pyx_filename);
              if (__Pyx_GetException(&__pyx_t_3, &__pyx_t_10, &__pyx_t_11) < 0) __PYX_ERR(0, 648, __pyx_L15_except_error)
              __Pyx_GOTREF(__pyx_t_3);
              __Pyx_GOTREF(__pyx_t_10);
              __Pyx_GOTREF(__pyx_t_11);

              /* "lupa/_lupa.pyx":650
 *                         except UnicodeDecodeError:
 *                             # safe 'decode'
 *                             py_string = s[:size].decode('ISO-8859-1')             # <<<<<<<<<<<<<<
 *             if py_string is None:
 *                 lua.lua_settop(L, old_top + 1)
 */
              __pyx_t_12 = __Pyx_decode_c_string(__pyx_v_s, 0, __pyx_v_size, NULL, NULL, PyUnicode_DecodeLatin1); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 650, __pyx_L15_except_error)
              __Pyx_GOTREF(__pyx_t_12);
              __Pyx_DECREF_SET(__pyx_v_py_string, ((PyObject*)__pyx_t_12));
              __pyx_t_12 = 0;
              __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
              __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
              __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0;
              goto __pyx_L14_exception_handled;
            }
            goto __pyx_L15_except_error;
            __pyx_L15_except_error:;

            /* "lupa/_lupa.pyx":646
 *                     s = lua.lua_tolstring(L, -1, &size)
 *                     if s:
 *                         try:             # <<<<<<<<<<<<<<
 *                             py_string = s[:size].decode(encoding)
 *                         except UnicodeDecodeError:
 */
            __Pyx_XGIVEREF(__pyx_t_6);
            __Pyx_XGIVEREF(__pyx_t_7);
            __Pyx_XGIVEREF(__pyx_t_8);
            __Pyx_ExceptionReset(__pyx_t_6, __pyx_t_7, __pyx_t_8);
            goto __pyx_L6_error;
            __pyx_L14_exception_handled:;
            __Pyx_XGIVEREF(__pyx_t_6);
            __Pyx_XGIVEREF(__pyx_t_7);
            __Pyx_XGIVEREF(__pyx_t_8);
            __Pyx_ExceptionReset(__pyx_t_6, __pyx_t_7, __pyx_t_8);
            __pyx_L18_try_end:;
          }

          /* "lupa/_lupa.pyx":645
 *                 if not lua.lua_isnil(L, -1) and lua.lua_pcall(L, 1, 1, 0) == 0:
 *                     s = lua.lua_tolstring(L, -1, &size)
 *                     if s:             # <<<<<<<<<<<<<<
 *                         try:
 *                             py_string = s[:size].decode(encoding)
 */
        }

        /* "lupa/_lupa.pyx":643
 *                 lua.lua_pushlstring(L, "__tostring", 10)
 *                 lua.lua_rawget(L, -2)
 *                 if not lua.lua_isnil(L, -1) and lua.lua_pcall(L, 1, 1, 0) == 0:             # <<<<<<<<<<<<<<
 *                     s = lua.lua_tolstring(L, -1, &size)
 *                     if s:
 */
      }

      /* "lupa/_lupa.pyx":640
 *             self.push_lua_object()
 *             # lookup and call "__tostring" metatable method manually to catch any errors
 *             if lua.lua_getmetatable(L, -1):             # <<<<<<<<<<<<<<
 *                 lua.lua_pushlstring(L, "__tostring", 10)
 *                 lua.lua_rawget(L, -2)
 */
    }

    /* "lupa/_lupa.pyx":651
 *                             # safe 'decode'
 *                             py_string = s[:size].decode('ISO-8859-1')
 *             if py_string is None:             # <<<<<<<<<<<<<<
 *                 lua.lua_settop(L, old_top + 1)
 *                 py_string = lua_object_repr(L, encoding)
 */
    __pyx_t_1 = (__pyx_v_py_string == ((PyObject*)Py_None));
    __pyx_t_5 = (__pyx_t_1 != 0);
    if (__pyx_t_5) {

      /* "lupa/_lupa.pyx":652
 *                             py_string = s[:size].decode('ISO-8859-1')
 *             if py_string is None:
 *                 lua.lua_settop(L, old_top + 1)             # <<<<<<<<<<<<<<
 *                 py_string = lua_object_repr(L, encoding)
 *         finally:
 */
      __pyx_t_11 = __Pyx_PyInt_AddObjC(__pyx_v_old_top, __pyx_int_1, 1, 0, 0); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 652, __pyx_L6_error)
      __Pyx_GOTREF(__pyx_t_11);
      __pyx_t_4 = __Pyx_PyInt_As_int(__pyx_t_11); if (unlikely((__pyx_t_4 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 652, __pyx_L6_error)
      __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
      lua_settop(__pyx_v_L, __pyx_t_4);

      /* "lupa/_lupa.pyx":653
 *             if py_string is None:
 *                 lua.lua_settop(L, old_top + 1)
 *                 py_string = lua_object_repr(L, encoding)             # <<<<<<<<<<<<<<
 *         finally:
 *             lua.lua_settop(L, old_top)
 */
      __pyx_t_11 = __pyx_f_4lupa_5_lupa_lua_object_repr(__pyx_v_L, __pyx_v_encoding); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 653, __pyx_L6_error)
      __Pyx_GOTREF(__pyx_t_11);
      if (!(likely(PyUnicode_CheckExact(__pyx_t_11))||((__pyx_t_11) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "unicode", Py_TYPE(__pyx_t_11)->tp_name), 0))) __PYX_ERR(0, 653, __pyx_L6_error)
      __Pyx_DECREF_SET(__pyx_v_py_string, ((PyObject*)__pyx_t_11));
      __pyx_t_11 = 0;

      /* "lupa/_lupa.pyx":651
 *                             # safe 'decode'
 *                             py_string = s[:size].decode('ISO-8859-1')
 *             if py_string is None:             # <<<<<<<<<<<<<<
 *                 lua.lua_settop(L, old_top + 1)
 *                 py_string = lua_object_repr(L, encoding)
 */
    }
  }

  /* "lupa/_lupa.pyx":655
 *                 py_string = lua_object_repr(L, encoding)
 *         finally:
 *             lua.lua_settop(L, old_top)             # <<<<<<<<<<<<<<
 *             unlock_runtime(self._runtime)
 *         return py_string
 */
  /*finally:*/ {
    /*normal exit:*/{
      __pyx_t_4 = __Pyx_PyInt_As_int(__pyx_v_old_top); if (unlikely((__pyx_t_4 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 655, __pyx_L1_error)
      lua_settop(__pyx_v_L, __pyx_t_4);

      /* "lupa/_lupa.pyx":656
 *         finally:
 *             lua.lua_settop(L, old_top)
 *             unlock_runtime(self._runtime)             # <<<<<<<<<<<<<<
 *         return py_string
 * 
 */
      __pyx_t_11 = ((PyObject *)__pyx_v_self->_runtime);
      __Pyx_INCREF(__pyx_t_11);
      __pyx_f_4lupa_5_lupa_unlock_runtime(((struct __pyx_obj_4lupa_5_lupa_LuaRuntime *)__pyx_t_11));
      __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
      goto __pyx_L7;
    }
    __pyx_L6_error:;
    /*exception exit:*/{
      __Pyx_PyThreadState_declare
      __Pyx_PyThreadState_assign
      __pyx_t_8 = 0; __pyx_t_7 = 0; __pyx_t_6 = 0; __pyx_t_15 = 0; __pyx_t_16 = 0; __pyx_t_17 = 0;
      __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
      __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0;
      __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0;
      __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
      if (PY_MAJOR_VERSION >= 3) __Pyx_ExceptionSwap(&__pyx_t_15, &__pyx_t_16, &__pyx_t_17);
      if ((PY_MAJOR_VERSION < 3) || unlikely(__Pyx_GetException(&__pyx_t_8, &__pyx_t_7, &__pyx_t_6) < 0)) __Pyx_ErrFetch(&__pyx_t_8, &__pyx_t_7, &__pyx_t_6);
      __Pyx_XGOTREF(__pyx_t_8);
      __Pyx_XGOTREF(__pyx_t_7);
      __Pyx_XGOTREF(__pyx_t_6);
      __Pyx_XGOTREF(__pyx_t_15);
      __Pyx_XGOTREF(__pyx_t_16);
      __Pyx_XGOTREF(__pyx_t_17);
      __pyx_t_4 = __pyx_lineno; __pyx_t_13 = __pyx_clineno; __pyx_t_14 = __pyx_filename;
      {

        /* "lupa/_lupa.pyx":655
 *                 py_string = lua_object_repr(L, encoding)
 *         finally:
 *             lua.lua_settop(L, old_top)             # <<<<<<<<<<<<<<
 *             unlock_runtime(self._runtime)
 *         return py_string
 */
        __pyx_t_18 = __Pyx_PyInt_As_int(__pyx_v_old_top); if (unlikely((__pyx_t_18 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 655, __pyx_L23_error)
        lua_settop(__pyx_v_L, __pyx_t_18);

        /* "lupa/_lupa.pyx":656
 *         finally:
 *             lua.lua_settop(L, old_top)
 *             unlock_runtime(self._runtime)             # <<<<<<<<<<<<<<
 *         return py_string
 * 
 */
        __pyx_t_11 = ((PyObject *)__pyx_v_self->_runtime);
        __Pyx_INCREF(__pyx_t_11);
        __pyx_f_4lupa_5_lupa_unlock_runtime(((struct __pyx_obj_4lupa_5_lupa_LuaRuntime *)__pyx_t_11));
        __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
      }
      if (PY_MAJOR_VERSION >= 3) {
        __Pyx_XGIVEREF(__pyx_t_15);
        __Pyx_XGIVEREF(__pyx_t_16);
        __Pyx_XGIVEREF(__pyx_t_17);
        __Pyx_ExceptionReset(__pyx_t_15, __pyx_t_16, __pyx_t_17);
      }
      __Pyx_XGIVEREF(__pyx_t_8);
      __Pyx_XGIVEREF(__pyx_t_7);
      __Pyx_XGIVEREF(__pyx_t_6);
      __Pyx_ErrRestore(__pyx_t_8, __pyx_t_7, __pyx_t_6);
      __pyx_t_8 = 0; __pyx_t_7 = 0; __pyx_t_6 = 0; __pyx_t_15 = 0; __pyx_t_16 = 0; __pyx_t_17 = 0;
      __pyx_lineno = __pyx_t_4; __pyx_clineno = __pyx_t_13; __pyx_filename = __pyx_t_14;
      goto __pyx_L1_error;
      __pyx_L23_error:;
      if (PY_MAJOR_VERSION >= 3) {
        __Pyx_XGIVEREF(__pyx_t_15);
        __Pyx_XGIVEREF(__pyx_t_16);
        __Pyx_XGIVEREF(__pyx_t_17);
        __Pyx_ExceptionReset(__pyx_t_15, __pyx_t_16, __pyx_t_17);
      }
      __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
      __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
      __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
      __pyx_t_15 = 0; __pyx_t_16 = 0; __pyx_t_17 = 0;
      goto __pyx_L1_error;
    }
    __pyx_L7:;
  }

  /* "lupa/_lupa.pyx":657
 *             lua.lua_settop(L, old_top)
 *             unlock_runtime(self._runtime)
 *         return py_string             # <<<<<<<<<<<<<<
 * 
 *     def __getattr__(self, name):
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v_py_string);
  __pyx_r = __pyx_v_py_string;
  goto __pyx_L0;

  /* "lupa/_lupa.pyx":628
 *             unlock_runtime(self._runtime)
 * 
 *     def __str__(self):             # <<<<<<<<<<<<<<
 *         assert self._runtime is not None
 *         cdef lua_State* L = self._state
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_10);
  __Pyx_XDECREF(__pyx_t_11);
  __Pyx_XDECREF(__pyx_t_12);
  __Pyx_AddTraceback("lupa._lupa._LuaObject.__str__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_py_string);
  __Pyx_XDECREF(__pyx_v_encoding);
  __Pyx_XDECREF(__pyx_v_old_top);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lupa/_lupa.pyx":659
 *         return py_string
 * 
 *     def __getattr__(self, name):             # <<<<<<<<<<<<<<
 *         assert self._runtime is not None
 *         if isinstance(name, unicode):
 */

/* Python wrapper */
static PyObject *__pyx_pw_4lupa_5_lupa_10_LuaObject_17__getattr__(PyObject *__pyx_v_self, PyObject *__pyx_v_name); /*proto*/
static PyObject *__pyx_pw_4lupa_5_lupa_10_LuaObject_17__getattr__(PyObject *__pyx_v_self, PyObject *__pyx_v_name) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__getattr__ (wrapper)", 0);
  __pyx_r = __pyx_pf_4lupa_5_lupa_10_LuaObject_16__getattr__(((struct __pyx_obj_4lupa_5_lupa__LuaObject *)__pyx_v_self), ((PyObject *)__pyx_v_name));

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

static PyObject *__pyx_pf_4lupa_5_lupa_10_LuaObject_16__getattr__(struct __pyx_obj_4lupa_5_lupa__LuaObject *__pyx_v_self, PyObject *__pyx_v_name) {
  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;
  char const *__pyx_t_8;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__getattr__", 0);
  __Pyx_INCREF(__pyx_v_name);

  /* "lupa/_lupa.pyx":660
 * 
 *     def __getattr__(self, name):
 *         assert self._runtime is not None             # <<<<<<<<<<<<<<
 *         if isinstance(name, unicode):
 *             if (<unicode>name).startswith(u'__') and (<unicode>name).endswith(u'__'):
 */
  #ifndef CYTHON_WITHOUT_ASSERTIONS
  if (unlikely(!Py_OptimizeFlag)) {
    __pyx_t_1 = (((PyObject *)__pyx_v_self->_runtime) != Py_None);
    if (unlikely(!(__pyx_t_1 != 0))) {
      PyErr_SetNone(PyExc_AssertionError);
      __PYX_ERR(0, 660, __pyx_L1_error)
    }
  }
  #endif

  /* "lupa/_lupa.pyx":661
 *     def __getattr__(self, name):
 *         assert self._runtime is not None
 *         if isinstance(name, unicode):             # <<<<<<<<<<<<<<
 *             if (<unicode>name).startswith(u'__') and (<unicode>name).endswith(u'__'):
 *                 return object.__getattr__(self, name)
 */
  __pyx_t_1 = PyUnicode_Check(__pyx_v_name); 
  __pyx_t_2 = (__pyx_t_1 != 0);
  if (__pyx_t_2) {

    /* "lupa/_lupa.pyx":662
 *         assert self._runtime is not None
 *         if isinstance(name, unicode):
 *             if (<unicode>name).startswith(u'__') and (<unicode>name).endswith(u'__'):             # <<<<<<<<<<<<<<
 *                 return object.__getattr__(self, name)
 *             name = (<unicode>name).encode(self._runtime._source_encoding)
 */
    if (unlikely(__pyx_v_name == Py_None)) {
      PyErr_Format(PyExc_AttributeError, "'NoneType' object has no attribute '%.30s'", "startswith");
      __PYX_ERR(0, 662, __pyx_L1_error)
    }
    __pyx_t_1 = __Pyx_PyUnicode_Tailmatch(((PyObject*)__pyx_v_name), __pyx_n_u__16, 0, PY_SSIZE_T_MAX, -1); if (unlikely(__pyx_t_1 == ((int)-1))) __PYX_ERR(0, 662, __pyx_L1_error)
    if ((__pyx_t_1 != 0)) {
    } else {
      __pyx_t_2 = (__pyx_t_1 != 0);
      goto __pyx_L5_bool_binop_done;
    }
    if (unlikely(__pyx_v_name == Py_None)) {
      PyErr_Format(PyExc_AttributeError, "'NoneType' object has no attribute '%.30s'", "endswith");
      __PYX_ERR(0, 662, __pyx_L1_error)
    }
    __pyx_t_1 = __Pyx_PyUnicode_Tailmatch(((PyObject*)__pyx_v_name), __pyx_n_u__16, 0, PY_SSIZE_T_MAX, 1); if (unlikely(__pyx_t_1 == ((int)-1))) __PYX_ERR(0, 662, __pyx_L1_error)
    __pyx_t_2 = (__pyx_t_1 != 0);
    __pyx_L5_bool_binop_done:;
    if (__pyx_t_2) {

      /* "lupa/_lupa.pyx":663
 *         if isinstance(name, unicode):
 *             if (<unicode>name).startswith(u'__') and (<unicode>name).endswith(u'__'):
 *                 return object.__getattr__(self, name)             # <<<<<<<<<<<<<<
 *             name = (<unicode>name).encode(self._runtime._source_encoding)
 *         elif isinstance(name, bytes):
 */
      __Pyx_XDECREF(__pyx_r);
      __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_builtin_object, __pyx_n_s_getattr); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 663, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_t_5 = NULL;
      __pyx_t_6 = 0;
      if (CYTHON_UNPACK_METHODS && likely(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_6 = 1;
        }
      }
      #if CYTHON_FAST_PYCALL
      if (PyFunction_Check(__pyx_t_4)) {
        PyObject *__pyx_temp[3] = {__pyx_t_5, ((PyObject *)__pyx_v_self), __pyx_v_name};
        __pyx_t_3 = __Pyx_PyFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_6, 2+__pyx_t_6); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 663, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
        __Pyx_GOTREF(__pyx_t_3);
      } else
      #endif
      #if CYTHON_FAST_PYCCALL
      if (__Pyx_PyFastCFunction_Check(__pyx_t_4)) {
        PyObject *__pyx_temp[3] = {__pyx_t_5, ((PyObject *)__pyx_v_self), __pyx_v_name};
        __pyx_t_3 = __Pyx_PyCFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_6, 2+__pyx_t_6); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 663, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
        __Pyx_GOTREF(__pyx_t_3);
      } else
      #endif
      {
        __pyx_t_7 = PyTuple_New(2+__pyx_t_6); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 663, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_7);
        if (__pyx_t_5) {
          __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_5); __pyx_t_5 = NULL;
        }
        __Pyx_INCREF(((PyObject *)__pyx_v_self));
        __Pyx_GIVEREF(((PyObject *)__pyx_v_self));
        PyTuple_SET_ITEM(__pyx_t_7, 0+__pyx_t_6, ((PyObject *)__pyx_v_self));
        __Pyx_INCREF(__pyx_v_name);
        __Pyx_GIVEREF(__pyx_v_name);
        PyTuple_SET_ITEM(__pyx_t_7, 1+__pyx_t_6, __pyx_v_name);
        __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_7, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 663, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_3);
        __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      }
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __pyx_r = __pyx_t_3;
      __pyx_t_3 = 0;
      goto __pyx_L0;

      /* "lupa/_lupa.pyx":662
 *         assert self._runtime is not None
 *         if isinstance(name, unicode):
 *             if (<unicode>name).startswith(u'__') and (<unicode>name).endswith(u'__'):             # <<<<<<<<<<<<<<
 *                 return object.__getattr__(self, name)
 *             name = (<unicode>name).encode(self._runtime._source_encoding)
 */
    }

    /* "lupa/_lupa.pyx":664
 *             if (<unicode>name).startswith(u'__') and (<unicode>name).endswith(u'__'):
 *                 return object.__getattr__(self, name)
 *             name = (<unicode>name).encode(self._runtime._source_encoding)             # <<<<<<<<<<<<<<
 *         elif isinstance(name, bytes):
 *             if (<bytes>name).startswith(b'__') and (<bytes>name).endswith(b'__'):
 */
    if (unlikely(__pyx_v_name == Py_None)) {
      PyErr_Format(PyExc_AttributeError, "'NoneType' object has no attribute '%.30s'", "encode");
      __PYX_ERR(0, 664, __pyx_L1_error)
    }
    if (unlikely(__pyx_v_self->_runtime->_source_encoding == Py_None)) {
      PyErr_SetString(PyExc_TypeError, "expected bytes, NoneType found");
      __PYX_ERR(0, 664, __pyx_L1_error)
    }
    __pyx_t_8 = __Pyx_PyBytes_AsString(__pyx_v_self->_runtime->_source_encoding); if (unlikely((!__pyx_t_8) && PyErr_Occurred())) __PYX_ERR(0, 664, __pyx_L1_error)
    __pyx_t_3 = PyUnicode_AsEncodedString(((PyObject*)__pyx_v_name), __pyx_t_8, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 664, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF_SET(__pyx_v_name, __pyx_t_3);
    __pyx_t_3 = 0;

    /* "lupa/_lupa.pyx":661
 *     def __getattr__(self, name):
 *         assert self._runtime is not None
 *         if isinstance(name, unicode):             # <<<<<<<<<<<<<<
 *             if (<unicode>name).startswith(u'__') and (<unicode>name).endswith(u'__'):
 *                 return object.__getattr__(self, name)
 */
    goto __pyx_L3;
  }

  /* "lupa/_lupa.pyx":665
 *                 return object.__getattr__(self, name)
 *             name = (<unicode>name).encode(self._runtime._source_encoding)
 *         elif isinstance(name, bytes):             # <<<<<<<<<<<<<<
 *             if (<bytes>name).startswith(b'__') and (<bytes>name).endswith(b'__'):
 *                 return object.__getattr__(self, name)
 */
  __pyx_t_2 = PyBytes_Check(__pyx_v_name); 
  __pyx_t_1 = (__pyx_t_2 != 0);
  if (__pyx_t_1) {

    /* "lupa/_lupa.pyx":666
 *             name = (<unicode>name).encode(self._runtime._source_encoding)
 *         elif isinstance(name, bytes):
 *             if (<bytes>name).startswith(b'__') and (<bytes>name).endswith(b'__'):             # <<<<<<<<<<<<<<
 *                 return object.__getattr__(self, name)
 *         return self._getitem(name, is_attr_access=True)
 */
    if (unlikely(__pyx_v_name == Py_None)) {
      PyErr_Format(PyExc_AttributeError, "'NoneType' object has no attribute '%.30s'", "startswith");
      __PYX_ERR(0, 666, __pyx_L1_error)
    }
    __pyx_t_2 = __Pyx_PyBytes_Tailmatch(((PyObject*)__pyx_v_name), __pyx_n_b__16, 0, PY_SSIZE_T_MAX, -1); if (unlikely(__pyx_t_2 == ((int)-1))) __PYX_ERR(0, 666, __pyx_L1_error)
    if ((__pyx_t_2 != 0)) {
    } else {
      __pyx_t_1 = (__pyx_t_2 != 0);
      goto __pyx_L8_bool_binop_done;
    }
    if (unlikely(__pyx_v_name == Py_None)) {
      PyErr_Format(PyExc_AttributeError, "'NoneType' object has no attribute '%.30s'", "endswith");
      __PYX_ERR(0, 666, __pyx_L1_error)
    }
    __pyx_t_2 = __Pyx_PyBytes_Tailmatch(((PyObject*)__pyx_v_name), __pyx_n_b__16, 0, PY_SSIZE_T_MAX, 1); if (unlikely(__pyx_t_2 == ((int)-1))) __PYX_ERR(0, 666, __pyx_L1_error)
    __pyx_t_1 = (__pyx_t_2 != 0);
    __pyx_L8_bool_binop_done:;
    if (__pyx_t_1) {

      /* "lupa/_lupa.pyx":667
 *         elif isinstance(name, bytes):
 *             if (<bytes>name).startswith(b'__') and (<bytes>name).endswith(b'__'):
 *                 return object.__getattr__(self, name)             # <<<<<<<<<<<<<<
 *         return self._getitem(name, is_attr_access=True)
 * 
 */
      __Pyx_XDECREF(__pyx_r);
      __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_builtin_object, __pyx_n_s_getattr); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 667, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_t_7 = NULL;
      __pyx_t_6 = 0;
      if (CYTHON_UNPACK_METHODS && likely(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_6 = 1;
        }
      }
      #if CYTHON_FAST_PYCALL
      if (PyFunction_Check(__pyx_t_4)) {
        PyObject *__pyx_temp[3] = {__pyx_t_7, ((PyObject *)__pyx_v_self), __pyx_v_name};
        __pyx_t_3 = __Pyx_PyFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_6, 2+__pyx_t_6); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 667, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
        __Pyx_GOTREF(__pyx_t_3);
      } else
      #endif
      #if CYTHON_FAST_PYCCALL
      if (__Pyx_PyFastCFunction_Check(__pyx_t_4)) {
        PyObject *__pyx_temp[3] = {__pyx_t_7, ((PyObject *)__pyx_v_self), __pyx_v_name};
        __pyx_t_3 = __Pyx_PyCFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_6, 2+__pyx_t_6); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 667, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
        __Pyx_GOTREF(__pyx_t_3);
      } else
      #endif
      {
        __pyx_t_5 = PyTuple_New(2+__pyx_t_6); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 667, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_5);
        if (__pyx_t_7) {
          __Pyx_GIVEREF(__pyx_t_7); PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_7); __pyx_t_7 = NULL;
        }
        __Pyx_INCREF(((PyObject *)__pyx_v_self));
        __Pyx_GIVEREF(((PyObject *)__pyx_v_self));
        PyTuple_SET_ITEM(__pyx_t_5, 0+__pyx_t_6, ((PyObject *)__pyx_v_self));
        __Pyx_INCREF(__pyx_v_name);
        __Pyx_GIVEREF(__pyx_v_name);
        PyTuple_SET_ITEM(__pyx_t_5, 1+__pyx_t_6, __pyx_v_name);
        __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_5, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 667, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_3);
        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      }
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __pyx_r = __pyx_t_3;
      __pyx_t_3 = 0;
      goto __pyx_L0;

      /* "lupa/_lupa.pyx":666
 *             name = (<unicode>name).encode(self._runtime._source_encoding)
 *         elif isinstance(name, bytes):
 *             if (<bytes>name).startswith(b'__') and (<bytes>name).endswith(b'__'):             # <<<<<<<<<<<<<<
 *                 return object.__getattr__(self, name)
 *         return self._getitem(name, is_attr_access=True)
 */
    }

    /* "lupa/_lupa.pyx":665
 *                 return object.__getattr__(self, name)
 *             name = (<unicode>name).encode(self._runtime._source_encoding)
 *         elif isinstance(name, bytes):             # <<<<<<<<<<<<<<
 *             if (<bytes>name).startswith(b'__') and (<bytes>name).endswith(b'__'):
 *                 return object.__getattr__(self, name)
 */
  }
  __pyx_L3:;

  /* "lupa/_lupa.pyx":668
 *             if (<bytes>name).startswith(b'__') and (<bytes>name).endswith(b'__'):
 *                 return object.__getattr__(self, name)
 *         return self._getitem(name, is_attr_access=True)             # <<<<<<<<<<<<<<
 * 
 *     def __getitem__(self, index_or_name):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_3 = __pyx_f_4lupa_5_lupa_10_LuaObject__getitem(__pyx_v_self, __pyx_v_name, 1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 668, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_r = __pyx_t_3;
  __pyx_t_3 = 0;
  goto __pyx_L0;

  /* "lupa/_lupa.pyx":659
 *         return py_string
 * 
 *     def __getattr__(self, name):             # <<<<<<<<<<<<<<
 *         assert self._runtime is not None
 *         if isinstance(name, unicode):
 */

  /* 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_AddTraceback("lupa._lupa._LuaObject.__getattr__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_name);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lupa/_lupa.pyx":670
 *         return self._getitem(name, is_attr_access=True)
 * 
 *     def __getitem__(self, index_or_name):             # <<<<<<<<<<<<<<
 *         return self._getitem(index_or_name, is_attr_access=False)
 * 
 */

/* Python wrapper */
static PyObject *__pyx_pw_4lupa_5_lupa_10_LuaObject_19__getitem__(PyObject *__pyx_v_self, PyObject *__pyx_v_index_or_name); /*proto*/
static PyObject *__pyx_pw_4lupa_5_lupa_10_LuaObject_19__getitem__(PyObject *__pyx_v_self, PyObject *__pyx_v_index_or_name) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__getitem__ (wrapper)", 0);
  __pyx_r = __pyx_pf_4lupa_5_lupa_10_LuaObject_18__getitem__(((struct __pyx_obj_4lupa_5_lupa__LuaObject *)__pyx_v_self), ((PyObject *)__pyx_v_index_or_name));

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

static PyObject *__pyx_pf_4lupa_5_lupa_10_LuaObject_18__getitem__(struct __pyx_obj_4lupa_5_lupa__LuaObject *__pyx_v_self, PyObject *__pyx_v_index_or_name) {
  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("__getitem__", 0);

  /* "lupa/_lupa.pyx":671
 * 
 *     def __getitem__(self, index_or_name):
 *         return self._getitem(index_or_name, is_attr_access=False)             # <<<<<<<<<<<<<<
 * 
 *     @cython.final
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __pyx_f_4lupa_5_lupa_10_LuaObject__getitem(__pyx_v_self, __pyx_v_index_or_name, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 671, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "lupa/_lupa.pyx":670
 *         return self._getitem(name, is_attr_access=True)
 * 
 *     def __getitem__(self, index_or_name):             # <<<<<<<<<<<<<<
 *         return self._getitem(index_or_name, is_attr_access=False)
 * 
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("lupa._lupa._LuaObject.__getitem__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lupa/_lupa.pyx":674
 * 
 *     @cython.final
 *     cdef _getitem(self, name, bint is_attr_access):             # <<<<<<<<<<<<<<
 *         cdef lua_State* L = self._state
 *         lock_runtime(self._runtime)
 */

static PyObject *__pyx_f_4lupa_5_lupa_10_LuaObject__getitem(struct __pyx_obj_4lupa_5_lupa__LuaObject *__pyx_v_self, PyObject *__pyx_v_name, int __pyx_v_is_attr_access) {
  lua_State *__pyx_v_L;
  int __pyx_v_old_top;
  int __pyx_v_lua_type;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  lua_State *__pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  int __pyx_t_3;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  struct __pyx_opt_args_4lupa_5_lupa_py_to_lua __pyx_t_6;
  int __pyx_t_7;
  char const *__pyx_t_8;
  PyObject *__pyx_t_9 = NULL;
  PyObject *__pyx_t_10 = NULL;
  PyObject *__pyx_t_11 = NULL;
  PyObject *__pyx_t_12 = NULL;
  PyObject *__pyx_t_13 = NULL;
  PyObject *__pyx_t_14 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("_getitem", 0);

  /* "lupa/_lupa.pyx":675
 *     @cython.final
 *     cdef _getitem(self, name, bint is_attr_access):
 *         cdef lua_State* L = self._state             # <<<<<<<<<<<<<<
 *         lock_runtime(self._runtime)
 *         old_top = lua.lua_gettop(L)
 */
  __pyx_t_1 = __pyx_v_self->_state;
  __pyx_v_L = __pyx_t_1;

  /* "lupa/_lupa.pyx":676
 *     cdef _getitem(self, name, bint is_attr_access):
 *         cdef lua_State* L = self._state
 *         lock_runtime(self._runtime)             # <<<<<<<<<<<<<<
 *         old_top = lua.lua_gettop(L)
 *         try:
 */
  __pyx_t_2 = ((PyObject *)__pyx_v_self->_runtime);
  __Pyx_INCREF(__pyx_t_2);
  __pyx_t_3 = __pyx_f_4lupa_5_lupa_lock_runtime(((struct __pyx_obj_4lupa_5_lupa_LuaRuntime *)__pyx_t_2)); if (unlikely(__pyx_t_3 == ((int)-1))) __PYX_ERR(0, 676, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "lupa/_lupa.pyx":677
 *         cdef lua_State* L = self._state
 *         lock_runtime(self._runtime)
 *         old_top = lua.lua_gettop(L)             # <<<<<<<<<<<<<<
 *         try:
 *             self.push_lua_object()
 */
  __pyx_v_old_top = lua_gettop(__pyx_v_L);

  /* "lupa/_lupa.pyx":678
 *         lock_runtime(self._runtime)
 *         old_top = lua.lua_gettop(L)
 *         try:             # <<<<<<<<<<<<<<
 *             self.push_lua_object()
 *             lua_type = lua.lua_type(L, -1)
 */
  /*try:*/ {

    /* "lupa/_lupa.pyx":679
 *         old_top = lua.lua_gettop(L)
 *         try:
 *             self.push_lua_object()             # <<<<<<<<<<<<<<
 *             lua_type = lua.lua_type(L, -1)
 *             if lua_type == lua.LUA_TFUNCTION or lua_type == lua.LUA_TTHREAD:
 */
    __pyx_t_3 = __pyx_f_4lupa_5_lupa_10_LuaObject_push_lua_object(__pyx_v_self); if (unlikely(__pyx_t_3 == ((int)-1))) __PYX_ERR(0, 679, __pyx_L4_error)

    /* "lupa/_lupa.pyx":680
 *         try:
 *             self.push_lua_object()
 *             lua_type = lua.lua_type(L, -1)             # <<<<<<<<<<<<<<
 *             if lua_type == lua.LUA_TFUNCTION or lua_type == lua.LUA_TTHREAD:
 *                 lua.lua_pop(L, 1)
 */
    __pyx_v_lua_type = lua_type(__pyx_v_L, -1);

    /* "lupa/_lupa.pyx":681
 *             self.push_lua_object()
 *             lua_type = lua.lua_type(L, -1)
 *             if lua_type == lua.LUA_TFUNCTION or lua_type == lua.LUA_TTHREAD:             # <<<<<<<<<<<<<<
 *                 lua.lua_pop(L, 1)
 *                 raise (AttributeError if is_attr_access else TypeError)(
 */
    switch (__pyx_v_lua_type) {
      case LUA_TFUNCTION:
      case LUA_TTHREAD:

      /* "lupa/_lupa.pyx":682
 *             lua_type = lua.lua_type(L, -1)
 *             if lua_type == lua.LUA_TFUNCTION or lua_type == lua.LUA_TTHREAD:
 *                 lua.lua_pop(L, 1)             # <<<<<<<<<<<<<<
 *                 raise (AttributeError if is_attr_access else TypeError)(
 *                     "item/attribute access not supported on functions")
 */
      lua_pop(__pyx_v_L, 1);

      /* "lupa/_lupa.pyx":683
 *             if lua_type == lua.LUA_TFUNCTION or lua_type == lua.LUA_TTHREAD:
 *                 lua.lua_pop(L, 1)
 *                 raise (AttributeError if is_attr_access else TypeError)(             # <<<<<<<<<<<<<<
 *                     "item/attribute access not supported on functions")
 *             # table[nil] fails, so map None -> python.none for Lua tables
 */
      if ((__pyx_v_is_attr_access != 0)) {
        __Pyx_INCREF(__pyx_builtin_AttributeError);
        __pyx_t_4 = __pyx_builtin_AttributeError;
      } else {
        __Pyx_INCREF(__pyx_builtin_TypeError);
        __pyx_t_4 = __pyx_builtin_TypeError;
      }
      __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_2 = (__pyx_t_5) ? __Pyx_PyObject_Call2Args(__pyx_t_4, __pyx_t_5, __pyx_kp_s_item_attribute_access_not_suppor) : __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_kp_s_item_attribute_access_not_suppor);
      __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
      if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 683, __pyx_L4_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, 683, __pyx_L4_error)

      /* "lupa/_lupa.pyx":681
 *             self.push_lua_object()
 *             lua_type = lua.lua_type(L, -1)
 *             if lua_type == lua.LUA_TFUNCTION or lua_type == lua.LUA_TTHREAD:             # <<<<<<<<<<<<<<
 *                 lua.lua_pop(L, 1)
 *                 raise (AttributeError if is_attr_access else TypeError)(
 */
      break;
      default: break;
    }

    /* "lupa/_lupa.pyx":686
 *                     "item/attribute access not supported on functions")
 *             # table[nil] fails, so map None -> python.none for Lua tables
 *             py_to_lua(self._runtime, L, name, wrap_none=lua_type == lua.LUA_TTABLE)             # <<<<<<<<<<<<<<
 *             lua.lua_gettable(L, -2)
 *             return py_from_lua(self._runtime, L, -1)
 */
    __pyx_t_2 = ((PyObject *)__pyx_v_self->_runtime);
    __Pyx_INCREF(__pyx_t_2);
    __pyx_t_6.__pyx_n = 1;
    __pyx_t_6.wrap_none = (__pyx_v_lua_type == LUA_TTABLE);
    __pyx_t_3 = __pyx_f_4lupa_5_lupa_py_to_lua(((struct __pyx_obj_4lupa_5_lupa_LuaRuntime *)__pyx_t_2), __pyx_v_L, __pyx_v_name, &__pyx_t_6); if (unlikely(__pyx_t_3 == ((int)-1))) __PYX_ERR(0, 686, __pyx_L4_error)
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

    /* "lupa/_lupa.pyx":687
 *             # table[nil] fails, so map None -> python.none for Lua tables
 *             py_to_lua(self._runtime, L, name, wrap_none=lua_type == lua.LUA_TTABLE)
 *             lua.lua_gettable(L, -2)             # <<<<<<<<<<<<<<
 *             return py_from_lua(self._runtime, L, -1)
 *         finally:
 */
    lua_gettable(__pyx_v_L, -2);

    /* "lupa/_lupa.pyx":688
 *             py_to_lua(self._runtime, L, name, wrap_none=lua_type == lua.LUA_TTABLE)
 *             lua.lua_gettable(L, -2)
 *             return py_from_lua(self._runtime, L, -1)             # <<<<<<<<<<<<<<
 *         finally:
 *             lua.lua_settop(L, old_top)
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_2 = ((PyObject *)__pyx_v_self->_runtime);
    __Pyx_INCREF(__pyx_t_2);
    __pyx_t_4 = __pyx_f_4lupa_5_lupa_py_from_lua(((struct __pyx_obj_4lupa_5_lupa_LuaRuntime *)__pyx_t_2), __pyx_v_L, -1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 688, __pyx_L4_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_L3_return;
  }

  /* "lupa/_lupa.pyx":690
 *             return py_from_lua(self._runtime, L, -1)
 *         finally:
 *             lua.lua_settop(L, old_top)             # <<<<<<<<<<<<<<
 *             unlock_runtime(self._runtime)
 * 
 */
  /*finally:*/ {
    __pyx_L4_error:;
    /*exception exit:*/{
      __Pyx_PyThreadState_declare
      __Pyx_PyThreadState_assign
      __pyx_t_9 = 0; __pyx_t_10 = 0; __pyx_t_11 = 0; __pyx_t_12 = 0; __pyx_t_13 = 0; __pyx_t_14 = 0;
      __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
      __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
      if (PY_MAJOR_VERSION >= 3) __Pyx_ExceptionSwap(&__pyx_t_12, &__pyx_t_13, &__pyx_t_14);
      if ((PY_MAJOR_VERSION < 3) || unlikely(__Pyx_GetException(&__pyx_t_9, &__pyx_t_10, &__pyx_t_11) < 0)) __Pyx_ErrFetch(&__pyx_t_9, &__pyx_t_10, &__pyx_t_11);
      __Pyx_XGOTREF(__pyx_t_9);
      __Pyx_XGOTREF(__pyx_t_10);
      __Pyx_XGOTREF(__pyx_t_11);
      __Pyx_XGOTREF(__pyx_t_12);
      __Pyx_XGOTREF(__pyx_t_13);
      __Pyx_XGOTREF(__pyx_t_14);
      __pyx_t_3 = __pyx_lineno; __pyx_t_7 = __pyx_clineno; __pyx_t_8 = __pyx_filename;
      {
        lua_settop(__pyx_v_L, __pyx_v_old_top);

        /* "lupa/_lupa.pyx":691
 *         finally:
 *             lua.lua_settop(L, old_top)
 *             unlock_runtime(self._runtime)             # <<<<<<<<<<<<<<
 * 
 * 
 */
        __pyx_t_4 = ((PyObject *)__pyx_v_self->_runtime);
        __Pyx_INCREF(__pyx_t_4);
        __pyx_f_4lupa_5_lupa_unlock_runtime(((struct __pyx_obj_4lupa_5_lupa_LuaRuntime *)__pyx_t_4));
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      }
      if (PY_MAJOR_VERSION >= 3) {
        __Pyx_XGIVEREF(__pyx_t_12);
        __Pyx_XGIVEREF(__pyx_t_13);
        __Pyx_XGIVEREF(__pyx_t_14);
        __Pyx_ExceptionReset(__pyx_t_12, __pyx_t_13, __pyx_t_14);
      }
      __Pyx_XGIVEREF(__pyx_t_9);
      __Pyx_XGIVEREF(__pyx_t_10);
      __Pyx_XGIVEREF(__pyx_t_11);
      __Pyx_ErrRestore(__pyx_t_9, __pyx_t_10, __pyx_t_11);
      __pyx_t_9 = 0; __pyx_t_10 = 0; __pyx_t_11 = 0; __pyx_t_12 = 0; __pyx_t_13 = 0; __pyx_t_14 = 0;
      __pyx_lineno = __pyx_t_3; __pyx_clineno = __pyx_t_7; __pyx_filename = __pyx_t_8;
      goto __pyx_L1_error;
    }
    __pyx_L3_return: {
      __pyx_t_14 = __pyx_r;
      __pyx_r = 0;

      /* "lupa/_lupa.pyx":690
 *             return py_from_lua(self._runtime, L, -1)
 *         finally:
 *             lua.lua_settop(L, old_top)             # <<<<<<<<<<<<<<
 *             unlock_runtime(self._runtime)
 * 
 */
      lua_settop(__pyx_v_L, __pyx_v_old_top);

      /* "lupa/_lupa.pyx":691
 *         finally:
 *             lua.lua_settop(L, old_top)
 *             unlock_runtime(self._runtime)             # <<<<<<<<<<<<<<
 * 
 * 
 */
      __pyx_t_4 = ((PyObject *)__pyx_v_self->_runtime);
      __Pyx_INCREF(__pyx_t_4);
      __pyx_f_4lupa_5_lupa_unlock_runtime(((struct __pyx_obj_4lupa_5_lupa_LuaRuntime *)__pyx_t_4));
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __pyx_r = __pyx_t_14;
      __pyx_t_14 = 0;
      goto __pyx_L0;
    }
  }

  /* "lupa/_lupa.pyx":674
 * 
 *     @cython.final
 *     cdef _getitem(self, name, bint is_attr_access):             # <<<<<<<<<<<<<<
 *         cdef lua_State* L = self._state
 *         lock_runtime(self._runtime)
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_AddTraceback("lupa._lupa._LuaObject._getitem", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "(tree fragment)":1
 * def __reduce_cython__(self):             # <<<<<<<<<<<<<<
 *     raise TypeError("self._state cannot be converted to a Python object for pickling")
 * def __setstate_cython__(self, __pyx_state):
 */

/* Python wrapper */
static PyObject *__pyx_pw_4lupa_5_lupa_10_LuaObject_21__reduce_cython__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static char __pyx_doc_4lupa_5_lupa_10_LuaObject_20__reduce_cython__[] = "_LuaObject.__reduce_cython__(self)";
static PyMethodDef __pyx_mdef_4lupa_5_lupa_10_LuaObject_21__reduce_cython__ = {"__reduce_cython__", (PyCFunction)__pyx_pw_4lupa_5_lupa_10_LuaObject_21__reduce_cython__, METH_NOARGS, __pyx_doc_4lupa_5_lupa_10_LuaObject_20__reduce_cython__};
static PyObject *__pyx_pw_4lupa_5_lupa_10_LuaObject_21__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_4lupa_5_lupa_10_LuaObject_20__reduce_cython__(((struct __pyx_obj_4lupa_5_lupa__LuaObject *)__pyx_v_self));

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

static PyObject *__pyx_pf_4lupa_5_lupa_10_LuaObject_20__reduce_cython__(CYTHON_UNUSED struct __pyx_obj_4lupa_5_lupa__LuaObject *__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("self._state cannot be converted to a Python object for pickling")             # <<<<<<<<<<<<<<
 * def __setstate_cython__(self, __pyx_state):
 *     raise TypeError("self._state cannot be converted to a Python object for pickling")
 */
  __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__17, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 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(2, 2, __pyx_L1_error)

  /* "(tree fragment)":1
 * def __reduce_cython__(self):             # <<<<<<<<<<<<<<
 *     raise TypeError("self._state cannot be converted to a Python object for pickling")
 * def __setstate_cython__(self, __pyx_state):
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("lupa._lupa._LuaObject.__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("self._state cannot be converted to a Python object for pickling")
 * def __setstate_cython__(self, __pyx_state):             # <<<<<<<<<<<<<<
 *     raise TypeError("self._state cannot be converted to a Python object for pickling")
 */

/* Python wrapper */
static PyObject *__pyx_pw_4lupa_5_lupa_10_LuaObject_23__setstate_cython__(PyObject *__pyx_v_self, PyObject *__pyx_v___pyx_state); /*proto*/
static char __pyx_doc_4lupa_5_lupa_10_LuaObject_22__setstate_cython__[] = "_LuaObject.__setstate_cython__(self, __pyx_state)";
static PyMethodDef __pyx_mdef_4lupa_5_lupa_10_LuaObject_23__setstate_cython__ = {"__setstate_cython__", (PyCFunction)__pyx_pw_4lupa_5_lupa_10_LuaObject_23__setstate_cython__, METH_O, __pyx_doc_4lupa_5_lupa_10_LuaObject_22__setstate_cython__};
static PyObject *__pyx_pw_4lupa_5_lupa_10_LuaObject_23__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_4lupa_5_lupa_10_LuaObject_22__setstate_cython__(((struct __pyx_obj_4lupa_5_lupa__LuaObject *)__pyx_v_self), ((PyObject *)__pyx_v___pyx_state));

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

static PyObject *__pyx_pf_4lupa_5_lupa_10_LuaObject_22__setstate_cython__(CYTHON_UNUSED struct __pyx_obj_4lupa_5_lupa__LuaObject *__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("self._state cannot be converted to a Python object for pickling")
 * def __setstate_cython__(self, __pyx_state):
 *     raise TypeError("self._state cannot be converted to a Python object for pickling")             # <<<<<<<<<<<<<<
 */
  __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__18, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 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(2, 4, __pyx_L1_error)

  /* "(tree fragment)":3
 * def __reduce_cython__(self):
 *     raise TypeError("self._state cannot be converted to a Python object for pickling")
 * def __setstate_cython__(self, __pyx_state):             # <<<<<<<<<<<<<<
 *     raise TypeError("self._state cannot be converted to a Python object for pickling")
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("lupa._lupa._LuaObject.__setstate_cython__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lupa/_lupa.pyx":694
 * 
 * 
 * cdef _LuaObject new_lua_object(LuaRuntime runtime, lua_State* L, int n):             # <<<<<<<<<<<<<<
 *     cdef _LuaObject obj = _LuaObject.__new__(_LuaObject)
 *     init_lua_object(obj, runtime, L, n)
 */

static struct __pyx_obj_4lupa_5_lupa__LuaObject *__pyx_f_4lupa_5_lupa_new_lua_object(struct __pyx_obj_4lupa_5_lupa_LuaRuntime *__pyx_v_runtime, lua_State *__pyx_v_L, int __pyx_v_n) {
  struct __pyx_obj_4lupa_5_lupa__LuaObject *__pyx_v_obj = 0;
  struct __pyx_obj_4lupa_5_lupa__LuaObject *__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("new_lua_object", 0);

  /* "lupa/_lupa.pyx":695
 * 
 * cdef _LuaObject new_lua_object(LuaRuntime runtime, lua_State* L, int n):
 *     cdef _LuaObject obj = _LuaObject.__new__(_LuaObject)             # <<<<<<<<<<<<<<
 *     init_lua_object(obj, runtime, L, n)
 *     return obj
 */
  __pyx_t_1 = ((PyObject *)__pyx_tp_new_4lupa_5_lupa__LuaObject(((PyTypeObject *)__pyx_ptype_4lupa_5_lupa__LuaObject), __pyx_empty_tuple, NULL)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 695, __pyx_L1_error)
  __Pyx_GOTREF(((PyObject *)__pyx_t_1));
  __pyx_v_obj = ((struct __pyx_obj_4lupa_5_lupa__LuaObject *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "lupa/_lupa.pyx":696
 * cdef _LuaObject new_lua_object(LuaRuntime runtime, lua_State* L, int n):
 *     cdef _LuaObject obj = _LuaObject.__new__(_LuaObject)
 *     init_lua_object(obj, runtime, L, n)             # <<<<<<<<<<<<<<
 *     return obj
 * 
 */
  __pyx_f_4lupa_5_lupa_init_lua_object(__pyx_v_obj, __pyx_v_runtime, __pyx_v_L, __pyx_v_n);

  /* "lupa/_lupa.pyx":697
 *     cdef _LuaObject obj = _LuaObject.__new__(_LuaObject)
 *     init_lua_object(obj, runtime, L, n)
 *     return obj             # <<<<<<<<<<<<<<
 * 
 * cdef void init_lua_object(_LuaObject obj, LuaRuntime runtime, lua_State* L, int n):
 */
  __Pyx_XDECREF(((PyObject *)__pyx_r));
  __Pyx_INCREF(((PyObject *)__pyx_v_obj));
  __pyx_r = __pyx_v_obj;
  goto __pyx_L0;

  /* "lupa/_lupa.pyx":694
 * 
 * 
 * cdef _LuaObject new_lua_object(LuaRuntime runtime, lua_State* L, int n):             # <<<<<<<<<<<<<<
 *     cdef _LuaObject obj = _LuaObject.__new__(_LuaObject)
 *     init_lua_object(obj, runtime, L, n)
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("lupa._lupa.new_lua_object", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_obj);
  __Pyx_XGIVEREF((PyObject *)__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lupa/_lupa.pyx":699
 *     return obj
 * 
 * cdef void init_lua_object(_LuaObject obj, LuaRuntime runtime, lua_State* L, int n):             # <<<<<<<<<<<<<<
 *     obj._runtime = runtime
 *     obj._state = L
 */

static void __pyx_f_4lupa_5_lupa_init_lua_object(struct __pyx_obj_4lupa_5_lupa__LuaObject *__pyx_v_obj, struct __pyx_obj_4lupa_5_lupa_LuaRuntime *__pyx_v_runtime, lua_State *__pyx_v_L, int __pyx_v_n) {
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("init_lua_object", 0);

  /* "lupa/_lupa.pyx":700
 * 
 * cdef void init_lua_object(_LuaObject obj, LuaRuntime runtime, lua_State* L, int n):
 *     obj._runtime = runtime             # <<<<<<<<<<<<<<
 *     obj._state = L
 *     lua.lua_pushvalue(L, n)
 */
  __Pyx_INCREF(((PyObject *)__pyx_v_runtime));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_runtime));
  __Pyx_GOTREF(__pyx_v_obj->_runtime);
  __Pyx_DECREF(((PyObject *)__pyx_v_obj->_runtime));
  __pyx_v_obj->_runtime = __pyx_v_runtime;

  /* "lupa/_lupa.pyx":701
 * cdef void init_lua_object(_LuaObject obj, LuaRuntime runtime, lua_State* L, int n):
 *     obj._runtime = runtime
 *     obj._state = L             # <<<<<<<<<<<<<<
 *     lua.lua_pushvalue(L, n)
 *     obj._ref = lua.luaL_ref(L, lua.LUA_REGISTRYINDEX)
 */
  __pyx_v_obj->_state = __pyx_v_L;

  /* "lupa/_lupa.pyx":702
 *     obj._runtime = runtime
 *     obj._state = L
 *     lua.lua_pushvalue(L, n)             # <<<<<<<<<<<<<<
 *     obj._ref = lua.luaL_ref(L, lua.LUA_REGISTRYINDEX)
 * 
 */
  lua_pushvalue(__pyx_v_L, __pyx_v_n);

  /* "lupa/_lupa.pyx":703
 *     obj._state = L
 *     lua.lua_pushvalue(L, n)
 *     obj._ref = lua.luaL_ref(L, lua.LUA_REGISTRYINDEX)             # <<<<<<<<<<<<<<
 * 
 * cdef object lua_object_repr(lua_State* L, bytes encoding):
 */
  __pyx_v_obj->_ref = luaL_ref(__pyx_v_L, LUA_REGISTRYINDEX);

  /* "lupa/_lupa.pyx":699
 *     return obj
 * 
 * cdef void init_lua_object(_LuaObject obj, LuaRuntime runtime, lua_State* L, int n):             # <<<<<<<<<<<<<<
 *     obj._runtime = runtime
 *     obj._state = L
 */

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

/* "lupa/_lupa.pyx":705
 *     obj._ref = lua.luaL_ref(L, lua.LUA_REGISTRYINDEX)
 * 
 * cdef object lua_object_repr(lua_State* L, bytes encoding):             # <<<<<<<<<<<<<<
 *     cdef bytes py_bytes
 *     lua_type = lua.lua_type(L, -1)
 */

static PyObject *__pyx_f_4lupa_5_lupa_lua_object_repr(lua_State *__pyx_v_L, PyObject *__pyx_v_encoding) {
  PyObject *__pyx_v_py_bytes = 0;
  int __pyx_v_lua_type;
  void *__pyx_v_ptr;
  PyObject *__pyx_r = NULL;
  __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;
  char const *__pyx_t_6;
  int __pyx_t_7;
  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;
  __Pyx_RefNannySetupContext("lua_object_repr", 0);

  /* "lupa/_lupa.pyx":707
 * cdef object lua_object_repr(lua_State* L, bytes encoding):
 *     cdef bytes py_bytes
 *     lua_type = lua.lua_type(L, -1)             # <<<<<<<<<<<<<<
 *     if lua_type in (lua.LUA_TTABLE, lua.LUA_TFUNCTION):
 *         ptr = <void*>lua.lua_topointer(L, -1)
 */
  __pyx_v_lua_type = lua_type(__pyx_v_L, -1);

  /* "lupa/_lupa.pyx":708
 *     cdef bytes py_bytes
 *     lua_type = lua.lua_type(L, -1)
 *     if lua_type in (lua.LUA_TTABLE, lua.LUA_TFUNCTION):             # <<<<<<<<<<<<<<
 *         ptr = <void*>lua.lua_topointer(L, -1)
 *     elif lua_type in (lua.LUA_TUSERDATA, lua.LUA_TLIGHTUSERDATA):
 */
  switch (__pyx_v_lua_type) {
    case LUA_TTABLE:
    case LUA_TFUNCTION:

    /* "lupa/_lupa.pyx":709
 *     lua_type = lua.lua_type(L, -1)
 *     if lua_type in (lua.LUA_TTABLE, lua.LUA_TFUNCTION):
 *         ptr = <void*>lua.lua_topointer(L, -1)             # <<<<<<<<<<<<<<
 *     elif lua_type in (lua.LUA_TUSERDATA, lua.LUA_TLIGHTUSERDATA):
 *         ptr = <void*>lua.lua_touserdata(L, -1)
 */
    __pyx_v_ptr = ((void *)lua_topointer(__pyx_v_L, -1));

    /* "lupa/_lupa.pyx":708
 *     cdef bytes py_bytes
 *     lua_type = lua.lua_type(L, -1)
 *     if lua_type in (lua.LUA_TTABLE, lua.LUA_TFUNCTION):             # <<<<<<<<<<<<<<
 *         ptr = <void*>lua.lua_topointer(L, -1)
 *     elif lua_type in (lua.LUA_TUSERDATA, lua.LUA_TLIGHTUSERDATA):
 */
    break;
    case LUA_TUSERDATA:

    /* "lupa/_lupa.pyx":710
 *     if lua_type in (lua.LUA_TTABLE, lua.LUA_TFUNCTION):
 *         ptr = <void*>lua.lua_topointer(L, -1)
 *     elif lua_type in (lua.LUA_TUSERDATA, lua.LUA_TLIGHTUSERDATA):             # <<<<<<<<<<<<<<
 *         ptr = <void*>lua.lua_touserdata(L, -1)
 *     elif lua_type == lua.LUA_TTHREAD:
 */
    case LUA_TLIGHTUSERDATA:

    /* "lupa/_lupa.pyx":711
 *         ptr = <void*>lua.lua_topointer(L, -1)
 *     elif lua_type in (lua.LUA_TUSERDATA, lua.LUA_TLIGHTUSERDATA):
 *         ptr = <void*>lua.lua_touserdata(L, -1)             # <<<<<<<<<<<<<<
 *     elif lua_type == lua.LUA_TTHREAD:
 *         ptr = <void*>lua.lua_tothread(L, -1)
 */
    __pyx_v_ptr = ((void *)lua_touserdata(__pyx_v_L, -1));

    /* "lupa/_lupa.pyx":710
 *     if lua_type in (lua.LUA_TTABLE, lua.LUA_TFUNCTION):
 *         ptr = <void*>lua.lua_topointer(L, -1)
 *     elif lua_type in (lua.LUA_TUSERDATA, lua.LUA_TLIGHTUSERDATA):             # <<<<<<<<<<<<<<
 *         ptr = <void*>lua.lua_touserdata(L, -1)
 *     elif lua_type == lua.LUA_TTHREAD:
 */
    break;
    case LUA_TTHREAD:

    /* "lupa/_lupa.pyx":713
 *         ptr = <void*>lua.lua_touserdata(L, -1)
 *     elif lua_type == lua.LUA_TTHREAD:
 *         ptr = <void*>lua.lua_tothread(L, -1)             # <<<<<<<<<<<<<<
 *     else:
 *         ptr = NULL
 */
    __pyx_v_ptr = ((void *)lua_tothread(__pyx_v_L, -1));

    /* "lupa/_lupa.pyx":712
 *     elif lua_type in (lua.LUA_TUSERDATA, lua.LUA_TLIGHTUSERDATA):
 *         ptr = <void*>lua.lua_touserdata(L, -1)
 *     elif lua_type == lua.LUA_TTHREAD:             # <<<<<<<<<<<<<<
 *         ptr = <void*>lua.lua_tothread(L, -1)
 *     else:
 */
    break;
    default:

    /* "lupa/_lupa.pyx":715
 *         ptr = <void*>lua.lua_tothread(L, -1)
 *     else:
 *         ptr = NULL             # <<<<<<<<<<<<<<
 *     if ptr:
 *         py_bytes = PyBytes_FromFormat(
 */
    __pyx_v_ptr = NULL;
    break;
  }

  /* "lupa/_lupa.pyx":716
 *     else:
 *         ptr = NULL
 *     if ptr:             # <<<<<<<<<<<<<<
 *         py_bytes = PyBytes_FromFormat(
 *             "<Lua %s at %p>", lua.lua_typename(L, lua_type), ptr)
 */
  __pyx_t_1 = (__pyx_v_ptr != 0);
  if (__pyx_t_1) {

    /* "lupa/_lupa.pyx":717
 *         ptr = NULL
 *     if ptr:
 *         py_bytes = PyBytes_FromFormat(             # <<<<<<<<<<<<<<
 *             "<Lua %s at %p>", lua.lua_typename(L, lua_type), ptr)
 *     else:
 */
    __pyx_t_2 = PyBytes_FromFormat(((char *)"<Lua %s at %p>"), lua_typename(__pyx_v_L, __pyx_v_lua_type), __pyx_v_ptr); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 717, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_v_py_bytes = ((PyObject*)__pyx_t_2);
    __pyx_t_2 = 0;

    /* "lupa/_lupa.pyx":716
 *     else:
 *         ptr = NULL
 *     if ptr:             # <<<<<<<<<<<<<<
 *         py_bytes = PyBytes_FromFormat(
 *             "<Lua %s at %p>", lua.lua_typename(L, lua_type), ptr)
 */
    goto __pyx_L3;
  }

  /* "lupa/_lupa.pyx":720
 *             "<Lua %s at %p>", lua.lua_typename(L, lua_type), ptr)
 *     else:
 *         py_bytes = PyBytes_FromFormat(             # <<<<<<<<<<<<<<
 *             "<Lua %s>", lua.lua_typename(L, lua_type))
 *     try:
 */
  /*else*/ {

    /* "lupa/_lupa.pyx":721
 *     else:
 *         py_bytes = PyBytes_FromFormat(
 *             "<Lua %s>", lua.lua_typename(L, lua_type))             # <<<<<<<<<<<<<<
 *     try:
 *         return py_bytes.decode(encoding)
 */
    __pyx_t_2 = PyBytes_FromFormat(((char *)"<Lua %s>"), lua_typename(__pyx_v_L, __pyx_v_lua_type)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 720, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_v_py_bytes = ((PyObject*)__pyx_t_2);
    __pyx_t_2 = 0;
  }
  __pyx_L3:;

  /* "lupa/_lupa.pyx":722
 *         py_bytes = PyBytes_FromFormat(
 *             "<Lua %s>", lua.lua_typename(L, lua_type))
 *     try:             # <<<<<<<<<<<<<<
 *         return py_bytes.decode(encoding)
 *     except UnicodeDecodeError:
 */
  {
    __Pyx_PyThreadState_declare
    __Pyx_PyThreadState_assign
    __Pyx_ExceptionSave(&__pyx_t_3, &__pyx_t_4, &__pyx_t_5);
    __Pyx_XGOTREF(__pyx_t_3);
    __Pyx_XGOTREF(__pyx_t_4);
    __Pyx_XGOTREF(__pyx_t_5);
    /*try:*/ {

      /* "lupa/_lupa.pyx":723
 *             "<Lua %s>", lua.lua_typename(L, lua_type))
 *     try:
 *         return py_bytes.decode(encoding)             # <<<<<<<<<<<<<<
 *     except UnicodeDecodeError:
 *         # safe 'decode'
 */
      __Pyx_XDECREF(__pyx_r);
      if (unlikely(__pyx_v_py_bytes == Py_None)) {
        PyErr_Format(PyExc_AttributeError, "'NoneType' object has no attribute '%.30s'", "decode");
        __PYX_ERR(0, 723, __pyx_L4_error)
      }
      if (unlikely(__pyx_v_encoding == Py_None)) {
        PyErr_SetString(PyExc_TypeError, "expected bytes, NoneType found");
        __PYX_ERR(0, 723, __pyx_L4_error)
      }
      __pyx_t_6 = __Pyx_PyBytes_AsString(__pyx_v_encoding); if (unlikely((!__pyx_t_6) && PyErr_Occurred())) __PYX_ERR(0, 723, __pyx_L4_error)
      __pyx_t_2 = __Pyx_decode_bytes(__pyx_v_py_bytes, 0, PY_SSIZE_T_MAX, __pyx_t_6, NULL, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 723, __pyx_L4_error)
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_r = __pyx_t_2;
      __pyx_t_2 = 0;
      goto __pyx_L8_try_return;

      /* "lupa/_lupa.pyx":722
 *         py_bytes = PyBytes_FromFormat(
 *             "<Lua %s>", lua.lua_typename(L, lua_type))
 *     try:             # <<<<<<<<<<<<<<
 *         return py_bytes.decode(encoding)
 *     except UnicodeDecodeError:
 */
    }
    __pyx_L4_error:;
    __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;

    /* "lupa/_lupa.pyx":724
 *     try:
 *         return py_bytes.decode(encoding)
 *     except UnicodeDecodeError:             # <<<<<<<<<<<<<<
 *         # safe 'decode'
 *         return py_bytes.decode('ISO-8859-1')
 */
    __pyx_t_7 = __Pyx_PyErr_ExceptionMatches(__pyx_builtin_UnicodeDecodeError);
    if (__pyx_t_7) {
      __Pyx_AddTraceback("lupa._lupa.lua_object_repr", __pyx_clineno, __pyx_lineno, __pyx_filename);
      if (__Pyx_GetException(&__pyx_t_2, &__pyx_t_8, &__pyx_t_9) < 0) __PYX_ERR(0, 724, __pyx_L6_except_error)
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_GOTREF(__pyx_t_8);
      __Pyx_GOTREF(__pyx_t_9);

      /* "lupa/_lupa.pyx":726
 *     except UnicodeDecodeError:
 *         # safe 'decode'
 *         return py_bytes.decode('ISO-8859-1')             # <<<<<<<<<<<<<<
 * 
 * 
 */
      __Pyx_XDECREF(__pyx_r);
      if (unlikely(__pyx_v_py_bytes == Py_None)) {
        PyErr_Format(PyExc_AttributeError, "'NoneType' object has no attribute '%.30s'", "decode");
        __PYX_ERR(0, 726, __pyx_L6_except_error)
      }
      __pyx_t_10 = __Pyx_decode_bytes(__pyx_v_py_bytes, 0, PY_SSIZE_T_MAX, NULL, NULL, PyUnicode_DecodeLatin1); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 726, __pyx_L6_except_error)
      __Pyx_GOTREF(__pyx_t_10);
      __pyx_r = __pyx_t_10;
      __pyx_t_10 = 0;
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
      goto __pyx_L7_except_return;
    }
    goto __pyx_L6_except_error;
    __pyx_L6_except_error:;

    /* "lupa/_lupa.pyx":722
 *         py_bytes = PyBytes_FromFormat(
 *             "<Lua %s>", lua.lua_typename(L, lua_type))
 *     try:             # <<<<<<<<<<<<<<
 *         return py_bytes.decode(encoding)
 *     except UnicodeDecodeError:
 */
    __Pyx_XGIVEREF(__pyx_t_3);
    __Pyx_XGIVEREF(__pyx_t_4);
    __Pyx_XGIVEREF(__pyx_t_5);
    __Pyx_ExceptionReset(__pyx_t_3, __pyx_t_4, __pyx_t_5);
    goto __pyx_L1_error;
    __pyx_L8_try_return:;
    __Pyx_XGIVEREF(__pyx_t_3);
    __Pyx_XGIVEREF(__pyx_t_4);
    __Pyx_XGIVEREF(__pyx_t_5);
    __Pyx_ExceptionReset(__pyx_t_3, __pyx_t_4, __pyx_t_5);
    goto __pyx_L0;
    __pyx_L7_except_return:;
    __Pyx_XGIVEREF(__pyx_t_3);
    __Pyx_XGIVEREF(__pyx_t_4);
    __Pyx_XGIVEREF(__pyx_t_5);
    __Pyx_ExceptionReset(__pyx_t_3, __pyx_t_4, __pyx_t_5);
    goto __pyx_L0;
  }

  /* "lupa/_lupa.pyx":705
 *     obj._ref = lua.luaL_ref(L, lua.LUA_REGISTRYINDEX)
 * 
 * cdef object lua_object_repr(lua_State* L, bytes encoding):             # <<<<<<<<<<<<<<
 *     cdef bytes py_bytes
 *     lua_type = lua.lua_type(L, -1)
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_XDECREF(__pyx_t_9);
  __Pyx_XDECREF(__pyx_t_10);
  __Pyx_AddTraceback("lupa._lupa.lua_object_repr", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_py_bytes);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lupa/_lupa.pyx":733
 * @cython.no_gc_clear
 * cdef class _LuaTable(_LuaObject):
 *     def __iter__(self):             # <<<<<<<<<<<<<<
 *         return _LuaIter(self, KEYS)
 * 
 */

/* Python wrapper */
static PyObject *__pyx_pw_4lupa_5_lupa_9_LuaTable_1__iter__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_4lupa_5_lupa_9_LuaTable_1__iter__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__iter__ (wrapper)", 0);
  __pyx_r = __pyx_pf_4lupa_5_lupa_9_LuaTable___iter__(((struct __pyx_obj_4lupa_5_lupa__LuaTable *)__pyx_v_self));

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

static PyObject *__pyx_pf_4lupa_5_lupa_9_LuaTable___iter__(struct __pyx_obj_4lupa_5_lupa__LuaTable *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__iter__", 0);

  /* "lupa/_lupa.pyx":734
 * cdef class _LuaTable(_LuaObject):
 *     def __iter__(self):
 *         return _LuaIter(self, KEYS)             # <<<<<<<<<<<<<<
 * 
 *     def keys(self):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_e_4lupa_5_lupa_KEYS); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 734, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 734, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_INCREF(((PyObject *)__pyx_v_self));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_self));
  PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_v_self));
  __Pyx_GIVEREF(__pyx_t_1);
  PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_t_1);
  __pyx_t_1 = 0;
  __pyx_t_1 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_4lupa_5_lupa__LuaIter), __pyx_t_2, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 734, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "lupa/_lupa.pyx":733
 * @cython.no_gc_clear
 * cdef class _LuaTable(_LuaObject):
 *     def __iter__(self):             # <<<<<<<<<<<<<<
 *         return _LuaIter(self, KEYS)
 * 
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_AddTraceback("lupa._lupa._LuaTable.__iter__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lupa/_lupa.pyx":736
 *         return _LuaIter(self, KEYS)
 * 
 *     def keys(self):             # <<<<<<<<<<<<<<
 *         """Returns an iterator over the keys of a table that this
 *         object represents.  Same as iter(obj).
 */

/* Python wrapper */
static PyObject *__pyx_pw_4lupa_5_lupa_9_LuaTable_3keys(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static char __pyx_doc_4lupa_5_lupa_9_LuaTable_2keys[] = "_LuaTable.keys(self)\nReturns an iterator over the keys of a table that this\n        object represents.  Same as iter(obj).\n        ";
static PyMethodDef __pyx_mdef_4lupa_5_lupa_9_LuaTable_3keys = {"keys", (PyCFunction)__pyx_pw_4lupa_5_lupa_9_LuaTable_3keys, METH_NOARGS, __pyx_doc_4lupa_5_lupa_9_LuaTable_2keys};
static PyObject *__pyx_pw_4lupa_5_lupa_9_LuaTable_3keys(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("keys (wrapper)", 0);
  __pyx_r = __pyx_pf_4lupa_5_lupa_9_LuaTable_2keys(((struct __pyx_obj_4lupa_5_lupa__LuaTable *)__pyx_v_self));

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

static PyObject *__pyx_pf_4lupa_5_lupa_9_LuaTable_2keys(struct __pyx_obj_4lupa_5_lupa__LuaTable *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("keys", 0);

  /* "lupa/_lupa.pyx":740
 *         object represents.  Same as iter(obj).
 *         """
 *         return _LuaIter(self, KEYS)             # <<<<<<<<<<<<<<
 * 
 *     def values(self):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_e_4lupa_5_lupa_KEYS); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 740, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 740, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_INCREF(((PyObject *)__pyx_v_self));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_self));
  PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_v_self));
  __Pyx_GIVEREF(__pyx_t_1);
  PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_t_1);
  __pyx_t_1 = 0;
  __pyx_t_1 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_4lupa_5_lupa__LuaIter), __pyx_t_2, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 740, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "lupa/_lupa.pyx":736
 *         return _LuaIter(self, KEYS)
 * 
 *     def keys(self):             # <<<<<<<<<<<<<<
 *         """Returns an iterator over the keys of a table that this
 *         object represents.  Same as iter(obj).
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_AddTraceback("lupa._lupa._LuaTable.keys", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lupa/_lupa.pyx":742
 *         return _LuaIter(self, KEYS)
 * 
 *     def values(self):             # <<<<<<<<<<<<<<
 *         """Returns an iterator over the values of a table that this
 *         object represents.
 */

/* Python wrapper */
static PyObject *__pyx_pw_4lupa_5_lupa_9_LuaTable_5values(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static char __pyx_doc_4lupa_5_lupa_9_LuaTable_4values[] = "_LuaTable.values(self)\nReturns an iterator over the values of a table that this\n        object represents.\n        ";
static PyMethodDef __pyx_mdef_4lupa_5_lupa_9_LuaTable_5values = {"values", (PyCFunction)__pyx_pw_4lupa_5_lupa_9_LuaTable_5values, METH_NOARGS, __pyx_doc_4lupa_5_lupa_9_LuaTable_4values};
static PyObject *__pyx_pw_4lupa_5_lupa_9_LuaTable_5values(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("values (wrapper)", 0);
  __pyx_r = __pyx_pf_4lupa_5_lupa_9_LuaTable_4values(((struct __pyx_obj_4lupa_5_lupa__LuaTable *)__pyx_v_self));

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

static PyObject *__pyx_pf_4lupa_5_lupa_9_LuaTable_4values(struct __pyx_obj_4lupa_5_lupa__LuaTable *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("values", 0);

  /* "lupa/_lupa.pyx":746
 *         object represents.
 *         """
 *         return _LuaIter(self, VALUES)             # <<<<<<<<<<<<<<
 * 
 *     def items(self):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_e_4lupa_5_lupa_VALUES); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 746, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 746, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_INCREF(((PyObject *)__pyx_v_self));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_self));
  PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_v_self));
  __Pyx_GIVEREF(__pyx_t_1);
  PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_t_1);
  __pyx_t_1 = 0;
  __pyx_t_1 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_4lupa_5_lupa__LuaIter), __pyx_t_2, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 746, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "lupa/_lupa.pyx":742
 *         return _LuaIter(self, KEYS)
 * 
 *     def values(self):             # <<<<<<<<<<<<<<
 *         """Returns an iterator over the values of a table that this
 *         object represents.
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_AddTraceback("lupa._lupa._LuaTable.values", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lupa/_lupa.pyx":748
 *         return _LuaIter(self, VALUES)
 * 
 *     def items(self):             # <<<<<<<<<<<<<<
 *         """Returns an iterator over the key-value pairs of a table
 *         that this object represents.
 */

/* Python wrapper */
static PyObject *__pyx_pw_4lupa_5_lupa_9_LuaTable_7items(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static char __pyx_doc_4lupa_5_lupa_9_LuaTable_6items[] = "_LuaTable.items(self)\nReturns an iterator over the key-value pairs of a table\n        that this object represents.\n        ";
static PyMethodDef __pyx_mdef_4lupa_5_lupa_9_LuaTable_7items = {"items", (PyCFunction)__pyx_pw_4lupa_5_lupa_9_LuaTable_7items, METH_NOARGS, __pyx_doc_4lupa_5_lupa_9_LuaTable_6items};
static PyObject *__pyx_pw_4lupa_5_lupa_9_LuaTable_7items(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("items (wrapper)", 0);
  __pyx_r = __pyx_pf_4lupa_5_lupa_9_LuaTable_6items(((struct __pyx_obj_4lupa_5_lupa__LuaTable *)__pyx_v_self));

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

static PyObject *__pyx_pf_4lupa_5_lupa_9_LuaTable_6items(struct __pyx_obj_4lupa_5_lupa__LuaTable *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("items", 0);

  /* "lupa/_lupa.pyx":752
 *         that this object represents.
 *         """
 *         return _LuaIter(self, ITEMS)             # <<<<<<<<<<<<<<
 * 
 *     def __setattr__(self, name, value):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_e_4lupa_5_lupa_ITEMS); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 752, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 752, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_INCREF(((PyObject *)__pyx_v_self));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_self));
  PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_v_self));
  __Pyx_GIVEREF(__pyx_t_1);
  PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_t_1);
  __pyx_t_1 = 0;
  __pyx_t_1 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_4lupa_5_lupa__LuaIter), __pyx_t_2, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 752, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "lupa/_lupa.pyx":748
 *         return _LuaIter(self, VALUES)
 * 
 *     def items(self):             # <<<<<<<<<<<<<<
 *         """Returns an iterator over the key-value pairs of a table
 *         that this object represents.
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_AddTraceback("lupa._lupa._LuaTable.items", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lupa/_lupa.pyx":754
 *         return _LuaIter(self, ITEMS)
 * 
 *     def __setattr__(self, name, value):             # <<<<<<<<<<<<<<
 *         assert self._runtime is not None
 *         if isinstance(name, unicode):
 */

/* Python wrapper */
static int __pyx_pw_4lupa_5_lupa_9_LuaTable_9__setattr__(PyObject *__pyx_v_self, PyObject *__pyx_v_name, PyObject *__pyx_v_value); /*proto*/
static int __pyx_pw_4lupa_5_lupa_9_LuaTable_9__setattr__(PyObject *__pyx_v_self, PyObject *__pyx_v_name, PyObject *__pyx_v_value) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__setattr__ (wrapper)", 0);
  __pyx_r = __pyx_pf_4lupa_5_lupa_9_LuaTable_8__setattr__(((struct __pyx_obj_4lupa_5_lupa__LuaTable *)__pyx_v_self), ((PyObject *)__pyx_v_name), ((PyObject *)__pyx_v_value));

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

static int __pyx_pf_4lupa_5_lupa_9_LuaTable_8__setattr__(struct __pyx_obj_4lupa_5_lupa__LuaTable *__pyx_v_self, PyObject *__pyx_v_name, PyObject *__pyx_v_value) {
  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;
  int __pyx_t_6;
  PyObject *__pyx_t_7 = NULL;
  char const *__pyx_t_8;
  int __pyx_t_9;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__setattr__", 0);
  __Pyx_INCREF(__pyx_v_name);

  /* "lupa/_lupa.pyx":755
 * 
 *     def __setattr__(self, name, value):
 *         assert self._runtime is not None             # <<<<<<<<<<<<<<
 *         if isinstance(name, unicode):
 *             if (<unicode>name).startswith(u'__') and (<unicode>name).endswith(u'__'):
 */
  #ifndef CYTHON_WITHOUT_ASSERTIONS
  if (unlikely(!Py_OptimizeFlag)) {
    __pyx_t_1 = (((PyObject *)__pyx_v_self->__pyx_base._runtime) != Py_None);
    if (unlikely(!(__pyx_t_1 != 0))) {
      PyErr_SetNone(PyExc_AssertionError);
      __PYX_ERR(0, 755, __pyx_L1_error)
    }
  }
  #endif

  /* "lupa/_lupa.pyx":756
 *     def __setattr__(self, name, value):
 *         assert self._runtime is not None
 *         if isinstance(name, unicode):             # <<<<<<<<<<<<<<
 *             if (<unicode>name).startswith(u'__') and (<unicode>name).endswith(u'__'):
 *                 object.__setattr__(self, name, value)
 */
  __pyx_t_1 = PyUnicode_Check(__pyx_v_name); 
  __pyx_t_2 = (__pyx_t_1 != 0);
  if (__pyx_t_2) {

    /* "lupa/_lupa.pyx":757
 *         assert self._runtime is not None
 *         if isinstance(name, unicode):
 *             if (<unicode>name).startswith(u'__') and (<unicode>name).endswith(u'__'):             # <<<<<<<<<<<<<<
 *                 object.__setattr__(self, name, value)
 *                 return
 */
    if (unlikely(__pyx_v_name == Py_None)) {
      PyErr_Format(PyExc_AttributeError, "'NoneType' object has no attribute '%.30s'", "startswith");
      __PYX_ERR(0, 757, __pyx_L1_error)
    }
    __pyx_t_1 = __Pyx_PyUnicode_Tailmatch(((PyObject*)__pyx_v_name), __pyx_n_u__16, 0, PY_SSIZE_T_MAX, -1); if (unlikely(__pyx_t_1 == ((int)-1))) __PYX_ERR(0, 757, __pyx_L1_error)
    if ((__pyx_t_1 != 0)) {
    } else {
      __pyx_t_2 = (__pyx_t_1 != 0);
      goto __pyx_L5_bool_binop_done;
    }
    if (unlikely(__pyx_v_name == Py_None)) {
      PyErr_Format(PyExc_AttributeError, "'NoneType' object has no attribute '%.30s'", "endswith");
      __PYX_ERR(0, 757, __pyx_L1_error)
    }
    __pyx_t_1 = __Pyx_PyUnicode_Tailmatch(((PyObject*)__pyx_v_name), __pyx_n_u__16, 0, PY_SSIZE_T_MAX, 1); if (unlikely(__pyx_t_1 == ((int)-1))) __PYX_ERR(0, 757, __pyx_L1_error)
    __pyx_t_2 = (__pyx_t_1 != 0);
    __pyx_L5_bool_binop_done:;
    if (__pyx_t_2) {

      /* "lupa/_lupa.pyx":758
 *         if isinstance(name, unicode):
 *             if (<unicode>name).startswith(u'__') and (<unicode>name).endswith(u'__'):
 *                 object.__setattr__(self, name, value)             # <<<<<<<<<<<<<<
 *                 return
 *             name = (<unicode>name).encode(self._runtime._source_encoding)
 */
      __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_builtin_object, __pyx_n_s_setattr); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 758, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_t_5 = NULL;
      __pyx_t_6 = 0;
      if (CYTHON_UNPACK_METHODS && likely(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_6 = 1;
        }
      }
      #if CYTHON_FAST_PYCALL
      if (PyFunction_Check(__pyx_t_4)) {
        PyObject *__pyx_temp[4] = {__pyx_t_5, ((PyObject *)__pyx_v_self), __pyx_v_name, __pyx_v_value};
        __pyx_t_3 = __Pyx_PyFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_6, 3+__pyx_t_6); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 758, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
        __Pyx_GOTREF(__pyx_t_3);
      } else
      #endif
      #if CYTHON_FAST_PYCCALL
      if (__Pyx_PyFastCFunction_Check(__pyx_t_4)) {
        PyObject *__pyx_temp[4] = {__pyx_t_5, ((PyObject *)__pyx_v_self), __pyx_v_name, __pyx_v_value};
        __pyx_t_3 = __Pyx_PyCFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_6, 3+__pyx_t_6); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 758, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
        __Pyx_GOTREF(__pyx_t_3);
      } else
      #endif
      {
        __pyx_t_7 = PyTuple_New(3+__pyx_t_6); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 758, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_7);
        if (__pyx_t_5) {
          __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_5); __pyx_t_5 = NULL;
        }
        __Pyx_INCREF(((PyObject *)__pyx_v_self));
        __Pyx_GIVEREF(((PyObject *)__pyx_v_self));
        PyTuple_SET_ITEM(__pyx_t_7, 0+__pyx_t_6, ((PyObject *)__pyx_v_self));
        __Pyx_INCREF(__pyx_v_name);
        __Pyx_GIVEREF(__pyx_v_name);
        PyTuple_SET_ITEM(__pyx_t_7, 1+__pyx_t_6, __pyx_v_name);
        __Pyx_INCREF(__pyx_v_value);
        __Pyx_GIVEREF(__pyx_v_value);
        PyTuple_SET_ITEM(__pyx_t_7, 2+__pyx_t_6, __pyx_v_value);
        __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_7, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 758, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_3);
        __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      }
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

      /* "lupa/_lupa.pyx":759
 *             if (<unicode>name).startswith(u'__') and (<unicode>name).endswith(u'__'):
 *                 object.__setattr__(self, name, value)
 *                 return             # <<<<<<<<<<<<<<
 *             name = (<unicode>name).encode(self._runtime._source_encoding)
 *         elif isinstance(name, bytes) and (<bytes>name).startswith(b'__') and (<bytes>name).endswith(b'__'):
 */
      __pyx_r = 0;
      goto __pyx_L0;

      /* "lupa/_lupa.pyx":757
 *         assert self._runtime is not None
 *         if isinstance(name, unicode):
 *             if (<unicode>name).startswith(u'__') and (<unicode>name).endswith(u'__'):             # <<<<<<<<<<<<<<
 *                 object.__setattr__(self, name, value)
 *                 return
 */
    }

    /* "lupa/_lupa.pyx":760
 *                 object.__setattr__(self, name, value)
 *                 return
 *             name = (<unicode>name).encode(self._runtime._source_encoding)             # <<<<<<<<<<<<<<
 *         elif isinstance(name, bytes) and (<bytes>name).startswith(b'__') and (<bytes>name).endswith(b'__'):
 *             object.__setattr__(self, name, value)
 */
    if (unlikely(__pyx_v_name == Py_None)) {
      PyErr_Format(PyExc_AttributeError, "'NoneType' object has no attribute '%.30s'", "encode");
      __PYX_ERR(0, 760, __pyx_L1_error)
    }
    if (unlikely(__pyx_v_self->__pyx_base._runtime->_source_encoding == Py_None)) {
      PyErr_SetString(PyExc_TypeError, "expected bytes, NoneType found");
      __PYX_ERR(0, 760, __pyx_L1_error)
    }
    __pyx_t_8 = __Pyx_PyBytes_AsString(__pyx_v_self->__pyx_base._runtime->_source_encoding); if (unlikely((!__pyx_t_8) && PyErr_Occurred())) __PYX_ERR(0, 760, __pyx_L1_error)
    __pyx_t_3 = PyUnicode_AsEncodedString(((PyObject*)__pyx_v_name), __pyx_t_8, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 760, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF_SET(__pyx_v_name, __pyx_t_3);
    __pyx_t_3 = 0;

    /* "lupa/_lupa.pyx":756
 *     def __setattr__(self, name, value):
 *         assert self._runtime is not None
 *         if isinstance(name, unicode):             # <<<<<<<<<<<<<<
 *             if (<unicode>name).startswith(u'__') and (<unicode>name).endswith(u'__'):
 *                 object.__setattr__(self, name, value)
 */
    goto __pyx_L3;
  }

  /* "lupa/_lupa.pyx":761
 *                 return
 *             name = (<unicode>name).encode(self._runtime._source_encoding)
 *         elif isinstance(name, bytes) and (<bytes>name).startswith(b'__') and (<bytes>name).endswith(b'__'):             # <<<<<<<<<<<<<<
 *             object.__setattr__(self, name, value)
 *             return
 */
  __pyx_t_1 = PyBytes_Check(__pyx_v_name); 
  __pyx_t_9 = (__pyx_t_1 != 0);
  if (__pyx_t_9) {
  } else {
    __pyx_t_2 = __pyx_t_9;
    goto __pyx_L7_bool_binop_done;
  }
  if (unlikely(__pyx_v_name == Py_None)) {
    PyErr_Format(PyExc_AttributeError, "'NoneType' object has no attribute '%.30s'", "startswith");
    __PYX_ERR(0, 761, __pyx_L1_error)
  }
  __pyx_t_9 = __Pyx_PyBytes_Tailmatch(((PyObject*)__pyx_v_name), __pyx_n_b__16, 0, PY_SSIZE_T_MAX, -1); if (unlikely(__pyx_t_9 == ((int)-1))) __PYX_ERR(0, 761, __pyx_L1_error)
  if ((__pyx_t_9 != 0)) {
  } else {
    __pyx_t_2 = (__pyx_t_9 != 0);
    goto __pyx_L7_bool_binop_done;
  }
  if (unlikely(__pyx_v_name == Py_None)) {
    PyErr_Format(PyExc_AttributeError, "'NoneType' object has no attribute '%.30s'", "endswith");
    __PYX_ERR(0, 761, __pyx_L1_error)
  }
  __pyx_t_9 = __Pyx_PyBytes_Tailmatch(((PyObject*)__pyx_v_name), __pyx_n_b__16, 0, PY_SSIZE_T_MAX, 1); if (unlikely(__pyx_t_9 == ((int)-1))) __PYX_ERR(0, 761, __pyx_L1_error)
  __pyx_t_2 = (__pyx_t_9 != 0);
  __pyx_L7_bool_binop_done:;
  if (__pyx_t_2) {

    /* "lupa/_lupa.pyx":762
 *             name = (<unicode>name).encode(self._runtime._source_encoding)
 *         elif isinstance(name, bytes) and (<bytes>name).startswith(b'__') and (<bytes>name).endswith(b'__'):
 *             object.__setattr__(self, name, value)             # <<<<<<<<<<<<<<
 *             return
 *         self._setitem(name, value)
 */
    __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_builtin_object, __pyx_n_s_setattr); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 762, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_7 = NULL;
    __pyx_t_6 = 0;
    if (CYTHON_UNPACK_METHODS && likely(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_6 = 1;
      }
    }
    #if CYTHON_FAST_PYCALL
    if (PyFunction_Check(__pyx_t_4)) {
      PyObject *__pyx_temp[4] = {__pyx_t_7, ((PyObject *)__pyx_v_self), __pyx_v_name, __pyx_v_value};
      __pyx_t_3 = __Pyx_PyFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_6, 3+__pyx_t_6); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 762, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
      __Pyx_GOTREF(__pyx_t_3);
    } else
    #endif
    #if CYTHON_FAST_PYCCALL
    if (__Pyx_PyFastCFunction_Check(__pyx_t_4)) {
      PyObject *__pyx_temp[4] = {__pyx_t_7, ((PyObject *)__pyx_v_self), __pyx_v_name, __pyx_v_value};
      __pyx_t_3 = __Pyx_PyCFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_6, 3+__pyx_t_6); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 762, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
      __Pyx_GOTREF(__pyx_t_3);
    } else
    #endif
    {
      __pyx_t_5 = PyTuple_New(3+__pyx_t_6); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 762, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
      if (__pyx_t_7) {
        __Pyx_GIVEREF(__pyx_t_7); PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_7); __pyx_t_7 = NULL;
      }
      __Pyx_INCREF(((PyObject *)__pyx_v_self));
      __Pyx_GIVEREF(((PyObject *)__pyx_v_self));
      PyTuple_SET_ITEM(__pyx_t_5, 0+__pyx_t_6, ((PyObject *)__pyx_v_self));
      __Pyx_INCREF(__pyx_v_name);
      __Pyx_GIVEREF(__pyx_v_name);
      PyTuple_SET_ITEM(__pyx_t_5, 1+__pyx_t_6, __pyx_v_name);
      __Pyx_INCREF(__pyx_v_value);
      __Pyx_GIVEREF(__pyx_v_value);
      PyTuple_SET_ITEM(__pyx_t_5, 2+__pyx_t_6, __pyx_v_value);
      __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_5, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 762, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    }
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

    /* "lupa/_lupa.pyx":763
 *         elif isinstance(name, bytes) and (<bytes>name).startswith(b'__') and (<bytes>name).endswith(b'__'):
 *             object.__setattr__(self, name, value)
 *             return             # <<<<<<<<<<<<<<
 *         self._setitem(name, value)
 * 
 */
    __pyx_r = 0;
    goto __pyx_L0;

    /* "lupa/_lupa.pyx":761
 *                 return
 *             name = (<unicode>name).encode(self._runtime._source_encoding)
 *         elif isinstance(name, bytes) and (<bytes>name).startswith(b'__') and (<bytes>name).endswith(b'__'):             # <<<<<<<<<<<<<<
 *             object.__setattr__(self, name, value)
 *             return
 */
  }
  __pyx_L3:;

  /* "lupa/_lupa.pyx":764
 *             object.__setattr__(self, name, value)
 *             return
 *         self._setitem(name, value)             # <<<<<<<<<<<<<<
 * 
 *     def __setitem__(self, index_or_name, value):
 */
  __pyx_t_6 = __pyx_f_4lupa_5_lupa_9_LuaTable__setitem(__pyx_v_self, __pyx_v_name, __pyx_v_value); if (unlikely(__pyx_t_6 == ((int)-1))) __PYX_ERR(0, 764, __pyx_L1_error)

  /* "lupa/_lupa.pyx":754
 *         return _LuaIter(self, ITEMS)
 * 
 *     def __setattr__(self, name, value):             # <<<<<<<<<<<<<<
 *         assert self._runtime is not None
 *         if isinstance(name, unicode):
 */

  /* 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_7);
  __Pyx_AddTraceback("lupa._lupa._LuaTable.__setattr__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_name);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lupa/_lupa.pyx":766
 *         self._setitem(name, value)
 * 
 *     def __setitem__(self, index_or_name, value):             # <<<<<<<<<<<<<<
 *         self._setitem(index_or_name, value)
 * 
 */

/* Python wrapper */
static int __pyx_pw_4lupa_5_lupa_9_LuaTable_11__setitem__(PyObject *__pyx_v_self, PyObject *__pyx_v_index_or_name, PyObject *__pyx_v_value); /*proto*/
static int __pyx_pw_4lupa_5_lupa_9_LuaTable_11__setitem__(PyObject *__pyx_v_self, PyObject *__pyx_v_index_or_name, PyObject *__pyx_v_value) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__setitem__ (wrapper)", 0);
  __pyx_r = __pyx_pf_4lupa_5_lupa_9_LuaTable_10__setitem__(((struct __pyx_obj_4lupa_5_lupa__LuaTable *)__pyx_v_self), ((PyObject *)__pyx_v_index_or_name), ((PyObject *)__pyx_v_value));

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

static int __pyx_pf_4lupa_5_lupa_9_LuaTable_10__setitem__(struct __pyx_obj_4lupa_5_lupa__LuaTable *__pyx_v_self, PyObject *__pyx_v_index_or_name, PyObject *__pyx_v_value) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__setitem__", 0);

  /* "lupa/_lupa.pyx":767
 * 
 *     def __setitem__(self, index_or_name, value):
 *         self._setitem(index_or_name, value)             # <<<<<<<<<<<<<<
 * 
 *     @cython.final
 */
  __pyx_t_1 = __pyx_f_4lupa_5_lupa_9_LuaTable__setitem(__pyx_v_self, __pyx_v_index_or_name, __pyx_v_value); if (unlikely(__pyx_t_1 == ((int)-1))) __PYX_ERR(0, 767, __pyx_L1_error)

  /* "lupa/_lupa.pyx":766
 *         self._setitem(name, value)
 * 
 *     def __setitem__(self, index_or_name, value):             # <<<<<<<<<<<<<<
 *         self._setitem(index_or_name, value)
 * 
 */

  /* function exit code */
  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_AddTraceback("lupa._lupa._LuaTable.__setitem__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lupa/_lupa.pyx":770
 * 
 *     @cython.final
 *     cdef int _setitem(self, name, value) except -1:             # <<<<<<<<<<<<<<
 *         cdef lua_State* L = self._state
 *         lock_runtime(self._runtime)
 */

static int __pyx_f_4lupa_5_lupa_9_LuaTable__setitem(struct __pyx_obj_4lupa_5_lupa__LuaTable *__pyx_v_self, PyObject *__pyx_v_name, PyObject *__pyx_v_value) {
  lua_State *__pyx_v_L;
  int __pyx_v_old_top;
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  lua_State *__pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  int __pyx_t_3;
  struct __pyx_opt_args_4lupa_5_lupa_py_to_lua __pyx_t_4;
  int __pyx_t_5;
  char const *__pyx_t_6;
  PyObject *__pyx_t_7 = NULL;
  PyObject *__pyx_t_8 = NULL;
  PyObject *__pyx_t_9 = NULL;
  PyObject *__pyx_t_10 = NULL;
  PyObject *__pyx_t_11 = NULL;
  PyObject *__pyx_t_12 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("_setitem", 0);

  /* "lupa/_lupa.pyx":771
 *     @cython.final
 *     cdef int _setitem(self, name, value) except -1:
 *         cdef lua_State* L = self._state             # <<<<<<<<<<<<<<
 *         lock_runtime(self._runtime)
 *         old_top = lua.lua_gettop(L)
 */
  __pyx_t_1 = __pyx_v_self->__pyx_base._state;
  __pyx_v_L = __pyx_t_1;

  /* "lupa/_lupa.pyx":772
 *     cdef int _setitem(self, name, value) except -1:
 *         cdef lua_State* L = self._state
 *         lock_runtime(self._runtime)             # <<<<<<<<<<<<<<
 *         old_top = lua.lua_gettop(L)
 *         try:
 */
  __pyx_t_2 = ((PyObject *)__pyx_v_self->__pyx_base._runtime);
  __Pyx_INCREF(__pyx_t_2);
  __pyx_t_3 = __pyx_f_4lupa_5_lupa_lock_runtime(((struct __pyx_obj_4lupa_5_lupa_LuaRuntime *)__pyx_t_2)); if (unlikely(__pyx_t_3 == ((int)-1))) __PYX_ERR(0, 772, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "lupa/_lupa.pyx":773
 *         cdef lua_State* L = self._state
 *         lock_runtime(self._runtime)
 *         old_top = lua.lua_gettop(L)             # <<<<<<<<<<<<<<
 *         try:
 *             self.push_lua_object()
 */
  __pyx_v_old_top = lua_gettop(__pyx_v_L);

  /* "lupa/_lupa.pyx":774
 *         lock_runtime(self._runtime)
 *         old_top = lua.lua_gettop(L)
 *         try:             # <<<<<<<<<<<<<<
 *             self.push_lua_object()
 *             # table[nil] fails, so map None -> python.none for Lua tables
 */
  /*try:*/ {

    /* "lupa/_lupa.pyx":775
 *         old_top = lua.lua_gettop(L)
 *         try:
 *             self.push_lua_object()             # <<<<<<<<<<<<<<
 *             # table[nil] fails, so map None -> python.none for Lua tables
 *             py_to_lua(self._runtime, L, name, wrap_none=True)
 */
    __pyx_t_3 = __pyx_f_4lupa_5_lupa_10_LuaObject_push_lua_object(((struct __pyx_obj_4lupa_5_lupa__LuaObject *)__pyx_v_self)); if (unlikely(__pyx_t_3 == ((int)-1))) __PYX_ERR(0, 775, __pyx_L4_error)

    /* "lupa/_lupa.pyx":777
 *             self.push_lua_object()
 *             # table[nil] fails, so map None -> python.none for Lua tables
 *             py_to_lua(self._runtime, L, name, wrap_none=True)             # <<<<<<<<<<<<<<
 *             py_to_lua(self._runtime, L, value)
 *             lua.lua_settable(L, -3)
 */
    __pyx_t_2 = ((PyObject *)__pyx_v_self->__pyx_base._runtime);
    __Pyx_INCREF(__pyx_t_2);
    __pyx_t_4.__pyx_n = 1;
    __pyx_t_4.wrap_none = 1;
    __pyx_t_3 = __pyx_f_4lupa_5_lupa_py_to_lua(((struct __pyx_obj_4lupa_5_lupa_LuaRuntime *)__pyx_t_2), __pyx_v_L, __pyx_v_name, &__pyx_t_4); if (unlikely(__pyx_t_3 == ((int)-1))) __PYX_ERR(0, 777, __pyx_L4_error)
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

    /* "lupa/_lupa.pyx":778
 *             # table[nil] fails, so map None -> python.none for Lua tables
 *             py_to_lua(self._runtime, L, name, wrap_none=True)
 *             py_to_lua(self._runtime, L, value)             # <<<<<<<<<<<<<<
 *             lua.lua_settable(L, -3)
 *         finally:
 */
    __pyx_t_2 = ((PyObject *)__pyx_v_self->__pyx_base._runtime);
    __Pyx_INCREF(__pyx_t_2);
    __pyx_t_3 = __pyx_f_4lupa_5_lupa_py_to_lua(((struct __pyx_obj_4lupa_5_lupa_LuaRuntime *)__pyx_t_2), __pyx_v_L, __pyx_v_value, NULL); if (unlikely(__pyx_t_3 == ((int)-1))) __PYX_ERR(0, 778, __pyx_L4_error)
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

    /* "lupa/_lupa.pyx":779
 *             py_to_lua(self._runtime, L, name, wrap_none=True)
 *             py_to_lua(self._runtime, L, value)
 *             lua.lua_settable(L, -3)             # <<<<<<<<<<<<<<
 *         finally:
 *             lua.lua_settop(L, old_top)
 */
    lua_settable(__pyx_v_L, -3);
  }

  /* "lupa/_lupa.pyx":781
 *             lua.lua_settable(L, -3)
 *         finally:
 *             lua.lua_settop(L, old_top)             # <<<<<<<<<<<<<<
 *             unlock_runtime(self._runtime)
 *         return 0
 */
  /*finally:*/ {
    /*normal exit:*/{
      lua_settop(__pyx_v_L, __pyx_v_old_top);

      /* "lupa/_lupa.pyx":782
 *         finally:
 *             lua.lua_settop(L, old_top)
 *             unlock_runtime(self._runtime)             # <<<<<<<<<<<<<<
 *         return 0
 * 
 */
      __pyx_t_2 = ((PyObject *)__pyx_v_self->__pyx_base._runtime);
      __Pyx_INCREF(__pyx_t_2);
      __pyx_f_4lupa_5_lupa_unlock_runtime(((struct __pyx_obj_4lupa_5_lupa_LuaRuntime *)__pyx_t_2));
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      goto __pyx_L5;
    }
    __pyx_L4_error:;
    /*exception exit:*/{
      __Pyx_PyThreadState_declare
      __Pyx_PyThreadState_assign
      __pyx_t_7 = 0; __pyx_t_8 = 0; __pyx_t_9 = 0; __pyx_t_10 = 0; __pyx_t_11 = 0; __pyx_t_12 = 0;
      __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
      if (PY_MAJOR_VERSION >= 3) __Pyx_ExceptionSwap(&__pyx_t_10, &__pyx_t_11, &__pyx_t_12);
      if ((PY_MAJOR_VERSION < 3) || unlikely(__Pyx_GetException(&__pyx_t_7, &__pyx_t_8, &__pyx_t_9) < 0)) __Pyx_ErrFetch(&__pyx_t_7, &__pyx_t_8, &__pyx_t_9);
      __Pyx_XGOTREF(__pyx_t_7);
      __Pyx_XGOTREF(__pyx_t_8);
      __Pyx_XGOTREF(__pyx_t_9);
      __Pyx_XGOTREF(__pyx_t_10);
      __Pyx_XGOTREF(__pyx_t_11);
      __Pyx_XGOTREF(__pyx_t_12);
      __pyx_t_3 = __pyx_lineno; __pyx_t_5 = __pyx_clineno; __pyx_t_6 = __pyx_filename;
      {

        /* "lupa/_lupa.pyx":781
 *             lua.lua_settable(L, -3)
 *         finally:
 *             lua.lua_settop(L, old_top)             # <<<<<<<<<<<<<<
 *             unlock_runtime(self._runtime)
 *         return 0
 */
        lua_settop(__pyx_v_L, __pyx_v_old_top);

        /* "lupa/_lupa.pyx":782
 *         finally:
 *             lua.lua_settop(L, old_top)
 *             unlock_runtime(self._runtime)             # <<<<<<<<<<<<<<
 *         return 0
 * 
 */
        __pyx_t_2 = ((PyObject *)__pyx_v_self->__pyx_base._runtime);
        __Pyx_INCREF(__pyx_t_2);
        __pyx_f_4lupa_5_lupa_unlock_runtime(((struct __pyx_obj_4lupa_5_lupa_LuaRuntime *)__pyx_t_2));
        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      }
      if (PY_MAJOR_VERSION >= 3) {
        __Pyx_XGIVEREF(__pyx_t_10);
        __Pyx_XGIVEREF(__pyx_t_11);
        __Pyx_XGIVEREF(__pyx_t_12);
        __Pyx_ExceptionReset(__pyx_t_10, __pyx_t_11, __pyx_t_12);
      }
      __Pyx_XGIVEREF(__pyx_t_7);
      __Pyx_XGIVEREF(__pyx_t_8);
      __Pyx_XGIVEREF(__pyx_t_9);
      __Pyx_ErrRestore(__pyx_t_7, __pyx_t_8, __pyx_t_9);
      __pyx_t_7 = 0; __pyx_t_8 = 0; __pyx_t_9 = 0; __pyx_t_10 = 0; __pyx_t_11 = 0; __pyx_t_12 = 0;
      __pyx_lineno = __pyx_t_3; __pyx_clineno = __pyx_t_5; __pyx_filename = __pyx_t_6;
      goto __pyx_L1_error;
    }
    __pyx_L5:;
  }

  /* "lupa/_lupa.pyx":783
 *             lua.lua_settop(L, old_top)
 *             unlock_runtime(self._runtime)
 *         return 0             # <<<<<<<<<<<<<<
 * 
 *     def __delattr__(self, item):
 */
  __pyx_r = 0;
  goto __pyx_L0;

  /* "lupa/_lupa.pyx":770
 * 
 *     @cython.final
 *     cdef int _setitem(self, name, value) except -1:             # <<<<<<<<<<<<<<
 *         cdef lua_State* L = self._state
 *         lock_runtime(self._runtime)
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_AddTraceback("lupa._lupa._LuaTable._setitem", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lupa/_lupa.pyx":785
 *         return 0
 * 
 *     def __delattr__(self, item):             # <<<<<<<<<<<<<<
 *         assert self._runtime is not None
 *         if isinstance(item, unicode):
 */

/* Python wrapper */
static int __pyx_pw_4lupa_5_lupa_9_LuaTable_13__delattr__(PyObject *__pyx_v_self, PyObject *__pyx_v_item); /*proto*/
static int __pyx_pw_4lupa_5_lupa_9_LuaTable_13__delattr__(PyObject *__pyx_v_self, PyObject *__pyx_v_item) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__delattr__ (wrapper)", 0);
  __pyx_r = __pyx_pf_4lupa_5_lupa_9_LuaTable_12__delattr__(((struct __pyx_obj_4lupa_5_lupa__LuaTable *)__pyx_v_self), ((PyObject *)__pyx_v_item));

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

static int __pyx_pf_4lupa_5_lupa_9_LuaTable_12__delattr__(struct __pyx_obj_4lupa_5_lupa__LuaTable *__pyx_v_self, PyObject *__pyx_v_item) {
  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;
  int __pyx_t_6;
  PyObject *__pyx_t_7 = NULL;
  char const *__pyx_t_8;
  int __pyx_t_9;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__delattr__", 0);
  __Pyx_INCREF(__pyx_v_item);

  /* "lupa/_lupa.pyx":786
 * 
 *     def __delattr__(self, item):
 *         assert self._runtime is not None             # <<<<<<<<<<<<<<
 *         if isinstance(item, unicode):
 *             if (<unicode>item).startswith(u'__') and (<unicode>item).endswith(u'__'):
 */
  #ifndef CYTHON_WITHOUT_ASSERTIONS
  if (unlikely(!Py_OptimizeFlag)) {
    __pyx_t_1 = (((PyObject *)__pyx_v_self->__pyx_base._runtime) != Py_None);
    if (unlikely(!(__pyx_t_1 != 0))) {
      PyErr_SetNone(PyExc_AssertionError);
      __PYX_ERR(0, 786, __pyx_L1_error)
    }
  }
  #endif

  /* "lupa/_lupa.pyx":787
 *     def __delattr__(self, item):
 *         assert self._runtime is not None
 *         if isinstance(item, unicode):             # <<<<<<<<<<<<<<
 *             if (<unicode>item).startswith(u'__') and (<unicode>item).endswith(u'__'):
 *                 object.__delattr__(self, item)
 */
  __pyx_t_1 = PyUnicode_Check(__pyx_v_item); 
  __pyx_t_2 = (__pyx_t_1 != 0);
  if (__pyx_t_2) {

    /* "lupa/_lupa.pyx":788
 *         assert self._runtime is not None
 *         if isinstance(item, unicode):
 *             if (<unicode>item).startswith(u'__') and (<unicode>item).endswith(u'__'):             # <<<<<<<<<<<<<<
 *                 object.__delattr__(self, item)
 *                 return
 */
    if (unlikely(__pyx_v_item == Py_None)) {
      PyErr_Format(PyExc_AttributeError, "'NoneType' object has no attribute '%.30s'", "startswith");
      __PYX_ERR(0, 788, __pyx_L1_error)
    }
    __pyx_t_1 = __Pyx_PyUnicode_Tailmatch(((PyObject*)__pyx_v_item), __pyx_n_u__16, 0, PY_SSIZE_T_MAX, -1); if (unlikely(__pyx_t_1 == ((int)-1))) __PYX_ERR(0, 788, __pyx_L1_error)
    if ((__pyx_t_1 != 0)) {
    } else {
      __pyx_t_2 = (__pyx_t_1 != 0);
      goto __pyx_L5_bool_binop_done;
    }
    if (unlikely(__pyx_v_item == Py_None)) {
      PyErr_Format(PyExc_AttributeError, "'NoneType' object has no attribute '%.30s'", "endswith");
      __PYX_ERR(0, 788, __pyx_L1_error)
    }
    __pyx_t_1 = __Pyx_PyUnicode_Tailmatch(((PyObject*)__pyx_v_item), __pyx_n_u__16, 0, PY_SSIZE_T_MAX, 1); if (unlikely(__pyx_t_1 == ((int)-1))) __PYX_ERR(0, 788, __pyx_L1_error)
    __pyx_t_2 = (__pyx_t_1 != 0);
    __pyx_L5_bool_binop_done:;
    if (__pyx_t_2) {

      /* "lupa/_lupa.pyx":789
 *         if isinstance(item, unicode):
 *             if (<unicode>item).startswith(u'__') and (<unicode>item).endswith(u'__'):
 *                 object.__delattr__(self, item)             # <<<<<<<<<<<<<<
 *                 return
 *             item = (<unicode>item).encode(self._runtime._source_encoding)
 */
      __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_builtin_object, __pyx_n_s_delattr); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 789, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_t_5 = NULL;
      __pyx_t_6 = 0;
      if (CYTHON_UNPACK_METHODS && likely(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_6 = 1;
        }
      }
      #if CYTHON_FAST_PYCALL
      if (PyFunction_Check(__pyx_t_4)) {
        PyObject *__pyx_temp[3] = {__pyx_t_5, ((PyObject *)__pyx_v_self), __pyx_v_item};
        __pyx_t_3 = __Pyx_PyFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_6, 2+__pyx_t_6); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 789, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
        __Pyx_GOTREF(__pyx_t_3);
      } else
      #endif
      #if CYTHON_FAST_PYCCALL
      if (__Pyx_PyFastCFunction_Check(__pyx_t_4)) {
        PyObject *__pyx_temp[3] = {__pyx_t_5, ((PyObject *)__pyx_v_self), __pyx_v_item};
        __pyx_t_3 = __Pyx_PyCFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_6, 2+__pyx_t_6); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 789, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
        __Pyx_GOTREF(__pyx_t_3);
      } else
      #endif
      {
        __pyx_t_7 = PyTuple_New(2+__pyx_t_6); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 789, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_7);
        if (__pyx_t_5) {
          __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_5); __pyx_t_5 = NULL;
        }
        __Pyx_INCREF(((PyObject *)__pyx_v_self));
        __Pyx_GIVEREF(((PyObject *)__pyx_v_self));
        PyTuple_SET_ITEM(__pyx_t_7, 0+__pyx_t_6, ((PyObject *)__pyx_v_self));
        __Pyx_INCREF(__pyx_v_item);
        __Pyx_GIVEREF(__pyx_v_item);
        PyTuple_SET_ITEM(__pyx_t_7, 1+__pyx_t_6, __pyx_v_item);
        __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_7, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 789, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_3);
        __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      }
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

      /* "lupa/_lupa.pyx":790
 *             if (<unicode>item).startswith(u'__') and (<unicode>item).endswith(u'__'):
 *                 object.__delattr__(self, item)
 *                 return             # <<<<<<<<<<<<<<
 *             item = (<unicode>item).encode(self._runtime._source_encoding)
 *         elif isinstance(item, bytes) and (<bytes>item).startswith(b'__') and (<bytes>item).endswith(b'__'):
 */
      __pyx_r = 0;
      goto __pyx_L0;

      /* "lupa/_lupa.pyx":788
 *         assert self._runtime is not None
 *         if isinstance(item, unicode):
 *             if (<unicode>item).startswith(u'__') and (<unicode>item).endswith(u'__'):             # <<<<<<<<<<<<<<
 *                 object.__delattr__(self, item)
 *                 return
 */
    }

    /* "lupa/_lupa.pyx":791
 *                 object.__delattr__(self, item)
 *                 return
 *             item = (<unicode>item).encode(self._runtime._source_encoding)             # <<<<<<<<<<<<<<
 *         elif isinstance(item, bytes) and (<bytes>item).startswith(b'__') and (<bytes>item).endswith(b'__'):
 *             object.__delattr__(self, item)
 */
    if (unlikely(__pyx_v_item == Py_None)) {
      PyErr_Format(PyExc_AttributeError, "'NoneType' object has no attribute '%.30s'", "encode");
      __PYX_ERR(0, 791, __pyx_L1_error)
    }
    if (unlikely(__pyx_v_self->__pyx_base._runtime->_source_encoding == Py_None)) {
      PyErr_SetString(PyExc_TypeError, "expected bytes, NoneType found");
      __PYX_ERR(0, 791, __pyx_L1_error)
    }
    __pyx_t_8 = __Pyx_PyBytes_AsString(__pyx_v_self->__pyx_base._runtime->_source_encoding); if (unlikely((!__pyx_t_8) && PyErr_Occurred())) __PYX_ERR(0, 791, __pyx_L1_error)
    __pyx_t_3 = PyUnicode_AsEncodedString(((PyObject*)__pyx_v_item), __pyx_t_8, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 791, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF_SET(__pyx_v_item, __pyx_t_3);
    __pyx_t_3 = 0;

    /* "lupa/_lupa.pyx":787
 *     def __delattr__(self, item):
 *         assert self._runtime is not None
 *         if isinstance(item, unicode):             # <<<<<<<<<<<<<<
 *             if (<unicode>item).startswith(u'__') and (<unicode>item).endswith(u'__'):
 *                 object.__delattr__(self, item)
 */
    goto __pyx_L3;
  }

  /* "lupa/_lupa.pyx":792
 *                 return
 *             item = (<unicode>item).encode(self._runtime._source_encoding)
 *         elif isinstance(item, bytes) and (<bytes>item).startswith(b'__') and (<bytes>item).endswith(b'__'):             # <<<<<<<<<<<<<<
 *             object.__delattr__(self, item)
 *             return
 */
  __pyx_t_1 = PyBytes_Check(__pyx_v_item); 
  __pyx_t_9 = (__pyx_t_1 != 0);
  if (__pyx_t_9) {
  } else {
    __pyx_t_2 = __pyx_t_9;
    goto __pyx_L7_bool_binop_done;
  }
  if (unlikely(__pyx_v_item == Py_None)) {
    PyErr_Format(PyExc_AttributeError, "'NoneType' object has no attribute '%.30s'", "startswith");
    __PYX_ERR(0, 792, __pyx_L1_error)
  }
  __pyx_t_9 = __Pyx_PyBytes_Tailmatch(((PyObject*)__pyx_v_item), __pyx_n_b__16, 0, PY_SSIZE_T_MAX, -1); if (unlikely(__pyx_t_9 == ((int)-1))) __PYX_ERR(0, 792, __pyx_L1_error)
  if ((__pyx_t_9 != 0)) {
  } else {
    __pyx_t_2 = (__pyx_t_9 != 0);
    goto __pyx_L7_bool_binop_done;
  }
  if (unlikely(__pyx_v_item == Py_None)) {
    PyErr_Format(PyExc_AttributeError, "'NoneType' object has no attribute '%.30s'", "endswith");
    __PYX_ERR(0, 792, __pyx_L1_error)
  }
  __pyx_t_9 = __Pyx_PyBytes_Tailmatch(((PyObject*)__pyx_v_item), __pyx_n_b__16, 0, PY_SSIZE_T_MAX, 1); if (unlikely(__pyx_t_9 == ((int)-1))) __PYX_ERR(0, 792, __pyx_L1_error)
  __pyx_t_2 = (__pyx_t_9 != 0);
  __pyx_L7_bool_binop_done:;
  if (__pyx_t_2) {

    /* "lupa/_lupa.pyx":793
 *             item = (<unicode>item).encode(self._runtime._source_encoding)
 *         elif isinstance(item, bytes) and (<bytes>item).startswith(b'__') and (<bytes>item).endswith(b'__'):
 *             object.__delattr__(self, item)             # <<<<<<<<<<<<<<
 *             return
 *         self._delitem(item)
 */
    __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_builtin_object, __pyx_n_s_delattr); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 793, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_7 = NULL;
    __pyx_t_6 = 0;
    if (CYTHON_UNPACK_METHODS && likely(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_6 = 1;
      }
    }
    #if CYTHON_FAST_PYCALL
    if (PyFunction_Check(__pyx_t_4)) {
      PyObject *__pyx_temp[3] = {__pyx_t_7, ((PyObject *)__pyx_v_self), __pyx_v_item};
      __pyx_t_3 = __Pyx_PyFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_6, 2+__pyx_t_6); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 793, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
      __Pyx_GOTREF(__pyx_t_3);
    } else
    #endif
    #if CYTHON_FAST_PYCCALL
    if (__Pyx_PyFastCFunction_Check(__pyx_t_4)) {
      PyObject *__pyx_temp[3] = {__pyx_t_7, ((PyObject *)__pyx_v_self), __pyx_v_item};
      __pyx_t_3 = __Pyx_PyCFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_6, 2+__pyx_t_6); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 793, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
      __Pyx_GOTREF(__pyx_t_3);
    } else
    #endif
    {
      __pyx_t_5 = PyTuple_New(2+__pyx_t_6); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 793, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
      if (__pyx_t_7) {
        __Pyx_GIVEREF(__pyx_t_7); PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_7); __pyx_t_7 = NULL;
      }
      __Pyx_INCREF(((PyObject *)__pyx_v_self));
      __Pyx_GIVEREF(((PyObject *)__pyx_v_self));
      PyTuple_SET_ITEM(__pyx_t_5, 0+__pyx_t_6, ((PyObject *)__pyx_v_self));
      __Pyx_INCREF(__pyx_v_item);
      __Pyx_GIVEREF(__pyx_v_item);
      PyTuple_SET_ITEM(__pyx_t_5, 1+__pyx_t_6, __pyx_v_item);
      __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_5, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 793, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    }
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

    /* "lupa/_lupa.pyx":794
 *         elif isinstance(item, bytes) and (<bytes>item).startswith(b'__') and (<bytes>item).endswith(b'__'):
 *             object.__delattr__(self, item)
 *             return             # <<<<<<<<<<<<<<
 *         self._delitem(item)
 * 
 */
    __pyx_r = 0;
    goto __pyx_L0;

    /* "lupa/_lupa.pyx":792
 *                 return
 *             item = (<unicode>item).encode(self._runtime._source_encoding)
 *         elif isinstance(item, bytes) and (<bytes>item).startswith(b'__') and (<bytes>item).endswith(b'__'):             # <<<<<<<<<<<<<<
 *             object.__delattr__(self, item)
 *             return
 */
  }
  __pyx_L3:;

  /* "lupa/_lupa.pyx":795
 *             object.__delattr__(self, item)
 *             return
 *         self._delitem(item)             # <<<<<<<<<<<<<<
 * 
 *     def __delitem__(self, key):
 */
  __pyx_t_3 = __pyx_f_4lupa_5_lupa_9_LuaTable__delitem(__pyx_v_self, __pyx_v_item); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 795, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

  /* "lupa/_lupa.pyx":785
 *         return 0
 * 
 *     def __delattr__(self, item):             # <<<<<<<<<<<<<<
 *         assert self._runtime is not None
 *         if isinstance(item, unicode):
 */

  /* 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_7);
  __Pyx_AddTraceback("lupa._lupa._LuaTable.__delattr__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_item);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lupa/_lupa.pyx":797
 *         self._delitem(item)
 * 
 *     def __delitem__(self, key):             # <<<<<<<<<<<<<<
 *         self._delitem(key)
 * 
 */

/* Python wrapper */
static int __pyx_pw_4lupa_5_lupa_9_LuaTable_15__delitem__(PyObject *__pyx_v_self, PyObject *__pyx_v_key); /*proto*/
static int __pyx_pw_4lupa_5_lupa_9_LuaTable_15__delitem__(PyObject *__pyx_v_self, PyObject *__pyx_v_key) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__delitem__ (wrapper)", 0);
  __pyx_r = __pyx_pf_4lupa_5_lupa_9_LuaTable_14__delitem__(((struct __pyx_obj_4lupa_5_lupa__LuaTable *)__pyx_v_self), ((PyObject *)__pyx_v_key));

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

static int __pyx_pf_4lupa_5_lupa_9_LuaTable_14__delitem__(struct __pyx_obj_4lupa_5_lupa__LuaTable *__pyx_v_self, PyObject *__pyx_v_key) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__delitem__", 0);

  /* "lupa/_lupa.pyx":798
 * 
 *     def __delitem__(self, key):
 *         self._delitem(key)             # <<<<<<<<<<<<<<
 * 
 *     @cython.final
 */
  __pyx_t_1 = __pyx_f_4lupa_5_lupa_9_LuaTable__delitem(__pyx_v_self, __pyx_v_key); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 798, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "lupa/_lupa.pyx":797
 *         self._delitem(item)
 * 
 *     def __delitem__(self, key):             # <<<<<<<<<<<<<<
 *         self._delitem(key)
 * 
 */

  /* function exit code */
  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("lupa._lupa._LuaTable.__delitem__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lupa/_lupa.pyx":801
 * 
 *     @cython.final
 *     cdef _delitem(self, name):             # <<<<<<<<<<<<<<
 *         cdef lua_State* L = self._state
 *         lock_runtime(self._runtime)
 */

static PyObject *__pyx_f_4lupa_5_lupa_9_LuaTable__delitem(struct __pyx_obj_4lupa_5_lupa__LuaTable *__pyx_v_self, PyObject *__pyx_v_name) {
  lua_State *__pyx_v_L;
  int __pyx_v_old_top;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  lua_State *__pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  int __pyx_t_3;
  struct __pyx_opt_args_4lupa_5_lupa_py_to_lua __pyx_t_4;
  int __pyx_t_5;
  char const *__pyx_t_6;
  PyObject *__pyx_t_7 = NULL;
  PyObject *__pyx_t_8 = NULL;
  PyObject *__pyx_t_9 = NULL;
  PyObject *__pyx_t_10 = NULL;
  PyObject *__pyx_t_11 = NULL;
  PyObject *__pyx_t_12 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("_delitem", 0);

  /* "lupa/_lupa.pyx":802
 *     @cython.final
 *     cdef _delitem(self, name):
 *         cdef lua_State* L = self._state             # <<<<<<<<<<<<<<
 *         lock_runtime(self._runtime)
 *         old_top = lua.lua_gettop(L)
 */
  __pyx_t_1 = __pyx_v_self->__pyx_base._state;
  __pyx_v_L = __pyx_t_1;

  /* "lupa/_lupa.pyx":803
 *     cdef _delitem(self, name):
 *         cdef lua_State* L = self._state
 *         lock_runtime(self._runtime)             # <<<<<<<<<<<<<<
 *         old_top = lua.lua_gettop(L)
 *         try:
 */
  __pyx_t_2 = ((PyObject *)__pyx_v_self->__pyx_base._runtime);
  __Pyx_INCREF(__pyx_t_2);
  __pyx_t_3 = __pyx_f_4lupa_5_lupa_lock_runtime(((struct __pyx_obj_4lupa_5_lupa_LuaRuntime *)__pyx_t_2)); if (unlikely(__pyx_t_3 == ((int)-1))) __PYX_ERR(0, 803, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "lupa/_lupa.pyx":804
 *         cdef lua_State* L = self._state
 *         lock_runtime(self._runtime)
 *         old_top = lua.lua_gettop(L)             # <<<<<<<<<<<<<<
 *         try:
 *             self.push_lua_object()
 */
  __pyx_v_old_top = lua_gettop(__pyx_v_L);

  /* "lupa/_lupa.pyx":805
 *         lock_runtime(self._runtime)
 *         old_top = lua.lua_gettop(L)
 *         try:             # <<<<<<<<<<<<<<
 *             self.push_lua_object()
 *             py_to_lua(self._runtime, L, name, wrap_none=True)
 */
  /*try:*/ {

    /* "lupa/_lupa.pyx":806
 *         old_top = lua.lua_gettop(L)
 *         try:
 *             self.push_lua_object()             # <<<<<<<<<<<<<<
 *             py_to_lua(self._runtime, L, name, wrap_none=True)
 *             lua.lua_pushnil(L)
 */
    __pyx_t_3 = __pyx_f_4lupa_5_lupa_10_LuaObject_push_lua_object(((struct __pyx_obj_4lupa_5_lupa__LuaObject *)__pyx_v_self)); if (unlikely(__pyx_t_3 == ((int)-1))) __PYX_ERR(0, 806, __pyx_L4_error)

    /* "lupa/_lupa.pyx":807
 *         try:
 *             self.push_lua_object()
 *             py_to_lua(self._runtime, L, name, wrap_none=True)             # <<<<<<<<<<<<<<
 *             lua.lua_pushnil(L)
 *             lua.lua_settable(L, -3)
 */
    __pyx_t_2 = ((PyObject *)__pyx_v_self->__pyx_base._runtime);
    __Pyx_INCREF(__pyx_t_2);
    __pyx_t_4.__pyx_n = 1;
    __pyx_t_4.wrap_none = 1;
    __pyx_t_3 = __pyx_f_4lupa_5_lupa_py_to_lua(((struct __pyx_obj_4lupa_5_lupa_LuaRuntime *)__pyx_t_2), __pyx_v_L, __pyx_v_name, &__pyx_t_4); if (unlikely(__pyx_t_3 == ((int)-1))) __PYX_ERR(0, 807, __pyx_L4_error)
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

    /* "lupa/_lupa.pyx":808
 *             self.push_lua_object()
 *             py_to_lua(self._runtime, L, name, wrap_none=True)
 *             lua.lua_pushnil(L)             # <<<<<<<<<<<<<<
 *             lua.lua_settable(L, -3)
 *         finally:
 */
    lua_pushnil(__pyx_v_L);

    /* "lupa/_lupa.pyx":809
 *             py_to_lua(self._runtime, L, name, wrap_none=True)
 *             lua.lua_pushnil(L)
 *             lua.lua_settable(L, -3)             # <<<<<<<<<<<<<<
 *         finally:
 *             lua.lua_settop(L, old_top)
 */
    lua_settable(__pyx_v_L, -3);
  }

  /* "lupa/_lupa.pyx":811
 *             lua.lua_settable(L, -3)
 *         finally:
 *             lua.lua_settop(L, old_top)             # <<<<<<<<<<<<<<
 *             unlock_runtime(self._runtime)
 * 
 */
  /*finally:*/ {
    /*normal exit:*/{
      lua_settop(__pyx_v_L, __pyx_v_old_top);

      /* "lupa/_lupa.pyx":812
 *         finally:
 *             lua.lua_settop(L, old_top)
 *             unlock_runtime(self._runtime)             # <<<<<<<<<<<<<<
 * 
 * 
 */
      __pyx_t_2 = ((PyObject *)__pyx_v_self->__pyx_base._runtime);
      __Pyx_INCREF(__pyx_t_2);
      __pyx_f_4lupa_5_lupa_unlock_runtime(((struct __pyx_obj_4lupa_5_lupa_LuaRuntime *)__pyx_t_2));
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      goto __pyx_L5;
    }
    __pyx_L4_error:;
    /*exception exit:*/{
      __Pyx_PyThreadState_declare
      __Pyx_PyThreadState_assign
      __pyx_t_7 = 0; __pyx_t_8 = 0; __pyx_t_9 = 0; __pyx_t_10 = 0; __pyx_t_11 = 0; __pyx_t_12 = 0;
      __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
      if (PY_MAJOR_VERSION >= 3) __Pyx_ExceptionSwap(&__pyx_t_10, &__pyx_t_11, &__pyx_t_12);
      if ((PY_MAJOR_VERSION < 3) || unlikely(__Pyx_GetException(&__pyx_t_7, &__pyx_t_8, &__pyx_t_9) < 0)) __Pyx_ErrFetch(&__pyx_t_7, &__pyx_t_8, &__pyx_t_9);
      __Pyx_XGOTREF(__pyx_t_7);
      __Pyx_XGOTREF(__pyx_t_8);
      __Pyx_XGOTREF(__pyx_t_9);
      __Pyx_XGOTREF(__pyx_t_10);
      __Pyx_XGOTREF(__pyx_t_11);
      __Pyx_XGOTREF(__pyx_t_12);
      __pyx_t_3 = __pyx_lineno; __pyx_t_5 = __pyx_clineno; __pyx_t_6 = __pyx_filename;
      {

        /* "lupa/_lupa.pyx":811
 *             lua.lua_settable(L, -3)
 *         finally:
 *             lua.lua_settop(L, old_top)             # <<<<<<<<<<<<<<
 *             unlock_runtime(self._runtime)
 * 
 */
        lua_settop(__pyx_v_L, __pyx_v_old_top);

        /* "lupa/_lupa.pyx":812
 *         finally:
 *             lua.lua_settop(L, old_top)
 *             unlock_runtime(self._runtime)             # <<<<<<<<<<<<<<
 * 
 * 
 */
        __pyx_t_2 = ((PyObject *)__pyx_v_self->__pyx_base._runtime);
        __Pyx_INCREF(__pyx_t_2);
        __pyx_f_4lupa_5_lupa_unlock_runtime(((struct __pyx_obj_4lupa_5_lupa_LuaRuntime *)__pyx_t_2));
        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      }
      if (PY_MAJOR_VERSION >= 3) {
        __Pyx_XGIVEREF(__pyx_t_10);
        __Pyx_XGIVEREF(__pyx_t_11);
        __Pyx_XGIVEREF(__pyx_t_12);
        __Pyx_ExceptionReset(__pyx_t_10, __pyx_t_11, __pyx_t_12);
      }
      __Pyx_XGIVEREF(__pyx_t_7);
      __Pyx_XGIVEREF(__pyx_t_8);
      __Pyx_XGIVEREF(__pyx_t_9);
      __Pyx_ErrRestore(__pyx_t_7, __pyx_t_8, __pyx_t_9);
      __pyx_t_7 = 0; __pyx_t_8 = 0; __pyx_t_9 = 0; __pyx_t_10 = 0; __pyx_t_11 = 0; __pyx_t_12 = 0;
      __pyx_lineno = __pyx_t_3; __pyx_clineno = __pyx_t_5; __pyx_filename = __pyx_t_6;
      goto __pyx_L1_error;
    }
    __pyx_L5:;
  }

  /* "lupa/_lupa.pyx":801
 * 
 *     @cython.final
 *     cdef _delitem(self, name):             # <<<<<<<<<<<<<<
 *         cdef lua_State* L = self._state
 *         lock_runtime(self._runtime)
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_AddTraceback("lupa._lupa._LuaTable._delitem", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "(tree fragment)":1
 * def __reduce_cython__(self):             # <<<<<<<<<<<<<<
 *     raise TypeError("self._state cannot be converted to a Python object for pickling")
 * def __setstate_cython__(self, __pyx_state):
 */

/* Python wrapper */
static PyObject *__pyx_pw_4lupa_5_lupa_9_LuaTable_17__reduce_cython__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static char __pyx_doc_4lupa_5_lupa_9_LuaTable_16__reduce_cython__[] = "_LuaTable.__reduce_cython__(self)";
static PyMethodDef __pyx_mdef_4lupa_5_lupa_9_LuaTable_17__reduce_cython__ = {"__reduce_cython__", (PyCFunction)__pyx_pw_4lupa_5_lupa_9_LuaTable_17__reduce_cython__, METH_NOARGS, __pyx_doc_4lupa_5_lupa_9_LuaTable_16__reduce_cython__};
static PyObject *__pyx_pw_4lupa_5_lupa_9_LuaTable_17__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_4lupa_5_lupa_9_LuaTable_16__reduce_cython__(((struct __pyx_obj_4lupa_5_lupa__LuaTable *)__pyx_v_self));

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

static PyObject *__pyx_pf_4lupa_5_lupa_9_LuaTable_16__reduce_cython__(CYTHON_UNUSED struct __pyx_obj_4lupa_5_lupa__LuaTable *__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("self._state cannot be converted to a Python object for pickling")             # <<<<<<<<<<<<<<
 * def __setstate_cython__(self, __pyx_state):
 *     raise TypeError("self._state cannot be converted to a Python object for pickling")
 */
  __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__19, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 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(2, 2, __pyx_L1_error)

  /* "(tree fragment)":1
 * def __reduce_cython__(self):             # <<<<<<<<<<<<<<
 *     raise TypeError("self._state cannot be converted to a Python object for pickling")
 * def __setstate_cython__(self, __pyx_state):
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("lupa._lupa._LuaTable.__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("self._state cannot be converted to a Python object for pickling")
 * def __setstate_cython__(self, __pyx_state):             # <<<<<<<<<<<<<<
 *     raise TypeError("self._state cannot be converted to a Python object for pickling")
 */

/* Python wrapper */
static PyObject *__pyx_pw_4lupa_5_lupa_9_LuaTable_19__setstate_cython__(PyObject *__pyx_v_self, PyObject *__pyx_v___pyx_state); /*proto*/
static char __pyx_doc_4lupa_5_lupa_9_LuaTable_18__setstate_cython__[] = "_LuaTable.__setstate_cython__(self, __pyx_state)";
static PyMethodDef __pyx_mdef_4lupa_5_lupa_9_LuaTable_19__setstate_cython__ = {"__setstate_cython__", (PyCFunction)__pyx_pw_4lupa_5_lupa_9_LuaTable_19__setstate_cython__, METH_O, __pyx_doc_4lupa_5_lupa_9_LuaTable_18__setstate_cython__};
static PyObject *__pyx_pw_4lupa_5_lupa_9_LuaTable_19__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_4lupa_5_lupa_9_LuaTable_18__setstate_cython__(((struct __pyx_obj_4lupa_5_lupa__LuaTable *)__pyx_v_self), ((PyObject *)__pyx_v___pyx_state));

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

static PyObject *__pyx_pf_4lupa_5_lupa_9_LuaTable_18__setstate_cython__(CYTHON_UNUSED struct __pyx_obj_4lupa_5_lupa__LuaTable *__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("self._state cannot be converted to a Python object for pickling")
 * def __setstate_cython__(self, __pyx_state):
 *     raise TypeError("self._state cannot be converted to a Python object for pickling")             # <<<<<<<<<<<<<<
 */
  __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__20, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 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(2, 4, __pyx_L1_error)

  /* "(tree fragment)":3
 * def __reduce_cython__(self):
 *     raise TypeError("self._state cannot be converted to a Python object for pickling")
 * def __setstate_cython__(self, __pyx_state):             # <<<<<<<<<<<<<<
 *     raise TypeError("self._state cannot be converted to a Python object for pickling")
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("lupa._lupa._LuaTable.__setstate_cython__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lupa/_lupa.pyx":815
 * 
 * 
 * cdef _LuaTable new_lua_table(LuaRuntime runtime, lua_State* L, int n):             # <<<<<<<<<<<<<<
 *     cdef _LuaTable obj = _LuaTable.__new__(_LuaTable)
 *     init_lua_object(obj, runtime, L, n)
 */

static struct __pyx_obj_4lupa_5_lupa__LuaTable *__pyx_f_4lupa_5_lupa_new_lua_table(struct __pyx_obj_4lupa_5_lupa_LuaRuntime *__pyx_v_runtime, lua_State *__pyx_v_L, int __pyx_v_n) {
  struct __pyx_obj_4lupa_5_lupa__LuaTable *__pyx_v_obj = 0;
  struct __pyx_obj_4lupa_5_lupa__LuaTable *__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("new_lua_table", 0);

  /* "lupa/_lupa.pyx":816
 * 
 * cdef _LuaTable new_lua_table(LuaRuntime runtime, lua_State* L, int n):
 *     cdef _LuaTable obj = _LuaTable.__new__(_LuaTable)             # <<<<<<<<<<<<<<
 *     init_lua_object(obj, runtime, L, n)
 *     return obj
 */
  __pyx_t_1 = ((PyObject *)__pyx_tp_new_4lupa_5_lupa__LuaTable(((PyTypeObject *)__pyx_ptype_4lupa_5_lupa__LuaTable), __pyx_empty_tuple, NULL)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 816, __pyx_L1_error)
  __Pyx_GOTREF(((PyObject *)__pyx_t_1));
  __pyx_v_obj = ((struct __pyx_obj_4lupa_5_lupa__LuaTable *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "lupa/_lupa.pyx":817
 * cdef _LuaTable new_lua_table(LuaRuntime runtime, lua_State* L, int n):
 *     cdef _LuaTable obj = _LuaTable.__new__(_LuaTable)
 *     init_lua_object(obj, runtime, L, n)             # <<<<<<<<<<<<<<
 *     return obj
 * 
 */
  __pyx_f_4lupa_5_lupa_init_lua_object(((struct __pyx_obj_4lupa_5_lupa__LuaObject *)__pyx_v_obj), __pyx_v_runtime, __pyx_v_L, __pyx_v_n);

  /* "lupa/_lupa.pyx":818
 *     cdef _LuaTable obj = _LuaTable.__new__(_LuaTable)
 *     init_lua_object(obj, runtime, L, n)
 *     return obj             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_XDECREF(((PyObject *)__pyx_r));
  __Pyx_INCREF(((PyObject *)__pyx_v_obj));
  __pyx_r = __pyx_v_obj;
  goto __pyx_L0;

  /* "lupa/_lupa.pyx":815
 * 
 * 
 * cdef _LuaTable new_lua_table(LuaRuntime runtime, lua_State* L, int n):             # <<<<<<<<<<<<<<
 *     cdef _LuaTable obj = _LuaTable.__new__(_LuaTable)
 *     init_lua_object(obj, runtime, L, n)
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("lupa._lupa.new_lua_table", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_obj);
  __Pyx_XGIVEREF((PyObject *)__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lupa/_lupa.pyx":826
 *     """A Lua function (which may become a coroutine).
 *     """
 *     def coroutine(self, *args):             # <<<<<<<<<<<<<<
 *         """Create a Lua coroutine from a Lua function and call it with
 *         the passed parameters to start it up.
 */

/* Python wrapper */
static PyObject *__pyx_pw_4lupa_5_lupa_12_LuaFunction_1coroutine(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4lupa_5_lupa_12_LuaFunction_coroutine[] = "_LuaFunction.coroutine(self, *args)\nCreate a Lua coroutine from a Lua function and call it with\n        the passed parameters to start it up.\n        ";
static PyMethodDef __pyx_mdef_4lupa_5_lupa_12_LuaFunction_1coroutine = {"coroutine", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_4lupa_5_lupa_12_LuaFunction_1coroutine, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4lupa_5_lupa_12_LuaFunction_coroutine};
static PyObject *__pyx_pw_4lupa_5_lupa_12_LuaFunction_1coroutine(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_args = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("coroutine (wrapper)", 0);
  if (unlikely(__pyx_kwds) && unlikely(PyDict_Size(__pyx_kwds) > 0) && unlikely(!__Pyx_CheckKeywordStrings(__pyx_kwds, "coroutine", 0))) return NULL;
  __Pyx_INCREF(__pyx_args);
  __pyx_v_args = __pyx_args;
  __pyx_r = __pyx_pf_4lupa_5_lupa_12_LuaFunction_coroutine(((struct __pyx_obj_4lupa_5_lupa__LuaFunction *)__pyx_v_self), __pyx_v_args);

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

static PyObject *__pyx_pf_4lupa_5_lupa_12_LuaFunction_coroutine(struct __pyx_obj_4lupa_5_lupa__LuaFunction *__pyx_v_self, PyObject *__pyx_v_args) {
  lua_State *__pyx_v_L;
  lua_State *__pyx_v_co;
  struct __pyx_obj_4lupa_5_lupa__LuaThread *__pyx_v_thread = 0;
  int __pyx_v_old_top;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  lua_State *__pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  int __pyx_t_4;
  int __pyx_t_5;
  PyObject *__pyx_t_6 = NULL;
  int __pyx_t_7;
  char const *__pyx_t_8;
  PyObject *__pyx_t_9 = NULL;
  PyObject *__pyx_t_10 = NULL;
  PyObject *__pyx_t_11 = NULL;
  PyObject *__pyx_t_12 = NULL;
  PyObject *__pyx_t_13 = NULL;
  PyObject *__pyx_t_14 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("coroutine", 0);

  /* "lupa/_lupa.pyx":830
 *         the passed parameters to start it up.
 *         """
 *         assert self._runtime is not None             # <<<<<<<<<<<<<<
 *         cdef lua_State* L = self._state
 *         cdef lua_State* co
 */
  #ifndef CYTHON_WITHOUT_ASSERTIONS
  if (unlikely(!Py_OptimizeFlag)) {
    __pyx_t_1 = (((PyObject *)__pyx_v_self->__pyx_base._runtime) != Py_None);
    if (unlikely(!(__pyx_t_1 != 0))) {
      PyErr_SetNone(PyExc_AssertionError);
      __PYX_ERR(0, 830, __pyx_L1_error)
    }
  }
  #endif

  /* "lupa/_lupa.pyx":831
 *         """
 *         assert self._runtime is not None
 *         cdef lua_State* L = self._state             # <<<<<<<<<<<<<<
 *         cdef lua_State* co
 *         cdef _LuaThread thread
 */
  __pyx_t_2 = __pyx_v_self->__pyx_base._state;
  __pyx_v_L = __pyx_t_2;

  /* "lupa/_lupa.pyx":834
 *         cdef lua_State* co
 *         cdef _LuaThread thread
 *         lock_runtime(self._runtime)             # <<<<<<<<<<<<<<
 *         old_top = lua.lua_gettop(L)
 *         try:
 */
  __pyx_t_3 = ((PyObject *)__pyx_v_self->__pyx_base._runtime);
  __Pyx_INCREF(__pyx_t_3);
  __pyx_t_4 = __pyx_f_4lupa_5_lupa_lock_runtime(((struct __pyx_obj_4lupa_5_lupa_LuaRuntime *)__pyx_t_3)); if (unlikely(__pyx_t_4 == ((int)-1))) __PYX_ERR(0, 834, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

  /* "lupa/_lupa.pyx":835
 *         cdef _LuaThread thread
 *         lock_runtime(self._runtime)
 *         old_top = lua.lua_gettop(L)             # <<<<<<<<<<<<<<
 *         try:
 *             self.push_lua_object()
 */
  __pyx_v_old_top = lua_gettop(__pyx_v_L);

  /* "lupa/_lupa.pyx":836
 *         lock_runtime(self._runtime)
 *         old_top = lua.lua_gettop(L)
 *         try:             # <<<<<<<<<<<<<<
 *             self.push_lua_object()
 *             if not lua.lua_isfunction(L, -1) or lua.lua_iscfunction(L, -1):
 */
  /*try:*/ {

    /* "lupa/_lupa.pyx":837
 *         old_top = lua.lua_gettop(L)
 *         try:
 *             self.push_lua_object()             # <<<<<<<<<<<<<<
 *             if not lua.lua_isfunction(L, -1) or lua.lua_iscfunction(L, -1):
 *                 raise TypeError("Lua object is not a function")
 */
    __pyx_t_4 = __pyx_f_4lupa_5_lupa_10_LuaObject_push_lua_object(((struct __pyx_obj_4lupa_5_lupa__LuaObject *)__pyx_v_self)); if (unlikely(__pyx_t_4 == ((int)-1))) __PYX_ERR(0, 837, __pyx_L4_error)

    /* "lupa/_lupa.pyx":838
 *         try:
 *             self.push_lua_object()
 *             if not lua.lua_isfunction(L, -1) or lua.lua_iscfunction(L, -1):             # <<<<<<<<<<<<<<
 *                 raise TypeError("Lua object is not a function")
 *             # create thread stack and push the function on it
 */
    __pyx_t_5 = ((!(lua_isfunction(__pyx_v_L, -1) != 0)) != 0);
    if (!__pyx_t_5) {
    } else {
      __pyx_t_1 = __pyx_t_5;
      goto __pyx_L7_bool_binop_done;
    }
    __pyx_t_5 = (lua_iscfunction(__pyx_v_L, -1) != 0);
    __pyx_t_1 = __pyx_t_5;
    __pyx_L7_bool_binop_done:;
    if (unlikely(__pyx_t_1)) {

      /* "lupa/_lupa.pyx":839
 *             self.push_lua_object()
 *             if not lua.lua_isfunction(L, -1) or lua.lua_iscfunction(L, -1):
 *                 raise TypeError("Lua object is not a function")             # <<<<<<<<<<<<<<
 *             # create thread stack and push the function on it
 *             co = lua.lua_newthread(L)
 */
      __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__21, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 839, __pyx_L4_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, 839, __pyx_L4_error)

      /* "lupa/_lupa.pyx":838
 *         try:
 *             self.push_lua_object()
 *             if not lua.lua_isfunction(L, -1) or lua.lua_iscfunction(L, -1):             # <<<<<<<<<<<<<<
 *                 raise TypeError("Lua object is not a function")
 *             # create thread stack and push the function on it
 */
    }

    /* "lupa/_lupa.pyx":841
 *                 raise TypeError("Lua object is not a function")
 *             # create thread stack and push the function on it
 *             co = lua.lua_newthread(L)             # <<<<<<<<<<<<<<
 *             lua.lua_pushvalue(L, 1)
 *             lua.lua_xmove(L, co, 1)
 */
    __pyx_v_co = lua_newthread(__pyx_v_L);

    /* "lupa/_lupa.pyx":842
 *             # create thread stack and push the function on it
 *             co = lua.lua_newthread(L)
 *             lua.lua_pushvalue(L, 1)             # <<<<<<<<<<<<<<
 *             lua.lua_xmove(L, co, 1)
 *             # create the coroutine object and initialise it
 */
    lua_pushvalue(__pyx_v_L, 1);

    /* "lupa/_lupa.pyx":843
 *             co = lua.lua_newthread(L)
 *             lua.lua_pushvalue(L, 1)
 *             lua.lua_xmove(L, co, 1)             # <<<<<<<<<<<<<<
 *             # create the coroutine object and initialise it
 *             assert lua.lua_isthread(L, -1)
 */
    lua_xmove(__pyx_v_L, __pyx_v_co, 1);

    /* "lupa/_lupa.pyx":845
 *             lua.lua_xmove(L, co, 1)
 *             # create the coroutine object and initialise it
 *             assert lua.lua_isthread(L, -1)             # <<<<<<<<<<<<<<
 *             thread = new_lua_thread(self._runtime, L, -1)
 *             thread._arguments = args # always a tuple, not None !
 */
    #ifndef CYTHON_WITHOUT_ASSERTIONS
    if (unlikely(!Py_OptimizeFlag)) {
      if (unlikely(!(lua_isthread(__pyx_v_L, -1) != 0))) {
        PyErr_SetNone(PyExc_AssertionError);
        __PYX_ERR(0, 845, __pyx_L4_error)
      }
    }
    #endif

    /* "lupa/_lupa.pyx":846
 *             # create the coroutine object and initialise it
 *             assert lua.lua_isthread(L, -1)
 *             thread = new_lua_thread(self._runtime, L, -1)             # <<<<<<<<<<<<<<
 *             thread._arguments = args # always a tuple, not None !
 *             return thread
 */
    __pyx_t_3 = ((PyObject *)__pyx_v_self->__pyx_base._runtime);
    __Pyx_INCREF(__pyx_t_3);
    __pyx_t_6 = ((PyObject *)__pyx_f_4lupa_5_lupa_new_lua_thread(((struct __pyx_obj_4lupa_5_lupa_LuaRuntime *)__pyx_t_3), __pyx_v_L, -1)); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 846, __pyx_L4_error)
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_v_thread = ((struct __pyx_obj_4lupa_5_lupa__LuaThread *)__pyx_t_6);
    __pyx_t_6 = 0;

    /* "lupa/_lupa.pyx":847
 *             assert lua.lua_isthread(L, -1)
 *             thread = new_lua_thread(self._runtime, L, -1)
 *             thread._arguments = args # always a tuple, not None !             # <<<<<<<<<<<<<<
 *             return thread
 *         finally:
 */
    __Pyx_INCREF(__pyx_v_args);
    __Pyx_GIVEREF(__pyx_v_args);
    __Pyx_GOTREF(__pyx_v_thread->_arguments);
    __Pyx_DECREF(__pyx_v_thread->_arguments);
    __pyx_v_thread->_arguments = __pyx_v_args;

    /* "lupa/_lupa.pyx":848
 *             thread = new_lua_thread(self._runtime, L, -1)
 *             thread._arguments = args # always a tuple, not None !
 *             return thread             # <<<<<<<<<<<<<<
 *         finally:
 *             lua.lua_settop(L, old_top)
 */
    __Pyx_XDECREF(__pyx_r);
    __Pyx_INCREF(((PyObject *)__pyx_v_thread));
    __pyx_r = ((PyObject *)__pyx_v_thread);
    goto __pyx_L3_return;
  }

  /* "lupa/_lupa.pyx":850
 *             return thread
 *         finally:
 *             lua.lua_settop(L, old_top)             # <<<<<<<<<<<<<<
 *             unlock_runtime(self._runtime)
 * 
 */
  /*finally:*/ {
    __pyx_L4_error:;
    /*exception exit:*/{
      __Pyx_PyThreadState_declare
      __Pyx_PyThreadState_assign
      __pyx_t_9 = 0; __pyx_t_10 = 0; __pyx_t_11 = 0; __pyx_t_12 = 0; __pyx_t_13 = 0; __pyx_t_14 = 0;
      __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
      if (PY_MAJOR_VERSION >= 3) __Pyx_ExceptionSwap(&__pyx_t_12, &__pyx_t_13, &__pyx_t_14);
      if ((PY_MAJOR_VERSION < 3) || unlikely(__Pyx_GetException(&__pyx_t_9, &__pyx_t_10, &__pyx_t_11) < 0)) __Pyx_ErrFetch(&__pyx_t_9, &__pyx_t_10, &__pyx_t_11);
      __Pyx_XGOTREF(__pyx_t_9);
      __Pyx_XGOTREF(__pyx_t_10);
      __Pyx_XGOTREF(__pyx_t_11);
      __Pyx_XGOTREF(__pyx_t_12);
      __Pyx_XGOTREF(__pyx_t_13);
      __Pyx_XGOTREF(__pyx_t_14);
      __pyx_t_4 = __pyx_lineno; __pyx_t_7 = __pyx_clineno; __pyx_t_8 = __pyx_filename;
      {
        lua_settop(__pyx_v_L, __pyx_v_old_top);

        /* "lupa/_lupa.pyx":851
 *         finally:
 *             lua.lua_settop(L, old_top)
 *             unlock_runtime(self._runtime)             # <<<<<<<<<<<<<<
 * 
 * cdef _LuaFunction new_lua_function(LuaRuntime runtime, lua_State* L, int n):
 */
        __pyx_t_6 = ((PyObject *)__pyx_v_self->__pyx_base._runtime);
        __Pyx_INCREF(__pyx_t_6);
        __pyx_f_4lupa_5_lupa_unlock_runtime(((struct __pyx_obj_4lupa_5_lupa_LuaRuntime *)__pyx_t_6));
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      }
      if (PY_MAJOR_VERSION >= 3) {
        __Pyx_XGIVEREF(__pyx_t_12);
        __Pyx_XGIVEREF(__pyx_t_13);
        __Pyx_XGIVEREF(__pyx_t_14);
        __Pyx_ExceptionReset(__pyx_t_12, __pyx_t_13, __pyx_t_14);
      }
      __Pyx_XGIVEREF(__pyx_t_9);
      __Pyx_XGIVEREF(__pyx_t_10);
      __Pyx_XGIVEREF(__pyx_t_11);
      __Pyx_ErrRestore(__pyx_t_9, __pyx_t_10, __pyx_t_11);
      __pyx_t_9 = 0; __pyx_t_10 = 0; __pyx_t_11 = 0; __pyx_t_12 = 0; __pyx_t_13 = 0; __pyx_t_14 = 0;
      __pyx_lineno = __pyx_t_4; __pyx_clineno = __pyx_t_7; __pyx_filename = __pyx_t_8;
      goto __pyx_L1_error;
    }
    __pyx_L3_return: {
      __pyx_t_14 = __pyx_r;
      __pyx_r = 0;

      /* "lupa/_lupa.pyx":850
 *             return thread
 *         finally:
 *             lua.lua_settop(L, old_top)             # <<<<<<<<<<<<<<
 *             unlock_runtime(self._runtime)
 * 
 */
      lua_settop(__pyx_v_L, __pyx_v_old_top);

      /* "lupa/_lupa.pyx":851
 *         finally:
 *             lua.lua_settop(L, old_top)
 *             unlock_runtime(self._runtime)             # <<<<<<<<<<<<<<
 * 
 * cdef _LuaFunction new_lua_function(LuaRuntime runtime, lua_State* L, int n):
 */
      __pyx_t_6 = ((PyObject *)__pyx_v_self->__pyx_base._runtime);
      __Pyx_INCREF(__pyx_t_6);
      __pyx_f_4lupa_5_lupa_unlock_runtime(((struct __pyx_obj_4lupa_5_lupa_LuaRuntime *)__pyx_t_6));
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      __pyx_r = __pyx_t_14;
      __pyx_t_14 = 0;
      goto __pyx_L0;
    }
  }

  /* "lupa/_lupa.pyx":826
 *     """A Lua function (which may become a coroutine).
 *     """
 *     def coroutine(self, *args):             # <<<<<<<<<<<<<<
 *         """Create a Lua coroutine from a Lua function and call it with
 *         the passed parameters to start it up.
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_AddTraceback("lupa._lupa._LuaFunction.coroutine", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_thread);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "(tree fragment)":1
 * def __reduce_cython__(self):             # <<<<<<<<<<<<<<
 *     raise TypeError("self._state cannot be converted to a Python object for pickling")
 * def __setstate_cython__(self, __pyx_state):
 */

/* Python wrapper */
static PyObject *__pyx_pw_4lupa_5_lupa_12_LuaFunction_3__reduce_cython__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static char __pyx_doc_4lupa_5_lupa_12_LuaFunction_2__reduce_cython__[] = "_LuaFunction.__reduce_cython__(self)";
static PyMethodDef __pyx_mdef_4lupa_5_lupa_12_LuaFunction_3__reduce_cython__ = {"__reduce_cython__", (PyCFunction)__pyx_pw_4lupa_5_lupa_12_LuaFunction_3__reduce_cython__, METH_NOARGS, __pyx_doc_4lupa_5_lupa_12_LuaFunction_2__reduce_cython__};
static PyObject *__pyx_pw_4lupa_5_lupa_12_LuaFunction_3__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_4lupa_5_lupa_12_LuaFunction_2__reduce_cython__(((struct __pyx_obj_4lupa_5_lupa__LuaFunction *)__pyx_v_self));

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

static PyObject *__pyx_pf_4lupa_5_lupa_12_LuaFunction_2__reduce_cython__(CYTHON_UNUSED struct __pyx_obj_4lupa_5_lupa__LuaFunction *__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("self._state cannot be converted to a Python object for pickling")             # <<<<<<<<<<<<<<
 * def __setstate_cython__(self, __pyx_state):
 *     raise TypeError("self._state cannot be converted to a Python object for pickling")
 */
  __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__22, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 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(2, 2, __pyx_L1_error)

  /* "(tree fragment)":1
 * def __reduce_cython__(self):             # <<<<<<<<<<<<<<
 *     raise TypeError("self._state cannot be converted to a Python object for pickling")
 * def __setstate_cython__(self, __pyx_state):
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("lupa._lupa._LuaFunction.__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("self._state cannot be converted to a Python object for pickling")
 * def __setstate_cython__(self, __pyx_state):             # <<<<<<<<<<<<<<
 *     raise TypeError("self._state cannot be converted to a Python object for pickling")
 */

/* Python wrapper */
static PyObject *__pyx_pw_4lupa_5_lupa_12_LuaFunction_5__setstate_cython__(PyObject *__pyx_v_self, PyObject *__pyx_v___pyx_state); /*proto*/
static char __pyx_doc_4lupa_5_lupa_12_LuaFunction_4__setstate_cython__[] = "_LuaFunction.__setstate_cython__(self, __pyx_state)";
static PyMethodDef __pyx_mdef_4lupa_5_lupa_12_LuaFunction_5__setstate_cython__ = {"__setstate_cython__", (PyCFunction)__pyx_pw_4lupa_5_lupa_12_LuaFunction_5__setstate_cython__, METH_O, __pyx_doc_4lupa_5_lupa_12_LuaFunction_4__setstate_cython__};
static PyObject *__pyx_pw_4lupa_5_lupa_12_LuaFunction_5__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_4lupa_5_lupa_12_LuaFunction_4__setstate_cython__(((struct __pyx_obj_4lupa_5_lupa__LuaFunction *)__pyx_v_self), ((PyObject *)__pyx_v___pyx_state));

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

static PyObject *__pyx_pf_4lupa_5_lupa_12_LuaFunction_4__setstate_cython__(CYTHON_UNUSED struct __pyx_obj_4lupa_5_lupa__LuaFunction *__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("self._state cannot be converted to a Python object for pickling")
 * def __setstate_cython__(self, __pyx_state):
 *     raise TypeError("self._state cannot be converted to a Python object for pickling")             # <<<<<<<<<<<<<<
 */
  __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__23, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 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(2, 4, __pyx_L1_error)

  /* "(tree fragment)":3
 * def __reduce_cython__(self):
 *     raise TypeError("self._state cannot be converted to a Python object for pickling")
 * def __setstate_cython__(self, __pyx_state):             # <<<<<<<<<<<<<<
 *     raise TypeError("self._state cannot be converted to a Python object for pickling")
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("lupa._lupa._LuaFunction.__setstate_cython__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lupa/_lupa.pyx":853
 *             unlock_runtime(self._runtime)
 * 
 * cdef _LuaFunction new_lua_function(LuaRuntime runtime, lua_State* L, int n):             # <<<<<<<<<<<<<<
 *     cdef _LuaFunction obj = _LuaFunction.__new__(_LuaFunction)
 *     init_lua_object(obj, runtime, L, n)
 */

static struct __pyx_obj_4lupa_5_lupa__LuaFunction *__pyx_f_4lupa_5_lupa_new_lua_function(struct __pyx_obj_4lupa_5_lupa_LuaRuntime *__pyx_v_runtime, lua_State *__pyx_v_L, int __pyx_v_n) {
  struct __pyx_obj_4lupa_5_lupa__LuaFunction *__pyx_v_obj = 0;
  struct __pyx_obj_4lupa_5_lupa__LuaFunction *__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("new_lua_function", 0);

  /* "lupa/_lupa.pyx":854
 * 
 * cdef _LuaFunction new_lua_function(LuaRuntime runtime, lua_State* L, int n):
 *     cdef _LuaFunction obj = _LuaFunction.__new__(_LuaFunction)             # <<<<<<<<<<<<<<
 *     init_lua_object(obj, runtime, L, n)
 *     return obj
 */
  __pyx_t_1 = ((PyObject *)__pyx_tp_new_4lupa_5_lupa__LuaFunction(((PyTypeObject *)__pyx_ptype_4lupa_5_lupa__LuaFunction), __pyx_empty_tuple, NULL)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 854, __pyx_L1_error)
  __Pyx_GOTREF(((PyObject *)__pyx_t_1));
  __pyx_v_obj = ((struct __pyx_obj_4lupa_5_lupa__LuaFunction *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "lupa/_lupa.pyx":855
 * cdef _LuaFunction new_lua_function(LuaRuntime runtime, lua_State* L, int n):
 *     cdef _LuaFunction obj = _LuaFunction.__new__(_LuaFunction)
 *     init_lua_object(obj, runtime, L, n)             # <<<<<<<<<<<<<<
 *     return obj
 * 
 */
  __pyx_f_4lupa_5_lupa_init_lua_object(((struct __pyx_obj_4lupa_5_lupa__LuaObject *)__pyx_v_obj), __pyx_v_runtime, __pyx_v_L, __pyx_v_n);

  /* "lupa/_lupa.pyx":856
 *     cdef _LuaFunction obj = _LuaFunction.__new__(_LuaFunction)
 *     init_lua_object(obj, runtime, L, n)
 *     return obj             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_XDECREF(((PyObject *)__pyx_r));
  __Pyx_INCREF(((PyObject *)__pyx_v_obj));
  __pyx_r = __pyx_v_obj;
  goto __pyx_L0;

  /* "lupa/_lupa.pyx":853
 *             unlock_runtime(self._runtime)
 * 
 * cdef _LuaFunction new_lua_function(LuaRuntime runtime, lua_State* L, int n):             # <<<<<<<<<<<<<<
 *     cdef _LuaFunction obj = _LuaFunction.__new__(_LuaFunction)
 *     init_lua_object(obj, runtime, L, n)
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("lupa._lupa.new_lua_function", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_obj);
  __Pyx_XGIVEREF((PyObject *)__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lupa/_lupa.pyx":865
 *     """A function that returns a new coroutine when called.
 *     """
 *     def __call__(self, *args):             # <<<<<<<<<<<<<<
 *         return self.coroutine(*args)
 * 
 */

/* Python wrapper */
static PyObject *__pyx_pw_4lupa_5_lupa_21_LuaCoroutineFunction_1__call__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_pw_4lupa_5_lupa_21_LuaCoroutineFunction_1__call__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_args = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__call__ (wrapper)", 0);
  if (unlikely(__pyx_kwds) && unlikely(PyDict_Size(__pyx_kwds) > 0) && unlikely(!__Pyx_CheckKeywordStrings(__pyx_kwds, "__call__", 0))) return NULL;
  __Pyx_INCREF(__pyx_args);
  __pyx_v_args = __pyx_args;
  __pyx_r = __pyx_pf_4lupa_5_lupa_21_LuaCoroutineFunction___call__(((struct __pyx_obj_4lupa_5_lupa__LuaCoroutineFunction *)__pyx_v_self), __pyx_v_args);

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

static PyObject *__pyx_pf_4lupa_5_lupa_21_LuaCoroutineFunction___call__(struct __pyx_obj_4lupa_5_lupa__LuaCoroutineFunction *__pyx_v_self, PyObject *__pyx_v_args) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__call__", 0);

  /* "lupa/_lupa.pyx":866
 *     """
 *     def __call__(self, *args):
 *         return self.coroutine(*args)             # <<<<<<<<<<<<<<
 * 
 * cdef _LuaCoroutineFunction new_lua_coroutine_function(LuaRuntime runtime, lua_State* L, int n):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_coroutine); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 866, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_v_args, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 866, __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;

  /* "lupa/_lupa.pyx":865
 *     """A function that returns a new coroutine when called.
 *     """
 *     def __call__(self, *args):             # <<<<<<<<<<<<<<
 *         return self.coroutine(*args)
 * 
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_AddTraceback("lupa._lupa._LuaCoroutineFunction.__call__", __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("self._state cannot be converted to a Python object for pickling")
 * def __setstate_cython__(self, __pyx_state):
 */

/* Python wrapper */
static PyObject *__pyx_pw_4lupa_5_lupa_21_LuaCoroutineFunction_3__reduce_cython__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static char __pyx_doc_4lupa_5_lupa_21_LuaCoroutineFunction_2__reduce_cython__[] = "_LuaCoroutineFunction.__reduce_cython__(self)";
static PyMethodDef __pyx_mdef_4lupa_5_lupa_21_LuaCoroutineFunction_3__reduce_cython__ = {"__reduce_cython__", (PyCFunction)__pyx_pw_4lupa_5_lupa_21_LuaCoroutineFunction_3__reduce_cython__, METH_NOARGS, __pyx_doc_4lupa_5_lupa_21_LuaCoroutineFunction_2__reduce_cython__};
static PyObject *__pyx_pw_4lupa_5_lupa_21_LuaCoroutineFunction_3__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_4lupa_5_lupa_21_LuaCoroutineFunction_2__reduce_cython__(((struct __pyx_obj_4lupa_5_lupa__LuaCoroutineFunction *)__pyx_v_self));

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

static PyObject *__pyx_pf_4lupa_5_lupa_21_LuaCoroutineFunction_2__reduce_cython__(CYTHON_UNUSED struct __pyx_obj_4lupa_5_lupa__LuaCoroutineFunction *__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("self._state cannot be converted to a Python object for pickling")             # <<<<<<<<<<<<<<
 * def __setstate_cython__(self, __pyx_state):
 *     raise TypeError("self._state cannot be converted to a Python object for pickling")
 */
  __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__24, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 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(2, 2, __pyx_L1_error)

  /* "(tree fragment)":1
 * def __reduce_cython__(self):             # <<<<<<<<<<<<<<
 *     raise TypeError("self._state cannot be converted to a Python object for pickling")
 * def __setstate_cython__(self, __pyx_state):
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("lupa._lupa._LuaCoroutineFunction.__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("self._state cannot be converted to a Python object for pickling")
 * def __setstate_cython__(self, __pyx_state):             # <<<<<<<<<<<<<<
 *     raise TypeError("self._state cannot be converted to a Python object for pickling")
 */

/* Python wrapper */
static PyObject *__pyx_pw_4lupa_5_lupa_21_LuaCoroutineFunction_5__setstate_cython__(PyObject *__pyx_v_self, PyObject *__pyx_v___pyx_state); /*proto*/
static char __pyx_doc_4lupa_5_lupa_21_LuaCoroutineFunction_4__setstate_cython__[] = "_LuaCoroutineFunction.__setstate_cython__(self, __pyx_state)";
static PyMethodDef __pyx_mdef_4lupa_5_lupa_21_LuaCoroutineFunction_5__setstate_cython__ = {"__setstate_cython__", (PyCFunction)__pyx_pw_4lupa_5_lupa_21_LuaCoroutineFunction_5__setstate_cython__, METH_O, __pyx_doc_4lupa_5_lupa_21_LuaCoroutineFunction_4__setstate_cython__};
static PyObject *__pyx_pw_4lupa_5_lupa_21_LuaCoroutineFunction_5__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_4lupa_5_lupa_21_LuaCoroutineFunction_4__setstate_cython__(((struct __pyx_obj_4lupa_5_lupa__LuaCoroutineFunction *)__pyx_v_self), ((PyObject *)__pyx_v___pyx_state));

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

static PyObject *__pyx_pf_4lupa_5_lupa_21_LuaCoroutineFunction_4__setstate_cython__(CYTHON_UNUSED struct __pyx_obj_4lupa_5_lupa__LuaCoroutineFunction *__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("self._state cannot be converted to a Python object for pickling")
 * def __setstate_cython__(self, __pyx_state):
 *     raise TypeError("self._state cannot be converted to a Python object for pickling")             # <<<<<<<<<<<<<<
 */
  __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__25, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 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(2, 4, __pyx_L1_error)

  /* "(tree fragment)":3
 * def __reduce_cython__(self):
 *     raise TypeError("self._state cannot be converted to a Python object for pickling")
 * def __setstate_cython__(self, __pyx_state):             # <<<<<<<<<<<<<<
 *     raise TypeError("self._state cannot be converted to a Python object for pickling")
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("lupa._lupa._LuaCoroutineFunction.__setstate_cython__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lupa/_lupa.pyx":868
 *         return self.coroutine(*args)
 * 
 * cdef _LuaCoroutineFunction new_lua_coroutine_function(LuaRuntime runtime, lua_State* L, int n):             # <<<<<<<<<<<<<<
 *     cdef _LuaCoroutineFunction obj = _LuaCoroutineFunction.__new__(_LuaCoroutineFunction)
 *     init_lua_object(obj, runtime, L, n)
 */

static struct __pyx_obj_4lupa_5_lupa__LuaCoroutineFunction *__pyx_f_4lupa_5_lupa_new_lua_coroutine_function(struct __pyx_obj_4lupa_5_lupa_LuaRuntime *__pyx_v_runtime, lua_State *__pyx_v_L, int __pyx_v_n) {
  struct __pyx_obj_4lupa_5_lupa__LuaCoroutineFunction *__pyx_v_obj = 0;
  struct __pyx_obj_4lupa_5_lupa__LuaCoroutineFunction *__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("new_lua_coroutine_function", 0);

  /* "lupa/_lupa.pyx":869
 * 
 * cdef _LuaCoroutineFunction new_lua_coroutine_function(LuaRuntime runtime, lua_State* L, int n):
 *     cdef _LuaCoroutineFunction obj = _LuaCoroutineFunction.__new__(_LuaCoroutineFunction)             # <<<<<<<<<<<<<<
 *     init_lua_object(obj, runtime, L, n)
 *     return obj
 */
  __pyx_t_1 = ((PyObject *)__pyx_tp_new_4lupa_5_lupa__LuaCoroutineFunction(((PyTypeObject *)__pyx_ptype_4lupa_5_lupa__LuaCoroutineFunction), __pyx_empty_tuple, NULL)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 869, __pyx_L1_error)
  __Pyx_GOTREF(((PyObject *)__pyx_t_1));
  __pyx_v_obj = ((struct __pyx_obj_4lupa_5_lupa__LuaCoroutineFunction *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "lupa/_lupa.pyx":870
 * cdef _LuaCoroutineFunction new_lua_coroutine_function(LuaRuntime runtime, lua_State* L, int n):
 *     cdef _LuaCoroutineFunction obj = _LuaCoroutineFunction.__new__(_LuaCoroutineFunction)
 *     init_lua_object(obj, runtime, L, n)             # <<<<<<<<<<<<<<
 *     return obj
 * 
 */
  __pyx_f_4lupa_5_lupa_init_lua_object(((struct __pyx_obj_4lupa_5_lupa__LuaObject *)__pyx_v_obj), __pyx_v_runtime, __pyx_v_L, __pyx_v_n);

  /* "lupa/_lupa.pyx":871
 *     cdef _LuaCoroutineFunction obj = _LuaCoroutineFunction.__new__(_LuaCoroutineFunction)
 *     init_lua_object(obj, runtime, L, n)
 *     return obj             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_XDECREF(((PyObject *)__pyx_r));
  __Pyx_INCREF(((PyObject *)__pyx_v_obj));
  __pyx_r = __pyx_v_obj;
  goto __pyx_L0;

  /* "lupa/_lupa.pyx":868
 *         return self.coroutine(*args)
 * 
 * cdef _LuaCoroutineFunction new_lua_coroutine_function(LuaRuntime runtime, lua_State* L, int n):             # <<<<<<<<<<<<<<
 *     cdef _LuaCoroutineFunction obj = _LuaCoroutineFunction.__new__(_LuaCoroutineFunction)
 *     init_lua_object(obj, runtime, L, n)
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("lupa._lupa.new_lua_coroutine_function", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_obj);
  __Pyx_XGIVEREF((PyObject *)__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lupa/_lupa.pyx":882
 *     cdef lua_State* _co_state
 *     cdef tuple _arguments
 *     def __iter__(self):             # <<<<<<<<<<<<<<
 *         return self
 * 
 */

/* Python wrapper */
static PyObject *__pyx_pw_4lupa_5_lupa_10_LuaThread_1__iter__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_4lupa_5_lupa_10_LuaThread_1__iter__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__iter__ (wrapper)", 0);
  __pyx_r = __pyx_pf_4lupa_5_lupa_10_LuaThread___iter__(((struct __pyx_obj_4lupa_5_lupa__LuaThread *)__pyx_v_self));

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

static PyObject *__pyx_pf_4lupa_5_lupa_10_LuaThread___iter__(struct __pyx_obj_4lupa_5_lupa__LuaThread *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__iter__", 0);

  /* "lupa/_lupa.pyx":883
 *     cdef tuple _arguments
 *     def __iter__(self):
 *         return self             # <<<<<<<<<<<<<<
 * 
 *     def __next__(self):
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(((PyObject *)__pyx_v_self));
  __pyx_r = ((PyObject *)__pyx_v_self);
  goto __pyx_L0;

  /* "lupa/_lupa.pyx":882
 *     cdef lua_State* _co_state
 *     cdef tuple _arguments
 *     def __iter__(self):             # <<<<<<<<<<<<<<
 *         return self
 * 
 */

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

/* "lupa/_lupa.pyx":885
 *         return self
 * 
 *     def __next__(self):             # <<<<<<<<<<<<<<
 *         assert self._runtime is not None
 *         cdef tuple args = self._arguments
 */

/* Python wrapper */
static PyObject *__pyx_pw_4lupa_5_lupa_10_LuaThread_3__next__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_4lupa_5_lupa_10_LuaThread_3__next__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__next__ (wrapper)", 0);
  __pyx_r = __pyx_pf_4lupa_5_lupa_10_LuaThread_2__next__(((struct __pyx_obj_4lupa_5_lupa__LuaThread *)__pyx_v_self));

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

static PyObject *__pyx_pf_4lupa_5_lupa_10_LuaThread_2__next__(struct __pyx_obj_4lupa_5_lupa__LuaThread *__pyx_v_self) {
  PyObject *__pyx_v_args = 0;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  int __pyx_t_3;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__next__", 0);

  /* "lupa/_lupa.pyx":886
 * 
 *     def __next__(self):
 *         assert self._runtime is not None             # <<<<<<<<<<<<<<
 *         cdef tuple args = self._arguments
 *         if args is not None:
 */
  #ifndef CYTHON_WITHOUT_ASSERTIONS
  if (unlikely(!Py_OptimizeFlag)) {
    __pyx_t_1 = (((PyObject *)__pyx_v_self->__pyx_base._runtime) != Py_None);
    if (unlikely(!(__pyx_t_1 != 0))) {
      PyErr_SetNone(PyExc_AssertionError);
      __PYX_ERR(0, 886, __pyx_L1_error)
    }
  }
  #endif

  /* "lupa/_lupa.pyx":887
 *     def __next__(self):
 *         assert self._runtime is not None
 *         cdef tuple args = self._arguments             # <<<<<<<<<<<<<<
 *         if args is not None:
 *             self._arguments = None
 */
  __pyx_t_2 = __pyx_v_self->_arguments;
  __Pyx_INCREF(__pyx_t_2);
  __pyx_v_args = ((PyObject*)__pyx_t_2);
  __pyx_t_2 = 0;

  /* "lupa/_lupa.pyx":888
 *         assert self._runtime is not None
 *         cdef tuple args = self._arguments
 *         if args is not None:             # <<<<<<<<<<<<<<
 *             self._arguments = None
 *         return resume_lua_thread(self, args)
 */
  __pyx_t_1 = (__pyx_v_args != ((PyObject*)Py_None));
  __pyx_t_3 = (__pyx_t_1 != 0);
  if (__pyx_t_3) {

    /* "lupa/_lupa.pyx":889
 *         cdef tuple args = self._arguments
 *         if args is not None:
 *             self._arguments = None             # <<<<<<<<<<<<<<
 *         return resume_lua_thread(self, args)
 * 
 */
    __Pyx_INCREF(Py_None);
    __Pyx_GIVEREF(Py_None);
    __Pyx_GOTREF(__pyx_v_self->_arguments);
    __Pyx_DECREF(__pyx_v_self->_arguments);
    __pyx_v_self->_arguments = ((PyObject*)Py_None);

    /* "lupa/_lupa.pyx":888
 *         assert self._runtime is not None
 *         cdef tuple args = self._arguments
 *         if args is not None:             # <<<<<<<<<<<<<<
 *             self._arguments = None
 *         return resume_lua_thread(self, args)
 */
  }

  /* "lupa/_lupa.pyx":890
 *         if args is not None:
 *             self._arguments = None
 *         return resume_lua_thread(self, args)             # <<<<<<<<<<<<<<
 * 
 *     def send(self, value):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2 = __pyx_f_4lupa_5_lupa_resume_lua_thread(__pyx_v_self, __pyx_v_args); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 890, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_r = __pyx_t_2;
  __pyx_t_2 = 0;
  goto __pyx_L0;

  /* "lupa/_lupa.pyx":885
 *         return self
 * 
 *     def __next__(self):             # <<<<<<<<<<<<<<
 *         assert self._runtime is not None
 *         cdef tuple args = self._arguments
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_AddTraceback("lupa._lupa._LuaThread.__next__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_args);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lupa/_lupa.pyx":892
 *         return resume_lua_thread(self, args)
 * 
 *     def send(self, value):             # <<<<<<<<<<<<<<
 *         """Send a value into the coroutine.  If the value is a tuple,
 *         send the unpacked elements.
 */

/* Python wrapper */
static PyObject *__pyx_pw_4lupa_5_lupa_10_LuaThread_5send(PyObject *__pyx_v_self, PyObject *__pyx_v_value); /*proto*/
static char __pyx_doc_4lupa_5_lupa_10_LuaThread_4send[] = "_LuaThread.send(self, value)\nSend a value into the coroutine.  If the value is a tuple,\n        send the unpacked elements.\n        ";
static PyMethodDef __pyx_mdef_4lupa_5_lupa_10_LuaThread_5send = {"send", (PyCFunction)__pyx_pw_4lupa_5_lupa_10_LuaThread_5send, METH_O, __pyx_doc_4lupa_5_lupa_10_LuaThread_4send};
static PyObject *__pyx_pw_4lupa_5_lupa_10_LuaThread_5send(PyObject *__pyx_v_self, PyObject *__pyx_v_value) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("send (wrapper)", 0);
  __pyx_r = __pyx_pf_4lupa_5_lupa_10_LuaThread_4send(((struct __pyx_obj_4lupa_5_lupa__LuaThread *)__pyx_v_self), ((PyObject *)__pyx_v_value));

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

static PyObject *__pyx_pf_4lupa_5_lupa_10_LuaThread_4send(struct __pyx_obj_4lupa_5_lupa__LuaThread *__pyx_v_self, PyObject *__pyx_v_value) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  int __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("send", 0);
  __Pyx_INCREF(__pyx_v_value);

  /* "lupa/_lupa.pyx":896
 *         send the unpacked elements.
 *         """
 *         if value is not None:             # <<<<<<<<<<<<<<
 *             if self._arguments is not None:
 *                 raise TypeError("can't send non-None value to a just-started generator")
 */
  __pyx_t_1 = (__pyx_v_value != Py_None);
  __pyx_t_2 = (__pyx_t_1 != 0);
  if (__pyx_t_2) {

    /* "lupa/_lupa.pyx":897
 *         """
 *         if value is not None:
 *             if self._arguments is not None:             # <<<<<<<<<<<<<<
 *                 raise TypeError("can't send non-None value to a just-started generator")
 *             if not isinstance(value, tuple):
 */
    __pyx_t_2 = (__pyx_v_self->_arguments != ((PyObject*)Py_None));
    __pyx_t_1 = (__pyx_t_2 != 0);
    if (unlikely(__pyx_t_1)) {

      /* "lupa/_lupa.pyx":898
 *         if value is not None:
 *             if self._arguments is not None:
 *                 raise TypeError("can't send non-None value to a just-started generator")             # <<<<<<<<<<<<<<
 *             if not isinstance(value, tuple):
 *                 value = (value,)
 */
      __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__26, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 898, __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, 898, __pyx_L1_error)

      /* "lupa/_lupa.pyx":897
 *         """
 *         if value is not None:
 *             if self._arguments is not None:             # <<<<<<<<<<<<<<
 *                 raise TypeError("can't send non-None value to a just-started generator")
 *             if not isinstance(value, tuple):
 */
    }

    /* "lupa/_lupa.pyx":899
 *             if self._arguments is not None:
 *                 raise TypeError("can't send non-None value to a just-started generator")
 *             if not isinstance(value, tuple):             # <<<<<<<<<<<<<<
 *                 value = (value,)
 *         elif self._arguments is not None:
 */
    __pyx_t_1 = PyTuple_Check(__pyx_v_value); 
    __pyx_t_2 = ((!(__pyx_t_1 != 0)) != 0);
    if (__pyx_t_2) {

      /* "lupa/_lupa.pyx":900
 *                 raise TypeError("can't send non-None value to a just-started generator")
 *             if not isinstance(value, tuple):
 *                 value = (value,)             # <<<<<<<<<<<<<<
 *         elif self._arguments is not None:
 *             value = self._arguments
 */
      __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 900, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_INCREF(__pyx_v_value);
      __Pyx_GIVEREF(__pyx_v_value);
      PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_v_value);
      __Pyx_DECREF_SET(__pyx_v_value, __pyx_t_3);
      __pyx_t_3 = 0;

      /* "lupa/_lupa.pyx":899
 *             if self._arguments is not None:
 *                 raise TypeError("can't send non-None value to a just-started generator")
 *             if not isinstance(value, tuple):             # <<<<<<<<<<<<<<
 *                 value = (value,)
 *         elif self._arguments is not None:
 */
    }

    /* "lupa/_lupa.pyx":896
 *         send the unpacked elements.
 *         """
 *         if value is not None:             # <<<<<<<<<<<<<<
 *             if self._arguments is not None:
 *                 raise TypeError("can't send non-None value to a just-started generator")
 */
    goto __pyx_L3;
  }

  /* "lupa/_lupa.pyx":901
 *             if not isinstance(value, tuple):
 *                 value = (value,)
 *         elif self._arguments is not None:             # <<<<<<<<<<<<<<
 *             value = self._arguments
 *             self._arguments = None
 */
  __pyx_t_2 = (__pyx_v_self->_arguments != ((PyObject*)Py_None));
  __pyx_t_1 = (__pyx_t_2 != 0);
  if (__pyx_t_1) {

    /* "lupa/_lupa.pyx":902
 *                 value = (value,)
 *         elif self._arguments is not None:
 *             value = self._arguments             # <<<<<<<<<<<<<<
 *             self._arguments = None
 *         return resume_lua_thread(self, <tuple>value)
 */
    __pyx_t_3 = __pyx_v_self->_arguments;
    __Pyx_INCREF(__pyx_t_3);
    __Pyx_DECREF_SET(__pyx_v_value, __pyx_t_3);
    __pyx_t_3 = 0;

    /* "lupa/_lupa.pyx":903
 *         elif self._arguments is not None:
 *             value = self._arguments
 *             self._arguments = None             # <<<<<<<<<<<<<<
 *         return resume_lua_thread(self, <tuple>value)
 * 
 */
    __Pyx_INCREF(Py_None);
    __Pyx_GIVEREF(Py_None);
    __Pyx_GOTREF(__pyx_v_self->_arguments);
    __Pyx_DECREF(__pyx_v_self->_arguments);
    __pyx_v_self->_arguments = ((PyObject*)Py_None);

    /* "lupa/_lupa.pyx":901
 *             if not isinstance(value, tuple):
 *                 value = (value,)
 *         elif self._arguments is not None:             # <<<<<<<<<<<<<<
 *             value = self._arguments
 *             self._arguments = None
 */
  }
  __pyx_L3:;

  /* "lupa/_lupa.pyx":904
 *             value = self._arguments
 *             self._arguments = None
 *         return resume_lua_thread(self, <tuple>value)             # <<<<<<<<<<<<<<
 * 
 *     def __bool__(self):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_3 = __pyx_f_4lupa_5_lupa_resume_lua_thread(__pyx_v_self, ((PyObject*)__pyx_v_value)); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 904, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_r = __pyx_t_3;
  __pyx_t_3 = 0;
  goto __pyx_L0;

  /* "lupa/_lupa.pyx":892
 *         return resume_lua_thread(self, args)
 * 
 *     def send(self, value):             # <<<<<<<<<<<<<<
 *         """Send a value into the coroutine.  If the value is a tuple,
 *         send the unpacked elements.
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("lupa._lupa._LuaThread.send", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_value);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lupa/_lupa.pyx":906
 *         return resume_lua_thread(self, <tuple>value)
 * 
 *     def __bool__(self):             # <<<<<<<<<<<<<<
 *         cdef lua.lua_Debug dummy
 *         assert self._runtime is not None
 */

/* Python wrapper */
static int __pyx_pw_4lupa_5_lupa_10_LuaThread_7__bool__(PyObject *__pyx_v_self); /*proto*/
static int __pyx_pw_4lupa_5_lupa_10_LuaThread_7__bool__(PyObject *__pyx_v_self) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__bool__ (wrapper)", 0);
  __pyx_r = __pyx_pf_4lupa_5_lupa_10_LuaThread_6__bool__(((struct __pyx_obj_4lupa_5_lupa__LuaThread *)__pyx_v_self));

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

static int __pyx_pf_4lupa_5_lupa_10_LuaThread_6__bool__(struct __pyx_obj_4lupa_5_lupa__LuaThread *__pyx_v_self) {
  lua_Debug __pyx_v_dummy;
  int __pyx_v_status;
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__bool__", 0);

  /* "lupa/_lupa.pyx":908
 *     def __bool__(self):
 *         cdef lua.lua_Debug dummy
 *         assert self._runtime is not None             # <<<<<<<<<<<<<<
 *         cdef int status = lua.lua_status(self._co_state)
 *         if status == lua.LUA_YIELD:
 */
  #ifndef CYTHON_WITHOUT_ASSERTIONS
  if (unlikely(!Py_OptimizeFlag)) {
    __pyx_t_1 = (((PyObject *)__pyx_v_self->__pyx_base._runtime) != Py_None);
    if (unlikely(!(__pyx_t_1 != 0))) {
      PyErr_SetNone(PyExc_AssertionError);
      __PYX_ERR(0, 908, __pyx_L1_error)
    }
  }
  #endif

  /* "lupa/_lupa.pyx":909
 *         cdef lua.lua_Debug dummy
 *         assert self._runtime is not None
 *         cdef int status = lua.lua_status(self._co_state)             # <<<<<<<<<<<<<<
 *         if status == lua.LUA_YIELD:
 *             return True
 */
  __pyx_v_status = lua_status(__pyx_v_self->_co_state);

  /* "lupa/_lupa.pyx":910
 *         assert self._runtime is not None
 *         cdef int status = lua.lua_status(self._co_state)
 *         if status == lua.LUA_YIELD:             # <<<<<<<<<<<<<<
 *             return True
 *         if status == 0:
 */
  __pyx_t_1 = ((__pyx_v_status == LUA_YIELD) != 0);
  if (__pyx_t_1) {

    /* "lupa/_lupa.pyx":911
 *         cdef int status = lua.lua_status(self._co_state)
 *         if status == lua.LUA_YIELD:
 *             return True             # <<<<<<<<<<<<<<
 *         if status == 0:
 *             # copied from Lua code: check for frames
 */
    __pyx_r = 1;
    goto __pyx_L0;

    /* "lupa/_lupa.pyx":910
 *         assert self._runtime is not None
 *         cdef int status = lua.lua_status(self._co_state)
 *         if status == lua.LUA_YIELD:             # <<<<<<<<<<<<<<
 *             return True
 *         if status == 0:
 */
  }

  /* "lupa/_lupa.pyx":912
 *         if status == lua.LUA_YIELD:
 *             return True
 *         if status == 0:             # <<<<<<<<<<<<<<
 *             # copied from Lua code: check for frames
 *             if lua.lua_getstack(self._co_state, 0, &dummy) > 0:
 */
  __pyx_t_1 = ((__pyx_v_status == 0) != 0);
  if (__pyx_t_1) {

    /* "lupa/_lupa.pyx":914
 *         if status == 0:
 *             # copied from Lua code: check for frames
 *             if lua.lua_getstack(self._co_state, 0, &dummy) > 0:             # <<<<<<<<<<<<<<
 *                 return True # currently running
 *             elif lua.lua_gettop(self._co_state) > 0:
 */
    __pyx_t_1 = ((lua_getstack(__pyx_v_self->_co_state, 0, (&__pyx_v_dummy)) > 0) != 0);
    if (__pyx_t_1) {

      /* "lupa/_lupa.pyx":915
 *             # copied from Lua code: check for frames
 *             if lua.lua_getstack(self._co_state, 0, &dummy) > 0:
 *                 return True # currently running             # <<<<<<<<<<<<<<
 *             elif lua.lua_gettop(self._co_state) > 0:
 *                 return True # not started yet
 */
      __pyx_r = 1;
      goto __pyx_L0;

      /* "lupa/_lupa.pyx":914
 *         if status == 0:
 *             # copied from Lua code: check for frames
 *             if lua.lua_getstack(self._co_state, 0, &dummy) > 0:             # <<<<<<<<<<<<<<
 *                 return True # currently running
 *             elif lua.lua_gettop(self._co_state) > 0:
 */
    }

    /* "lupa/_lupa.pyx":916
 *             if lua.lua_getstack(self._co_state, 0, &dummy) > 0:
 *                 return True # currently running
 *             elif lua.lua_gettop(self._co_state) > 0:             # <<<<<<<<<<<<<<
 *                 return True # not started yet
 *         return False
 */
    __pyx_t_1 = ((lua_gettop(__pyx_v_self->_co_state) > 0) != 0);
    if (__pyx_t_1) {

      /* "lupa/_lupa.pyx":917
 *                 return True # currently running
 *             elif lua.lua_gettop(self._co_state) > 0:
 *                 return True # not started yet             # <<<<<<<<<<<<<<
 *         return False
 * 
 */
      __pyx_r = 1;
      goto __pyx_L0;

      /* "lupa/_lupa.pyx":916
 *             if lua.lua_getstack(self._co_state, 0, &dummy) > 0:
 *                 return True # currently running
 *             elif lua.lua_gettop(self._co_state) > 0:             # <<<<<<<<<<<<<<
 *                 return True # not started yet
 *         return False
 */
    }

    /* "lupa/_lupa.pyx":912
 *         if status == lua.LUA_YIELD:
 *             return True
 *         if status == 0:             # <<<<<<<<<<<<<<
 *             # copied from Lua code: check for frames
 *             if lua.lua_getstack(self._co_state, 0, &dummy) > 0:
 */
  }

  /* "lupa/_lupa.pyx":918
 *             elif lua.lua_gettop(self._co_state) > 0:
 *                 return True # not started yet
 *         return False             # <<<<<<<<<<<<<<
 * 
 * cdef _LuaThread new_lua_thread(LuaRuntime runtime, lua_State* L, int n):
 */
  __pyx_r = 0;
  goto __pyx_L0;

  /* "lupa/_lupa.pyx":906
 *         return resume_lua_thread(self, <tuple>value)
 * 
 *     def __bool__(self):             # <<<<<<<<<<<<<<
 *         cdef lua.lua_Debug dummy
 *         assert self._runtime is not None
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_AddTraceback("lupa._lupa._LuaThread.__bool__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "(tree fragment)":1
 * def __reduce_cython__(self):             # <<<<<<<<<<<<<<
 *     raise TypeError("self._co_state,self._state cannot be converted to a Python object for pickling")
 * def __setstate_cython__(self, __pyx_state):
 */

/* Python wrapper */
static PyObject *__pyx_pw_4lupa_5_lupa_10_LuaThread_9__reduce_cython__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static char __pyx_doc_4lupa_5_lupa_10_LuaThread_8__reduce_cython__[] = "_LuaThread.__reduce_cython__(self)";
static PyMethodDef __pyx_mdef_4lupa_5_lupa_10_LuaThread_9__reduce_cython__ = {"__reduce_cython__", (PyCFunction)__pyx_pw_4lupa_5_lupa_10_LuaThread_9__reduce_cython__, METH_NOARGS, __pyx_doc_4lupa_5_lupa_10_LuaThread_8__reduce_cython__};
static PyObject *__pyx_pw_4lupa_5_lupa_10_LuaThread_9__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_4lupa_5_lupa_10_LuaThread_8__reduce_cython__(((struct __pyx_obj_4lupa_5_lupa__LuaThread *)__pyx_v_self));

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

static PyObject *__pyx_pf_4lupa_5_lupa_10_LuaThread_8__reduce_cython__(CYTHON_UNUSED struct __pyx_obj_4lupa_5_lupa__LuaThread *__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("self._co_state,self._state cannot be converted to a Python object for pickling")             # <<<<<<<<<<<<<<
 * def __setstate_cython__(self, __pyx_state):
 *     raise TypeError("self._co_state,self._state cannot be converted to a Python object for pickling")
 */
  __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__27, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 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(2, 2, __pyx_L1_error)

  /* "(tree fragment)":1
 * def __reduce_cython__(self):             # <<<<<<<<<<<<<<
 *     raise TypeError("self._co_state,self._state cannot be converted to a Python object for pickling")
 * def __setstate_cython__(self, __pyx_state):
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("lupa._lupa._LuaThread.__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("self._co_state,self._state cannot be converted to a Python object for pickling")
 * def __setstate_cython__(self, __pyx_state):             # <<<<<<<<<<<<<<
 *     raise TypeError("self._co_state,self._state cannot be converted to a Python object for pickling")
 */

/* Python wrapper */
static PyObject *__pyx_pw_4lupa_5_lupa_10_LuaThread_11__setstate_cython__(PyObject *__pyx_v_self, PyObject *__pyx_v___pyx_state); /*proto*/
static char __pyx_doc_4lupa_5_lupa_10_LuaThread_10__setstate_cython__[] = "_LuaThread.__setstate_cython__(self, __pyx_state)";
static PyMethodDef __pyx_mdef_4lupa_5_lupa_10_LuaThread_11__setstate_cython__ = {"__setstate_cython__", (PyCFunction)__pyx_pw_4lupa_5_lupa_10_LuaThread_11__setstate_cython__, METH_O, __pyx_doc_4lupa_5_lupa_10_LuaThread_10__setstate_cython__};
static PyObject *__pyx_pw_4lupa_5_lupa_10_LuaThread_11__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_4lupa_5_lupa_10_LuaThread_10__setstate_cython__(((struct __pyx_obj_4lupa_5_lupa__LuaThread *)__pyx_v_self), ((PyObject *)__pyx_v___pyx_state));

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

static PyObject *__pyx_pf_4lupa_5_lupa_10_LuaThread_10__setstate_cython__(CYTHON_UNUSED struct __pyx_obj_4lupa_5_lupa__LuaThread *__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("self._co_state,self._state cannot be converted to a Python object for pickling")
 * def __setstate_cython__(self, __pyx_state):
 *     raise TypeError("self._co_state,self._state cannot be converted to a Python object for pickling")             # <<<<<<<<<<<<<<
 */
  __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__28, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 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(2, 4, __pyx_L1_error)

  /* "(tree fragment)":3
 * def __reduce_cython__(self):
 *     raise TypeError("self._co_state,self._state cannot be converted to a Python object for pickling")
 * def __setstate_cython__(self, __pyx_state):             # <<<<<<<<<<<<<<
 *     raise TypeError("self._co_state,self._state cannot be converted to a Python object for pickling")
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("lupa._lupa._LuaThread.__setstate_cython__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lupa/_lupa.pyx":920
 *         return False
 * 
 * cdef _LuaThread new_lua_thread(LuaRuntime runtime, lua_State* L, int n):             # <<<<<<<<<<<<<<
 *     cdef _LuaThread obj = _LuaThread.__new__(_LuaThread)
 *     init_lua_object(obj, runtime, L, n)
 */

static struct __pyx_obj_4lupa_5_lupa__LuaThread *__pyx_f_4lupa_5_lupa_new_lua_thread(struct __pyx_obj_4lupa_5_lupa_LuaRuntime *__pyx_v_runtime, lua_State *__pyx_v_L, int __pyx_v_n) {
  struct __pyx_obj_4lupa_5_lupa__LuaThread *__pyx_v_obj = 0;
  struct __pyx_obj_4lupa_5_lupa__LuaThread *__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("new_lua_thread", 0);

  /* "lupa/_lupa.pyx":921
 * 
 * cdef _LuaThread new_lua_thread(LuaRuntime runtime, lua_State* L, int n):
 *     cdef _LuaThread obj = _LuaThread.__new__(_LuaThread)             # <<<<<<<<<<<<<<
 *     init_lua_object(obj, runtime, L, n)
 *     obj._co_state = lua.lua_tothread(L, n)
 */
  __pyx_t_1 = ((PyObject *)__pyx_tp_new_4lupa_5_lupa__LuaThread(((PyTypeObject *)__pyx_ptype_4lupa_5_lupa__LuaThread), __pyx_empty_tuple, NULL)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 921, __pyx_L1_error)
  __Pyx_GOTREF(((PyObject *)__pyx_t_1));
  __pyx_v_obj = ((struct __pyx_obj_4lupa_5_lupa__LuaThread *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "lupa/_lupa.pyx":922
 * cdef _LuaThread new_lua_thread(LuaRuntime runtime, lua_State* L, int n):
 *     cdef _LuaThread obj = _LuaThread.__new__(_LuaThread)
 *     init_lua_object(obj, runtime, L, n)             # <<<<<<<<<<<<<<
 *     obj._co_state = lua.lua_tothread(L, n)
 *     return obj
 */
  __pyx_f_4lupa_5_lupa_init_lua_object(((struct __pyx_obj_4lupa_5_lupa__LuaObject *)__pyx_v_obj), __pyx_v_runtime, __pyx_v_L, __pyx_v_n);

  /* "lupa/_lupa.pyx":923
 *     cdef _LuaThread obj = _LuaThread.__new__(_LuaThread)
 *     init_lua_object(obj, runtime, L, n)
 *     obj._co_state = lua.lua_tothread(L, n)             # <<<<<<<<<<<<<<
 *     return obj
 * 
 */
  __pyx_v_obj->_co_state = lua_tothread(__pyx_v_L, __pyx_v_n);

  /* "lupa/_lupa.pyx":924
 *     init_lua_object(obj, runtime, L, n)
 *     obj._co_state = lua.lua_tothread(L, n)
 *     return obj             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_XDECREF(((PyObject *)__pyx_r));
  __Pyx_INCREF(((PyObject *)__pyx_v_obj));
  __pyx_r = __pyx_v_obj;
  goto __pyx_L0;

  /* "lupa/_lupa.pyx":920
 *         return False
 * 
 * cdef _LuaThread new_lua_thread(LuaRuntime runtime, lua_State* L, int n):             # <<<<<<<<<<<<<<
 *     cdef _LuaThread obj = _LuaThread.__new__(_LuaThread)
 *     init_lua_object(obj, runtime, L, n)
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("lupa._lupa.new_lua_thread", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_obj);
  __Pyx_XGIVEREF((PyObject *)__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lupa/_lupa.pyx":927
 * 
 * 
 * cdef _LuaObject new_lua_thread_or_function(LuaRuntime runtime, lua_State* L, int n):             # <<<<<<<<<<<<<<
 *     # this is special - we replace a new (unstarted) thread by its
 *     # underlying function to better follow Python's own generator
 */

static struct __pyx_obj_4lupa_5_lupa__LuaObject *__pyx_f_4lupa_5_lupa_new_lua_thread_or_function(struct __pyx_obj_4lupa_5_lupa_LuaRuntime *__pyx_v_runtime, lua_State *__pyx_v_L, int __pyx_v_n) {
  lua_State *__pyx_v_co;
  struct __pyx_obj_4lupa_5_lupa__LuaObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  int __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  int __pyx_t_4;
  int __pyx_t_5;
  char const *__pyx_t_6;
  PyObject *__pyx_t_7 = NULL;
  PyObject *__pyx_t_8 = NULL;
  PyObject *__pyx_t_9 = NULL;
  PyObject *__pyx_t_10 = NULL;
  PyObject *__pyx_t_11 = NULL;
  PyObject *__pyx_t_12 = NULL;
  struct __pyx_obj_4lupa_5_lupa__LuaObject *__pyx_t_13 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("new_lua_thread_or_function", 0);

  /* "lupa/_lupa.pyx":931
 *     # underlying function to better follow Python's own generator
 *     # protocol
 *     cdef lua_State* co = lua.lua_tothread(L, n)             # <<<<<<<<<<<<<<
 *     assert co is not NULL
 *     if lua.lua_status(co) == 0 and lua.lua_gettop(co) == 1:
 */
  __pyx_v_co = lua_tothread(__pyx_v_L, __pyx_v_n);

  /* "lupa/_lupa.pyx":932
 *     # protocol
 *     cdef lua_State* co = lua.lua_tothread(L, n)
 *     assert co is not NULL             # <<<<<<<<<<<<<<
 *     if lua.lua_status(co) == 0 and lua.lua_gettop(co) == 1:
 *         # not started yet => get the function and return that
 */
  #ifndef CYTHON_WITHOUT_ASSERTIONS
  if (unlikely(!Py_OptimizeFlag)) {
    if (unlikely(!((__pyx_v_co != NULL) != 0))) {
      PyErr_SetNone(PyExc_AssertionError);
      __PYX_ERR(0, 932, __pyx_L1_error)
    }
  }
  #endif

  /* "lupa/_lupa.pyx":933
 *     cdef lua_State* co = lua.lua_tothread(L, n)
 *     assert co is not NULL
 *     if lua.lua_status(co) == 0 and lua.lua_gettop(co) == 1:             # <<<<<<<<<<<<<<
 *         # not started yet => get the function and return that
 *         lua.lua_pushvalue(co, 1)
 */
  __pyx_t_2 = ((lua_status(__pyx_v_co) == 0) != 0);
  if (__pyx_t_2) {
  } else {
    __pyx_t_1 = __pyx_t_2;
    goto __pyx_L4_bool_binop_done;
  }
  __pyx_t_2 = ((lua_gettop(__pyx_v_co) == 1) != 0);
  __pyx_t_1 = __pyx_t_2;
  __pyx_L4_bool_binop_done:;
  if (__pyx_t_1) {

    /* "lupa/_lupa.pyx":935
 *     if lua.lua_status(co) == 0 and lua.lua_gettop(co) == 1:
 *         # not started yet => get the function and return that
 *         lua.lua_pushvalue(co, 1)             # <<<<<<<<<<<<<<
 *         lua.lua_xmove(co, L, 1)
 *         try:
 */
    lua_pushvalue(__pyx_v_co, 1);

    /* "lupa/_lupa.pyx":936
 *         # not started yet => get the function and return that
 *         lua.lua_pushvalue(co, 1)
 *         lua.lua_xmove(co, L, 1)             # <<<<<<<<<<<<<<
 *         try:
 *             return new_lua_coroutine_function(runtime, L, -1)
 */
    lua_xmove(__pyx_v_co, __pyx_v_L, 1);

    /* "lupa/_lupa.pyx":937
 *         lua.lua_pushvalue(co, 1)
 *         lua.lua_xmove(co, L, 1)
 *         try:             # <<<<<<<<<<<<<<
 *             return new_lua_coroutine_function(runtime, L, -1)
 *         finally:
 */
    /*try:*/ {

      /* "lupa/_lupa.pyx":938
 *         lua.lua_xmove(co, L, 1)
 *         try:
 *             return new_lua_coroutine_function(runtime, L, -1)             # <<<<<<<<<<<<<<
 *         finally:
 *             lua.lua_pop(L, 1)
 */
      __Pyx_XDECREF(((PyObject *)__pyx_r));
      __pyx_t_3 = ((PyObject *)__pyx_f_4lupa_5_lupa_new_lua_coroutine_function(__pyx_v_runtime, __pyx_v_L, -1)); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 938, __pyx_L7_error)
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_r = ((struct __pyx_obj_4lupa_5_lupa__LuaObject *)__pyx_t_3);
      __pyx_t_3 = 0;
      goto __pyx_L6_return;
    }

    /* "lupa/_lupa.pyx":940
 *             return new_lua_coroutine_function(runtime, L, -1)
 *         finally:
 *             lua.lua_pop(L, 1)             # <<<<<<<<<<<<<<
 *     else:
 *         # already started => wrap the thread
 */
    /*finally:*/ {
      __pyx_L7_error:;
      /*exception exit:*/{
        __Pyx_PyThreadState_declare
        __Pyx_PyThreadState_assign
        __pyx_t_7 = 0; __pyx_t_8 = 0; __pyx_t_9 = 0; __pyx_t_10 = 0; __pyx_t_11 = 0; __pyx_t_12 = 0;
        __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
        if (PY_MAJOR_VERSION >= 3) __Pyx_ExceptionSwap(&__pyx_t_10, &__pyx_t_11, &__pyx_t_12);
        if ((PY_MAJOR_VERSION < 3) || unlikely(__Pyx_GetException(&__pyx_t_7, &__pyx_t_8, &__pyx_t_9) < 0)) __Pyx_ErrFetch(&__pyx_t_7, &__pyx_t_8, &__pyx_t_9);
        __Pyx_XGOTREF(__pyx_t_7);
        __Pyx_XGOTREF(__pyx_t_8);
        __Pyx_XGOTREF(__pyx_t_9);
        __Pyx_XGOTREF(__pyx_t_10);
        __Pyx_XGOTREF(__pyx_t_11);
        __Pyx_XGOTREF(__pyx_t_12);
        __pyx_t_4 = __pyx_lineno; __pyx_t_5 = __pyx_clineno; __pyx_t_6 = __pyx_filename;
        {
          lua_pop(__pyx_v_L, 1);
        }
        if (PY_MAJOR_VERSION >= 3) {
          __Pyx_XGIVEREF(__pyx_t_10);
          __Pyx_XGIVEREF(__pyx_t_11);
          __Pyx_XGIVEREF(__pyx_t_12);
          __Pyx_ExceptionReset(__pyx_t_10, __pyx_t_11, __pyx_t_12);
        }
        __Pyx_XGIVEREF(__pyx_t_7);
        __Pyx_XGIVEREF(__pyx_t_8);
        __Pyx_XGIVEREF(__pyx_t_9);
        __Pyx_ErrRestore(__pyx_t_7, __pyx_t_8, __pyx_t_9);
        __pyx_t_7 = 0; __pyx_t_8 = 0; __pyx_t_9 = 0; __pyx_t_10 = 0; __pyx_t_11 = 0; __pyx_t_12 = 0;
        __pyx_lineno = __pyx_t_4; __pyx_clineno = __pyx_t_5; __pyx_filename = __pyx_t_6;
        goto __pyx_L1_error;
      }
      __pyx_L6_return: {
        __pyx_t_13 = __pyx_r;
        __pyx_r = 0;
        lua_pop(__pyx_v_L, 1);
        __pyx_r = __pyx_t_13;
        __pyx_t_13 = 0;
        goto __pyx_L0;
      }
    }

    /* "lupa/_lupa.pyx":933
 *     cdef lua_State* co = lua.lua_tothread(L, n)
 *     assert co is not NULL
 *     if lua.lua_status(co) == 0 and lua.lua_gettop(co) == 1:             # <<<<<<<<<<<<<<
 *         # not started yet => get the function and return that
 *         lua.lua_pushvalue(co, 1)
 */
  }

  /* "lupa/_lupa.pyx":943
 *     else:
 *         # already started => wrap the thread
 *         return new_lua_thread(runtime, L, n)             # <<<<<<<<<<<<<<
 * 
 * 
 */
  /*else*/ {
    __Pyx_XDECREF(((PyObject *)__pyx_r));
    __pyx_t_3 = ((PyObject *)__pyx_f_4lupa_5_lupa_new_lua_thread(__pyx_v_runtime, __pyx_v_L, __pyx_v_n)); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 943, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_r = ((struct __pyx_obj_4lupa_5_lupa__LuaObject *)__pyx_t_3);
    __pyx_t_3 = 0;
    goto __pyx_L0;
  }

  /* "lupa/_lupa.pyx":927
 * 
 * 
 * cdef _LuaObject new_lua_thread_or_function(LuaRuntime runtime, lua_State* L, int n):             # <<<<<<<<<<<<<<
 *     # this is special - we replace a new (unstarted) thread by its
 *     # underlying function to better follow Python's own generator
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("lupa._lupa.new_lua_thread_or_function", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XGIVEREF((PyObject *)__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lupa/_lupa.pyx":946
 * 
 * 
 * cdef object resume_lua_thread(_LuaThread thread, tuple args):             # <<<<<<<<<<<<<<
 *     cdef lua_State* co = thread._co_state
 *     cdef lua_State* L = thread._state
 */

static PyObject *__pyx_f_4lupa_5_lupa_resume_lua_thread(struct __pyx_obj_4lupa_5_lupa__LuaThread *__pyx_v_thread, PyObject *__pyx_v_args) {
  lua_State *__pyx_v_co;
  lua_State *__pyx_v_L;
  int __pyx_v_status;
  int __pyx_v_nargs;
  int __pyx_v_nres;
  int __pyx_v_old_top;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  lua_State *__pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  int __pyx_t_3;
  int __pyx_t_4;
  int __pyx_t_5;
  Py_ssize_t __pyx_t_6;
  PyObject *__pyx_t_7 = NULL;
  int __pyx_t_8;
  char const *__pyx_t_9;
  PyObject *__pyx_t_10 = NULL;
  PyObject *__pyx_t_11 = NULL;
  PyObject *__pyx_t_12 = NULL;
  PyObject *__pyx_t_13 = NULL;
  PyObject *__pyx_t_14 = NULL;
  PyObject *__pyx_t_15 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("resume_lua_thread", 0);

  /* "lupa/_lupa.pyx":947
 * 
 * cdef object resume_lua_thread(_LuaThread thread, tuple args):
 *     cdef lua_State* co = thread._co_state             # <<<<<<<<<<<<<<
 *     cdef lua_State* L = thread._state
 *     cdef int status, i, nargs = 0, nres = 0
 */
  __pyx_t_1 = __pyx_v_thread->_co_state;
  __pyx_v_co = __pyx_t_1;

  /* "lupa/_lupa.pyx":948
 * cdef object resume_lua_thread(_LuaThread thread, tuple args):
 *     cdef lua_State* co = thread._co_state
 *     cdef lua_State* L = thread._state             # <<<<<<<<<<<<<<
 *     cdef int status, i, nargs = 0, nres = 0
 *     lock_runtime(thread._runtime)
 */
  __pyx_t_1 = __pyx_v_thread->__pyx_base._state;
  __pyx_v_L = __pyx_t_1;

  /* "lupa/_lupa.pyx":949
 *     cdef lua_State* co = thread._co_state
 *     cdef lua_State* L = thread._state
 *     cdef int status, i, nargs = 0, nres = 0             # <<<<<<<<<<<<<<
 *     lock_runtime(thread._runtime)
 *     old_top = lua.lua_gettop(L)
 */
  __pyx_v_nargs = 0;
  __pyx_v_nres = 0;

  /* "lupa/_lupa.pyx":950
 *     cdef lua_State* L = thread._state
 *     cdef int status, i, nargs = 0, nres = 0
 *     lock_runtime(thread._runtime)             # <<<<<<<<<<<<<<
 *     old_top = lua.lua_gettop(L)
 *     try:
 */
  __pyx_t_2 = ((PyObject *)__pyx_v_thread->__pyx_base._runtime);
  __Pyx_INCREF(__pyx_t_2);
  __pyx_t_3 = __pyx_f_4lupa_5_lupa_lock_runtime(((struct __pyx_obj_4lupa_5_lupa_LuaRuntime *)__pyx_t_2)); if (unlikely(__pyx_t_3 == ((int)-1))) __PYX_ERR(0, 950, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "lupa/_lupa.pyx":951
 *     cdef int status, i, nargs = 0, nres = 0
 *     lock_runtime(thread._runtime)
 *     old_top = lua.lua_gettop(L)             # <<<<<<<<<<<<<<
 *     try:
 *         if lua.lua_status(co) == 0 and lua.lua_gettop(co) == 0:
 */
  __pyx_v_old_top = lua_gettop(__pyx_v_L);

  /* "lupa/_lupa.pyx":952
 *     lock_runtime(thread._runtime)
 *     old_top = lua.lua_gettop(L)
 *     try:             # <<<<<<<<<<<<<<
 *         if lua.lua_status(co) == 0 and lua.lua_gettop(co) == 0:
 *             # already terminated
 */
  /*try:*/ {

    /* "lupa/_lupa.pyx":953
 *     old_top = lua.lua_gettop(L)
 *     try:
 *         if lua.lua_status(co) == 0 and lua.lua_gettop(co) == 0:             # <<<<<<<<<<<<<<
 *             # already terminated
 *             raise StopIteration
 */
    __pyx_t_5 = ((lua_status(__pyx_v_co) == 0) != 0);
    if (__pyx_t_5) {
    } else {
      __pyx_t_4 = __pyx_t_5;
      goto __pyx_L7_bool_binop_done;
    }
    __pyx_t_5 = ((lua_gettop(__pyx_v_co) == 0) != 0);
    __pyx_t_4 = __pyx_t_5;
    __pyx_L7_bool_binop_done:;
    if (unlikely(__pyx_t_4)) {

      /* "lupa/_lupa.pyx":955
 *         if lua.lua_status(co) == 0 and lua.lua_gettop(co) == 0:
 *             # already terminated
 *             raise StopIteration             # <<<<<<<<<<<<<<
 *         if args:
 *             nargs = len(args)
 */
      __Pyx_Raise(__pyx_builtin_StopIteration, 0, 0, 0);
      __PYX_ERR(0, 955, __pyx_L4_error)

      /* "lupa/_lupa.pyx":953
 *     old_top = lua.lua_gettop(L)
 *     try:
 *         if lua.lua_status(co) == 0 and lua.lua_gettop(co) == 0:             # <<<<<<<<<<<<<<
 *             # already terminated
 *             raise StopIteration
 */
    }

    /* "lupa/_lupa.pyx":956
 *             # already terminated
 *             raise StopIteration
 *         if args:             # <<<<<<<<<<<<<<
 *             nargs = len(args)
 *             push_lua_arguments(thread._runtime, co, args)
 */
    __pyx_t_4 = (__pyx_v_args != Py_None)&&(PyTuple_GET_SIZE(__pyx_v_args) != 0);
    if (__pyx_t_4) {

      /* "lupa/_lupa.pyx":957
 *             raise StopIteration
 *         if args:
 *             nargs = len(args)             # <<<<<<<<<<<<<<
 *             push_lua_arguments(thread._runtime, co, args)
 *         with nogil:
 */
      if (unlikely(__pyx_v_args == Py_None)) {
        PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()");
        __PYX_ERR(0, 957, __pyx_L4_error)
      }
      __pyx_t_6 = PyTuple_GET_SIZE(__pyx_v_args); if (unlikely(__pyx_t_6 == ((Py_ssize_t)-1))) __PYX_ERR(0, 957, __pyx_L4_error)
      __pyx_v_nargs = __pyx_t_6;

      /* "lupa/_lupa.pyx":958
 *         if args:
 *             nargs = len(args)
 *             push_lua_arguments(thread._runtime, co, args)             # <<<<<<<<<<<<<<
 *         with nogil:
 *             status = lua.lua_resume(co, L, nargs, &nres)
 */
      __pyx_t_2 = ((PyObject *)__pyx_v_thread->__pyx_base._runtime);
      __Pyx_INCREF(__pyx_t_2);
      __pyx_t_3 = __pyx_f_4lupa_5_lupa_push_lua_arguments(((struct __pyx_obj_4lupa_5_lupa_LuaRuntime *)__pyx_t_2), __pyx_v_co, __pyx_v_args, NULL); if (unlikely(__pyx_t_3 == ((int)-1))) __PYX_ERR(0, 958, __pyx_L4_error)
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

      /* "lupa/_lupa.pyx":956
 *             # already terminated
 *             raise StopIteration
 *         if args:             # <<<<<<<<<<<<<<
 *             nargs = len(args)
 *             push_lua_arguments(thread._runtime, co, args)
 */
    }

    /* "lupa/_lupa.pyx":959
 *             nargs = len(args)
 *             push_lua_arguments(thread._runtime, co, args)
 *         with nogil:             # <<<<<<<<<<<<<<
 *             status = lua.lua_resume(co, L, nargs, &nres)
 *         if status != lua.LUA_YIELD:
 */
    {
        #ifdef WITH_THREAD
        PyThreadState *_save;
        Py_UNBLOCK_THREADS
        __Pyx_FastGIL_Remember();
        #endif
        /*try:*/ {

          /* "lupa/_lupa.pyx":960
 *             push_lua_arguments(thread._runtime, co, args)
 *         with nogil:
 *             status = lua.lua_resume(co, L, nargs, &nres)             # <<<<<<<<<<<<<<
 *         if status != lua.LUA_YIELD:
 *             if status == 0:
 */
          __pyx_v_status = __lupa_lua_resume(__pyx_v_co, __pyx_v_L, __pyx_v_nargs, (&__pyx_v_nres));
        }

        /* "lupa/_lupa.pyx":959
 *             nargs = len(args)
 *             push_lua_arguments(thread._runtime, co, args)
 *         with nogil:             # <<<<<<<<<<<<<<
 *             status = lua.lua_resume(co, L, nargs, &nres)
 *         if status != lua.LUA_YIELD:
 */
        /*finally:*/ {
          /*normal exit:*/{
            #ifdef WITH_THREAD
            __Pyx_FastGIL_Forget();
            Py_BLOCK_THREADS
            #endif
            goto __pyx_L12;
          }
          __pyx_L12:;
        }
    }

    /* "lupa/_lupa.pyx":961
 *         with nogil:
 *             status = lua.lua_resume(co, L, nargs, &nres)
 *         if status != lua.LUA_YIELD:             # <<<<<<<<<<<<<<
 *             if status == 0:
 *                 # terminated
 */
    __pyx_t_4 = ((__pyx_v_status != LUA_YIELD) != 0);
    if (__pyx_t_4) {

      /* "lupa/_lupa.pyx":962
 *             status = lua.lua_resume(co, L, nargs, &nres)
 *         if status != lua.LUA_YIELD:
 *             if status == 0:             # <<<<<<<<<<<<<<
 *                 # terminated
 *                 if nres == 0:
 */
      __pyx_t_4 = ((__pyx_v_status == 0) != 0);
      if (__pyx_t_4) {

        /* "lupa/_lupa.pyx":964
 *             if status == 0:
 *                 # terminated
 *                 if nres == 0:             # <<<<<<<<<<<<<<
 *                     # no values left to return
 *                     raise StopIteration
 */
        __pyx_t_4 = ((__pyx_v_nres == 0) != 0);
        if (unlikely(__pyx_t_4)) {

          /* "lupa/_lupa.pyx":966
 *                 if nres == 0:
 *                     # no values left to return
 *                     raise StopIteration             # <<<<<<<<<<<<<<
 *             else:
 *                 raise_lua_error(thread._runtime, co, status)
 */
          __Pyx_Raise(__pyx_builtin_StopIteration, 0, 0, 0);
          __PYX_ERR(0, 966, __pyx_L4_error)

          /* "lupa/_lupa.pyx":964
 *             if status == 0:
 *                 # terminated
 *                 if nres == 0:             # <<<<<<<<<<<<<<
 *                     # no values left to return
 *                     raise StopIteration
 */
        }

        /* "lupa/_lupa.pyx":962
 *             status = lua.lua_resume(co, L, nargs, &nres)
 *         if status != lua.LUA_YIELD:
 *             if status == 0:             # <<<<<<<<<<<<<<
 *                 # terminated
 *                 if nres == 0:
 */
        goto __pyx_L14;
      }

      /* "lupa/_lupa.pyx":968
 *                     raise StopIteration
 *             else:
 *                 raise_lua_error(thread._runtime, co, status)             # <<<<<<<<<<<<<<
 * 
 *         # Move yielded values to the main state before unpacking.
 */
      /*else*/ {
        __pyx_t_2 = ((PyObject *)__pyx_v_thread->__pyx_base._runtime);
        __Pyx_INCREF(__pyx_t_2);
        __pyx_t_3 = __pyx_f_4lupa_5_lupa_raise_lua_error(((struct __pyx_obj_4lupa_5_lupa_LuaRuntime *)__pyx_t_2), __pyx_v_co, __pyx_v_status); if (unlikely(__pyx_t_3 == ((int)-1))) __PYX_ERR(0, 968, __pyx_L4_error)
        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      }
      __pyx_L14:;

      /* "lupa/_lupa.pyx":961
 *         with nogil:
 *             status = lua.lua_resume(co, L, nargs, &nres)
 *         if status != lua.LUA_YIELD:             # <<<<<<<<<<<<<<
 *             if status == 0:
 *                 # terminated
 */
    }

    /* "lupa/_lupa.pyx":973
 *         # This is what Lua's internal auxresume function is doing;
 *         # it affects wrapped Lua functions returned to Python.
 *         lua.lua_xmove(co, L, nres)             # <<<<<<<<<<<<<<
 *         return unpack_lua_results(thread._runtime, L)
 *     finally:
 */
    lua_xmove(__pyx_v_co, __pyx_v_L, __pyx_v_nres);

    /* "lupa/_lupa.pyx":974
 *         # it affects wrapped Lua functions returned to Python.
 *         lua.lua_xmove(co, L, nres)
 *         return unpack_lua_results(thread._runtime, L)             # <<<<<<<<<<<<<<
 *     finally:
 *         # FIXME: check that coroutine state is OK in case of errors?
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_2 = ((PyObject *)__pyx_v_thread->__pyx_base._runtime);
    __Pyx_INCREF(__pyx_t_2);
    __pyx_t_7 = __pyx_f_4lupa_5_lupa_unpack_lua_results(((struct __pyx_obj_4lupa_5_lupa_LuaRuntime *)__pyx_t_2), __pyx_v_L); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 974, __pyx_L4_error)
    __Pyx_GOTREF(__pyx_t_7);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_r = __pyx_t_7;
    __pyx_t_7 = 0;
    goto __pyx_L3_return;
  }

  /* "lupa/_lupa.pyx":977
 *     finally:
 *         # FIXME: check that coroutine state is OK in case of errors?
 *         lua.lua_settop(L, old_top)             # <<<<<<<<<<<<<<
 *         unlock_runtime(thread._runtime)
 * 
 */
  /*finally:*/ {
    __pyx_L4_error:;
    /*exception exit:*/{
      __Pyx_PyThreadState_declare
      __Pyx_PyThreadState_assign
      __pyx_t_10 = 0; __pyx_t_11 = 0; __pyx_t_12 = 0; __pyx_t_13 = 0; __pyx_t_14 = 0; __pyx_t_15 = 0;
      __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
      if (PY_MAJOR_VERSION >= 3) __Pyx_ExceptionSwap(&__pyx_t_13, &__pyx_t_14, &__pyx_t_15);
      if ((PY_MAJOR_VERSION < 3) || unlikely(__Pyx_GetException(&__pyx_t_10, &__pyx_t_11, &__pyx_t_12) < 0)) __Pyx_ErrFetch(&__pyx_t_10, &__pyx_t_11, &__pyx_t_12);
      __Pyx_XGOTREF(__pyx_t_10);
      __Pyx_XGOTREF(__pyx_t_11);
      __Pyx_XGOTREF(__pyx_t_12);
      __Pyx_XGOTREF(__pyx_t_13);
      __Pyx_XGOTREF(__pyx_t_14);
      __Pyx_XGOTREF(__pyx_t_15);
      __pyx_t_3 = __pyx_lineno; __pyx_t_8 = __pyx_clineno; __pyx_t_9 = __pyx_filename;
      {
        lua_settop(__pyx_v_L, __pyx_v_old_top);

        /* "lupa/_lupa.pyx":978
 *         # FIXME: check that coroutine state is OK in case of errors?
 *         lua.lua_settop(L, old_top)
 *         unlock_runtime(thread._runtime)             # <<<<<<<<<<<<<<
 * 
 * 
 */
        __pyx_t_7 = ((PyObject *)__pyx_v_thread->__pyx_base._runtime);
        __Pyx_INCREF(__pyx_t_7);
        __pyx_f_4lupa_5_lupa_unlock_runtime(((struct __pyx_obj_4lupa_5_lupa_LuaRuntime *)__pyx_t_7));
        __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      }
      if (PY_MAJOR_VERSION >= 3) {
        __Pyx_XGIVEREF(__pyx_t_13);
        __Pyx_XGIVEREF(__pyx_t_14);
        __Pyx_XGIVEREF(__pyx_t_15);
        __Pyx_ExceptionReset(__pyx_t_13, __pyx_t_14, __pyx_t_15);
      }
      __Pyx_XGIVEREF(__pyx_t_10);
      __Pyx_XGIVEREF(__pyx_t_11);
      __Pyx_XGIVEREF(__pyx_t_12);
      __Pyx_ErrRestore(__pyx_t_10, __pyx_t_11, __pyx_t_12);
      __pyx_t_10 = 0; __pyx_t_11 = 0; __pyx_t_12 = 0; __pyx_t_13 = 0; __pyx_t_14 = 0; __pyx_t_15 = 0;
      __pyx_lineno = __pyx_t_3; __pyx_clineno = __pyx_t_8; __pyx_filename = __pyx_t_9;
      goto __pyx_L1_error;
    }
    __pyx_L3_return: {
      __pyx_t_15 = __pyx_r;
      __pyx_r = 0;

      /* "lupa/_lupa.pyx":977
 *     finally:
 *         # FIXME: check that coroutine state is OK in case of errors?
 *         lua.lua_settop(L, old_top)             # <<<<<<<<<<<<<<
 *         unlock_runtime(thread._runtime)
 * 
 */
      lua_settop(__pyx_v_L, __pyx_v_old_top);

      /* "lupa/_lupa.pyx":978
 *         # FIXME: check that coroutine state is OK in case of errors?
 *         lua.lua_settop(L, old_top)
 *         unlock_runtime(thread._runtime)             # <<<<<<<<<<<<<<
 * 
 * 
 */
      __pyx_t_7 = ((PyObject *)__pyx_v_thread->__pyx_base._runtime);
      __Pyx_INCREF(__pyx_t_7);
      __pyx_f_4lupa_5_lupa_unlock_runtime(((struct __pyx_obj_4lupa_5_lupa_LuaRuntime *)__pyx_t_7));
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      __pyx_r = __pyx_t_15;
      __pyx_t_15 = 0;
      goto __pyx_L0;
    }
  }

  /* "lupa/_lupa.pyx":946
 * 
 * 
 * cdef object resume_lua_thread(_LuaThread thread, tuple args):             # <<<<<<<<<<<<<<
 *     cdef lua_State* co = thread._co_state
 *     cdef lua_State* L = thread._state
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_AddTraceback("lupa._lupa.resume_lua_thread", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lupa/_lupa.pyx":997
 *     cdef char _what
 * 
 *     def __cinit__(self, _LuaObject obj not None, int what):             # <<<<<<<<<<<<<<
 *         self._state = NULL
 *         assert obj._runtime is not None
 */

/* Python wrapper */
static int __pyx_pw_4lupa_5_lupa_8_LuaIter_1__cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static int __pyx_pw_4lupa_5_lupa_8_LuaIter_1__cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  struct __pyx_obj_4lupa_5_lupa__LuaObject *__pyx_v_obj = 0;
  int __pyx_v_what;
  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_obj,&__pyx_n_s_what,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_obj)) != 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_what)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("__cinit__", 1, 2, 2, 1); __PYX_ERR(0, 997, __pyx_L3_error)
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__cinit__") < 0)) __PYX_ERR(0, 997, __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_obj = ((struct __pyx_obj_4lupa_5_lupa__LuaObject *)values[0]);
    __pyx_v_what = __Pyx_PyInt_As_int(values[1]); if (unlikely((__pyx_v_what == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 997, __pyx_L3_error)
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("__cinit__", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 997, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("lupa._lupa._LuaIter.__cinit__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return -1;
  __pyx_L4_argument_unpacking_done:;
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_obj), __pyx_ptype_4lupa_5_lupa__LuaObject, 0, "obj", 0))) __PYX_ERR(0, 997, __pyx_L1_error)
  __pyx_r = __pyx_pf_4lupa_5_lupa_8_LuaIter___cinit__(((struct __pyx_obj_4lupa_5_lupa__LuaIter *)__pyx_v_self), __pyx_v_obj, __pyx_v_what);

  /* function exit code */
  goto __pyx_L0;
  __pyx_L1_error:;
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static int __pyx_pf_4lupa_5_lupa_8_LuaIter___cinit__(struct __pyx_obj_4lupa_5_lupa__LuaIter *__pyx_v_self, struct __pyx_obj_4lupa_5_lupa__LuaObject *__pyx_v_obj, int __pyx_v_what) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  lua_State *__pyx_t_3;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__cinit__", 0);

  /* "lupa/_lupa.pyx":998
 * 
 *     def __cinit__(self, _LuaObject obj not None, int what):
 *         self._state = NULL             # <<<<<<<<<<<<<<
 *         assert obj._runtime is not None
 *         self._runtime = obj._runtime
 */
  __pyx_v_self->_state = NULL;

  /* "lupa/_lupa.pyx":999
 *     def __cinit__(self, _LuaObject obj not None, int what):
 *         self._state = NULL
 *         assert obj._runtime is not None             # <<<<<<<<<<<<<<
 *         self._runtime = obj._runtime
 *         self._obj = obj
 */
  #ifndef CYTHON_WITHOUT_ASSERTIONS
  if (unlikely(!Py_OptimizeFlag)) {
    __pyx_t_1 = (((PyObject *)__pyx_v_obj->_runtime) != Py_None);
    if (unlikely(!(__pyx_t_1 != 0))) {
      PyErr_SetNone(PyExc_AssertionError);
      __PYX_ERR(0, 999, __pyx_L1_error)
    }
  }
  #endif

  /* "lupa/_lupa.pyx":1000
 *         self._state = NULL
 *         assert obj._runtime is not None
 *         self._runtime = obj._runtime             # <<<<<<<<<<<<<<
 *         self._obj = obj
 *         self._state = obj._state
 */
  __pyx_t_2 = ((PyObject *)__pyx_v_obj->_runtime);
  __Pyx_INCREF(__pyx_t_2);
  __Pyx_GIVEREF(__pyx_t_2);
  __Pyx_GOTREF(__pyx_v_self->_runtime);
  __Pyx_DECREF(((PyObject *)__pyx_v_self->_runtime));
  __pyx_v_self->_runtime = ((struct __pyx_obj_4lupa_5_lupa_LuaRuntime *)__pyx_t_2);
  __pyx_t_2 = 0;

  /* "lupa/_lupa.pyx":1001
 *         assert obj._runtime is not None
 *         self._runtime = obj._runtime
 *         self._obj = obj             # <<<<<<<<<<<<<<
 *         self._state = obj._state
 *         self._refiter = 0
 */
  __Pyx_INCREF(((PyObject *)__pyx_v_obj));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_obj));
  __Pyx_GOTREF(__pyx_v_self->_obj);
  __Pyx_DECREF(((PyObject *)__pyx_v_self->_obj));
  __pyx_v_self->_obj = __pyx_v_obj;

  /* "lupa/_lupa.pyx":1002
 *         self._runtime = obj._runtime
 *         self._obj = obj
 *         self._state = obj._state             # <<<<<<<<<<<<<<
 *         self._refiter = 0
 *         self._what = what
 */
  __pyx_t_3 = __pyx_v_obj->_state;
  __pyx_v_self->_state = __pyx_t_3;

  /* "lupa/_lupa.pyx":1003
 *         self._obj = obj
 *         self._state = obj._state
 *         self._refiter = 0             # <<<<<<<<<<<<<<
 *         self._what = what
 * 
 */
  __pyx_v_self->_refiter = 0;

  /* "lupa/_lupa.pyx":1004
 *         self._state = obj._state
 *         self._refiter = 0
 *         self._what = what             # <<<<<<<<<<<<<<
 * 
 *     def __dealloc__(self):
 */
  __pyx_v_self->_what = __pyx_v_what;

  /* "lupa/_lupa.pyx":997
 *     cdef char _what
 * 
 *     def __cinit__(self, _LuaObject obj not None, int what):             # <<<<<<<<<<<<<<
 *         self._state = NULL
 *         assert obj._runtime is not None
 */

  /* function exit code */
  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_AddTraceback("lupa._lupa._LuaIter.__cinit__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lupa/_lupa.pyx":1006
 *         self._what = what
 * 
 *     def __dealloc__(self):             # <<<<<<<<<<<<<<
 *         if self._runtime is None:
 *             return
 */

/* Python wrapper */
static void __pyx_pw_4lupa_5_lupa_8_LuaIter_3__dealloc__(PyObject *__pyx_v_self); /*proto*/
static void __pyx_pw_4lupa_5_lupa_8_LuaIter_3__dealloc__(PyObject *__pyx_v_self) {
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__dealloc__ (wrapper)", 0);
  __pyx_pf_4lupa_5_lupa_8_LuaIter_2__dealloc__(((struct __pyx_obj_4lupa_5_lupa__LuaIter *)__pyx_v_self));

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

static void __pyx_pf_4lupa_5_lupa_8_LuaIter_2__dealloc__(struct __pyx_obj_4lupa_5_lupa__LuaIter *__pyx_v_self) {
  lua_State *__pyx_v_L;
  int __pyx_v_locked;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  int __pyx_t_2;
  lua_State *__pyx_t_3;
  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_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__dealloc__", 0);

  /* "lupa/_lupa.pyx":1007
 * 
 *     def __dealloc__(self):
 *         if self._runtime is None:             # <<<<<<<<<<<<<<
 *             return
 *         cdef lua_State* L = self._state
 */
  __pyx_t_1 = (((PyObject *)__pyx_v_self->_runtime) == Py_None);
  __pyx_t_2 = (__pyx_t_1 != 0);
  if (__pyx_t_2) {

    /* "lupa/_lupa.pyx":1008
 *     def __dealloc__(self):
 *         if self._runtime is None:
 *             return             # <<<<<<<<<<<<<<
 *         cdef lua_State* L = self._state
 *         if L is not NULL and self._refiter:
 */
    goto __pyx_L0;

    /* "lupa/_lupa.pyx":1007
 * 
 *     def __dealloc__(self):
 *         if self._runtime is None:             # <<<<<<<<<<<<<<
 *             return
 *         cdef lua_State* L = self._state
 */
  }

  /* "lupa/_lupa.pyx":1009
 *         if self._runtime is None:
 *             return
 *         cdef lua_State* L = self._state             # <<<<<<<<<<<<<<
 *         if L is not NULL and self._refiter:
 *             locked = False
 */
  __pyx_t_3 = __pyx_v_self->_state;
  __pyx_v_L = __pyx_t_3;

  /* "lupa/_lupa.pyx":1010
 *             return
 *         cdef lua_State* L = self._state
 *         if L is not NULL and self._refiter:             # <<<<<<<<<<<<<<
 *             locked = False
 *             try:
 */
  __pyx_t_1 = ((__pyx_v_L != NULL) != 0);
  if (__pyx_t_1) {
  } else {
    __pyx_t_2 = __pyx_t_1;
    goto __pyx_L5_bool_binop_done;
  }
  __pyx_t_1 = (__pyx_v_self->_refiter != 0);
  __pyx_t_2 = __pyx_t_1;
  __pyx_L5_bool_binop_done:;
  if (__pyx_t_2) {

    /* "lupa/_lupa.pyx":1011
 *         cdef lua_State* L = self._state
 *         if L is not NULL and self._refiter:
 *             locked = False             # <<<<<<<<<<<<<<
 *             try:
 *                 lock_runtime(self._runtime)
 */
    __pyx_v_locked = 0;

    /* "lupa/_lupa.pyx":1012
 *         if L is not NULL and self._refiter:
 *             locked = False
 *             try:             # <<<<<<<<<<<<<<
 *                 lock_runtime(self._runtime)
 *                 locked = True
 */
    {
      __Pyx_PyThreadState_declare
      __Pyx_PyThreadState_assign
      __Pyx_ExceptionSave(&__pyx_t_4, &__pyx_t_5, &__pyx_t_6);
      __Pyx_XGOTREF(__pyx_t_4);
      __Pyx_XGOTREF(__pyx_t_5);
      __Pyx_XGOTREF(__pyx_t_6);
      /*try:*/ {

        /* "lupa/_lupa.pyx":1013
 *             locked = False
 *             try:
 *                 lock_runtime(self._runtime)             # <<<<<<<<<<<<<<
 *                 locked = True
 *             except:
 */
        __pyx_t_7 = ((PyObject *)__pyx_v_self->_runtime);
        __Pyx_INCREF(__pyx_t_7);
        __pyx_t_8 = __pyx_f_4lupa_5_lupa_lock_runtime(((struct __pyx_obj_4lupa_5_lupa_LuaRuntime *)__pyx_t_7)); if (unlikely(__pyx_t_8 == ((int)-1))) __PYX_ERR(0, 1013, __pyx_L7_error)
        __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;

        /* "lupa/_lupa.pyx":1014
 *             try:
 *                 lock_runtime(self._runtime)
 *                 locked = True             # <<<<<<<<<<<<<<
 *             except:
 *                 pass
 */
        __pyx_v_locked = 1;

        /* "lupa/_lupa.pyx":1012
 *         if L is not NULL and self._refiter:
 *             locked = False
 *             try:             # <<<<<<<<<<<<<<
 *                 lock_runtime(self._runtime)
 *                 locked = True
 */
      }
      __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
      __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
      __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
      goto __pyx_L12_try_end;
      __pyx_L7_error:;
      __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;

      /* "lupa/_lupa.pyx":1015
 *                 lock_runtime(self._runtime)
 *                 locked = True
 *             except:             # <<<<<<<<<<<<<<
 *                 pass
 *             lua.luaL_unref(L, lua.LUA_REGISTRYINDEX, self._refiter)
 */
      /*except:*/ {
        __Pyx_ErrRestore(0,0,0);
        goto __pyx_L8_exception_handled;
      }
      __pyx_L8_exception_handled:;
      __Pyx_XGIVEREF(__pyx_t_4);
      __Pyx_XGIVEREF(__pyx_t_5);
      __Pyx_XGIVEREF(__pyx_t_6);
      __Pyx_ExceptionReset(__pyx_t_4, __pyx_t_5, __pyx_t_6);
      __pyx_L12_try_end:;
    }

    /* "lupa/_lupa.pyx":1017
 *             except:
 *                 pass
 *             lua.luaL_unref(L, lua.LUA_REGISTRYINDEX, self._refiter)             # <<<<<<<<<<<<<<
 *             if locked:
 *                 unlock_runtime(self._runtime)
 */
    luaL_unref(__pyx_v_L, LUA_REGISTRYINDEX, __pyx_v_self->_refiter);

    /* "lupa/_lupa.pyx":1018
 *                 pass
 *             lua.luaL_unref(L, lua.LUA_REGISTRYINDEX, self._refiter)
 *             if locked:             # <<<<<<<<<<<<<<
 *                 unlock_runtime(self._runtime)
 * 
 */
    __pyx_t_2 = (__pyx_v_locked != 0);
    if (__pyx_t_2) {

      /* "lupa/_lupa.pyx":1019
 *             lua.luaL_unref(L, lua.LUA_REGISTRYINDEX, self._refiter)
 *             if locked:
 *                 unlock_runtime(self._runtime)             # <<<<<<<<<<<<<<
 * 
 *     def __repr__(self):
 */
      __pyx_t_7 = ((PyObject *)__pyx_v_self->_runtime);
      __Pyx_INCREF(__pyx_t_7);
      __pyx_f_4lupa_5_lupa_unlock_runtime(((struct __pyx_obj_4lupa_5_lupa_LuaRuntime *)__pyx_t_7));
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;

      /* "lupa/_lupa.pyx":1018
 *                 pass
 *             lua.luaL_unref(L, lua.LUA_REGISTRYINDEX, self._refiter)
 *             if locked:             # <<<<<<<<<<<<<<
 *                 unlock_runtime(self._runtime)
 * 
 */
    }

    /* "lupa/_lupa.pyx":1010
 *             return
 *         cdef lua_State* L = self._state
 *         if L is not NULL and self._refiter:             # <<<<<<<<<<<<<<
 *             locked = False
 *             try:
 */
  }

  /* "lupa/_lupa.pyx":1006
 *         self._what = what
 * 
 *     def __dealloc__(self):             # <<<<<<<<<<<<<<
 *         if self._runtime is None:
 *             return
 */

  /* function exit code */
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
}

/* "lupa/_lupa.pyx":1021
 *                 unlock_runtime(self._runtime)
 * 
 *     def __repr__(self):             # <<<<<<<<<<<<<<
 *         return u"LuaIter(%r)" % (self._obj)
 * 
 */

/* Python wrapper */
static PyObject *__pyx_pw_4lupa_5_lupa_8_LuaIter_5__repr__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_4lupa_5_lupa_8_LuaIter_5__repr__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__repr__ (wrapper)", 0);
  __pyx_r = __pyx_pf_4lupa_5_lupa_8_LuaIter_4__repr__(((struct __pyx_obj_4lupa_5_lupa__LuaIter *)__pyx_v_self));

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

static PyObject *__pyx_pf_4lupa_5_lupa_8_LuaIter_4__repr__(struct __pyx_obj_4lupa_5_lupa__LuaIter *__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("__repr__", 0);

  /* "lupa/_lupa.pyx":1022
 * 
 *     def __repr__(self):
 *         return u"LuaIter(%r)" % (self._obj)             # <<<<<<<<<<<<<<
 * 
 *     def __iter__(self):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = PyUnicode_Format(__pyx_kp_u_LuaIter_r, ((PyObject *)__pyx_v_self->_obj)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1022, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "lupa/_lupa.pyx":1021
 *                 unlock_runtime(self._runtime)
 * 
 *     def __repr__(self):             # <<<<<<<<<<<<<<
 *         return u"LuaIter(%r)" % (self._obj)
 * 
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("lupa._lupa._LuaIter.__repr__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lupa/_lupa.pyx":1024
 *         return u"LuaIter(%r)" % (self._obj)
 * 
 *     def __iter__(self):             # <<<<<<<<<<<<<<
 *         return self
 * 
 */

/* Python wrapper */
static PyObject *__pyx_pw_4lupa_5_lupa_8_LuaIter_7__iter__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_4lupa_5_lupa_8_LuaIter_7__iter__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__iter__ (wrapper)", 0);
  __pyx_r = __pyx_pf_4lupa_5_lupa_8_LuaIter_6__iter__(((struct __pyx_obj_4lupa_5_lupa__LuaIter *)__pyx_v_self));

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

static PyObject *__pyx_pf_4lupa_5_lupa_8_LuaIter_6__iter__(struct __pyx_obj_4lupa_5_lupa__LuaIter *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__iter__", 0);

  /* "lupa/_lupa.pyx":1025
 * 
 *     def __iter__(self):
 *         return self             # <<<<<<<<<<<<<<
 * 
 *     def __next__(self):
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(((PyObject *)__pyx_v_self));
  __pyx_r = ((PyObject *)__pyx_v_self);
  goto __pyx_L0;

  /* "lupa/_lupa.pyx":1024
 *         return u"LuaIter(%r)" % (self._obj)
 * 
 *     def __iter__(self):             # <<<<<<<<<<<<<<
 *         return self
 * 
 */

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

/* "lupa/_lupa.pyx":1027
 *         return self
 * 
 *     def __next__(self):             # <<<<<<<<<<<<<<
 *         if self._obj is None:
 *             raise StopIteration
 */

/* Python wrapper */
static PyObject *__pyx_pw_4lupa_5_lupa_8_LuaIter_9__next__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_4lupa_5_lupa_8_LuaIter_9__next__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__next__ (wrapper)", 0);
  __pyx_r = __pyx_pf_4lupa_5_lupa_8_LuaIter_8__next__(((struct __pyx_obj_4lupa_5_lupa__LuaIter *)__pyx_v_self));

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

static PyObject *__pyx_pf_4lupa_5_lupa_8_LuaIter_8__next__(struct __pyx_obj_4lupa_5_lupa__LuaIter *__pyx_v_self) {
  lua_State *__pyx_v_L;
  int __pyx_v_old_top;
  PyObject *__pyx_v_retval = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  int __pyx_t_2;
  lua_State *__pyx_t_3;
  PyObject *__pyx_t_4 = NULL;
  int __pyx_t_5;
  PyObject *__pyx_t_6 = NULL;
  PyObject *__pyx_t_7 = NULL;
  int __pyx_t_8;
  char const *__pyx_t_9;
  PyObject *__pyx_t_10 = NULL;
  PyObject *__pyx_t_11 = NULL;
  PyObject *__pyx_t_12 = NULL;
  PyObject *__pyx_t_13 = NULL;
  PyObject *__pyx_t_14 = NULL;
  PyObject *__pyx_t_15 = NULL;
  char const *__pyx_t_16;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__next__", 0);

  /* "lupa/_lupa.pyx":1028
 * 
 *     def __next__(self):
 *         if self._obj is None:             # <<<<<<<<<<<<<<
 *             raise StopIteration
 *         cdef lua_State* L = self._obj._state
 */
  __pyx_t_1 = (((PyObject *)__pyx_v_self->_obj) == Py_None);
  __pyx_t_2 = (__pyx_t_1 != 0);
  if (unlikely(__pyx_t_2)) {

    /* "lupa/_lupa.pyx":1029
 *     def __next__(self):
 *         if self._obj is None:
 *             raise StopIteration             # <<<<<<<<<<<<<<
 *         cdef lua_State* L = self._obj._state
 *         lock_runtime(self._runtime)
 */
    __Pyx_Raise(__pyx_builtin_StopIteration, 0, 0, 0);
    __PYX_ERR(0, 1029, __pyx_L1_error)

    /* "lupa/_lupa.pyx":1028
 * 
 *     def __next__(self):
 *         if self._obj is None:             # <<<<<<<<<<<<<<
 *             raise StopIteration
 *         cdef lua_State* L = self._obj._state
 */
  }

  /* "lupa/_lupa.pyx":1030
 *         if self._obj is None:
 *             raise StopIteration
 *         cdef lua_State* L = self._obj._state             # <<<<<<<<<<<<<<
 *         lock_runtime(self._runtime)
 *         old_top = lua.lua_gettop(L)
 */
  __pyx_t_3 = __pyx_v_self->_obj->_state;
  __pyx_v_L = __pyx_t_3;

  /* "lupa/_lupa.pyx":1031
 *             raise StopIteration
 *         cdef lua_State* L = self._obj._state
 *         lock_runtime(self._runtime)             # <<<<<<<<<<<<<<
 *         old_top = lua.lua_gettop(L)
 *         try:
 */
  __pyx_t_4 = ((PyObject *)__pyx_v_self->_runtime);
  __Pyx_INCREF(__pyx_t_4);
  __pyx_t_5 = __pyx_f_4lupa_5_lupa_lock_runtime(((struct __pyx_obj_4lupa_5_lupa_LuaRuntime *)__pyx_t_4)); if (unlikely(__pyx_t_5 == ((int)-1))) __PYX_ERR(0, 1031, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

  /* "lupa/_lupa.pyx":1032
 *         cdef lua_State* L = self._obj._state
 *         lock_runtime(self._runtime)
 *         old_top = lua.lua_gettop(L)             # <<<<<<<<<<<<<<
 *         try:
 *             if self._obj is None:
 */
  __pyx_v_old_top = lua_gettop(__pyx_v_L);

  /* "lupa/_lupa.pyx":1033
 *         lock_runtime(self._runtime)
 *         old_top = lua.lua_gettop(L)
 *         try:             # <<<<<<<<<<<<<<
 *             if self._obj is None:
 *                 raise StopIteration
 */
  /*try:*/ {

    /* "lupa/_lupa.pyx":1034
 *         old_top = lua.lua_gettop(L)
 *         try:
 *             if self._obj is None:             # <<<<<<<<<<<<<<
 *                 raise StopIteration
 *             # iterable object
 */
    __pyx_t_2 = (((PyObject *)__pyx_v_self->_obj) == Py_None);
    __pyx_t_1 = (__pyx_t_2 != 0);
    if (unlikely(__pyx_t_1)) {

      /* "lupa/_lupa.pyx":1035
 *         try:
 *             if self._obj is None:
 *                 raise StopIteration             # <<<<<<<<<<<<<<
 *             # iterable object
 *             lua.lua_rawgeti(L, lua.LUA_REGISTRYINDEX, self._obj._ref)
 */
      __Pyx_Raise(__pyx_builtin_StopIteration, 0, 0, 0);
      __PYX_ERR(0, 1035, __pyx_L5_error)

      /* "lupa/_lupa.pyx":1034
 *         old_top = lua.lua_gettop(L)
 *         try:
 *             if self._obj is None:             # <<<<<<<<<<<<<<
 *                 raise StopIteration
 *             # iterable object
 */
    }

    /* "lupa/_lupa.pyx":1037
 *                 raise StopIteration
 *             # iterable object
 *             lua.lua_rawgeti(L, lua.LUA_REGISTRYINDEX, self._obj._ref)             # <<<<<<<<<<<<<<
 *             if not lua.lua_istable(L, -1):
 *                 if lua.lua_isnil(L, -1):
 */
    lua_rawgeti(__pyx_v_L, LUA_REGISTRYINDEX, __pyx_v_self->_obj->_ref);

    /* "lupa/_lupa.pyx":1038
 *             # iterable object
 *             lua.lua_rawgeti(L, lua.LUA_REGISTRYINDEX, self._obj._ref)
 *             if not lua.lua_istable(L, -1):             # <<<<<<<<<<<<<<
 *                 if lua.lua_isnil(L, -1):
 *                     lua.lua_pop(L, 1)
 */
    __pyx_t_1 = ((!(lua_istable(__pyx_v_L, -1) != 0)) != 0);
    if (__pyx_t_1) {

      /* "lupa/_lupa.pyx":1039
 *             lua.lua_rawgeti(L, lua.LUA_REGISTRYINDEX, self._obj._ref)
 *             if not lua.lua_istable(L, -1):
 *                 if lua.lua_isnil(L, -1):             # <<<<<<<<<<<<<<
 *                     lua.lua_pop(L, 1)
 *                     raise LuaError("lost reference")
 */
      __pyx_t_1 = (lua_isnil(__pyx_v_L, -1) != 0);
      if (unlikely(__pyx_t_1)) {

        /* "lupa/_lupa.pyx":1040
 *             if not lua.lua_istable(L, -1):
 *                 if lua.lua_isnil(L, -1):
 *                     lua.lua_pop(L, 1)             # <<<<<<<<<<<<<<
 *                     raise LuaError("lost reference")
 *                 raise TypeError("cannot iterate over non-table (found %r)" % self._obj)
 */
        lua_pop(__pyx_v_L, 1);

        /* "lupa/_lupa.pyx":1041
 *                 if lua.lua_isnil(L, -1):
 *                     lua.lua_pop(L, 1)
 *                     raise LuaError("lost reference")             # <<<<<<<<<<<<<<
 *                 raise TypeError("cannot iterate over non-table (found %r)" % self._obj)
 *             if not self._refiter:
 */
        __Pyx_GetModuleGlobalName(__pyx_t_6, __pyx_n_s_LuaError); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1041, __pyx_L5_error)
        __Pyx_GOTREF(__pyx_t_6);
        __pyx_t_7 = NULL;
        if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_6))) {
          __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_6);
          if (likely(__pyx_t_7)) {
            PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6);
            __Pyx_INCREF(__pyx_t_7);
            __Pyx_INCREF(function);
            __Pyx_DECREF_SET(__pyx_t_6, function);
          }
        }
        __pyx_t_4 = (__pyx_t_7) ? __Pyx_PyObject_Call2Args(__pyx_t_6, __pyx_t_7, __pyx_kp_s_lost_reference) : __Pyx_PyObject_CallOneArg(__pyx_t_6, __pyx_kp_s_lost_reference);
        __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
        if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1041, __pyx_L5_error)
        __Pyx_GOTREF(__pyx_t_4);
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
        __Pyx_Raise(__pyx_t_4, 0, 0, 0);
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
        __PYX_ERR(0, 1041, __pyx_L5_error)

        /* "lupa/_lupa.pyx":1039
 *             lua.lua_rawgeti(L, lua.LUA_REGISTRYINDEX, self._obj._ref)
 *             if not lua.lua_istable(L, -1):
 *                 if lua.lua_isnil(L, -1):             # <<<<<<<<<<<<<<
 *                     lua.lua_pop(L, 1)
 *                     raise LuaError("lost reference")
 */
      }

      /* "lupa/_lupa.pyx":1042
 *                     lua.lua_pop(L, 1)
 *                     raise LuaError("lost reference")
 *                 raise TypeError("cannot iterate over non-table (found %r)" % self._obj)             # <<<<<<<<<<<<<<
 *             if not self._refiter:
 *                 # initial key
 */
      __pyx_t_4 = __Pyx_PyString_Format(__pyx_kp_s_cannot_iterate_over_non_table_fo, ((PyObject *)__pyx_v_self->_obj)); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1042, __pyx_L5_error)
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_t_6 = __Pyx_PyObject_CallOneArg(__pyx_builtin_TypeError, __pyx_t_4); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1042, __pyx_L5_error)
      __Pyx_GOTREF(__pyx_t_6);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __Pyx_Raise(__pyx_t_6, 0, 0, 0);
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      __PYX_ERR(0, 1042, __pyx_L5_error)

      /* "lupa/_lupa.pyx":1038
 *             # iterable object
 *             lua.lua_rawgeti(L, lua.LUA_REGISTRYINDEX, self._obj._ref)
 *             if not lua.lua_istable(L, -1):             # <<<<<<<<<<<<<<
 *                 if lua.lua_isnil(L, -1):
 *                     lua.lua_pop(L, 1)
 */
    }

    /* "lupa/_lupa.pyx":1043
 *                     raise LuaError("lost reference")
 *                 raise TypeError("cannot iterate over non-table (found %r)" % self._obj)
 *             if not self._refiter:             # <<<<<<<<<<<<<<
 *                 # initial key
 *                 lua.lua_pushnil(L)
 */
    __pyx_t_1 = ((!(__pyx_v_self->_refiter != 0)) != 0);
    if (__pyx_t_1) {

      /* "lupa/_lupa.pyx":1045
 *             if not self._refiter:
 *                 # initial key
 *                 lua.lua_pushnil(L)             # <<<<<<<<<<<<<<
 *             else:
 *                 # last key
 */
      lua_pushnil(__pyx_v_L);

      /* "lupa/_lupa.pyx":1043
 *                     raise LuaError("lost reference")
 *                 raise TypeError("cannot iterate over non-table (found %r)" % self._obj)
 *             if not self._refiter:             # <<<<<<<<<<<<<<
 *                 # initial key
 *                 lua.lua_pushnil(L)
 */
      goto __pyx_L10;
    }

    /* "lupa/_lupa.pyx":1048
 *             else:
 *                 # last key
 *                 lua.lua_rawgeti(L, lua.LUA_REGISTRYINDEX, self._refiter)             # <<<<<<<<<<<<<<
 *             if lua.lua_next(L, -2):
 *                 try:
 */
    /*else*/ {
      lua_rawgeti(__pyx_v_L, LUA_REGISTRYINDEX, __pyx_v_self->_refiter);
    }
    __pyx_L10:;

    /* "lupa/_lupa.pyx":1049
 *                 # last key
 *                 lua.lua_rawgeti(L, lua.LUA_REGISTRYINDEX, self._refiter)
 *             if lua.lua_next(L, -2):             # <<<<<<<<<<<<<<
 *                 try:
 *                     if self._what == KEYS:
 */
    __pyx_t_1 = (lua_next(__pyx_v_L, -2) != 0);
    if (__pyx_t_1) {

      /* "lupa/_lupa.pyx":1050
 *                 lua.lua_rawgeti(L, lua.LUA_REGISTRYINDEX, self._refiter)
 *             if lua.lua_next(L, -2):
 *                 try:             # <<<<<<<<<<<<<<
 *                     if self._what == KEYS:
 *                         retval = py_from_lua(self._runtime, L, -2)
 */
      /*try:*/ {

        /* "lupa/_lupa.pyx":1051
 *             if lua.lua_next(L, -2):
 *                 try:
 *                     if self._what == KEYS:             # <<<<<<<<<<<<<<
 *                         retval = py_from_lua(self._runtime, L, -2)
 *                     elif self._what == VALUES:
 */
        switch (__pyx_v_self->_what) {
          case __pyx_e_4lupa_5_lupa_KEYS:

          /* "lupa/_lupa.pyx":1052
 *                 try:
 *                     if self._what == KEYS:
 *                         retval = py_from_lua(self._runtime, L, -2)             # <<<<<<<<<<<<<<
 *                     elif self._what == VALUES:
 *                         retval = py_from_lua(self._runtime, L, -1)
 */
          __pyx_t_6 = ((PyObject *)__pyx_v_self->_runtime);
          __Pyx_INCREF(__pyx_t_6);
          __pyx_t_4 = __pyx_f_4lupa_5_lupa_py_from_lua(((struct __pyx_obj_4lupa_5_lupa_LuaRuntime *)__pyx_t_6), __pyx_v_L, -2); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1052, __pyx_L13_error)
          __Pyx_GOTREF(__pyx_t_4);
          __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
          __pyx_v_retval = __pyx_t_4;
          __pyx_t_4 = 0;

          /* "lupa/_lupa.pyx":1051
 *             if lua.lua_next(L, -2):
 *                 try:
 *                     if self._what == KEYS:             # <<<<<<<<<<<<<<
 *                         retval = py_from_lua(self._runtime, L, -2)
 *                     elif self._what == VALUES:
 */
          break;
          case __pyx_e_4lupa_5_lupa_VALUES:

          /* "lupa/_lupa.pyx":1054
 *                         retval = py_from_lua(self._runtime, L, -2)
 *                     elif self._what == VALUES:
 *                         retval = py_from_lua(self._runtime, L, -1)             # <<<<<<<<<<<<<<
 *                     else: # ITEMS
 *                         retval = (py_from_lua(self._runtime, L, -2), py_from_lua(self._runtime, L, -1))
 */
          __pyx_t_4 = ((PyObject *)__pyx_v_self->_runtime);
          __Pyx_INCREF(__pyx_t_4);
          __pyx_t_6 = __pyx_f_4lupa_5_lupa_py_from_lua(((struct __pyx_obj_4lupa_5_lupa_LuaRuntime *)__pyx_t_4), __pyx_v_L, -1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1054, __pyx_L13_error)
          __Pyx_GOTREF(__pyx_t_6);
          __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
          __pyx_v_retval = __pyx_t_6;
          __pyx_t_6 = 0;

          /* "lupa/_lupa.pyx":1053
 *                     if self._what == KEYS:
 *                         retval = py_from_lua(self._runtime, L, -2)
 *                     elif self._what == VALUES:             # <<<<<<<<<<<<<<
 *                         retval = py_from_lua(self._runtime, L, -1)
 *                     else: # ITEMS
 */
          break;
          default:

          /* "lupa/_lupa.pyx":1056
 *                         retval = py_from_lua(self._runtime, L, -1)
 *                     else: # ITEMS
 *                         retval = (py_from_lua(self._runtime, L, -2), py_from_lua(self._runtime, L, -1))             # <<<<<<<<<<<<<<
 *                 finally:
 *                     # pop value
 */
          __pyx_t_6 = ((PyObject *)__pyx_v_self->_runtime);
          __Pyx_INCREF(__pyx_t_6);
          __pyx_t_4 = __pyx_f_4lupa_5_lupa_py_from_lua(((struct __pyx_obj_4lupa_5_lupa_LuaRuntime *)__pyx_t_6), __pyx_v_L, -2); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1056, __pyx_L13_error)
          __Pyx_GOTREF(__pyx_t_4);
          __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
          __pyx_t_6 = ((PyObject *)__pyx_v_self->_runtime);
          __Pyx_INCREF(__pyx_t_6);
          __pyx_t_7 = __pyx_f_4lupa_5_lupa_py_from_lua(((struct __pyx_obj_4lupa_5_lupa_LuaRuntime *)__pyx_t_6), __pyx_v_L, -1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1056, __pyx_L13_error)
          __Pyx_GOTREF(__pyx_t_7);
          __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
          __pyx_t_6 = PyTuple_New(2); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1056, __pyx_L13_error)
          __Pyx_GOTREF(__pyx_t_6);
          __Pyx_GIVEREF(__pyx_t_4);
          PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_4);
          __Pyx_GIVEREF(__pyx_t_7);
          PyTuple_SET_ITEM(__pyx_t_6, 1, __pyx_t_7);
          __pyx_t_4 = 0;
          __pyx_t_7 = 0;
          __pyx_v_retval = __pyx_t_6;
          __pyx_t_6 = 0;
          break;
        }
      }

      /* "lupa/_lupa.pyx":1059
 *                 finally:
 *                     # pop value
 *                     lua.lua_pop(L, 1)             # <<<<<<<<<<<<<<
 *                     # pop and store key
 *                     if not self._refiter:
 */
      /*finally:*/ {
        /*normal exit:*/{
          lua_pop(__pyx_v_L, 1);

          /* "lupa/_lupa.pyx":1061
 *                     lua.lua_pop(L, 1)
 *                     # pop and store key
 *                     if not self._refiter:             # <<<<<<<<<<<<<<
 *                         self._refiter = lua.luaL_ref(L, lua.LUA_REGISTRYINDEX)
 *                     else:
 */
          __pyx_t_1 = ((!(__pyx_v_self->_refiter != 0)) != 0);
          if (__pyx_t_1) {

            /* "lupa/_lupa.pyx":1062
 *                     # pop and store key
 *                     if not self._refiter:
 *                         self._refiter = lua.luaL_ref(L, lua.LUA_REGISTRYINDEX)             # <<<<<<<<<<<<<<
 *                     else:
 *                         lua.lua_rawseti(L, lua.LUA_REGISTRYINDEX, self._refiter)
 */
            __pyx_v_self->_refiter = luaL_ref(__pyx_v_L, LUA_REGISTRYINDEX);

            /* "lupa/_lupa.pyx":1061
 *                     lua.lua_pop(L, 1)
 *                     # pop and store key
 *                     if not self._refiter:             # <<<<<<<<<<<<<<
 *                         self._refiter = lua.luaL_ref(L, lua.LUA_REGISTRYINDEX)
 *                     else:
 */
            goto __pyx_L15;
          }

          /* "lupa/_lupa.pyx":1064
 *                         self._refiter = lua.luaL_ref(L, lua.LUA_REGISTRYINDEX)
 *                     else:
 *                         lua.lua_rawseti(L, lua.LUA_REGISTRYINDEX, self._refiter)             # <<<<<<<<<<<<<<
 *                 return retval
 *             # iteration done, clean up
 */
          /*else*/ {
            lua_rawseti(__pyx_v_L, LUA_REGISTRYINDEX, __pyx_v_self->_refiter);
          }
          __pyx_L15:;
          goto __pyx_L14;
        }
        __pyx_L13_error:;
        /*exception exit:*/{
          __Pyx_PyThreadState_declare
          __Pyx_PyThreadState_assign
          __pyx_t_10 = 0; __pyx_t_11 = 0; __pyx_t_12 = 0; __pyx_t_13 = 0; __pyx_t_14 = 0; __pyx_t_15 = 0;
          __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
          __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
          __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
          if (PY_MAJOR_VERSION >= 3) __Pyx_ExceptionSwap(&__pyx_t_13, &__pyx_t_14, &__pyx_t_15);
          if ((PY_MAJOR_VERSION < 3) || unlikely(__Pyx_GetException(&__pyx_t_10, &__pyx_t_11, &__pyx_t_12) < 0)) __Pyx_ErrFetch(&__pyx_t_10, &__pyx_t_11, &__pyx_t_12);
          __Pyx_XGOTREF(__pyx_t_10);
          __Pyx_XGOTREF(__pyx_t_11);
          __Pyx_XGOTREF(__pyx_t_12);
          __Pyx_XGOTREF(__pyx_t_13);
          __Pyx_XGOTREF(__pyx_t_14);
          __Pyx_XGOTREF(__pyx_t_15);
          __pyx_t_5 = __pyx_lineno; __pyx_t_8 = __pyx_clineno; __pyx_t_9 = __pyx_filename;
          {

            /* "lupa/_lupa.pyx":1059
 *                 finally:
 *                     # pop value
 *                     lua.lua_pop(L, 1)             # <<<<<<<<<<<<<<
 *                     # pop and store key
 *                     if not self._refiter:
 */
            lua_pop(__pyx_v_L, 1);

            /* "lupa/_lupa.pyx":1061
 *                     lua.lua_pop(L, 1)
 *                     # pop and store key
 *                     if not self._refiter:             # <<<<<<<<<<<<<<
 *                         self._refiter = lua.luaL_ref(L, lua.LUA_REGISTRYINDEX)
 *                     else:
 */
            __pyx_t_1 = ((!(__pyx_v_self->_refiter != 0)) != 0);
            if (__pyx_t_1) {

              /* "lupa/_lupa.pyx":1062
 *                     # pop and store key
 *                     if not self._refiter:
 *                         self._refiter = lua.luaL_ref(L, lua.LUA_REGISTRYINDEX)             # <<<<<<<<<<<<<<
 *                     else:
 *                         lua.lua_rawseti(L, lua.LUA_REGISTRYINDEX, self._refiter)
 */
              __pyx_v_self->_refiter = luaL_ref(__pyx_v_L, LUA_REGISTRYINDEX);

              /* "lupa/_lupa.pyx":1061
 *                     lua.lua_pop(L, 1)
 *                     # pop and store key
 *                     if not self._refiter:             # <<<<<<<<<<<<<<
 *                         self._refiter = lua.luaL_ref(L, lua.LUA_REGISTRYINDEX)
 *                     else:
 */
              goto __pyx_L18;
            }

            /* "lupa/_lupa.pyx":1064
 *                         self._refiter = lua.luaL_ref(L, lua.LUA_REGISTRYINDEX)
 *                     else:
 *                         lua.lua_rawseti(L, lua.LUA_REGISTRYINDEX, self._refiter)             # <<<<<<<<<<<<<<
 *                 return retval
 *             # iteration done, clean up
 */
            /*else*/ {
              lua_rawseti(__pyx_v_L, LUA_REGISTRYINDEX, __pyx_v_self->_refiter);
            }
            __pyx_L18:;
          }
          if (PY_MAJOR_VERSION >= 3) {
            __Pyx_XGIVEREF(__pyx_t_13);
            __Pyx_XGIVEREF(__pyx_t_14);
            __Pyx_XGIVEREF(__pyx_t_15);
            __Pyx_ExceptionReset(__pyx_t_13, __pyx_t_14, __pyx_t_15);
          }
          __Pyx_XGIVEREF(__pyx_t_10);
          __Pyx_XGIVEREF(__pyx_t_11);
          __Pyx_XGIVEREF(__pyx_t_12);
          __Pyx_ErrRestore(__pyx_t_10, __pyx_t_11, __pyx_t_12);
          __pyx_t_10 = 0; __pyx_t_11 = 0; __pyx_t_12 = 0; __pyx_t_13 = 0; __pyx_t_14 = 0; __pyx_t_15 = 0;
          __pyx_lineno = __pyx_t_5; __pyx_clineno = __pyx_t_8; __pyx_filename = __pyx_t_9;
          goto __pyx_L5_error;
        }
        __pyx_L14:;
      }

      /* "lupa/_lupa.pyx":1065
 *                     else:
 *                         lua.lua_rawseti(L, lua.LUA_REGISTRYINDEX, self._refiter)
 *                 return retval             # <<<<<<<<<<<<<<
 *             # iteration done, clean up
 *             if self._refiter:
 */
      __Pyx_XDECREF(__pyx_r);
      __Pyx_INCREF(__pyx_v_retval);
      __pyx_r = __pyx_v_retval;
      goto __pyx_L4_return;

      /* "lupa/_lupa.pyx":1049
 *                 # last key
 *                 lua.lua_rawgeti(L, lua.LUA_REGISTRYINDEX, self._refiter)
 *             if lua.lua_next(L, -2):             # <<<<<<<<<<<<<<
 *                 try:
 *                     if self._what == KEYS:
 */
    }

    /* "lupa/_lupa.pyx":1067
 *                 return retval
 *             # iteration done, clean up
 *             if self._refiter:             # <<<<<<<<<<<<<<
 *                 lua.luaL_unref(L, lua.LUA_REGISTRYINDEX, self._refiter)
 *                 self._refiter = 0
 */
    __pyx_t_1 = (__pyx_v_self->_refiter != 0);
    if (__pyx_t_1) {

      /* "lupa/_lupa.pyx":1068
 *             # iteration done, clean up
 *             if self._refiter:
 *                 lua.luaL_unref(L, lua.LUA_REGISTRYINDEX, self._refiter)             # <<<<<<<<<<<<<<
 *                 self._refiter = 0
 *             self._obj = None
 */
      luaL_unref(__pyx_v_L, LUA_REGISTRYINDEX, __pyx_v_self->_refiter);

      /* "lupa/_lupa.pyx":1069
 *             if self._refiter:
 *                 lua.luaL_unref(L, lua.LUA_REGISTRYINDEX, self._refiter)
 *                 self._refiter = 0             # <<<<<<<<<<<<<<
 *             self._obj = None
 *         finally:
 */
      __pyx_v_self->_refiter = 0;

      /* "lupa/_lupa.pyx":1067
 *                 return retval
 *             # iteration done, clean up
 *             if self._refiter:             # <<<<<<<<<<<<<<
 *                 lua.luaL_unref(L, lua.LUA_REGISTRYINDEX, self._refiter)
 *                 self._refiter = 0
 */
    }

    /* "lupa/_lupa.pyx":1070
 *                 lua.luaL_unref(L, lua.LUA_REGISTRYINDEX, self._refiter)
 *                 self._refiter = 0
 *             self._obj = None             # <<<<<<<<<<<<<<
 *         finally:
 *             lua.lua_settop(L, old_top)
 */
    __Pyx_INCREF(Py_None);
    __Pyx_GIVEREF(Py_None);
    __Pyx_GOTREF(__pyx_v_self->_obj);
    __Pyx_DECREF(((PyObject *)__pyx_v_self->_obj));
    __pyx_v_self->_obj = ((struct __pyx_obj_4lupa_5_lupa__LuaObject *)Py_None);
  }

  /* "lupa/_lupa.pyx":1072
 *             self._obj = None
 *         finally:
 *             lua.lua_settop(L, old_top)             # <<<<<<<<<<<<<<
 *             unlock_runtime(self._runtime)
 *         raise StopIteration
 */
  /*finally:*/ {
    /*normal exit:*/{
      lua_settop(__pyx_v_L, __pyx_v_old_top);

      /* "lupa/_lupa.pyx":1073
 *         finally:
 *             lua.lua_settop(L, old_top)
 *             unlock_runtime(self._runtime)             # <<<<<<<<<<<<<<
 *         raise StopIteration
 * 
 */
      __pyx_t_6 = ((PyObject *)__pyx_v_self->_runtime);
      __Pyx_INCREF(__pyx_t_6);
      __pyx_f_4lupa_5_lupa_unlock_runtime(((struct __pyx_obj_4lupa_5_lupa_LuaRuntime *)__pyx_t_6));
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      goto __pyx_L6;
    }
    __pyx_L5_error:;
    /*exception exit:*/{
      __Pyx_PyThreadState_declare
      __Pyx_PyThreadState_assign
      __pyx_t_15 = 0; __pyx_t_14 = 0; __pyx_t_13 = 0; __pyx_t_12 = 0; __pyx_t_11 = 0; __pyx_t_10 = 0;
      __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
      __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
      __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
      if (PY_MAJOR_VERSION >= 3) __Pyx_ExceptionSwap(&__pyx_t_12, &__pyx_t_11, &__pyx_t_10);
      if ((PY_MAJOR_VERSION < 3) || unlikely(__Pyx_GetException(&__pyx_t_15, &__pyx_t_14, &__pyx_t_13) < 0)) __Pyx_ErrFetch(&__pyx_t_15, &__pyx_t_14, &__pyx_t_13);
      __Pyx_XGOTREF(__pyx_t_15);
      __Pyx_XGOTREF(__pyx_t_14);
      __Pyx_XGOTREF(__pyx_t_13);
      __Pyx_XGOTREF(__pyx_t_12);
      __Pyx_XGOTREF(__pyx_t_11);
      __Pyx_XGOTREF(__pyx_t_10);
      __pyx_t_8 = __pyx_lineno; __pyx_t_5 = __pyx_clineno; __pyx_t_16 = __pyx_filename;
      {

        /* "lupa/_lupa.pyx":1072
 *             self._obj = None
 *         finally:
 *             lua.lua_settop(L, old_top)             # <<<<<<<<<<<<<<
 *             unlock_runtime(self._runtime)
 *         raise StopIteration
 */
        lua_settop(__pyx_v_L, __pyx_v_old_top);

        /* "lupa/_lupa.pyx":1073
 *         finally:
 *             lua.lua_settop(L, old_top)
 *             unlock_runtime(self._runtime)             # <<<<<<<<<<<<<<
 *         raise StopIteration
 * 
 */
        __pyx_t_6 = ((PyObject *)__pyx_v_self->_runtime);
        __Pyx_INCREF(__pyx_t_6);
        __pyx_f_4lupa_5_lupa_unlock_runtime(((struct __pyx_obj_4lupa_5_lupa_LuaRuntime *)__pyx_t_6));
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      }
      if (PY_MAJOR_VERSION >= 3) {
        __Pyx_XGIVEREF(__pyx_t_12);
        __Pyx_XGIVEREF(__pyx_t_11);
        __Pyx_XGIVEREF(__pyx_t_10);
        __Pyx_ExceptionReset(__pyx_t_12, __pyx_t_11, __pyx_t_10);
      }
      __Pyx_XGIVEREF(__pyx_t_15);
      __Pyx_XGIVEREF(__pyx_t_14);
      __Pyx_XGIVEREF(__pyx_t_13);
      __Pyx_ErrRestore(__pyx_t_15, __pyx_t_14, __pyx_t_13);
      __pyx_t_15 = 0; __pyx_t_14 = 0; __pyx_t_13 = 0; __pyx_t_12 = 0; __pyx_t_11 = 0; __pyx_t_10 = 0;
      __pyx_lineno = __pyx_t_8; __pyx_clineno = __pyx_t_5; __pyx_filename = __pyx_t_16;
      goto __pyx_L1_error;
    }
    __pyx_L4_return: {
      __pyx_t_10 = __pyx_r;
      __pyx_r = 0;

      /* "lupa/_lupa.pyx":1072
 *             self._obj = None
 *         finally:
 *             lua.lua_settop(L, old_top)             # <<<<<<<<<<<<<<
 *             unlock_runtime(self._runtime)
 *         raise StopIteration
 */
      lua_settop(__pyx_v_L, __pyx_v_old_top);

      /* "lupa/_lupa.pyx":1073
 *         finally:
 *             lua.lua_settop(L, old_top)
 *             unlock_runtime(self._runtime)             # <<<<<<<<<<<<<<
 *         raise StopIteration
 * 
 */
      __pyx_t_6 = ((PyObject *)__pyx_v_self->_runtime);
      __Pyx_INCREF(__pyx_t_6);
      __pyx_f_4lupa_5_lupa_unlock_runtime(((struct __pyx_obj_4lupa_5_lupa_LuaRuntime *)__pyx_t_6));
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      __pyx_r = __pyx_t_10;
      __pyx_t_10 = 0;
      goto __pyx_L0;
    }
    __pyx_L6:;
  }

  /* "lupa/_lupa.pyx":1074
 *             lua.lua_settop(L, old_top)
 *             unlock_runtime(self._runtime)
 *         raise StopIteration             # <<<<<<<<<<<<<<
 * 
 * # type conversions and protocol adaptations
 */
  __Pyx_Raise(__pyx_builtin_StopIteration, 0, 0, 0);
  __PYX_ERR(0, 1074, __pyx_L1_error)

  /* "lupa/_lupa.pyx":1027
 *         return self
 * 
 *     def __next__(self):             # <<<<<<<<<<<<<<
 *         if self._obj is None:
 *             raise StopIteration
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_AddTraceback("lupa._lupa._LuaIter.__next__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_retval);
  __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_4lupa_5_lupa_8_LuaIter_11__reduce_cython__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static char __pyx_doc_4lupa_5_lupa_8_LuaIter_10__reduce_cython__[] = "_LuaIter.__reduce_cython__(self)";
static PyMethodDef __pyx_mdef_4lupa_5_lupa_8_LuaIter_11__reduce_cython__ = {"__reduce_cython__", (PyCFunction)__pyx_pw_4lupa_5_lupa_8_LuaIter_11__reduce_cython__, METH_NOARGS, __pyx_doc_4lupa_5_lupa_8_LuaIter_10__reduce_cython__};
static PyObject *__pyx_pw_4lupa_5_lupa_8_LuaIter_11__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_4lupa_5_lupa_8_LuaIter_10__reduce_cython__(((struct __pyx_obj_4lupa_5_lupa__LuaIter *)__pyx_v_self));

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

static PyObject *__pyx_pf_4lupa_5_lupa_8_LuaIter_10__reduce_cython__(CYTHON_UNUSED struct __pyx_obj_4lupa_5_lupa__LuaIter *__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__29, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 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(2, 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("lupa._lupa._LuaIter.__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_4lupa_5_lupa_8_LuaIter_13__setstate_cython__(PyObject *__pyx_v_self, PyObject *__pyx_v___pyx_state); /*proto*/
static char __pyx_doc_4lupa_5_lupa_8_LuaIter_12__setstate_cython__[] = "_LuaIter.__setstate_cython__(self, __pyx_state)";
static PyMethodDef __pyx_mdef_4lupa_5_lupa_8_LuaIter_13__setstate_cython__ = {"__setstate_cython__", (PyCFunction)__pyx_pw_4lupa_5_lupa_8_LuaIter_13__setstate_cython__, METH_O, __pyx_doc_4lupa_5_lupa_8_LuaIter_12__setstate_cython__};
static PyObject *__pyx_pw_4lupa_5_lupa_8_LuaIter_13__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_4lupa_5_lupa_8_LuaIter_12__setstate_cython__(((struct __pyx_obj_4lupa_5_lupa__LuaIter *)__pyx_v_self), ((PyObject *)__pyx_v___pyx_state));

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

static PyObject *__pyx_pf_4lupa_5_lupa_8_LuaIter_12__setstate_cython__(CYTHON_UNUSED struct __pyx_obj_4lupa_5_lupa__LuaIter *__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__30, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 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(2, 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("lupa._lupa._LuaIter.__setstate_cython__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lupa/_lupa.pyx":1078
 * # type conversions and protocol adaptations
 * 
 * cdef int py_asfunc_call(lua_State *L) nogil:             # <<<<<<<<<<<<<<
 *     if (lua.lua_gettop(L) == 1 and lua.lua_islightuserdata(L, 1)
 *             and lua.lua_topointer(L, 1) == <void*>unpack_wrapped_pyfunction):
 */

static int __pyx_f_4lupa_5_lupa_py_asfunc_call(lua_State *__pyx_v_L) {
  int __pyx_r;
  int __pyx_t_1;
  int __pyx_t_2;

  /* "lupa/_lupa.pyx":1079
 * 
 * cdef int py_asfunc_call(lua_State *L) nogil:
 *     if (lua.lua_gettop(L) == 1 and lua.lua_islightuserdata(L, 1)             # <<<<<<<<<<<<<<
 *             and lua.lua_topointer(L, 1) == <void*>unpack_wrapped_pyfunction):
 *         # special case: unwrap_lua_object() calls this to find out the Python object
 */
  __pyx_t_2 = ((lua_gettop(__pyx_v_L) == 1) != 0);
  if (__pyx_t_2) {
  } else {
    __pyx_t_1 = __pyx_t_2;
    goto __pyx_L4_bool_binop_done;
  }

  /* "lupa/_lupa.pyx":1080
 * cdef int py_asfunc_call(lua_State *L) nogil:
 *     if (lua.lua_gettop(L) == 1 and lua.lua_islightuserdata(L, 1)
 *             and lua.lua_topointer(L, 1) == <void*>unpack_wrapped_pyfunction):             # <<<<<<<<<<<<<<
 *         # special case: unwrap_lua_object() calls this to find out the Python object
 *         lua.lua_pushvalue(L, lua.lua_upvalueindex(1))
 */
  __pyx_t_2 = (lua_islightuserdata(__pyx_v_L, 1) != 0);
  if (__pyx_t_2) {
  } else {
    __pyx_t_1 = __pyx_t_2;
    goto __pyx_L4_bool_binop_done;
  }
  __pyx_t_2 = ((lua_topointer(__pyx_v_L, 1) == ((void *)__pyx_f_4lupa_5_lupa_unpack_wrapped_pyfunction)) != 0);
  __pyx_t_1 = __pyx_t_2;
  __pyx_L4_bool_binop_done:;

  /* "lupa/_lupa.pyx":1079
 * 
 * cdef int py_asfunc_call(lua_State *L) nogil:
 *     if (lua.lua_gettop(L) == 1 and lua.lua_islightuserdata(L, 1)             # <<<<<<<<<<<<<<
 *             and lua.lua_topointer(L, 1) == <void*>unpack_wrapped_pyfunction):
 *         # special case: unwrap_lua_object() calls this to find out the Python object
 */
  if (__pyx_t_1) {

    /* "lupa/_lupa.pyx":1082
 *             and lua.lua_topointer(L, 1) == <void*>unpack_wrapped_pyfunction):
 *         # special case: unwrap_lua_object() calls this to find out the Python object
 *         lua.lua_pushvalue(L, lua.lua_upvalueindex(1))             # <<<<<<<<<<<<<<
 *         return 1
 *     lua.lua_pushvalue(L, lua.lua_upvalueindex(1))
 */
    lua_pushvalue(__pyx_v_L, lua_upvalueindex(1));

    /* "lupa/_lupa.pyx":1083
 *         # special case: unwrap_lua_object() calls this to find out the Python object
 *         lua.lua_pushvalue(L, lua.lua_upvalueindex(1))
 *         return 1             # <<<<<<<<<<<<<<
 *     lua.lua_pushvalue(L, lua.lua_upvalueindex(1))
 *     lua.lua_insert(L, 1)
 */
    __pyx_r = 1;
    goto __pyx_L0;

    /* "lupa/_lupa.pyx":1079
 * 
 * cdef int py_asfunc_call(lua_State *L) nogil:
 *     if (lua.lua_gettop(L) == 1 and lua.lua_islightuserdata(L, 1)             # <<<<<<<<<<<<<<
 *             and lua.lua_topointer(L, 1) == <void*>unpack_wrapped_pyfunction):
 *         # special case: unwrap_lua_object() calls this to find out the Python object
 */
  }

  /* "lupa/_lupa.pyx":1084
 *         lua.lua_pushvalue(L, lua.lua_upvalueindex(1))
 *         return 1
 *     lua.lua_pushvalue(L, lua.lua_upvalueindex(1))             # <<<<<<<<<<<<<<
 *     lua.lua_insert(L, 1)
 *     return py_object_call(L)
 */
  lua_pushvalue(__pyx_v_L, lua_upvalueindex(1));

  /* "lupa/_lupa.pyx":1085
 *         return 1
 *     lua.lua_pushvalue(L, lua.lua_upvalueindex(1))
 *     lua.lua_insert(L, 1)             # <<<<<<<<<<<<<<
 *     return py_object_call(L)
 * 
 */
  lua_insert(__pyx_v_L, 1);

  /* "lupa/_lupa.pyx":1086
 *     lua.lua_pushvalue(L, lua.lua_upvalueindex(1))
 *     lua.lua_insert(L, 1)
 *     return py_object_call(L)             # <<<<<<<<<<<<<<
 * 
 * cdef py_object* unpack_wrapped_pyfunction(lua_State* L, int n) nogil:
 */
  __pyx_r = __pyx_f_4lupa_5_lupa_py_object_call(__pyx_v_L);
  goto __pyx_L0;

  /* "lupa/_lupa.pyx":1078
 * # type conversions and protocol adaptations
 * 
 * cdef int py_asfunc_call(lua_State *L) nogil:             # <<<<<<<<<<<<<<
 *     if (lua.lua_gettop(L) == 1 and lua.lua_islightuserdata(L, 1)
 *             and lua.lua_topointer(L, 1) == <void*>unpack_wrapped_pyfunction):
 */

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

/* "lupa/_lupa.pyx":1088
 *     return py_object_call(L)
 * 
 * cdef py_object* unpack_wrapped_pyfunction(lua_State* L, int n) nogil:             # <<<<<<<<<<<<<<
 *     cdef lua.lua_CFunction cfunction = lua.lua_tocfunction(L, n)
 *     if cfunction is <lua.lua_CFunction>py_asfunc_call:
 */

static struct __pyx_t_4lupa_5_lupa_py_object *__pyx_f_4lupa_5_lupa_unpack_wrapped_pyfunction(lua_State *__pyx_v_L, int __pyx_v_n) {
  lua_CFunction __pyx_v_cfunction;
  struct __pyx_t_4lupa_5_lupa_py_object *__pyx_r;
  int __pyx_t_1;

  /* "lupa/_lupa.pyx":1089
 * 
 * cdef py_object* unpack_wrapped_pyfunction(lua_State* L, int n) nogil:
 *     cdef lua.lua_CFunction cfunction = lua.lua_tocfunction(L, n)             # <<<<<<<<<<<<<<
 *     if cfunction is <lua.lua_CFunction>py_asfunc_call:
 *         lua.lua_pushvalue(L, n)
 */
  __pyx_v_cfunction = lua_tocfunction(__pyx_v_L, __pyx_v_n);

  /* "lupa/_lupa.pyx":1090
 * cdef py_object* unpack_wrapped_pyfunction(lua_State* L, int n) nogil:
 *     cdef lua.lua_CFunction cfunction = lua.lua_tocfunction(L, n)
 *     if cfunction is <lua.lua_CFunction>py_asfunc_call:             # <<<<<<<<<<<<<<
 *         lua.lua_pushvalue(L, n)
 *         lua.lua_pushlightuserdata(L, <void*>unpack_wrapped_pyfunction)
 */
  __pyx_t_1 = ((__pyx_v_cfunction == ((lua_CFunction)__pyx_f_4lupa_5_lupa_py_asfunc_call)) != 0);
  if (__pyx_t_1) {

    /* "lupa/_lupa.pyx":1091
 *     cdef lua.lua_CFunction cfunction = lua.lua_tocfunction(L, n)
 *     if cfunction is <lua.lua_CFunction>py_asfunc_call:
 *         lua.lua_pushvalue(L, n)             # <<<<<<<<<<<<<<
 *         lua.lua_pushlightuserdata(L, <void*>unpack_wrapped_pyfunction)
 *         if lua.lua_pcall(L, 1, 1, 0) == 0:
 */
    lua_pushvalue(__pyx_v_L, __pyx_v_n);

    /* "lupa/_lupa.pyx":1092
 *     if cfunction is <lua.lua_CFunction>py_asfunc_call:
 *         lua.lua_pushvalue(L, n)
 *         lua.lua_pushlightuserdata(L, <void*>unpack_wrapped_pyfunction)             # <<<<<<<<<<<<<<
 *         if lua.lua_pcall(L, 1, 1, 0) == 0:
 *             return unpack_userdata(L, -1)
 */
    lua_pushlightuserdata(__pyx_v_L, ((void *)__pyx_f_4lupa_5_lupa_unpack_wrapped_pyfunction));

    /* "lupa/_lupa.pyx":1093
 *         lua.lua_pushvalue(L, n)
 *         lua.lua_pushlightuserdata(L, <void*>unpack_wrapped_pyfunction)
 *         if lua.lua_pcall(L, 1, 1, 0) == 0:             # <<<<<<<<<<<<<<
 *             return unpack_userdata(L, -1)
 *     return NULL
 */
    __pyx_t_1 = ((lua_pcall(__pyx_v_L, 1, 1, 0) == 0) != 0);
    if (__pyx_t_1) {

      /* "lupa/_lupa.pyx":1094
 *         lua.lua_pushlightuserdata(L, <void*>unpack_wrapped_pyfunction)
 *         if lua.lua_pcall(L, 1, 1, 0) == 0:
 *             return unpack_userdata(L, -1)             # <<<<<<<<<<<<<<
 *     return NULL
 * 
 */
      __pyx_r = __pyx_f_4lupa_5_lupa_unpack_userdata(__pyx_v_L, -1);
      goto __pyx_L0;

      /* "lupa/_lupa.pyx":1093
 *         lua.lua_pushvalue(L, n)
 *         lua.lua_pushlightuserdata(L, <void*>unpack_wrapped_pyfunction)
 *         if lua.lua_pcall(L, 1, 1, 0) == 0:             # <<<<<<<<<<<<<<
 *             return unpack_userdata(L, -1)
 *     return NULL
 */
    }

    /* "lupa/_lupa.pyx":1090
 * cdef py_object* unpack_wrapped_pyfunction(lua_State* L, int n) nogil:
 *     cdef lua.lua_CFunction cfunction = lua.lua_tocfunction(L, n)
 *     if cfunction is <lua.lua_CFunction>py_asfunc_call:             # <<<<<<<<<<<<<<
 *         lua.lua_pushvalue(L, n)
 *         lua.lua_pushlightuserdata(L, <void*>unpack_wrapped_pyfunction)
 */
  }

  /* "lupa/_lupa.pyx":1095
 *         if lua.lua_pcall(L, 1, 1, 0) == 0:
 *             return unpack_userdata(L, -1)
 *     return NULL             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_r = NULL;
  goto __pyx_L0;

  /* "lupa/_lupa.pyx":1088
 *     return py_object_call(L)
 * 
 * cdef py_object* unpack_wrapped_pyfunction(lua_State* L, int n) nogil:             # <<<<<<<<<<<<<<
 *     cdef lua.lua_CFunction cfunction = lua.lua_tocfunction(L, n)
 *     if cfunction is <lua.lua_CFunction>py_asfunc_call:
 */

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

/* "lupa/_lupa.pyx":1104
 *     cdef object _obj
 *     cdef int _type_flags
 *     def __cinit__(self):             # <<<<<<<<<<<<<<
 *         self._type_flags = 0
 *     def __init__(self):
 */

/* Python wrapper */
static int __pyx_pw_4lupa_5_lupa_18_PyProtocolWrapper_1__cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static int __pyx_pw_4lupa_5_lupa_18_PyProtocolWrapper_1__cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__cinit__ (wrapper)", 0);
  if (unlikely(PyTuple_GET_SIZE(__pyx_args) > 0)) {
    __Pyx_RaiseArgtupleInvalid("__cinit__", 1, 0, 0, PyTuple_GET_SIZE(__pyx_args)); return -1;}
  if (unlikely(__pyx_kwds) && unlikely(PyDict_Size(__pyx_kwds) > 0) && unlikely(!__Pyx_CheckKeywordStrings(__pyx_kwds, "__cinit__", 0))) return -1;
  __pyx_r = __pyx_pf_4lupa_5_lupa_18_PyProtocolWrapper___cinit__(((struct __pyx_obj_4lupa_5_lupa__PyProtocolWrapper *)__pyx_v_self));

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

static int __pyx_pf_4lupa_5_lupa_18_PyProtocolWrapper___cinit__(struct __pyx_obj_4lupa_5_lupa__PyProtocolWrapper *__pyx_v_self) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__cinit__", 0);

  /* "lupa/_lupa.pyx":1105
 *     cdef int _type_flags
 *     def __cinit__(self):
 *         self._type_flags = 0             # <<<<<<<<<<<<<<
 *     def __init__(self):
 *         raise TypeError("Type cannot be instantiated from Python")
 */
  __pyx_v_self->_type_flags = 0;

  /* "lupa/_lupa.pyx":1104
 *     cdef object _obj
 *     cdef int _type_flags
 *     def __cinit__(self):             # <<<<<<<<<<<<<<
 *         self._type_flags = 0
 *     def __init__(self):
 */

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

/* "lupa/_lupa.pyx":1106
 *     def __cinit__(self):
 *         self._type_flags = 0
 *     def __init__(self):             # <<<<<<<<<<<<<<
 *         raise TypeError("Type cannot be instantiated from Python")
 * 
 */

/* Python wrapper */
static int __pyx_pw_4lupa_5_lupa_18_PyProtocolWrapper_3__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static int __pyx_pw_4lupa_5_lupa_18_PyProtocolWrapper_3__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__init__ (wrapper)", 0);
  if (unlikely(PyTuple_GET_SIZE(__pyx_args) > 0)) {
    __Pyx_RaiseArgtupleInvalid("__init__", 1, 0, 0, PyTuple_GET_SIZE(__pyx_args)); return -1;}
  if (unlikely(__pyx_kwds) && unlikely(PyDict_Size(__pyx_kwds) > 0) && unlikely(!__Pyx_CheckKeywordStrings(__pyx_kwds, "__init__", 0))) return -1;
  __pyx_r = __pyx_pf_4lupa_5_lupa_18_PyProtocolWrapper_2__init__(((struct __pyx_obj_4lupa_5_lupa__PyProtocolWrapper *)__pyx_v_self));

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

static int __pyx_pf_4lupa_5_lupa_18_PyProtocolWrapper_2__init__(CYTHON_UNUSED struct __pyx_obj_4lupa_5_lupa__PyProtocolWrapper *__pyx_v_self) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__init__", 0);

  /* "lupa/_lupa.pyx":1107
 *         self._type_flags = 0
 *     def __init__(self):
 *         raise TypeError("Type cannot be instantiated from Python")             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__31, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1107, __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, 1107, __pyx_L1_error)

  /* "lupa/_lupa.pyx":1106
 *     def __cinit__(self):
 *         self._type_flags = 0
 *     def __init__(self):             # <<<<<<<<<<<<<<
 *         raise TypeError("Type cannot be instantiated from Python")
 * 
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("lupa._lupa._PyProtocolWrapper.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __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_4lupa_5_lupa_18_PyProtocolWrapper_5__reduce_cython__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static char __pyx_doc_4lupa_5_lupa_18_PyProtocolWrapper_4__reduce_cython__[] = "_PyProtocolWrapper.__reduce_cython__(self)";
static PyMethodDef __pyx_mdef_4lupa_5_lupa_18_PyProtocolWrapper_5__reduce_cython__ = {"__reduce_cython__", (PyCFunction)__pyx_pw_4lupa_5_lupa_18_PyProtocolWrapper_5__reduce_cython__, METH_NOARGS, __pyx_doc_4lupa_5_lupa_18_PyProtocolWrapper_4__reduce_cython__};
static PyObject *__pyx_pw_4lupa_5_lupa_18_PyProtocolWrapper_5__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_4lupa_5_lupa_18_PyProtocolWrapper_4__reduce_cython__(((struct __pyx_obj_4lupa_5_lupa__PyProtocolWrapper *)__pyx_v_self));

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

static PyObject *__pyx_pf_4lupa_5_lupa_18_PyProtocolWrapper_4__reduce_cython__(CYTHON_UNUSED struct __pyx_obj_4lupa_5_lupa__PyProtocolWrapper *__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__32, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 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(2, 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("lupa._lupa._PyProtocolWrapper.__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_4lupa_5_lupa_18_PyProtocolWrapper_7__setstate_cython__(PyObject *__pyx_v_self, PyObject *__pyx_v___pyx_state); /*proto*/
static char __pyx_doc_4lupa_5_lupa_18_PyProtocolWrapper_6__setstate_cython__[] = "_PyProtocolWrapper.__setstate_cython__(self, __pyx_state)";
static PyMethodDef __pyx_mdef_4lupa_5_lupa_18_PyProtocolWrapper_7__setstate_cython__ = {"__setstate_cython__", (PyCFunction)__pyx_pw_4lupa_5_lupa_18_PyProtocolWrapper_7__setstate_cython__, METH_O, __pyx_doc_4lupa_5_lupa_18_PyProtocolWrapper_6__setstate_cython__};
static PyObject *__pyx_pw_4lupa_5_lupa_18_PyProtocolWrapper_7__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_4lupa_5_lupa_18_PyProtocolWrapper_6__setstate_cython__(((struct __pyx_obj_4lupa_5_lupa__PyProtocolWrapper *)__pyx_v_self), ((PyObject *)__pyx_v___pyx_state));

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

static PyObject *__pyx_pf_4lupa_5_lupa_18_PyProtocolWrapper_6__setstate_cython__(CYTHON_UNUSED struct __pyx_obj_4lupa_5_lupa__PyProtocolWrapper *__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__33, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 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(2, 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("lupa._lupa._PyProtocolWrapper.__setstate_cython__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lupa/_lupa.pyx":1110
 * 
 * 
 * def as_attrgetter(obj):             # <<<<<<<<<<<<<<
 *     cdef _PyProtocolWrapper wrap = _PyProtocolWrapper.__new__(_PyProtocolWrapper)
 *     wrap._obj = obj
 */

/* Python wrapper */
static PyObject *__pyx_pw_4lupa_5_lupa_7as_attrgetter(PyObject *__pyx_self, PyObject *__pyx_v_obj); /*proto*/
static char __pyx_doc_4lupa_5_lupa_6as_attrgetter[] = "as_attrgetter(obj)";
static PyMethodDef __pyx_mdef_4lupa_5_lupa_7as_attrgetter = {"as_attrgetter", (PyCFunction)__pyx_pw_4lupa_5_lupa_7as_attrgetter, METH_O, __pyx_doc_4lupa_5_lupa_6as_attrgetter};
static PyObject *__pyx_pw_4lupa_5_lupa_7as_attrgetter(PyObject *__pyx_self, PyObject *__pyx_v_obj) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("as_attrgetter (wrapper)", 0);
  __pyx_r = __pyx_pf_4lupa_5_lupa_6as_attrgetter(__pyx_self, ((PyObject *)__pyx_v_obj));

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

static PyObject *__pyx_pf_4lupa_5_lupa_6as_attrgetter(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_obj) {
  struct __pyx_obj_4lupa_5_lupa__PyProtocolWrapper *__pyx_v_wrap = 0;
  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("as_attrgetter", 0);

  /* "lupa/_lupa.pyx":1111
 * 
 * def as_attrgetter(obj):
 *     cdef _PyProtocolWrapper wrap = _PyProtocolWrapper.__new__(_PyProtocolWrapper)             # <<<<<<<<<<<<<<
 *     wrap._obj = obj
 *     wrap._type_flags = 0
 */
  __pyx_t_1 = ((PyObject *)__pyx_tp_new_4lupa_5_lupa__PyProtocolWrapper(((PyTypeObject *)__pyx_ptype_4lupa_5_lupa__PyProtocolWrapper), __pyx_empty_tuple, NULL)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1111, __pyx_L1_error)
  __Pyx_GOTREF(((PyObject *)__pyx_t_1));
  __pyx_v_wrap = ((struct __pyx_obj_4lupa_5_lupa__PyProtocolWrapper *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "lupa/_lupa.pyx":1112
 * def as_attrgetter(obj):
 *     cdef _PyProtocolWrapper wrap = _PyProtocolWrapper.__new__(_PyProtocolWrapper)
 *     wrap._obj = obj             # <<<<<<<<<<<<<<
 *     wrap._type_flags = 0
 *     return wrap
 */
  __Pyx_INCREF(__pyx_v_obj);
  __Pyx_GIVEREF(__pyx_v_obj);
  __Pyx_GOTREF(__pyx_v_wrap->_obj);
  __Pyx_DECREF(__pyx_v_wrap->_obj);
  __pyx_v_wrap->_obj = __pyx_v_obj;

  /* "lupa/_lupa.pyx":1113
 *     cdef _PyProtocolWrapper wrap = _PyProtocolWrapper.__new__(_PyProtocolWrapper)
 *     wrap._obj = obj
 *     wrap._type_flags = 0             # <<<<<<<<<<<<<<
 *     return wrap
 * 
 */
  __pyx_v_wrap->_type_flags = 0;

  /* "lupa/_lupa.pyx":1114
 *     wrap._obj = obj
 *     wrap._type_flags = 0
 *     return wrap             # <<<<<<<<<<<<<<
 * 
 * def as_itemgetter(obj):
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(((PyObject *)__pyx_v_wrap));
  __pyx_r = ((PyObject *)__pyx_v_wrap);
  goto __pyx_L0;

  /* "lupa/_lupa.pyx":1110
 * 
 * 
 * def as_attrgetter(obj):             # <<<<<<<<<<<<<<
 *     cdef _PyProtocolWrapper wrap = _PyProtocolWrapper.__new__(_PyProtocolWrapper)
 *     wrap._obj = obj
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("lupa._lupa.as_attrgetter", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_wrap);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lupa/_lupa.pyx":1116
 *     return wrap
 * 
 * def as_itemgetter(obj):             # <<<<<<<<<<<<<<
 *     cdef _PyProtocolWrapper wrap = _PyProtocolWrapper.__new__(_PyProtocolWrapper)
 *     wrap._obj = obj
 */

/* Python wrapper */
static PyObject *__pyx_pw_4lupa_5_lupa_9as_itemgetter(PyObject *__pyx_self, PyObject *__pyx_v_obj); /*proto*/
static char __pyx_doc_4lupa_5_lupa_8as_itemgetter[] = "as_itemgetter(obj)";
static PyMethodDef __pyx_mdef_4lupa_5_lupa_9as_itemgetter = {"as_itemgetter", (PyCFunction)__pyx_pw_4lupa_5_lupa_9as_itemgetter, METH_O, __pyx_doc_4lupa_5_lupa_8as_itemgetter};
static PyObject *__pyx_pw_4lupa_5_lupa_9as_itemgetter(PyObject *__pyx_self, PyObject *__pyx_v_obj) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("as_itemgetter (wrapper)", 0);
  __pyx_r = __pyx_pf_4lupa_5_lupa_8as_itemgetter(__pyx_self, ((PyObject *)__pyx_v_obj));

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

static PyObject *__pyx_pf_4lupa_5_lupa_8as_itemgetter(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_obj) {
  struct __pyx_obj_4lupa_5_lupa__PyProtocolWrapper *__pyx_v_wrap = 0;
  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("as_itemgetter", 0);

  /* "lupa/_lupa.pyx":1117
 * 
 * def as_itemgetter(obj):
 *     cdef _PyProtocolWrapper wrap = _PyProtocolWrapper.__new__(_PyProtocolWrapper)             # <<<<<<<<<<<<<<
 *     wrap._obj = obj
 *     wrap._type_flags = OBJ_AS_INDEX
 */
  __pyx_t_1 = ((PyObject *)__pyx_tp_new_4lupa_5_lupa__PyProtocolWrapper(((PyTypeObject *)__pyx_ptype_4lupa_5_lupa__PyProtocolWrapper), __pyx_empty_tuple, NULL)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1117, __pyx_L1_error)
  __Pyx_GOTREF(((PyObject *)__pyx_t_1));
  __pyx_v_wrap = ((struct __pyx_obj_4lupa_5_lupa__PyProtocolWrapper *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "lupa/_lupa.pyx":1118
 * def as_itemgetter(obj):
 *     cdef _PyProtocolWrapper wrap = _PyProtocolWrapper.__new__(_PyProtocolWrapper)
 *     wrap._obj = obj             # <<<<<<<<<<<<<<
 *     wrap._type_flags = OBJ_AS_INDEX
 *     return wrap
 */
  __Pyx_INCREF(__pyx_v_obj);
  __Pyx_GIVEREF(__pyx_v_obj);
  __Pyx_GOTREF(__pyx_v_wrap->_obj);
  __Pyx_DECREF(__pyx_v_wrap->_obj);
  __pyx_v_wrap->_obj = __pyx_v_obj;

  /* "lupa/_lupa.pyx":1119
 *     cdef _PyProtocolWrapper wrap = _PyProtocolWrapper.__new__(_PyProtocolWrapper)
 *     wrap._obj = obj
 *     wrap._type_flags = OBJ_AS_INDEX             # <<<<<<<<<<<<<<
 *     return wrap
 * 
 */
  __pyx_v_wrap->_type_flags = __pyx_e_4lupa_5_lupa_OBJ_AS_INDEX;

  /* "lupa/_lupa.pyx":1120
 *     wrap._obj = obj
 *     wrap._type_flags = OBJ_AS_INDEX
 *     return wrap             # <<<<<<<<<<<<<<
 * 
 * cdef object py_from_lua(LuaRuntime runtime, lua_State *L, int n):
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(((PyObject *)__pyx_v_wrap));
  __pyx_r = ((PyObject *)__pyx_v_wrap);
  goto __pyx_L0;

  /* "lupa/_lupa.pyx":1116
 *     return wrap
 * 
 * def as_itemgetter(obj):             # <<<<<<<<<<<<<<
 *     cdef _PyProtocolWrapper wrap = _PyProtocolWrapper.__new__(_PyProtocolWrapper)
 *     wrap._obj = obj
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("lupa._lupa.as_itemgetter", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_wrap);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lupa/_lupa.pyx":1122
 *     return wrap
 * 
 * cdef object py_from_lua(LuaRuntime runtime, lua_State *L, int n):             # <<<<<<<<<<<<<<
 *     """
 *     Convert a Lua object to a Python object by either mapping, wrapping
 */

static PyObject *__pyx_f_4lupa_5_lupa_py_from_lua(struct __pyx_obj_4lupa_5_lupa_LuaRuntime *__pyx_v_runtime, lua_State *__pyx_v_L, int __pyx_v_n) {
  size_t __pyx_v_size;
  char const *__pyx_v_s;
  lua_Number __pyx_v_number;
  struct __pyx_t_4lupa_5_lupa_py_object *__pyx_v_py_obj;
  int __pyx_v_lua_type;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  int __pyx_t_3;
  char const *__pyx_t_4;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("py_from_lua", 0);

  /* "lupa/_lupa.pyx":1127
 *     or unwrapping it.
 *     """
 *     cdef size_t size = 0             # <<<<<<<<<<<<<<
 *     cdef const char *s
 *     cdef lua.lua_Number number
 */
  __pyx_v_size = 0;

  /* "lupa/_lupa.pyx":1131
 *     cdef lua.lua_Number number
 *     cdef py_object* py_obj
 *     cdef int lua_type = lua.lua_type(L, n)             # <<<<<<<<<<<<<<
 * 
 *     if lua_type == lua.LUA_TNIL:
 */
  __pyx_v_lua_type = lua_type(__pyx_v_L, __pyx_v_n);

  /* "lupa/_lupa.pyx":1133
 *     cdef int lua_type = lua.lua_type(L, n)
 * 
 *     if lua_type == lua.LUA_TNIL:             # <<<<<<<<<<<<<<
 *         return None
 *     elif lua_type == lua.LUA_TNUMBER:
 */
  switch (__pyx_v_lua_type) {
    case LUA_TNIL:

    /* "lupa/_lupa.pyx":1134
 * 
 *     if lua_type == lua.LUA_TNIL:
 *         return None             # <<<<<<<<<<<<<<
 *     elif lua_type == lua.LUA_TNUMBER:
 *         number = lua.lua_tonumber(L, n)
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_r = Py_None; __Pyx_INCREF(Py_None);
    goto __pyx_L0;

    /* "lupa/_lupa.pyx":1133
 *     cdef int lua_type = lua.lua_type(L, n)
 * 
 *     if lua_type == lua.LUA_TNIL:             # <<<<<<<<<<<<<<
 *         return None
 *     elif lua_type == lua.LUA_TNUMBER:
 */
    break;
    case LUA_TNUMBER:

    /* "lupa/_lupa.pyx":1136
 *         return None
 *     elif lua_type == lua.LUA_TNUMBER:
 *         number = lua.lua_tonumber(L, n)             # <<<<<<<<<<<<<<
 *         if number != <long>number:
 *             return <double>number
 */
    __pyx_v_number = lua_tonumber(__pyx_v_L, __pyx_v_n);

    /* "lupa/_lupa.pyx":1137
 *     elif lua_type == lua.LUA_TNUMBER:
 *         number = lua.lua_tonumber(L, n)
 *         if number != <long>number:             # <<<<<<<<<<<<<<
 *             return <double>number
 *         else:
 */
    __pyx_t_1 = ((__pyx_v_number != ((long)__pyx_v_number)) != 0);
    if (__pyx_t_1) {

      /* "lupa/_lupa.pyx":1138
 *         number = lua.lua_tonumber(L, n)
 *         if number != <long>number:
 *             return <double>number             # <<<<<<<<<<<<<<
 *         else:
 *             return <long>number
 */
      __Pyx_XDECREF(__pyx_r);
      __pyx_t_2 = PyFloat_FromDouble(((double)__pyx_v_number)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1138, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_r = __pyx_t_2;
      __pyx_t_2 = 0;
      goto __pyx_L0;

      /* "lupa/_lupa.pyx":1137
 *     elif lua_type == lua.LUA_TNUMBER:
 *         number = lua.lua_tonumber(L, n)
 *         if number != <long>number:             # <<<<<<<<<<<<<<
 *             return <double>number
 *         else:
 */
    }

    /* "lupa/_lupa.pyx":1140
 *             return <double>number
 *         else:
 *             return <long>number             # <<<<<<<<<<<<<<
 *     elif lua_type == lua.LUA_TSTRING:
 *         s = lua.lua_tolstring(L, n, &size)
 */
    /*else*/ {
      __Pyx_XDECREF(__pyx_r);
      __pyx_t_2 = __Pyx_PyInt_From_long(((long)__pyx_v_number)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1140, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_r = __pyx_t_2;
      __pyx_t_2 = 0;
      goto __pyx_L0;
    }

    /* "lupa/_lupa.pyx":1135
 *     if lua_type == lua.LUA_TNIL:
 *         return None
 *     elif lua_type == lua.LUA_TNUMBER:             # <<<<<<<<<<<<<<
 *         number = lua.lua_tonumber(L, n)
 *         if number != <long>number:
 */
    break;
    case LUA_TSTRING:

    /* "lupa/_lupa.pyx":1142
 *             return <long>number
 *     elif lua_type == lua.LUA_TSTRING:
 *         s = lua.lua_tolstring(L, n, &size)             # <<<<<<<<<<<<<<
 *         if runtime._encoding is not None:
 *             return s[:size].decode(runtime._encoding)
 */
    __pyx_v_s = lua_tolstring(__pyx_v_L, __pyx_v_n, (&__pyx_v_size));

    /* "lupa/_lupa.pyx":1143
 *     elif lua_type == lua.LUA_TSTRING:
 *         s = lua.lua_tolstring(L, n, &size)
 *         if runtime._encoding is not None:             # <<<<<<<<<<<<<<
 *             return s[:size].decode(runtime._encoding)
 *         else:
 */
    __pyx_t_1 = (__pyx_v_runtime->_encoding != ((PyObject*)Py_None));
    __pyx_t_3 = (__pyx_t_1 != 0);
    if (__pyx_t_3) {

      /* "lupa/_lupa.pyx":1144
 *         s = lua.lua_tolstring(L, n, &size)
 *         if runtime._encoding is not None:
 *             return s[:size].decode(runtime._encoding)             # <<<<<<<<<<<<<<
 *         else:
 *             return s[:size]
 */
      __Pyx_XDECREF(__pyx_r);
      if (unlikely(__pyx_v_runtime->_encoding == Py_None)) {
        PyErr_SetString(PyExc_TypeError, "expected bytes, NoneType found");
        __PYX_ERR(0, 1144, __pyx_L1_error)
      }
      __pyx_t_4 = __Pyx_PyBytes_AsString(__pyx_v_runtime->_encoding); if (unlikely((!__pyx_t_4) && PyErr_Occurred())) __PYX_ERR(0, 1144, __pyx_L1_error)
      __pyx_t_2 = __Pyx_decode_c_string(__pyx_v_s, 0, __pyx_v_size, __pyx_t_4, NULL, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1144, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_r = __pyx_t_2;
      __pyx_t_2 = 0;
      goto __pyx_L0;

      /* "lupa/_lupa.pyx":1143
 *     elif lua_type == lua.LUA_TSTRING:
 *         s = lua.lua_tolstring(L, n, &size)
 *         if runtime._encoding is not None:             # <<<<<<<<<<<<<<
 *             return s[:size].decode(runtime._encoding)
 *         else:
 */
    }

    /* "lupa/_lupa.pyx":1146
 *             return s[:size].decode(runtime._encoding)
 *         else:
 *             return s[:size]             # <<<<<<<<<<<<<<
 *     elif lua_type == lua.LUA_TBOOLEAN:
 *         return lua.lua_toboolean(L, n)
 */
    /*else*/ {
      __Pyx_XDECREF(__pyx_r);
      __pyx_t_2 = __Pyx_PyBytes_FromStringAndSize(__pyx_v_s + 0, __pyx_v_size - 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1146, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_r = __pyx_t_2;
      __pyx_t_2 = 0;
      goto __pyx_L0;
    }

    /* "lupa/_lupa.pyx":1141
 *         else:
 *             return <long>number
 *     elif lua_type == lua.LUA_TSTRING:             # <<<<<<<<<<<<<<
 *         s = lua.lua_tolstring(L, n, &size)
 *         if runtime._encoding is not None:
 */
    break;
    case LUA_TBOOLEAN:

    /* "lupa/_lupa.pyx":1148
 *             return s[:size]
 *     elif lua_type == lua.LUA_TBOOLEAN:
 *         return lua.lua_toboolean(L, n)             # <<<<<<<<<<<<<<
 *     elif lua_type == lua.LUA_TUSERDATA:
 *         py_obj = unpack_userdata(L, n)
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_2 = __Pyx_PyBool_FromLong(lua_toboolean(__pyx_v_L, __pyx_v_n)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1148, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_r = __pyx_t_2;
    __pyx_t_2 = 0;
    goto __pyx_L0;

    /* "lupa/_lupa.pyx":1147
 *         else:
 *             return s[:size]
 *     elif lua_type == lua.LUA_TBOOLEAN:             # <<<<<<<<<<<<<<
 *         return lua.lua_toboolean(L, n)
 *     elif lua_type == lua.LUA_TUSERDATA:
 */
    break;
    case LUA_TUSERDATA:

    /* "lupa/_lupa.pyx":1150
 *         return lua.lua_toboolean(L, n)
 *     elif lua_type == lua.LUA_TUSERDATA:
 *         py_obj = unpack_userdata(L, n)             # <<<<<<<<<<<<<<
 *         if py_obj:
 *             return <object>py_obj.obj
 */
    __pyx_v_py_obj = __pyx_f_4lupa_5_lupa_unpack_userdata(__pyx_v_L, __pyx_v_n);

    /* "lupa/_lupa.pyx":1151
 *     elif lua_type == lua.LUA_TUSERDATA:
 *         py_obj = unpack_userdata(L, n)
 *         if py_obj:             # <<<<<<<<<<<<<<
 *             return <object>py_obj.obj
 *     elif lua_type == lua.LUA_TTABLE:
 */
    __pyx_t_3 = (__pyx_v_py_obj != 0);
    if (__pyx_t_3) {

      /* "lupa/_lupa.pyx":1152
 *         py_obj = unpack_userdata(L, n)
 *         if py_obj:
 *             return <object>py_obj.obj             # <<<<<<<<<<<<<<
 *     elif lua_type == lua.LUA_TTABLE:
 *         return new_lua_table(runtime, L, n)
 */
      __Pyx_XDECREF(__pyx_r);
      __Pyx_INCREF(((PyObject *)__pyx_v_py_obj->obj));
      __pyx_r = ((PyObject *)__pyx_v_py_obj->obj);
      goto __pyx_L0;

      /* "lupa/_lupa.pyx":1151
 *     elif lua_type == lua.LUA_TUSERDATA:
 *         py_obj = unpack_userdata(L, n)
 *         if py_obj:             # <<<<<<<<<<<<<<
 *             return <object>py_obj.obj
 *     elif lua_type == lua.LUA_TTABLE:
 */
    }

    /* "lupa/_lupa.pyx":1149
 *     elif lua_type == lua.LUA_TBOOLEAN:
 *         return lua.lua_toboolean(L, n)
 *     elif lua_type == lua.LUA_TUSERDATA:             # <<<<<<<<<<<<<<
 *         py_obj = unpack_userdata(L, n)
 *         if py_obj:
 */
    break;
    case LUA_TTABLE:

    /* "lupa/_lupa.pyx":1154
 *             return <object>py_obj.obj
 *     elif lua_type == lua.LUA_TTABLE:
 *         return new_lua_table(runtime, L, n)             # <<<<<<<<<<<<<<
 *     elif lua_type == lua.LUA_TTHREAD:
 *         return new_lua_thread_or_function(runtime, L, n)
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_2 = ((PyObject *)__pyx_f_4lupa_5_lupa_new_lua_table(__pyx_v_runtime, __pyx_v_L, __pyx_v_n)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1154, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_r = __pyx_t_2;
    __pyx_t_2 = 0;
    goto __pyx_L0;

    /* "lupa/_lupa.pyx":1153
 *         if py_obj:
 *             return <object>py_obj.obj
 *     elif lua_type == lua.LUA_TTABLE:             # <<<<<<<<<<<<<<
 *         return new_lua_table(runtime, L, n)
 *     elif lua_type == lua.LUA_TTHREAD:
 */
    break;
    case LUA_TTHREAD:

    /* "lupa/_lupa.pyx":1156
 *         return new_lua_table(runtime, L, n)
 *     elif lua_type == lua.LUA_TTHREAD:
 *         return new_lua_thread_or_function(runtime, L, n)             # <<<<<<<<<<<<<<
 *     elif lua_type == lua.LUA_TFUNCTION:
 *         py_obj = unpack_wrapped_pyfunction(L, n)
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_2 = ((PyObject *)__pyx_f_4lupa_5_lupa_new_lua_thread_or_function(__pyx_v_runtime, __pyx_v_L, __pyx_v_n)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1156, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_r = __pyx_t_2;
    __pyx_t_2 = 0;
    goto __pyx_L0;

    /* "lupa/_lupa.pyx":1155
 *     elif lua_type == lua.LUA_TTABLE:
 *         return new_lua_table(runtime, L, n)
 *     elif lua_type == lua.LUA_TTHREAD:             # <<<<<<<<<<<<<<
 *         return new_lua_thread_or_function(runtime, L, n)
 *     elif lua_type == lua.LUA_TFUNCTION:
 */
    break;
    case LUA_TFUNCTION:

    /* "lupa/_lupa.pyx":1158
 *         return new_lua_thread_or_function(runtime, L, n)
 *     elif lua_type == lua.LUA_TFUNCTION:
 *         py_obj = unpack_wrapped_pyfunction(L, n)             # <<<<<<<<<<<<<<
 *         if py_obj:
 *             return <object>py_obj.obj
 */
    __pyx_v_py_obj = __pyx_f_4lupa_5_lupa_unpack_wrapped_pyfunction(__pyx_v_L, __pyx_v_n);

    /* "lupa/_lupa.pyx":1159
 *     elif lua_type == lua.LUA_TFUNCTION:
 *         py_obj = unpack_wrapped_pyfunction(L, n)
 *         if py_obj:             # <<<<<<<<<<<<<<
 *             return <object>py_obj.obj
 *         return new_lua_function(runtime, L, n)
 */
    __pyx_t_3 = (__pyx_v_py_obj != 0);
    if (__pyx_t_3) {

      /* "lupa/_lupa.pyx":1160
 *         py_obj = unpack_wrapped_pyfunction(L, n)
 *         if py_obj:
 *             return <object>py_obj.obj             # <<<<<<<<<<<<<<
 *         return new_lua_function(runtime, L, n)
 *     return new_lua_object(runtime, L, n)
 */
      __Pyx_XDECREF(__pyx_r);
      __Pyx_INCREF(((PyObject *)__pyx_v_py_obj->obj));
      __pyx_r = ((PyObject *)__pyx_v_py_obj->obj);
      goto __pyx_L0;

      /* "lupa/_lupa.pyx":1159
 *     elif lua_type == lua.LUA_TFUNCTION:
 *         py_obj = unpack_wrapped_pyfunction(L, n)
 *         if py_obj:             # <<<<<<<<<<<<<<
 *             return <object>py_obj.obj
 *         return new_lua_function(runtime, L, n)
 */
    }

    /* "lupa/_lupa.pyx":1161
 *         if py_obj:
 *             return <object>py_obj.obj
 *         return new_lua_function(runtime, L, n)             # <<<<<<<<<<<<<<
 *     return new_lua_object(runtime, L, n)
 * 
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_2 = ((PyObject *)__pyx_f_4lupa_5_lupa_new_lua_function(__pyx_v_runtime, __pyx_v_L, __pyx_v_n)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1161, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_r = __pyx_t_2;
    __pyx_t_2 = 0;
    goto __pyx_L0;

    /* "lupa/_lupa.pyx":1157
 *     elif lua_type == lua.LUA_TTHREAD:
 *         return new_lua_thread_or_function(runtime, L, n)
 *     elif lua_type == lua.LUA_TFUNCTION:             # <<<<<<<<<<<<<<
 *         py_obj = unpack_wrapped_pyfunction(L, n)
 *         if py_obj:
 */
    break;
    default: break;
  }

  /* "lupa/_lupa.pyx":1162
 *             return <object>py_obj.obj
 *         return new_lua_function(runtime, L, n)
 *     return new_lua_object(runtime, L, n)             # <<<<<<<<<<<<<<
 * 
 * cdef py_object* unpack_userdata(lua_State *L, int n) nogil:
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2 = ((PyObject *)__pyx_f_4lupa_5_lupa_new_lua_object(__pyx_v_runtime, __pyx_v_L, __pyx_v_n)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1162, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_r = __pyx_t_2;
  __pyx_t_2 = 0;
  goto __pyx_L0;

  /* "lupa/_lupa.pyx":1122
 *     return wrap
 * 
 * cdef object py_from_lua(LuaRuntime runtime, lua_State *L, int n):             # <<<<<<<<<<<<<<
 *     """
 *     Convert a Lua object to a Python object by either mapping, wrapping
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_AddTraceback("lupa._lupa.py_from_lua", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lupa/_lupa.pyx":1164
 *     return new_lua_object(runtime, L, n)
 * 
 * cdef py_object* unpack_userdata(lua_State *L, int n) nogil:             # <<<<<<<<<<<<<<
 *     """
 *     Like luaL_checkudata(), unpacks a userdata object and validates that
 */

static struct __pyx_t_4lupa_5_lupa_py_object *__pyx_f_4lupa_5_lupa_unpack_userdata(lua_State *__pyx_v_L, int __pyx_v_n) {
  void *__pyx_v_p;
  struct __pyx_t_4lupa_5_lupa_py_object *__pyx_r;
  int __pyx_t_1;
  int __pyx_t_2;

  /* "lupa/_lupa.pyx":1169
 *     it's a wrapped Python object.  Returns NULL on failure.
 *     """
 *     p = lua.lua_touserdata(L, n)             # <<<<<<<<<<<<<<
 *     if p and lua.lua_getmetatable(L, n):
 *         # found userdata with metatable - the one we expect?
 */
  __pyx_v_p = lua_touserdata(__pyx_v_L, __pyx_v_n);

  /* "lupa/_lupa.pyx":1170
 *     """
 *     p = lua.lua_touserdata(L, n)
 *     if p and lua.lua_getmetatable(L, n):             # <<<<<<<<<<<<<<
 *         # found userdata with metatable - the one we expect?
 *         lua.luaL_getmetatable(L, POBJECT)
 */
  __pyx_t_2 = (__pyx_v_p != 0);
  if (__pyx_t_2) {
  } else {
    __pyx_t_1 = __pyx_t_2;
    goto __pyx_L4_bool_binop_done;
  }
  __pyx_t_2 = (lua_getmetatable(__pyx_v_L, __pyx_v_n) != 0);
  __pyx_t_1 = __pyx_t_2;
  __pyx_L4_bool_binop_done:;
  if (__pyx_t_1) {

    /* "lupa/_lupa.pyx":1172
 *     if p and lua.lua_getmetatable(L, n):
 *         # found userdata with metatable - the one we expect?
 *         lua.luaL_getmetatable(L, POBJECT)             # <<<<<<<<<<<<<<
 *         if lua.lua_rawequal(L, -1, -2):
 *             lua.lua_pop(L, 2)
 */
    luaL_getmetatable(__pyx_v_L, ((char *)"POBJECT"));

    /* "lupa/_lupa.pyx":1173
 *         # found userdata with metatable - the one we expect?
 *         lua.luaL_getmetatable(L, POBJECT)
 *         if lua.lua_rawequal(L, -1, -2):             # <<<<<<<<<<<<<<
 *             lua.lua_pop(L, 2)
 *             return <py_object*>p
 */
    __pyx_t_1 = (lua_rawequal(__pyx_v_L, -1, -2) != 0);
    if (__pyx_t_1) {

      /* "lupa/_lupa.pyx":1174
 *         lua.luaL_getmetatable(L, POBJECT)
 *         if lua.lua_rawequal(L, -1, -2):
 *             lua.lua_pop(L, 2)             # <<<<<<<<<<<<<<
 *             return <py_object*>p
 *         lua.lua_pop(L, 2)
 */
      lua_pop(__pyx_v_L, 2);

      /* "lupa/_lupa.pyx":1175
 *         if lua.lua_rawequal(L, -1, -2):
 *             lua.lua_pop(L, 2)
 *             return <py_object*>p             # <<<<<<<<<<<<<<
 *         lua.lua_pop(L, 2)
 *     return NULL
 */
      __pyx_r = ((struct __pyx_t_4lupa_5_lupa_py_object *)__pyx_v_p);
      goto __pyx_L0;

      /* "lupa/_lupa.pyx":1173
 *         # found userdata with metatable - the one we expect?
 *         lua.luaL_getmetatable(L, POBJECT)
 *         if lua.lua_rawequal(L, -1, -2):             # <<<<<<<<<<<<<<
 *             lua.lua_pop(L, 2)
 *             return <py_object*>p
 */
    }

    /* "lupa/_lupa.pyx":1176
 *             lua.lua_pop(L, 2)
 *             return <py_object*>p
 *         lua.lua_pop(L, 2)             # <<<<<<<<<<<<<<
 *     return NULL
 * 
 */
    lua_pop(__pyx_v_L, 2);

    /* "lupa/_lupa.pyx":1170
 *     """
 *     p = lua.lua_touserdata(L, n)
 *     if p and lua.lua_getmetatable(L, n):             # <<<<<<<<<<<<<<
 *         # found userdata with metatable - the one we expect?
 *         lua.luaL_getmetatable(L, POBJECT)
 */
  }

  /* "lupa/_lupa.pyx":1177
 *             return <py_object*>p
 *         lua.lua_pop(L, 2)
 *     return NULL             # <<<<<<<<<<<<<<
 * 
 * cdef int py_function_result_to_lua(LuaRuntime runtime, lua_State *L, object o) except -1:
 */
  __pyx_r = NULL;
  goto __pyx_L0;

  /* "lupa/_lupa.pyx":1164
 *     return new_lua_object(runtime, L, n)
 * 
 * cdef py_object* unpack_userdata(lua_State *L, int n) nogil:             # <<<<<<<<<<<<<<
 *     """
 *     Like luaL_checkudata(), unpacks a userdata object and validates that
 */

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

/* "lupa/_lupa.pyx":1179
 *     return NULL
 * 
 * cdef int py_function_result_to_lua(LuaRuntime runtime, lua_State *L, object o) except -1:             # <<<<<<<<<<<<<<
 *      if runtime._unpack_returned_tuples and isinstance(o, tuple):
 *          push_lua_arguments(runtime, L, <tuple>o)
 */

static int __pyx_f_4lupa_5_lupa_py_function_result_to_lua(struct __pyx_obj_4lupa_5_lupa_LuaRuntime *__pyx_v_runtime, lua_State *__pyx_v_L, PyObject *__pyx_v_o) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  int __pyx_t_2;
  int __pyx_t_3;
  int __pyx_t_4;
  Py_ssize_t __pyx_t_5;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("py_function_result_to_lua", 0);

  /* "lupa/_lupa.pyx":1180
 * 
 * cdef int py_function_result_to_lua(LuaRuntime runtime, lua_State *L, object o) except -1:
 *      if runtime._unpack_returned_tuples and isinstance(o, tuple):             # <<<<<<<<<<<<<<
 *          push_lua_arguments(runtime, L, <tuple>o)
 *          return len(<tuple>o)
 */
  __pyx_t_2 = (__pyx_v_runtime->_unpack_returned_tuples != 0);
  if (__pyx_t_2) {
  } else {
    __pyx_t_1 = __pyx_t_2;
    goto __pyx_L4_bool_binop_done;
  }
  __pyx_t_2 = PyTuple_Check(__pyx_v_o); 
  __pyx_t_3 = (__pyx_t_2 != 0);
  __pyx_t_1 = __pyx_t_3;
  __pyx_L4_bool_binop_done:;
  if (__pyx_t_1) {

    /* "lupa/_lupa.pyx":1181
 * cdef int py_function_result_to_lua(LuaRuntime runtime, lua_State *L, object o) except -1:
 *      if runtime._unpack_returned_tuples and isinstance(o, tuple):
 *          push_lua_arguments(runtime, L, <tuple>o)             # <<<<<<<<<<<<<<
 *          return len(<tuple>o)
 *      return py_to_lua(runtime, L, o)
 */
    __pyx_t_4 = __pyx_f_4lupa_5_lupa_push_lua_arguments(__pyx_v_runtime, __pyx_v_L, ((PyObject*)__pyx_v_o), NULL); if (unlikely(__pyx_t_4 == ((int)-1))) __PYX_ERR(0, 1181, __pyx_L1_error)

    /* "lupa/_lupa.pyx":1182
 *      if runtime._unpack_returned_tuples and isinstance(o, tuple):
 *          push_lua_arguments(runtime, L, <tuple>o)
 *          return len(<tuple>o)             # <<<<<<<<<<<<<<
 *      return py_to_lua(runtime, L, o)
 * 
 */
    if (unlikely(__pyx_v_o == Py_None)) {
      PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()");
      __PYX_ERR(0, 1182, __pyx_L1_error)
    }
    __pyx_t_5 = PyTuple_GET_SIZE(((PyObject*)__pyx_v_o)); if (unlikely(__pyx_t_5 == ((Py_ssize_t)-1))) __PYX_ERR(0, 1182, __pyx_L1_error)
    __pyx_r = __pyx_t_5;
    goto __pyx_L0;

    /* "lupa/_lupa.pyx":1180
 * 
 * cdef int py_function_result_to_lua(LuaRuntime runtime, lua_State *L, object o) except -1:
 *      if runtime._unpack_returned_tuples and isinstance(o, tuple):             # <<<<<<<<<<<<<<
 *          push_lua_arguments(runtime, L, <tuple>o)
 *          return len(<tuple>o)
 */
  }

  /* "lupa/_lupa.pyx":1183
 *          push_lua_arguments(runtime, L, <tuple>o)
 *          return len(<tuple>o)
 *      return py_to_lua(runtime, L, o)             # <<<<<<<<<<<<<<
 * 
 * cdef int py_to_lua(LuaRuntime runtime, lua_State *L, object o, bint wrap_none=False) except -1:
 */
  __pyx_t_4 = __pyx_f_4lupa_5_lupa_py_to_lua(__pyx_v_runtime, __pyx_v_L, __pyx_v_o, NULL); if (unlikely(__pyx_t_4 == ((int)-1))) __PYX_ERR(0, 1183, __pyx_L1_error)
  __pyx_r = __pyx_t_4;
  goto __pyx_L0;

  /* "lupa/_lupa.pyx":1179
 *     return NULL
 * 
 * cdef int py_function_result_to_lua(LuaRuntime runtime, lua_State *L, object o) except -1:             # <<<<<<<<<<<<<<
 *      if runtime._unpack_returned_tuples and isinstance(o, tuple):
 *          push_lua_arguments(runtime, L, <tuple>o)
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_AddTraceback("lupa._lupa.py_function_result_to_lua", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lupa/_lupa.pyx":1185
 *      return py_to_lua(runtime, L, o)
 * 
 * cdef int py_to_lua(LuaRuntime runtime, lua_State *L, object o, bint wrap_none=False) except -1:             # <<<<<<<<<<<<<<
 *     cdef int pushed_values_count = 0
 *     cdef int type_flags = 0
 */

static int __pyx_f_4lupa_5_lupa_py_to_lua(struct __pyx_obj_4lupa_5_lupa_LuaRuntime *__pyx_v_runtime, lua_State *__pyx_v_L, PyObject *__pyx_v_o, struct __pyx_opt_args_4lupa_5_lupa_py_to_lua *__pyx_optional_args) {
  int __pyx_v_wrap_none = ((int)0);
  int __pyx_v_pushed_values_count;
  int __pyx_v_type_flags;
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  int __pyx_t_2;
  int __pyx_t_3;
  double __pyx_t_4;
  long __pyx_t_5;
  char *__pyx_t_6;
  Py_ssize_t __pyx_t_7;
  int __pyx_t_8;
  PyObject *__pyx_t_9 = NULL;
  PyObject *__pyx_t_10 = NULL;
  PyObject *__pyx_t_11 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("py_to_lua", 0);
  if (__pyx_optional_args) {
    if (__pyx_optional_args->__pyx_n > 0) {
      __pyx_v_wrap_none = __pyx_optional_args->wrap_none;
    }
  }
  __Pyx_INCREF(__pyx_v_o);

  /* "lupa/_lupa.pyx":1186
 * 
 * cdef int py_to_lua(LuaRuntime runtime, lua_State *L, object o, bint wrap_none=False) except -1:
 *     cdef int pushed_values_count = 0             # <<<<<<<<<<<<<<
 *     cdef int type_flags = 0
 * 
 */
  __pyx_v_pushed_values_count = 0;

  /* "lupa/_lupa.pyx":1187
 * cdef int py_to_lua(LuaRuntime runtime, lua_State *L, object o, bint wrap_none=False) except -1:
 *     cdef int pushed_values_count = 0
 *     cdef int type_flags = 0             # <<<<<<<<<<<<<<
 * 
 *     if o is None:
 */
  __pyx_v_type_flags = 0;

  /* "lupa/_lupa.pyx":1189
 *     cdef int type_flags = 0
 * 
 *     if o is None:             # <<<<<<<<<<<<<<
 *         if wrap_none:
 *             lua.lua_pushlstring(L, "Py_None", 7)
 */
  __pyx_t_1 = (__pyx_v_o == Py_None);
  __pyx_t_2 = (__pyx_t_1 != 0);
  if (__pyx_t_2) {

    /* "lupa/_lupa.pyx":1190
 * 
 *     if o is None:
 *         if wrap_none:             # <<<<<<<<<<<<<<
 *             lua.lua_pushlstring(L, "Py_None", 7)
 *             lua.lua_rawget(L, lua.LUA_REGISTRYINDEX)
 */
    __pyx_t_2 = (__pyx_v_wrap_none != 0);
    if (__pyx_t_2) {

      /* "lupa/_lupa.pyx":1191
 *     if o is None:
 *         if wrap_none:
 *             lua.lua_pushlstring(L, "Py_None", 7)             # <<<<<<<<<<<<<<
 *             lua.lua_rawget(L, lua.LUA_REGISTRYINDEX)
 *             if lua.lua_isnil(L, -1):
 */
      lua_pushlstring(__pyx_v_L, ((char *)"Py_None"), 7);

      /* "lupa/_lupa.pyx":1192
 *         if wrap_none:
 *             lua.lua_pushlstring(L, "Py_None", 7)
 *             lua.lua_rawget(L, lua.LUA_REGISTRYINDEX)             # <<<<<<<<<<<<<<
 *             if lua.lua_isnil(L, -1):
 *                 lua.lua_pop(L, 1)
 */
      lua_rawget(__pyx_v_L, LUA_REGISTRYINDEX);

      /* "lupa/_lupa.pyx":1193
 *             lua.lua_pushlstring(L, "Py_None", 7)
 *             lua.lua_rawget(L, lua.LUA_REGISTRYINDEX)
 *             if lua.lua_isnil(L, -1):             # <<<<<<<<<<<<<<
 *                 lua.lua_pop(L, 1)
 *                 return 0
 */
      __pyx_t_2 = (lua_isnil(__pyx_v_L, -1) != 0);
      if (__pyx_t_2) {

        /* "lupa/_lupa.pyx":1194
 *             lua.lua_rawget(L, lua.LUA_REGISTRYINDEX)
 *             if lua.lua_isnil(L, -1):
 *                 lua.lua_pop(L, 1)             # <<<<<<<<<<<<<<
 *                 return 0
 *             pushed_values_count = 1
 */
        lua_pop(__pyx_v_L, 1);

        /* "lupa/_lupa.pyx":1195
 *             if lua.lua_isnil(L, -1):
 *                 lua.lua_pop(L, 1)
 *                 return 0             # <<<<<<<<<<<<<<
 *             pushed_values_count = 1
 *         else:
 */
        __pyx_r = 0;
        goto __pyx_L0;

        /* "lupa/_lupa.pyx":1193
 *             lua.lua_pushlstring(L, "Py_None", 7)
 *             lua.lua_rawget(L, lua.LUA_REGISTRYINDEX)
 *             if lua.lua_isnil(L, -1):             # <<<<<<<<<<<<<<
 *                 lua.lua_pop(L, 1)
 *                 return 0
 */
      }

      /* "lupa/_lupa.pyx":1196
 *                 lua.lua_pop(L, 1)
 *                 return 0
 *             pushed_values_count = 1             # <<<<<<<<<<<<<<
 *         else:
 *             # Not really needed, but this way we may check for errors
 */
      __pyx_v_pushed_values_count = 1;

      /* "lupa/_lupa.pyx":1190
 * 
 *     if o is None:
 *         if wrap_none:             # <<<<<<<<<<<<<<
 *             lua.lua_pushlstring(L, "Py_None", 7)
 *             lua.lua_rawget(L, lua.LUA_REGISTRYINDEX)
 */
      goto __pyx_L4;
    }

    /* "lupa/_lupa.pyx":1200
 *             # Not really needed, but this way we may check for errors
 *             # with pushed_values_count == 0.
 *             lua.lua_pushnil(L)             # <<<<<<<<<<<<<<
 *             pushed_values_count = 1
 *     elif o is True or o is False:
 */
    /*else*/ {
      lua_pushnil(__pyx_v_L);

      /* "lupa/_lupa.pyx":1201
 *             # with pushed_values_count == 0.
 *             lua.lua_pushnil(L)
 *             pushed_values_count = 1             # <<<<<<<<<<<<<<
 *     elif o is True or o is False:
 *         lua.lua_pushboolean(L, <bint>o)
 */
      __pyx_v_pushed_values_count = 1;
    }
    __pyx_L4:;

    /* "lupa/_lupa.pyx":1189
 *     cdef int type_flags = 0
 * 
 *     if o is None:             # <<<<<<<<<<<<<<
 *         if wrap_none:
 *             lua.lua_pushlstring(L, "Py_None", 7)
 */
    goto __pyx_L3;
  }

  /* "lupa/_lupa.pyx":1202
 *             lua.lua_pushnil(L)
 *             pushed_values_count = 1
 *     elif o is True or o is False:             # <<<<<<<<<<<<<<
 *         lua.lua_pushboolean(L, <bint>o)
 *         pushed_values_count = 1
 */
  __pyx_t_1 = (__pyx_v_o == Py_True);
  __pyx_t_3 = (__pyx_t_1 != 0);
  if (!__pyx_t_3) {
  } else {
    __pyx_t_2 = __pyx_t_3;
    goto __pyx_L6_bool_binop_done;
  }
  __pyx_t_3 = (__pyx_v_o == Py_False);
  __pyx_t_1 = (__pyx_t_3 != 0);
  __pyx_t_2 = __pyx_t_1;
  __pyx_L6_bool_binop_done:;
  if (__pyx_t_2) {

    /* "lupa/_lupa.pyx":1203
 *             pushed_values_count = 1
 *     elif o is True or o is False:
 *         lua.lua_pushboolean(L, <bint>o)             # <<<<<<<<<<<<<<
 *         pushed_values_count = 1
 *     elif type(o) is float:
 */
    __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_v_o); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(0, 1203, __pyx_L1_error)
    lua_pushboolean(__pyx_v_L, __pyx_t_2);

    /* "lupa/_lupa.pyx":1204
 *     elif o is True or o is False:
 *         lua.lua_pushboolean(L, <bint>o)
 *         pushed_values_count = 1             # <<<<<<<<<<<<<<
 *     elif type(o) is float:
 *         lua.lua_pushnumber(L, <lua.lua_Number>cpython.float.PyFloat_AS_DOUBLE(o))
 */
    __pyx_v_pushed_values_count = 1;

    /* "lupa/_lupa.pyx":1202
 *             lua.lua_pushnil(L)
 *             pushed_values_count = 1
 *     elif o is True or o is False:             # <<<<<<<<<<<<<<
 *         lua.lua_pushboolean(L, <bint>o)
 *         pushed_values_count = 1
 */
    goto __pyx_L3;
  }

  /* "lupa/_lupa.pyx":1205
 *         lua.lua_pushboolean(L, <bint>o)
 *         pushed_values_count = 1
 *     elif type(o) is float:             # <<<<<<<<<<<<<<
 *         lua.lua_pushnumber(L, <lua.lua_Number>cpython.float.PyFloat_AS_DOUBLE(o))
 *         pushed_values_count = 1
 */
  __pyx_t_2 = (((PyObject *)Py_TYPE(__pyx_v_o)) == ((PyObject *)(&PyFloat_Type)));
  __pyx_t_1 = (__pyx_t_2 != 0);
  if (__pyx_t_1) {

    /* "lupa/_lupa.pyx":1206
 *         pushed_values_count = 1
 *     elif type(o) is float:
 *         lua.lua_pushnumber(L, <lua.lua_Number>cpython.float.PyFloat_AS_DOUBLE(o))             # <<<<<<<<<<<<<<
 *         pushed_values_count = 1
 *     elif isinstance(o, long):
 */
    lua_pushnumber(__pyx_v_L, ((lua_Number)PyFloat_AS_DOUBLE(__pyx_v_o)));

    /* "lupa/_lupa.pyx":1207
 *     elif type(o) is float:
 *         lua.lua_pushnumber(L, <lua.lua_Number>cpython.float.PyFloat_AS_DOUBLE(o))
 *         pushed_values_count = 1             # <<<<<<<<<<<<<<
 *     elif isinstance(o, long):
 *         lua.lua_pushnumber(L, <lua.lua_Number>cpython.long.PyLong_AsDouble(o))
 */
    __pyx_v_pushed_values_count = 1;

    /* "lupa/_lupa.pyx":1205
 *         lua.lua_pushboolean(L, <bint>o)
 *         pushed_values_count = 1
 *     elif type(o) is float:             # <<<<<<<<<<<<<<
 *         lua.lua_pushnumber(L, <lua.lua_Number>cpython.float.PyFloat_AS_DOUBLE(o))
 *         pushed_values_count = 1
 */
    goto __pyx_L3;
  }

  /* "lupa/_lupa.pyx":1208
 *         lua.lua_pushnumber(L, <lua.lua_Number>cpython.float.PyFloat_AS_DOUBLE(o))
 *         pushed_values_count = 1
 *     elif isinstance(o, long):             # <<<<<<<<<<<<<<
 *         lua.lua_pushnumber(L, <lua.lua_Number>cpython.long.PyLong_AsDouble(o))
 *         pushed_values_count = 1
 */
  __pyx_t_1 = PyLong_Check(__pyx_v_o); 
  __pyx_t_2 = (__pyx_t_1 != 0);
  if (__pyx_t_2) {

    /* "lupa/_lupa.pyx":1209
 *         pushed_values_count = 1
 *     elif isinstance(o, long):
 *         lua.lua_pushnumber(L, <lua.lua_Number>cpython.long.PyLong_AsDouble(o))             # <<<<<<<<<<<<<<
 *         pushed_values_count = 1
 *     elif IS_PY2 and isinstance(o, int):
 */
    __pyx_t_4 = PyLong_AsDouble(__pyx_v_o); if (unlikely(__pyx_t_4 == ((double)(-1.0)) && PyErr_Occurred())) __PYX_ERR(0, 1209, __pyx_L1_error)
    lua_pushnumber(__pyx_v_L, ((lua_Number)__pyx_t_4));

    /* "lupa/_lupa.pyx":1210
 *     elif isinstance(o, long):
 *         lua.lua_pushnumber(L, <lua.lua_Number>cpython.long.PyLong_AsDouble(o))
 *         pushed_values_count = 1             # <<<<<<<<<<<<<<
 *     elif IS_PY2 and isinstance(o, int):
 *         lua.lua_pushnumber(L, <lua.lua_Number><long>o)
 */
    __pyx_v_pushed_values_count = 1;

    /* "lupa/_lupa.pyx":1208
 *         lua.lua_pushnumber(L, <lua.lua_Number>cpython.float.PyFloat_AS_DOUBLE(o))
 *         pushed_values_count = 1
 *     elif isinstance(o, long):             # <<<<<<<<<<<<<<
 *         lua.lua_pushnumber(L, <lua.lua_Number>cpython.long.PyLong_AsDouble(o))
 *         pushed_values_count = 1
 */
    goto __pyx_L3;
  }

  /* "lupa/_lupa.pyx":1211
 *         lua.lua_pushnumber(L, <lua.lua_Number>cpython.long.PyLong_AsDouble(o))
 *         pushed_values_count = 1
 *     elif IS_PY2 and isinstance(o, int):             # <<<<<<<<<<<<<<
 *         lua.lua_pushnumber(L, <lua.lua_Number><long>o)
 *         pushed_values_count = 1
 */
  __pyx_t_1 = (IS_PY2 != 0);
  if (__pyx_t_1) {
  } else {
    __pyx_t_2 = __pyx_t_1;
    goto __pyx_L8_bool_binop_done;
  }
  __pyx_t_1 = PyInt_Check(__pyx_v_o); 
  __pyx_t_3 = (__pyx_t_1 != 0);
  __pyx_t_2 = __pyx_t_3;
  __pyx_L8_bool_binop_done:;
  if (__pyx_t_2) {

    /* "lupa/_lupa.pyx":1212
 *         pushed_values_count = 1
 *     elif IS_PY2 and isinstance(o, int):
 *         lua.lua_pushnumber(L, <lua.lua_Number><long>o)             # <<<<<<<<<<<<<<
 *         pushed_values_count = 1
 *     elif isinstance(o, bytes):
 */
    __pyx_t_5 = __Pyx_PyInt_As_long(__pyx_v_o); if (unlikely((__pyx_t_5 == (long)-1) && PyErr_Occurred())) __PYX_ERR(0, 1212, __pyx_L1_error)
    lua_pushnumber(__pyx_v_L, ((lua_Number)((long)__pyx_t_5)));

    /* "lupa/_lupa.pyx":1213
 *     elif IS_PY2 and isinstance(o, int):
 *         lua.lua_pushnumber(L, <lua.lua_Number><long>o)
 *         pushed_values_count = 1             # <<<<<<<<<<<<<<
 *     elif isinstance(o, bytes):
 *         lua.lua_pushlstring(L, <char*>(<bytes>o), len(<bytes>o))
 */
    __pyx_v_pushed_values_count = 1;

    /* "lupa/_lupa.pyx":1211
 *         lua.lua_pushnumber(L, <lua.lua_Number>cpython.long.PyLong_AsDouble(o))
 *         pushed_values_count = 1
 *     elif IS_PY2 and isinstance(o, int):             # <<<<<<<<<<<<<<
 *         lua.lua_pushnumber(L, <lua.lua_Number><long>o)
 *         pushed_values_count = 1
 */
    goto __pyx_L3;
  }

  /* "lupa/_lupa.pyx":1214
 *         lua.lua_pushnumber(L, <lua.lua_Number><long>o)
 *         pushed_values_count = 1
 *     elif isinstance(o, bytes):             # <<<<<<<<<<<<<<
 *         lua.lua_pushlstring(L, <char*>(<bytes>o), len(<bytes>o))
 *         pushed_values_count = 1
 */
  __pyx_t_2 = PyBytes_Check(__pyx_v_o); 
  __pyx_t_3 = (__pyx_t_2 != 0);
  if (__pyx_t_3) {

    /* "lupa/_lupa.pyx":1215
 *         pushed_values_count = 1
 *     elif isinstance(o, bytes):
 *         lua.lua_pushlstring(L, <char*>(<bytes>o), len(<bytes>o))             # <<<<<<<<<<<<<<
 *         pushed_values_count = 1
 *     elif isinstance(o, unicode) and runtime._encoding is not None:
 */
    if (unlikely(__pyx_v_o == Py_None)) {
      PyErr_SetString(PyExc_TypeError, "expected bytes, NoneType found");
      __PYX_ERR(0, 1215, __pyx_L1_error)
    }
    __pyx_t_6 = __Pyx_PyBytes_AsWritableString(__pyx_v_o); if (unlikely((!__pyx_t_6) && PyErr_Occurred())) __PYX_ERR(0, 1215, __pyx_L1_error)
    if (unlikely(__pyx_v_o == Py_None)) {
      PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()");
      __PYX_ERR(0, 1215, __pyx_L1_error)
    }
    __pyx_t_7 = PyBytes_GET_SIZE(((PyObject*)__pyx_v_o)); if (unlikely(__pyx_t_7 == ((Py_ssize_t)-1))) __PYX_ERR(0, 1215, __pyx_L1_error)
    lua_pushlstring(__pyx_v_L, ((char *)__pyx_t_6), __pyx_t_7);

    /* "lupa/_lupa.pyx":1216
 *     elif isinstance(o, bytes):
 *         lua.lua_pushlstring(L, <char*>(<bytes>o), len(<bytes>o))
 *         pushed_values_count = 1             # <<<<<<<<<<<<<<
 *     elif isinstance(o, unicode) and runtime._encoding is not None:
 *         pushed_values_count = push_encoded_unicode_string(runtime, L, <unicode>o)
 */
    __pyx_v_pushed_values_count = 1;

    /* "lupa/_lupa.pyx":1214
 *         lua.lua_pushnumber(L, <lua.lua_Number><long>o)
 *         pushed_values_count = 1
 *     elif isinstance(o, bytes):             # <<<<<<<<<<<<<<
 *         lua.lua_pushlstring(L, <char*>(<bytes>o), len(<bytes>o))
 *         pushed_values_count = 1
 */
    goto __pyx_L3;
  }

  /* "lupa/_lupa.pyx":1217
 *         lua.lua_pushlstring(L, <char*>(<bytes>o), len(<bytes>o))
 *         pushed_values_count = 1
 *     elif isinstance(o, unicode) and runtime._encoding is not None:             # <<<<<<<<<<<<<<
 *         pushed_values_count = push_encoded_unicode_string(runtime, L, <unicode>o)
 *     elif isinstance(o, _LuaObject):
 */
  __pyx_t_2 = PyUnicode_Check(__pyx_v_o); 
  __pyx_t_1 = (__pyx_t_2 != 0);
  if (__pyx_t_1) {
  } else {
    __pyx_t_3 = __pyx_t_1;
    goto __pyx_L10_bool_binop_done;
  }
  __pyx_t_1 = (__pyx_v_runtime->_encoding != ((PyObject*)Py_None));
  __pyx_t_2 = (__pyx_t_1 != 0);
  __pyx_t_3 = __pyx_t_2;
  __pyx_L10_bool_binop_done:;
  if (__pyx_t_3) {

    /* "lupa/_lupa.pyx":1218
 *         pushed_values_count = 1
 *     elif isinstance(o, unicode) and runtime._encoding is not None:
 *         pushed_values_count = push_encoded_unicode_string(runtime, L, <unicode>o)             # <<<<<<<<<<<<<<
 *     elif isinstance(o, _LuaObject):
 *         if (<_LuaObject>o)._runtime is not runtime:
 */
    __pyx_t_8 = __pyx_f_4lupa_5_lupa_push_encoded_unicode_string(__pyx_v_runtime, __pyx_v_L, ((PyObject*)__pyx_v_o)); if (unlikely(__pyx_t_8 == ((int)-1))) __PYX_ERR(0, 1218, __pyx_L1_error)
    __pyx_v_pushed_values_count = __pyx_t_8;

    /* "lupa/_lupa.pyx":1217
 *         lua.lua_pushlstring(L, <char*>(<bytes>o), len(<bytes>o))
 *         pushed_values_count = 1
 *     elif isinstance(o, unicode) and runtime._encoding is not None:             # <<<<<<<<<<<<<<
 *         pushed_values_count = push_encoded_unicode_string(runtime, L, <unicode>o)
 *     elif isinstance(o, _LuaObject):
 */
    goto __pyx_L3;
  }

  /* "lupa/_lupa.pyx":1219
 *     elif isinstance(o, unicode) and runtime._encoding is not None:
 *         pushed_values_count = push_encoded_unicode_string(runtime, L, <unicode>o)
 *     elif isinstance(o, _LuaObject):             # <<<<<<<<<<<<<<
 *         if (<_LuaObject>o)._runtime is not runtime:
 *             raise LuaError("cannot mix objects from different Lua runtimes")
 */
  __pyx_t_3 = __Pyx_TypeCheck(__pyx_v_o, __pyx_ptype_4lupa_5_lupa__LuaObject); 
  __pyx_t_2 = (__pyx_t_3 != 0);
  if (__pyx_t_2) {

    /* "lupa/_lupa.pyx":1220
 *         pushed_values_count = push_encoded_unicode_string(runtime, L, <unicode>o)
 *     elif isinstance(o, _LuaObject):
 *         if (<_LuaObject>o)._runtime is not runtime:             # <<<<<<<<<<<<<<
 *             raise LuaError("cannot mix objects from different Lua runtimes")
 *         lua.lua_rawgeti(L, lua.LUA_REGISTRYINDEX, (<_LuaObject>o)._ref)
 */
    __pyx_t_2 = (((struct __pyx_obj_4lupa_5_lupa__LuaObject *)__pyx_v_o)->_runtime != __pyx_v_runtime);
    __pyx_t_3 = (__pyx_t_2 != 0);
    if (unlikely(__pyx_t_3)) {

      /* "lupa/_lupa.pyx":1221
 *     elif isinstance(o, _LuaObject):
 *         if (<_LuaObject>o)._runtime is not runtime:
 *             raise LuaError("cannot mix objects from different Lua runtimes")             # <<<<<<<<<<<<<<
 *         lua.lua_rawgeti(L, lua.LUA_REGISTRYINDEX, (<_LuaObject>o)._ref)
 *         pushed_values_count = 1
 */
      __Pyx_GetModuleGlobalName(__pyx_t_10, __pyx_n_s_LuaError); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 1221, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_10);
      __pyx_t_11 = NULL;
      if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_10))) {
        __pyx_t_11 = PyMethod_GET_SELF(__pyx_t_10);
        if (likely(__pyx_t_11)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_10);
          __Pyx_INCREF(__pyx_t_11);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_10, function);
        }
      }
      __pyx_t_9 = (__pyx_t_11) ? __Pyx_PyObject_Call2Args(__pyx_t_10, __pyx_t_11, __pyx_kp_s_cannot_mix_objects_from_differen) : __Pyx_PyObject_CallOneArg(__pyx_t_10, __pyx_kp_s_cannot_mix_objects_from_differen);
      __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0;
      if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 1221, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_9);
      __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
      __Pyx_Raise(__pyx_t_9, 0, 0, 0);
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
      __PYX_ERR(0, 1221, __pyx_L1_error)

      /* "lupa/_lupa.pyx":1220
 *         pushed_values_count = push_encoded_unicode_string(runtime, L, <unicode>o)
 *     elif isinstance(o, _LuaObject):
 *         if (<_LuaObject>o)._runtime is not runtime:             # <<<<<<<<<<<<<<
 *             raise LuaError("cannot mix objects from different Lua runtimes")
 *         lua.lua_rawgeti(L, lua.LUA_REGISTRYINDEX, (<_LuaObject>o)._ref)
 */
    }

    /* "lupa/_lupa.pyx":1222
 *         if (<_LuaObject>o)._runtime is not runtime:
 *             raise LuaError("cannot mix objects from different Lua runtimes")
 *         lua.lua_rawgeti(L, lua.LUA_REGISTRYINDEX, (<_LuaObject>o)._ref)             # <<<<<<<<<<<<<<
 *         pushed_values_count = 1
 *     elif isinstance(o, float):
 */
    lua_rawgeti(__pyx_v_L, LUA_REGISTRYINDEX, ((struct __pyx_obj_4lupa_5_lupa__LuaObject *)__pyx_v_o)->_ref);

    /* "lupa/_lupa.pyx":1223
 *             raise LuaError("cannot mix objects from different Lua runtimes")
 *         lua.lua_rawgeti(L, lua.LUA_REGISTRYINDEX, (<_LuaObject>o)._ref)
 *         pushed_values_count = 1             # <<<<<<<<<<<<<<
 *     elif isinstance(o, float):
 *         lua.lua_pushnumber(L, <lua.lua_Number><double>o)
 */
    __pyx_v_pushed_values_count = 1;

    /* "lupa/_lupa.pyx":1219
 *     elif isinstance(o, unicode) and runtime._encoding is not None:
 *         pushed_values_count = push_encoded_unicode_string(runtime, L, <unicode>o)
 *     elif isinstance(o, _LuaObject):             # <<<<<<<<<<<<<<
 *         if (<_LuaObject>o)._runtime is not runtime:
 *             raise LuaError("cannot mix objects from different Lua runtimes")
 */
    goto __pyx_L3;
  }

  /* "lupa/_lupa.pyx":1224
 *         lua.lua_rawgeti(L, lua.LUA_REGISTRYINDEX, (<_LuaObject>o)._ref)
 *         pushed_values_count = 1
 *     elif isinstance(o, float):             # <<<<<<<<<<<<<<
 *         lua.lua_pushnumber(L, <lua.lua_Number><double>o)
 *         pushed_values_count = 1
 */
  __pyx_t_3 = PyFloat_Check(__pyx_v_o); 
  __pyx_t_2 = (__pyx_t_3 != 0);
  if (__pyx_t_2) {

    /* "lupa/_lupa.pyx":1225
 *         pushed_values_count = 1
 *     elif isinstance(o, float):
 *         lua.lua_pushnumber(L, <lua.lua_Number><double>o)             # <<<<<<<<<<<<<<
 *         pushed_values_count = 1
 *     else:
 */
    __pyx_t_4 = __pyx_PyFloat_AsDouble(__pyx_v_o); if (unlikely((__pyx_t_4 == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 1225, __pyx_L1_error)
    lua_pushnumber(__pyx_v_L, ((lua_Number)((double)__pyx_t_4)));

    /* "lupa/_lupa.pyx":1226
 *     elif isinstance(o, float):
 *         lua.lua_pushnumber(L, <lua.lua_Number><double>o)
 *         pushed_values_count = 1             # <<<<<<<<<<<<<<
 *     else:
 *         if isinstance(o, _PyProtocolWrapper):
 */
    __pyx_v_pushed_values_count = 1;

    /* "lupa/_lupa.pyx":1224
 *         lua.lua_rawgeti(L, lua.LUA_REGISTRYINDEX, (<_LuaObject>o)._ref)
 *         pushed_values_count = 1
 *     elif isinstance(o, float):             # <<<<<<<<<<<<<<
 *         lua.lua_pushnumber(L, <lua.lua_Number><double>o)
 *         pushed_values_count = 1
 */
    goto __pyx_L3;
  }

  /* "lupa/_lupa.pyx":1228
 *         pushed_values_count = 1
 *     else:
 *         if isinstance(o, _PyProtocolWrapper):             # <<<<<<<<<<<<<<
 *             type_flags = (<_PyProtocolWrapper>o)._type_flags
 *             o = (<_PyProtocolWrapper>o)._obj
 */
  /*else*/ {
    __pyx_t_2 = __Pyx_TypeCheck(__pyx_v_o, __pyx_ptype_4lupa_5_lupa__PyProtocolWrapper); 
    __pyx_t_3 = (__pyx_t_2 != 0);
    if (__pyx_t_3) {

      /* "lupa/_lupa.pyx":1229
 *     else:
 *         if isinstance(o, _PyProtocolWrapper):
 *             type_flags = (<_PyProtocolWrapper>o)._type_flags             # <<<<<<<<<<<<<<
 *             o = (<_PyProtocolWrapper>o)._obj
 *         else:
 */
      __pyx_t_8 = ((struct __pyx_obj_4lupa_5_lupa__PyProtocolWrapper *)__pyx_v_o)->_type_flags;
      __pyx_v_type_flags = __pyx_t_8;

      /* "lupa/_lupa.pyx":1230
 *         if isinstance(o, _PyProtocolWrapper):
 *             type_flags = (<_PyProtocolWrapper>o)._type_flags
 *             o = (<_PyProtocolWrapper>o)._obj             # <<<<<<<<<<<<<<
 *         else:
 *             # prefer __getitem__ over __getattr__ by default
 */
      __pyx_t_9 = ((struct __pyx_obj_4lupa_5_lupa__PyProtocolWrapper *)__pyx_v_o)->_obj;
      __Pyx_INCREF(__pyx_t_9);
      __Pyx_DECREF_SET(__pyx_v_o, __pyx_t_9);
      __pyx_t_9 = 0;

      /* "lupa/_lupa.pyx":1228
 *         pushed_values_count = 1
 *     else:
 *         if isinstance(o, _PyProtocolWrapper):             # <<<<<<<<<<<<<<
 *             type_flags = (<_PyProtocolWrapper>o)._type_flags
 *             o = (<_PyProtocolWrapper>o)._obj
 */
      goto __pyx_L13;
    }

    /* "lupa/_lupa.pyx":1233
 *         else:
 *             # prefer __getitem__ over __getattr__ by default
 *             type_flags = OBJ_AS_INDEX if hasattr(o, '__getitem__') else 0             # <<<<<<<<<<<<<<
 *         pushed_values_count = py_to_lua_custom(runtime, L, o, type_flags)
 *     return pushed_values_count
 */
    /*else*/ {
      __pyx_t_3 = __Pyx_HasAttr(__pyx_v_o, __pyx_n_s_getitem); if (unlikely(__pyx_t_3 == ((int)-1))) __PYX_ERR(0, 1233, __pyx_L1_error)
      if ((__pyx_t_3 != 0)) {
        __pyx_t_8 = __pyx_e_4lupa_5_lupa_OBJ_AS_INDEX;
      } else {
        __pyx_t_8 = 0;
      }
      __pyx_v_type_flags = __pyx_t_8;
    }
    __pyx_L13:;

    /* "lupa/_lupa.pyx":1234
 *             # prefer __getitem__ over __getattr__ by default
 *             type_flags = OBJ_AS_INDEX if hasattr(o, '__getitem__') else 0
 *         pushed_values_count = py_to_lua_custom(runtime, L, o, type_flags)             # <<<<<<<<<<<<<<
 *     return pushed_values_count
 * 
 */
    __pyx_v_pushed_values_count = __pyx_f_4lupa_5_lupa_py_to_lua_custom(__pyx_v_runtime, __pyx_v_L, __pyx_v_o, __pyx_v_type_flags);
  }
  __pyx_L3:;

  /* "lupa/_lupa.pyx":1235
 *             type_flags = OBJ_AS_INDEX if hasattr(o, '__getitem__') else 0
 *         pushed_values_count = py_to_lua_custom(runtime, L, o, type_flags)
 *     return pushed_values_count             # <<<<<<<<<<<<<<
 * 
 * cdef int push_encoded_unicode_string(LuaRuntime runtime, lua_State *L, unicode ustring) except -1:
 */
  __pyx_r = __pyx_v_pushed_values_count;
  goto __pyx_L0;

  /* "lupa/_lupa.pyx":1185
 *      return py_to_lua(runtime, L, o)
 * 
 * cdef int py_to_lua(LuaRuntime runtime, lua_State *L, object o, bint wrap_none=False) except -1:             # <<<<<<<<<<<<<<
 *     cdef int pushed_values_count = 0
 *     cdef int type_flags = 0
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_9);
  __Pyx_XDECREF(__pyx_t_10);
  __Pyx_XDECREF(__pyx_t_11);
  __Pyx_AddTraceback("lupa._lupa.py_to_lua", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_o);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lupa/_lupa.pyx":1237
 *     return pushed_values_count
 * 
 * cdef int push_encoded_unicode_string(LuaRuntime runtime, lua_State *L, unicode ustring) except -1:             # <<<<<<<<<<<<<<
 *     cdef bytes bytes_string = ustring.encode(runtime._encoding)
 *     lua.lua_pushlstring(L, <char*>bytes_string, len(bytes_string))
 */

static int __pyx_f_4lupa_5_lupa_push_encoded_unicode_string(struct __pyx_obj_4lupa_5_lupa_LuaRuntime *__pyx_v_runtime, lua_State *__pyx_v_L, PyObject *__pyx_v_ustring) {
  PyObject *__pyx_v_bytes_string = 0;
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  char const *__pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  char *__pyx_t_3;
  Py_ssize_t __pyx_t_4;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("push_encoded_unicode_string", 0);

  /* "lupa/_lupa.pyx":1238
 * 
 * cdef int push_encoded_unicode_string(LuaRuntime runtime, lua_State *L, unicode ustring) except -1:
 *     cdef bytes bytes_string = ustring.encode(runtime._encoding)             # <<<<<<<<<<<<<<
 *     lua.lua_pushlstring(L, <char*>bytes_string, len(bytes_string))
 *     return 1
 */
  if (unlikely(__pyx_v_ustring == Py_None)) {
    PyErr_Format(PyExc_AttributeError, "'NoneType' object has no attribute '%.30s'", "encode");
    __PYX_ERR(0, 1238, __pyx_L1_error)
  }
  if (unlikely(__pyx_v_runtime->_encoding == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "expected bytes, NoneType found");
    __PYX_ERR(0, 1238, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_PyBytes_AsString(__pyx_v_runtime->_encoding); if (unlikely((!__pyx_t_1) && PyErr_Occurred())) __PYX_ERR(0, 1238, __pyx_L1_error)
  __pyx_t_2 = PyUnicode_AsEncodedString(__pyx_v_ustring, __pyx_t_1, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1238, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_v_bytes_string = ((PyObject*)__pyx_t_2);
  __pyx_t_2 = 0;

  /* "lupa/_lupa.pyx":1239
 * cdef int push_encoded_unicode_string(LuaRuntime runtime, lua_State *L, unicode ustring) except -1:
 *     cdef bytes bytes_string = ustring.encode(runtime._encoding)
 *     lua.lua_pushlstring(L, <char*>bytes_string, len(bytes_string))             # <<<<<<<<<<<<<<
 *     return 1
 * 
 */
  if (unlikely(__pyx_v_bytes_string == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "expected bytes, NoneType found");
    __PYX_ERR(0, 1239, __pyx_L1_error)
  }
  __pyx_t_3 = __Pyx_PyBytes_AsWritableString(__pyx_v_bytes_string); if (unlikely((!__pyx_t_3) && PyErr_Occurred())) __PYX_ERR(0, 1239, __pyx_L1_error)
  if (unlikely(__pyx_v_bytes_string == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()");
    __PYX_ERR(0, 1239, __pyx_L1_error)
  }
  __pyx_t_4 = PyBytes_GET_SIZE(__pyx_v_bytes_string); if (unlikely(__pyx_t_4 == ((Py_ssize_t)-1))) __PYX_ERR(0, 1239, __pyx_L1_error)
  lua_pushlstring(__pyx_v_L, ((char *)__pyx_t_3), __pyx_t_4);

  /* "lupa/_lupa.pyx":1240
 *     cdef bytes bytes_string = ustring.encode(runtime._encoding)
 *     lua.lua_pushlstring(L, <char*>bytes_string, len(bytes_string))
 *     return 1             # <<<<<<<<<<<<<<
 * 
 * cdef bint py_to_lua_custom(LuaRuntime runtime, lua_State *L, object o, int type_flags):
 */
  __pyx_r = 1;
  goto __pyx_L0;

  /* "lupa/_lupa.pyx":1237
 *     return pushed_values_count
 * 
 * cdef int push_encoded_unicode_string(LuaRuntime runtime, lua_State *L, unicode ustring) except -1:             # <<<<<<<<<<<<<<
 *     cdef bytes bytes_string = ustring.encode(runtime._encoding)
 *     lua.lua_pushlstring(L, <char*>bytes_string, len(bytes_string))
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_AddTraceback("lupa._lupa.push_encoded_unicode_string", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_bytes_string);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lupa/_lupa.pyx":1242
 *     return 1
 * 
 * cdef bint py_to_lua_custom(LuaRuntime runtime, lua_State *L, object o, int type_flags):             # <<<<<<<<<<<<<<
 *     cdef py_object *py_obj = <py_object*> lua.lua_newuserdata(L, sizeof(py_object))
 *     if not py_obj:
 */

static int __pyx_f_4lupa_5_lupa_py_to_lua_custom(struct __pyx_obj_4lupa_5_lupa_LuaRuntime *__pyx_v_runtime, lua_State *__pyx_v_L, PyObject *__pyx_v_o, int __pyx_v_type_flags) {
  struct __pyx_t_4lupa_5_lupa_py_object *__pyx_v_py_obj;
  PyObject *__pyx_v_obj_id = NULL;
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  int __pyx_t_4;
  int __pyx_t_5;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("py_to_lua_custom", 0);

  /* "lupa/_lupa.pyx":1243
 * 
 * cdef bint py_to_lua_custom(LuaRuntime runtime, lua_State *L, object o, int type_flags):
 *     cdef py_object *py_obj = <py_object*> lua.lua_newuserdata(L, sizeof(py_object))             # <<<<<<<<<<<<<<
 *     if not py_obj:
 *         return 0 # values pushed
 */
  __pyx_v_py_obj = ((struct __pyx_t_4lupa_5_lupa_py_object *)lua_newuserdata(__pyx_v_L, (sizeof(struct __pyx_t_4lupa_5_lupa_py_object))));

  /* "lupa/_lupa.pyx":1244
 * cdef bint py_to_lua_custom(LuaRuntime runtime, lua_State *L, object o, int type_flags):
 *     cdef py_object *py_obj = <py_object*> lua.lua_newuserdata(L, sizeof(py_object))
 *     if not py_obj:             # <<<<<<<<<<<<<<
 *         return 0 # values pushed
 * 
 */
  __pyx_t_1 = ((!(__pyx_v_py_obj != 0)) != 0);
  if (__pyx_t_1) {

    /* "lupa/_lupa.pyx":1245
 *     cdef py_object *py_obj = <py_object*> lua.lua_newuserdata(L, sizeof(py_object))
 *     if not py_obj:
 *         return 0 # values pushed             # <<<<<<<<<<<<<<
 * 
 *     # originally, we just used:
 */
    __pyx_r = 0;
    goto __pyx_L0;

    /* "lupa/_lupa.pyx":1244
 * cdef bint py_to_lua_custom(LuaRuntime runtime, lua_State *L, object o, int type_flags):
 *     cdef py_object *py_obj = <py_object*> lua.lua_newuserdata(L, sizeof(py_object))
 *     if not py_obj:             # <<<<<<<<<<<<<<
 *         return 0 # values pushed
 * 
 */
  }

  /* "lupa/_lupa.pyx":1251
 *     # now, we store an owned reference in "runtime._pyrefs_in_lua" to keep it visible to Python
 *     # and a borrowed reference in "py_obj.obj" for access from Lua
 *     obj_id = <object><uintptr_t><PyObject*>(o)             # <<<<<<<<<<<<<<
 *     if obj_id in runtime._pyrefs_in_lua:
 *         runtime._pyrefs_in_lua[obj_id].append(o)
 */
  __pyx_t_2 = __Pyx_PyInt_FromSize_t(((uintptr_t)((PyObject *)__pyx_v_o))); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1251, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = __pyx_t_2;
  __Pyx_INCREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_v_obj_id = __pyx_t_3;
  __pyx_t_3 = 0;

  /* "lupa/_lupa.pyx":1252
 *     # and a borrowed reference in "py_obj.obj" for access from Lua
 *     obj_id = <object><uintptr_t><PyObject*>(o)
 *     if obj_id in runtime._pyrefs_in_lua:             # <<<<<<<<<<<<<<
 *         runtime._pyrefs_in_lua[obj_id].append(o)
 *     else:
 */
  if (unlikely(__pyx_v_runtime->_pyrefs_in_lua == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable");
    __PYX_ERR(0, 1252, __pyx_L1_error)
  }
  __pyx_t_1 = (__Pyx_PyDict_ContainsTF(__pyx_v_obj_id, __pyx_v_runtime->_pyrefs_in_lua, Py_EQ)); if (unlikely(__pyx_t_1 < 0)) __PYX_ERR(0, 1252, __pyx_L1_error)
  __pyx_t_4 = (__pyx_t_1 != 0);
  if (__pyx_t_4) {

    /* "lupa/_lupa.pyx":1253
 *     obj_id = <object><uintptr_t><PyObject*>(o)
 *     if obj_id in runtime._pyrefs_in_lua:
 *         runtime._pyrefs_in_lua[obj_id].append(o)             # <<<<<<<<<<<<<<
 *     else:
 *         runtime._pyrefs_in_lua[obj_id] = [o]
 */
    if (unlikely(__pyx_v_runtime->_pyrefs_in_lua == Py_None)) {
      PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
      __PYX_ERR(0, 1253, __pyx_L1_error)
    }
    __pyx_t_3 = __Pyx_PyDict_GetItem(__pyx_v_runtime->_pyrefs_in_lua, __pyx_v_obj_id); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1253, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_5 = __Pyx_PyObject_Append(__pyx_t_3, __pyx_v_o); if (unlikely(__pyx_t_5 == ((int)-1))) __PYX_ERR(0, 1253, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

    /* "lupa/_lupa.pyx":1252
 *     # and a borrowed reference in "py_obj.obj" for access from Lua
 *     obj_id = <object><uintptr_t><PyObject*>(o)
 *     if obj_id in runtime._pyrefs_in_lua:             # <<<<<<<<<<<<<<
 *         runtime._pyrefs_in_lua[obj_id].append(o)
 *     else:
 */
    goto __pyx_L4;
  }

  /* "lupa/_lupa.pyx":1255
 *         runtime._pyrefs_in_lua[obj_id].append(o)
 *     else:
 *         runtime._pyrefs_in_lua[obj_id] = [o]             # <<<<<<<<<<<<<<
 * 
 *     py_obj.obj = <PyObject*>o
 */
  /*else*/ {
    __pyx_t_3 = PyList_New(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1255, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_INCREF(__pyx_v_o);
    __Pyx_GIVEREF(__pyx_v_o);
    PyList_SET_ITEM(__pyx_t_3, 0, __pyx_v_o);
    if (unlikely(__pyx_v_runtime->_pyrefs_in_lua == Py_None)) {
      PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
      __PYX_ERR(0, 1255, __pyx_L1_error)
    }
    if (unlikely(PyDict_SetItem(__pyx_v_runtime->_pyrefs_in_lua, __pyx_v_obj_id, __pyx_t_3) < 0)) __PYX_ERR(0, 1255, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  }
  __pyx_L4:;

  /* "lupa/_lupa.pyx":1257
 *         runtime._pyrefs_in_lua[obj_id] = [o]
 * 
 *     py_obj.obj = <PyObject*>o             # <<<<<<<<<<<<<<
 *     py_obj.runtime = <PyObject*>runtime
 *     py_obj.type_flags = type_flags
 */
  __pyx_v_py_obj->obj = ((PyObject *)__pyx_v_o);

  /* "lupa/_lupa.pyx":1258
 * 
 *     py_obj.obj = <PyObject*>o
 *     py_obj.runtime = <PyObject*>runtime             # <<<<<<<<<<<<<<
 *     py_obj.type_flags = type_flags
 *     lua.luaL_getmetatable(L, POBJECT)
 */
  __pyx_v_py_obj->runtime = ((PyObject *)__pyx_v_runtime);

  /* "lupa/_lupa.pyx":1259
 *     py_obj.obj = <PyObject*>o
 *     py_obj.runtime = <PyObject*>runtime
 *     py_obj.type_flags = type_flags             # <<<<<<<<<<<<<<
 *     lua.luaL_getmetatable(L, POBJECT)
 *     lua.lua_setmetatable(L, -2)
 */
  __pyx_v_py_obj->type_flags = __pyx_v_type_flags;

  /* "lupa/_lupa.pyx":1260
 *     py_obj.runtime = <PyObject*>runtime
 *     py_obj.type_flags = type_flags
 *     lua.luaL_getmetatable(L, POBJECT)             # <<<<<<<<<<<<<<
 *     lua.lua_setmetatable(L, -2)
 *     return 1 # values pushed
 */
  luaL_getmetatable(__pyx_v_L, ((char *)"POBJECT"));

  /* "lupa/_lupa.pyx":1261
 *     py_obj.type_flags = type_flags
 *     lua.luaL_getmetatable(L, POBJECT)
 *     lua.lua_setmetatable(L, -2)             # <<<<<<<<<<<<<<
 *     return 1 # values pushed
 * 
 */
  (void)(lua_setmetatable(__pyx_v_L, -2));

  /* "lupa/_lupa.pyx":1262
 *     lua.luaL_getmetatable(L, POBJECT)
 *     lua.lua_setmetatable(L, -2)
 *     return 1 # values pushed             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_r = 1;
  goto __pyx_L0;

  /* "lupa/_lupa.pyx":1242
 *     return 1
 * 
 * cdef bint py_to_lua_custom(LuaRuntime runtime, lua_State *L, object o, int type_flags):             # <<<<<<<<<<<<<<
 *     cdef py_object *py_obj = <py_object*> lua.lua_newuserdata(L, sizeof(py_object))
 *     if not py_obj:
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_WriteUnraisable("lupa._lupa.py_to_lua_custom", __pyx_clineno, __pyx_lineno, __pyx_filename, 1, 0);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_obj_id);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lupa/_lupa.pyx":1265
 * 
 * 
 * cdef inline int _isascii(unsigned char* s):             # <<<<<<<<<<<<<<
 *     cdef unsigned char c = 0
 *     while s[0]:
 */

static CYTHON_INLINE int __pyx_f_4lupa_5_lupa__isascii(unsigned char *__pyx_v_s) {
  unsigned char __pyx_v_c;
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  __Pyx_RefNannySetupContext("_isascii", 0);

  /* "lupa/_lupa.pyx":1266
 * 
 * cdef inline int _isascii(unsigned char* s):
 *     cdef unsigned char c = 0             # <<<<<<<<<<<<<<
 *     while s[0]:
 *         c |= s[0]
 */
  __pyx_v_c = 0;

  /* "lupa/_lupa.pyx":1267
 * cdef inline int _isascii(unsigned char* s):
 *     cdef unsigned char c = 0
 *     while s[0]:             # <<<<<<<<<<<<<<
 *         c |= s[0]
 *         s += 1
 */
  while (1) {
    __pyx_t_1 = ((__pyx_v_s[0]) != 0);
    if (!__pyx_t_1) break;

    /* "lupa/_lupa.pyx":1268
 *     cdef unsigned char c = 0
 *     while s[0]:
 *         c |= s[0]             # <<<<<<<<<<<<<<
 *         s += 1
 *     return c & 0x80 == 0
 */
    __pyx_v_c = (__pyx_v_c | (__pyx_v_s[0]));

    /* "lupa/_lupa.pyx":1269
 *     while s[0]:
 *         c |= s[0]
 *         s += 1             # <<<<<<<<<<<<<<
 *     return c & 0x80 == 0
 * 
 */
    __pyx_v_s = (__pyx_v_s + 1);
  }

  /* "lupa/_lupa.pyx":1270
 *         c |= s[0]
 *         s += 1
 *     return c & 0x80 == 0             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_r = ((__pyx_v_c & 0x80) == 0);
  goto __pyx_L0;

  /* "lupa/_lupa.pyx":1265
 * 
 * 
 * cdef inline int _isascii(unsigned char* s):             # <<<<<<<<<<<<<<
 *     cdef unsigned char c = 0
 *     while s[0]:
 */

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

/* "lupa/_lupa.pyx":1273
 * 
 * 
 * cdef bytes _asciiOrNone(s):             # <<<<<<<<<<<<<<
 *     if s is None:
 *         return s
 */

static PyObject *__pyx_f_4lupa_5_lupa__asciiOrNone(PyObject *__pyx_v_s) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  int __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  unsigned char *__pyx_t_5;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("_asciiOrNone", 0);
  __Pyx_INCREF(__pyx_v_s);

  /* "lupa/_lupa.pyx":1274
 * 
 * cdef bytes _asciiOrNone(s):
 *     if s is None:             # <<<<<<<<<<<<<<
 *         return s
 *     elif isinstance(s, unicode):
 */
  __pyx_t_1 = (__pyx_v_s == Py_None);
  __pyx_t_2 = (__pyx_t_1 != 0);
  if (__pyx_t_2) {

    /* "lupa/_lupa.pyx":1275
 * cdef bytes _asciiOrNone(s):
 *     if s is None:
 *         return s             # <<<<<<<<<<<<<<
 *     elif isinstance(s, unicode):
 *         return (<unicode>s).encode('ascii')
 */
    __Pyx_XDECREF(__pyx_r);
    if (!(likely(PyBytes_CheckExact(__pyx_v_s))||((__pyx_v_s) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "bytes", Py_TYPE(__pyx_v_s)->tp_name), 0))) __PYX_ERR(0, 1275, __pyx_L1_error)
    __Pyx_INCREF(__pyx_v_s);
    __pyx_r = ((PyObject*)__pyx_v_s);
    goto __pyx_L0;

    /* "lupa/_lupa.pyx":1274
 * 
 * cdef bytes _asciiOrNone(s):
 *     if s is None:             # <<<<<<<<<<<<<<
 *         return s
 *     elif isinstance(s, unicode):
 */
  }

  /* "lupa/_lupa.pyx":1276
 *     if s is None:
 *         return s
 *     elif isinstance(s, unicode):             # <<<<<<<<<<<<<<
 *         return (<unicode>s).encode('ascii')
 *     elif isinstance(s, bytearray):
 */
  __pyx_t_2 = PyUnicode_Check(__pyx_v_s); 
  __pyx_t_1 = (__pyx_t_2 != 0);
  if (__pyx_t_1) {

    /* "lupa/_lupa.pyx":1277
 *         return s
 *     elif isinstance(s, unicode):
 *         return (<unicode>s).encode('ascii')             # <<<<<<<<<<<<<<
 *     elif isinstance(s, bytearray):
 *         s = bytes(s)
 */
    __Pyx_XDECREF(__pyx_r);
    if (unlikely(__pyx_v_s == Py_None)) {
      PyErr_Format(PyExc_AttributeError, "'NoneType' object has no attribute '%.30s'", "encode");
      __PYX_ERR(0, 1277, __pyx_L1_error)
    }
    __pyx_t_3 = PyUnicode_AsASCIIString(((PyObject*)__pyx_v_s)); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1277, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_r = ((PyObject*)__pyx_t_3);
    __pyx_t_3 = 0;
    goto __pyx_L0;

    /* "lupa/_lupa.pyx":1276
 *     if s is None:
 *         return s
 *     elif isinstance(s, unicode):             # <<<<<<<<<<<<<<
 *         return (<unicode>s).encode('ascii')
 *     elif isinstance(s, bytearray):
 */
  }

  /* "lupa/_lupa.pyx":1278
 *     elif isinstance(s, unicode):
 *         return (<unicode>s).encode('ascii')
 *     elif isinstance(s, bytearray):             # <<<<<<<<<<<<<<
 *         s = bytes(s)
 *     elif not isinstance(s, bytes):
 */
  __pyx_t_1 = PyByteArray_Check(__pyx_v_s); 
  __pyx_t_2 = (__pyx_t_1 != 0);
  if (__pyx_t_2) {

    /* "lupa/_lupa.pyx":1279
 *         return (<unicode>s).encode('ascii')
 *     elif isinstance(s, bytearray):
 *         s = bytes(s)             # <<<<<<<<<<<<<<
 *     elif not isinstance(s, bytes):
 *         raise ValueError("expected string, got %s" % type(s))
 */
    __pyx_t_3 = __Pyx_PyObject_CallOneArg(((PyObject *)(&PyBytes_Type)), __pyx_v_s); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1279, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF_SET(__pyx_v_s, __pyx_t_3);
    __pyx_t_3 = 0;

    /* "lupa/_lupa.pyx":1278
 *     elif isinstance(s, unicode):
 *         return (<unicode>s).encode('ascii')
 *     elif isinstance(s, bytearray):             # <<<<<<<<<<<<<<
 *         s = bytes(s)
 *     elif not isinstance(s, bytes):
 */
    goto __pyx_L3;
  }

  /* "lupa/_lupa.pyx":1280
 *     elif isinstance(s, bytearray):
 *         s = bytes(s)
 *     elif not isinstance(s, bytes):             # <<<<<<<<<<<<<<
 *         raise ValueError("expected string, got %s" % type(s))
 *     if not _isascii(<bytes>s):
 */
  __pyx_t_2 = PyBytes_Check(__pyx_v_s); 
  __pyx_t_1 = ((!(__pyx_t_2 != 0)) != 0);
  if (unlikely(__pyx_t_1)) {

    /* "lupa/_lupa.pyx":1281
 *         s = bytes(s)
 *     elif not isinstance(s, bytes):
 *         raise ValueError("expected string, got %s" % type(s))             # <<<<<<<<<<<<<<
 *     if not _isascii(<bytes>s):
 *         raise ValueError("byte string input has unknown encoding, only ASCII is allowed")
 */
    __pyx_t_3 = __Pyx_PyString_FormatSafe(__pyx_kp_s_expected_string_got_s, ((PyObject *)Py_TYPE(__pyx_v_s))); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1281, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_4 = __Pyx_PyObject_CallOneArg(__pyx_builtin_ValueError, __pyx_t_3); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1281, __pyx_L1_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, 1281, __pyx_L1_error)

    /* "lupa/_lupa.pyx":1280
 *     elif isinstance(s, bytearray):
 *         s = bytes(s)
 *     elif not isinstance(s, bytes):             # <<<<<<<<<<<<<<
 *         raise ValueError("expected string, got %s" % type(s))
 *     if not _isascii(<bytes>s):
 */
  }
  __pyx_L3:;

  /* "lupa/_lupa.pyx":1282
 *     elif not isinstance(s, bytes):
 *         raise ValueError("expected string, got %s" % type(s))
 *     if not _isascii(<bytes>s):             # <<<<<<<<<<<<<<
 *         raise ValueError("byte string input has unknown encoding, only ASCII is allowed")
 *     return <bytes>s
 */
  if (unlikely(__pyx_v_s == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "expected bytes, NoneType found");
    __PYX_ERR(0, 1282, __pyx_L1_error)
  }
  __pyx_t_5 = __Pyx_PyBytes_AsWritableUString(__pyx_v_s); if (unlikely((!__pyx_t_5) && PyErr_Occurred())) __PYX_ERR(0, 1282, __pyx_L1_error)
  __pyx_t_1 = ((!(__pyx_f_4lupa_5_lupa__isascii(__pyx_t_5) != 0)) != 0);
  if (unlikely(__pyx_t_1)) {

    /* "lupa/_lupa.pyx":1283
 *         raise ValueError("expected string, got %s" % type(s))
 *     if not _isascii(<bytes>s):
 *         raise ValueError("byte string input has unknown encoding, only ASCII is allowed")             # <<<<<<<<<<<<<<
 *     return <bytes>s
 * 
 */
    __pyx_t_4 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__34, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1283, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_Raise(__pyx_t_4, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __PYX_ERR(0, 1283, __pyx_L1_error)

    /* "lupa/_lupa.pyx":1282
 *     elif not isinstance(s, bytes):
 *         raise ValueError("expected string, got %s" % type(s))
 *     if not _isascii(<bytes>s):             # <<<<<<<<<<<<<<
 *         raise ValueError("byte string input has unknown encoding, only ASCII is allowed")
 *     return <bytes>s
 */
  }

  /* "lupa/_lupa.pyx":1284
 *     if not _isascii(<bytes>s):
 *         raise ValueError("byte string input has unknown encoding, only ASCII is allowed")
 *     return <bytes>s             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(((PyObject*)__pyx_v_s));
  __pyx_r = ((PyObject*)__pyx_v_s);
  goto __pyx_L0;

  /* "lupa/_lupa.pyx":1273
 * 
 * 
 * cdef bytes _asciiOrNone(s):             # <<<<<<<<<<<<<<
 *     if s is None:
 *         return s
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_AddTraceback("lupa._lupa._asciiOrNone", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_s);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lupa/_lupa.pyx":1289
 * # error handling
 * 
 * cdef int raise_lua_error(LuaRuntime runtime, lua_State* L, int result) except -1:             # <<<<<<<<<<<<<<
 *     if result == 0:
 *         return 0
 */

static int __pyx_f_4lupa_5_lupa_raise_lua_error(struct __pyx_obj_4lupa_5_lupa_LuaRuntime *__pyx_v_runtime, lua_State *__pyx_v_L, int __pyx_v_result) {
  int __pyx_r;
  __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("raise_lua_error", 0);

  /* "lupa/_lupa.pyx":1290
 * 
 * cdef int raise_lua_error(LuaRuntime runtime, lua_State* L, int result) except -1:
 *     if result == 0:             # <<<<<<<<<<<<<<
 *         return 0
 *     elif result == lua.LUA_ERRMEM:
 */
  switch (__pyx_v_result) {
    case 0:

    /* "lupa/_lupa.pyx":1291
 * cdef int raise_lua_error(LuaRuntime runtime, lua_State* L, int result) except -1:
 *     if result == 0:
 *         return 0             # <<<<<<<<<<<<<<
 *     elif result == lua.LUA_ERRMEM:
 *         raise MemoryError()
 */
    __pyx_r = 0;
    goto __pyx_L0;

    /* "lupa/_lupa.pyx":1290
 * 
 * cdef int raise_lua_error(LuaRuntime runtime, lua_State* L, int result) except -1:
 *     if result == 0:             # <<<<<<<<<<<<<<
 *         return 0
 *     elif result == lua.LUA_ERRMEM:
 */
    break;
    case LUA_ERRMEM:

    /* "lupa/_lupa.pyx":1293
 *         return 0
 *     elif result == lua.LUA_ERRMEM:
 *         raise MemoryError()             # <<<<<<<<<<<<<<
 *     else:
 *         raise LuaError( build_lua_error_message(runtime, L, None, -1) )
 */
    PyErr_NoMemory(); __PYX_ERR(0, 1293, __pyx_L1_error)

    /* "lupa/_lupa.pyx":1292
 *     if result == 0:
 *         return 0
 *     elif result == lua.LUA_ERRMEM:             # <<<<<<<<<<<<<<
 *         raise MemoryError()
 *     else:
 */
    break;
    default:

    /* "lupa/_lupa.pyx":1295
 *         raise MemoryError()
 *     else:
 *         raise LuaError( build_lua_error_message(runtime, L, None, -1) )             # <<<<<<<<<<<<<<
 * 
 * cdef build_lua_error_message(LuaRuntime runtime, lua_State* L, unicode err_message, int n):
 */
    __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_LuaError); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1295, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_3 = __pyx_f_4lupa_5_lupa_build_lua_error_message(__pyx_v_runtime, __pyx_v_L, ((PyObject*)Py_None), -1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1295, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_4 = NULL;
    if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_2))) {
      __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_2);
      if (likely(__pyx_t_4)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
        __Pyx_INCREF(__pyx_t_4);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_2, function);
      }
    }
    __pyx_t_1 = (__pyx_t_4) ? __Pyx_PyObject_Call2Args(__pyx_t_2, __pyx_t_4, __pyx_t_3) : __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3);
    __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1295, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_Raise(__pyx_t_1, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __PYX_ERR(0, 1295, __pyx_L1_error)
    break;
  }

  /* "lupa/_lupa.pyx":1289
 * # error handling
 * 
 * cdef int raise_lua_error(LuaRuntime runtime, lua_State* L, int result) except -1:             # <<<<<<<<<<<<<<
 *     if result == 0:
 *         return 0
 */

  /* 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("lupa._lupa.raise_lua_error", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lupa/_lupa.pyx":1297
 *         raise LuaError( build_lua_error_message(runtime, L, None, -1) )
 * 
 * cdef build_lua_error_message(LuaRuntime runtime, lua_State* L, unicode err_message, int n):             # <<<<<<<<<<<<<<
 *     cdef size_t size = 0
 *     cdef const char *s = lua.lua_tolstring(L, n, &size)
 */

static PyObject *__pyx_f_4lupa_5_lupa_build_lua_error_message(struct __pyx_obj_4lupa_5_lupa_LuaRuntime *__pyx_v_runtime, lua_State *__pyx_v_L, PyObject *__pyx_v_err_message, int __pyx_v_n) {
  size_t __pyx_v_size;
  char const *__pyx_v_s;
  PyObject *__pyx_v_py_ustring = NULL;
  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;
  char const *__pyx_t_6;
  PyObject *__pyx_t_7 = NULL;
  int __pyx_t_8;
  PyObject *__pyx_t_9 = NULL;
  PyObject *__pyx_t_10 = NULL;
  PyObject *__pyx_t_11 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("build_lua_error_message", 0);

  /* "lupa/_lupa.pyx":1298
 * 
 * cdef build_lua_error_message(LuaRuntime runtime, lua_State* L, unicode err_message, int n):
 *     cdef size_t size = 0             # <<<<<<<<<<<<<<
 *     cdef const char *s = lua.lua_tolstring(L, n, &size)
 *     if runtime._encoding is not None:
 */
  __pyx_v_size = 0;

  /* "lupa/_lupa.pyx":1299
 * cdef build_lua_error_message(LuaRuntime runtime, lua_State* L, unicode err_message, int n):
 *     cdef size_t size = 0
 *     cdef const char *s = lua.lua_tolstring(L, n, &size)             # <<<<<<<<<<<<<<
 *     if runtime._encoding is not None:
 *         try:
 */
  __pyx_v_s = lua_tolstring(__pyx_v_L, __pyx_v_n, (&__pyx_v_size));

  /* "lupa/_lupa.pyx":1300
 *     cdef size_t size = 0
 *     cdef const char *s = lua.lua_tolstring(L, n, &size)
 *     if runtime._encoding is not None:             # <<<<<<<<<<<<<<
 *         try:
 *             py_ustring = s[:size].decode(runtime._encoding)
 */
  __pyx_t_1 = (__pyx_v_runtime->_encoding != ((PyObject*)Py_None));
  __pyx_t_2 = (__pyx_t_1 != 0);
  if (__pyx_t_2) {

    /* "lupa/_lupa.pyx":1301
 *     cdef const char *s = lua.lua_tolstring(L, n, &size)
 *     if runtime._encoding is not None:
 *         try:             # <<<<<<<<<<<<<<
 *             py_ustring = s[:size].decode(runtime._encoding)
 *         except UnicodeDecodeError:
 */
    {
      __Pyx_PyThreadState_declare
      __Pyx_PyThreadState_assign
      __Pyx_ExceptionSave(&__pyx_t_3, &__pyx_t_4, &__pyx_t_5);
      __Pyx_XGOTREF(__pyx_t_3);
      __Pyx_XGOTREF(__pyx_t_4);
      __Pyx_XGOTREF(__pyx_t_5);
      /*try:*/ {

        /* "lupa/_lupa.pyx":1302
 *     if runtime._encoding is not None:
 *         try:
 *             py_ustring = s[:size].decode(runtime._encoding)             # <<<<<<<<<<<<<<
 *         except UnicodeDecodeError:
 *             py_ustring = s[:size].decode('ISO-8859-1') # safe 'fake' decoding
 */
        if (unlikely(__pyx_v_runtime->_encoding == Py_None)) {
          PyErr_SetString(PyExc_TypeError, "expected bytes, NoneType found");
          __PYX_ERR(0, 1302, __pyx_L4_error)
        }
        __pyx_t_6 = __Pyx_PyBytes_AsString(__pyx_v_runtime->_encoding); if (unlikely((!__pyx_t_6) && PyErr_Occurred())) __PYX_ERR(0, 1302, __pyx_L4_error)
        __pyx_t_7 = __Pyx_decode_c_string(__pyx_v_s, 0, __pyx_v_size, __pyx_t_6, NULL, NULL); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1302, __pyx_L4_error)
        __Pyx_GOTREF(__pyx_t_7);
        __pyx_v_py_ustring = __pyx_t_7;
        __pyx_t_7 = 0;

        /* "lupa/_lupa.pyx":1301
 *     cdef const char *s = lua.lua_tolstring(L, n, &size)
 *     if runtime._encoding is not None:
 *         try:             # <<<<<<<<<<<<<<
 *             py_ustring = s[:size].decode(runtime._encoding)
 *         except UnicodeDecodeError:
 */
      }
      __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
      __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
      goto __pyx_L9_try_end;
      __pyx_L4_error:;
      __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;

      /* "lupa/_lupa.pyx":1303
 *         try:
 *             py_ustring = s[:size].decode(runtime._encoding)
 *         except UnicodeDecodeError:             # <<<<<<<<<<<<<<
 *             py_ustring = s[:size].decode('ISO-8859-1') # safe 'fake' decoding
 *     else:
 */
      __pyx_t_8 = __Pyx_PyErr_ExceptionMatches(__pyx_builtin_UnicodeDecodeError);
      if (__pyx_t_8) {
        __Pyx_AddTraceback("lupa._lupa.build_lua_error_message", __pyx_clineno, __pyx_lineno, __pyx_filename);
        if (__Pyx_GetException(&__pyx_t_7, &__pyx_t_9, &__pyx_t_10) < 0) __PYX_ERR(0, 1303, __pyx_L6_except_error)
        __Pyx_GOTREF(__pyx_t_7);
        __Pyx_GOTREF(__pyx_t_9);
        __Pyx_GOTREF(__pyx_t_10);

        /* "lupa/_lupa.pyx":1304
 *             py_ustring = s[:size].decode(runtime._encoding)
 *         except UnicodeDecodeError:
 *             py_ustring = s[:size].decode('ISO-8859-1') # safe 'fake' decoding             # <<<<<<<<<<<<<<
 *     else:
 *         py_ustring = s[:size].decode('ISO-8859-1')
 */
        __pyx_t_11 = __Pyx_decode_c_string(__pyx_v_s, 0, __pyx_v_size, NULL, NULL, PyUnicode_DecodeLatin1); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 1304, __pyx_L6_except_error)
        __Pyx_GOTREF(__pyx_t_11);
        __Pyx_XDECREF_SET(__pyx_v_py_ustring, __pyx_t_11);
        __pyx_t_11 = 0;
        __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
        __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
        __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
        goto __pyx_L5_exception_handled;
      }
      goto __pyx_L6_except_error;
      __pyx_L6_except_error:;

      /* "lupa/_lupa.pyx":1301
 *     cdef const char *s = lua.lua_tolstring(L, n, &size)
 *     if runtime._encoding is not None:
 *         try:             # <<<<<<<<<<<<<<
 *             py_ustring = s[:size].decode(runtime._encoding)
 *         except UnicodeDecodeError:
 */
      __Pyx_XGIVEREF(__pyx_t_3);
      __Pyx_XGIVEREF(__pyx_t_4);
      __Pyx_XGIVEREF(__pyx_t_5);
      __Pyx_ExceptionReset(__pyx_t_3, __pyx_t_4, __pyx_t_5);
      goto __pyx_L1_error;
      __pyx_L5_exception_handled:;
      __Pyx_XGIVEREF(__pyx_t_3);
      __Pyx_XGIVEREF(__pyx_t_4);
      __Pyx_XGIVEREF(__pyx_t_5);
      __Pyx_ExceptionReset(__pyx_t_3, __pyx_t_4, __pyx_t_5);
      __pyx_L9_try_end:;
    }

    /* "lupa/_lupa.pyx":1300
 *     cdef size_t size = 0
 *     cdef const char *s = lua.lua_tolstring(L, n, &size)
 *     if runtime._encoding is not None:             # <<<<<<<<<<<<<<
 *         try:
 *             py_ustring = s[:size].decode(runtime._encoding)
 */
    goto __pyx_L3;
  }

  /* "lupa/_lupa.pyx":1306
 *             py_ustring = s[:size].decode('ISO-8859-1') # safe 'fake' decoding
 *     else:
 *         py_ustring = s[:size].decode('ISO-8859-1')             # <<<<<<<<<<<<<<
 *     if err_message is None:
 *         return py_ustring
 */
  /*else*/ {
    __pyx_t_10 = __Pyx_decode_c_string(__pyx_v_s, 0, __pyx_v_size, NULL, NULL, PyUnicode_DecodeLatin1); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 1306, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_10);
    __pyx_v_py_ustring = __pyx_t_10;
    __pyx_t_10 = 0;
  }
  __pyx_L3:;

  /* "lupa/_lupa.pyx":1307
 *     else:
 *         py_ustring = s[:size].decode('ISO-8859-1')
 *     if err_message is None:             # <<<<<<<<<<<<<<
 *         return py_ustring
 *     else:
 */
  __pyx_t_2 = (__pyx_v_err_message == ((PyObject*)Py_None));
  __pyx_t_1 = (__pyx_t_2 != 0);
  if (__pyx_t_1) {

    /* "lupa/_lupa.pyx":1308
 *         py_ustring = s[:size].decode('ISO-8859-1')
 *     if err_message is None:
 *         return py_ustring             # <<<<<<<<<<<<<<
 *     else:
 *         return err_message % py_ustring
 */
    __Pyx_XDECREF(__pyx_r);
    __Pyx_INCREF(__pyx_v_py_ustring);
    __pyx_r = __pyx_v_py_ustring;
    goto __pyx_L0;

    /* "lupa/_lupa.pyx":1307
 *     else:
 *         py_ustring = s[:size].decode('ISO-8859-1')
 *     if err_message is None:             # <<<<<<<<<<<<<<
 *         return py_ustring
 *     else:
 */
  }

  /* "lupa/_lupa.pyx":1310
 *         return py_ustring
 *     else:
 *         return err_message % py_ustring             # <<<<<<<<<<<<<<
 * 
 * # calling into Lua
 */
  /*else*/ {
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_10 = __Pyx_PyUnicode_FormatSafe(__pyx_v_err_message, __pyx_v_py_ustring); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 1310, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_10);
    __pyx_r = __pyx_t_10;
    __pyx_t_10 = 0;
    goto __pyx_L0;
  }

  /* "lupa/_lupa.pyx":1297
 *         raise LuaError( build_lua_error_message(runtime, L, None, -1) )
 * 
 * cdef build_lua_error_message(LuaRuntime runtime, lua_State* L, unicode err_message, int n):             # <<<<<<<<<<<<<<
 *     cdef size_t size = 0
 *     cdef const char *s = lua.lua_tolstring(L, n, &size)
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_XDECREF(__pyx_t_9);
  __Pyx_XDECREF(__pyx_t_10);
  __Pyx_XDECREF(__pyx_t_11);
  __Pyx_AddTraceback("lupa._lupa.build_lua_error_message", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_py_ustring);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lupa/_lupa.pyx":1314
 * # calling into Lua
 * 
 * cdef run_lua(LuaRuntime runtime, bytes lua_code, tuple args):             # <<<<<<<<<<<<<<
 *     # locks the runtime
 *     cdef lua_State* L = runtime._state
 */

static PyObject *__pyx_f_4lupa_5_lupa_run_lua(struct __pyx_obj_4lupa_5_lupa_LuaRuntime *__pyx_v_runtime, PyObject *__pyx_v_lua_code, PyObject *__pyx_v_args) {
  lua_State *__pyx_v_L;
  int __pyx_v_old_top;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  lua_State *__pyx_t_1;
  int __pyx_t_2;
  char *__pyx_t_3;
  Py_ssize_t __pyx_t_4;
  int __pyx_t_5;
  PyObject *__pyx_t_6 = NULL;
  PyObject *__pyx_t_7 = NULL;
  PyObject *__pyx_t_8 = NULL;
  PyObject *__pyx_t_9 = NULL;
  int __pyx_t_10;
  char const *__pyx_t_11;
  PyObject *__pyx_t_12 = NULL;
  PyObject *__pyx_t_13 = NULL;
  PyObject *__pyx_t_14 = NULL;
  PyObject *__pyx_t_15 = NULL;
  PyObject *__pyx_t_16 = NULL;
  PyObject *__pyx_t_17 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("run_lua", 0);

  /* "lupa/_lupa.pyx":1316
 * cdef run_lua(LuaRuntime runtime, bytes lua_code, tuple args):
 *     # locks the runtime
 *     cdef lua_State* L = runtime._state             # <<<<<<<<<<<<<<
 *     cdef bint result
 *     lock_runtime(runtime)
 */
  __pyx_t_1 = __pyx_v_runtime->_state;
  __pyx_v_L = __pyx_t_1;

  /* "lupa/_lupa.pyx":1318
 *     cdef lua_State* L = runtime._state
 *     cdef bint result
 *     lock_runtime(runtime)             # <<<<<<<<<<<<<<
 *     old_top = lua.lua_gettop(L)
 *     try:
 */
  __pyx_t_2 = __pyx_f_4lupa_5_lupa_lock_runtime(__pyx_v_runtime); if (unlikely(__pyx_t_2 == ((int)-1))) __PYX_ERR(0, 1318, __pyx_L1_error)

  /* "lupa/_lupa.pyx":1319
 *     cdef bint result
 *     lock_runtime(runtime)
 *     old_top = lua.lua_gettop(L)             # <<<<<<<<<<<<<<
 *     try:
 *         if lua.luaL_loadbuffer(L, lua_code, len(lua_code), '<python>'):
 */
  __pyx_v_old_top = lua_gettop(__pyx_v_L);

  /* "lupa/_lupa.pyx":1320
 *     lock_runtime(runtime)
 *     old_top = lua.lua_gettop(L)
 *     try:             # <<<<<<<<<<<<<<
 *         if lua.luaL_loadbuffer(L, lua_code, len(lua_code), '<python>'):
 *             raise LuaSyntaxError(build_lua_error_message(
 */
  /*try:*/ {

    /* "lupa/_lupa.pyx":1321
 *     old_top = lua.lua_gettop(L)
 *     try:
 *         if lua.luaL_loadbuffer(L, lua_code, len(lua_code), '<python>'):             # <<<<<<<<<<<<<<
 *             raise LuaSyntaxError(build_lua_error_message(
 *                 runtime, L, u"error loading code: %s", -1))
 */
    if (unlikely(__pyx_v_lua_code == Py_None)) {
      PyErr_SetString(PyExc_TypeError, "expected bytes, NoneType found");
      __PYX_ERR(0, 1321, __pyx_L4_error)
    }
    __pyx_t_3 = __Pyx_PyBytes_AsWritableString(__pyx_v_lua_code); if (unlikely((!__pyx_t_3) && PyErr_Occurred())) __PYX_ERR(0, 1321, __pyx_L4_error)
    if (unlikely(__pyx_v_lua_code == Py_None)) {
      PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()");
      __PYX_ERR(0, 1321, __pyx_L4_error)
    }
    __pyx_t_4 = PyBytes_GET_SIZE(__pyx_v_lua_code); if (unlikely(__pyx_t_4 == ((Py_ssize_t)-1))) __PYX_ERR(0, 1321, __pyx_L4_error)
    __pyx_t_5 = (luaL_loadbuffer(__pyx_v_L, __pyx_t_3, __pyx_t_4, ((char *)"<python>")) != 0);
    if (unlikely(__pyx_t_5)) {

      /* "lupa/_lupa.pyx":1322
 *     try:
 *         if lua.luaL_loadbuffer(L, lua_code, len(lua_code), '<python>'):
 *             raise LuaSyntaxError(build_lua_error_message(             # <<<<<<<<<<<<<<
 *                 runtime, L, u"error loading code: %s", -1))
 *         return call_lua(runtime, L, args)
 */
      __Pyx_GetModuleGlobalName(__pyx_t_7, __pyx_n_s_LuaSyntaxError); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1322, __pyx_L4_error)
      __Pyx_GOTREF(__pyx_t_7);

      /* "lupa/_lupa.pyx":1323
 *         if lua.luaL_loadbuffer(L, lua_code, len(lua_code), '<python>'):
 *             raise LuaSyntaxError(build_lua_error_message(
 *                 runtime, L, u"error loading code: %s", -1))             # <<<<<<<<<<<<<<
 *         return call_lua(runtime, L, args)
 *     finally:
 */
      __pyx_t_8 = __pyx_f_4lupa_5_lupa_build_lua_error_message(__pyx_v_runtime, __pyx_v_L, __pyx_kp_u_error_loading_code_s, -1); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 1322, __pyx_L4_error)
      __Pyx_GOTREF(__pyx_t_8);
      __pyx_t_9 = NULL;
      if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_7))) {
        __pyx_t_9 = PyMethod_GET_SELF(__pyx_t_7);
        if (likely(__pyx_t_9)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_7);
          __Pyx_INCREF(__pyx_t_9);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_7, function);
        }
      }
      __pyx_t_6 = (__pyx_t_9) ? __Pyx_PyObject_Call2Args(__pyx_t_7, __pyx_t_9, __pyx_t_8) : __Pyx_PyObject_CallOneArg(__pyx_t_7, __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_6)) __PYX_ERR(0, 1322, __pyx_L4_error)
      __Pyx_GOTREF(__pyx_t_6);
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      __Pyx_Raise(__pyx_t_6, 0, 0, 0);
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      __PYX_ERR(0, 1322, __pyx_L4_error)

      /* "lupa/_lupa.pyx":1321
 *     old_top = lua.lua_gettop(L)
 *     try:
 *         if lua.luaL_loadbuffer(L, lua_code, len(lua_code), '<python>'):             # <<<<<<<<<<<<<<
 *             raise LuaSyntaxError(build_lua_error_message(
 *                 runtime, L, u"error loading code: %s", -1))
 */
    }

    /* "lupa/_lupa.pyx":1324
 *             raise LuaSyntaxError(build_lua_error_message(
 *                 runtime, L, u"error loading code: %s", -1))
 *         return call_lua(runtime, L, args)             # <<<<<<<<<<<<<<
 *     finally:
 *         lua.lua_settop(L, old_top)
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_6 = __pyx_f_4lupa_5_lupa_call_lua(__pyx_v_runtime, __pyx_v_L, __pyx_v_args); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1324, __pyx_L4_error)
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_r = __pyx_t_6;
    __pyx_t_6 = 0;
    goto __pyx_L3_return;
  }

  /* "lupa/_lupa.pyx":1326
 *         return call_lua(runtime, L, args)
 *     finally:
 *         lua.lua_settop(L, old_top)             # <<<<<<<<<<<<<<
 *         unlock_runtime(runtime)
 * 
 */
  /*finally:*/ {
    __pyx_L4_error:;
    /*exception exit:*/{
      __Pyx_PyThreadState_declare
      __Pyx_PyThreadState_assign
      __pyx_t_12 = 0; __pyx_t_13 = 0; __pyx_t_14 = 0; __pyx_t_15 = 0; __pyx_t_16 = 0; __pyx_t_17 = 0;
      __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
      __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
      __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
      __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
      if (PY_MAJOR_VERSION >= 3) __Pyx_ExceptionSwap(&__pyx_t_15, &__pyx_t_16, &__pyx_t_17);
      if ((PY_MAJOR_VERSION < 3) || unlikely(__Pyx_GetException(&__pyx_t_12, &__pyx_t_13, &__pyx_t_14) < 0)) __Pyx_ErrFetch(&__pyx_t_12, &__pyx_t_13, &__pyx_t_14);
      __Pyx_XGOTREF(__pyx_t_12);
      __Pyx_XGOTREF(__pyx_t_13);
      __Pyx_XGOTREF(__pyx_t_14);
      __Pyx_XGOTREF(__pyx_t_15);
      __Pyx_XGOTREF(__pyx_t_16);
      __Pyx_XGOTREF(__pyx_t_17);
      __pyx_t_2 = __pyx_lineno; __pyx_t_10 = __pyx_clineno; __pyx_t_11 = __pyx_filename;
      {
        lua_settop(__pyx_v_L, __pyx_v_old_top);

        /* "lupa/_lupa.pyx":1327
 *     finally:
 *         lua.lua_settop(L, old_top)
 *         unlock_runtime(runtime)             # <<<<<<<<<<<<<<
 * 
 * cdef call_lua(LuaRuntime runtime, lua_State *L, tuple args):
 */
        __pyx_f_4lupa_5_lupa_unlock_runtime(__pyx_v_runtime);
      }
      if (PY_MAJOR_VERSION >= 3) {
        __Pyx_XGIVEREF(__pyx_t_15);
        __Pyx_XGIVEREF(__pyx_t_16);
        __Pyx_XGIVEREF(__pyx_t_17);
        __Pyx_ExceptionReset(__pyx_t_15, __pyx_t_16, __pyx_t_17);
      }
      __Pyx_XGIVEREF(__pyx_t_12);
      __Pyx_XGIVEREF(__pyx_t_13);
      __Pyx_XGIVEREF(__pyx_t_14);
      __Pyx_ErrRestore(__pyx_t_12, __pyx_t_13, __pyx_t_14);
      __pyx_t_12 = 0; __pyx_t_13 = 0; __pyx_t_14 = 0; __pyx_t_15 = 0; __pyx_t_16 = 0; __pyx_t_17 = 0;
      __pyx_lineno = __pyx_t_2; __pyx_clineno = __pyx_t_10; __pyx_filename = __pyx_t_11;
      goto __pyx_L1_error;
    }
    __pyx_L3_return: {
      __pyx_t_17 = __pyx_r;
      __pyx_r = 0;

      /* "lupa/_lupa.pyx":1326
 *         return call_lua(runtime, L, args)
 *     finally:
 *         lua.lua_settop(L, old_top)             # <<<<<<<<<<<<<<
 *         unlock_runtime(runtime)
 * 
 */
      lua_settop(__pyx_v_L, __pyx_v_old_top);

      /* "lupa/_lupa.pyx":1327
 *     finally:
 *         lua.lua_settop(L, old_top)
 *         unlock_runtime(runtime)             # <<<<<<<<<<<<<<
 * 
 * cdef call_lua(LuaRuntime runtime, lua_State *L, tuple args):
 */
      __pyx_f_4lupa_5_lupa_unlock_runtime(__pyx_v_runtime);
      __pyx_r = __pyx_t_17;
      __pyx_t_17 = 0;
      goto __pyx_L0;
    }
  }

  /* "lupa/_lupa.pyx":1314
 * # calling into Lua
 * 
 * cdef run_lua(LuaRuntime runtime, bytes lua_code, tuple args):             # <<<<<<<<<<<<<<
 *     # locks the runtime
 *     cdef lua_State* L = runtime._state
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_XDECREF(__pyx_t_9);
  __Pyx_AddTraceback("lupa._lupa.run_lua", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lupa/_lupa.pyx":1329
 *         unlock_runtime(runtime)
 * 
 * cdef call_lua(LuaRuntime runtime, lua_State *L, tuple args):             # <<<<<<<<<<<<<<
 *     # does not lock the runtime!
 *     # does not clean up the stack!
 */

static PyObject *__pyx_f_4lupa_5_lupa_call_lua(struct __pyx_obj_4lupa_5_lupa_LuaRuntime *__pyx_v_runtime, lua_State *__pyx_v_L, PyObject *__pyx_v_args) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  Py_ssize_t __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("call_lua", 0);

  /* "lupa/_lupa.pyx":1332
 *     # does not lock the runtime!
 *     # does not clean up the stack!
 *     push_lua_arguments(runtime, L, args)             # <<<<<<<<<<<<<<
 *     return execute_lua_call(runtime, L, len(args))
 * 
 */
  __pyx_t_1 = __pyx_f_4lupa_5_lupa_push_lua_arguments(__pyx_v_runtime, __pyx_v_L, __pyx_v_args, NULL); if (unlikely(__pyx_t_1 == ((int)-1))) __PYX_ERR(0, 1332, __pyx_L1_error)

  /* "lupa/_lupa.pyx":1333
 *     # does not clean up the stack!
 *     push_lua_arguments(runtime, L, args)
 *     return execute_lua_call(runtime, L, len(args))             # <<<<<<<<<<<<<<
 * 
 * cdef object execute_lua_call(LuaRuntime runtime, lua_State *L, Py_ssize_t nargs):
 */
  __Pyx_XDECREF(__pyx_r);
  if (unlikely(__pyx_v_args == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()");
    __PYX_ERR(0, 1333, __pyx_L1_error)
  }
  __pyx_t_2 = PyTuple_GET_SIZE(__pyx_v_args); if (unlikely(__pyx_t_2 == ((Py_ssize_t)-1))) __PYX_ERR(0, 1333, __pyx_L1_error)
  __pyx_t_3 = __pyx_f_4lupa_5_lupa_execute_lua_call(__pyx_v_runtime, __pyx_v_L, __pyx_t_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1333, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_r = __pyx_t_3;
  __pyx_t_3 = 0;
  goto __pyx_L0;

  /* "lupa/_lupa.pyx":1329
 *         unlock_runtime(runtime)
 * 
 * cdef call_lua(LuaRuntime runtime, lua_State *L, tuple args):             # <<<<<<<<<<<<<<
 *     # does not lock the runtime!
 *     # does not clean up the stack!
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("lupa._lupa.call_lua", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lupa/_lupa.pyx":1335
 *     return execute_lua_call(runtime, L, len(args))
 * 
 * cdef object execute_lua_call(LuaRuntime runtime, lua_State *L, Py_ssize_t nargs):             # <<<<<<<<<<<<<<
 *     cdef int result_status
 *     cdef object result
 */

static PyObject *__pyx_f_4lupa_5_lupa_execute_lua_call(struct __pyx_obj_4lupa_5_lupa_LuaRuntime *__pyx_v_runtime, lua_State *__pyx_v_L, Py_ssize_t __pyx_v_nargs) {
  int __pyx_v_result_status;
  int __pyx_v_errfunc;
  PyObject *__pyx_v_results = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  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("execute_lua_call", 0);

  /* "lupa/_lupa.pyx":1339
 *     cdef object result
 *     # call into Lua
 *     cdef int errfunc = 0             # <<<<<<<<<<<<<<
 *     with nogil:
 *         lua.lua_getglobal(L, "debug")
 */
  __pyx_v_errfunc = 0;

  /* "lupa/_lupa.pyx":1340
 *     # call into Lua
 *     cdef int errfunc = 0
 *     with nogil:             # <<<<<<<<<<<<<<
 *         lua.lua_getglobal(L, "debug")
 *         if not lua.lua_istable(L, -1):
 */
  {
      #ifdef WITH_THREAD
      PyThreadState *_save;
      Py_UNBLOCK_THREADS
      __Pyx_FastGIL_Remember();
      #endif
      /*try:*/ {

        /* "lupa/_lupa.pyx":1341
 *     cdef int errfunc = 0
 *     with nogil:
 *         lua.lua_getglobal(L, "debug")             # <<<<<<<<<<<<<<
 *         if not lua.lua_istable(L, -1):
 *             lua.lua_pop(L, 1)
 */
        lua_getglobal(__pyx_v_L, ((char *)"debug"));

        /* "lupa/_lupa.pyx":1342
 *     with nogil:
 *         lua.lua_getglobal(L, "debug")
 *         if not lua.lua_istable(L, -1):             # <<<<<<<<<<<<<<
 *             lua.lua_pop(L, 1)
 *         else:
 */
        __pyx_t_1 = ((!(lua_istable(__pyx_v_L, -1) != 0)) != 0);
        if (__pyx_t_1) {

          /* "lupa/_lupa.pyx":1343
 *         lua.lua_getglobal(L, "debug")
 *         if not lua.lua_istable(L, -1):
 *             lua.lua_pop(L, 1)             # <<<<<<<<<<<<<<
 *         else:
 *             lua.lua_getfield(L, -1, "traceback")
 */
          lua_pop(__pyx_v_L, 1);

          /* "lupa/_lupa.pyx":1342
 *     with nogil:
 *         lua.lua_getglobal(L, "debug")
 *         if not lua.lua_istable(L, -1):             # <<<<<<<<<<<<<<
 *             lua.lua_pop(L, 1)
 *         else:
 */
          goto __pyx_L6;
        }

        /* "lupa/_lupa.pyx":1345
 *             lua.lua_pop(L, 1)
 *         else:
 *             lua.lua_getfield(L, -1, "traceback")             # <<<<<<<<<<<<<<
 *             if not lua.lua_isfunction(L, -1):
 *                 lua.lua_pop(L, 2)
 */
        /*else*/ {
          lua_getfield(__pyx_v_L, -1, ((char *)"traceback"));

          /* "lupa/_lupa.pyx":1346
 *         else:
 *             lua.lua_getfield(L, -1, "traceback")
 *             if not lua.lua_isfunction(L, -1):             # <<<<<<<<<<<<<<
 *                 lua.lua_pop(L, 2)
 *             else:
 */
          __pyx_t_1 = ((!(lua_isfunction(__pyx_v_L, -1) != 0)) != 0);
          if (__pyx_t_1) {

            /* "lupa/_lupa.pyx":1347
 *             lua.lua_getfield(L, -1, "traceback")
 *             if not lua.lua_isfunction(L, -1):
 *                 lua.lua_pop(L, 2)             # <<<<<<<<<<<<<<
 *             else:
 *                 lua.lua_replace(L, -2)
 */
            lua_pop(__pyx_v_L, 2);

            /* "lupa/_lupa.pyx":1346
 *         else:
 *             lua.lua_getfield(L, -1, "traceback")
 *             if not lua.lua_isfunction(L, -1):             # <<<<<<<<<<<<<<
 *                 lua.lua_pop(L, 2)
 *             else:
 */
            goto __pyx_L7;
          }

          /* "lupa/_lupa.pyx":1349
 *                 lua.lua_pop(L, 2)
 *             else:
 *                 lua.lua_replace(L, -2)             # <<<<<<<<<<<<<<
 *                 lua.lua_insert(L, 1)
 *                 errfunc = 1
 */
          /*else*/ {
            lua_replace(__pyx_v_L, -2);

            /* "lupa/_lupa.pyx":1350
 *             else:
 *                 lua.lua_replace(L, -2)
 *                 lua.lua_insert(L, 1)             # <<<<<<<<<<<<<<
 *                 errfunc = 1
 *         result_status = lua.lua_pcall(L, nargs, lua.LUA_MULTRET, errfunc)
 */
            lua_insert(__pyx_v_L, 1);

            /* "lupa/_lupa.pyx":1351
 *                 lua.lua_replace(L, -2)
 *                 lua.lua_insert(L, 1)
 *                 errfunc = 1             # <<<<<<<<<<<<<<
 *         result_status = lua.lua_pcall(L, nargs, lua.LUA_MULTRET, errfunc)
 *         if errfunc:
 */
            __pyx_v_errfunc = 1;
          }
          __pyx_L7:;
        }
        __pyx_L6:;

        /* "lupa/_lupa.pyx":1352
 *                 lua.lua_insert(L, 1)
 *                 errfunc = 1
 *         result_status = lua.lua_pcall(L, nargs, lua.LUA_MULTRET, errfunc)             # <<<<<<<<<<<<<<
 *         if errfunc:
 *             lua.lua_remove(L, 1)
 */
        __pyx_v_result_status = lua_pcall(__pyx_v_L, __pyx_v_nargs, LUA_MULTRET, __pyx_v_errfunc);

        /* "lupa/_lupa.pyx":1353
 *                 errfunc = 1
 *         result_status = lua.lua_pcall(L, nargs, lua.LUA_MULTRET, errfunc)
 *         if errfunc:             # <<<<<<<<<<<<<<
 *             lua.lua_remove(L, 1)
 *     results = unpack_lua_results(runtime, L)
 */
        __pyx_t_1 = (__pyx_v_errfunc != 0);
        if (__pyx_t_1) {

          /* "lupa/_lupa.pyx":1354
 *         result_status = lua.lua_pcall(L, nargs, lua.LUA_MULTRET, errfunc)
 *         if errfunc:
 *             lua.lua_remove(L, 1)             # <<<<<<<<<<<<<<
 *     results = unpack_lua_results(runtime, L)
 *     if result_status:
 */
          lua_remove(__pyx_v_L, 1);

          /* "lupa/_lupa.pyx":1353
 *                 errfunc = 1
 *         result_status = lua.lua_pcall(L, nargs, lua.LUA_MULTRET, errfunc)
 *         if errfunc:             # <<<<<<<<<<<<<<
 *             lua.lua_remove(L, 1)
 *     results = unpack_lua_results(runtime, L)
 */
        }
      }

      /* "lupa/_lupa.pyx":1340
 *     # call into Lua
 *     cdef int errfunc = 0
 *     with nogil:             # <<<<<<<<<<<<<<
 *         lua.lua_getglobal(L, "debug")
 *         if not lua.lua_istable(L, -1):
 */
      /*finally:*/ {
        /*normal exit:*/{
          #ifdef WITH_THREAD
          __Pyx_FastGIL_Forget();
          Py_BLOCK_THREADS
          #endif
          goto __pyx_L5;
        }
        __pyx_L5:;
      }
  }

  /* "lupa/_lupa.pyx":1355
 *         if errfunc:
 *             lua.lua_remove(L, 1)
 *     results = unpack_lua_results(runtime, L)             # <<<<<<<<<<<<<<
 *     if result_status:
 *         if isinstance(results, BaseException):
 */
  __pyx_t_2 = __pyx_f_4lupa_5_lupa_unpack_lua_results(__pyx_v_runtime, __pyx_v_L); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1355, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_v_results = __pyx_t_2;
  __pyx_t_2 = 0;

  /* "lupa/_lupa.pyx":1356
 *             lua.lua_remove(L, 1)
 *     results = unpack_lua_results(runtime, L)
 *     if result_status:             # <<<<<<<<<<<<<<
 *         if isinstance(results, BaseException):
 *             runtime.reraise_on_exception()
 */
  __pyx_t_1 = (__pyx_v_result_status != 0);
  if (__pyx_t_1) {

    /* "lupa/_lupa.pyx":1357
 *     results = unpack_lua_results(runtime, L)
 *     if result_status:
 *         if isinstance(results, BaseException):             # <<<<<<<<<<<<<<
 *             runtime.reraise_on_exception()
 *         raise_lua_error(runtime, L, result_status)
 */
    __pyx_t_1 = PyObject_IsInstance(__pyx_v_results, __pyx_builtin_BaseException); if (unlikely(__pyx_t_1 == ((int)-1))) __PYX_ERR(0, 1357, __pyx_L1_error)
    __pyx_t_3 = (__pyx_t_1 != 0);
    if (__pyx_t_3) {

      /* "lupa/_lupa.pyx":1358
 *     if result_status:
 *         if isinstance(results, BaseException):
 *             runtime.reraise_on_exception()             # <<<<<<<<<<<<<<
 *         raise_lua_error(runtime, L, result_status)
 *     return results
 */
      __pyx_t_4 = __pyx_f_4lupa_5_lupa_10LuaRuntime_reraise_on_exception(__pyx_v_runtime); if (unlikely(__pyx_t_4 == ((int)-1))) __PYX_ERR(0, 1358, __pyx_L1_error)

      /* "lupa/_lupa.pyx":1357
 *     results = unpack_lua_results(runtime, L)
 *     if result_status:
 *         if isinstance(results, BaseException):             # <<<<<<<<<<<<<<
 *             runtime.reraise_on_exception()
 *         raise_lua_error(runtime, L, result_status)
 */
    }

    /* "lupa/_lupa.pyx":1359
 *         if isinstance(results, BaseException):
 *             runtime.reraise_on_exception()
 *         raise_lua_error(runtime, L, result_status)             # <<<<<<<<<<<<<<
 *     return results
 * 
 */
    __pyx_t_4 = __pyx_f_4lupa_5_lupa_raise_lua_error(__pyx_v_runtime, __pyx_v_L, __pyx_v_result_status); if (unlikely(__pyx_t_4 == ((int)-1))) __PYX_ERR(0, 1359, __pyx_L1_error)

    /* "lupa/_lupa.pyx":1356
 *             lua.lua_remove(L, 1)
 *     results = unpack_lua_results(runtime, L)
 *     if result_status:             # <<<<<<<<<<<<<<
 *         if isinstance(results, BaseException):
 *             runtime.reraise_on_exception()
 */
  }

  /* "lupa/_lupa.pyx":1360
 *             runtime.reraise_on_exception()
 *         raise_lua_error(runtime, L, result_status)
 *     return results             # <<<<<<<<<<<<<<
 * 
 * cdef int push_lua_arguments(LuaRuntime runtime, lua_State *L,
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v_results);
  __pyx_r = __pyx_v_results;
  goto __pyx_L0;

  /* "lupa/_lupa.pyx":1335
 *     return execute_lua_call(runtime, L, len(args))
 * 
 * cdef object execute_lua_call(LuaRuntime runtime, lua_State *L, Py_ssize_t nargs):             # <<<<<<<<<<<<<<
 *     cdef int result_status
 *     cdef object result
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_AddTraceback("lupa._lupa.execute_lua_call", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_results);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lupa/_lupa.pyx":1362
 *     return results
 * 
 * cdef int push_lua_arguments(LuaRuntime runtime, lua_State *L,             # <<<<<<<<<<<<<<
 *                             tuple args, bint first_may_be_nil=True) except -1:
 *     cdef int i
 */

static int __pyx_f_4lupa_5_lupa_push_lua_arguments(struct __pyx_obj_4lupa_5_lupa_LuaRuntime *__pyx_v_runtime, lua_State *__pyx_v_L, PyObject *__pyx_v_args, struct __pyx_opt_args_4lupa_5_lupa_push_lua_arguments *__pyx_optional_args) {

  /* "lupa/_lupa.pyx":1363
 * 
 * cdef int push_lua_arguments(LuaRuntime runtime, lua_State *L,
 *                             tuple args, bint first_may_be_nil=True) except -1:             # <<<<<<<<<<<<<<
 *     cdef int i
 *     if args:
 */
  int __pyx_v_first_may_be_nil = ((int)1);
  int __pyx_v_i;
  int __pyx_v_old_top;
  PyObject *__pyx_v_arg = NULL;
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  int __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  Py_ssize_t __pyx_t_4;
  PyObject *__pyx_t_5 = NULL;
  int __pyx_t_6;
  struct __pyx_opt_args_4lupa_5_lupa_py_to_lua __pyx_t_7;
  PyObject *__pyx_t_8 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("push_lua_arguments", 0);
  if (__pyx_optional_args) {
    if (__pyx_optional_args->__pyx_n > 0) {
      __pyx_v_first_may_be_nil = __pyx_optional_args->first_may_be_nil;
    }
  }

  /* "lupa/_lupa.pyx":1365
 *                             tuple args, bint first_may_be_nil=True) except -1:
 *     cdef int i
 *     if args:             # <<<<<<<<<<<<<<
 *         old_top = lua.lua_gettop(L)
 *         for i, arg in enumerate(args):
 */
  __pyx_t_1 = (__pyx_v_args != Py_None)&&(PyTuple_GET_SIZE(__pyx_v_args) != 0);
  if (__pyx_t_1) {

    /* "lupa/_lupa.pyx":1366
 *     cdef int i
 *     if args:
 *         old_top = lua.lua_gettop(L)             # <<<<<<<<<<<<<<
 *         for i, arg in enumerate(args):
 *             if not py_to_lua(runtime, L, arg, wrap_none=not first_may_be_nil):
 */
    __pyx_v_old_top = lua_gettop(__pyx_v_L);

    /* "lupa/_lupa.pyx":1367
 *     if args:
 *         old_top = lua.lua_gettop(L)
 *         for i, arg in enumerate(args):             # <<<<<<<<<<<<<<
 *             if not py_to_lua(runtime, L, arg, wrap_none=not first_may_be_nil):
 *                 lua.lua_settop(L, old_top)
 */
    __pyx_t_2 = 0;
    __pyx_t_3 = __pyx_v_args; __Pyx_INCREF(__pyx_t_3); __pyx_t_4 = 0;
    for (;;) {
      if (__pyx_t_4 >= PyTuple_GET_SIZE(__pyx_t_3)) break;
      #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
      __pyx_t_5 = PyTuple_GET_ITEM(__pyx_t_3, __pyx_t_4); __Pyx_INCREF(__pyx_t_5); __pyx_t_4++; if (unlikely(0 < 0)) __PYX_ERR(0, 1367, __pyx_L1_error)
      #else
      __pyx_t_5 = PySequence_ITEM(__pyx_t_3, __pyx_t_4); __pyx_t_4++; if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1367, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
      #endif
      __Pyx_XDECREF_SET(__pyx_v_arg, __pyx_t_5);
      __pyx_t_5 = 0;
      __pyx_v_i = __pyx_t_2;
      __pyx_t_2 = (__pyx_t_2 + 1);

      /* "lupa/_lupa.pyx":1368
 *         old_top = lua.lua_gettop(L)
 *         for i, arg in enumerate(args):
 *             if not py_to_lua(runtime, L, arg, wrap_none=not first_may_be_nil):             # <<<<<<<<<<<<<<
 *                 lua.lua_settop(L, old_top)
 *                 raise TypeError("failed to convert argument at index %d" % i)
 */
      __pyx_t_7.__pyx_n = 1;
      __pyx_t_7.wrap_none = (!(__pyx_v_first_may_be_nil != 0));
      __pyx_t_6 = __pyx_f_4lupa_5_lupa_py_to_lua(__pyx_v_runtime, __pyx_v_L, __pyx_v_arg, &__pyx_t_7); if (unlikely(__pyx_t_6 == ((int)-1))) __PYX_ERR(0, 1368, __pyx_L1_error)
      __pyx_t_1 = ((!(__pyx_t_6 != 0)) != 0);
      if (unlikely(__pyx_t_1)) {

        /* "lupa/_lupa.pyx":1369
 *         for i, arg in enumerate(args):
 *             if not py_to_lua(runtime, L, arg, wrap_none=not first_may_be_nil):
 *                 lua.lua_settop(L, old_top)             # <<<<<<<<<<<<<<
 *                 raise TypeError("failed to convert argument at index %d" % i)
 *             first_may_be_nil = True
 */
        lua_settop(__pyx_v_L, __pyx_v_old_top);

        /* "lupa/_lupa.pyx":1370
 *             if not py_to_lua(runtime, L, arg, wrap_none=not first_may_be_nil):
 *                 lua.lua_settop(L, old_top)
 *                 raise TypeError("failed to convert argument at index %d" % i)             # <<<<<<<<<<<<<<
 *             first_may_be_nil = True
 *     return 0
 */
        __pyx_t_5 = __Pyx_PyInt_From_int(__pyx_v_i); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1370, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_5);
        __pyx_t_8 = __Pyx_PyString_Format(__pyx_kp_s_failed_to_convert_argument_at_in, __pyx_t_5); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 1370, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_8);
        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
        __pyx_t_5 = __Pyx_PyObject_CallOneArg(__pyx_builtin_TypeError, __pyx_t_8); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1370, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_5);
        __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
        __Pyx_Raise(__pyx_t_5, 0, 0, 0);
        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
        __PYX_ERR(0, 1370, __pyx_L1_error)

        /* "lupa/_lupa.pyx":1368
 *         old_top = lua.lua_gettop(L)
 *         for i, arg in enumerate(args):
 *             if not py_to_lua(runtime, L, arg, wrap_none=not first_may_be_nil):             # <<<<<<<<<<<<<<
 *                 lua.lua_settop(L, old_top)
 *                 raise TypeError("failed to convert argument at index %d" % i)
 */
      }

      /* "lupa/_lupa.pyx":1371
 *                 lua.lua_settop(L, old_top)
 *                 raise TypeError("failed to convert argument at index %d" % i)
 *             first_may_be_nil = True             # <<<<<<<<<<<<<<
 *     return 0
 * 
 */
      __pyx_v_first_may_be_nil = 1;

      /* "lupa/_lupa.pyx":1367
 *     if args:
 *         old_top = lua.lua_gettop(L)
 *         for i, arg in enumerate(args):             # <<<<<<<<<<<<<<
 *             if not py_to_lua(runtime, L, arg, wrap_none=not first_may_be_nil):
 *                 lua.lua_settop(L, old_top)
 */
    }
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

    /* "lupa/_lupa.pyx":1365
 *                             tuple args, bint first_may_be_nil=True) except -1:
 *     cdef int i
 *     if args:             # <<<<<<<<<<<<<<
 *         old_top = lua.lua_gettop(L)
 *         for i, arg in enumerate(args):
 */
  }

  /* "lupa/_lupa.pyx":1372
 *                 raise TypeError("failed to convert argument at index %d" % i)
 *             first_may_be_nil = True
 *     return 0             # <<<<<<<<<<<<<<
 * 
 * cdef inline object unpack_lua_results(LuaRuntime runtime, lua_State *L):
 */
  __pyx_r = 0;
  goto __pyx_L0;

  /* "lupa/_lupa.pyx":1362
 *     return results
 * 
 * cdef int push_lua_arguments(LuaRuntime runtime, lua_State *L,             # <<<<<<<<<<<<<<
 *                             tuple args, bint first_may_be_nil=True) except -1:
 *     cdef int i
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_AddTraceback("lupa._lupa.push_lua_arguments", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_arg);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lupa/_lupa.pyx":1374
 *     return 0
 * 
 * cdef inline object unpack_lua_results(LuaRuntime runtime, lua_State *L):             # <<<<<<<<<<<<<<
 *     cdef int nargs = lua.lua_gettop(L)
 *     if nargs == 1:
 */

static CYTHON_INLINE PyObject *__pyx_f_4lupa_5_lupa_unpack_lua_results(struct __pyx_obj_4lupa_5_lupa_LuaRuntime *__pyx_v_runtime, lua_State *__pyx_v_L) {
  int __pyx_v_nargs;
  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("unpack_lua_results", 0);

  /* "lupa/_lupa.pyx":1375
 * 
 * cdef inline object unpack_lua_results(LuaRuntime runtime, lua_State *L):
 *     cdef int nargs = lua.lua_gettop(L)             # <<<<<<<<<<<<<<
 *     if nargs == 1:
 *         return py_from_lua(runtime, L, 1)
 */
  __pyx_v_nargs = lua_gettop(__pyx_v_L);

  /* "lupa/_lupa.pyx":1376
 * cdef inline object unpack_lua_results(LuaRuntime runtime, lua_State *L):
 *     cdef int nargs = lua.lua_gettop(L)
 *     if nargs == 1:             # <<<<<<<<<<<<<<
 *         return py_from_lua(runtime, L, 1)
 *     if nargs == 0:
 */
  __pyx_t_1 = ((__pyx_v_nargs == 1) != 0);
  if (__pyx_t_1) {

    /* "lupa/_lupa.pyx":1377
 *     cdef int nargs = lua.lua_gettop(L)
 *     if nargs == 1:
 *         return py_from_lua(runtime, L, 1)             # <<<<<<<<<<<<<<
 *     if nargs == 0:
 *         return None
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_2 = __pyx_f_4lupa_5_lupa_py_from_lua(__pyx_v_runtime, __pyx_v_L, 1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1377, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_r = __pyx_t_2;
    __pyx_t_2 = 0;
    goto __pyx_L0;

    /* "lupa/_lupa.pyx":1376
 * cdef inline object unpack_lua_results(LuaRuntime runtime, lua_State *L):
 *     cdef int nargs = lua.lua_gettop(L)
 *     if nargs == 1:             # <<<<<<<<<<<<<<
 *         return py_from_lua(runtime, L, 1)
 *     if nargs == 0:
 */
  }

  /* "lupa/_lupa.pyx":1378
 *     if nargs == 1:
 *         return py_from_lua(runtime, L, 1)
 *     if nargs == 0:             # <<<<<<<<<<<<<<
 *         return None
 *     return unpack_multiple_lua_results(runtime, L, nargs)
 */
  __pyx_t_1 = ((__pyx_v_nargs == 0) != 0);
  if (__pyx_t_1) {

    /* "lupa/_lupa.pyx":1379
 *         return py_from_lua(runtime, L, 1)
 *     if nargs == 0:
 *         return None             # <<<<<<<<<<<<<<
 *     return unpack_multiple_lua_results(runtime, L, nargs)
 * 
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_r = Py_None; __Pyx_INCREF(Py_None);
    goto __pyx_L0;

    /* "lupa/_lupa.pyx":1378
 *     if nargs == 1:
 *         return py_from_lua(runtime, L, 1)
 *     if nargs == 0:             # <<<<<<<<<<<<<<
 *         return None
 *     return unpack_multiple_lua_results(runtime, L, nargs)
 */
  }

  /* "lupa/_lupa.pyx":1380
 *     if nargs == 0:
 *         return None
 *     return unpack_multiple_lua_results(runtime, L, nargs)             # <<<<<<<<<<<<<<
 * 
 * cdef tuple unpack_multiple_lua_results(LuaRuntime runtime, lua_State *L, int nargs):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2 = __pyx_f_4lupa_5_lupa_unpack_multiple_lua_results(__pyx_v_runtime, __pyx_v_L, __pyx_v_nargs); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1380, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_r = __pyx_t_2;
  __pyx_t_2 = 0;
  goto __pyx_L0;

  /* "lupa/_lupa.pyx":1374
 *     return 0
 * 
 * cdef inline object unpack_lua_results(LuaRuntime runtime, lua_State *L):             # <<<<<<<<<<<<<<
 *     cdef int nargs = lua.lua_gettop(L)
 *     if nargs == 1:
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_AddTraceback("lupa._lupa.unpack_lua_results", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lupa/_lupa.pyx":1382
 *     return unpack_multiple_lua_results(runtime, L, nargs)
 * 
 * cdef tuple unpack_multiple_lua_results(LuaRuntime runtime, lua_State *L, int nargs):             # <<<<<<<<<<<<<<
 *     cdef tuple args = cpython.tuple.PyTuple_New(nargs)
 *     cdef int i
 */

static PyObject *__pyx_f_4lupa_5_lupa_unpack_multiple_lua_results(struct __pyx_obj_4lupa_5_lupa_LuaRuntime *__pyx_v_runtime, lua_State *__pyx_v_L, int __pyx_v_nargs) {
  PyObject *__pyx_v_args = 0;
  int __pyx_v_i;
  PyObject *__pyx_v_arg = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_t_2;
  int __pyx_t_3;
  int __pyx_t_4;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("unpack_multiple_lua_results", 0);

  /* "lupa/_lupa.pyx":1383
 * 
 * cdef tuple unpack_multiple_lua_results(LuaRuntime runtime, lua_State *L, int nargs):
 *     cdef tuple args = cpython.tuple.PyTuple_New(nargs)             # <<<<<<<<<<<<<<
 *     cdef int i
 *     for i in range(nargs):
 */
  __pyx_t_1 = PyTuple_New(__pyx_v_nargs); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1383, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_args = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "lupa/_lupa.pyx":1385
 *     cdef tuple args = cpython.tuple.PyTuple_New(nargs)
 *     cdef int i
 *     for i in range(nargs):             # <<<<<<<<<<<<<<
 *         arg = py_from_lua(runtime, L, i+1)
 *         cpython.ref.Py_INCREF(arg)
 */
  __pyx_t_2 = __pyx_v_nargs;
  __pyx_t_3 = __pyx_t_2;
  for (__pyx_t_4 = 0; __pyx_t_4 < __pyx_t_3; __pyx_t_4+=1) {
    __pyx_v_i = __pyx_t_4;

    /* "lupa/_lupa.pyx":1386
 *     cdef int i
 *     for i in range(nargs):
 *         arg = py_from_lua(runtime, L, i+1)             # <<<<<<<<<<<<<<
 *         cpython.ref.Py_INCREF(arg)
 *         cpython.tuple.PyTuple_SET_ITEM(args, i, arg)
 */
    __pyx_t_1 = __pyx_f_4lupa_5_lupa_py_from_lua(__pyx_v_runtime, __pyx_v_L, (__pyx_v_i + 1)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1386, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_XDECREF_SET(__pyx_v_arg, __pyx_t_1);
    __pyx_t_1 = 0;

    /* "lupa/_lupa.pyx":1387
 *     for i in range(nargs):
 *         arg = py_from_lua(runtime, L, i+1)
 *         cpython.ref.Py_INCREF(arg)             # <<<<<<<<<<<<<<
 *         cpython.tuple.PyTuple_SET_ITEM(args, i, arg)
 *     return args
 */
    Py_INCREF(__pyx_v_arg);

    /* "lupa/_lupa.pyx":1388
 *         arg = py_from_lua(runtime, L, i+1)
 *         cpython.ref.Py_INCREF(arg)
 *         cpython.tuple.PyTuple_SET_ITEM(args, i, arg)             # <<<<<<<<<<<<<<
 *     return args
 * 
 */
    PyTuple_SET_ITEM(__pyx_v_args, __pyx_v_i, __pyx_v_arg);
  }

  /* "lupa/_lupa.pyx":1389
 *         cpython.ref.Py_INCREF(arg)
 *         cpython.tuple.PyTuple_SET_ITEM(args, i, arg)
 *     return args             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v_args);
  __pyx_r = __pyx_v_args;
  goto __pyx_L0;

  /* "lupa/_lupa.pyx":1382
 *     return unpack_multiple_lua_results(runtime, L, nargs)
 * 
 * cdef tuple unpack_multiple_lua_results(LuaRuntime runtime, lua_State *L, int nargs):             # <<<<<<<<<<<<<<
 *     cdef tuple args = cpython.tuple.PyTuple_New(nargs)
 *     cdef int i
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("lupa._lupa.unpack_multiple_lua_results", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_args);
  __Pyx_XDECREF(__pyx_v_arg);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lupa/_lupa.pyx":1415
 * # ref-counting support for Python objects
 * 
 * cdef int decref_with_gil(py_object *py_obj, lua_State* L) with gil:             # <<<<<<<<<<<<<<
 *     # originally, we just used:
 *     #cpython.ref.Py_XDECREF(py_obj.obj)
 */

static int __pyx_f_4lupa_5_lupa_decref_with_gil(struct __pyx_t_4lupa_5_lupa_py_object *__pyx_v_py_obj, lua_State *__pyx_v_L) {
  struct __pyx_obj_4lupa_5_lupa_LuaRuntime *__pyx_v_runtime = NULL;
  PyObject *__pyx_v_obj_id = NULL;
  PyObject *__pyx_v_refs = NULL;
  int __pyx_r;
  __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;
  PyObject *__pyx_t_6 = NULL;
  PyObject *__pyx_t_7 = NULL;
  PyObject *__pyx_t_8 = NULL;
  int __pyx_t_9;
  PyObject *__pyx_t_10 = NULL;
  Py_ssize_t __pyx_t_11;
  int __pyx_t_12;
  PyObject *__pyx_t_13 = NULL;
  PyObject *__pyx_t_14 = NULL;
  PyObject *__pyx_t_15 = 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("decref_with_gil", 0);

  /* "lupa/_lupa.pyx":1419
 *     #cpython.ref.Py_XDECREF(py_obj.obj)
 *     # now, we keep Python object references in Lua visible to Python in a dict of lists:
 *     runtime = <LuaRuntime>py_obj.runtime             # <<<<<<<<<<<<<<
 *     try:
 *         obj_id = <object><uintptr_t>py_obj.obj
 */
  __pyx_t_1 = ((PyObject *)__pyx_v_py_obj->runtime);
  __Pyx_INCREF(__pyx_t_1);
  __pyx_v_runtime = ((struct __pyx_obj_4lupa_5_lupa_LuaRuntime *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "lupa/_lupa.pyx":1420
 *     # now, we keep Python object references in Lua visible to Python in a dict of lists:
 *     runtime = <LuaRuntime>py_obj.runtime
 *     try:             # <<<<<<<<<<<<<<
 *         obj_id = <object><uintptr_t>py_obj.obj
 *         try:
 */
  {
    __Pyx_PyThreadState_declare
    __Pyx_PyThreadState_assign
    __Pyx_ExceptionSave(&__pyx_t_2, &__pyx_t_3, &__pyx_t_4);
    __Pyx_XGOTREF(__pyx_t_2);
    __Pyx_XGOTREF(__pyx_t_3);
    __Pyx_XGOTREF(__pyx_t_4);
    /*try:*/ {

      /* "lupa/_lupa.pyx":1421
 *     runtime = <LuaRuntime>py_obj.runtime
 *     try:
 *         obj_id = <object><uintptr_t>py_obj.obj             # <<<<<<<<<<<<<<
 *         try:
 *             refs = <list>runtime._pyrefs_in_lua[obj_id]
 */
      __pyx_t_1 = __Pyx_PyInt_FromSize_t(((uintptr_t)__pyx_v_py_obj->obj)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1421, __pyx_L3_error)
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_5 = __pyx_t_1;
      __Pyx_INCREF(__pyx_t_5);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __pyx_v_obj_id = __pyx_t_5;
      __pyx_t_5 = 0;

      /* "lupa/_lupa.pyx":1422
 *     try:
 *         obj_id = <object><uintptr_t>py_obj.obj
 *         try:             # <<<<<<<<<<<<<<
 *             refs = <list>runtime._pyrefs_in_lua[obj_id]
 *         except (TypeError, KeyError):
 */
      {
        __Pyx_PyThreadState_declare
        __Pyx_PyThreadState_assign
        __Pyx_ExceptionSave(&__pyx_t_6, &__pyx_t_7, &__pyx_t_8);
        __Pyx_XGOTREF(__pyx_t_6);
        __Pyx_XGOTREF(__pyx_t_7);
        __Pyx_XGOTREF(__pyx_t_8);
        /*try:*/ {

          /* "lupa/_lupa.pyx":1423
 *         obj_id = <object><uintptr_t>py_obj.obj
 *         try:
 *             refs = <list>runtime._pyrefs_in_lua[obj_id]             # <<<<<<<<<<<<<<
 *         except (TypeError, KeyError):
 *             return 0  # runtime was already cleared during GC, nothing left to do
 */
          if (unlikely(__pyx_v_runtime->_pyrefs_in_lua == Py_None)) {
            PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
            __PYX_ERR(0, 1423, __pyx_L9_error)
          }
          __pyx_t_5 = __Pyx_PyDict_GetItem(__pyx_v_runtime->_pyrefs_in_lua, __pyx_v_obj_id); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1423, __pyx_L9_error)
          __Pyx_GOTREF(__pyx_t_5);
          __pyx_t_1 = __pyx_t_5;
          __Pyx_INCREF(__pyx_t_1);
          __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
          __pyx_v_refs = ((PyObject*)__pyx_t_1);
          __pyx_t_1 = 0;

          /* "lupa/_lupa.pyx":1422
 *     try:
 *         obj_id = <object><uintptr_t>py_obj.obj
 *         try:             # <<<<<<<<<<<<<<
 *             refs = <list>runtime._pyrefs_in_lua[obj_id]
 *         except (TypeError, KeyError):
 */
        }
        __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
        __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
        __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
        goto __pyx_L14_try_end;
        __pyx_L9_error:;
        __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
        __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;

        /* "lupa/_lupa.pyx":1424
 *         try:
 *             refs = <list>runtime._pyrefs_in_lua[obj_id]
 *         except (TypeError, KeyError):             # <<<<<<<<<<<<<<
 *             return 0  # runtime was already cleared during GC, nothing left to do
 *         if len(refs) == 1:
 */
        __pyx_t_9 = __Pyx_PyErr_ExceptionMatches(__pyx_builtin_TypeError) || __Pyx_PyErr_ExceptionMatches(__pyx_builtin_KeyError);
        if (__pyx_t_9) {
          __Pyx_AddTraceback("lupa._lupa.decref_with_gil", __pyx_clineno, __pyx_lineno, __pyx_filename);
          if (__Pyx_GetException(&__pyx_t_1, &__pyx_t_5, &__pyx_t_10) < 0) __PYX_ERR(0, 1424, __pyx_L11_except_error)
          __Pyx_GOTREF(__pyx_t_1);
          __Pyx_GOTREF(__pyx_t_5);
          __Pyx_GOTREF(__pyx_t_10);

          /* "lupa/_lupa.pyx":1425
 *             refs = <list>runtime._pyrefs_in_lua[obj_id]
 *         except (TypeError, KeyError):
 *             return 0  # runtime was already cleared during GC, nothing left to do             # <<<<<<<<<<<<<<
 *         if len(refs) == 1:
 *             del runtime._pyrefs_in_lua[obj_id]
 */
          __pyx_r = 0;
          __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
          __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
          __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
          goto __pyx_L12_except_return;
        }
        goto __pyx_L11_except_error;
        __pyx_L11_except_error:;

        /* "lupa/_lupa.pyx":1422
 *     try:
 *         obj_id = <object><uintptr_t>py_obj.obj
 *         try:             # <<<<<<<<<<<<<<
 *             refs = <list>runtime._pyrefs_in_lua[obj_id]
 *         except (TypeError, KeyError):
 */
        __Pyx_XGIVEREF(__pyx_t_6);
        __Pyx_XGIVEREF(__pyx_t_7);
        __Pyx_XGIVEREF(__pyx_t_8);
        __Pyx_ExceptionReset(__pyx_t_6, __pyx_t_7, __pyx_t_8);
        goto __pyx_L3_error;
        __pyx_L12_except_return:;
        __Pyx_XGIVEREF(__pyx_t_6);
        __Pyx_XGIVEREF(__pyx_t_7);
        __Pyx_XGIVEREF(__pyx_t_8);
        __Pyx_ExceptionReset(__pyx_t_6, __pyx_t_7, __pyx_t_8);
        goto __pyx_L7_try_return;
        __pyx_L14_try_end:;
      }

      /* "lupa/_lupa.pyx":1426
 *         except (TypeError, KeyError):
 *             return 0  # runtime was already cleared during GC, nothing left to do
 *         if len(refs) == 1:             # <<<<<<<<<<<<<<
 *             del runtime._pyrefs_in_lua[obj_id]
 *         else:
 */
      if (unlikely(__pyx_v_refs == Py_None)) {
        PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()");
        __PYX_ERR(0, 1426, __pyx_L3_error)
      }
      __pyx_t_11 = PyList_GET_SIZE(__pyx_v_refs); if (unlikely(__pyx_t_11 == ((Py_ssize_t)-1))) __PYX_ERR(0, 1426, __pyx_L3_error)
      __pyx_t_12 = ((__pyx_t_11 == 1) != 0);
      if (__pyx_t_12) {

        /* "lupa/_lupa.pyx":1427
 *             return 0  # runtime was already cleared during GC, nothing left to do
 *         if len(refs) == 1:
 *             del runtime._pyrefs_in_lua[obj_id]             # <<<<<<<<<<<<<<
 *         else:
 *             refs.pop()  # any, really
 */
        if (unlikely(__pyx_v_runtime->_pyrefs_in_lua == Py_None)) {
          PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
          __PYX_ERR(0, 1427, __pyx_L3_error)
        }
        if (unlikely(PyDict_DelItem(__pyx_v_runtime->_pyrefs_in_lua, __pyx_v_obj_id) < 0)) __PYX_ERR(0, 1427, __pyx_L3_error)

        /* "lupa/_lupa.pyx":1426
 *         except (TypeError, KeyError):
 *             return 0  # runtime was already cleared during GC, nothing left to do
 *         if len(refs) == 1:             # <<<<<<<<<<<<<<
 *             del runtime._pyrefs_in_lua[obj_id]
 *         else:
 */
        goto __pyx_L17;
      }

      /* "lupa/_lupa.pyx":1429
 *             del runtime._pyrefs_in_lua[obj_id]
 *         else:
 *             refs.pop()  # any, really             # <<<<<<<<<<<<<<
 *         return 0
 *     except:
 */
      /*else*/ {
        if (unlikely(__pyx_v_refs == Py_None)) {
          PyErr_Format(PyExc_AttributeError, "'NoneType' object has no attribute '%.30s'", "pop");
          __PYX_ERR(0, 1429, __pyx_L3_error)
        }
        __pyx_t_10 = __Pyx_PyList_Pop(__pyx_v_refs); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 1429, __pyx_L3_error)
        __Pyx_GOTREF(__pyx_t_10);
        __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
      }
      __pyx_L17:;

      /* "lupa/_lupa.pyx":1430
 *         else:
 *             refs.pop()  # any, really
 *         return 0             # <<<<<<<<<<<<<<
 *     except:
 *         try: runtime.store_raised_exception(L, b'error while cleaning up a Python object')
 */
      __pyx_r = 0;
      goto __pyx_L7_try_return;

      /* "lupa/_lupa.pyx":1420
 *     # now, we keep Python object references in Lua visible to Python in a dict of lists:
 *     runtime = <LuaRuntime>py_obj.runtime
 *     try:             # <<<<<<<<<<<<<<
 *         obj_id = <object><uintptr_t>py_obj.obj
 *         try:
 */
    }
    __pyx_L3_error:;
    __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
    __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;

    /* "lupa/_lupa.pyx":1431
 *             refs.pop()  # any, really
 *         return 0
 *     except:             # <<<<<<<<<<<<<<
 *         try: runtime.store_raised_exception(L, b'error while cleaning up a Python object')
 *         finally: return -1
 */
    /*except:*/ {
      __Pyx_AddTraceback("lupa._lupa.decref_with_gil", __pyx_clineno, __pyx_lineno, __pyx_filename);
      if (__Pyx_GetException(&__pyx_t_10, &__pyx_t_5, &__pyx_t_1) < 0) __PYX_ERR(0, 1431, __pyx_L5_except_error)
      __Pyx_GOTREF(__pyx_t_10);
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_GOTREF(__pyx_t_1);

      /* "lupa/_lupa.pyx":1432
 *         return 0
 *     except:
 *         try: runtime.store_raised_exception(L, b'error while cleaning up a Python object')             # <<<<<<<<<<<<<<
 *         finally: return -1
 * 
 */
      /*try:*/ {
        __pyx_t_9 = __pyx_f_4lupa_5_lupa_10LuaRuntime_store_raised_exception(__pyx_v_runtime, __pyx_v_L, __pyx_kp_b_error_while_cleaning_up_a_Python); if (unlikely(__pyx_t_9 == ((int)-1))) __PYX_ERR(0, 1432, __pyx_L23_error)
      }

      /* "lupa/_lupa.pyx":1433
 *     except:
 *         try: runtime.store_raised_exception(L, b'error while cleaning up a Python object')
 *         finally: return -1             # <<<<<<<<<<<<<<
 * 
 * cdef int py_object_gc(lua_State* L) nogil:
 */
      /*finally:*/ {
        /*normal exit:*/{
          __pyx_r = -1;
          __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
          __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
          __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
          goto __pyx_L6_except_return;
        }
        __pyx_L23_error:;
        /*exception exit:*/{
          __Pyx_PyThreadState_declare
          __Pyx_PyThreadState_assign
          __pyx_t_8 = 0; __pyx_t_7 = 0; __pyx_t_6 = 0; __pyx_t_13 = 0; __pyx_t_14 = 0; __pyx_t_15 = 0;
          if (PY_MAJOR_VERSION >= 3) __Pyx_ExceptionSwap(&__pyx_t_13, &__pyx_t_14, &__pyx_t_15);
          if ((PY_MAJOR_VERSION < 3) || unlikely(__Pyx_GetException(&__pyx_t_8, &__pyx_t_7, &__pyx_t_6) < 0)) __Pyx_ErrFetch(&__pyx_t_8, &__pyx_t_7, &__pyx_t_6);
          __Pyx_XGOTREF(__pyx_t_8);
          __Pyx_XGOTREF(__pyx_t_7);
          __Pyx_XGOTREF(__pyx_t_6);
          __Pyx_XGOTREF(__pyx_t_13);
          __Pyx_XGOTREF(__pyx_t_14);
          __Pyx_XGOTREF(__pyx_t_15);
          {
            __pyx_r = -1;
            __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
            __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
            __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
            goto __pyx_L27_return;
          }
          __pyx_L27_return:;
          if (PY_MAJOR_VERSION >= 3) {
            __Pyx_XGIVEREF(__pyx_t_13);
            __Pyx_XGIVEREF(__pyx_t_14);
            __Pyx_XGIVEREF(__pyx_t_15);
            __Pyx_ExceptionReset(__pyx_t_13, __pyx_t_14, __pyx_t_15);
          }
          __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
          __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
          __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
          __pyx_t_13 = 0; __pyx_t_14 = 0; __pyx_t_15 = 0;
          goto __pyx_L6_except_return;
        }
      }
    }
    __pyx_L5_except_error:;

    /* "lupa/_lupa.pyx":1420
 *     # now, we keep Python object references in Lua visible to Python in a dict of lists:
 *     runtime = <LuaRuntime>py_obj.runtime
 *     try:             # <<<<<<<<<<<<<<
 *         obj_id = <object><uintptr_t>py_obj.obj
 *         try:
 */
    __Pyx_XGIVEREF(__pyx_t_2);
    __Pyx_XGIVEREF(__pyx_t_3);
    __Pyx_XGIVEREF(__pyx_t_4);
    __Pyx_ExceptionReset(__pyx_t_2, __pyx_t_3, __pyx_t_4);
    goto __pyx_L1_error;
    __pyx_L7_try_return:;
    __Pyx_XGIVEREF(__pyx_t_2);
    __Pyx_XGIVEREF(__pyx_t_3);
    __Pyx_XGIVEREF(__pyx_t_4);
    __Pyx_ExceptionReset(__pyx_t_2, __pyx_t_3, __pyx_t_4);
    goto __pyx_L0;
    __pyx_L6_except_return:;
    __Pyx_XGIVEREF(__pyx_t_2);
    __Pyx_XGIVEREF(__pyx_t_3);
    __Pyx_XGIVEREF(__pyx_t_4);
    __Pyx_ExceptionReset(__pyx_t_2, __pyx_t_3, __pyx_t_4);
    goto __pyx_L0;
  }

  /* "lupa/_lupa.pyx":1415
 * # ref-counting support for Python objects
 * 
 * cdef int decref_with_gil(py_object *py_obj, lua_State* L) with gil:             # <<<<<<<<<<<<<<
 *     # originally, we just used:
 *     #cpython.ref.Py_XDECREF(py_obj.obj)
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_10);
  __Pyx_WriteUnraisable("lupa._lupa.decref_with_gil", __pyx_clineno, __pyx_lineno, __pyx_filename, 1, 0);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_runtime);
  __Pyx_XDECREF(__pyx_v_obj_id);
  __Pyx_XDECREF(__pyx_v_refs);
  __Pyx_RefNannyFinishContext();
  #ifdef WITH_THREAD
  __Pyx_PyGILState_Release(__pyx_gilstate_save);
  #endif
  return __pyx_r;
}

/* "lupa/_lupa.pyx":1435
 *         finally: return -1
 * 
 * cdef int py_object_gc(lua_State* L) nogil:             # <<<<<<<<<<<<<<
 *     if not lua.lua_isuserdata(L, 1):
 *         return 0
 */

static int __pyx_f_4lupa_5_lupa_py_object_gc(lua_State *__pyx_v_L) {
  struct __pyx_t_4lupa_5_lupa_py_object *__pyx_v_py_obj;
  int __pyx_r;
  int __pyx_t_1;
  int __pyx_t_2;

  /* "lupa/_lupa.pyx":1436
 * 
 * cdef int py_object_gc(lua_State* L) nogil:
 *     if not lua.lua_isuserdata(L, 1):             # <<<<<<<<<<<<<<
 *         return 0
 *     py_obj = unpack_userdata(L, 1)
 */
  __pyx_t_1 = ((!(lua_isuserdata(__pyx_v_L, 1) != 0)) != 0);
  if (__pyx_t_1) {

    /* "lupa/_lupa.pyx":1437
 * cdef int py_object_gc(lua_State* L) nogil:
 *     if not lua.lua_isuserdata(L, 1):
 *         return 0             # <<<<<<<<<<<<<<
 *     py_obj = unpack_userdata(L, 1)
 *     if py_obj is not NULL and py_obj.obj is not NULL:
 */
    __pyx_r = 0;
    goto __pyx_L0;

    /* "lupa/_lupa.pyx":1436
 * 
 * cdef int py_object_gc(lua_State* L) nogil:
 *     if not lua.lua_isuserdata(L, 1):             # <<<<<<<<<<<<<<
 *         return 0
 *     py_obj = unpack_userdata(L, 1)
 */
  }

  /* "lupa/_lupa.pyx":1438
 *     if not lua.lua_isuserdata(L, 1):
 *         return 0
 *     py_obj = unpack_userdata(L, 1)             # <<<<<<<<<<<<<<
 *     if py_obj is not NULL and py_obj.obj is not NULL:
 *         if decref_with_gil(py_obj, L):
 */
  __pyx_v_py_obj = __pyx_f_4lupa_5_lupa_unpack_userdata(__pyx_v_L, 1);

  /* "lupa/_lupa.pyx":1439
 *         return 0
 *     py_obj = unpack_userdata(L, 1)
 *     if py_obj is not NULL and py_obj.obj is not NULL:             # <<<<<<<<<<<<<<
 *         if decref_with_gil(py_obj, L):
 *             return lua.lua_error(L)  # never returns!
 */
  __pyx_t_2 = ((__pyx_v_py_obj != NULL) != 0);
  if (__pyx_t_2) {
  } else {
    __pyx_t_1 = __pyx_t_2;
    goto __pyx_L5_bool_binop_done;
  }
  __pyx_t_2 = ((__pyx_v_py_obj->obj != NULL) != 0);
  __pyx_t_1 = __pyx_t_2;
  __pyx_L5_bool_binop_done:;
  if (__pyx_t_1) {

    /* "lupa/_lupa.pyx":1440
 *     py_obj = unpack_userdata(L, 1)
 *     if py_obj is not NULL and py_obj.obj is not NULL:
 *         if decref_with_gil(py_obj, L):             # <<<<<<<<<<<<<<
 *             return lua.lua_error(L)  # never returns!
 *     return 0
 */
    __pyx_t_1 = (__pyx_f_4lupa_5_lupa_decref_with_gil(__pyx_v_py_obj, __pyx_v_L) != 0);
    if (__pyx_t_1) {

      /* "lupa/_lupa.pyx":1441
 *     if py_obj is not NULL and py_obj.obj is not NULL:
 *         if decref_with_gil(py_obj, L):
 *             return lua.lua_error(L)  # never returns!             # <<<<<<<<<<<<<<
 *     return 0
 * 
 */
      __pyx_r = lua_error(__pyx_v_L);
      goto __pyx_L0;

      /* "lupa/_lupa.pyx":1440
 *     py_obj = unpack_userdata(L, 1)
 *     if py_obj is not NULL and py_obj.obj is not NULL:
 *         if decref_with_gil(py_obj, L):             # <<<<<<<<<<<<<<
 *             return lua.lua_error(L)  # never returns!
 *     return 0
 */
    }

    /* "lupa/_lupa.pyx":1439
 *         return 0
 *     py_obj = unpack_userdata(L, 1)
 *     if py_obj is not NULL and py_obj.obj is not NULL:             # <<<<<<<<<<<<<<
 *         if decref_with_gil(py_obj, L):
 *             return lua.lua_error(L)  # never returns!
 */
  }

  /* "lupa/_lupa.pyx":1442
 *         if decref_with_gil(py_obj, L):
 *             return lua.lua_error(L)  # never returns!
 *     return 0             # <<<<<<<<<<<<<<
 * 
 * # calling Python objects
 */
  __pyx_r = 0;
  goto __pyx_L0;

  /* "lupa/_lupa.pyx":1435
 *         finally: return -1
 * 
 * cdef int py_object_gc(lua_State* L) nogil:             # <<<<<<<<<<<<<<
 *     if not lua.lua_isuserdata(L, 1):
 *         return 0
 */

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

/* "lupa/_lupa.pyx":1446
 * # calling Python objects
 * 
 * cdef bint call_python(LuaRuntime runtime, lua_State *L, py_object* py_obj) except -1:             # <<<<<<<<<<<<<<
 *     cdef int i, nargs = lua.lua_gettop(L) - 1
 *     cdef tuple args
 */

static int __pyx_f_4lupa_5_lupa_call_python(struct __pyx_obj_4lupa_5_lupa_LuaRuntime *__pyx_v_runtime, lua_State *__pyx_v_L, struct __pyx_t_4lupa_5_lupa_py_object *__pyx_v_py_obj) {
  int __pyx_v_i;
  int __pyx_v_nargs;
  PyObject *__pyx_v_args = 0;
  PyObject *__pyx_v_f = NULL;
  PyObject *__pyx_v_result = NULL;
  PyObject *__pyx_v_arg = NULL;
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  int __pyx_t_5;
  PyObject *__pyx_t_6;
  int __pyx_t_7;
  int __pyx_t_8;
  int __pyx_t_9;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("call_python", 0);

  /* "lupa/_lupa.pyx":1447
 * 
 * cdef bint call_python(LuaRuntime runtime, lua_State *L, py_object* py_obj) except -1:
 *     cdef int i, nargs = lua.lua_gettop(L) - 1             # <<<<<<<<<<<<<<
 *     cdef tuple args
 * 
 */
  __pyx_v_nargs = (lua_gettop(__pyx_v_L) - 1);

  /* "lupa/_lupa.pyx":1450
 *     cdef tuple args
 * 
 *     if not py_obj:             # <<<<<<<<<<<<<<
 *         raise TypeError("not a python object")
 * 
 */
  __pyx_t_1 = ((!(__pyx_v_py_obj != 0)) != 0);
  if (unlikely(__pyx_t_1)) {

    /* "lupa/_lupa.pyx":1451
 * 
 *     if not py_obj:
 *         raise TypeError("not a python object")             # <<<<<<<<<<<<<<
 * 
 *     f = <object>py_obj.obj
 */
    __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__35, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1451, __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, 1451, __pyx_L1_error)

    /* "lupa/_lupa.pyx":1450
 *     cdef tuple args
 * 
 *     if not py_obj:             # <<<<<<<<<<<<<<
 *         raise TypeError("not a python object")
 * 
 */
  }

  /* "lupa/_lupa.pyx":1453
 *         raise TypeError("not a python object")
 * 
 *     f = <object>py_obj.obj             # <<<<<<<<<<<<<<
 * 
 *     if not nargs:
 */
  __pyx_t_2 = ((PyObject *)__pyx_v_py_obj->obj);
  __Pyx_INCREF(__pyx_t_2);
  __pyx_v_f = __pyx_t_2;
  __pyx_t_2 = 0;

  /* "lupa/_lupa.pyx":1455
 *     f = <object>py_obj.obj
 * 
 *     if not nargs:             # <<<<<<<<<<<<<<
 *         lua.lua_settop(L, 0)  # FIXME
 *         result = f()
 */
  __pyx_t_1 = ((!(__pyx_v_nargs != 0)) != 0);
  if (__pyx_t_1) {

    /* "lupa/_lupa.pyx":1456
 * 
 *     if not nargs:
 *         lua.lua_settop(L, 0)  # FIXME             # <<<<<<<<<<<<<<
 *         result = f()
 *     else:
 */
    lua_settop(__pyx_v_L, 0);

    /* "lupa/_lupa.pyx":1457
 *     if not nargs:
 *         lua.lua_settop(L, 0)  # FIXME
 *         result = f()             # <<<<<<<<<<<<<<
 *     else:
 *         arg = py_from_lua(runtime, L, 2)
 */
    __Pyx_INCREF(__pyx_v_f);
    __pyx_t_3 = __pyx_v_f; __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_CallOneArg(__pyx_t_3, __pyx_t_4) : __Pyx_PyObject_CallNoArg(__pyx_t_3);
    __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
    if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1457, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_v_result = __pyx_t_2;
    __pyx_t_2 = 0;

    /* "lupa/_lupa.pyx":1455
 *     f = <object>py_obj.obj
 * 
 *     if not nargs:             # <<<<<<<<<<<<<<
 *         lua.lua_settop(L, 0)  # FIXME
 *         result = f()
 */
    goto __pyx_L4;
  }

  /* "lupa/_lupa.pyx":1459
 *         result = f()
 *     else:
 *         arg = py_from_lua(runtime, L, 2)             # <<<<<<<<<<<<<<
 * 
 *         if PyMethod_Check(f) and (<PyObject*>arg) is PyMethod_GET_SELF(f):
 */
  /*else*/ {
    __pyx_t_2 = __pyx_f_4lupa_5_lupa_py_from_lua(__pyx_v_runtime, __pyx_v_L, 2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1459, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_v_arg = __pyx_t_2;
    __pyx_t_2 = 0;

    /* "lupa/_lupa.pyx":1461
 *         arg = py_from_lua(runtime, L, 2)
 * 
 *         if PyMethod_Check(f) and (<PyObject*>arg) is PyMethod_GET_SELF(f):             # <<<<<<<<<<<<<<
 *             # Calling a bound method and self is already the first argument.
 *             # Lua x:m(a, b) => Python as x.m(x, a, b) but should be x.m(a, b)
 */
    __pyx_t_5 = (PyMethod_Check(__pyx_v_f) != 0);
    if (__pyx_t_5) {
    } else {
      __pyx_t_1 = __pyx_t_5;
      goto __pyx_L6_bool_binop_done;
    }
    __pyx_t_5 = ((((PyObject *)__pyx_v_arg) == PyMethod_GET_SELF(__pyx_v_f)) != 0);
    __pyx_t_1 = __pyx_t_5;
    __pyx_L6_bool_binop_done:;
    if (__pyx_t_1) {

      /* "lupa/_lupa.pyx":1471
 *             # The method wrapper would only prepend self to the tuple again,
 *             # so we just call the underlying function directly instead.
 *             f = <object>PyMethod_GET_FUNCTION(f)             # <<<<<<<<<<<<<<
 * 
 *         args = cpython.tuple.PyTuple_New(nargs)
 */
      __pyx_t_6 = PyMethod_GET_FUNCTION(__pyx_v_f);
      __pyx_t_2 = ((PyObject *)__pyx_t_6);
      __Pyx_INCREF(__pyx_t_2);
      __Pyx_DECREF_SET(__pyx_v_f, __pyx_t_2);
      __pyx_t_2 = 0;

      /* "lupa/_lupa.pyx":1461
 *         arg = py_from_lua(runtime, L, 2)
 * 
 *         if PyMethod_Check(f) and (<PyObject*>arg) is PyMethod_GET_SELF(f):             # <<<<<<<<<<<<<<
 *             # Calling a bound method and self is already the first argument.
 *             # Lua x:m(a, b) => Python as x.m(x, a, b) but should be x.m(a, b)
 */
    }

    /* "lupa/_lupa.pyx":1473
 *             f = <object>PyMethod_GET_FUNCTION(f)
 * 
 *         args = cpython.tuple.PyTuple_New(nargs)             # <<<<<<<<<<<<<<
 *         cpython.ref.Py_INCREF(arg)
 *         cpython.tuple.PyTuple_SET_ITEM(args, 0, arg)
 */
    __pyx_t_2 = PyTuple_New(__pyx_v_nargs); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1473, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_v_args = ((PyObject*)__pyx_t_2);
    __pyx_t_2 = 0;

    /* "lupa/_lupa.pyx":1474
 * 
 *         args = cpython.tuple.PyTuple_New(nargs)
 *         cpython.ref.Py_INCREF(arg)             # <<<<<<<<<<<<<<
 *         cpython.tuple.PyTuple_SET_ITEM(args, 0, arg)
 * 
 */
    Py_INCREF(__pyx_v_arg);

    /* "lupa/_lupa.pyx":1475
 *         args = cpython.tuple.PyTuple_New(nargs)
 *         cpython.ref.Py_INCREF(arg)
 *         cpython.tuple.PyTuple_SET_ITEM(args, 0, arg)             # <<<<<<<<<<<<<<
 * 
 *         for i in range(1, nargs):
 */
    PyTuple_SET_ITEM(__pyx_v_args, 0, __pyx_v_arg);

    /* "lupa/_lupa.pyx":1477
 *         cpython.tuple.PyTuple_SET_ITEM(args, 0, arg)
 * 
 *         for i in range(1, nargs):             # <<<<<<<<<<<<<<
 *             arg = py_from_lua(runtime, L, i+2)
 *             cpython.ref.Py_INCREF(arg)
 */
    __pyx_t_7 = __pyx_v_nargs;
    __pyx_t_8 = __pyx_t_7;
    for (__pyx_t_9 = 1; __pyx_t_9 < __pyx_t_8; __pyx_t_9+=1) {
      __pyx_v_i = __pyx_t_9;

      /* "lupa/_lupa.pyx":1478
 * 
 *         for i in range(1, nargs):
 *             arg = py_from_lua(runtime, L, i+2)             # <<<<<<<<<<<<<<
 *             cpython.ref.Py_INCREF(arg)
 *             cpython.tuple.PyTuple_SET_ITEM(args, i, arg)
 */
      __pyx_t_2 = __pyx_f_4lupa_5_lupa_py_from_lua(__pyx_v_runtime, __pyx_v_L, (__pyx_v_i + 2)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1478, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF_SET(__pyx_v_arg, __pyx_t_2);
      __pyx_t_2 = 0;

      /* "lupa/_lupa.pyx":1479
 *         for i in range(1, nargs):
 *             arg = py_from_lua(runtime, L, i+2)
 *             cpython.ref.Py_INCREF(arg)             # <<<<<<<<<<<<<<
 *             cpython.tuple.PyTuple_SET_ITEM(args, i, arg)
 * 
 */
      Py_INCREF(__pyx_v_arg);

      /* "lupa/_lupa.pyx":1480
 *             arg = py_from_lua(runtime, L, i+2)
 *             cpython.ref.Py_INCREF(arg)
 *             cpython.tuple.PyTuple_SET_ITEM(args, i, arg)             # <<<<<<<<<<<<<<
 * 
 *         lua.lua_settop(L, 0)  # FIXME
 */
      PyTuple_SET_ITEM(__pyx_v_args, __pyx_v_i, __pyx_v_arg);
    }

    /* "lupa/_lupa.pyx":1482
 *             cpython.tuple.PyTuple_SET_ITEM(args, i, arg)
 * 
 *         lua.lua_settop(L, 0)  # FIXME             # <<<<<<<<<<<<<<
 *         result = f(*args)
 * 
 */
    lua_settop(__pyx_v_L, 0);

    /* "lupa/_lupa.pyx":1483
 * 
 *         lua.lua_settop(L, 0)  # FIXME
 *         result = f(*args)             # <<<<<<<<<<<<<<
 * 
 *     return py_function_result_to_lua(runtime, L, result)
 */
    if (unlikely(__pyx_v_args == Py_None)) {
      PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable");
      __PYX_ERR(0, 1483, __pyx_L1_error)
    }
    __pyx_t_2 = __Pyx_PyObject_Call(__pyx_v_f, __pyx_v_args, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1483, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_v_result = __pyx_t_2;
    __pyx_t_2 = 0;
  }
  __pyx_L4:;

  /* "lupa/_lupa.pyx":1485
 *         result = f(*args)
 * 
 *     return py_function_result_to_lua(runtime, L, result)             # <<<<<<<<<<<<<<
 * 
 * cdef int py_call_with_gil(lua_State* L, py_object *py_obj) with gil:
 */
  __pyx_t_7 = __pyx_f_4lupa_5_lupa_py_function_result_to_lua(__pyx_v_runtime, __pyx_v_L, __pyx_v_result); if (unlikely(__pyx_t_7 == ((int)-1))) __PYX_ERR(0, 1485, __pyx_L1_error)
  __pyx_r = __pyx_t_7;
  goto __pyx_L0;

  /* "lupa/_lupa.pyx":1446
 * # calling Python objects
 * 
 * cdef bint call_python(LuaRuntime runtime, lua_State *L, py_object* py_obj) except -1:             # <<<<<<<<<<<<<<
 *     cdef int i, nargs = lua.lua_gettop(L) - 1
 *     cdef tuple args
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_AddTraceback("lupa._lupa.call_python", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_args);
  __Pyx_XDECREF(__pyx_v_f);
  __Pyx_XDECREF(__pyx_v_result);
  __Pyx_XDECREF(__pyx_v_arg);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lupa/_lupa.pyx":1487
 *     return py_function_result_to_lua(runtime, L, result)
 * 
 * cdef int py_call_with_gil(lua_State* L, py_object *py_obj) with gil:             # <<<<<<<<<<<<<<
 *     cdef LuaRuntime runtime = None
 *     cdef lua_State* stored_state = NULL
 */

static int __pyx_f_4lupa_5_lupa_py_call_with_gil(lua_State *__pyx_v_L, struct __pyx_t_4lupa_5_lupa_py_object *__pyx_v_py_obj) {
  struct __pyx_obj_4lupa_5_lupa_LuaRuntime *__pyx_v_runtime = 0;
  lua_State *__pyx_v_stored_state;
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  int __pyx_t_5;
  lua_State *__pyx_t_6;
  PyObject *__pyx_t_7 = NULL;
  PyObject *__pyx_t_8 = NULL;
  int __pyx_t_9;
  int __pyx_t_10;
  char const *__pyx_t_11;
  PyObject *__pyx_t_12 = NULL;
  PyObject *__pyx_t_13 = NULL;
  PyObject *__pyx_t_14 = 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("py_call_with_gil", 0);

  /* "lupa/_lupa.pyx":1488
 * 
 * cdef int py_call_with_gil(lua_State* L, py_object *py_obj) with gil:
 *     cdef LuaRuntime runtime = None             # <<<<<<<<<<<<<<
 *     cdef lua_State* stored_state = NULL
 * 
 */
  __Pyx_INCREF(Py_None);
  __pyx_v_runtime = ((struct __pyx_obj_4lupa_5_lupa_LuaRuntime *)Py_None);

  /* "lupa/_lupa.pyx":1489
 * cdef int py_call_with_gil(lua_State* L, py_object *py_obj) with gil:
 *     cdef LuaRuntime runtime = None
 *     cdef lua_State* stored_state = NULL             # <<<<<<<<<<<<<<
 * 
 *     try:
 */
  __pyx_v_stored_state = NULL;

  /* "lupa/_lupa.pyx":1491
 *     cdef lua_State* stored_state = NULL
 * 
 *     try:             # <<<<<<<<<<<<<<
 *         runtime = <LuaRuntime?>py_obj.runtime
 *         if runtime._state is not L:
 */
  /*try:*/ {
    {
      __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:*/ {

        /* "lupa/_lupa.pyx":1492
 * 
 *     try:
 *         runtime = <LuaRuntime?>py_obj.runtime             # <<<<<<<<<<<<<<
 *         if runtime._state is not L:
 *             stored_state = runtime._state
 */
        __pyx_t_4 = ((PyObject *)__pyx_v_py_obj->runtime);
        __Pyx_INCREF(__pyx_t_4);
        __Pyx_DECREF_SET(__pyx_v_runtime, ((struct __pyx_obj_4lupa_5_lupa_LuaRuntime *)__pyx_t_4));
        __pyx_t_4 = 0;

        /* "lupa/_lupa.pyx":1493
 *     try:
 *         runtime = <LuaRuntime?>py_obj.runtime
 *         if runtime._state is not L:             # <<<<<<<<<<<<<<
 *             stored_state = runtime._state
 *             runtime._state = L
 */
        __pyx_t_5 = ((__pyx_v_runtime->_state != __pyx_v_L) != 0);
        if (__pyx_t_5) {

          /* "lupa/_lupa.pyx":1494
 *         runtime = <LuaRuntime?>py_obj.runtime
 *         if runtime._state is not L:
 *             stored_state = runtime._state             # <<<<<<<<<<<<<<
 *             runtime._state = L
 *         return call_python(runtime, L, py_obj)
 */
          __pyx_t_6 = __pyx_v_runtime->_state;
          __pyx_v_stored_state = __pyx_t_6;

          /* "lupa/_lupa.pyx":1495
 *         if runtime._state is not L:
 *             stored_state = runtime._state
 *             runtime._state = L             # <<<<<<<<<<<<<<
 *         return call_python(runtime, L, py_obj)
 *     except:
 */
          __pyx_v_runtime->_state = __pyx_v_L;

          /* "lupa/_lupa.pyx":1493
 *     try:
 *         runtime = <LuaRuntime?>py_obj.runtime
 *         if runtime._state is not L:             # <<<<<<<<<<<<<<
 *             stored_state = runtime._state
 *             runtime._state = L
 */
        }

        /* "lupa/_lupa.pyx":1496
 *             stored_state = runtime._state
 *             runtime._state = L
 *         return call_python(runtime, L, py_obj)             # <<<<<<<<<<<<<<
 *     except:
 *         runtime.store_raised_exception(L, b'error during Python call')
 */
        __pyx_t_5 = __pyx_f_4lupa_5_lupa_call_python(__pyx_v_runtime, __pyx_v_L, __pyx_v_py_obj); if (unlikely(__pyx_t_5 == ((int)-1))) __PYX_ERR(0, 1496, __pyx_L6_error)
        __pyx_r = __pyx_t_5;
        goto __pyx_L10_try_return;

        /* "lupa/_lupa.pyx":1491
 *     cdef lua_State* stored_state = NULL
 * 
 *     try:             # <<<<<<<<<<<<<<
 *         runtime = <LuaRuntime?>py_obj.runtime
 *         if runtime._state is not L:
 */
      }
      __pyx_L6_error:;
      __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;

      /* "lupa/_lupa.pyx":1497
 *             runtime._state = L
 *         return call_python(runtime, L, py_obj)
 *     except:             # <<<<<<<<<<<<<<
 *         runtime.store_raised_exception(L, b'error during Python call')
 *         return -1
 */
      /*except:*/ {
        __Pyx_AddTraceback("lupa._lupa.py_call_with_gil", __pyx_clineno, __pyx_lineno, __pyx_filename);
        if (__Pyx_GetException(&__pyx_t_4, &__pyx_t_7, &__pyx_t_8) < 0) __PYX_ERR(0, 1497, __pyx_L8_except_error)
        __Pyx_GOTREF(__pyx_t_4);
        __Pyx_GOTREF(__pyx_t_7);
        __Pyx_GOTREF(__pyx_t_8);

        /* "lupa/_lupa.pyx":1498
 *         return call_python(runtime, L, py_obj)
 *     except:
 *         runtime.store_raised_exception(L, b'error during Python call')             # <<<<<<<<<<<<<<
 *         return -1
 *     finally:
 */
        __pyx_t_9 = __pyx_f_4lupa_5_lupa_10LuaRuntime_store_raised_exception(__pyx_v_runtime, __pyx_v_L, __pyx_kp_b_error_during_Python_call); if (unlikely(__pyx_t_9 == ((int)-1))) __PYX_ERR(0, 1498, __pyx_L8_except_error)

        /* "lupa/_lupa.pyx":1499
 *     except:
 *         runtime.store_raised_exception(L, b'error during Python call')
 *         return -1             # <<<<<<<<<<<<<<
 *     finally:
 *         if stored_state is not NULL:
 */
        __pyx_r = -1;
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
        __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
        __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
        goto __pyx_L9_except_return;
      }
      __pyx_L8_except_error:;

      /* "lupa/_lupa.pyx":1491
 *     cdef lua_State* stored_state = NULL
 * 
 *     try:             # <<<<<<<<<<<<<<
 *         runtime = <LuaRuntime?>py_obj.runtime
 *         if runtime._state is not L:
 */
      __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_L4_error;
      __pyx_L10_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_L3_return;
      __pyx_L9_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_L3_return;
    }
  }

  /* "lupa/_lupa.pyx":1501
 *         return -1
 *     finally:
 *         if stored_state is not NULL:             # <<<<<<<<<<<<<<
 *             runtime._state = stored_state
 * 
 */
  /*finally:*/ {
    __pyx_L4_error:;
    /*exception exit:*/{
      __Pyx_PyThreadState_declare
      __Pyx_PyThreadState_assign
      __pyx_t_3 = 0; __pyx_t_2 = 0; __pyx_t_1 = 0; __pyx_t_12 = 0; __pyx_t_13 = 0; __pyx_t_14 = 0;
      __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
      __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
      __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
      if (PY_MAJOR_VERSION >= 3) __Pyx_ExceptionSwap(&__pyx_t_12, &__pyx_t_13, &__pyx_t_14);
      if ((PY_MAJOR_VERSION < 3) || unlikely(__Pyx_GetException(&__pyx_t_3, &__pyx_t_2, &__pyx_t_1) < 0)) __Pyx_ErrFetch(&__pyx_t_3, &__pyx_t_2, &__pyx_t_1);
      __Pyx_XGOTREF(__pyx_t_3);
      __Pyx_XGOTREF(__pyx_t_2);
      __Pyx_XGOTREF(__pyx_t_1);
      __Pyx_XGOTREF(__pyx_t_12);
      __Pyx_XGOTREF(__pyx_t_13);
      __Pyx_XGOTREF(__pyx_t_14);
      __pyx_t_9 = __pyx_lineno; __pyx_t_10 = __pyx_clineno; __pyx_t_11 = __pyx_filename;
      {
        __pyx_t_5 = ((__pyx_v_stored_state != NULL) != 0);
        if (__pyx_t_5) {

          /* "lupa/_lupa.pyx":1502
 *     finally:
 *         if stored_state is not NULL:
 *             runtime._state = stored_state             # <<<<<<<<<<<<<<
 * 
 * cdef int py_object_call(lua_State* L) nogil:
 */
          __pyx_v_runtime->_state = __pyx_v_stored_state;

          /* "lupa/_lupa.pyx":1501
 *         return -1
 *     finally:
 *         if stored_state is not NULL:             # <<<<<<<<<<<<<<
 *             runtime._state = stored_state
 * 
 */
        }
      }
      if (PY_MAJOR_VERSION >= 3) {
        __Pyx_XGIVEREF(__pyx_t_12);
        __Pyx_XGIVEREF(__pyx_t_13);
        __Pyx_XGIVEREF(__pyx_t_14);
        __Pyx_ExceptionReset(__pyx_t_12, __pyx_t_13, __pyx_t_14);
      }
      __Pyx_XGIVEREF(__pyx_t_3);
      __Pyx_XGIVEREF(__pyx_t_2);
      __Pyx_XGIVEREF(__pyx_t_1);
      __Pyx_ErrRestore(__pyx_t_3, __pyx_t_2, __pyx_t_1);
      __pyx_t_3 = 0; __pyx_t_2 = 0; __pyx_t_1 = 0; __pyx_t_12 = 0; __pyx_t_13 = 0; __pyx_t_14 = 0;
      __pyx_lineno = __pyx_t_9; __pyx_clineno = __pyx_t_10; __pyx_filename = __pyx_t_11;
      goto __pyx_L1_error;
    }
    __pyx_L3_return: {
      __pyx_t_10 = __pyx_r;
      __pyx_t_5 = ((__pyx_v_stored_state != NULL) != 0);
      if (__pyx_t_5) {

        /* "lupa/_lupa.pyx":1502
 *     finally:
 *         if stored_state is not NULL:
 *             runtime._state = stored_state             # <<<<<<<<<<<<<<
 * 
 * cdef int py_object_call(lua_State* L) nogil:
 */
        __pyx_v_runtime->_state = __pyx_v_stored_state;

        /* "lupa/_lupa.pyx":1501
 *         return -1
 *     finally:
 *         if stored_state is not NULL:             # <<<<<<<<<<<<<<
 *             runtime._state = stored_state
 * 
 */
      }
      __pyx_r = __pyx_t_10;
      goto __pyx_L0;
    }
  }

  /* "lupa/_lupa.pyx":1487
 *     return py_function_result_to_lua(runtime, L, result)
 * 
 * cdef int py_call_with_gil(lua_State* L, py_object *py_obj) with gil:             # <<<<<<<<<<<<<<
 *     cdef LuaRuntime runtime = None
 *     cdef lua_State* stored_state = NULL
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_WriteUnraisable("lupa._lupa.py_call_with_gil", __pyx_clineno, __pyx_lineno, __pyx_filename, 1, 0);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_runtime);
  __Pyx_RefNannyFinishContext();
  #ifdef WITH_THREAD
  __Pyx_PyGILState_Release(__pyx_gilstate_save);
  #endif
  return __pyx_r;
}

/* "lupa/_lupa.pyx":1504
 *             runtime._state = stored_state
 * 
 * cdef int py_object_call(lua_State* L) nogil:             # <<<<<<<<<<<<<<
 *     cdef py_object* py_obj = unwrap_lua_object(L, 1) # may not return on error!
 *     if not py_obj:
 */

static int __pyx_f_4lupa_5_lupa_py_object_call(lua_State *__pyx_v_L) {
  struct __pyx_t_4lupa_5_lupa_py_object *__pyx_v_py_obj;
  int __pyx_v_result;
  int __pyx_r;
  int __pyx_t_1;

  /* "lupa/_lupa.pyx":1505
 * 
 * cdef int py_object_call(lua_State* L) nogil:
 *     cdef py_object* py_obj = unwrap_lua_object(L, 1) # may not return on error!             # <<<<<<<<<<<<<<
 *     if not py_obj:
 *         return lua.luaL_argerror(L, 1, "not a python object")  # never returns!
 */
  __pyx_v_py_obj = __pyx_f_4lupa_5_lupa_unwrap_lua_object(__pyx_v_L, 1);

  /* "lupa/_lupa.pyx":1506
 * cdef int py_object_call(lua_State* L) nogil:
 *     cdef py_object* py_obj = unwrap_lua_object(L, 1) # may not return on error!
 *     if not py_obj:             # <<<<<<<<<<<<<<
 *         return lua.luaL_argerror(L, 1, "not a python object")  # never returns!
 * 
 */
  __pyx_t_1 = ((!(__pyx_v_py_obj != 0)) != 0);
  if (__pyx_t_1) {

    /* "lupa/_lupa.pyx":1507
 *     cdef py_object* py_obj = unwrap_lua_object(L, 1) # may not return on error!
 *     if not py_obj:
 *         return lua.luaL_argerror(L, 1, "not a python object")  # never returns!             # <<<<<<<<<<<<<<
 * 
 *     result = py_call_with_gil(L, py_obj)
 */
    __pyx_r = luaL_argerror(__pyx_v_L, 1, ((char *)"not a python object"));
    goto __pyx_L0;

    /* "lupa/_lupa.pyx":1506
 * cdef int py_object_call(lua_State* L) nogil:
 *     cdef py_object* py_obj = unwrap_lua_object(L, 1) # may not return on error!
 *     if not py_obj:             # <<<<<<<<<<<<<<
 *         return lua.luaL_argerror(L, 1, "not a python object")  # never returns!
 * 
 */
  }

  /* "lupa/_lupa.pyx":1509
 *         return lua.luaL_argerror(L, 1, "not a python object")  # never returns!
 * 
 *     result = py_call_with_gil(L, py_obj)             # <<<<<<<<<<<<<<
 *     if result < 0:
 *         return lua.lua_error(L)  # never returns!
 */
  __pyx_v_result = __pyx_f_4lupa_5_lupa_py_call_with_gil(__pyx_v_L, __pyx_v_py_obj);

  /* "lupa/_lupa.pyx":1510
 * 
 *     result = py_call_with_gil(L, py_obj)
 *     if result < 0:             # <<<<<<<<<<<<<<
 *         return lua.lua_error(L)  # never returns!
 *     return result
 */
  __pyx_t_1 = ((__pyx_v_result < 0) != 0);
  if (__pyx_t_1) {

    /* "lupa/_lupa.pyx":1511
 *     result = py_call_with_gil(L, py_obj)
 *     if result < 0:
 *         return lua.lua_error(L)  # never returns!             # <<<<<<<<<<<<<<
 *     return result
 * 
 */
    __pyx_r = lua_error(__pyx_v_L);
    goto __pyx_L0;

    /* "lupa/_lupa.pyx":1510
 * 
 *     result = py_call_with_gil(L, py_obj)
 *     if result < 0:             # <<<<<<<<<<<<<<
 *         return lua.lua_error(L)  # never returns!
 *     return result
 */
  }

  /* "lupa/_lupa.pyx":1512
 *     if result < 0:
 *         return lua.lua_error(L)  # never returns!
 *     return result             # <<<<<<<<<<<<<<
 * 
 * # str() support for Python objects
 */
  __pyx_r = __pyx_v_result;
  goto __pyx_L0;

  /* "lupa/_lupa.pyx":1504
 *             runtime._state = stored_state
 * 
 * cdef int py_object_call(lua_State* L) nogil:             # <<<<<<<<<<<<<<
 *     cdef py_object* py_obj = unwrap_lua_object(L, 1) # may not return on error!
 *     if not py_obj:
 */

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

/* "lupa/_lupa.pyx":1516
 * # str() support for Python objects
 * 
 * cdef int py_str_with_gil(lua_State* L, py_object* py_obj) with gil:             # <<<<<<<<<<<<<<
 *     cdef LuaRuntime runtime
 *     try:
 */

static int __pyx_f_4lupa_5_lupa_py_str_with_gil(lua_State *__pyx_v_L, struct __pyx_t_4lupa_5_lupa_py_object *__pyx_v_py_obj) {
  struct __pyx_obj_4lupa_5_lupa_LuaRuntime *__pyx_v_runtime = 0;
  PyObject *__pyx_v_s = NULL;
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  int __pyx_t_5;
  int __pyx_t_6;
  char const *__pyx_t_7;
  char *__pyx_t_8;
  Py_ssize_t __pyx_t_9;
  PyObject *__pyx_t_10 = NULL;
  PyObject *__pyx_t_11 = NULL;
  int __pyx_t_12;
  PyObject *__pyx_t_13 = NULL;
  PyObject *__pyx_t_14 = NULL;
  PyObject *__pyx_t_15 = NULL;
  PyObject *__pyx_t_16 = NULL;
  PyObject *__pyx_t_17 = NULL;
  PyObject *__pyx_t_18 = 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("py_str_with_gil", 0);

  /* "lupa/_lupa.pyx":1518
 * cdef int py_str_with_gil(lua_State* L, py_object* py_obj) with gil:
 *     cdef LuaRuntime runtime
 *     try:             # <<<<<<<<<<<<<<
 *         runtime = <LuaRuntime?>py_obj.runtime
 *         s = str(<object>py_obj.obj)
 */
  {
    __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:*/ {

      /* "lupa/_lupa.pyx":1519
 *     cdef LuaRuntime runtime
 *     try:
 *         runtime = <LuaRuntime?>py_obj.runtime             # <<<<<<<<<<<<<<
 *         s = str(<object>py_obj.obj)
 *         if isinstance(s, unicode):
 */
      __pyx_t_4 = ((PyObject *)__pyx_v_py_obj->runtime);
      __Pyx_INCREF(__pyx_t_4);
      __pyx_v_runtime = ((struct __pyx_obj_4lupa_5_lupa_LuaRuntime *)__pyx_t_4);
      __pyx_t_4 = 0;

      /* "lupa/_lupa.pyx":1520
 *     try:
 *         runtime = <LuaRuntime?>py_obj.runtime
 *         s = str(<object>py_obj.obj)             # <<<<<<<<<<<<<<
 *         if isinstance(s, unicode):
 *             if runtime._encoding is None:
 */
      __pyx_t_4 = __Pyx_PyObject_CallOneArg(((PyObject *)(&PyString_Type)), ((PyObject *)__pyx_v_py_obj->obj)); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1520, __pyx_L3_error)
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_v_s = __pyx_t_4;
      __pyx_t_4 = 0;

      /* "lupa/_lupa.pyx":1521
 *         runtime = <LuaRuntime?>py_obj.runtime
 *         s = str(<object>py_obj.obj)
 *         if isinstance(s, unicode):             # <<<<<<<<<<<<<<
 *             if runtime._encoding is None:
 *                 s = (<unicode>s).encode('UTF-8')
 */
      __pyx_t_5 = PyUnicode_Check(__pyx_v_s); 
      __pyx_t_6 = (__pyx_t_5 != 0);
      if (__pyx_t_6) {

        /* "lupa/_lupa.pyx":1522
 *         s = str(<object>py_obj.obj)
 *         if isinstance(s, unicode):
 *             if runtime._encoding is None:             # <<<<<<<<<<<<<<
 *                 s = (<unicode>s).encode('UTF-8')
 *             else:
 */
        __pyx_t_6 = (__pyx_v_runtime->_encoding == ((PyObject*)Py_None));
        __pyx_t_5 = (__pyx_t_6 != 0);
        if (__pyx_t_5) {

          /* "lupa/_lupa.pyx":1523
 *         if isinstance(s, unicode):
 *             if runtime._encoding is None:
 *                 s = (<unicode>s).encode('UTF-8')             # <<<<<<<<<<<<<<
 *             else:
 *                 s = (<unicode>s).encode(runtime._encoding)
 */
          if (unlikely(__pyx_v_s == Py_None)) {
            PyErr_Format(PyExc_AttributeError, "'NoneType' object has no attribute '%.30s'", "encode");
            __PYX_ERR(0, 1523, __pyx_L3_error)
          }
          __pyx_t_4 = PyUnicode_AsUTF8String(((PyObject*)__pyx_v_s)); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1523, __pyx_L3_error)
          __Pyx_GOTREF(__pyx_t_4);
          __Pyx_DECREF_SET(__pyx_v_s, __pyx_t_4);
          __pyx_t_4 = 0;

          /* "lupa/_lupa.pyx":1522
 *         s = str(<object>py_obj.obj)
 *         if isinstance(s, unicode):
 *             if runtime._encoding is None:             # <<<<<<<<<<<<<<
 *                 s = (<unicode>s).encode('UTF-8')
 *             else:
 */
          goto __pyx_L10;
        }

        /* "lupa/_lupa.pyx":1525
 *                 s = (<unicode>s).encode('UTF-8')
 *             else:
 *                 s = (<unicode>s).encode(runtime._encoding)             # <<<<<<<<<<<<<<
 *         else:
 *             assert isinstance(s, bytes)
 */
        /*else*/ {
          if (unlikely(__pyx_v_s == Py_None)) {
            PyErr_Format(PyExc_AttributeError, "'NoneType' object has no attribute '%.30s'", "encode");
            __PYX_ERR(0, 1525, __pyx_L3_error)
          }
          if (unlikely(__pyx_v_runtime->_encoding == Py_None)) {
            PyErr_SetString(PyExc_TypeError, "expected bytes, NoneType found");
            __PYX_ERR(0, 1525, __pyx_L3_error)
          }
          __pyx_t_7 = __Pyx_PyBytes_AsString(__pyx_v_runtime->_encoding); if (unlikely((!__pyx_t_7) && PyErr_Occurred())) __PYX_ERR(0, 1525, __pyx_L3_error)
          __pyx_t_4 = PyUnicode_AsEncodedString(((PyObject*)__pyx_v_s), __pyx_t_7, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1525, __pyx_L3_error)
          __Pyx_GOTREF(__pyx_t_4);
          __Pyx_DECREF_SET(__pyx_v_s, __pyx_t_4);
          __pyx_t_4 = 0;
        }
        __pyx_L10:;

        /* "lupa/_lupa.pyx":1521
 *         runtime = <LuaRuntime?>py_obj.runtime
 *         s = str(<object>py_obj.obj)
 *         if isinstance(s, unicode):             # <<<<<<<<<<<<<<
 *             if runtime._encoding is None:
 *                 s = (<unicode>s).encode('UTF-8')
 */
        goto __pyx_L9;
      }

      /* "lupa/_lupa.pyx":1527
 *                 s = (<unicode>s).encode(runtime._encoding)
 *         else:
 *             assert isinstance(s, bytes)             # <<<<<<<<<<<<<<
 *         lua.lua_pushlstring(L, <bytes>s, len(<bytes>s))
 *         return 1 # returning 1 value
 */
      /*else*/ {
        #ifndef CYTHON_WITHOUT_ASSERTIONS
        if (unlikely(!Py_OptimizeFlag)) {
          __pyx_t_5 = PyBytes_Check(__pyx_v_s); 
          if (unlikely(!(__pyx_t_5 != 0))) {
            PyErr_SetNone(PyExc_AssertionError);
            __PYX_ERR(0, 1527, __pyx_L3_error)
          }
        }
        #endif
      }
      __pyx_L9:;

      /* "lupa/_lupa.pyx":1528
 *         else:
 *             assert isinstance(s, bytes)
 *         lua.lua_pushlstring(L, <bytes>s, len(<bytes>s))             # <<<<<<<<<<<<<<
 *         return 1 # returning 1 value
 *     except:
 */
      if (unlikely(__pyx_v_s == Py_None)) {
        PyErr_SetString(PyExc_TypeError, "expected bytes, NoneType found");
        __PYX_ERR(0, 1528, __pyx_L3_error)
      }
      __pyx_t_8 = __Pyx_PyBytes_AsWritableString(__pyx_v_s); if (unlikely((!__pyx_t_8) && PyErr_Occurred())) __PYX_ERR(0, 1528, __pyx_L3_error)
      if (unlikely(__pyx_v_s == Py_None)) {
        PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()");
        __PYX_ERR(0, 1528, __pyx_L3_error)
      }
      __pyx_t_9 = PyBytes_GET_SIZE(((PyObject*)__pyx_v_s)); if (unlikely(__pyx_t_9 == ((Py_ssize_t)-1))) __PYX_ERR(0, 1528, __pyx_L3_error)
      lua_pushlstring(__pyx_v_L, __pyx_t_8, __pyx_t_9);

      /* "lupa/_lupa.pyx":1529
 *             assert isinstance(s, bytes)
 *         lua.lua_pushlstring(L, <bytes>s, len(<bytes>s))
 *         return 1 # returning 1 value             # <<<<<<<<<<<<<<
 *     except:
 *         try: runtime.store_raised_exception(L, b'error during Python str() call')
 */
      __pyx_r = 1;
      goto __pyx_L7_try_return;

      /* "lupa/_lupa.pyx":1518
 * cdef int py_str_with_gil(lua_State* L, py_object* py_obj) with gil:
 *     cdef LuaRuntime runtime
 *     try:             # <<<<<<<<<<<<<<
 *         runtime = <LuaRuntime?>py_obj.runtime
 *         s = str(<object>py_obj.obj)
 */
    }
    __pyx_L3_error:;
    __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;

    /* "lupa/_lupa.pyx":1530
 *         lua.lua_pushlstring(L, <bytes>s, len(<bytes>s))
 *         return 1 # returning 1 value
 *     except:             # <<<<<<<<<<<<<<
 *         try: runtime.store_raised_exception(L, b'error during Python str() call')
 *         finally: return -1
 */
    /*except:*/ {
      __Pyx_AddTraceback("lupa._lupa.py_str_with_gil", __pyx_clineno, __pyx_lineno, __pyx_filename);
      if (__Pyx_GetException(&__pyx_t_4, &__pyx_t_10, &__pyx_t_11) < 0) __PYX_ERR(0, 1530, __pyx_L5_except_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_GOTREF(__pyx_t_10);
      __Pyx_GOTREF(__pyx_t_11);

      /* "lupa/_lupa.pyx":1531
 *         return 1 # returning 1 value
 *     except:
 *         try: runtime.store_raised_exception(L, b'error during Python str() call')             # <<<<<<<<<<<<<<
 *         finally: return -1
 * 
 */
      /*try:*/ {
        if (unlikely(!__pyx_v_runtime)) { __Pyx_RaiseUnboundLocalError("runtime"); __PYX_ERR(0, 1531, __pyx_L16_error) }
        __pyx_t_12 = __pyx_f_4lupa_5_lupa_10LuaRuntime_store_raised_exception(__pyx_v_runtime, __pyx_v_L, __pyx_kp_b_error_during_Python_str_call); if (unlikely(__pyx_t_12 == ((int)-1))) __PYX_ERR(0, 1531, __pyx_L16_error)
      }

      /* "lupa/_lupa.pyx":1532
 *     except:
 *         try: runtime.store_raised_exception(L, b'error during Python str() call')
 *         finally: return -1             # <<<<<<<<<<<<<<
 * 
 * cdef int py_object_str(lua_State* L) nogil:
 */
      /*finally:*/ {
        /*normal exit:*/{
          __pyx_r = -1;
          __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
          __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
          __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
          goto __pyx_L6_except_return;
        }
        __pyx_L16_error:;
        /*exception exit:*/{
          __Pyx_PyThreadState_declare
          __Pyx_PyThreadState_assign
          __pyx_t_13 = 0; __pyx_t_14 = 0; __pyx_t_15 = 0; __pyx_t_16 = 0; __pyx_t_17 = 0; __pyx_t_18 = 0;
          if (PY_MAJOR_VERSION >= 3) __Pyx_ExceptionSwap(&__pyx_t_16, &__pyx_t_17, &__pyx_t_18);
          if ((PY_MAJOR_VERSION < 3) || unlikely(__Pyx_GetException(&__pyx_t_13, &__pyx_t_14, &__pyx_t_15) < 0)) __Pyx_ErrFetch(&__pyx_t_13, &__pyx_t_14, &__pyx_t_15);
          __Pyx_XGOTREF(__pyx_t_13);
          __Pyx_XGOTREF(__pyx_t_14);
          __Pyx_XGOTREF(__pyx_t_15);
          __Pyx_XGOTREF(__pyx_t_16);
          __Pyx_XGOTREF(__pyx_t_17);
          __Pyx_XGOTREF(__pyx_t_18);
          {
            __pyx_r = -1;
            __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
            __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
            __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
            goto __pyx_L20_return;
          }
          __pyx_L20_return:;
          if (PY_MAJOR_VERSION >= 3) {
            __Pyx_XGIVEREF(__pyx_t_16);
            __Pyx_XGIVEREF(__pyx_t_17);
            __Pyx_XGIVEREF(__pyx_t_18);
            __Pyx_ExceptionReset(__pyx_t_16, __pyx_t_17, __pyx_t_18);
          }
          __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0;
          __Pyx_XDECREF(__pyx_t_14); __pyx_t_14 = 0;
          __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0;
          __pyx_t_16 = 0; __pyx_t_17 = 0; __pyx_t_18 = 0;
          goto __pyx_L6_except_return;
        }
      }
    }
    __pyx_L5_except_error:;

    /* "lupa/_lupa.pyx":1518
 * cdef int py_str_with_gil(lua_State* L, py_object* py_obj) with gil:
 *     cdef LuaRuntime runtime
 *     try:             # <<<<<<<<<<<<<<
 *         runtime = <LuaRuntime?>py_obj.runtime
 *         s = str(<object>py_obj.obj)
 */
    __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;
  }

  /* "lupa/_lupa.pyx":1516
 * # str() support for Python objects
 * 
 * cdef int py_str_with_gil(lua_State* L, py_object* py_obj) with gil:             # <<<<<<<<<<<<<<
 *     cdef LuaRuntime runtime
 *     try:
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_10);
  __Pyx_XDECREF(__pyx_t_11);
  __Pyx_WriteUnraisable("lupa._lupa.py_str_with_gil", __pyx_clineno, __pyx_lineno, __pyx_filename, 1, 0);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_runtime);
  __Pyx_XDECREF(__pyx_v_s);
  __Pyx_RefNannyFinishContext();
  #ifdef WITH_THREAD
  __Pyx_PyGILState_Release(__pyx_gilstate_save);
  #endif
  return __pyx_r;
}

/* "lupa/_lupa.pyx":1534
 *         finally: return -1
 * 
 * cdef int py_object_str(lua_State* L) nogil:             # <<<<<<<<<<<<<<
 *     cdef py_object* py_obj = unwrap_lua_object(L, 1) # may not return on error!
 *     if not py_obj:
 */

static int __pyx_f_4lupa_5_lupa_py_object_str(lua_State *__pyx_v_L) {
  struct __pyx_t_4lupa_5_lupa_py_object *__pyx_v_py_obj;
  int __pyx_v_result;
  int __pyx_r;
  int __pyx_t_1;

  /* "lupa/_lupa.pyx":1535
 * 
 * cdef int py_object_str(lua_State* L) nogil:
 *     cdef py_object* py_obj = unwrap_lua_object(L, 1) # may not return on error!             # <<<<<<<<<<<<<<
 *     if not py_obj:
 *         return lua.luaL_argerror(L, 1, "not a python object")   # never returns!
 */
  __pyx_v_py_obj = __pyx_f_4lupa_5_lupa_unwrap_lua_object(__pyx_v_L, 1);

  /* "lupa/_lupa.pyx":1536
 * cdef int py_object_str(lua_State* L) nogil:
 *     cdef py_object* py_obj = unwrap_lua_object(L, 1) # may not return on error!
 *     if not py_obj:             # <<<<<<<<<<<<<<
 *         return lua.luaL_argerror(L, 1, "not a python object")   # never returns!
 *     result = py_str_with_gil(L, py_obj)
 */
  __pyx_t_1 = ((!(__pyx_v_py_obj != 0)) != 0);
  if (__pyx_t_1) {

    /* "lupa/_lupa.pyx":1537
 *     cdef py_object* py_obj = unwrap_lua_object(L, 1) # may not return on error!
 *     if not py_obj:
 *         return lua.luaL_argerror(L, 1, "not a python object")   # never returns!             # <<<<<<<<<<<<<<
 *     result = py_str_with_gil(L, py_obj)
 *     if result < 0:
 */
    __pyx_r = luaL_argerror(__pyx_v_L, 1, ((char *)"not a python object"));
    goto __pyx_L0;

    /* "lupa/_lupa.pyx":1536
 * cdef int py_object_str(lua_State* L) nogil:
 *     cdef py_object* py_obj = unwrap_lua_object(L, 1) # may not return on error!
 *     if not py_obj:             # <<<<<<<<<<<<<<
 *         return lua.luaL_argerror(L, 1, "not a python object")   # never returns!
 *     result = py_str_with_gil(L, py_obj)
 */
  }

  /* "lupa/_lupa.pyx":1538
 *     if not py_obj:
 *         return lua.luaL_argerror(L, 1, "not a python object")   # never returns!
 *     result = py_str_with_gil(L, py_obj)             # <<<<<<<<<<<<<<
 *     if result < 0:
 *         return lua.lua_error(L)  # never returns!
 */
  __pyx_v_result = __pyx_f_4lupa_5_lupa_py_str_with_gil(__pyx_v_L, __pyx_v_py_obj);

  /* "lupa/_lupa.pyx":1539
 *         return lua.luaL_argerror(L, 1, "not a python object")   # never returns!
 *     result = py_str_with_gil(L, py_obj)
 *     if result < 0:             # <<<<<<<<<<<<<<
 *         return lua.lua_error(L)  # never returns!
 *     return result
 */
  __pyx_t_1 = ((__pyx_v_result < 0) != 0);
  if (__pyx_t_1) {

    /* "lupa/_lupa.pyx":1540
 *     result = py_str_with_gil(L, py_obj)
 *     if result < 0:
 *         return lua.lua_error(L)  # never returns!             # <<<<<<<<<<<<<<
 *     return result
 * 
 */
    __pyx_r = lua_error(__pyx_v_L);
    goto __pyx_L0;

    /* "lupa/_lupa.pyx":1539
 *         return lua.luaL_argerror(L, 1, "not a python object")   # never returns!
 *     result = py_str_with_gil(L, py_obj)
 *     if result < 0:             # <<<<<<<<<<<<<<
 *         return lua.lua_error(L)  # never returns!
 *     return result
 */
  }

  /* "lupa/_lupa.pyx":1541
 *     if result < 0:
 *         return lua.lua_error(L)  # never returns!
 *     return result             # <<<<<<<<<<<<<<
 * 
 * # item access for Python objects
 */
  __pyx_r = __pyx_v_result;
  goto __pyx_L0;

  /* "lupa/_lupa.pyx":1534
 *         finally: return -1
 * 
 * cdef int py_object_str(lua_State* L) nogil:             # <<<<<<<<<<<<<<
 *     cdef py_object* py_obj = unwrap_lua_object(L, 1) # may not return on error!
 *     if not py_obj:
 */

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

/* "lupa/_lupa.pyx":1561
 * #   using the getitem method of access.
 * 
 * cdef int getitem_for_lua(LuaRuntime runtime, lua_State* L, py_object* py_obj, int key_n) except -1:             # <<<<<<<<<<<<<<
 *     return py_to_lua(runtime, L,
 *                      (<object>py_obj.obj)[ py_from_lua(runtime, L, key_n) ])
 */

static int __pyx_f_4lupa_5_lupa_getitem_for_lua(struct __pyx_obj_4lupa_5_lupa_LuaRuntime *__pyx_v_runtime, lua_State *__pyx_v_L, struct __pyx_t_4lupa_5_lupa_py_object *__pyx_v_py_obj, int __pyx_v_key_n) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  int __pyx_t_3;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("getitem_for_lua", 0);

  /* "lupa/_lupa.pyx":1563
 * cdef int getitem_for_lua(LuaRuntime runtime, lua_State* L, py_object* py_obj, int key_n) except -1:
 *     return py_to_lua(runtime, L,
 *                      (<object>py_obj.obj)[ py_from_lua(runtime, L, key_n) ])             # <<<<<<<<<<<<<<
 * 
 * cdef int setitem_for_lua(LuaRuntime runtime, lua_State* L, py_object* py_obj, int key_n, int value_n) except -1:
 */
  __pyx_t_1 = __pyx_f_4lupa_5_lupa_py_from_lua(__pyx_v_runtime, __pyx_v_L, __pyx_v_key_n); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1563, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyObject_GetItem(((PyObject *)__pyx_v_py_obj->obj), __pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1563, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "lupa/_lupa.pyx":1562
 * 
 * cdef int getitem_for_lua(LuaRuntime runtime, lua_State* L, py_object* py_obj, int key_n) except -1:
 *     return py_to_lua(runtime, L,             # <<<<<<<<<<<<<<
 *                      (<object>py_obj.obj)[ py_from_lua(runtime, L, key_n) ])
 * 
 */
  __pyx_t_3 = __pyx_f_4lupa_5_lupa_py_to_lua(__pyx_v_runtime, __pyx_v_L, __pyx_t_2, NULL); if (unlikely(__pyx_t_3 == ((int)-1))) __PYX_ERR(0, 1562, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_r = __pyx_t_3;
  goto __pyx_L0;

  /* "lupa/_lupa.pyx":1561
 * #   using the getitem method of access.
 * 
 * cdef int getitem_for_lua(LuaRuntime runtime, lua_State* L, py_object* py_obj, int key_n) except -1:             # <<<<<<<<<<<<<<
 *     return py_to_lua(runtime, L,
 *                      (<object>py_obj.obj)[ py_from_lua(runtime, L, key_n) ])
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_AddTraceback("lupa._lupa.getitem_for_lua", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lupa/_lupa.pyx":1565
 *                      (<object>py_obj.obj)[ py_from_lua(runtime, L, key_n) ])
 * 
 * cdef int setitem_for_lua(LuaRuntime runtime, lua_State* L, py_object* py_obj, int key_n, int value_n) except -1:             # <<<<<<<<<<<<<<
 *     (<object>py_obj.obj)[ py_from_lua(runtime, L, key_n) ] = py_from_lua(runtime, L, value_n)
 *     return 0
 */

static int __pyx_f_4lupa_5_lupa_setitem_for_lua(struct __pyx_obj_4lupa_5_lupa_LuaRuntime *__pyx_v_runtime, lua_State *__pyx_v_L, struct __pyx_t_4lupa_5_lupa_py_object *__pyx_v_py_obj, int __pyx_v_key_n, int __pyx_v_value_n) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("setitem_for_lua", 0);

  /* "lupa/_lupa.pyx":1566
 * 
 * cdef int setitem_for_lua(LuaRuntime runtime, lua_State* L, py_object* py_obj, int key_n, int value_n) except -1:
 *     (<object>py_obj.obj)[ py_from_lua(runtime, L, key_n) ] = py_from_lua(runtime, L, value_n)             # <<<<<<<<<<<<<<
 *     return 0
 * 
 */
  __pyx_t_1 = __pyx_f_4lupa_5_lupa_py_from_lua(__pyx_v_runtime, __pyx_v_L, __pyx_v_value_n); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1566, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __pyx_f_4lupa_5_lupa_py_from_lua(__pyx_v_runtime, __pyx_v_L, __pyx_v_key_n); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1566, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (unlikely(PyObject_SetItem(((PyObject *)__pyx_v_py_obj->obj), __pyx_t_2, __pyx_t_1) < 0)) __PYX_ERR(0, 1566, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "lupa/_lupa.pyx":1567
 * cdef int setitem_for_lua(LuaRuntime runtime, lua_State* L, py_object* py_obj, int key_n, int value_n) except -1:
 *     (<object>py_obj.obj)[ py_from_lua(runtime, L, key_n) ] = py_from_lua(runtime, L, value_n)
 *     return 0             # <<<<<<<<<<<<<<
 * 
 * cdef int getattr_for_lua(LuaRuntime runtime, lua_State* L, py_object* py_obj, int key_n) except -1:
 */
  __pyx_r = 0;
  goto __pyx_L0;

  /* "lupa/_lupa.pyx":1565
 *                      (<object>py_obj.obj)[ py_from_lua(runtime, L, key_n) ])
 * 
 * cdef int setitem_for_lua(LuaRuntime runtime, lua_State* L, py_object* py_obj, int key_n, int value_n) except -1:             # <<<<<<<<<<<<<<
 *     (<object>py_obj.obj)[ py_from_lua(runtime, L, key_n) ] = py_from_lua(runtime, L, value_n)
 *     return 0
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_AddTraceback("lupa._lupa.setitem_for_lua", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lupa/_lupa.pyx":1569
 *     return 0
 * 
 * cdef int getattr_for_lua(LuaRuntime runtime, lua_State* L, py_object* py_obj, int key_n) except -1:             # <<<<<<<<<<<<<<
 *     obj = <object>py_obj.obj
 *     attr_name = py_from_lua(runtime, L, key_n)
 */

static int __pyx_f_4lupa_5_lupa_getattr_for_lua(struct __pyx_obj_4lupa_5_lupa_LuaRuntime *__pyx_v_runtime, lua_State *__pyx_v_L, struct __pyx_t_4lupa_5_lupa_py_object *__pyx_v_py_obj, int __pyx_v_key_n) {
  PyObject *__pyx_v_obj = NULL;
  PyObject *__pyx_v_attr_name = NULL;
  PyObject *__pyx_v_value = NULL;
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_t_2;
  int __pyx_t_3;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  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("getattr_for_lua", 0);

  /* "lupa/_lupa.pyx":1570
 * 
 * cdef int getattr_for_lua(LuaRuntime runtime, lua_State* L, py_object* py_obj, int key_n) except -1:
 *     obj = <object>py_obj.obj             # <<<<<<<<<<<<<<
 *     attr_name = py_from_lua(runtime, L, key_n)
 *     if runtime._attribute_getter is not None:
 */
  __pyx_t_1 = ((PyObject *)__pyx_v_py_obj->obj);
  __Pyx_INCREF(__pyx_t_1);
  __pyx_v_obj = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "lupa/_lupa.pyx":1571
 * cdef int getattr_for_lua(LuaRuntime runtime, lua_State* L, py_object* py_obj, int key_n) except -1:
 *     obj = <object>py_obj.obj
 *     attr_name = py_from_lua(runtime, L, key_n)             # <<<<<<<<<<<<<<
 *     if runtime._attribute_getter is not None:
 *         value = runtime._attribute_getter(obj, attr_name)
 */
  __pyx_t_1 = __pyx_f_4lupa_5_lupa_py_from_lua(__pyx_v_runtime, __pyx_v_L, __pyx_v_key_n); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1571, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_attr_name = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "lupa/_lupa.pyx":1572
 *     obj = <object>py_obj.obj
 *     attr_name = py_from_lua(runtime, L, key_n)
 *     if runtime._attribute_getter is not None:             # <<<<<<<<<<<<<<
 *         value = runtime._attribute_getter(obj, attr_name)
 *         return py_to_lua(runtime, L, value)
 */
  __pyx_t_2 = (__pyx_v_runtime->_attribute_getter != Py_None);
  __pyx_t_3 = (__pyx_t_2 != 0);
  if (__pyx_t_3) {

    /* "lupa/_lupa.pyx":1573
 *     attr_name = py_from_lua(runtime, L, key_n)
 *     if runtime._attribute_getter is not None:
 *         value = runtime._attribute_getter(obj, attr_name)             # <<<<<<<<<<<<<<
 *         return py_to_lua(runtime, L, value)
 *     if runtime._attribute_filter is not None:
 */
    __Pyx_INCREF(__pyx_v_runtime->_attribute_getter);
    __pyx_t_4 = __pyx_v_runtime->_attribute_getter; __pyx_t_5 = NULL;
    __pyx_t_6 = 0;
    if (CYTHON_UNPACK_METHODS && likely(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_6 = 1;
      }
    }
    #if CYTHON_FAST_PYCALL
    if (PyFunction_Check(__pyx_t_4)) {
      PyObject *__pyx_temp[3] = {__pyx_t_5, __pyx_v_obj, __pyx_v_attr_name};
      __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_6, 2+__pyx_t_6); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1573, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
      __Pyx_GOTREF(__pyx_t_1);
    } else
    #endif
    #if CYTHON_FAST_PYCCALL
    if (__Pyx_PyFastCFunction_Check(__pyx_t_4)) {
      PyObject *__pyx_temp[3] = {__pyx_t_5, __pyx_v_obj, __pyx_v_attr_name};
      __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_6, 2+__pyx_t_6); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1573, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
      __Pyx_GOTREF(__pyx_t_1);
    } else
    #endif
    {
      __pyx_t_7 = PyTuple_New(2+__pyx_t_6); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1573, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_7);
      if (__pyx_t_5) {
        __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_5); __pyx_t_5 = NULL;
      }
      __Pyx_INCREF(__pyx_v_obj);
      __Pyx_GIVEREF(__pyx_v_obj);
      PyTuple_SET_ITEM(__pyx_t_7, 0+__pyx_t_6, __pyx_v_obj);
      __Pyx_INCREF(__pyx_v_attr_name);
      __Pyx_GIVEREF(__pyx_v_attr_name);
      PyTuple_SET_ITEM(__pyx_t_7, 1+__pyx_t_6, __pyx_v_attr_name);
      __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_7, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1573, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    }
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_v_value = __pyx_t_1;
    __pyx_t_1 = 0;

    /* "lupa/_lupa.pyx":1574
 *     if runtime._attribute_getter is not None:
 *         value = runtime._attribute_getter(obj, attr_name)
 *         return py_to_lua(runtime, L, value)             # <<<<<<<<<<<<<<
 *     if runtime._attribute_filter is not None:
 *         attr_name = runtime._attribute_filter(obj, attr_name, False)
 */
    __pyx_t_6 = __pyx_f_4lupa_5_lupa_py_to_lua(__pyx_v_runtime, __pyx_v_L, __pyx_v_value, NULL); if (unlikely(__pyx_t_6 == ((int)-1))) __PYX_ERR(0, 1574, __pyx_L1_error)
    __pyx_r = __pyx_t_6;
    goto __pyx_L0;

    /* "lupa/_lupa.pyx":1572
 *     obj = <object>py_obj.obj
 *     attr_name = py_from_lua(runtime, L, key_n)
 *     if runtime._attribute_getter is not None:             # <<<<<<<<<<<<<<
 *         value = runtime._attribute_getter(obj, attr_name)
 *         return py_to_lua(runtime, L, value)
 */
  }

  /* "lupa/_lupa.pyx":1575
 *         value = runtime._attribute_getter(obj, attr_name)
 *         return py_to_lua(runtime, L, value)
 *     if runtime._attribute_filter is not None:             # <<<<<<<<<<<<<<
 *         attr_name = runtime._attribute_filter(obj, attr_name, False)
 *     if isinstance(attr_name, bytes):
 */
  __pyx_t_3 = (__pyx_v_runtime->_attribute_filter != Py_None);
  __pyx_t_2 = (__pyx_t_3 != 0);
  if (__pyx_t_2) {

    /* "lupa/_lupa.pyx":1576
 *         return py_to_lua(runtime, L, value)
 *     if runtime._attribute_filter is not None:
 *         attr_name = runtime._attribute_filter(obj, attr_name, False)             # <<<<<<<<<<<<<<
 *     if isinstance(attr_name, bytes):
 *         attr_name = (<bytes>attr_name).decode(runtime._source_encoding)
 */
    __Pyx_INCREF(__pyx_v_runtime->_attribute_filter);
    __pyx_t_4 = __pyx_v_runtime->_attribute_filter; __pyx_t_7 = NULL;
    __pyx_t_6 = 0;
    if (CYTHON_UNPACK_METHODS && likely(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_6 = 1;
      }
    }
    #if CYTHON_FAST_PYCALL
    if (PyFunction_Check(__pyx_t_4)) {
      PyObject *__pyx_temp[4] = {__pyx_t_7, __pyx_v_obj, __pyx_v_attr_name, Py_False};
      __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_6, 3+__pyx_t_6); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1576, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
      __Pyx_GOTREF(__pyx_t_1);
    } else
    #endif
    #if CYTHON_FAST_PYCCALL
    if (__Pyx_PyFastCFunction_Check(__pyx_t_4)) {
      PyObject *__pyx_temp[4] = {__pyx_t_7, __pyx_v_obj, __pyx_v_attr_name, Py_False};
      __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_6, 3+__pyx_t_6); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1576, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
      __Pyx_GOTREF(__pyx_t_1);
    } else
    #endif
    {
      __pyx_t_5 = PyTuple_New(3+__pyx_t_6); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1576, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
      if (__pyx_t_7) {
        __Pyx_GIVEREF(__pyx_t_7); PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_7); __pyx_t_7 = NULL;
      }
      __Pyx_INCREF(__pyx_v_obj);
      __Pyx_GIVEREF(__pyx_v_obj);
      PyTuple_SET_ITEM(__pyx_t_5, 0+__pyx_t_6, __pyx_v_obj);
      __Pyx_INCREF(__pyx_v_attr_name);
      __Pyx_GIVEREF(__pyx_v_attr_name);
      PyTuple_SET_ITEM(__pyx_t_5, 1+__pyx_t_6, __pyx_v_attr_name);
      __Pyx_INCREF(Py_False);
      __Pyx_GIVEREF(Py_False);
      PyTuple_SET_ITEM(__pyx_t_5, 2+__pyx_t_6, Py_False);
      __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_5, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1576, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    }
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_DECREF_SET(__pyx_v_attr_name, __pyx_t_1);
    __pyx_t_1 = 0;

    /* "lupa/_lupa.pyx":1575
 *         value = runtime._attribute_getter(obj, attr_name)
 *         return py_to_lua(runtime, L, value)
 *     if runtime._attribute_filter is not None:             # <<<<<<<<<<<<<<
 *         attr_name = runtime._attribute_filter(obj, attr_name, False)
 *     if isinstance(attr_name, bytes):
 */
  }

  /* "lupa/_lupa.pyx":1577
 *     if runtime._attribute_filter is not None:
 *         attr_name = runtime._attribute_filter(obj, attr_name, False)
 *     if isinstance(attr_name, bytes):             # <<<<<<<<<<<<<<
 *         attr_name = (<bytes>attr_name).decode(runtime._source_encoding)
 *     return py_to_lua(runtime, L, getattr(obj, attr_name))
 */
  __pyx_t_2 = PyBytes_Check(__pyx_v_attr_name); 
  __pyx_t_3 = (__pyx_t_2 != 0);
  if (__pyx_t_3) {

    /* "lupa/_lupa.pyx":1578
 *         attr_name = runtime._attribute_filter(obj, attr_name, False)
 *     if isinstance(attr_name, bytes):
 *         attr_name = (<bytes>attr_name).decode(runtime._source_encoding)             # <<<<<<<<<<<<<<
 *     return py_to_lua(runtime, L, getattr(obj, attr_name))
 * 
 */
    if (unlikely(__pyx_v_attr_name == Py_None)) {
      PyErr_Format(PyExc_AttributeError, "'NoneType' object has no attribute '%.30s'", "decode");
      __PYX_ERR(0, 1578, __pyx_L1_error)
    }
    if (unlikely(__pyx_v_runtime->_source_encoding == Py_None)) {
      PyErr_SetString(PyExc_TypeError, "expected bytes, NoneType found");
      __PYX_ERR(0, 1578, __pyx_L1_error)
    }
    __pyx_t_8 = __Pyx_PyBytes_AsString(__pyx_v_runtime->_source_encoding); if (unlikely((!__pyx_t_8) && PyErr_Occurred())) __PYX_ERR(0, 1578, __pyx_L1_error)
    __pyx_t_1 = __Pyx_decode_bytes(((PyObject*)__pyx_v_attr_name), 0, PY_SSIZE_T_MAX, __pyx_t_8, NULL, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1578, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF_SET(__pyx_v_attr_name, __pyx_t_1);
    __pyx_t_1 = 0;

    /* "lupa/_lupa.pyx":1577
 *     if runtime._attribute_filter is not None:
 *         attr_name = runtime._attribute_filter(obj, attr_name, False)
 *     if isinstance(attr_name, bytes):             # <<<<<<<<<<<<<<
 *         attr_name = (<bytes>attr_name).decode(runtime._source_encoding)
 *     return py_to_lua(runtime, L, getattr(obj, attr_name))
 */
  }

  /* "lupa/_lupa.pyx":1579
 *     if isinstance(attr_name, bytes):
 *         attr_name = (<bytes>attr_name).decode(runtime._source_encoding)
 *     return py_to_lua(runtime, L, getattr(obj, attr_name))             # <<<<<<<<<<<<<<
 * 
 * cdef int setattr_for_lua(LuaRuntime runtime, lua_State* L, py_object* py_obj, int key_n, int value_n) except -1:
 */
  __pyx_t_1 = __Pyx_GetAttr(__pyx_v_obj, __pyx_v_attr_name); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1579, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_6 = __pyx_f_4lupa_5_lupa_py_to_lua(__pyx_v_runtime, __pyx_v_L, __pyx_t_1, NULL); if (unlikely(__pyx_t_6 == ((int)-1))) __PYX_ERR(0, 1579, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_r = __pyx_t_6;
  goto __pyx_L0;

  /* "lupa/_lupa.pyx":1569
 *     return 0
 * 
 * cdef int getattr_for_lua(LuaRuntime runtime, lua_State* L, py_object* py_obj, int key_n) except -1:             # <<<<<<<<<<<<<<
 *     obj = <object>py_obj.obj
 *     attr_name = py_from_lua(runtime, L, key_n)
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_AddTraceback("lupa._lupa.getattr_for_lua", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_obj);
  __Pyx_XDECREF(__pyx_v_attr_name);
  __Pyx_XDECREF(__pyx_v_value);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lupa/_lupa.pyx":1581
 *     return py_to_lua(runtime, L, getattr(obj, attr_name))
 * 
 * cdef int setattr_for_lua(LuaRuntime runtime, lua_State* L, py_object* py_obj, int key_n, int value_n) except -1:             # <<<<<<<<<<<<<<
 *     obj = <object>py_obj.obj
 *     attr_name = py_from_lua(runtime, L, key_n)
 */

static int __pyx_f_4lupa_5_lupa_setattr_for_lua(struct __pyx_obj_4lupa_5_lupa_LuaRuntime *__pyx_v_runtime, lua_State *__pyx_v_L, struct __pyx_t_4lupa_5_lupa_py_object *__pyx_v_py_obj, int __pyx_v_key_n, int __pyx_v_value_n) {
  PyObject *__pyx_v_obj = NULL;
  PyObject *__pyx_v_attr_name = NULL;
  PyObject *__pyx_v_attr_value = NULL;
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_t_2;
  int __pyx_t_3;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  int __pyx_t_6;
  PyObject *__pyx_t_7 = NULL;
  char const *__pyx_t_8;
  int __pyx_t_9;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("setattr_for_lua", 0);

  /* "lupa/_lupa.pyx":1582
 * 
 * cdef int setattr_for_lua(LuaRuntime runtime, lua_State* L, py_object* py_obj, int key_n, int value_n) except -1:
 *     obj = <object>py_obj.obj             # <<<<<<<<<<<<<<
 *     attr_name = py_from_lua(runtime, L, key_n)
 *     attr_value = py_from_lua(runtime, L, value_n)
 */
  __pyx_t_1 = ((PyObject *)__pyx_v_py_obj->obj);
  __Pyx_INCREF(__pyx_t_1);
  __pyx_v_obj = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "lupa/_lupa.pyx":1583
 * cdef int setattr_for_lua(LuaRuntime runtime, lua_State* L, py_object* py_obj, int key_n, int value_n) except -1:
 *     obj = <object>py_obj.obj
 *     attr_name = py_from_lua(runtime, L, key_n)             # <<<<<<<<<<<<<<
 *     attr_value = py_from_lua(runtime, L, value_n)
 *     if runtime._attribute_setter is not None:
 */
  __pyx_t_1 = __pyx_f_4lupa_5_lupa_py_from_lua(__pyx_v_runtime, __pyx_v_L, __pyx_v_key_n); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1583, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_attr_name = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "lupa/_lupa.pyx":1584
 *     obj = <object>py_obj.obj
 *     attr_name = py_from_lua(runtime, L, key_n)
 *     attr_value = py_from_lua(runtime, L, value_n)             # <<<<<<<<<<<<<<
 *     if runtime._attribute_setter is not None:
 *         runtime._attribute_setter(obj, attr_name, attr_value)
 */
  __pyx_t_1 = __pyx_f_4lupa_5_lupa_py_from_lua(__pyx_v_runtime, __pyx_v_L, __pyx_v_value_n); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1584, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_attr_value = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "lupa/_lupa.pyx":1585
 *     attr_name = py_from_lua(runtime, L, key_n)
 *     attr_value = py_from_lua(runtime, L, value_n)
 *     if runtime._attribute_setter is not None:             # <<<<<<<<<<<<<<
 *         runtime._attribute_setter(obj, attr_name, attr_value)
 *     else:
 */
  __pyx_t_2 = (__pyx_v_runtime->_attribute_setter != Py_None);
  __pyx_t_3 = (__pyx_t_2 != 0);
  if (__pyx_t_3) {

    /* "lupa/_lupa.pyx":1586
 *     attr_value = py_from_lua(runtime, L, value_n)
 *     if runtime._attribute_setter is not None:
 *         runtime._attribute_setter(obj, attr_name, attr_value)             # <<<<<<<<<<<<<<
 *     else:
 *         if runtime._attribute_filter is not None:
 */
    __Pyx_INCREF(__pyx_v_runtime->_attribute_setter);
    __pyx_t_4 = __pyx_v_runtime->_attribute_setter; __pyx_t_5 = NULL;
    __pyx_t_6 = 0;
    if (CYTHON_UNPACK_METHODS && likely(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_6 = 1;
      }
    }
    #if CYTHON_FAST_PYCALL
    if (PyFunction_Check(__pyx_t_4)) {
      PyObject *__pyx_temp[4] = {__pyx_t_5, __pyx_v_obj, __pyx_v_attr_name, __pyx_v_attr_value};
      __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_6, 3+__pyx_t_6); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1586, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
      __Pyx_GOTREF(__pyx_t_1);
    } else
    #endif
    #if CYTHON_FAST_PYCCALL
    if (__Pyx_PyFastCFunction_Check(__pyx_t_4)) {
      PyObject *__pyx_temp[4] = {__pyx_t_5, __pyx_v_obj, __pyx_v_attr_name, __pyx_v_attr_value};
      __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_6, 3+__pyx_t_6); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1586, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
      __Pyx_GOTREF(__pyx_t_1);
    } else
    #endif
    {
      __pyx_t_7 = PyTuple_New(3+__pyx_t_6); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1586, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_7);
      if (__pyx_t_5) {
        __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_5); __pyx_t_5 = NULL;
      }
      __Pyx_INCREF(__pyx_v_obj);
      __Pyx_GIVEREF(__pyx_v_obj);
      PyTuple_SET_ITEM(__pyx_t_7, 0+__pyx_t_6, __pyx_v_obj);
      __Pyx_INCREF(__pyx_v_attr_name);
      __Pyx_GIVEREF(__pyx_v_attr_name);
      PyTuple_SET_ITEM(__pyx_t_7, 1+__pyx_t_6, __pyx_v_attr_name);
      __Pyx_INCREF(__pyx_v_attr_value);
      __Pyx_GIVEREF(__pyx_v_attr_value);
      PyTuple_SET_ITEM(__pyx_t_7, 2+__pyx_t_6, __pyx_v_attr_value);
      __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_7, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1586, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    }
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

    /* "lupa/_lupa.pyx":1585
 *     attr_name = py_from_lua(runtime, L, key_n)
 *     attr_value = py_from_lua(runtime, L, value_n)
 *     if runtime._attribute_setter is not None:             # <<<<<<<<<<<<<<
 *         runtime._attribute_setter(obj, attr_name, attr_value)
 *     else:
 */
    goto __pyx_L3;
  }

  /* "lupa/_lupa.pyx":1588
 *         runtime._attribute_setter(obj, attr_name, attr_value)
 *     else:
 *         if runtime._attribute_filter is not None:             # <<<<<<<<<<<<<<
 *             attr_name = runtime._attribute_filter(obj, attr_name, True)
 *         if isinstance(attr_name, bytes):
 */
  /*else*/ {
    __pyx_t_3 = (__pyx_v_runtime->_attribute_filter != Py_None);
    __pyx_t_2 = (__pyx_t_3 != 0);
    if (__pyx_t_2) {

      /* "lupa/_lupa.pyx":1589
 *     else:
 *         if runtime._attribute_filter is not None:
 *             attr_name = runtime._attribute_filter(obj, attr_name, True)             # <<<<<<<<<<<<<<
 *         if isinstance(attr_name, bytes):
 *             attr_name = (<bytes>attr_name).decode(runtime._source_encoding)
 */
      __Pyx_INCREF(__pyx_v_runtime->_attribute_filter);
      __pyx_t_4 = __pyx_v_runtime->_attribute_filter; __pyx_t_7 = NULL;
      __pyx_t_6 = 0;
      if (CYTHON_UNPACK_METHODS && likely(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_6 = 1;
        }
      }
      #if CYTHON_FAST_PYCALL
      if (PyFunction_Check(__pyx_t_4)) {
        PyObject *__pyx_temp[4] = {__pyx_t_7, __pyx_v_obj, __pyx_v_attr_name, Py_True};
        __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_6, 3+__pyx_t_6); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1589, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
        __Pyx_GOTREF(__pyx_t_1);
      } else
      #endif
      #if CYTHON_FAST_PYCCALL
      if (__Pyx_PyFastCFunction_Check(__pyx_t_4)) {
        PyObject *__pyx_temp[4] = {__pyx_t_7, __pyx_v_obj, __pyx_v_attr_name, Py_True};
        __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_6, 3+__pyx_t_6); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1589, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
        __Pyx_GOTREF(__pyx_t_1);
      } else
      #endif
      {
        __pyx_t_5 = PyTuple_New(3+__pyx_t_6); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1589, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_5);
        if (__pyx_t_7) {
          __Pyx_GIVEREF(__pyx_t_7); PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_7); __pyx_t_7 = NULL;
        }
        __Pyx_INCREF(__pyx_v_obj);
        __Pyx_GIVEREF(__pyx_v_obj);
        PyTuple_SET_ITEM(__pyx_t_5, 0+__pyx_t_6, __pyx_v_obj);
        __Pyx_INCREF(__pyx_v_attr_name);
        __Pyx_GIVEREF(__pyx_v_attr_name);
        PyTuple_SET_ITEM(__pyx_t_5, 1+__pyx_t_6, __pyx_v_attr_name);
        __Pyx_INCREF(Py_True);
        __Pyx_GIVEREF(Py_True);
        PyTuple_SET_ITEM(__pyx_t_5, 2+__pyx_t_6, Py_True);
        __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_5, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1589, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_1);
        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      }
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __Pyx_DECREF_SET(__pyx_v_attr_name, __pyx_t_1);
      __pyx_t_1 = 0;

      /* "lupa/_lupa.pyx":1588
 *         runtime._attribute_setter(obj, attr_name, attr_value)
 *     else:
 *         if runtime._attribute_filter is not None:             # <<<<<<<<<<<<<<
 *             attr_name = runtime._attribute_filter(obj, attr_name, True)
 *         if isinstance(attr_name, bytes):
 */
    }

    /* "lupa/_lupa.pyx":1590
 *         if runtime._attribute_filter is not None:
 *             attr_name = runtime._attribute_filter(obj, attr_name, True)
 *         if isinstance(attr_name, bytes):             # <<<<<<<<<<<<<<
 *             attr_name = (<bytes>attr_name).decode(runtime._source_encoding)
 *         setattr(obj, attr_name, attr_value)
 */
    __pyx_t_2 = PyBytes_Check(__pyx_v_attr_name); 
    __pyx_t_3 = (__pyx_t_2 != 0);
    if (__pyx_t_3) {

      /* "lupa/_lupa.pyx":1591
 *             attr_name = runtime._attribute_filter(obj, attr_name, True)
 *         if isinstance(attr_name, bytes):
 *             attr_name = (<bytes>attr_name).decode(runtime._source_encoding)             # <<<<<<<<<<<<<<
 *         setattr(obj, attr_name, attr_value)
 *     return 0
 */
      if (unlikely(__pyx_v_attr_name == Py_None)) {
        PyErr_Format(PyExc_AttributeError, "'NoneType' object has no attribute '%.30s'", "decode");
        __PYX_ERR(0, 1591, __pyx_L1_error)
      }
      if (unlikely(__pyx_v_runtime->_source_encoding == Py_None)) {
        PyErr_SetString(PyExc_TypeError, "expected bytes, NoneType found");
        __PYX_ERR(0, 1591, __pyx_L1_error)
      }
      __pyx_t_8 = __Pyx_PyBytes_AsString(__pyx_v_runtime->_source_encoding); if (unlikely((!__pyx_t_8) && PyErr_Occurred())) __PYX_ERR(0, 1591, __pyx_L1_error)
      __pyx_t_1 = __Pyx_decode_bytes(((PyObject*)__pyx_v_attr_name), 0, PY_SSIZE_T_MAX, __pyx_t_8, NULL, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1591, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF_SET(__pyx_v_attr_name, __pyx_t_1);
      __pyx_t_1 = 0;

      /* "lupa/_lupa.pyx":1590
 *         if runtime._attribute_filter is not None:
 *             attr_name = runtime._attribute_filter(obj, attr_name, True)
 *         if isinstance(attr_name, bytes):             # <<<<<<<<<<<<<<
 *             attr_name = (<bytes>attr_name).decode(runtime._source_encoding)
 *         setattr(obj, attr_name, attr_value)
 */
    }

    /* "lupa/_lupa.pyx":1592
 *         if isinstance(attr_name, bytes):
 *             attr_name = (<bytes>attr_name).decode(runtime._source_encoding)
 *         setattr(obj, attr_name, attr_value)             # <<<<<<<<<<<<<<
 *     return 0
 * 
 */
    __pyx_t_9 = PyObject_SetAttr(__pyx_v_obj, __pyx_v_attr_name, __pyx_v_attr_value); if (unlikely(__pyx_t_9 == ((int)-1))) __PYX_ERR(0, 1592, __pyx_L1_error)
  }
  __pyx_L3:;

  /* "lupa/_lupa.pyx":1593
 *             attr_name = (<bytes>attr_name).decode(runtime._source_encoding)
 *         setattr(obj, attr_name, attr_value)
 *     return 0             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_r = 0;
  goto __pyx_L0;

  /* "lupa/_lupa.pyx":1581
 *     return py_to_lua(runtime, L, getattr(obj, attr_name))
 * 
 * cdef int setattr_for_lua(LuaRuntime runtime, lua_State* L, py_object* py_obj, int key_n, int value_n) except -1:             # <<<<<<<<<<<<<<
 *     obj = <object>py_obj.obj
 *     attr_name = py_from_lua(runtime, L, key_n)
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_AddTraceback("lupa._lupa.setattr_for_lua", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_obj);
  __Pyx_XDECREF(__pyx_v_attr_name);
  __Pyx_XDECREF(__pyx_v_attr_value);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lupa/_lupa.pyx":1596
 * 
 * 
 * cdef int py_object_getindex_with_gil(lua_State* L, py_object* py_obj) with gil:             # <<<<<<<<<<<<<<
 *     cdef LuaRuntime runtime
 *     try:
 */

static int __pyx_f_4lupa_5_lupa_py_object_getindex_with_gil(lua_State *__pyx_v_L, struct __pyx_t_4lupa_5_lupa_py_object *__pyx_v_py_obj) {
  struct __pyx_obj_4lupa_5_lupa_LuaRuntime *__pyx_v_runtime = 0;
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  int __pyx_t_5;
  int __pyx_t_6;
  int __pyx_t_7;
  int __pyx_t_8;
  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("py_object_getindex_with_gil", 0);

  /* "lupa/_lupa.pyx":1598
 * cdef int py_object_getindex_with_gil(lua_State* L, py_object* py_obj) with gil:
 *     cdef LuaRuntime runtime
 *     try:             # <<<<<<<<<<<<<<
 *         runtime = <LuaRuntime?>py_obj.runtime
 *         if (py_obj.type_flags & OBJ_AS_INDEX) and not runtime._attribute_getter:
 */
  {
    __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:*/ {

      /* "lupa/_lupa.pyx":1599
 *     cdef LuaRuntime runtime
 *     try:
 *         runtime = <LuaRuntime?>py_obj.runtime             # <<<<<<<<<<<<<<
 *         if (py_obj.type_flags & OBJ_AS_INDEX) and not runtime._attribute_getter:
 *             return getitem_for_lua(runtime, L, py_obj, 2)
 */
      __pyx_t_4 = ((PyObject *)__pyx_v_py_obj->runtime);
      __Pyx_INCREF(__pyx_t_4);
      __pyx_v_runtime = ((struct __pyx_obj_4lupa_5_lupa_LuaRuntime *)__pyx_t_4);
      __pyx_t_4 = 0;

      /* "lupa/_lupa.pyx":1600
 *     try:
 *         runtime = <LuaRuntime?>py_obj.runtime
 *         if (py_obj.type_flags & OBJ_AS_INDEX) and not runtime._attribute_getter:             # <<<<<<<<<<<<<<
 *             return getitem_for_lua(runtime, L, py_obj, 2)
 *         else:
 */
      __pyx_t_6 = ((__pyx_v_py_obj->type_flags & __pyx_e_4lupa_5_lupa_OBJ_AS_INDEX) != 0);
      if (__pyx_t_6) {
      } else {
        __pyx_t_5 = __pyx_t_6;
        goto __pyx_L10_bool_binop_done;
      }
      __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_v_runtime->_attribute_getter); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(0, 1600, __pyx_L3_error)
      __pyx_t_7 = ((!__pyx_t_6) != 0);
      __pyx_t_5 = __pyx_t_7;
      __pyx_L10_bool_binop_done:;
      if (__pyx_t_5) {

        /* "lupa/_lupa.pyx":1601
 *         runtime = <LuaRuntime?>py_obj.runtime
 *         if (py_obj.type_flags & OBJ_AS_INDEX) and not runtime._attribute_getter:
 *             return getitem_for_lua(runtime, L, py_obj, 2)             # <<<<<<<<<<<<<<
 *         else:
 *             return getattr_for_lua(runtime, L, py_obj, 2)
 */
        __pyx_t_8 = __pyx_f_4lupa_5_lupa_getitem_for_lua(__pyx_v_runtime, __pyx_v_L, __pyx_v_py_obj, 2); if (unlikely(__pyx_t_8 == ((int)-1))) __PYX_ERR(0, 1601, __pyx_L3_error)
        __pyx_r = __pyx_t_8;
        goto __pyx_L7_try_return;

        /* "lupa/_lupa.pyx":1600
 *     try:
 *         runtime = <LuaRuntime?>py_obj.runtime
 *         if (py_obj.type_flags & OBJ_AS_INDEX) and not runtime._attribute_getter:             # <<<<<<<<<<<<<<
 *             return getitem_for_lua(runtime, L, py_obj, 2)
 *         else:
 */
      }

      /* "lupa/_lupa.pyx":1603
 *             return getitem_for_lua(runtime, L, py_obj, 2)
 *         else:
 *             return getattr_for_lua(runtime, L, py_obj, 2)             # <<<<<<<<<<<<<<
 *     except:
 *         runtime.store_raised_exception(L, b'error reading Python attribute/item')
 */
      /*else*/ {
        __pyx_t_8 = __pyx_f_4lupa_5_lupa_getattr_for_lua(__pyx_v_runtime, __pyx_v_L, __pyx_v_py_obj, 2); if (unlikely(__pyx_t_8 == ((int)-1))) __PYX_ERR(0, 1603, __pyx_L3_error)
        __pyx_r = __pyx_t_8;
        goto __pyx_L7_try_return;
      }

      /* "lupa/_lupa.pyx":1598
 * cdef int py_object_getindex_with_gil(lua_State* L, py_object* py_obj) with gil:
 *     cdef LuaRuntime runtime
 *     try:             # <<<<<<<<<<<<<<
 *         runtime = <LuaRuntime?>py_obj.runtime
 *         if (py_obj.type_flags & OBJ_AS_INDEX) and not runtime._attribute_getter:
 */
    }
    __pyx_L3_error:;
    __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;

    /* "lupa/_lupa.pyx":1604
 *         else:
 *             return getattr_for_lua(runtime, L, py_obj, 2)
 *     except:             # <<<<<<<<<<<<<<
 *         runtime.store_raised_exception(L, b'error reading Python attribute/item')
 *         return -1
 */
    /*except:*/ {
      __Pyx_AddTraceback("lupa._lupa.py_object_getindex_with_gil", __pyx_clineno, __pyx_lineno, __pyx_filename);
      if (__Pyx_GetException(&__pyx_t_4, &__pyx_t_9, &__pyx_t_10) < 0) __PYX_ERR(0, 1604, __pyx_L5_except_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_GOTREF(__pyx_t_9);
      __Pyx_GOTREF(__pyx_t_10);

      /* "lupa/_lupa.pyx":1605
 *             return getattr_for_lua(runtime, L, py_obj, 2)
 *     except:
 *         runtime.store_raised_exception(L, b'error reading Python attribute/item')             # <<<<<<<<<<<<<<
 *         return -1
 * 
 */
      if (unlikely(!__pyx_v_runtime)) { __Pyx_RaiseUnboundLocalError("runtime"); __PYX_ERR(0, 1605, __pyx_L5_except_error) }
      __pyx_t_8 = __pyx_f_4lupa_5_lupa_10LuaRuntime_store_raised_exception(__pyx_v_runtime, __pyx_v_L, __pyx_kp_b_error_reading_Python_attribute_i); if (unlikely(__pyx_t_8 == ((int)-1))) __PYX_ERR(0, 1605, __pyx_L5_except_error)

      /* "lupa/_lupa.pyx":1606
 *     except:
 *         runtime.store_raised_exception(L, b'error reading Python attribute/item')
 *         return -1             # <<<<<<<<<<<<<<
 * 
 * cdef int py_object_getindex(lua_State* L) nogil:
 */
      __pyx_r = -1;
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
      __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
      goto __pyx_L6_except_return;
    }
    __pyx_L5_except_error:;

    /* "lupa/_lupa.pyx":1598
 * cdef int py_object_getindex_with_gil(lua_State* L, py_object* py_obj) with gil:
 *     cdef LuaRuntime runtime
 *     try:             # <<<<<<<<<<<<<<
 *         runtime = <LuaRuntime?>py_obj.runtime
 *         if (py_obj.type_flags & OBJ_AS_INDEX) and not runtime._attribute_getter:
 */
    __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;
  }

  /* "lupa/_lupa.pyx":1596
 * 
 * 
 * cdef int py_object_getindex_with_gil(lua_State* L, py_object* py_obj) with gil:             # <<<<<<<<<<<<<<
 *     cdef LuaRuntime runtime
 *     try:
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_9);
  __Pyx_XDECREF(__pyx_t_10);
  __Pyx_WriteUnraisable("lupa._lupa.py_object_getindex_with_gil", __pyx_clineno, __pyx_lineno, __pyx_filename, 1, 0);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_runtime);
  __Pyx_RefNannyFinishContext();
  #ifdef WITH_THREAD
  __Pyx_PyGILState_Release(__pyx_gilstate_save);
  #endif
  return __pyx_r;
}

/* "lupa/_lupa.pyx":1608
 *         return -1
 * 
 * cdef int py_object_getindex(lua_State* L) nogil:             # <<<<<<<<<<<<<<
 *     cdef py_object* py_obj = unwrap_lua_object(L, 1) # may not return on error!
 *     if not py_obj:
 */

static int __pyx_f_4lupa_5_lupa_py_object_getindex(lua_State *__pyx_v_L) {
  struct __pyx_t_4lupa_5_lupa_py_object *__pyx_v_py_obj;
  int __pyx_v_result;
  int __pyx_r;
  int __pyx_t_1;

  /* "lupa/_lupa.pyx":1609
 * 
 * cdef int py_object_getindex(lua_State* L) nogil:
 *     cdef py_object* py_obj = unwrap_lua_object(L, 1) # may not return on error!             # <<<<<<<<<<<<<<
 *     if not py_obj:
 *         return lua.luaL_argerror(L, 1, "not a python object")   # never returns!
 */
  __pyx_v_py_obj = __pyx_f_4lupa_5_lupa_unwrap_lua_object(__pyx_v_L, 1);

  /* "lupa/_lupa.pyx":1610
 * cdef int py_object_getindex(lua_State* L) nogil:
 *     cdef py_object* py_obj = unwrap_lua_object(L, 1) # may not return on error!
 *     if not py_obj:             # <<<<<<<<<<<<<<
 *         return lua.luaL_argerror(L, 1, "not a python object")   # never returns!
 *     result = py_object_getindex_with_gil(L, py_obj)
 */
  __pyx_t_1 = ((!(__pyx_v_py_obj != 0)) != 0);
  if (__pyx_t_1) {

    /* "lupa/_lupa.pyx":1611
 *     cdef py_object* py_obj = unwrap_lua_object(L, 1) # may not return on error!
 *     if not py_obj:
 *         return lua.luaL_argerror(L, 1, "not a python object")   # never returns!             # <<<<<<<<<<<<<<
 *     result = py_object_getindex_with_gil(L, py_obj)
 *     if result < 0:
 */
    __pyx_r = luaL_argerror(__pyx_v_L, 1, ((char *)"not a python object"));
    goto __pyx_L0;

    /* "lupa/_lupa.pyx":1610
 * cdef int py_object_getindex(lua_State* L) nogil:
 *     cdef py_object* py_obj = unwrap_lua_object(L, 1) # may not return on error!
 *     if not py_obj:             # <<<<<<<<<<<<<<
 *         return lua.luaL_argerror(L, 1, "not a python object")   # never returns!
 *     result = py_object_getindex_with_gil(L, py_obj)
 */
  }

  /* "lupa/_lupa.pyx":1612
 *     if not py_obj:
 *         return lua.luaL_argerror(L, 1, "not a python object")   # never returns!
 *     result = py_object_getindex_with_gil(L, py_obj)             # <<<<<<<<<<<<<<
 *     if result < 0:
 *         return lua.lua_error(L)  # never returns!
 */
  __pyx_v_result = __pyx_f_4lupa_5_lupa_py_object_getindex_with_gil(__pyx_v_L, __pyx_v_py_obj);

  /* "lupa/_lupa.pyx":1613
 *         return lua.luaL_argerror(L, 1, "not a python object")   # never returns!
 *     result = py_object_getindex_with_gil(L, py_obj)
 *     if result < 0:             # <<<<<<<<<<<<<<
 *         return lua.lua_error(L)  # never returns!
 *     return result
 */
  __pyx_t_1 = ((__pyx_v_result < 0) != 0);
  if (__pyx_t_1) {

    /* "lupa/_lupa.pyx":1614
 *     result = py_object_getindex_with_gil(L, py_obj)
 *     if result < 0:
 *         return lua.lua_error(L)  # never returns!             # <<<<<<<<<<<<<<
 *     return result
 * 
 */
    __pyx_r = lua_error(__pyx_v_L);
    goto __pyx_L0;

    /* "lupa/_lupa.pyx":1613
 *         return lua.luaL_argerror(L, 1, "not a python object")   # never returns!
 *     result = py_object_getindex_with_gil(L, py_obj)
 *     if result < 0:             # <<<<<<<<<<<<<<
 *         return lua.lua_error(L)  # never returns!
 *     return result
 */
  }

  /* "lupa/_lupa.pyx":1615
 *     if result < 0:
 *         return lua.lua_error(L)  # never returns!
 *     return result             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_r = __pyx_v_result;
  goto __pyx_L0;

  /* "lupa/_lupa.pyx":1608
 *         return -1
 * 
 * cdef int py_object_getindex(lua_State* L) nogil:             # <<<<<<<<<<<<<<
 *     cdef py_object* py_obj = unwrap_lua_object(L, 1) # may not return on error!
 *     if not py_obj:
 */

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

/* "lupa/_lupa.pyx":1618
 * 
 * 
 * cdef int py_object_setindex_with_gil(lua_State* L, py_object* py_obj) with gil:             # <<<<<<<<<<<<<<
 *     cdef LuaRuntime runtime
 *     try:
 */

static int __pyx_f_4lupa_5_lupa_py_object_setindex_with_gil(lua_State *__pyx_v_L, struct __pyx_t_4lupa_5_lupa_py_object *__pyx_v_py_obj) {
  struct __pyx_obj_4lupa_5_lupa_LuaRuntime *__pyx_v_runtime = 0;
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  int __pyx_t_5;
  int __pyx_t_6;
  int __pyx_t_7;
  int __pyx_t_8;
  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("py_object_setindex_with_gil", 0);

  /* "lupa/_lupa.pyx":1620
 * cdef int py_object_setindex_with_gil(lua_State* L, py_object* py_obj) with gil:
 *     cdef LuaRuntime runtime
 *     try:             # <<<<<<<<<<<<<<
 *         runtime = <LuaRuntime?>py_obj.runtime
 *         if (py_obj.type_flags & OBJ_AS_INDEX) and not runtime._attribute_setter:
 */
  {
    __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:*/ {

      /* "lupa/_lupa.pyx":1621
 *     cdef LuaRuntime runtime
 *     try:
 *         runtime = <LuaRuntime?>py_obj.runtime             # <<<<<<<<<<<<<<
 *         if (py_obj.type_flags & OBJ_AS_INDEX) and not runtime._attribute_setter:
 *             return setitem_for_lua(runtime, L, py_obj, 2, 3)
 */
      __pyx_t_4 = ((PyObject *)__pyx_v_py_obj->runtime);
      __Pyx_INCREF(__pyx_t_4);
      __pyx_v_runtime = ((struct __pyx_obj_4lupa_5_lupa_LuaRuntime *)__pyx_t_4);
      __pyx_t_4 = 0;

      /* "lupa/_lupa.pyx":1622
 *     try:
 *         runtime = <LuaRuntime?>py_obj.runtime
 *         if (py_obj.type_flags & OBJ_AS_INDEX) and not runtime._attribute_setter:             # <<<<<<<<<<<<<<
 *             return setitem_for_lua(runtime, L, py_obj, 2, 3)
 *         else:
 */
      __pyx_t_6 = ((__pyx_v_py_obj->type_flags & __pyx_e_4lupa_5_lupa_OBJ_AS_INDEX) != 0);
      if (__pyx_t_6) {
      } else {
        __pyx_t_5 = __pyx_t_6;
        goto __pyx_L10_bool_binop_done;
      }
      __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_v_runtime->_attribute_setter); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(0, 1622, __pyx_L3_error)
      __pyx_t_7 = ((!__pyx_t_6) != 0);
      __pyx_t_5 = __pyx_t_7;
      __pyx_L10_bool_binop_done:;
      if (__pyx_t_5) {

        /* "lupa/_lupa.pyx":1623
 *         runtime = <LuaRuntime?>py_obj.runtime
 *         if (py_obj.type_flags & OBJ_AS_INDEX) and not runtime._attribute_setter:
 *             return setitem_for_lua(runtime, L, py_obj, 2, 3)             # <<<<<<<<<<<<<<
 *         else:
 *             return setattr_for_lua(runtime, L, py_obj, 2, 3)
 */
        __pyx_t_8 = __pyx_f_4lupa_5_lupa_setitem_for_lua(__pyx_v_runtime, __pyx_v_L, __pyx_v_py_obj, 2, 3); if (unlikely(__pyx_t_8 == ((int)-1))) __PYX_ERR(0, 1623, __pyx_L3_error)
        __pyx_r = __pyx_t_8;
        goto __pyx_L7_try_return;

        /* "lupa/_lupa.pyx":1622
 *     try:
 *         runtime = <LuaRuntime?>py_obj.runtime
 *         if (py_obj.type_flags & OBJ_AS_INDEX) and not runtime._attribute_setter:             # <<<<<<<<<<<<<<
 *             return setitem_for_lua(runtime, L, py_obj, 2, 3)
 *         else:
 */
      }

      /* "lupa/_lupa.pyx":1625
 *             return setitem_for_lua(runtime, L, py_obj, 2, 3)
 *         else:
 *             return setattr_for_lua(runtime, L, py_obj, 2, 3)             # <<<<<<<<<<<<<<
 *     except:
 *         runtime.store_raised_exception(L, b'error writing Python attribute/item')
 */
      /*else*/ {
        __pyx_t_8 = __pyx_f_4lupa_5_lupa_setattr_for_lua(__pyx_v_runtime, __pyx_v_L, __pyx_v_py_obj, 2, 3); if (unlikely(__pyx_t_8 == ((int)-1))) __PYX_ERR(0, 1625, __pyx_L3_error)
        __pyx_r = __pyx_t_8;
        goto __pyx_L7_try_return;
      }

      /* "lupa/_lupa.pyx":1620
 * cdef int py_object_setindex_with_gil(lua_State* L, py_object* py_obj) with gil:
 *     cdef LuaRuntime runtime
 *     try:             # <<<<<<<<<<<<<<
 *         runtime = <LuaRuntime?>py_obj.runtime
 *         if (py_obj.type_flags & OBJ_AS_INDEX) and not runtime._attribute_setter:
 */
    }
    __pyx_L3_error:;
    __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;

    /* "lupa/_lupa.pyx":1626
 *         else:
 *             return setattr_for_lua(runtime, L, py_obj, 2, 3)
 *     except:             # <<<<<<<<<<<<<<
 *         runtime.store_raised_exception(L, b'error writing Python attribute/item')
 *         return -1
 */
    /*except:*/ {
      __Pyx_AddTraceback("lupa._lupa.py_object_setindex_with_gil", __pyx_clineno, __pyx_lineno, __pyx_filename);
      if (__Pyx_GetException(&__pyx_t_4, &__pyx_t_9, &__pyx_t_10) < 0) __PYX_ERR(0, 1626, __pyx_L5_except_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_GOTREF(__pyx_t_9);
      __Pyx_GOTREF(__pyx_t_10);

      /* "lupa/_lupa.pyx":1627
 *             return setattr_for_lua(runtime, L, py_obj, 2, 3)
 *     except:
 *         runtime.store_raised_exception(L, b'error writing Python attribute/item')             # <<<<<<<<<<<<<<
 *         return -1
 * 
 */
      if (unlikely(!__pyx_v_runtime)) { __Pyx_RaiseUnboundLocalError("runtime"); __PYX_ERR(0, 1627, __pyx_L5_except_error) }
      __pyx_t_8 = __pyx_f_4lupa_5_lupa_10LuaRuntime_store_raised_exception(__pyx_v_runtime, __pyx_v_L, __pyx_kp_b_error_writing_Python_attribute_i); if (unlikely(__pyx_t_8 == ((int)-1))) __PYX_ERR(0, 1627, __pyx_L5_except_error)

      /* "lupa/_lupa.pyx":1628
 *     except:
 *         runtime.store_raised_exception(L, b'error writing Python attribute/item')
 *         return -1             # <<<<<<<<<<<<<<
 * 
 * cdef int py_object_setindex(lua_State* L) nogil:
 */
      __pyx_r = -1;
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
      __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
      goto __pyx_L6_except_return;
    }
    __pyx_L5_except_error:;

    /* "lupa/_lupa.pyx":1620
 * cdef int py_object_setindex_with_gil(lua_State* L, py_object* py_obj) with gil:
 *     cdef LuaRuntime runtime
 *     try:             # <<<<<<<<<<<<<<
 *         runtime = <LuaRuntime?>py_obj.runtime
 *         if (py_obj.type_flags & OBJ_AS_INDEX) and not runtime._attribute_setter:
 */
    __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;
  }

  /* "lupa/_lupa.pyx":1618
 * 
 * 
 * cdef int py_object_setindex_with_gil(lua_State* L, py_object* py_obj) with gil:             # <<<<<<<<<<<<<<
 *     cdef LuaRuntime runtime
 *     try:
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_9);
  __Pyx_XDECREF(__pyx_t_10);
  __Pyx_WriteUnraisable("lupa._lupa.py_object_setindex_with_gil", __pyx_clineno, __pyx_lineno, __pyx_filename, 1, 0);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_runtime);
  __Pyx_RefNannyFinishContext();
  #ifdef WITH_THREAD
  __Pyx_PyGILState_Release(__pyx_gilstate_save);
  #endif
  return __pyx_r;
}

/* "lupa/_lupa.pyx":1630
 *         return -1
 * 
 * cdef int py_object_setindex(lua_State* L) nogil:             # <<<<<<<<<<<<<<
 *     cdef py_object* py_obj = unwrap_lua_object(L, 1) # may not return on error!
 *     if not py_obj:
 */

static int __pyx_f_4lupa_5_lupa_py_object_setindex(lua_State *__pyx_v_L) {
  struct __pyx_t_4lupa_5_lupa_py_object *__pyx_v_py_obj;
  int __pyx_v_result;
  int __pyx_r;
  int __pyx_t_1;

  /* "lupa/_lupa.pyx":1631
 * 
 * cdef int py_object_setindex(lua_State* L) nogil:
 *     cdef py_object* py_obj = unwrap_lua_object(L, 1) # may not return on error!             # <<<<<<<<<<<<<<
 *     if not py_obj:
 *         return lua.luaL_argerror(L, 1, "not a python object")   # never returns!
 */
  __pyx_v_py_obj = __pyx_f_4lupa_5_lupa_unwrap_lua_object(__pyx_v_L, 1);

  /* "lupa/_lupa.pyx":1632
 * cdef int py_object_setindex(lua_State* L) nogil:
 *     cdef py_object* py_obj = unwrap_lua_object(L, 1) # may not return on error!
 *     if not py_obj:             # <<<<<<<<<<<<<<
 *         return lua.luaL_argerror(L, 1, "not a python object")   # never returns!
 *     result = py_object_setindex_with_gil(L, py_obj)
 */
  __pyx_t_1 = ((!(__pyx_v_py_obj != 0)) != 0);
  if (__pyx_t_1) {

    /* "lupa/_lupa.pyx":1633
 *     cdef py_object* py_obj = unwrap_lua_object(L, 1) # may not return on error!
 *     if not py_obj:
 *         return lua.luaL_argerror(L, 1, "not a python object")   # never returns!             # <<<<<<<<<<<<<<
 *     result = py_object_setindex_with_gil(L, py_obj)
 *     if result < 0:
 */
    __pyx_r = luaL_argerror(__pyx_v_L, 1, ((char *)"not a python object"));
    goto __pyx_L0;

    /* "lupa/_lupa.pyx":1632
 * cdef int py_object_setindex(lua_State* L) nogil:
 *     cdef py_object* py_obj = unwrap_lua_object(L, 1) # may not return on error!
 *     if not py_obj:             # <<<<<<<<<<<<<<
 *         return lua.luaL_argerror(L, 1, "not a python object")   # never returns!
 *     result = py_object_setindex_with_gil(L, py_obj)
 */
  }

  /* "lupa/_lupa.pyx":1634
 *     if not py_obj:
 *         return lua.luaL_argerror(L, 1, "not a python object")   # never returns!
 *     result = py_object_setindex_with_gil(L, py_obj)             # <<<<<<<<<<<<<<
 *     if result < 0:
 *         return lua.lua_error(L)  # never returns!
 */
  __pyx_v_result = __pyx_f_4lupa_5_lupa_py_object_setindex_with_gil(__pyx_v_L, __pyx_v_py_obj);

  /* "lupa/_lupa.pyx":1635
 *         return lua.luaL_argerror(L, 1, "not a python object")   # never returns!
 *     result = py_object_setindex_with_gil(L, py_obj)
 *     if result < 0:             # <<<<<<<<<<<<<<
 *         return lua.lua_error(L)  # never returns!
 *     return result
 */
  __pyx_t_1 = ((__pyx_v_result < 0) != 0);
  if (__pyx_t_1) {

    /* "lupa/_lupa.pyx":1636
 *     result = py_object_setindex_with_gil(L, py_obj)
 *     if result < 0:
 *         return lua.lua_error(L)  # never returns!             # <<<<<<<<<<<<<<
 *     return result
 * 
 */
    __pyx_r = lua_error(__pyx_v_L);
    goto __pyx_L0;

    /* "lupa/_lupa.pyx":1635
 *         return lua.luaL_argerror(L, 1, "not a python object")   # never returns!
 *     result = py_object_setindex_with_gil(L, py_obj)
 *     if result < 0:             # <<<<<<<<<<<<<<
 *         return lua.lua_error(L)  # never returns!
 *     return result
 */
  }

  /* "lupa/_lupa.pyx":1637
 *     if result < 0:
 *         return lua.lua_error(L)  # never returns!
 *     return result             # <<<<<<<<<<<<<<
 * 
 * # special methods for Lua wrapped Python objects
 */
  __pyx_r = __pyx_v_result;
  goto __pyx_L0;

  /* "lupa/_lupa.pyx":1630
 *         return -1
 * 
 * cdef int py_object_setindex(lua_State* L) nogil:             # <<<<<<<<<<<<<<
 *     cdef py_object* py_obj = unwrap_lua_object(L, 1) # may not return on error!
 *     if not py_obj:
 */

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

/* "lupa/_lupa.pyx":1652
 * ## # Python helper functions for Lua
 * 
 * cdef inline py_object* unpack_single_python_argument_or_jump(lua_State* L) nogil:             # <<<<<<<<<<<<<<
 *     if lua.lua_gettop(L) > 1:
 *         lua.luaL_argerror(L, 2, "invalid arguments")   # never returns!
 */

static CYTHON_INLINE struct __pyx_t_4lupa_5_lupa_py_object *__pyx_f_4lupa_5_lupa_unpack_single_python_argument_or_jump(lua_State *__pyx_v_L) {
  struct __pyx_t_4lupa_5_lupa_py_object *__pyx_v_py_obj;
  struct __pyx_t_4lupa_5_lupa_py_object *__pyx_r;
  int __pyx_t_1;

  /* "lupa/_lupa.pyx":1653
 * 
 * cdef inline py_object* unpack_single_python_argument_or_jump(lua_State* L) nogil:
 *     if lua.lua_gettop(L) > 1:             # <<<<<<<<<<<<<<
 *         lua.luaL_argerror(L, 2, "invalid arguments")   # never returns!
 *     cdef py_object* py_obj = unwrap_lua_object(L, 1)
 */
  __pyx_t_1 = ((lua_gettop(__pyx_v_L) > 1) != 0);
  if (__pyx_t_1) {

    /* "lupa/_lupa.pyx":1654
 * cdef inline py_object* unpack_single_python_argument_or_jump(lua_State* L) nogil:
 *     if lua.lua_gettop(L) > 1:
 *         lua.luaL_argerror(L, 2, "invalid arguments")   # never returns!             # <<<<<<<<<<<<<<
 *     cdef py_object* py_obj = unwrap_lua_object(L, 1)
 *     if not py_obj:
 */
    (void)(luaL_argerror(__pyx_v_L, 2, ((char *)"invalid arguments")));

    /* "lupa/_lupa.pyx":1653
 * 
 * cdef inline py_object* unpack_single_python_argument_or_jump(lua_State* L) nogil:
 *     if lua.lua_gettop(L) > 1:             # <<<<<<<<<<<<<<
 *         lua.luaL_argerror(L, 2, "invalid arguments")   # never returns!
 *     cdef py_object* py_obj = unwrap_lua_object(L, 1)
 */
  }

  /* "lupa/_lupa.pyx":1655
 *     if lua.lua_gettop(L) > 1:
 *         lua.luaL_argerror(L, 2, "invalid arguments")   # never returns!
 *     cdef py_object* py_obj = unwrap_lua_object(L, 1)             # <<<<<<<<<<<<<<
 *     if not py_obj:
 *         lua.luaL_argerror(L, 1, "not a python object")   # never returns!
 */
  __pyx_v_py_obj = __pyx_f_4lupa_5_lupa_unwrap_lua_object(__pyx_v_L, 1);

  /* "lupa/_lupa.pyx":1656
 *         lua.luaL_argerror(L, 2, "invalid arguments")   # never returns!
 *     cdef py_object* py_obj = unwrap_lua_object(L, 1)
 *     if not py_obj:             # <<<<<<<<<<<<<<
 *         lua.luaL_argerror(L, 1, "not a python object")   # never returns!
 *     return py_obj
 */
  __pyx_t_1 = ((!(__pyx_v_py_obj != 0)) != 0);
  if (__pyx_t_1) {

    /* "lupa/_lupa.pyx":1657
 *     cdef py_object* py_obj = unwrap_lua_object(L, 1)
 *     if not py_obj:
 *         lua.luaL_argerror(L, 1, "not a python object")   # never returns!             # <<<<<<<<<<<<<<
 *     return py_obj
 * 
 */
    (void)(luaL_argerror(__pyx_v_L, 1, ((char *)"not a python object")));

    /* "lupa/_lupa.pyx":1656
 *         lua.luaL_argerror(L, 2, "invalid arguments")   # never returns!
 *     cdef py_object* py_obj = unwrap_lua_object(L, 1)
 *     if not py_obj:             # <<<<<<<<<<<<<<
 *         lua.luaL_argerror(L, 1, "not a python object")   # never returns!
 *     return py_obj
 */
  }

  /* "lupa/_lupa.pyx":1658
 *     if not py_obj:
 *         lua.luaL_argerror(L, 1, "not a python object")   # never returns!
 *     return py_obj             # <<<<<<<<<<<<<<
 * 
 * cdef py_object* unwrap_lua_object(lua_State* L, int n) nogil:
 */
  __pyx_r = __pyx_v_py_obj;
  goto __pyx_L0;

  /* "lupa/_lupa.pyx":1652
 * ## # Python helper functions for Lua
 * 
 * cdef inline py_object* unpack_single_python_argument_or_jump(lua_State* L) nogil:             # <<<<<<<<<<<<<<
 *     if lua.lua_gettop(L) > 1:
 *         lua.luaL_argerror(L, 2, "invalid arguments")   # never returns!
 */

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

/* "lupa/_lupa.pyx":1660
 *     return py_obj
 * 
 * cdef py_object* unwrap_lua_object(lua_State* L, int n) nogil:             # <<<<<<<<<<<<<<
 *     if lua.lua_isuserdata(L, n):
 *         return unpack_userdata(L, n)
 */

static struct __pyx_t_4lupa_5_lupa_py_object *__pyx_f_4lupa_5_lupa_unwrap_lua_object(lua_State *__pyx_v_L, int __pyx_v_n) {
  struct __pyx_t_4lupa_5_lupa_py_object *__pyx_r;
  int __pyx_t_1;

  /* "lupa/_lupa.pyx":1661
 * 
 * cdef py_object* unwrap_lua_object(lua_State* L, int n) nogil:
 *     if lua.lua_isuserdata(L, n):             # <<<<<<<<<<<<<<
 *         return unpack_userdata(L, n)
 *     else:
 */
  __pyx_t_1 = (lua_isuserdata(__pyx_v_L, __pyx_v_n) != 0);
  if (__pyx_t_1) {

    /* "lupa/_lupa.pyx":1662
 * cdef py_object* unwrap_lua_object(lua_State* L, int n) nogil:
 *     if lua.lua_isuserdata(L, n):
 *         return unpack_userdata(L, n)             # <<<<<<<<<<<<<<
 *     else:
 *         return unpack_wrapped_pyfunction(L, n)
 */
    __pyx_r = __pyx_f_4lupa_5_lupa_unpack_userdata(__pyx_v_L, __pyx_v_n);
    goto __pyx_L0;

    /* "lupa/_lupa.pyx":1661
 * 
 * cdef py_object* unwrap_lua_object(lua_State* L, int n) nogil:
 *     if lua.lua_isuserdata(L, n):             # <<<<<<<<<<<<<<
 *         return unpack_userdata(L, n)
 *     else:
 */
  }

  /* "lupa/_lupa.pyx":1664
 *         return unpack_userdata(L, n)
 *     else:
 *         return unpack_wrapped_pyfunction(L, n)             # <<<<<<<<<<<<<<
 * 
 * cdef int py_wrap_object_protocol_with_gil(lua_State* L, py_object* py_obj, int type_flags) with gil:
 */
  /*else*/ {
    __pyx_r = __pyx_f_4lupa_5_lupa_unpack_wrapped_pyfunction(__pyx_v_L, __pyx_v_n);
    goto __pyx_L0;
  }

  /* "lupa/_lupa.pyx":1660
 *     return py_obj
 * 
 * cdef py_object* unwrap_lua_object(lua_State* L, int n) nogil:             # <<<<<<<<<<<<<<
 *     if lua.lua_isuserdata(L, n):
 *         return unpack_userdata(L, n)
 */

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

/* "lupa/_lupa.pyx":1666
 *         return unpack_wrapped_pyfunction(L, n)
 * 
 * cdef int py_wrap_object_protocol_with_gil(lua_State* L, py_object* py_obj, int type_flags) with gil:             # <<<<<<<<<<<<<<
 *     cdef LuaRuntime runtime
 *     try:
 */

static int __pyx_f_4lupa_5_lupa_py_wrap_object_protocol_with_gil(lua_State *__pyx_v_L, struct __pyx_t_4lupa_5_lupa_py_object *__pyx_v_py_obj, int __pyx_v_type_flags) {
  struct __pyx_obj_4lupa_5_lupa_LuaRuntime *__pyx_v_runtime = 0;
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  #ifdef WITH_THREAD
  PyGILState_STATE __pyx_gilstate_save = __Pyx_PyGILState_Ensure();
  #endif
  __Pyx_RefNannySetupContext("py_wrap_object_protocol_with_gil", 0);

  /* "lupa/_lupa.pyx":1668
 * cdef int py_wrap_object_protocol_with_gil(lua_State* L, py_object* py_obj, int type_flags) with gil:
 *     cdef LuaRuntime runtime
 *     try:             # <<<<<<<<<<<<<<
 *         runtime = <LuaRuntime?>py_obj.runtime
 *         return py_to_lua_custom(runtime, L, <object>py_obj.obj, type_flags)
 */
  {
    (void)__pyx_t_1; (void)__pyx_t_2; (void)__pyx_t_3; /* mark used */
    /*try:*/ {

      /* "lupa/_lupa.pyx":1669
 *     cdef LuaRuntime runtime
 *     try:
 *         runtime = <LuaRuntime?>py_obj.runtime             # <<<<<<<<<<<<<<
 *         return py_to_lua_custom(runtime, L, <object>py_obj.obj, type_flags)
 *     except:
 */
      __pyx_t_4 = ((PyObject *)__pyx_v_py_obj->runtime);
      __Pyx_INCREF(__pyx_t_4);
      __pyx_v_runtime = ((struct __pyx_obj_4lupa_5_lupa_LuaRuntime *)__pyx_t_4);
      __pyx_t_4 = 0;

      /* "lupa/_lupa.pyx":1670
 *     try:
 *         runtime = <LuaRuntime?>py_obj.runtime
 *         return py_to_lua_custom(runtime, L, <object>py_obj.obj, type_flags)             # <<<<<<<<<<<<<<
 *     except:
 *         try: runtime.store_raised_exception(L, b'error during type adaptation')
 */
      __pyx_t_4 = ((PyObject *)__pyx_v_py_obj->obj);
      __Pyx_INCREF(__pyx_t_4);
      __pyx_r = __pyx_f_4lupa_5_lupa_py_to_lua_custom(__pyx_v_runtime, __pyx_v_L, __pyx_t_4, __pyx_v_type_flags);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      goto __pyx_L7_try_return;

      /* "lupa/_lupa.pyx":1668
 * cdef int py_wrap_object_protocol_with_gil(lua_State* L, py_object* py_obj, int type_flags) with gil:
 *     cdef LuaRuntime runtime
 *     try:             # <<<<<<<<<<<<<<
 *         runtime = <LuaRuntime?>py_obj.runtime
 *         return py_to_lua_custom(runtime, L, <object>py_obj.obj, type_flags)
 */
    }
    __pyx_L7_try_return:;
    goto __pyx_L0;
  }

  /* "lupa/_lupa.pyx":1666
 *         return unpack_wrapped_pyfunction(L, n)
 * 
 * cdef int py_wrap_object_protocol_with_gil(lua_State* L, py_object* py_obj, int type_flags) with gil:             # <<<<<<<<<<<<<<
 *     cdef LuaRuntime runtime
 *     try:
 */

  /* function exit code */
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_runtime);
  __Pyx_RefNannyFinishContext();
  #ifdef WITH_THREAD
  __Pyx_PyGILState_Release(__pyx_gilstate_save);
  #endif
  return __pyx_r;
}

/* "lupa/_lupa.pyx":1675
 *         finally: return -1
 * 
 * cdef int py_wrap_object_protocol(lua_State* L, int type_flags) nogil:             # <<<<<<<<<<<<<<
 *     cdef py_object* py_obj = unpack_single_python_argument_or_jump(L) # never returns on error!
 *     result = py_wrap_object_protocol_with_gil(L, py_obj, type_flags)
 */

static int __pyx_f_4lupa_5_lupa_py_wrap_object_protocol(lua_State *__pyx_v_L, int __pyx_v_type_flags) {
  struct __pyx_t_4lupa_5_lupa_py_object *__pyx_v_py_obj;
  int __pyx_v_result;
  int __pyx_r;
  int __pyx_t_1;

  /* "lupa/_lupa.pyx":1676
 * 
 * cdef int py_wrap_object_protocol(lua_State* L, int type_flags) nogil:
 *     cdef py_object* py_obj = unpack_single_python_argument_or_jump(L) # never returns on error!             # <<<<<<<<<<<<<<
 *     result = py_wrap_object_protocol_with_gil(L, py_obj, type_flags)
 *     if result < 0:
 */
  __pyx_v_py_obj = __pyx_f_4lupa_5_lupa_unpack_single_python_argument_or_jump(__pyx_v_L);

  /* "lupa/_lupa.pyx":1677
 * cdef int py_wrap_object_protocol(lua_State* L, int type_flags) nogil:
 *     cdef py_object* py_obj = unpack_single_python_argument_or_jump(L) # never returns on error!
 *     result = py_wrap_object_protocol_with_gil(L, py_obj, type_flags)             # <<<<<<<<<<<<<<
 *     if result < 0:
 *         return lua.lua_error(L)  # never returns!
 */
  __pyx_v_result = __pyx_f_4lupa_5_lupa_py_wrap_object_protocol_with_gil(__pyx_v_L, __pyx_v_py_obj, __pyx_v_type_flags);

  /* "lupa/_lupa.pyx":1678
 *     cdef py_object* py_obj = unpack_single_python_argument_or_jump(L) # never returns on error!
 *     result = py_wrap_object_protocol_with_gil(L, py_obj, type_flags)
 *     if result < 0:             # <<<<<<<<<<<<<<
 *         return lua.lua_error(L)  # never returns!
 *     return result
 */
  __pyx_t_1 = ((__pyx_v_result < 0) != 0);
  if (__pyx_t_1) {

    /* "lupa/_lupa.pyx":1679
 *     result = py_wrap_object_protocol_with_gil(L, py_obj, type_flags)
 *     if result < 0:
 *         return lua.lua_error(L)  # never returns!             # <<<<<<<<<<<<<<
 *     return result
 * 
 */
    __pyx_r = lua_error(__pyx_v_L);
    goto __pyx_L0;

    /* "lupa/_lupa.pyx":1678
 *     cdef py_object* py_obj = unpack_single_python_argument_or_jump(L) # never returns on error!
 *     result = py_wrap_object_protocol_with_gil(L, py_obj, type_flags)
 *     if result < 0:             # <<<<<<<<<<<<<<
 *         return lua.lua_error(L)  # never returns!
 *     return result
 */
  }

  /* "lupa/_lupa.pyx":1680
 *     if result < 0:
 *         return lua.lua_error(L)  # never returns!
 *     return result             # <<<<<<<<<<<<<<
 * 
 * cdef int py_as_attrgetter(lua_State* L) nogil:
 */
  __pyx_r = __pyx_v_result;
  goto __pyx_L0;

  /* "lupa/_lupa.pyx":1675
 *         finally: return -1
 * 
 * cdef int py_wrap_object_protocol(lua_State* L, int type_flags) nogil:             # <<<<<<<<<<<<<<
 *     cdef py_object* py_obj = unpack_single_python_argument_or_jump(L) # never returns on error!
 *     result = py_wrap_object_protocol_with_gil(L, py_obj, type_flags)
 */

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

/* "lupa/_lupa.pyx":1682
 *     return result
 * 
 * cdef int py_as_attrgetter(lua_State* L) nogil:             # <<<<<<<<<<<<<<
 *     return py_wrap_object_protocol(L, 0)
 * 
 */

static int __pyx_f_4lupa_5_lupa_py_as_attrgetter(lua_State *__pyx_v_L) {
  int __pyx_r;

  /* "lupa/_lupa.pyx":1683
 * 
 * cdef int py_as_attrgetter(lua_State* L) nogil:
 *     return py_wrap_object_protocol(L, 0)             # <<<<<<<<<<<<<<
 * 
 * cdef int py_as_itemgetter(lua_State* L) nogil:
 */
  __pyx_r = __pyx_f_4lupa_5_lupa_py_wrap_object_protocol(__pyx_v_L, 0);
  goto __pyx_L0;

  /* "lupa/_lupa.pyx":1682
 *     return result
 * 
 * cdef int py_as_attrgetter(lua_State* L) nogil:             # <<<<<<<<<<<<<<
 *     return py_wrap_object_protocol(L, 0)
 * 
 */

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

/* "lupa/_lupa.pyx":1685
 *     return py_wrap_object_protocol(L, 0)
 * 
 * cdef int py_as_itemgetter(lua_State* L) nogil:             # <<<<<<<<<<<<<<
 *     return py_wrap_object_protocol(L, OBJ_AS_INDEX)
 * 
 */

static int __pyx_f_4lupa_5_lupa_py_as_itemgetter(lua_State *__pyx_v_L) {
  int __pyx_r;

  /* "lupa/_lupa.pyx":1686
 * 
 * cdef int py_as_itemgetter(lua_State* L) nogil:
 *     return py_wrap_object_protocol(L, OBJ_AS_INDEX)             # <<<<<<<<<<<<<<
 * 
 * cdef int py_as_function(lua_State* L) nogil:
 */
  __pyx_r = __pyx_f_4lupa_5_lupa_py_wrap_object_protocol(__pyx_v_L, __pyx_e_4lupa_5_lupa_OBJ_AS_INDEX);
  goto __pyx_L0;

  /* "lupa/_lupa.pyx":1685
 *     return py_wrap_object_protocol(L, 0)
 * 
 * cdef int py_as_itemgetter(lua_State* L) nogil:             # <<<<<<<<<<<<<<
 *     return py_wrap_object_protocol(L, OBJ_AS_INDEX)
 * 
 */

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

/* "lupa/_lupa.pyx":1688
 *     return py_wrap_object_protocol(L, OBJ_AS_INDEX)
 * 
 * cdef int py_as_function(lua_State* L) nogil:             # <<<<<<<<<<<<<<
 *     cdef py_object* py_obj = unpack_single_python_argument_or_jump(L) # never returns on error!
 *     lua.lua_pushcclosure(L, <lua.lua_CFunction>py_asfunc_call, 1)
 */

static int __pyx_f_4lupa_5_lupa_py_as_function(lua_State *__pyx_v_L) {
  CYTHON_UNUSED struct __pyx_t_4lupa_5_lupa_py_object *__pyx_v_py_obj;
  int __pyx_r;

  /* "lupa/_lupa.pyx":1689
 * 
 * cdef int py_as_function(lua_State* L) nogil:
 *     cdef py_object* py_obj = unpack_single_python_argument_or_jump(L) # never returns on error!             # <<<<<<<<<<<<<<
 *     lua.lua_pushcclosure(L, <lua.lua_CFunction>py_asfunc_call, 1)
 *     return 1
 */
  __pyx_v_py_obj = __pyx_f_4lupa_5_lupa_unpack_single_python_argument_or_jump(__pyx_v_L);

  /* "lupa/_lupa.pyx":1690
 * cdef int py_as_function(lua_State* L) nogil:
 *     cdef py_object* py_obj = unpack_single_python_argument_or_jump(L) # never returns on error!
 *     lua.lua_pushcclosure(L, <lua.lua_CFunction>py_asfunc_call, 1)             # <<<<<<<<<<<<<<
 *     return 1
 * 
 */
  lua_pushcclosure(__pyx_v_L, ((lua_CFunction)__pyx_f_4lupa_5_lupa_py_asfunc_call), 1);

  /* "lupa/_lupa.pyx":1691
 *     cdef py_object* py_obj = unpack_single_python_argument_or_jump(L) # never returns on error!
 *     lua.lua_pushcclosure(L, <lua.lua_CFunction>py_asfunc_call, 1)
 *     return 1             # <<<<<<<<<<<<<<
 * 
 * # iteration support for Python objects in Lua
 */
  __pyx_r = 1;
  goto __pyx_L0;

  /* "lupa/_lupa.pyx":1688
 *     return py_wrap_object_protocol(L, OBJ_AS_INDEX)
 * 
 * cdef int py_as_function(lua_State* L) nogil:             # <<<<<<<<<<<<<<
 *     cdef py_object* py_obj = unpack_single_python_argument_or_jump(L) # never returns on error!
 *     lua.lua_pushcclosure(L, <lua.lua_CFunction>py_asfunc_call, 1)
 */

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

/* "lupa/_lupa.pyx":1695
 * # iteration support for Python objects in Lua
 * 
 * cdef int py_iter(lua_State* L) nogil:             # <<<<<<<<<<<<<<
 *     cdef py_object* py_obj = unpack_single_python_argument_or_jump(L) # never returns on error!
 *     result = py_iter_with_gil(L, py_obj, 0)
 */

static int __pyx_f_4lupa_5_lupa_py_iter(lua_State *__pyx_v_L) {
  struct __pyx_t_4lupa_5_lupa_py_object *__pyx_v_py_obj;
  int __pyx_v_result;
  int __pyx_r;
  int __pyx_t_1;

  /* "lupa/_lupa.pyx":1696
 * 
 * cdef int py_iter(lua_State* L) nogil:
 *     cdef py_object* py_obj = unpack_single_python_argument_or_jump(L) # never returns on error!             # <<<<<<<<<<<<<<
 *     result = py_iter_with_gil(L, py_obj, 0)
 *     if result < 0:
 */
  __pyx_v_py_obj = __pyx_f_4lupa_5_lupa_unpack_single_python_argument_or_jump(__pyx_v_L);

  /* "lupa/_lupa.pyx":1697
 * cdef int py_iter(lua_State* L) nogil:
 *     cdef py_object* py_obj = unpack_single_python_argument_or_jump(L) # never returns on error!
 *     result = py_iter_with_gil(L, py_obj, 0)             # <<<<<<<<<<<<<<
 *     if result < 0:
 *         return lua.lua_error(L)  # never returns!
 */
  __pyx_v_result = __pyx_f_4lupa_5_lupa_py_iter_with_gil(__pyx_v_L, __pyx_v_py_obj, 0);

  /* "lupa/_lupa.pyx":1698
 *     cdef py_object* py_obj = unpack_single_python_argument_or_jump(L) # never returns on error!
 *     result = py_iter_with_gil(L, py_obj, 0)
 *     if result < 0:             # <<<<<<<<<<<<<<
 *         return lua.lua_error(L)  # never returns!
 *     return result
 */
  __pyx_t_1 = ((__pyx_v_result < 0) != 0);
  if (__pyx_t_1) {

    /* "lupa/_lupa.pyx":1699
 *     result = py_iter_with_gil(L, py_obj, 0)
 *     if result < 0:
 *         return lua.lua_error(L)  # never returns!             # <<<<<<<<<<<<<<
 *     return result
 * 
 */
    __pyx_r = lua_error(__pyx_v_L);
    goto __pyx_L0;

    /* "lupa/_lupa.pyx":1698
 *     cdef py_object* py_obj = unpack_single_python_argument_or_jump(L) # never returns on error!
 *     result = py_iter_with_gil(L, py_obj, 0)
 *     if result < 0:             # <<<<<<<<<<<<<<
 *         return lua.lua_error(L)  # never returns!
 *     return result
 */
  }

  /* "lupa/_lupa.pyx":1700
 *     if result < 0:
 *         return lua.lua_error(L)  # never returns!
 *     return result             # <<<<<<<<<<<<<<
 * 
 * cdef int py_iterex(lua_State* L) nogil:
 */
  __pyx_r = __pyx_v_result;
  goto __pyx_L0;

  /* "lupa/_lupa.pyx":1695
 * # iteration support for Python objects in Lua
 * 
 * cdef int py_iter(lua_State* L) nogil:             # <<<<<<<<<<<<<<
 *     cdef py_object* py_obj = unpack_single_python_argument_or_jump(L) # never returns on error!
 *     result = py_iter_with_gil(L, py_obj, 0)
 */

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

/* "lupa/_lupa.pyx":1702
 *     return result
 * 
 * cdef int py_iterex(lua_State* L) nogil:             # <<<<<<<<<<<<<<
 *     cdef py_object* py_obj = unpack_single_python_argument_or_jump(L) # never returns on error!
 *     result = py_iter_with_gil(L, py_obj, OBJ_UNPACK_TUPLE)
 */

static int __pyx_f_4lupa_5_lupa_py_iterex(lua_State *__pyx_v_L) {
  struct __pyx_t_4lupa_5_lupa_py_object *__pyx_v_py_obj;
  int __pyx_v_result;
  int __pyx_r;
  int __pyx_t_1;

  /* "lupa/_lupa.pyx":1703
 * 
 * cdef int py_iterex(lua_State* L) nogil:
 *     cdef py_object* py_obj = unpack_single_python_argument_or_jump(L) # never returns on error!             # <<<<<<<<<<<<<<
 *     result = py_iter_with_gil(L, py_obj, OBJ_UNPACK_TUPLE)
 *     if result < 0:
 */
  __pyx_v_py_obj = __pyx_f_4lupa_5_lupa_unpack_single_python_argument_or_jump(__pyx_v_L);

  /* "lupa/_lupa.pyx":1704
 * cdef int py_iterex(lua_State* L) nogil:
 *     cdef py_object* py_obj = unpack_single_python_argument_or_jump(L) # never returns on error!
 *     result = py_iter_with_gil(L, py_obj, OBJ_UNPACK_TUPLE)             # <<<<<<<<<<<<<<
 *     if result < 0:
 *         return lua.lua_error(L)  # never returns!
 */
  __pyx_v_result = __pyx_f_4lupa_5_lupa_py_iter_with_gil(__pyx_v_L, __pyx_v_py_obj, __pyx_e_4lupa_5_lupa_OBJ_UNPACK_TUPLE);

  /* "lupa/_lupa.pyx":1705
 *     cdef py_object* py_obj = unpack_single_python_argument_or_jump(L) # never returns on error!
 *     result = py_iter_with_gil(L, py_obj, OBJ_UNPACK_TUPLE)
 *     if result < 0:             # <<<<<<<<<<<<<<
 *         return lua.lua_error(L)  # never returns!
 *     return result
 */
  __pyx_t_1 = ((__pyx_v_result < 0) != 0);
  if (__pyx_t_1) {

    /* "lupa/_lupa.pyx":1706
 *     result = py_iter_with_gil(L, py_obj, OBJ_UNPACK_TUPLE)
 *     if result < 0:
 *         return lua.lua_error(L)  # never returns!             # <<<<<<<<<<<<<<
 *     return result
 * 
 */
    __pyx_r = lua_error(__pyx_v_L);
    goto __pyx_L0;

    /* "lupa/_lupa.pyx":1705
 *     cdef py_object* py_obj = unpack_single_python_argument_or_jump(L) # never returns on error!
 *     result = py_iter_with_gil(L, py_obj, OBJ_UNPACK_TUPLE)
 *     if result < 0:             # <<<<<<<<<<<<<<
 *         return lua.lua_error(L)  # never returns!
 *     return result
 */
  }

  /* "lupa/_lupa.pyx":1707
 *     if result < 0:
 *         return lua.lua_error(L)  # never returns!
 *     return result             # <<<<<<<<<<<<<<
 * 
 * cdef int py_enumerate(lua_State* L) nogil:
 */
  __pyx_r = __pyx_v_result;
  goto __pyx_L0;

  /* "lupa/_lupa.pyx":1702
 *     return result
 * 
 * cdef int py_iterex(lua_State* L) nogil:             # <<<<<<<<<<<<<<
 *     cdef py_object* py_obj = unpack_single_python_argument_or_jump(L) # never returns on error!
 *     result = py_iter_with_gil(L, py_obj, OBJ_UNPACK_TUPLE)
 */

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

/* "lupa/_lupa.pyx":1709
 *     return result
 * 
 * cdef int py_enumerate(lua_State* L) nogil:             # <<<<<<<<<<<<<<
 *     if lua.lua_gettop(L) > 2:
 *         lua.luaL_argerror(L, 3, "invalid arguments")   # never returns!
 */

static int __pyx_f_4lupa_5_lupa_py_enumerate(lua_State *__pyx_v_L) {
  struct __pyx_t_4lupa_5_lupa_py_object *__pyx_v_py_obj;
  double __pyx_v_start;
  int __pyx_v_result;
  int __pyx_r;
  int __pyx_t_1;
  double __pyx_t_2;

  /* "lupa/_lupa.pyx":1710
 * 
 * cdef int py_enumerate(lua_State* L) nogil:
 *     if lua.lua_gettop(L) > 2:             # <<<<<<<<<<<<<<
 *         lua.luaL_argerror(L, 3, "invalid arguments")   # never returns!
 *     cdef py_object* py_obj = unwrap_lua_object(L, 1)
 */
  __pyx_t_1 = ((lua_gettop(__pyx_v_L) > 2) != 0);
  if (__pyx_t_1) {

    /* "lupa/_lupa.pyx":1711
 * cdef int py_enumerate(lua_State* L) nogil:
 *     if lua.lua_gettop(L) > 2:
 *         lua.luaL_argerror(L, 3, "invalid arguments")   # never returns!             # <<<<<<<<<<<<<<
 *     cdef py_object* py_obj = unwrap_lua_object(L, 1)
 *     if not py_obj:
 */
    (void)(luaL_argerror(__pyx_v_L, 3, ((char *)"invalid arguments")));

    /* "lupa/_lupa.pyx":1710
 * 
 * cdef int py_enumerate(lua_State* L) nogil:
 *     if lua.lua_gettop(L) > 2:             # <<<<<<<<<<<<<<
 *         lua.luaL_argerror(L, 3, "invalid arguments")   # never returns!
 *     cdef py_object* py_obj = unwrap_lua_object(L, 1)
 */
  }

  /* "lupa/_lupa.pyx":1712
 *     if lua.lua_gettop(L) > 2:
 *         lua.luaL_argerror(L, 3, "invalid arguments")   # never returns!
 *     cdef py_object* py_obj = unwrap_lua_object(L, 1)             # <<<<<<<<<<<<<<
 *     if not py_obj:
 *         lua.luaL_argerror(L, 1, "not a python object")   # never returns!
 */
  __pyx_v_py_obj = __pyx_f_4lupa_5_lupa_unwrap_lua_object(__pyx_v_L, 1);

  /* "lupa/_lupa.pyx":1713
 *         lua.luaL_argerror(L, 3, "invalid arguments")   # never returns!
 *     cdef py_object* py_obj = unwrap_lua_object(L, 1)
 *     if not py_obj:             # <<<<<<<<<<<<<<
 *         lua.luaL_argerror(L, 1, "not a python object")   # never returns!
 *     cdef double start = lua.lua_tonumber(L, -1) if lua.lua_gettop(L) == 2 else 0.0
 */
  __pyx_t_1 = ((!(__pyx_v_py_obj != 0)) != 0);
  if (__pyx_t_1) {

    /* "lupa/_lupa.pyx":1714
 *     cdef py_object* py_obj = unwrap_lua_object(L, 1)
 *     if not py_obj:
 *         lua.luaL_argerror(L, 1, "not a python object")   # never returns!             # <<<<<<<<<<<<<<
 *     cdef double start = lua.lua_tonumber(L, -1) if lua.lua_gettop(L) == 2 else 0.0
 *     result = py_enumerate_with_gil(L, py_obj, start)
 */
    (void)(luaL_argerror(__pyx_v_L, 1, ((char *)"not a python object")));

    /* "lupa/_lupa.pyx":1713
 *         lua.luaL_argerror(L, 3, "invalid arguments")   # never returns!
 *     cdef py_object* py_obj = unwrap_lua_object(L, 1)
 *     if not py_obj:             # <<<<<<<<<<<<<<
 *         lua.luaL_argerror(L, 1, "not a python object")   # never returns!
 *     cdef double start = lua.lua_tonumber(L, -1) if lua.lua_gettop(L) == 2 else 0.0
 */
  }

  /* "lupa/_lupa.pyx":1715
 *     if not py_obj:
 *         lua.luaL_argerror(L, 1, "not a python object")   # never returns!
 *     cdef double start = lua.lua_tonumber(L, -1) if lua.lua_gettop(L) == 2 else 0.0             # <<<<<<<<<<<<<<
 *     result = py_enumerate_with_gil(L, py_obj, start)
 *     if result < 0:
 */
  if (((lua_gettop(__pyx_v_L) == 2) != 0)) {
    __pyx_t_2 = lua_tonumber(__pyx_v_L, -1);
  } else {
    __pyx_t_2 = 0.0;
  }
  __pyx_v_start = __pyx_t_2;

  /* "lupa/_lupa.pyx":1716
 *         lua.luaL_argerror(L, 1, "not a python object")   # never returns!
 *     cdef double start = lua.lua_tonumber(L, -1) if lua.lua_gettop(L) == 2 else 0.0
 *     result = py_enumerate_with_gil(L, py_obj, start)             # <<<<<<<<<<<<<<
 *     if result < 0:
 *         return lua.lua_error(L)  # never returns!
 */
  __pyx_v_result = __pyx_f_4lupa_5_lupa_py_enumerate_with_gil(__pyx_v_L, __pyx_v_py_obj, __pyx_v_start);

  /* "lupa/_lupa.pyx":1717
 *     cdef double start = lua.lua_tonumber(L, -1) if lua.lua_gettop(L) == 2 else 0.0
 *     result = py_enumerate_with_gil(L, py_obj, start)
 *     if result < 0:             # <<<<<<<<<<<<<<
 *         return lua.lua_error(L)  # never returns!
 *     return result
 */
  __pyx_t_1 = ((__pyx_v_result < 0) != 0);
  if (__pyx_t_1) {

    /* "lupa/_lupa.pyx":1718
 *     result = py_enumerate_with_gil(L, py_obj, start)
 *     if result < 0:
 *         return lua.lua_error(L)  # never returns!             # <<<<<<<<<<<<<<
 *     return result
 * 
 */
    __pyx_r = lua_error(__pyx_v_L);
    goto __pyx_L0;

    /* "lupa/_lupa.pyx":1717
 *     cdef double start = lua.lua_tonumber(L, -1) if lua.lua_gettop(L) == 2 else 0.0
 *     result = py_enumerate_with_gil(L, py_obj, start)
 *     if result < 0:             # <<<<<<<<<<<<<<
 *         return lua.lua_error(L)  # never returns!
 *     return result
 */
  }

  /* "lupa/_lupa.pyx":1719
 *     if result < 0:
 *         return lua.lua_error(L)  # never returns!
 *     return result             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_r = __pyx_v_result;
  goto __pyx_L0;

  /* "lupa/_lupa.pyx":1709
 *     return result
 * 
 * cdef int py_enumerate(lua_State* L) nogil:             # <<<<<<<<<<<<<<
 *     if lua.lua_gettop(L) > 2:
 *         lua.luaL_argerror(L, 3, "invalid arguments")   # never returns!
 */

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

/* "lupa/_lupa.pyx":1722
 * 
 * 
 * cdef int py_enumerate_with_gil(lua_State* L, py_object* py_obj, double start) with gil:             # <<<<<<<<<<<<<<
 *     cdef LuaRuntime runtime
 *     try:
 */

static int __pyx_f_4lupa_5_lupa_py_enumerate_with_gil(lua_State *__pyx_v_L, struct __pyx_t_4lupa_5_lupa_py_object *__pyx_v_py_obj, double __pyx_v_start) {
  struct __pyx_obj_4lupa_5_lupa_LuaRuntime *__pyx_v_runtime = 0;
  PyObject *__pyx_v_obj = NULL;
  int __pyx_r;
  __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;
  PyObject *__pyx_t_6 = NULL;
  int __pyx_t_7;
  PyObject *__pyx_t_8 = NULL;
  PyObject *__pyx_t_9 = NULL;
  PyObject *__pyx_t_10 = NULL;
  PyObject *__pyx_t_11 = NULL;
  PyObject *__pyx_t_12 = NULL;
  PyObject *__pyx_t_13 = 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("py_enumerate_with_gil", 0);

  /* "lupa/_lupa.pyx":1724
 * cdef int py_enumerate_with_gil(lua_State* L, py_object* py_obj, double start) with gil:
 *     cdef LuaRuntime runtime
 *     try:             # <<<<<<<<<<<<<<
 *         runtime = <LuaRuntime?>py_obj.runtime
 *         obj = iter(<object>py_obj.obj)
 */
  {
    __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:*/ {

      /* "lupa/_lupa.pyx":1725
 *     cdef LuaRuntime runtime
 *     try:
 *         runtime = <LuaRuntime?>py_obj.runtime             # <<<<<<<<<<<<<<
 *         obj = iter(<object>py_obj.obj)
 *         return py_push_iterator(runtime, L, obj, OBJ_ENUMERATOR, start - 1.0)
 */
      __pyx_t_4 = ((PyObject *)__pyx_v_py_obj->runtime);
      __Pyx_INCREF(__pyx_t_4);
      __pyx_v_runtime = ((struct __pyx_obj_4lupa_5_lupa_LuaRuntime *)__pyx_t_4);
      __pyx_t_4 = 0;

      /* "lupa/_lupa.pyx":1726
 *     try:
 *         runtime = <LuaRuntime?>py_obj.runtime
 *         obj = iter(<object>py_obj.obj)             # <<<<<<<<<<<<<<
 *         return py_push_iterator(runtime, L, obj, OBJ_ENUMERATOR, start - 1.0)
 *     except:
 */
      __pyx_t_4 = ((PyObject *)__pyx_v_py_obj->obj);
      __Pyx_INCREF(__pyx_t_4);
      __pyx_t_5 = PyObject_GetIter(__pyx_t_4); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1726, __pyx_L3_error)
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __pyx_v_obj = __pyx_t_5;
      __pyx_t_5 = 0;

      /* "lupa/_lupa.pyx":1727
 *         runtime = <LuaRuntime?>py_obj.runtime
 *         obj = iter(<object>py_obj.obj)
 *         return py_push_iterator(runtime, L, obj, OBJ_ENUMERATOR, start - 1.0)             # <<<<<<<<<<<<<<
 *     except:
 *         try: runtime.store_raised_exception(L, b'error creating an iterator with enumerate()')
 */
      __pyx_r = __pyx_f_4lupa_5_lupa_py_push_iterator(__pyx_v_runtime, __pyx_v_L, __pyx_v_obj, __pyx_e_4lupa_5_lupa_OBJ_ENUMERATOR, (__pyx_v_start - 1.0));
      goto __pyx_L7_try_return;

      /* "lupa/_lupa.pyx":1724
 * cdef int py_enumerate_with_gil(lua_State* L, py_object* py_obj, double start) with gil:
 *     cdef LuaRuntime runtime
 *     try:             # <<<<<<<<<<<<<<
 *         runtime = <LuaRuntime?>py_obj.runtime
 *         obj = iter(<object>py_obj.obj)
 */
    }
    __pyx_L3_error:;
    __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;

    /* "lupa/_lupa.pyx":1728
 *         obj = iter(<object>py_obj.obj)
 *         return py_push_iterator(runtime, L, obj, OBJ_ENUMERATOR, start - 1.0)
 *     except:             # <<<<<<<<<<<<<<
 *         try: runtime.store_raised_exception(L, b'error creating an iterator with enumerate()')
 *         finally: return -1
 */
    /*except:*/ {
      __Pyx_AddTraceback("lupa._lupa.py_enumerate_with_gil", __pyx_clineno, __pyx_lineno, __pyx_filename);
      if (__Pyx_GetException(&__pyx_t_5, &__pyx_t_4, &__pyx_t_6) < 0) __PYX_ERR(0, 1728, __pyx_L5_except_error)
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_GOTREF(__pyx_t_6);

      /* "lupa/_lupa.pyx":1729
 *         return py_push_iterator(runtime, L, obj, OBJ_ENUMERATOR, start - 1.0)
 *     except:
 *         try: runtime.store_raised_exception(L, b'error creating an iterator with enumerate()')             # <<<<<<<<<<<<<<
 *         finally: return -1
 * 
 */
      /*try:*/ {
        if (unlikely(!__pyx_v_runtime)) { __Pyx_RaiseUnboundLocalError("runtime"); __PYX_ERR(0, 1729, __pyx_L14_error) }
        __pyx_t_7 = __pyx_f_4lupa_5_lupa_10LuaRuntime_store_raised_exception(__pyx_v_runtime, __pyx_v_L, __pyx_kp_b_error_creating_an_iterator_with); if (unlikely(__pyx_t_7 == ((int)-1))) __PYX_ERR(0, 1729, __pyx_L14_error)
      }

      /* "lupa/_lupa.pyx":1730
 *     except:
 *         try: runtime.store_raised_exception(L, b'error creating an iterator with enumerate()')
 *         finally: return -1             # <<<<<<<<<<<<<<
 * 
 * cdef int py_iter_with_gil(lua_State* L, py_object* py_obj, int type_flags) with gil:
 */
      /*finally:*/ {
        /*normal exit:*/{
          __pyx_r = -1;
          __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
          __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
          __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
          goto __pyx_L6_except_return;
        }
        __pyx_L14_error:;
        /*exception exit:*/{
          __Pyx_PyThreadState_declare
          __Pyx_PyThreadState_assign
          __pyx_t_8 = 0; __pyx_t_9 = 0; __pyx_t_10 = 0; __pyx_t_11 = 0; __pyx_t_12 = 0; __pyx_t_13 = 0;
          if (PY_MAJOR_VERSION >= 3) __Pyx_ExceptionSwap(&__pyx_t_11, &__pyx_t_12, &__pyx_t_13);
          if ((PY_MAJOR_VERSION < 3) || unlikely(__Pyx_GetException(&__pyx_t_8, &__pyx_t_9, &__pyx_t_10) < 0)) __Pyx_ErrFetch(&__pyx_t_8, &__pyx_t_9, &__pyx_t_10);
          __Pyx_XGOTREF(__pyx_t_8);
          __Pyx_XGOTREF(__pyx_t_9);
          __Pyx_XGOTREF(__pyx_t_10);
          __Pyx_XGOTREF(__pyx_t_11);
          __Pyx_XGOTREF(__pyx_t_12);
          __Pyx_XGOTREF(__pyx_t_13);
          {
            __pyx_r = -1;
            __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
            __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
            __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
            goto __pyx_L18_return;
          }
          __pyx_L18_return:;
          if (PY_MAJOR_VERSION >= 3) {
            __Pyx_XGIVEREF(__pyx_t_11);
            __Pyx_XGIVEREF(__pyx_t_12);
            __Pyx_XGIVEREF(__pyx_t_13);
            __Pyx_ExceptionReset(__pyx_t_11, __pyx_t_12, __pyx_t_13);
          }
          __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
          __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
          __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
          __pyx_t_11 = 0; __pyx_t_12 = 0; __pyx_t_13 = 0;
          goto __pyx_L6_except_return;
        }
      }
    }
    __pyx_L5_except_error:;

    /* "lupa/_lupa.pyx":1724
 * cdef int py_enumerate_with_gil(lua_State* L, py_object* py_obj, double start) with gil:
 *     cdef LuaRuntime runtime
 *     try:             # <<<<<<<<<<<<<<
 *         runtime = <LuaRuntime?>py_obj.runtime
 *         obj = iter(<object>py_obj.obj)
 */
    __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;
  }

  /* "lupa/_lupa.pyx":1722
 * 
 * 
 * cdef int py_enumerate_with_gil(lua_State* L, py_object* py_obj, double start) with gil:             # <<<<<<<<<<<<<<
 *     cdef LuaRuntime runtime
 *     try:
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_WriteUnraisable("lupa._lupa.py_enumerate_with_gil", __pyx_clineno, __pyx_lineno, __pyx_filename, 1, 0);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_runtime);
  __Pyx_XDECREF(__pyx_v_obj);
  __Pyx_RefNannyFinishContext();
  #ifdef WITH_THREAD
  __Pyx_PyGILState_Release(__pyx_gilstate_save);
  #endif
  return __pyx_r;
}

/* "lupa/_lupa.pyx":1732
 *         finally: return -1
 * 
 * cdef int py_iter_with_gil(lua_State* L, py_object* py_obj, int type_flags) with gil:             # <<<<<<<<<<<<<<
 *     cdef LuaRuntime runtime
 *     try:
 */

static int __pyx_f_4lupa_5_lupa_py_iter_with_gil(lua_State *__pyx_v_L, struct __pyx_t_4lupa_5_lupa_py_object *__pyx_v_py_obj, int __pyx_v_type_flags) {
  struct __pyx_obj_4lupa_5_lupa_LuaRuntime *__pyx_v_runtime = 0;
  PyObject *__pyx_v_obj = NULL;
  int __pyx_r;
  __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;
  PyObject *__pyx_t_6 = NULL;
  int __pyx_t_7;
  PyObject *__pyx_t_8 = NULL;
  PyObject *__pyx_t_9 = NULL;
  PyObject *__pyx_t_10 = NULL;
  PyObject *__pyx_t_11 = NULL;
  PyObject *__pyx_t_12 = NULL;
  PyObject *__pyx_t_13 = 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("py_iter_with_gil", 0);

  /* "lupa/_lupa.pyx":1734
 * cdef int py_iter_with_gil(lua_State* L, py_object* py_obj, int type_flags) with gil:
 *     cdef LuaRuntime runtime
 *     try:             # <<<<<<<<<<<<<<
 *         runtime = <LuaRuntime?>py_obj.runtime
 *         obj = iter(<object>py_obj.obj)
 */
  {
    __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:*/ {

      /* "lupa/_lupa.pyx":1735
 *     cdef LuaRuntime runtime
 *     try:
 *         runtime = <LuaRuntime?>py_obj.runtime             # <<<<<<<<<<<<<<
 *         obj = iter(<object>py_obj.obj)
 *         return py_push_iterator(runtime, L, obj, type_flags, 0.0)
 */
      __pyx_t_4 = ((PyObject *)__pyx_v_py_obj->runtime);
      __Pyx_INCREF(__pyx_t_4);
      __pyx_v_runtime = ((struct __pyx_obj_4lupa_5_lupa_LuaRuntime *)__pyx_t_4);
      __pyx_t_4 = 0;

      /* "lupa/_lupa.pyx":1736
 *     try:
 *         runtime = <LuaRuntime?>py_obj.runtime
 *         obj = iter(<object>py_obj.obj)             # <<<<<<<<<<<<<<
 *         return py_push_iterator(runtime, L, obj, type_flags, 0.0)
 *     except:
 */
      __pyx_t_4 = ((PyObject *)__pyx_v_py_obj->obj);
      __Pyx_INCREF(__pyx_t_4);
      __pyx_t_5 = PyObject_GetIter(__pyx_t_4); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1736, __pyx_L3_error)
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __pyx_v_obj = __pyx_t_5;
      __pyx_t_5 = 0;

      /* "lupa/_lupa.pyx":1737
 *         runtime = <LuaRuntime?>py_obj.runtime
 *         obj = iter(<object>py_obj.obj)
 *         return py_push_iterator(runtime, L, obj, type_flags, 0.0)             # <<<<<<<<<<<<<<
 *     except:
 *         try: runtime.store_raised_exception(L, b'error creating an iterator')
 */
      __pyx_r = __pyx_f_4lupa_5_lupa_py_push_iterator(__pyx_v_runtime, __pyx_v_L, __pyx_v_obj, __pyx_v_type_flags, 0.0);
      goto __pyx_L7_try_return;

      /* "lupa/_lupa.pyx":1734
 * cdef int py_iter_with_gil(lua_State* L, py_object* py_obj, int type_flags) with gil:
 *     cdef LuaRuntime runtime
 *     try:             # <<<<<<<<<<<<<<
 *         runtime = <LuaRuntime?>py_obj.runtime
 *         obj = iter(<object>py_obj.obj)
 */
    }
    __pyx_L3_error:;
    __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;

    /* "lupa/_lupa.pyx":1738
 *         obj = iter(<object>py_obj.obj)
 *         return py_push_iterator(runtime, L, obj, type_flags, 0.0)
 *     except:             # <<<<<<<<<<<<<<
 *         try: runtime.store_raised_exception(L, b'error creating an iterator')
 *         finally: return -1
 */
    /*except:*/ {
      __Pyx_AddTraceback("lupa._lupa.py_iter_with_gil", __pyx_clineno, __pyx_lineno, __pyx_filename);
      if (__Pyx_GetException(&__pyx_t_5, &__pyx_t_4, &__pyx_t_6) < 0) __PYX_ERR(0, 1738, __pyx_L5_except_error)
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_GOTREF(__pyx_t_6);

      /* "lupa/_lupa.pyx":1739
 *         return py_push_iterator(runtime, L, obj, type_flags, 0.0)
 *     except:
 *         try: runtime.store_raised_exception(L, b'error creating an iterator')             # <<<<<<<<<<<<<<
 *         finally: return -1
 * 
 */
      /*try:*/ {
        if (unlikely(!__pyx_v_runtime)) { __Pyx_RaiseUnboundLocalError("runtime"); __PYX_ERR(0, 1739, __pyx_L14_error) }
        __pyx_t_7 = __pyx_f_4lupa_5_lupa_10LuaRuntime_store_raised_exception(__pyx_v_runtime, __pyx_v_L, __pyx_kp_b_error_creating_an_iterator); if (unlikely(__pyx_t_7 == ((int)-1))) __PYX_ERR(0, 1739, __pyx_L14_error)
      }

      /* "lupa/_lupa.pyx":1740
 *     except:
 *         try: runtime.store_raised_exception(L, b'error creating an iterator')
 *         finally: return -1             # <<<<<<<<<<<<<<
 * 
 * cdef int py_push_iterator(LuaRuntime runtime, lua_State* L, iterator, int type_flags,
 */
      /*finally:*/ {
        /*normal exit:*/{
          __pyx_r = -1;
          __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
          __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
          __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
          goto __pyx_L6_except_return;
        }
        __pyx_L14_error:;
        /*exception exit:*/{
          __Pyx_PyThreadState_declare
          __Pyx_PyThreadState_assign
          __pyx_t_8 = 0; __pyx_t_9 = 0; __pyx_t_10 = 0; __pyx_t_11 = 0; __pyx_t_12 = 0; __pyx_t_13 = 0;
          if (PY_MAJOR_VERSION >= 3) __Pyx_ExceptionSwap(&__pyx_t_11, &__pyx_t_12, &__pyx_t_13);
          if ((PY_MAJOR_VERSION < 3) || unlikely(__Pyx_GetException(&__pyx_t_8, &__pyx_t_9, &__pyx_t_10) < 0)) __Pyx_ErrFetch(&__pyx_t_8, &__pyx_t_9, &__pyx_t_10);
          __Pyx_XGOTREF(__pyx_t_8);
          __Pyx_XGOTREF(__pyx_t_9);
          __Pyx_XGOTREF(__pyx_t_10);
          __Pyx_XGOTREF(__pyx_t_11);
          __Pyx_XGOTREF(__pyx_t_12);
          __Pyx_XGOTREF(__pyx_t_13);
          {
            __pyx_r = -1;
            __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
            __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
            __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
            goto __pyx_L18_return;
          }
          __pyx_L18_return:;
          if (PY_MAJOR_VERSION >= 3) {
            __Pyx_XGIVEREF(__pyx_t_11);
            __Pyx_XGIVEREF(__pyx_t_12);
            __Pyx_XGIVEREF(__pyx_t_13);
            __Pyx_ExceptionReset(__pyx_t_11, __pyx_t_12, __pyx_t_13);
          }
          __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
          __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
          __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
          __pyx_t_11 = 0; __pyx_t_12 = 0; __pyx_t_13 = 0;
          goto __pyx_L6_except_return;
        }
      }
    }
    __pyx_L5_except_error:;

    /* "lupa/_lupa.pyx":1734
 * cdef int py_iter_with_gil(lua_State* L, py_object* py_obj, int type_flags) with gil:
 *     cdef LuaRuntime runtime
 *     try:             # <<<<<<<<<<<<<<
 *         runtime = <LuaRuntime?>py_obj.runtime
 *         obj = iter(<object>py_obj.obj)
 */
    __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;
  }

  /* "lupa/_lupa.pyx":1732
 *         finally: return -1
 * 
 * cdef int py_iter_with_gil(lua_State* L, py_object* py_obj, int type_flags) with gil:             # <<<<<<<<<<<<<<
 *     cdef LuaRuntime runtime
 *     try:
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_WriteUnraisable("lupa._lupa.py_iter_with_gil", __pyx_clineno, __pyx_lineno, __pyx_filename, 1, 0);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_runtime);
  __Pyx_XDECREF(__pyx_v_obj);
  __Pyx_RefNannyFinishContext();
  #ifdef WITH_THREAD
  __Pyx_PyGILState_Release(__pyx_gilstate_save);
  #endif
  return __pyx_r;
}

/* "lupa/_lupa.pyx":1742
 *         finally: return -1
 * 
 * cdef int py_push_iterator(LuaRuntime runtime, lua_State* L, iterator, int type_flags,             # <<<<<<<<<<<<<<
 *                           lua.lua_Number initial_value):
 *     # Lua needs three values: iterator C function + state + control variable (last iter) value
 */

static int __pyx_f_4lupa_5_lupa_py_push_iterator(struct __pyx_obj_4lupa_5_lupa_LuaRuntime *__pyx_v_runtime, lua_State *__pyx_v_L, PyObject *__pyx_v_iterator, int __pyx_v_type_flags, lua_Number __pyx_v_initial_value) {
  int __pyx_v_old_top;
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  __Pyx_RefNannySetupContext("py_push_iterator", 0);

  /* "lupa/_lupa.pyx":1745
 *                           lua.lua_Number initial_value):
 *     # Lua needs three values: iterator C function + state + control variable (last iter) value
 *     old_top = lua.lua_gettop(L)             # <<<<<<<<<<<<<<
 *     lua.lua_pushcfunction(L, <lua.lua_CFunction>py_iter_next)
 *     # push the wrapped iterator object as for-loop state object
 */
  __pyx_v_old_top = lua_gettop(__pyx_v_L);

  /* "lupa/_lupa.pyx":1746
 *     # Lua needs three values: iterator C function + state + control variable (last iter) value
 *     old_top = lua.lua_gettop(L)
 *     lua.lua_pushcfunction(L, <lua.lua_CFunction>py_iter_next)             # <<<<<<<<<<<<<<
 *     # push the wrapped iterator object as for-loop state object
 *     if runtime._unpack_returned_tuples:
 */
  lua_pushcfunction(__pyx_v_L, ((lua_CFunction)__pyx_f_4lupa_5_lupa_py_iter_next));

  /* "lupa/_lupa.pyx":1748
 *     lua.lua_pushcfunction(L, <lua.lua_CFunction>py_iter_next)
 *     # push the wrapped iterator object as for-loop state object
 *     if runtime._unpack_returned_tuples:             # <<<<<<<<<<<<<<
 *         type_flags |= OBJ_UNPACK_TUPLE
 *     if py_to_lua_custom(runtime, L, iterator, type_flags) < 1:
 */
  __pyx_t_1 = (__pyx_v_runtime->_unpack_returned_tuples != 0);
  if (__pyx_t_1) {

    /* "lupa/_lupa.pyx":1749
 *     # push the wrapped iterator object as for-loop state object
 *     if runtime._unpack_returned_tuples:
 *         type_flags |= OBJ_UNPACK_TUPLE             # <<<<<<<<<<<<<<
 *     if py_to_lua_custom(runtime, L, iterator, type_flags) < 1:
 *         lua.lua_settop(L, old_top)
 */
    __pyx_v_type_flags = (__pyx_v_type_flags | __pyx_e_4lupa_5_lupa_OBJ_UNPACK_TUPLE);

    /* "lupa/_lupa.pyx":1748
 *     lua.lua_pushcfunction(L, <lua.lua_CFunction>py_iter_next)
 *     # push the wrapped iterator object as for-loop state object
 *     if runtime._unpack_returned_tuples:             # <<<<<<<<<<<<<<
 *         type_flags |= OBJ_UNPACK_TUPLE
 *     if py_to_lua_custom(runtime, L, iterator, type_flags) < 1:
 */
  }

  /* "lupa/_lupa.pyx":1750
 *     if runtime._unpack_returned_tuples:
 *         type_flags |= OBJ_UNPACK_TUPLE
 *     if py_to_lua_custom(runtime, L, iterator, type_flags) < 1:             # <<<<<<<<<<<<<<
 *         lua.lua_settop(L, old_top)
 *         return -1
 */
  __pyx_t_1 = ((__pyx_f_4lupa_5_lupa_py_to_lua_custom(__pyx_v_runtime, __pyx_v_L, __pyx_v_iterator, __pyx_v_type_flags) < 1) != 0);
  if (__pyx_t_1) {

    /* "lupa/_lupa.pyx":1751
 *         type_flags |= OBJ_UNPACK_TUPLE
 *     if py_to_lua_custom(runtime, L, iterator, type_flags) < 1:
 *         lua.lua_settop(L, old_top)             # <<<<<<<<<<<<<<
 *         return -1
 *     # push either enumerator index or nil as control variable value
 */
    lua_settop(__pyx_v_L, __pyx_v_old_top);

    /* "lupa/_lupa.pyx":1752
 *     if py_to_lua_custom(runtime, L, iterator, type_flags) < 1:
 *         lua.lua_settop(L, old_top)
 *         return -1             # <<<<<<<<<<<<<<
 *     # push either enumerator index or nil as control variable value
 *     if type_flags & OBJ_ENUMERATOR:
 */
    __pyx_r = -1;
    goto __pyx_L0;

    /* "lupa/_lupa.pyx":1750
 *     if runtime._unpack_returned_tuples:
 *         type_flags |= OBJ_UNPACK_TUPLE
 *     if py_to_lua_custom(runtime, L, iterator, type_flags) < 1:             # <<<<<<<<<<<<<<
 *         lua.lua_settop(L, old_top)
 *         return -1
 */
  }

  /* "lupa/_lupa.pyx":1754
 *         return -1
 *     # push either enumerator index or nil as control variable value
 *     if type_flags & OBJ_ENUMERATOR:             # <<<<<<<<<<<<<<
 *         lua.lua_pushnumber(L, initial_value)
 *     else:
 */
  __pyx_t_1 = ((__pyx_v_type_flags & __pyx_e_4lupa_5_lupa_OBJ_ENUMERATOR) != 0);
  if (__pyx_t_1) {

    /* "lupa/_lupa.pyx":1755
 *     # push either enumerator index or nil as control variable value
 *     if type_flags & OBJ_ENUMERATOR:
 *         lua.lua_pushnumber(L, initial_value)             # <<<<<<<<<<<<<<
 *     else:
 *         lua.lua_pushnil(L)
 */
    lua_pushnumber(__pyx_v_L, __pyx_v_initial_value);

    /* "lupa/_lupa.pyx":1754
 *         return -1
 *     # push either enumerator index or nil as control variable value
 *     if type_flags & OBJ_ENUMERATOR:             # <<<<<<<<<<<<<<
 *         lua.lua_pushnumber(L, initial_value)
 *     else:
 */
    goto __pyx_L5;
  }

  /* "lupa/_lupa.pyx":1757
 *         lua.lua_pushnumber(L, initial_value)
 *     else:
 *         lua.lua_pushnil(L)             # <<<<<<<<<<<<<<
 *     return 3
 * 
 */
  /*else*/ {
    lua_pushnil(__pyx_v_L);
  }
  __pyx_L5:;

  /* "lupa/_lupa.pyx":1758
 *     else:
 *         lua.lua_pushnil(L)
 *     return 3             # <<<<<<<<<<<<<<
 * 
 * cdef int py_iter_next(lua_State* L) nogil:
 */
  __pyx_r = 3;
  goto __pyx_L0;

  /* "lupa/_lupa.pyx":1742
 *         finally: return -1
 * 
 * cdef int py_push_iterator(LuaRuntime runtime, lua_State* L, iterator, int type_flags,             # <<<<<<<<<<<<<<
 *                           lua.lua_Number initial_value):
 *     # Lua needs three values: iterator C function + state + control variable (last iter) value
 */

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

/* "lupa/_lupa.pyx":1760
 *     return 3
 * 
 * cdef int py_iter_next(lua_State* L) nogil:             # <<<<<<<<<<<<<<
 *     # first value in the C closure: the Python iterator object
 *     cdef py_object* py_obj = unwrap_lua_object(L, 1)
 */

static int __pyx_f_4lupa_5_lupa_py_iter_next(lua_State *__pyx_v_L) {
  struct __pyx_t_4lupa_5_lupa_py_object *__pyx_v_py_obj;
  int __pyx_v_result;
  int __pyx_r;
  int __pyx_t_1;

  /* "lupa/_lupa.pyx":1762
 * cdef int py_iter_next(lua_State* L) nogil:
 *     # first value in the C closure: the Python iterator object
 *     cdef py_object* py_obj = unwrap_lua_object(L, 1)             # <<<<<<<<<<<<<<
 *     if not py_obj:
 *         return lua.luaL_argerror(L, 1, "not a python object")   # never returns!
 */
  __pyx_v_py_obj = __pyx_f_4lupa_5_lupa_unwrap_lua_object(__pyx_v_L, 1);

  /* "lupa/_lupa.pyx":1763
 *     # first value in the C closure: the Python iterator object
 *     cdef py_object* py_obj = unwrap_lua_object(L, 1)
 *     if not py_obj:             # <<<<<<<<<<<<<<
 *         return lua.luaL_argerror(L, 1, "not a python object")   # never returns!
 *     result = py_iter_next_with_gil(L, py_obj)
 */
  __pyx_t_1 = ((!(__pyx_v_py_obj != 0)) != 0);
  if (__pyx_t_1) {

    /* "lupa/_lupa.pyx":1764
 *     cdef py_object* py_obj = unwrap_lua_object(L, 1)
 *     if not py_obj:
 *         return lua.luaL_argerror(L, 1, "not a python object")   # never returns!             # <<<<<<<<<<<<<<
 *     result = py_iter_next_with_gil(L, py_obj)
 *     if result < 0:
 */
    __pyx_r = luaL_argerror(__pyx_v_L, 1, ((char *)"not a python object"));
    goto __pyx_L0;

    /* "lupa/_lupa.pyx":1763
 *     # first value in the C closure: the Python iterator object
 *     cdef py_object* py_obj = unwrap_lua_object(L, 1)
 *     if not py_obj:             # <<<<<<<<<<<<<<
 *         return lua.luaL_argerror(L, 1, "not a python object")   # never returns!
 *     result = py_iter_next_with_gil(L, py_obj)
 */
  }

  /* "lupa/_lupa.pyx":1765
 *     if not py_obj:
 *         return lua.luaL_argerror(L, 1, "not a python object")   # never returns!
 *     result = py_iter_next_with_gil(L, py_obj)             # <<<<<<<<<<<<<<
 *     if result < 0:
 *         return lua.lua_error(L)  # never returns!
 */
  __pyx_v_result = __pyx_f_4lupa_5_lupa_py_iter_next_with_gil(__pyx_v_L, __pyx_v_py_obj);

  /* "lupa/_lupa.pyx":1766
 *         return lua.luaL_argerror(L, 1, "not a python object")   # never returns!
 *     result = py_iter_next_with_gil(L, py_obj)
 *     if result < 0:             # <<<<<<<<<<<<<<
 *         return lua.lua_error(L)  # never returns!
 *     return result
 */
  __pyx_t_1 = ((__pyx_v_result < 0) != 0);
  if (__pyx_t_1) {

    /* "lupa/_lupa.pyx":1767
 *     result = py_iter_next_with_gil(L, py_obj)
 *     if result < 0:
 *         return lua.lua_error(L)  # never returns!             # <<<<<<<<<<<<<<
 *     return result
 * 
 */
    __pyx_r = lua_error(__pyx_v_L);
    goto __pyx_L0;

    /* "lupa/_lupa.pyx":1766
 *         return lua.luaL_argerror(L, 1, "not a python object")   # never returns!
 *     result = py_iter_next_with_gil(L, py_obj)
 *     if result < 0:             # <<<<<<<<<<<<<<
 *         return lua.lua_error(L)  # never returns!
 *     return result
 */
  }

  /* "lupa/_lupa.pyx":1768
 *     if result < 0:
 *         return lua.lua_error(L)  # never returns!
 *     return result             # <<<<<<<<<<<<<<
 * 
 * cdef int py_iter_next_with_gil(lua_State* L, py_object* py_iter) with gil:
 */
  __pyx_r = __pyx_v_result;
  goto __pyx_L0;

  /* "lupa/_lupa.pyx":1760
 *     return 3
 * 
 * cdef int py_iter_next(lua_State* L) nogil:             # <<<<<<<<<<<<<<
 *     # first value in the C closure: the Python iterator object
 *     cdef py_object* py_obj = unwrap_lua_object(L, 1)
 */

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

/* "lupa/_lupa.pyx":1770
 *     return result
 * 
 * cdef int py_iter_next_with_gil(lua_State* L, py_object* py_iter) with gil:             # <<<<<<<<<<<<<<
 *     cdef LuaRuntime runtime
 *     try:
 */

static int __pyx_f_4lupa_5_lupa_py_iter_next_with_gil(lua_State *__pyx_v_L, struct __pyx_t_4lupa_5_lupa_py_object *__pyx_v_py_iter) {
  struct __pyx_obj_4lupa_5_lupa_LuaRuntime *__pyx_v_runtime = 0;
  PyObject *__pyx_v_obj = NULL;
  int __pyx_v_allow_nil;
  PyObject *__pyx_v_result = NULL;
  int __pyx_r;
  __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;
  PyObject *__pyx_t_6 = NULL;
  PyObject *__pyx_t_7 = NULL;
  PyObject *__pyx_t_8 = NULL;
  int __pyx_t_9;
  PyObject *__pyx_t_10 = NULL;
  int __pyx_t_11;
  int __pyx_t_12;
  int __pyx_t_13;
  struct __pyx_opt_args_4lupa_5_lupa_push_lua_arguments __pyx_t_14;
  Py_ssize_t __pyx_t_15;
  struct __pyx_opt_args_4lupa_5_lupa_py_to_lua __pyx_t_16;
  PyObject *__pyx_t_17 = NULL;
  PyObject *__pyx_t_18 = NULL;
  PyObject *__pyx_t_19 = 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("py_iter_next_with_gil", 0);

  /* "lupa/_lupa.pyx":1772
 * cdef int py_iter_next_with_gil(lua_State* L, py_object* py_iter) with gil:
 *     cdef LuaRuntime runtime
 *     try:             # <<<<<<<<<<<<<<
 *         runtime = <LuaRuntime?>py_iter.runtime
 *         try:
 */
  {
    __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:*/ {

      /* "lupa/_lupa.pyx":1773
 *     cdef LuaRuntime runtime
 *     try:
 *         runtime = <LuaRuntime?>py_iter.runtime             # <<<<<<<<<<<<<<
 *         try:
 *             obj = next(<object>py_iter.obj)
 */
      __pyx_t_4 = ((PyObject *)__pyx_v_py_iter->runtime);
      __Pyx_INCREF(__pyx_t_4);
      __pyx_v_runtime = ((struct __pyx_obj_4lupa_5_lupa_LuaRuntime *)__pyx_t_4);
      __pyx_t_4 = 0;

      /* "lupa/_lupa.pyx":1774
 *     try:
 *         runtime = <LuaRuntime?>py_iter.runtime
 *         try:             # <<<<<<<<<<<<<<
 *             obj = next(<object>py_iter.obj)
 *         except StopIteration:
 */
      {
        __Pyx_PyThreadState_declare
        __Pyx_PyThreadState_assign
        __Pyx_ExceptionSave(&__pyx_t_5, &__pyx_t_6, &__pyx_t_7);
        __Pyx_XGOTREF(__pyx_t_5);
        __Pyx_XGOTREF(__pyx_t_6);
        __Pyx_XGOTREF(__pyx_t_7);
        /*try:*/ {

          /* "lupa/_lupa.pyx":1775
 *         runtime = <LuaRuntime?>py_iter.runtime
 *         try:
 *             obj = next(<object>py_iter.obj)             # <<<<<<<<<<<<<<
 *         except StopIteration:
 *             lua.lua_pushnil(L)
 */
          __pyx_t_4 = ((PyObject *)__pyx_v_py_iter->obj);
          __Pyx_INCREF(__pyx_t_4);
          __pyx_t_8 = __Pyx_PyIter_Next(__pyx_t_4); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 1775, __pyx_L9_error)
          __Pyx_GOTREF(__pyx_t_8);
          __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
          __pyx_v_obj = __pyx_t_8;
          __pyx_t_8 = 0;

          /* "lupa/_lupa.pyx":1774
 *     try:
 *         runtime = <LuaRuntime?>py_iter.runtime
 *         try:             # <<<<<<<<<<<<<<
 *             obj = next(<object>py_iter.obj)
 *         except StopIteration:
 */
        }
        __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
        __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
        __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
        goto __pyx_L14_try_end;
        __pyx_L9_error:;
        __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
        __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;

        /* "lupa/_lupa.pyx":1776
 *         try:
 *             obj = next(<object>py_iter.obj)
 *         except StopIteration:             # <<<<<<<<<<<<<<
 *             lua.lua_pushnil(L)
 *             return 1
 */
        __pyx_t_9 = __Pyx_PyErr_ExceptionMatches(__pyx_builtin_StopIteration);
        if (__pyx_t_9) {
          __Pyx_AddTraceback("lupa._lupa.py_iter_next_with_gil", __pyx_clineno, __pyx_lineno, __pyx_filename);
          if (__Pyx_GetException(&__pyx_t_8, &__pyx_t_4, &__pyx_t_10) < 0) __PYX_ERR(0, 1776, __pyx_L11_except_error)
          __Pyx_GOTREF(__pyx_t_8);
          __Pyx_GOTREF(__pyx_t_4);
          __Pyx_GOTREF(__pyx_t_10);

          /* "lupa/_lupa.pyx":1777
 *             obj = next(<object>py_iter.obj)
 *         except StopIteration:
 *             lua.lua_pushnil(L)             # <<<<<<<<<<<<<<
 *             return 1
 * 
 */
          lua_pushnil(__pyx_v_L);

          /* "lupa/_lupa.pyx":1778
 *         except StopIteration:
 *             lua.lua_pushnil(L)
 *             return 1             # <<<<<<<<<<<<<<
 * 
 *         # NOTE: cannot return nil for None as first item
 */
          __pyx_r = 1;
          __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
          __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
          __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
          goto __pyx_L12_except_return;
        }
        goto __pyx_L11_except_error;
        __pyx_L11_except_error:;

        /* "lupa/_lupa.pyx":1774
 *     try:
 *         runtime = <LuaRuntime?>py_iter.runtime
 *         try:             # <<<<<<<<<<<<<<
 *             obj = next(<object>py_iter.obj)
 *         except StopIteration:
 */
        __Pyx_XGIVEREF(__pyx_t_5);
        __Pyx_XGIVEREF(__pyx_t_6);
        __Pyx_XGIVEREF(__pyx_t_7);
        __Pyx_ExceptionReset(__pyx_t_5, __pyx_t_6, __pyx_t_7);
        goto __pyx_L3_error;
        __pyx_L12_except_return:;
        __Pyx_XGIVEREF(__pyx_t_5);
        __Pyx_XGIVEREF(__pyx_t_6);
        __Pyx_XGIVEREF(__pyx_t_7);
        __Pyx_ExceptionReset(__pyx_t_5, __pyx_t_6, __pyx_t_7);
        goto __pyx_L7_try_return;
        __pyx_L14_try_end:;
      }

      /* "lupa/_lupa.pyx":1782
 *         # NOTE: cannot return nil for None as first item
 *         # as Lua interprets it as end of the iterator
 *         allow_nil = False             # <<<<<<<<<<<<<<
 *         if py_iter.type_flags & OBJ_ENUMERATOR:
 *             lua.lua_pushnumber(L, lua.lua_tonumber(L, -1) + 1.0)
 */
      __pyx_v_allow_nil = 0;

      /* "lupa/_lupa.pyx":1783
 *         # as Lua interprets it as end of the iterator
 *         allow_nil = False
 *         if py_iter.type_flags & OBJ_ENUMERATOR:             # <<<<<<<<<<<<<<
 *             lua.lua_pushnumber(L, lua.lua_tonumber(L, -1) + 1.0)
 *             allow_nil = True
 */
      __pyx_t_11 = ((__pyx_v_py_iter->type_flags & __pyx_e_4lupa_5_lupa_OBJ_ENUMERATOR) != 0);
      if (__pyx_t_11) {

        /* "lupa/_lupa.pyx":1784
 *         allow_nil = False
 *         if py_iter.type_flags & OBJ_ENUMERATOR:
 *             lua.lua_pushnumber(L, lua.lua_tonumber(L, -1) + 1.0)             # <<<<<<<<<<<<<<
 *             allow_nil = True
 *         if (py_iter.type_flags & OBJ_UNPACK_TUPLE) and isinstance(obj, tuple):
 */
        lua_pushnumber(__pyx_v_L, (lua_tonumber(__pyx_v_L, -1) + 1.0));

        /* "lupa/_lupa.pyx":1785
 *         if py_iter.type_flags & OBJ_ENUMERATOR:
 *             lua.lua_pushnumber(L, lua.lua_tonumber(L, -1) + 1.0)
 *             allow_nil = True             # <<<<<<<<<<<<<<
 *         if (py_iter.type_flags & OBJ_UNPACK_TUPLE) and isinstance(obj, tuple):
 *             # special case: when the iterable returns a tuple, unpack it
 */
        __pyx_v_allow_nil = 1;

        /* "lupa/_lupa.pyx":1783
 *         # as Lua interprets it as end of the iterator
 *         allow_nil = False
 *         if py_iter.type_flags & OBJ_ENUMERATOR:             # <<<<<<<<<<<<<<
 *             lua.lua_pushnumber(L, lua.lua_tonumber(L, -1) + 1.0)
 *             allow_nil = True
 */
      }

      /* "lupa/_lupa.pyx":1786
 *             lua.lua_pushnumber(L, lua.lua_tonumber(L, -1) + 1.0)
 *             allow_nil = True
 *         if (py_iter.type_flags & OBJ_UNPACK_TUPLE) and isinstance(obj, tuple):             # <<<<<<<<<<<<<<
 *             # special case: when the iterable returns a tuple, unpack it
 *             push_lua_arguments(runtime, L, <tuple>obj, first_may_be_nil=allow_nil)
 */
      __pyx_t_12 = ((__pyx_v_py_iter->type_flags & __pyx_e_4lupa_5_lupa_OBJ_UNPACK_TUPLE) != 0);
      if (__pyx_t_12) {
      } else {
        __pyx_t_11 = __pyx_t_12;
        goto __pyx_L19_bool_binop_done;
      }
      __pyx_t_12 = PyTuple_Check(__pyx_v_obj); 
      __pyx_t_13 = (__pyx_t_12 != 0);
      __pyx_t_11 = __pyx_t_13;
      __pyx_L19_bool_binop_done:;
      if (__pyx_t_11) {

        /* "lupa/_lupa.pyx":1788
 *         if (py_iter.type_flags & OBJ_UNPACK_TUPLE) and isinstance(obj, tuple):
 *             # special case: when the iterable returns a tuple, unpack it
 *             push_lua_arguments(runtime, L, <tuple>obj, first_may_be_nil=allow_nil)             # <<<<<<<<<<<<<<
 *             result = len(<tuple>obj)
 *         else:
 */
        __pyx_t_14.__pyx_n = 1;
        __pyx_t_14.first_may_be_nil = __pyx_v_allow_nil;
        __pyx_t_9 = __pyx_f_4lupa_5_lupa_push_lua_arguments(__pyx_v_runtime, __pyx_v_L, ((PyObject*)__pyx_v_obj), &__pyx_t_14); if (unlikely(__pyx_t_9 == ((int)-1))) __PYX_ERR(0, 1788, __pyx_L3_error)

        /* "lupa/_lupa.pyx":1789
 *             # special case: when the iterable returns a tuple, unpack it
 *             push_lua_arguments(runtime, L, <tuple>obj, first_may_be_nil=allow_nil)
 *             result = len(<tuple>obj)             # <<<<<<<<<<<<<<
 *         else:
 *             result = py_to_lua(runtime, L, obj, wrap_none=not allow_nil)
 */
        if (unlikely(__pyx_v_obj == Py_None)) {
          PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()");
          __PYX_ERR(0, 1789, __pyx_L3_error)
        }
        __pyx_t_15 = PyTuple_GET_SIZE(((PyObject*)__pyx_v_obj)); if (unlikely(__pyx_t_15 == ((Py_ssize_t)-1))) __PYX_ERR(0, 1789, __pyx_L3_error)
        __pyx_t_10 = PyInt_FromSsize_t(__pyx_t_15); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 1789, __pyx_L3_error)
        __Pyx_GOTREF(__pyx_t_10);
        __pyx_v_result = __pyx_t_10;
        __pyx_t_10 = 0;

        /* "lupa/_lupa.pyx":1786
 *             lua.lua_pushnumber(L, lua.lua_tonumber(L, -1) + 1.0)
 *             allow_nil = True
 *         if (py_iter.type_flags & OBJ_UNPACK_TUPLE) and isinstance(obj, tuple):             # <<<<<<<<<<<<<<
 *             # special case: when the iterable returns a tuple, unpack it
 *             push_lua_arguments(runtime, L, <tuple>obj, first_may_be_nil=allow_nil)
 */
        goto __pyx_L18;
      }

      /* "lupa/_lupa.pyx":1791
 *             result = len(<tuple>obj)
 *         else:
 *             result = py_to_lua(runtime, L, obj, wrap_none=not allow_nil)             # <<<<<<<<<<<<<<
 *             if result < 1:
 *                 return -1
 */
      /*else*/ {
        __pyx_t_16.__pyx_n = 1;
        __pyx_t_16.wrap_none = (!(__pyx_v_allow_nil != 0));
        __pyx_t_9 = __pyx_f_4lupa_5_lupa_py_to_lua(__pyx_v_runtime, __pyx_v_L, __pyx_v_obj, &__pyx_t_16); if (unlikely(__pyx_t_9 == ((int)-1))) __PYX_ERR(0, 1791, __pyx_L3_error)
        __pyx_t_10 = __Pyx_PyInt_From_int(__pyx_t_9); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 1791, __pyx_L3_error)
        __Pyx_GOTREF(__pyx_t_10);
        __pyx_v_result = __pyx_t_10;
        __pyx_t_10 = 0;

        /* "lupa/_lupa.pyx":1792
 *         else:
 *             result = py_to_lua(runtime, L, obj, wrap_none=not allow_nil)
 *             if result < 1:             # <<<<<<<<<<<<<<
 *                 return -1
 *         if py_iter.type_flags & OBJ_ENUMERATOR:
 */
        __pyx_t_10 = PyObject_RichCompare(__pyx_v_result, __pyx_int_1, Py_LT); __Pyx_XGOTREF(__pyx_t_10); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 1792, __pyx_L3_error)
        __pyx_t_11 = __Pyx_PyObject_IsTrue(__pyx_t_10); if (unlikely(__pyx_t_11 < 0)) __PYX_ERR(0, 1792, __pyx_L3_error)
        __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
        if (__pyx_t_11) {

          /* "lupa/_lupa.pyx":1793
 *             result = py_to_lua(runtime, L, obj, wrap_none=not allow_nil)
 *             if result < 1:
 *                 return -1             # <<<<<<<<<<<<<<
 *         if py_iter.type_flags & OBJ_ENUMERATOR:
 *             result += 1
 */
          __pyx_r = -1;
          goto __pyx_L7_try_return;

          /* "lupa/_lupa.pyx":1792
 *         else:
 *             result = py_to_lua(runtime, L, obj, wrap_none=not allow_nil)
 *             if result < 1:             # <<<<<<<<<<<<<<
 *                 return -1
 *         if py_iter.type_flags & OBJ_ENUMERATOR:
 */
        }
      }
      __pyx_L18:;

      /* "lupa/_lupa.pyx":1794
 *             if result < 1:
 *                 return -1
 *         if py_iter.type_flags & OBJ_ENUMERATOR:             # <<<<<<<<<<<<<<
 *             result += 1
 *         return result
 */
      __pyx_t_11 = ((__pyx_v_py_iter->type_flags & __pyx_e_4lupa_5_lupa_OBJ_ENUMERATOR) != 0);
      if (__pyx_t_11) {

        /* "lupa/_lupa.pyx":1795
 *                 return -1
 *         if py_iter.type_flags & OBJ_ENUMERATOR:
 *             result += 1             # <<<<<<<<<<<<<<
 *         return result
 *     except:
 */
        __pyx_t_10 = __Pyx_PyInt_AddObjC(__pyx_v_result, __pyx_int_1, 1, 1, 0); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 1795, __pyx_L3_error)
        __Pyx_GOTREF(__pyx_t_10);
        __Pyx_DECREF_SET(__pyx_v_result, __pyx_t_10);
        __pyx_t_10 = 0;

        /* "lupa/_lupa.pyx":1794
 *             if result < 1:
 *                 return -1
 *         if py_iter.type_flags & OBJ_ENUMERATOR:             # <<<<<<<<<<<<<<
 *             result += 1
 *         return result
 */
      }

      /* "lupa/_lupa.pyx":1796
 *         if py_iter.type_flags & OBJ_ENUMERATOR:
 *             result += 1
 *         return result             # <<<<<<<<<<<<<<
 *     except:
 *         try: runtime.store_raised_exception(L, b'error while calling next(iterator)')
 */
      __pyx_t_9 = __Pyx_PyInt_As_int(__pyx_v_result); if (unlikely((__pyx_t_9 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 1796, __pyx_L3_error)
      __pyx_r = __pyx_t_9;
      goto __pyx_L7_try_return;

      /* "lupa/_lupa.pyx":1772
 * cdef int py_iter_next_with_gil(lua_State* L, py_object* py_iter) with gil:
 *     cdef LuaRuntime runtime
 *     try:             # <<<<<<<<<<<<<<
 *         runtime = <LuaRuntime?>py_iter.runtime
 *         try:
 */
    }
    __pyx_L3_error:;
    __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
    __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;

    /* "lupa/_lupa.pyx":1797
 *             result += 1
 *         return result
 *     except:             # <<<<<<<<<<<<<<
 *         try: runtime.store_raised_exception(L, b'error while calling next(iterator)')
 *         finally: return -1
 */
    /*except:*/ {
      __Pyx_AddTraceback("lupa._lupa.py_iter_next_with_gil", __pyx_clineno, __pyx_lineno, __pyx_filename);
      if (__Pyx_GetException(&__pyx_t_10, &__pyx_t_4, &__pyx_t_8) < 0) __PYX_ERR(0, 1797, __pyx_L5_except_error)
      __Pyx_GOTREF(__pyx_t_10);
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_GOTREF(__pyx_t_8);

      /* "lupa/_lupa.pyx":1798
 *         return result
 *     except:
 *         try: runtime.store_raised_exception(L, b'error while calling next(iterator)')             # <<<<<<<<<<<<<<
 *         finally: return -1
 * 
 */
      /*try:*/ {
        if (unlikely(!__pyx_v_runtime)) { __Pyx_RaiseUnboundLocalError("runtime"); __PYX_ERR(0, 1798, __pyx_L28_error) }
        __pyx_t_9 = __pyx_f_4lupa_5_lupa_10LuaRuntime_store_raised_exception(__pyx_v_runtime, __pyx_v_L, __pyx_kp_b_error_while_calling_next_iterato); if (unlikely(__pyx_t_9 == ((int)-1))) __PYX_ERR(0, 1798, __pyx_L28_error)
      }

      /* "lupa/_lupa.pyx":1799
 *     except:
 *         try: runtime.store_raised_exception(L, b'error while calling next(iterator)')
 *         finally: return -1             # <<<<<<<<<<<<<<
 * 
 * # 'python' module functions in Lua
 */
      /*finally:*/ {
        /*normal exit:*/{
          __pyx_r = -1;
          __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
          __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
          __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
          goto __pyx_L6_except_return;
        }
        __pyx_L28_error:;
        /*exception exit:*/{
          __Pyx_PyThreadState_declare
          __Pyx_PyThreadState_assign
          __pyx_t_7 = 0; __pyx_t_6 = 0; __pyx_t_5 = 0; __pyx_t_17 = 0; __pyx_t_18 = 0; __pyx_t_19 = 0;
          if (PY_MAJOR_VERSION >= 3) __Pyx_ExceptionSwap(&__pyx_t_17, &__pyx_t_18, &__pyx_t_19);
          if ((PY_MAJOR_VERSION < 3) || unlikely(__Pyx_GetException(&__pyx_t_7, &__pyx_t_6, &__pyx_t_5) < 0)) __Pyx_ErrFetch(&__pyx_t_7, &__pyx_t_6, &__pyx_t_5);
          __Pyx_XGOTREF(__pyx_t_7);
          __Pyx_XGOTREF(__pyx_t_6);
          __Pyx_XGOTREF(__pyx_t_5);
          __Pyx_XGOTREF(__pyx_t_17);
          __Pyx_XGOTREF(__pyx_t_18);
          __Pyx_XGOTREF(__pyx_t_19);
          {
            __pyx_r = -1;
            __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
            __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
            __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
            goto __pyx_L32_return;
          }
          __pyx_L32_return:;
          if (PY_MAJOR_VERSION >= 3) {
            __Pyx_XGIVEREF(__pyx_t_17);
            __Pyx_XGIVEREF(__pyx_t_18);
            __Pyx_XGIVEREF(__pyx_t_19);
            __Pyx_ExceptionReset(__pyx_t_17, __pyx_t_18, __pyx_t_19);
          }
          __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
          __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
          __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
          __pyx_t_17 = 0; __pyx_t_18 = 0; __pyx_t_19 = 0;
          goto __pyx_L6_except_return;
        }
      }
    }
    __pyx_L5_except_error:;

    /* "lupa/_lupa.pyx":1772
 * cdef int py_iter_next_with_gil(lua_State* L, py_object* py_iter) with gil:
 *     cdef LuaRuntime runtime
 *     try:             # <<<<<<<<<<<<<<
 *         runtime = <LuaRuntime?>py_iter.runtime
 *         try:
 */
    __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;
  }

  /* "lupa/_lupa.pyx":1770
 *     return result
 * 
 * cdef int py_iter_next_with_gil(lua_State* L, py_object* py_iter) with gil:             # <<<<<<<<<<<<<<
 *     cdef LuaRuntime runtime
 *     try:
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_XDECREF(__pyx_t_10);
  __Pyx_WriteUnraisable("lupa._lupa.py_iter_next_with_gil", __pyx_clineno, __pyx_lineno, __pyx_filename, 1, 0);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_runtime);
  __Pyx_XDECREF(__pyx_v_obj);
  __Pyx_XDECREF(__pyx_v_result);
  __Pyx_RefNannyFinishContext();
  #ifdef WITH_THREAD
  __Pyx_PyGILState_Release(__pyx_gilstate_save);
  #endif
  return __pyx_r;
}

/* "lupa/_lupa.pyx":1815
 * # Setup helpers for library tables (removed from C-API in Lua 5.3).
 * 
 * cdef void luaL_setfuncs(lua_State *L, const lua.luaL_Reg *l, int nup):             # <<<<<<<<<<<<<<
 *     cdef int i
 *     lua.luaL_checkstack(L, nup, "too many upvalues")
 */

static void __pyx_f_4lupa_5_lupa_luaL_setfuncs(lua_State *__pyx_v_L, luaL_Reg const *__pyx_v_l, int __pyx_v_nup) {
  CYTHON_UNUSED int __pyx_v_i;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  int __pyx_t_2;
  int __pyx_t_3;
  int __pyx_t_4;
  __Pyx_RefNannySetupContext("luaL_setfuncs", 0);

  /* "lupa/_lupa.pyx":1817
 * cdef void luaL_setfuncs(lua_State *L, const lua.luaL_Reg *l, int nup):
 *     cdef int i
 *     lua.luaL_checkstack(L, nup, "too many upvalues")             # <<<<<<<<<<<<<<
 *     while l.name != NULL:
 *         for i in range(nup):
 */
  luaL_checkstack(__pyx_v_L, __pyx_v_nup, ((char *)"too many upvalues"));

  /* "lupa/_lupa.pyx":1818
 *     cdef int i
 *     lua.luaL_checkstack(L, nup, "too many upvalues")
 *     while l.name != NULL:             # <<<<<<<<<<<<<<
 *         for i in range(nup):
 *             lua.lua_pushvalue(L, -nup)
 */
  while (1) {
    __pyx_t_1 = ((__pyx_v_l->name != NULL) != 0);
    if (!__pyx_t_1) break;

    /* "lupa/_lupa.pyx":1819
 *     lua.luaL_checkstack(L, nup, "too many upvalues")
 *     while l.name != NULL:
 *         for i in range(nup):             # <<<<<<<<<<<<<<
 *             lua.lua_pushvalue(L, -nup)
 *         lua.lua_pushcclosure(L, l.func, nup)
 */
    __pyx_t_2 = __pyx_v_nup;
    __pyx_t_3 = __pyx_t_2;
    for (__pyx_t_4 = 0; __pyx_t_4 < __pyx_t_3; __pyx_t_4+=1) {
      __pyx_v_i = __pyx_t_4;

      /* "lupa/_lupa.pyx":1820
 *     while l.name != NULL:
 *         for i in range(nup):
 *             lua.lua_pushvalue(L, -nup)             # <<<<<<<<<<<<<<
 *         lua.lua_pushcclosure(L, l.func, nup)
 *         lua.lua_setfield(L, -(nup + 2), l.name)
 */
      lua_pushvalue(__pyx_v_L, (-__pyx_v_nup));
    }

    /* "lupa/_lupa.pyx":1821
 *         for i in range(nup):
 *             lua.lua_pushvalue(L, -nup)
 *         lua.lua_pushcclosure(L, l.func, nup)             # <<<<<<<<<<<<<<
 *         lua.lua_setfield(L, -(nup + 2), l.name)
 *         l += 1
 */
    lua_pushcclosure(__pyx_v_L, __pyx_v_l->func, __pyx_v_nup);

    /* "lupa/_lupa.pyx":1822
 *             lua.lua_pushvalue(L, -nup)
 *         lua.lua_pushcclosure(L, l.func, nup)
 *         lua.lua_setfield(L, -(nup + 2), l.name)             # <<<<<<<<<<<<<<
 *         l += 1
 *     lua.lua_pop(L, nup)
 */
    lua_setfield(__pyx_v_L, (-(__pyx_v_nup + 2)), __pyx_v_l->name);

    /* "lupa/_lupa.pyx":1823
 *         lua.lua_pushcclosure(L, l.func, nup)
 *         lua.lua_setfield(L, -(nup + 2), l.name)
 *         l += 1             # <<<<<<<<<<<<<<
 *     lua.lua_pop(L, nup)
 * 
 */
    __pyx_v_l = (__pyx_v_l + 1);
  }

  /* "lupa/_lupa.pyx":1824
 *         lua.lua_setfield(L, -(nup + 2), l.name)
 *         l += 1
 *     lua.lua_pop(L, nup)             # <<<<<<<<<<<<<<
 * 
 * 
 */
  lua_pop(__pyx_v_L, __pyx_v_nup);

  /* "lupa/_lupa.pyx":1815
 * # Setup helpers for library tables (removed from C-API in Lua 5.3).
 * 
 * cdef void luaL_setfuncs(lua_State *L, const lua.luaL_Reg *l, int nup):             # <<<<<<<<<<<<<<
 *     cdef int i
 *     lua.luaL_checkstack(L, nup, "too many upvalues")
 */

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

/* "lupa/_lupa.pyx":1827
 * 
 * 
 * cdef int libsize(const lua.luaL_Reg *l):             # <<<<<<<<<<<<<<
 *     cdef int size = 0
 *     while l and l.name:
 */

static int __pyx_f_4lupa_5_lupa_libsize(luaL_Reg const *__pyx_v_l) {
  int __pyx_v_size;
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  int __pyx_t_2;
  __Pyx_RefNannySetupContext("libsize", 0);

  /* "lupa/_lupa.pyx":1828
 * 
 * cdef int libsize(const lua.luaL_Reg *l):
 *     cdef int size = 0             # <<<<<<<<<<<<<<
 *     while l and l.name:
 *         l += 1
 */
  __pyx_v_size = 0;

  /* "lupa/_lupa.pyx":1829
 * cdef int libsize(const lua.luaL_Reg *l):
 *     cdef int size = 0
 *     while l and l.name:             # <<<<<<<<<<<<<<
 *         l += 1
 *         size += 1
 */
  while (1) {
    __pyx_t_2 = (__pyx_v_l != 0);
    if (__pyx_t_2) {
    } else {
      __pyx_t_1 = __pyx_t_2;
      goto __pyx_L5_bool_binop_done;
    }
    __pyx_t_2 = (__pyx_v_l->name != 0);
    __pyx_t_1 = __pyx_t_2;
    __pyx_L5_bool_binop_done:;
    if (!__pyx_t_1) break;

    /* "lupa/_lupa.pyx":1830
 *     cdef int size = 0
 *     while l and l.name:
 *         l += 1             # <<<<<<<<<<<<<<
 *         size += 1
 *     return size
 */
    __pyx_v_l = (__pyx_v_l + 1);

    /* "lupa/_lupa.pyx":1831
 *     while l and l.name:
 *         l += 1
 *         size += 1             # <<<<<<<<<<<<<<
 *     return size
 * 
 */
    __pyx_v_size = (__pyx_v_size + 1);
  }

  /* "lupa/_lupa.pyx":1832
 *         l += 1
 *         size += 1
 *     return size             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_r = __pyx_v_size;
  goto __pyx_L0;

  /* "lupa/_lupa.pyx":1827
 * 
 * 
 * cdef int libsize(const lua.luaL_Reg *l):             # <<<<<<<<<<<<<<
 *     cdef int size = 0
 *     while l and l.name:
 */

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

/* "lupa/_lupa.pyx":1835
 * 
 * 
 * cdef const char *luaL_findtable(lua_State *L, int idx,             # <<<<<<<<<<<<<<
 *                                 const char *fname, int size_hint):
 *     cdef const char *end
 */

static char const *__pyx_f_4lupa_5_lupa_luaL_findtable(lua_State *__pyx_v_L, int __pyx_v_idx, char const *__pyx_v_fname, int __pyx_v_size_hint) {
  char const *__pyx_v_end;
  char const *__pyx_r;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  int __pyx_t_2;
  __Pyx_RefNannySetupContext("luaL_findtable", 0);

  /* "lupa/_lupa.pyx":1838
 *                                 const char *fname, int size_hint):
 *     cdef const char *end
 *     if idx:             # <<<<<<<<<<<<<<
 *         lua.lua_pushvalue(L, idx)
 * 
 */
  __pyx_t_1 = (__pyx_v_idx != 0);
  if (__pyx_t_1) {

    /* "lupa/_lupa.pyx":1839
 *     cdef const char *end
 *     if idx:
 *         lua.lua_pushvalue(L, idx)             # <<<<<<<<<<<<<<
 * 
 *     while True:
 */
    lua_pushvalue(__pyx_v_L, __pyx_v_idx);

    /* "lupa/_lupa.pyx":1838
 *                                 const char *fname, int size_hint):
 *     cdef const char *end
 *     if idx:             # <<<<<<<<<<<<<<
 *         lua.lua_pushvalue(L, idx)
 * 
 */
  }

  /* "lupa/_lupa.pyx":1841
 *         lua.lua_pushvalue(L, idx)
 * 
 *     while True:             # <<<<<<<<<<<<<<
 *         end = strchr(fname, '.')
 *         if end == NULL:
 */
  while (1) {

    /* "lupa/_lupa.pyx":1842
 * 
 *     while True:
 *         end = strchr(fname, '.')             # <<<<<<<<<<<<<<
 *         if end == NULL:
 *             end = fname + strlen(fname)
 */
    __pyx_v_end = strchr(__pyx_v_fname, '.');

    /* "lupa/_lupa.pyx":1843
 *     while True:
 *         end = strchr(fname, '.')
 *         if end == NULL:             # <<<<<<<<<<<<<<
 *             end = fname + strlen(fname)
 *         lua.lua_pushlstring(L, fname, end - fname)
 */
    __pyx_t_1 = ((__pyx_v_end == NULL) != 0);
    if (__pyx_t_1) {

      /* "lupa/_lupa.pyx":1844
 *         end = strchr(fname, '.')
 *         if end == NULL:
 *             end = fname + strlen(fname)             # <<<<<<<<<<<<<<
 *         lua.lua_pushlstring(L, fname, end - fname)
 *         lua.lua_rawget(L, -2)
 */
      __pyx_v_end = (__pyx_v_fname + strlen(__pyx_v_fname));

      /* "lupa/_lupa.pyx":1843
 *     while True:
 *         end = strchr(fname, '.')
 *         if end == NULL:             # <<<<<<<<<<<<<<
 *             end = fname + strlen(fname)
 *         lua.lua_pushlstring(L, fname, end - fname)
 */
    }

    /* "lupa/_lupa.pyx":1845
 *         if end == NULL:
 *             end = fname + strlen(fname)
 *         lua.lua_pushlstring(L, fname, end - fname)             # <<<<<<<<<<<<<<
 *         lua.lua_rawget(L, -2)
 *         if lua.lua_type(L, -1) == lua.LUA_TNIL:
 */
    lua_pushlstring(__pyx_v_L, __pyx_v_fname, (__pyx_v_end - __pyx_v_fname));

    /* "lupa/_lupa.pyx":1846
 *             end = fname + strlen(fname)
 *         lua.lua_pushlstring(L, fname, end - fname)
 *         lua.lua_rawget(L, -2)             # <<<<<<<<<<<<<<
 *         if lua.lua_type(L, -1) == lua.LUA_TNIL:
 *             lua.lua_pop(L, 1)
 */
    lua_rawget(__pyx_v_L, -2);

    /* "lupa/_lupa.pyx":1847
 *         lua.lua_pushlstring(L, fname, end - fname)
 *         lua.lua_rawget(L, -2)
 *         if lua.lua_type(L, -1) == lua.LUA_TNIL:             # <<<<<<<<<<<<<<
 *             lua.lua_pop(L, 1)
 *             lua.lua_createtable(L, 0, (1 if end[0] == '.' else size_hint))
 */
    __pyx_t_1 = ((lua_type(__pyx_v_L, -1) == LUA_TNIL) != 0);
    if (__pyx_t_1) {

      /* "lupa/_lupa.pyx":1848
 *         lua.lua_rawget(L, -2)
 *         if lua.lua_type(L, -1) == lua.LUA_TNIL:
 *             lua.lua_pop(L, 1)             # <<<<<<<<<<<<<<
 *             lua.lua_createtable(L, 0, (1 if end[0] == '.' else size_hint))
 *             lua.lua_pushlstring(L, fname, end - fname)
 */
      lua_pop(__pyx_v_L, 1);

      /* "lupa/_lupa.pyx":1849
 *         if lua.lua_type(L, -1) == lua.LUA_TNIL:
 *             lua.lua_pop(L, 1)
 *             lua.lua_createtable(L, 0, (1 if end[0] == '.' else size_hint))             # <<<<<<<<<<<<<<
 *             lua.lua_pushlstring(L, fname, end - fname)
 *             lua.lua_pushvalue(L, -2)
 */
      if ((((__pyx_v_end[0]) == '.') != 0)) {
        __pyx_t_2 = 1;
      } else {
        __pyx_t_2 = __pyx_v_size_hint;
      }
      lua_createtable(__pyx_v_L, 0, __pyx_t_2);

      /* "lupa/_lupa.pyx":1850
 *             lua.lua_pop(L, 1)
 *             lua.lua_createtable(L, 0, (1 if end[0] == '.' else size_hint))
 *             lua.lua_pushlstring(L, fname, end - fname)             # <<<<<<<<<<<<<<
 *             lua.lua_pushvalue(L, -2)
 *             lua.lua_settable(L, -4)
 */
      lua_pushlstring(__pyx_v_L, __pyx_v_fname, (__pyx_v_end - __pyx_v_fname));

      /* "lupa/_lupa.pyx":1851
 *             lua.lua_createtable(L, 0, (1 if end[0] == '.' else size_hint))
 *             lua.lua_pushlstring(L, fname, end - fname)
 *             lua.lua_pushvalue(L, -2)             # <<<<<<<<<<<<<<
 *             lua.lua_settable(L, -4)
 *         elif not lua.lua_istable(L, -1):
 */
      lua_pushvalue(__pyx_v_L, -2);

      /* "lupa/_lupa.pyx":1852
 *             lua.lua_pushlstring(L, fname, end - fname)
 *             lua.lua_pushvalue(L, -2)
 *             lua.lua_settable(L, -4)             # <<<<<<<<<<<<<<
 *         elif not lua.lua_istable(L, -1):
 *             lua.lua_pop(L, 2)
 */
      lua_settable(__pyx_v_L, -4);

      /* "lupa/_lupa.pyx":1847
 *         lua.lua_pushlstring(L, fname, end - fname)
 *         lua.lua_rawget(L, -2)
 *         if lua.lua_type(L, -1) == lua.LUA_TNIL:             # <<<<<<<<<<<<<<
 *             lua.lua_pop(L, 1)
 *             lua.lua_createtable(L, 0, (1 if end[0] == '.' else size_hint))
 */
      goto __pyx_L7;
    }

    /* "lupa/_lupa.pyx":1853
 *             lua.lua_pushvalue(L, -2)
 *             lua.lua_settable(L, -4)
 *         elif not lua.lua_istable(L, -1):             # <<<<<<<<<<<<<<
 *             lua.lua_pop(L, 2)
 *             return fname
 */
    __pyx_t_1 = ((!(lua_istable(__pyx_v_L, -1) != 0)) != 0);
    if (__pyx_t_1) {

      /* "lupa/_lupa.pyx":1854
 *             lua.lua_settable(L, -4)
 *         elif not lua.lua_istable(L, -1):
 *             lua.lua_pop(L, 2)             # <<<<<<<<<<<<<<
 *             return fname
 *         lua.lua_remove(L, -2)
 */
      lua_pop(__pyx_v_L, 2);

      /* "lupa/_lupa.pyx":1855
 *         elif not lua.lua_istable(L, -1):
 *             lua.lua_pop(L, 2)
 *             return fname             # <<<<<<<<<<<<<<
 *         lua.lua_remove(L, -2)
 *         fname = end + 1
 */
      __pyx_r = __pyx_v_fname;
      goto __pyx_L0;

      /* "lupa/_lupa.pyx":1853
 *             lua.lua_pushvalue(L, -2)
 *             lua.lua_settable(L, -4)
 *         elif not lua.lua_istable(L, -1):             # <<<<<<<<<<<<<<
 *             lua.lua_pop(L, 2)
 *             return fname
 */
    }
    __pyx_L7:;

    /* "lupa/_lupa.pyx":1856
 *             lua.lua_pop(L, 2)
 *             return fname
 *         lua.lua_remove(L, -2)             # <<<<<<<<<<<<<<
 *         fname = end + 1
 *         if end[0] != '.':
 */
    lua_remove(__pyx_v_L, -2);

    /* "lupa/_lupa.pyx":1857
 *             return fname
 *         lua.lua_remove(L, -2)
 *         fname = end + 1             # <<<<<<<<<<<<<<
 *         if end[0] != '.':
 *             break
 */
    __pyx_v_fname = (__pyx_v_end + 1);

    /* "lupa/_lupa.pyx":1858
 *         lua.lua_remove(L, -2)
 *         fname = end + 1
 *         if end[0] != '.':             # <<<<<<<<<<<<<<
 *             break
 *     return NULL
 */
    __pyx_t_1 = (((__pyx_v_end[0]) != '.') != 0);
    if (__pyx_t_1) {

      /* "lupa/_lupa.pyx":1859
 *         fname = end + 1
 *         if end[0] != '.':
 *             break             # <<<<<<<<<<<<<<
 *     return NULL
 * 
 */
      goto __pyx_L5_break;

      /* "lupa/_lupa.pyx":1858
 *         lua.lua_remove(L, -2)
 *         fname = end + 1
 *         if end[0] != '.':             # <<<<<<<<<<<<<<
 *             break
 *     return NULL
 */
    }
  }
  __pyx_L5_break:;

  /* "lupa/_lupa.pyx":1860
 *         if end[0] != '.':
 *             break
 *     return NULL             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_r = NULL;
  goto __pyx_L0;

  /* "lupa/_lupa.pyx":1835
 * 
 * 
 * cdef const char *luaL_findtable(lua_State *L, int idx,             # <<<<<<<<<<<<<<
 *                                 const char *fname, int size_hint):
 *     cdef const char *end
 */

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

/* "lupa/_lupa.pyx":1863
 * 
 * 
 * cdef void luaL_pushmodule(lua_State *L, const char *modname, int size_hint):             # <<<<<<<<<<<<<<
 *     # XXX: "_LOADED" is the value of LUA_LOADED_TABLE,
 *     # but it's absent in lua51
 */

static void __pyx_f_4lupa_5_lupa_luaL_pushmodule(lua_State *__pyx_v_L, char const *__pyx_v_modname, int __pyx_v_size_hint) {
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  __Pyx_RefNannySetupContext("luaL_pushmodule", 0);

  /* "lupa/_lupa.pyx":1866
 *     # XXX: "_LOADED" is the value of LUA_LOADED_TABLE,
 *     # but it's absent in lua51
 *     luaL_findtable(L, lua.LUA_REGISTRYINDEX, "_LOADED", 1)             # <<<<<<<<<<<<<<
 *     lua.lua_getfield(L, -1, modname)
 *     if lua.lua_type(L, -1) != lua.LUA_TTABLE:
 */
  (void)(__pyx_f_4lupa_5_lupa_luaL_findtable(__pyx_v_L, LUA_REGISTRYINDEX, ((char const *)"_LOADED"), 1));

  /* "lupa/_lupa.pyx":1867
 *     # but it's absent in lua51
 *     luaL_findtable(L, lua.LUA_REGISTRYINDEX, "_LOADED", 1)
 *     lua.lua_getfield(L, -1, modname)             # <<<<<<<<<<<<<<
 *     if lua.lua_type(L, -1) != lua.LUA_TTABLE:
 *         lua.lua_pop(L, 1)
 */
  lua_getfield(__pyx_v_L, -1, __pyx_v_modname);

  /* "lupa/_lupa.pyx":1868
 *     luaL_findtable(L, lua.LUA_REGISTRYINDEX, "_LOADED", 1)
 *     lua.lua_getfield(L, -1, modname)
 *     if lua.lua_type(L, -1) != lua.LUA_TTABLE:             # <<<<<<<<<<<<<<
 *         lua.lua_pop(L, 1)
 *         lua.lua_getglobal(L, '_G')
 */
  __pyx_t_1 = ((lua_type(__pyx_v_L, -1) != LUA_TTABLE) != 0);
  if (__pyx_t_1) {

    /* "lupa/_lupa.pyx":1869
 *     lua.lua_getfield(L, -1, modname)
 *     if lua.lua_type(L, -1) != lua.LUA_TTABLE:
 *         lua.lua_pop(L, 1)             # <<<<<<<<<<<<<<
 *         lua.lua_getglobal(L, '_G')
 *         if luaL_findtable(L, 0, modname, size_hint) != NULL:
 */
    lua_pop(__pyx_v_L, 1);

    /* "lupa/_lupa.pyx":1870
 *     if lua.lua_type(L, -1) != lua.LUA_TTABLE:
 *         lua.lua_pop(L, 1)
 *         lua.lua_getglobal(L, '_G')             # <<<<<<<<<<<<<<
 *         if luaL_findtable(L, 0, modname, size_hint) != NULL:
 *             lua.luaL_error(L, "name conflict for module '%s'", modname)
 */
    lua_getglobal(__pyx_v_L, ((char *)"_G"));

    /* "lupa/_lupa.pyx":1871
 *         lua.lua_pop(L, 1)
 *         lua.lua_getglobal(L, '_G')
 *         if luaL_findtable(L, 0, modname, size_hint) != NULL:             # <<<<<<<<<<<<<<
 *             lua.luaL_error(L, "name conflict for module '%s'", modname)
 *         lua.lua_pushvalue(L, -1)
 */
    __pyx_t_1 = ((__pyx_f_4lupa_5_lupa_luaL_findtable(__pyx_v_L, 0, __pyx_v_modname, __pyx_v_size_hint) != NULL) != 0);
    if (__pyx_t_1) {

      /* "lupa/_lupa.pyx":1872
 *         lua.lua_getglobal(L, '_G')
 *         if luaL_findtable(L, 0, modname, size_hint) != NULL:
 *             lua.luaL_error(L, "name conflict for module '%s'", modname)             # <<<<<<<<<<<<<<
 *         lua.lua_pushvalue(L, -1)
 *         lua.lua_setfield(L, -3, modname)
 */
      (void)(luaL_error(__pyx_v_L, ((char *)"name conflict for module '%s'"), __pyx_v_modname));

      /* "lupa/_lupa.pyx":1871
 *         lua.lua_pop(L, 1)
 *         lua.lua_getglobal(L, '_G')
 *         if luaL_findtable(L, 0, modname, size_hint) != NULL:             # <<<<<<<<<<<<<<
 *             lua.luaL_error(L, "name conflict for module '%s'", modname)
 *         lua.lua_pushvalue(L, -1)
 */
    }

    /* "lupa/_lupa.pyx":1873
 *         if luaL_findtable(L, 0, modname, size_hint) != NULL:
 *             lua.luaL_error(L, "name conflict for module '%s'", modname)
 *         lua.lua_pushvalue(L, -1)             # <<<<<<<<<<<<<<
 *         lua.lua_setfield(L, -3, modname)
 *     lua.lua_remove(L, -2)
 */
    lua_pushvalue(__pyx_v_L, -1);

    /* "lupa/_lupa.pyx":1874
 *             lua.luaL_error(L, "name conflict for module '%s'", modname)
 *         lua.lua_pushvalue(L, -1)
 *         lua.lua_setfield(L, -3, modname)             # <<<<<<<<<<<<<<
 *     lua.lua_remove(L, -2)
 * 
 */
    lua_setfield(__pyx_v_L, -3, __pyx_v_modname);

    /* "lupa/_lupa.pyx":1868
 *     luaL_findtable(L, lua.LUA_REGISTRYINDEX, "_LOADED", 1)
 *     lua.lua_getfield(L, -1, modname)
 *     if lua.lua_type(L, -1) != lua.LUA_TTABLE:             # <<<<<<<<<<<<<<
 *         lua.lua_pop(L, 1)
 *         lua.lua_getglobal(L, '_G')
 */
  }

  /* "lupa/_lupa.pyx":1875
 *         lua.lua_pushvalue(L, -1)
 *         lua.lua_setfield(L, -3, modname)
 *     lua.lua_remove(L, -2)             # <<<<<<<<<<<<<<
 * 
 * 
 */
  lua_remove(__pyx_v_L, -2);

  /* "lupa/_lupa.pyx":1863
 * 
 * 
 * cdef void luaL_pushmodule(lua_State *L, const char *modname, int size_hint):             # <<<<<<<<<<<<<<
 *     # XXX: "_LOADED" is the value of LUA_LOADED_TABLE,
 *     # but it's absent in lua51
 */

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

/* "lupa/_lupa.pyx":1878
 * 
 * 
 * cdef void luaL_openlib(lua_State *L, const char *libname,             # <<<<<<<<<<<<<<
 *                        const lua.luaL_Reg *l, int nup):
 *     if libname:
 */

static void __pyx_f_4lupa_5_lupa_luaL_openlib(lua_State *__pyx_v_L, char const *__pyx_v_libname, luaL_Reg const *__pyx_v_l, int __pyx_v_nup) {
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  __Pyx_RefNannySetupContext("luaL_openlib", 0);

  /* "lupa/_lupa.pyx":1880
 * cdef void luaL_openlib(lua_State *L, const char *libname,
 *                        const lua.luaL_Reg *l, int nup):
 *     if libname:             # <<<<<<<<<<<<<<
 *         luaL_pushmodule(L, libname, libsize(l))
 *         lua.lua_insert(L, -(nup + 1))
 */
  __pyx_t_1 = (__pyx_v_libname != 0);
  if (__pyx_t_1) {

    /* "lupa/_lupa.pyx":1881
 *                        const lua.luaL_Reg *l, int nup):
 *     if libname:
 *         luaL_pushmodule(L, libname, libsize(l))             # <<<<<<<<<<<<<<
 *         lua.lua_insert(L, -(nup + 1))
 *     if l:
 */
    __pyx_f_4lupa_5_lupa_luaL_pushmodule(__pyx_v_L, __pyx_v_libname, __pyx_f_4lupa_5_lupa_libsize(__pyx_v_l));

    /* "lupa/_lupa.pyx":1882
 *     if libname:
 *         luaL_pushmodule(L, libname, libsize(l))
 *         lua.lua_insert(L, -(nup + 1))             # <<<<<<<<<<<<<<
 *     if l:
 *         luaL_setfuncs(L, l, nup)
 */
    lua_insert(__pyx_v_L, (-(__pyx_v_nup + 1)));

    /* "lupa/_lupa.pyx":1880
 * cdef void luaL_openlib(lua_State *L, const char *libname,
 *                        const lua.luaL_Reg *l, int nup):
 *     if libname:             # <<<<<<<<<<<<<<
 *         luaL_pushmodule(L, libname, libsize(l))
 *         lua.lua_insert(L, -(nup + 1))
 */
  }

  /* "lupa/_lupa.pyx":1883
 *         luaL_pushmodule(L, libname, libsize(l))
 *         lua.lua_insert(L, -(nup + 1))
 *     if l:             # <<<<<<<<<<<<<<
 *         luaL_setfuncs(L, l, nup)
 *     else:
 */
  __pyx_t_1 = (__pyx_v_l != 0);
  if (__pyx_t_1) {

    /* "lupa/_lupa.pyx":1884
 *         lua.lua_insert(L, -(nup + 1))
 *     if l:
 *         luaL_setfuncs(L, l, nup)             # <<<<<<<<<<<<<<
 *     else:
 *         lua.lua_pop(L, nup)
 */
    __pyx_f_4lupa_5_lupa_luaL_setfuncs(__pyx_v_L, __pyx_v_l, __pyx_v_nup);

    /* "lupa/_lupa.pyx":1883
 *         luaL_pushmodule(L, libname, libsize(l))
 *         lua.lua_insert(L, -(nup + 1))
 *     if l:             # <<<<<<<<<<<<<<
 *         luaL_setfuncs(L, l, nup)
 *     else:
 */
    goto __pyx_L4;
  }

  /* "lupa/_lupa.pyx":1886
 *         luaL_setfuncs(L, l, nup)
 *     else:
 *         lua.lua_pop(L, nup)             # <<<<<<<<<<<<<<
 */
  /*else*/ {
    lua_pop(__pyx_v_L, __pyx_v_nup);
  }
  __pyx_L4:;

  /* "lupa/_lupa.pyx":1878
 * 
 * 
 * cdef void luaL_openlib(lua_State *L, const char *libname,             # <<<<<<<<<<<<<<
 *                        const lua.luaL_Reg *l, int nup):
 *     if libname:
 */

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

static PyObject *__pyx_tp_new_4lupa_5_lupa_FastRLock(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
  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;
  if (unlikely(__pyx_pw_4lupa_5_lupa_9FastRLock_1__cinit__(o, __pyx_empty_tuple, NULL) < 0)) goto bad;
  return o;
  bad:
  Py_DECREF(o); o = 0;
  return NULL;
}

static void __pyx_tp_dealloc_4lupa_5_lupa_FastRLock(PyObject *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_4lupa_5_lupa_9FastRLock_3__dealloc__(o);
    __Pyx_SET_REFCNT(o, Py_REFCNT(o) - 1);
    PyErr_Restore(etype, eval, etb);
  }
  (*Py_TYPE(o)->tp_free)(o);
}

static PyMethodDef __pyx_methods_4lupa_5_lupa_FastRLock[] = {
  {"acquire", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_4lupa_5_lupa_9FastRLock_5acquire, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4lupa_5_lupa_9FastRLock_4acquire},
  {"release", (PyCFunction)__pyx_pw_4lupa_5_lupa_9FastRLock_7release, METH_NOARGS, __pyx_doc_4lupa_5_lupa_9FastRLock_6release},
  {"__enter__", (PyCFunction)__pyx_pw_4lupa_5_lupa_9FastRLock_9__enter__, METH_NOARGS, __pyx_doc_4lupa_5_lupa_9FastRLock_8__enter__},
  {"__exit__", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_4lupa_5_lupa_9FastRLock_11__exit__, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4lupa_5_lupa_9FastRLock_10__exit__},
  {"_is_owned", (PyCFunction)__pyx_pw_4lupa_5_lupa_9FastRLock_13_is_owned, METH_NOARGS, __pyx_doc_4lupa_5_lupa_9FastRLock_12_is_owned},
  {"__reduce_cython__", (PyCFunction)__pyx_pw_4lupa_5_lupa_9FastRLock_15__reduce_cython__, METH_NOARGS, __pyx_doc_4lupa_5_lupa_9FastRLock_14__reduce_cython__},
  {"__setstate_cython__", (PyCFunction)__pyx_pw_4lupa_5_lupa_9FastRLock_17__setstate_cython__, METH_O, __pyx_doc_4lupa_5_lupa_9FastRLock_16__setstate_cython__},
  {0, 0, 0, 0}
};

static PyTypeObject __pyx_type_4lupa_5_lupa_FastRLock = {
  PyVarObject_HEAD_INIT(0, 0)
  "lupa._lupa.FastRLock", /*tp_name*/
  sizeof(struct __pyx_obj_4lupa_5_lupa_FastRLock), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_4lupa_5_lupa_FastRLock, /*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
  0, /*tp_repr*/
  0, /*tp_as_number*/
  0, /*tp_as_sequence*/
  0, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*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*/
  "Fast, re-entrant locking.\n\n    Under uncongested conditions, the lock is never acquired but only\n    counted.  Only when a second thread comes in and notices that the\n    lock is needed, it acquires the lock and notifies the first thread\n    to release it when it's done.  This is all made possible by the\n    wonderful GIL.\n    ", /*tp_doc*/
  0, /*tp_traverse*/
  0, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  __pyx_methods_4lupa_5_lupa_FastRLock, /*tp_methods*/
  0, /*tp_members*/
  0, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  0, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_4lupa_5_lupa_FastRLock, /*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 struct __pyx_vtabstruct_4lupa_5_lupa_LuaRuntime __pyx_vtable_4lupa_5_lupa_LuaRuntime;

static PyObject *__pyx_tp_new_4lupa_5_lupa_LuaRuntime(PyTypeObject *t, PyObject *a, PyObject *k) {
  struct __pyx_obj_4lupa_5_lupa_LuaRuntime *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_4lupa_5_lupa_LuaRuntime *)o);
  p->__pyx_vtab = __pyx_vtabptr_4lupa_5_lupa_LuaRuntime;
  p->_lock = ((struct __pyx_obj_4lupa_5_lupa_FastRLock *)Py_None); Py_INCREF(Py_None);
  p->_pyrefs_in_lua = ((PyObject*)Py_None); Py_INCREF(Py_None);
  p->_raised_exception = ((PyObject*)Py_None); Py_INCREF(Py_None);
  p->_encoding = ((PyObject*)Py_None); Py_INCREF(Py_None);
  p->_source_encoding = ((PyObject*)Py_None); Py_INCREF(Py_None);
  p->_attribute_filter = Py_None; Py_INCREF(Py_None);
  p->_attribute_getter = Py_None; Py_INCREF(Py_None);
  p->_attribute_setter = Py_None; Py_INCREF(Py_None);
  if (unlikely(__pyx_pw_4lupa_5_lupa_10LuaRuntime_1__cinit__(o, a, k) < 0)) goto bad;
  return o;
  bad:
  Py_DECREF(o); o = 0;
  return NULL;
}

static void __pyx_tp_dealloc_4lupa_5_lupa_LuaRuntime(PyObject *o) {
  struct __pyx_obj_4lupa_5_lupa_LuaRuntime *p = (struct __pyx_obj_4lupa_5_lupa_LuaRuntime *)o;
  #if CYTHON_USE_TP_FINALIZE
  if (unlikely(PyType_HasFeature(Py_TYPE(o), Py_TPFLAGS_HAVE_FINALIZE) && Py_TYPE(o)->tp_finalize) && !_PyGC_FINALIZED(o)) {
    if (PyObject_CallFinalizerFromDealloc(o)) return;
  }
  #endif
  PyObject_GC_UnTrack(o);
  {
    PyObject *etype, *eval, *etb;
    PyErr_Fetch(&etype, &eval, &etb);
    __Pyx_SET_REFCNT(o, Py_REFCNT(o) + 1);
    __pyx_pw_4lupa_5_lupa_10LuaRuntime_3__dealloc__(o);
    __Pyx_SET_REFCNT(o, Py_REFCNT(o) - 1);
    PyErr_Restore(etype, eval, etb);
  }
  Py_CLEAR(p->_lock);
  Py_CLEAR(p->_pyrefs_in_lua);
  Py_CLEAR(p->_raised_exception);
  Py_CLEAR(p->_encoding);
  Py_CLEAR(p->_source_encoding);
  Py_CLEAR(p->_attribute_filter);
  Py_CLEAR(p->_attribute_getter);
  Py_CLEAR(p->_attribute_setter);
  (*Py_TYPE(o)->tp_free)(o);
}

static int __pyx_tp_traverse_4lupa_5_lupa_LuaRuntime(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_4lupa_5_lupa_LuaRuntime *p = (struct __pyx_obj_4lupa_5_lupa_LuaRuntime *)o;
  if (p->_lock) {
    e = (*v)(((PyObject *)p->_lock), a); if (e) return e;
  }
  if (p->_pyrefs_in_lua) {
    e = (*v)(p->_pyrefs_in_lua, a); if (e) return e;
  }
  if (p->_raised_exception) {
    e = (*v)(p->_raised_exception, a); if (e) return e;
  }
  if (p->_attribute_filter) {
    e = (*v)(p->_attribute_filter, a); if (e) return e;
  }
  if (p->_attribute_getter) {
    e = (*v)(p->_attribute_getter, a); if (e) return e;
  }
  if (p->_attribute_setter) {
    e = (*v)(p->_attribute_setter, a); if (e) return e;
  }
  return 0;
}

static PyObject *__pyx_getprop_4lupa_5_lupa_10LuaRuntime_lua_version(PyObject *o, CYTHON_UNUSED void *x) {
  return __pyx_pw_4lupa_5_lupa_10LuaRuntime_11lua_version_1__get__(o);
}

static PyObject *__pyx_getprop_4lupa_5_lupa_10LuaRuntime_lua_implementation(PyObject *o, CYTHON_UNUSED void *x) {
  return __pyx_pw_4lupa_5_lupa_10LuaRuntime_18lua_implementation_1__get__(o);
}

static PyMethodDef __pyx_methods_4lupa_5_lupa_LuaRuntime[] = {
  {"eval", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_4lupa_5_lupa_10LuaRuntime_5eval, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4lupa_5_lupa_10LuaRuntime_4eval},
  {"execute", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_4lupa_5_lupa_10LuaRuntime_7execute, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4lupa_5_lupa_10LuaRuntime_6execute},
  {"compile", (PyCFunction)__pyx_pw_4lupa_5_lupa_10LuaRuntime_9compile, METH_O, __pyx_doc_4lupa_5_lupa_10LuaRuntime_8compile},
  {"require", (PyCFunction)__pyx_pw_4lupa_5_lupa_10LuaRuntime_11require, METH_O, __pyx_doc_4lupa_5_lupa_10LuaRuntime_10require},
  {"globals", (PyCFunction)__pyx_pw_4lupa_5_lupa_10LuaRuntime_13globals, METH_NOARGS, __pyx_doc_4lupa_5_lupa_10LuaRuntime_12globals},
  {"table", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_4lupa_5_lupa_10LuaRuntime_15table, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4lupa_5_lupa_10LuaRuntime_14table},
  {"table_from", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_4lupa_5_lupa_10LuaRuntime_17table_from, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4lupa_5_lupa_10LuaRuntime_16table_from},
  {"__reduce_cython__", (PyCFunction)__pyx_pw_4lupa_5_lupa_10LuaRuntime_19__reduce_cython__, METH_NOARGS, __pyx_doc_4lupa_5_lupa_10LuaRuntime_18__reduce_cython__},
  {"__setstate_cython__", (PyCFunction)__pyx_pw_4lupa_5_lupa_10LuaRuntime_21__setstate_cython__, METH_O, __pyx_doc_4lupa_5_lupa_10LuaRuntime_20__setstate_cython__},
  {0, 0, 0, 0}
};

static struct PyGetSetDef __pyx_getsets_4lupa_5_lupa_LuaRuntime[] = {
  {(char *)"lua_version", __pyx_getprop_4lupa_5_lupa_10LuaRuntime_lua_version, 0, (char *)"\n        The Lua runtime/language version as tuple, e.g. (5, 3) for Lua 5.3.\n        ", 0},
  {(char *)"lua_implementation", __pyx_getprop_4lupa_5_lupa_10LuaRuntime_lua_implementation, 0, (char *)"\n        The Lua implementation version string, e.g. \"Lua 5.3\" or \"LuaJIT 2.0.1\".\n        May execute Lua code.\n        ", 0},
  {0, 0, 0, 0, 0}
};

static PyTypeObject __pyx_type_4lupa_5_lupa_LuaRuntime = {
  PyVarObject_HEAD_INIT(0, 0)
  "lupa._lupa.LuaRuntime", /*tp_name*/
  sizeof(struct __pyx_obj_4lupa_5_lupa_LuaRuntime), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_4lupa_5_lupa_LuaRuntime, /*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
  0, /*tp_repr*/
  0, /*tp_as_number*/
  0, /*tp_as_sequence*/
  0, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*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|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  "The main entry point to the Lua runtime.\n\n    Available options:\n\n    * ``encoding``: the string encoding, defaulting to UTF-8.  If set\n      to ``None``, all string values will be returned as byte strings.\n      Otherwise, they will be decoded to unicode strings on the way\n      from Lua to Python and unicode strings will be encoded on the\n      way to Lua.  Note that ``str()`` calls on Lua objects will\n      always return a unicode object.\n\n    * ``source_encoding``: the encoding used for Lua code, defaulting to\n      the string encoding or UTF-8 if the string encoding is ``None``.\n\n    * ``attribute_filter``: filter function for attribute access\n      (get/set).  Must have the signature ``func(obj, attr_name,\n      is_setting)``, where ``is_setting`` is True when the attribute\n      is being set.  If provided, the function will be called for all\n      Python object attributes that are being accessed from Lua code.\n      Normally, it should return an attribute name that will then be\n      used for the lookup.  If it wants to prevent access, it should\n      raise an ``AttributeError``.  Note that Lua does not guarantee\n      that the names will be strings.  (New in Lupa 0.20)\n\n    * ``attribute_handlers``: like ``attribute_filter`` above, but\n      handles the getting/setting itself rather than giving hints\n      to the LuaRuntime.  This must be a 2-tuple, ``(getter, setter)``\n      where ``getter`` has the signature ``func(obj, attr_name)``\n      and either returns the value for ``obj.attr_name`` or raises an\n      ``AttributeError``  The function ``setter`` has the signature\n      ``func(obj, attr_name, value)`` and may raise an ``AttributeError``.\n      The return value of the setter is unused.  (New in Lupa 1.0)\n\n    * ``register_eval``: should Python's ``eval()`` function be available\n      to Lua code as ``python.eval()``?  Note that this does not remove it\n      from the builtins.  Use an ``attribute_filter`` function for t""hat.\n      (default: True)\n\n    * ``register_builtins``: should Python's builtins be available to Lua\n      code as ``python.builtins.*``?  Note that this does not prevent access\n      to the globals available as special Python function attributes, for\n      example.  Use an ``attribute_filter`` function for that.\n      (default: True, new in Lupa 1.2)\n\n    * ``unpack_returned_tuples``: should Python tuples be unpacked in Lua?\n      If ``py_fun()`` returns ``(1, 2, 3)``, then does ``a, b, c = py_fun()``\n      give ``a == 1 and b == 2 and c == 3`` or does it give\n      ``a == (1,2,3), b == nil, c == nil``?  ``unpack_returned_tuples=True``\n      gives the former.\n      (default: False, new in Lupa 0.21)\n\n    Example usage::\n\n      >>> from lupa import LuaRuntime\n      >>> lua = LuaRuntime()\n\n      >>> lua.eval('1+1')\n      2\n\n      >>> lua_func = lua.eval('function(f, n) return f(n) end')\n\n      >>> def py_add1(n): return n+1\n      >>> lua_func(py_add1, 2)\n      3\n    ", /*tp_doc*/
  __pyx_tp_traverse_4lupa_5_lupa_LuaRuntime, /*tp_traverse*/
  0, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  __pyx_methods_4lupa_5_lupa_LuaRuntime, /*tp_methods*/
  0, /*tp_members*/
  __pyx_getsets_4lupa_5_lupa_LuaRuntime, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  0, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_4lupa_5_lupa_LuaRuntime, /*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 struct __pyx_vtabstruct_4lupa_5_lupa__LuaObject __pyx_vtable_4lupa_5_lupa__LuaObject;

static struct __pyx_obj_4lupa_5_lupa__LuaObject *__pyx_freelist_4lupa_5_lupa__LuaObject[16];
static int __pyx_freecount_4lupa_5_lupa__LuaObject = 0;

static PyObject *__pyx_tp_new_4lupa_5_lupa__LuaObject(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
  struct __pyx_obj_4lupa_5_lupa__LuaObject *p;
  PyObject *o;
  if (CYTHON_COMPILING_IN_CPYTHON && likely((__pyx_freecount_4lupa_5_lupa__LuaObject > 0) & (t->tp_basicsize == sizeof(struct __pyx_obj_4lupa_5_lupa__LuaObject)) & ((t->tp_flags & (Py_TPFLAGS_IS_ABSTRACT | Py_TPFLAGS_HEAPTYPE)) == 0))) {
    o = (PyObject*)__pyx_freelist_4lupa_5_lupa__LuaObject[--__pyx_freecount_4lupa_5_lupa__LuaObject];
    memset(o, 0, sizeof(struct __pyx_obj_4lupa_5_lupa__LuaObject));
    (void) PyObject_INIT(o, t);
    PyObject_GC_Track(o);
  } else {
    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_4lupa_5_lupa__LuaObject *)o);
  p->__pyx_vtab = __pyx_vtabptr_4lupa_5_lupa__LuaObject;
  p->_runtime = ((struct __pyx_obj_4lupa_5_lupa_LuaRuntime *)Py_None); Py_INCREF(Py_None);
  return o;
}

static void __pyx_tp_dealloc_4lupa_5_lupa__LuaObject(PyObject *o) {
  struct __pyx_obj_4lupa_5_lupa__LuaObject *p = (struct __pyx_obj_4lupa_5_lupa__LuaObject *)o;
  #if CYTHON_USE_TP_FINALIZE
  if (unlikely(PyType_HasFeature(Py_TYPE(o), Py_TPFLAGS_HAVE_FINALIZE) && Py_TYPE(o)->tp_finalize) && !_PyGC_FINALIZED(o)) {
    if (PyObject_CallFinalizerFromDealloc(o)) return;
  }
  #endif
  PyObject_GC_UnTrack(o);
  {
    PyObject *etype, *eval, *etb;
    PyErr_Fetch(&etype, &eval, &etb);
    __Pyx_SET_REFCNT(o, Py_REFCNT(o) + 1);
    __pyx_pw_4lupa_5_lupa_10_LuaObject_3__dealloc__(o);
    __Pyx_SET_REFCNT(o, Py_REFCNT(o) - 1);
    PyErr_Restore(etype, eval, etb);
  }
  Py_CLEAR(p->_runtime);
  if (CYTHON_COMPILING_IN_CPYTHON && ((__pyx_freecount_4lupa_5_lupa__LuaObject < 16) & (Py_TYPE(o)->tp_basicsize == sizeof(struct __pyx_obj_4lupa_5_lupa__LuaObject)) & ((Py_TYPE(o)->tp_flags & (Py_TPFLAGS_IS_ABSTRACT | Py_TPFLAGS_HEAPTYPE)) == 0))) {
    __pyx_freelist_4lupa_5_lupa__LuaObject[__pyx_freecount_4lupa_5_lupa__LuaObject++] = ((struct __pyx_obj_4lupa_5_lupa__LuaObject *)o);
  } else {
    (*Py_TYPE(o)->tp_free)(o);
  }
}

static int __pyx_tp_traverse_4lupa_5_lupa__LuaObject(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_4lupa_5_lupa__LuaObject *p = (struct __pyx_obj_4lupa_5_lupa__LuaObject *)o;
  if (p->_runtime) {
    e = (*v)(((PyObject *)p->_runtime), a); if (e) return e;
  }
  return 0;
}
static PyObject *__pyx_sq_item_4lupa_5_lupa__LuaObject(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 PyObject *__pyx_tp_getattro_4lupa_5_lupa__LuaObject(PyObject *o, PyObject *n) {
  PyObject *v = __Pyx_PyObject_GenericGetAttr(o, n);
  if (!v && PyErr_ExceptionMatches(PyExc_AttributeError)) {
    PyErr_Clear();
    v = __pyx_pw_4lupa_5_lupa_10_LuaObject_17__getattr__(o, n);
  }
  return v;
}

static PyMethodDef __pyx_methods_4lupa_5_lupa__LuaObject[] = {
  {"__getattr__", (PyCFunction)__pyx_pw_4lupa_5_lupa_10_LuaObject_17__getattr__, METH_O|METH_COEXIST, 0},
  {"__reduce_cython__", (PyCFunction)__pyx_pw_4lupa_5_lupa_10_LuaObject_21__reduce_cython__, METH_NOARGS, __pyx_doc_4lupa_5_lupa_10_LuaObject_20__reduce_cython__},
  {"__setstate_cython__", (PyCFunction)__pyx_pw_4lupa_5_lupa_10_LuaObject_23__setstate_cython__, METH_O, __pyx_doc_4lupa_5_lupa_10_LuaObject_22__setstate_cython__},
  {0, 0, 0, 0}
};

static PyNumberMethods __pyx_tp_as_number__LuaObject = {
  0, /*nb_add*/
  0, /*nb_subtract*/
  0, /*nb_multiply*/
  #if PY_MAJOR_VERSION < 3 || (CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX < 0x03050000)
  0, /*nb_divide*/
  #endif
  0, /*nb_remainder*/
  0, /*nb_divmod*/
  0, /*nb_power*/
  0, /*nb_negative*/
  0, /*nb_positive*/
  0, /*nb_absolute*/
  __pyx_pw_4lupa_5_lupa_10_LuaObject_9__nonzero__, /*nb_nonzero*/
  0, /*nb_invert*/
  0, /*nb_lshift*/
  0, /*nb_rshift*/
  0, /*nb_and*/
  0, /*nb_xor*/
  0, /*nb_or*/
  #if PY_MAJOR_VERSION < 3 || (CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX < 0x03050000)
  0, /*nb_coerce*/
  #endif
  0, /*nb_int*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_long*/
  #else
  0, /*reserved*/
  #endif
  0, /*nb_float*/
  #if PY_MAJOR_VERSION < 3 || (CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX < 0x03050000)
  0, /*nb_oct*/
  #endif
  #if PY_MAJOR_VERSION < 3 || (CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX < 0x03050000)
  0, /*nb_hex*/
  #endif
  0, /*nb_inplace_add*/
  0, /*nb_inplace_subtract*/
  0, /*nb_inplace_multiply*/
  #if PY_MAJOR_VERSION < 3 || (CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX < 0x03050000)
  0, /*nb_inplace_divide*/
  #endif
  0, /*nb_inplace_remainder*/
  0, /*nb_inplace_power*/
  0, /*nb_inplace_lshift*/
  0, /*nb_inplace_rshift*/
  0, /*nb_inplace_and*/
  0, /*nb_inplace_xor*/
  0, /*nb_inplace_or*/
  0, /*nb_floor_divide*/
  0, /*nb_true_divide*/
  0, /*nb_inplace_floor_divide*/
  0, /*nb_inplace_true_divide*/
  0, /*nb_index*/
  #if PY_VERSION_HEX >= 0x03050000
  0, /*nb_matrix_multiply*/
  #endif
  #if PY_VERSION_HEX >= 0x03050000
  0, /*nb_inplace_matrix_multiply*/
  #endif
};

static PySequenceMethods __pyx_tp_as_sequence__LuaObject = {
  __pyx_pw_4lupa_5_lupa_10_LuaObject_7__len__, /*sq_length*/
  0, /*sq_concat*/
  0, /*sq_repeat*/
  __pyx_sq_item_4lupa_5_lupa__LuaObject, /*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__LuaObject = {
  __pyx_pw_4lupa_5_lupa_10_LuaObject_7__len__, /*mp_length*/
  __pyx_pw_4lupa_5_lupa_10_LuaObject_19__getitem__, /*mp_subscript*/
  0, /*mp_ass_subscript*/
};

static PyTypeObject __pyx_type_4lupa_5_lupa__LuaObject = {
  PyVarObject_HEAD_INIT(0, 0)
  "lupa._lupa._LuaObject", /*tp_name*/
  sizeof(struct __pyx_obj_4lupa_5_lupa__LuaObject), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_4lupa_5_lupa__LuaObject, /*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_4lupa_5_lupa_10_LuaObject_13__repr__, /*tp_repr*/
  &__pyx_tp_as_number__LuaObject, /*tp_as_number*/
  &__pyx_tp_as_sequence__LuaObject, /*tp_as_sequence*/
  &__pyx_tp_as_mapping__LuaObject, /*tp_as_mapping*/
  0, /*tp_hash*/
  __pyx_pw_4lupa_5_lupa_10_LuaObject_5__call__, /*tp_call*/
  __pyx_pw_4lupa_5_lupa_10_LuaObject_15__str__, /*tp_str*/
  __pyx_tp_getattro_4lupa_5_lupa__LuaObject, /*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|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  "_LuaObject()\nA wrapper around a Lua object such as a table or function.\n    ", /*tp_doc*/
  __pyx_tp_traverse_4lupa_5_lupa__LuaObject, /*tp_traverse*/
  0, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  __pyx_pw_4lupa_5_lupa_10_LuaObject_11__iter__, /*tp_iter*/
  0, /*tp_iternext*/
  __pyx_methods_4lupa_5_lupa__LuaObject, /*tp_methods*/
  0, /*tp_members*/
  0, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  __pyx_pw_4lupa_5_lupa_10_LuaObject_1__init__, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_4lupa_5_lupa__LuaObject, /*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 struct __pyx_vtabstruct_4lupa_5_lupa__LuaTable __pyx_vtable_4lupa_5_lupa__LuaTable;

static PyObject *__pyx_tp_new_4lupa_5_lupa__LuaTable(PyTypeObject *t, PyObject *a, PyObject *k) {
  struct __pyx_obj_4lupa_5_lupa__LuaTable *p;
  PyObject *o = __pyx_tp_new_4lupa_5_lupa__LuaObject(t, a, k);
  if (unlikely(!o)) return 0;
  p = ((struct __pyx_obj_4lupa_5_lupa__LuaTable *)o);
  p->__pyx_base.__pyx_vtab = (struct __pyx_vtabstruct_4lupa_5_lupa__LuaObject*)__pyx_vtabptr_4lupa_5_lupa__LuaTable;
  return o;
}

static int __pyx_mp_ass_subscript_4lupa_5_lupa__LuaTable(PyObject *o, PyObject *i, PyObject *v) {
  if (v) {
    return __pyx_pw_4lupa_5_lupa_9_LuaTable_11__setitem__(o, i, v);
  }
  else {
    return __pyx_pw_4lupa_5_lupa_9_LuaTable_15__delitem__(o, i);
  }
}

static int __pyx_tp_setattro_4lupa_5_lupa__LuaTable(PyObject *o, PyObject *n, PyObject *v) {
  if (v) {
    return __pyx_pw_4lupa_5_lupa_9_LuaTable_9__setattr__(o, n, v);
  }
  else {
    return __pyx_pw_4lupa_5_lupa_9_LuaTable_13__delattr__(o, n);
  }
}

static PyMethodDef __pyx_methods_4lupa_5_lupa__LuaTable[] = {
  {"keys", (PyCFunction)__pyx_pw_4lupa_5_lupa_9_LuaTable_3keys, METH_NOARGS, __pyx_doc_4lupa_5_lupa_9_LuaTable_2keys},
  {"values", (PyCFunction)__pyx_pw_4lupa_5_lupa_9_LuaTable_5values, METH_NOARGS, __pyx_doc_4lupa_5_lupa_9_LuaTable_4values},
  {"items", (PyCFunction)__pyx_pw_4lupa_5_lupa_9_LuaTable_7items, METH_NOARGS, __pyx_doc_4lupa_5_lupa_9_LuaTable_6items},
  {"__reduce_cython__", (PyCFunction)__pyx_pw_4lupa_5_lupa_9_LuaTable_17__reduce_cython__, METH_NOARGS, __pyx_doc_4lupa_5_lupa_9_LuaTable_16__reduce_cython__},
  {"__setstate_cython__", (PyCFunction)__pyx_pw_4lupa_5_lupa_9_LuaTable_19__setstate_cython__, METH_O, __pyx_doc_4lupa_5_lupa_9_LuaTable_18__setstate_cython__},
  {0, 0, 0, 0}
};

static PyMappingMethods __pyx_tp_as_mapping__LuaTable = {
  #if CYTHON_COMPILING_IN_PYPY
  __pyx_pw_4lupa_5_lupa_10_LuaObject_7__len__, /*mp_length*/
  #else
  0, /*mp_length*/
  #endif
  #if CYTHON_COMPILING_IN_PYPY
  __pyx_pw_4lupa_5_lupa_10_LuaObject_19__getitem__, /*mp_subscript*/
  #else
  0, /*mp_subscript*/
  #endif
  __pyx_mp_ass_subscript_4lupa_5_lupa__LuaTable, /*mp_ass_subscript*/
};

static PyTypeObject __pyx_type_4lupa_5_lupa__LuaTable = {
  PyVarObject_HEAD_INIT(0, 0)
  "lupa._lupa._LuaTable", /*tp_name*/
  sizeof(struct __pyx_obj_4lupa_5_lupa__LuaTable), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_4lupa_5_lupa__LuaObject, /*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
  #if CYTHON_COMPILING_IN_PYPY
  __pyx_pw_4lupa_5_lupa_10_LuaObject_13__repr__, /*tp_repr*/
  #else
  0, /*tp_repr*/
  #endif
  0, /*tp_as_number*/
  0, /*tp_as_sequence*/
  &__pyx_tp_as_mapping__LuaTable, /*tp_as_mapping*/
  0, /*tp_hash*/
  #if CYTHON_COMPILING_IN_PYPY
  __pyx_pw_4lupa_5_lupa_10_LuaObject_5__call__, /*tp_call*/
  #else
  0, /*tp_call*/
  #endif
  #if CYTHON_COMPILING_IN_PYPY
  __pyx_pw_4lupa_5_lupa_10_LuaObject_15__str__, /*tp_str*/
  #else
  0, /*tp_str*/
  #endif
  0, /*tp_getattro*/
  __pyx_tp_setattro_4lupa_5_lupa__LuaTable, /*tp_setattro*/
  0, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  0, /*tp_doc*/
  __pyx_tp_traverse_4lupa_5_lupa__LuaObject, /*tp_traverse*/
  0, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  __pyx_pw_4lupa_5_lupa_9_LuaTable_1__iter__, /*tp_iter*/
  0, /*tp_iternext*/
  __pyx_methods_4lupa_5_lupa__LuaTable, /*tp_methods*/
  0, /*tp_members*/
  0, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  #if CYTHON_COMPILING_IN_PYPY
  __pyx_pw_4lupa_5_lupa_10_LuaObject_1__init__, /*tp_init*/
  #else
  0, /*tp_init*/
  #endif
  0, /*tp_alloc*/
  __pyx_tp_new_4lupa_5_lupa__LuaTable, /*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 struct __pyx_vtabstruct_4lupa_5_lupa__LuaFunction __pyx_vtable_4lupa_5_lupa__LuaFunction;

static PyObject *__pyx_tp_new_4lupa_5_lupa__LuaFunction(PyTypeObject *t, PyObject *a, PyObject *k) {
  struct __pyx_obj_4lupa_5_lupa__LuaFunction *p;
  PyObject *o = __pyx_tp_new_4lupa_5_lupa__LuaObject(t, a, k);
  if (unlikely(!o)) return 0;
  p = ((struct __pyx_obj_4lupa_5_lupa__LuaFunction *)o);
  p->__pyx_base.__pyx_vtab = (struct __pyx_vtabstruct_4lupa_5_lupa__LuaObject*)__pyx_vtabptr_4lupa_5_lupa__LuaFunction;
  return o;
}

static PyMethodDef __pyx_methods_4lupa_5_lupa__LuaFunction[] = {
  {"coroutine", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_4lupa_5_lupa_12_LuaFunction_1coroutine, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4lupa_5_lupa_12_LuaFunction_coroutine},
  {"__reduce_cython__", (PyCFunction)__pyx_pw_4lupa_5_lupa_12_LuaFunction_3__reduce_cython__, METH_NOARGS, __pyx_doc_4lupa_5_lupa_12_LuaFunction_2__reduce_cython__},
  {"__setstate_cython__", (PyCFunction)__pyx_pw_4lupa_5_lupa_12_LuaFunction_5__setstate_cython__, METH_O, __pyx_doc_4lupa_5_lupa_12_LuaFunction_4__setstate_cython__},
  {0, 0, 0, 0}
};

static PyTypeObject __pyx_type_4lupa_5_lupa__LuaFunction = {
  PyVarObject_HEAD_INIT(0, 0)
  "lupa._lupa._LuaFunction", /*tp_name*/
  sizeof(struct __pyx_obj_4lupa_5_lupa__LuaFunction), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_4lupa_5_lupa__LuaObject, /*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
  #if CYTHON_COMPILING_IN_PYPY
  __pyx_pw_4lupa_5_lupa_10_LuaObject_13__repr__, /*tp_repr*/
  #else
  0, /*tp_repr*/
  #endif
  0, /*tp_as_number*/
  0, /*tp_as_sequence*/
  0, /*tp_as_mapping*/
  0, /*tp_hash*/
  #if CYTHON_COMPILING_IN_PYPY
  __pyx_pw_4lupa_5_lupa_10_LuaObject_5__call__, /*tp_call*/
  #else
  0, /*tp_call*/
  #endif
  #if CYTHON_COMPILING_IN_PYPY
  __pyx_pw_4lupa_5_lupa_10_LuaObject_15__str__, /*tp_str*/
  #else
  0, /*tp_str*/
  #endif
  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|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  "A Lua function (which may become a coroutine).\n    ", /*tp_doc*/
  __pyx_tp_traverse_4lupa_5_lupa__LuaObject, /*tp_traverse*/
  0, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  #if CYTHON_COMPILING_IN_PYPY
  __pyx_pw_4lupa_5_lupa_10_LuaObject_11__iter__, /*tp_iter*/
  #else
  0, /*tp_iter*/
  #endif
  0, /*tp_iternext*/
  __pyx_methods_4lupa_5_lupa__LuaFunction, /*tp_methods*/
  0, /*tp_members*/
  0, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  #if CYTHON_COMPILING_IN_PYPY
  __pyx_pw_4lupa_5_lupa_10_LuaObject_1__init__, /*tp_init*/
  #else
  0, /*tp_init*/
  #endif
  0, /*tp_alloc*/
  __pyx_tp_new_4lupa_5_lupa__LuaFunction, /*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 struct __pyx_vtabstruct_4lupa_5_lupa__LuaCoroutineFunction __pyx_vtable_4lupa_5_lupa__LuaCoroutineFunction;

static PyObject *__pyx_tp_new_4lupa_5_lupa__LuaCoroutineFunction(PyTypeObject *t, PyObject *a, PyObject *k) {
  struct __pyx_obj_4lupa_5_lupa__LuaCoroutineFunction *p;
  PyObject *o = __pyx_tp_new_4lupa_5_lupa__LuaFunction(t, a, k);
  if (unlikely(!o)) return 0;
  p = ((struct __pyx_obj_4lupa_5_lupa__LuaCoroutineFunction *)o);
  p->__pyx_base.__pyx_base.__pyx_vtab = (struct __pyx_vtabstruct_4lupa_5_lupa__LuaObject*)__pyx_vtabptr_4lupa_5_lupa__LuaCoroutineFunction;
  return o;
}

static PyMethodDef __pyx_methods_4lupa_5_lupa__LuaCoroutineFunction[] = {
  {"__reduce_cython__", (PyCFunction)__pyx_pw_4lupa_5_lupa_21_LuaCoroutineFunction_3__reduce_cython__, METH_NOARGS, __pyx_doc_4lupa_5_lupa_21_LuaCoroutineFunction_2__reduce_cython__},
  {"__setstate_cython__", (PyCFunction)__pyx_pw_4lupa_5_lupa_21_LuaCoroutineFunction_5__setstate_cython__, METH_O, __pyx_doc_4lupa_5_lupa_21_LuaCoroutineFunction_4__setstate_cython__},
  {0, 0, 0, 0}
};

static PyTypeObject __pyx_type_4lupa_5_lupa__LuaCoroutineFunction = {
  PyVarObject_HEAD_INIT(0, 0)
  "lupa._lupa._LuaCoroutineFunction", /*tp_name*/
  sizeof(struct __pyx_obj_4lupa_5_lupa__LuaCoroutineFunction), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_4lupa_5_lupa__LuaObject, /*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
  #if CYTHON_COMPILING_IN_PYPY
  __pyx_pw_4lupa_5_lupa_10_LuaObject_13__repr__, /*tp_repr*/
  #else
  0, /*tp_repr*/
  #endif
  0, /*tp_as_number*/
  0, /*tp_as_sequence*/
  0, /*tp_as_mapping*/
  0, /*tp_hash*/
  __pyx_pw_4lupa_5_lupa_21_LuaCoroutineFunction_1__call__, /*tp_call*/
  #if CYTHON_COMPILING_IN_PYPY
  __pyx_pw_4lupa_5_lupa_10_LuaObject_15__str__, /*tp_str*/
  #else
  0, /*tp_str*/
  #endif
  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_HAVE_GC, /*tp_flags*/
  "A function that returns a new coroutine when called.\n    ", /*tp_doc*/
  __pyx_tp_traverse_4lupa_5_lupa__LuaObject, /*tp_traverse*/
  0, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  #if CYTHON_COMPILING_IN_PYPY
  __pyx_pw_4lupa_5_lupa_10_LuaObject_11__iter__, /*tp_iter*/
  #else
  0, /*tp_iter*/
  #endif
  0, /*tp_iternext*/
  __pyx_methods_4lupa_5_lupa__LuaCoroutineFunction, /*tp_methods*/
  0, /*tp_members*/
  0, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  #if CYTHON_COMPILING_IN_PYPY
  __pyx_pw_4lupa_5_lupa_10_LuaObject_1__init__, /*tp_init*/
  #else
  0, /*tp_init*/
  #endif
  0, /*tp_alloc*/
  __pyx_tp_new_4lupa_5_lupa__LuaCoroutineFunction, /*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 struct __pyx_vtabstruct_4lupa_5_lupa__LuaThread __pyx_vtable_4lupa_5_lupa__LuaThread;

static PyObject *__pyx_tp_new_4lupa_5_lupa__LuaThread(PyTypeObject *t, PyObject *a, PyObject *k) {
  struct __pyx_obj_4lupa_5_lupa__LuaThread *p;
  PyObject *o = __pyx_tp_new_4lupa_5_lupa__LuaObject(t, a, k);
  if (unlikely(!o)) return 0;
  p = ((struct __pyx_obj_4lupa_5_lupa__LuaThread *)o);
  p->__pyx_base.__pyx_vtab = (struct __pyx_vtabstruct_4lupa_5_lupa__LuaObject*)__pyx_vtabptr_4lupa_5_lupa__LuaThread;
  p->_arguments = ((PyObject*)Py_None); Py_INCREF(Py_None);
  return o;
}

static void __pyx_tp_dealloc_4lupa_5_lupa__LuaThread(PyObject *o) {
  struct __pyx_obj_4lupa_5_lupa__LuaThread *p = (struct __pyx_obj_4lupa_5_lupa__LuaThread *)o;
  PyObject_GC_UnTrack(o);
  Py_CLEAR(p->_arguments);
  PyObject_GC_Track(o);
  __pyx_tp_dealloc_4lupa_5_lupa__LuaObject(o);
}

static int __pyx_tp_traverse_4lupa_5_lupa__LuaThread(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_4lupa_5_lupa__LuaThread *p = (struct __pyx_obj_4lupa_5_lupa__LuaThread *)o;
  e = __pyx_tp_traverse_4lupa_5_lupa__LuaObject(o, v, a); if (e) return e;
  if (p->_arguments) {
    e = (*v)(p->_arguments, a); if (e) return e;
  }
  return 0;
}

static PyObject *__pyx_specialmethod___pyx_pw_4lupa_5_lupa_10_LuaThread_3__next__(PyObject *self, CYTHON_UNUSED PyObject *arg) {return __pyx_pw_4lupa_5_lupa_10_LuaThread_3__next__(self);}

static PyMethodDef __pyx_methods_4lupa_5_lupa__LuaThread[] = {
  {"__next__", (PyCFunction)__pyx_specialmethod___pyx_pw_4lupa_5_lupa_10_LuaThread_3__next__, METH_NOARGS|METH_COEXIST, 0},
  {"send", (PyCFunction)__pyx_pw_4lupa_5_lupa_10_LuaThread_5send, METH_O, __pyx_doc_4lupa_5_lupa_10_LuaThread_4send},
  {"__reduce_cython__", (PyCFunction)__pyx_pw_4lupa_5_lupa_10_LuaThread_9__reduce_cython__, METH_NOARGS, __pyx_doc_4lupa_5_lupa_10_LuaThread_8__reduce_cython__},
  {"__setstate_cython__", (PyCFunction)__pyx_pw_4lupa_5_lupa_10_LuaThread_11__setstate_cython__, METH_O, __pyx_doc_4lupa_5_lupa_10_LuaThread_10__setstate_cython__},
  {0, 0, 0, 0}
};

static PyNumberMethods __pyx_tp_as_number__LuaThread = {
  0, /*nb_add*/
  0, /*nb_subtract*/
  0, /*nb_multiply*/
  #if PY_MAJOR_VERSION < 3 || (CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX < 0x03050000)
  0, /*nb_divide*/
  #endif
  0, /*nb_remainder*/
  0, /*nb_divmod*/
  0, /*nb_power*/
  0, /*nb_negative*/
  0, /*nb_positive*/
  0, /*nb_absolute*/
  __pyx_pw_4lupa_5_lupa_10_LuaThread_7__bool__, /*nb_nonzero*/
  0, /*nb_invert*/
  0, /*nb_lshift*/
  0, /*nb_rshift*/
  0, /*nb_and*/
  0, /*nb_xor*/
  0, /*nb_or*/
  #if PY_MAJOR_VERSION < 3 || (CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX < 0x03050000)
  0, /*nb_coerce*/
  #endif
  0, /*nb_int*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_long*/
  #else
  0, /*reserved*/
  #endif
  0, /*nb_float*/
  #if PY_MAJOR_VERSION < 3 || (CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX < 0x03050000)
  0, /*nb_oct*/
  #endif
  #if PY_MAJOR_VERSION < 3 || (CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX < 0x03050000)
  0, /*nb_hex*/
  #endif
  0, /*nb_inplace_add*/
  0, /*nb_inplace_subtract*/
  0, /*nb_inplace_multiply*/
  #if PY_MAJOR_VERSION < 3 || (CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX < 0x03050000)
  0, /*nb_inplace_divide*/
  #endif
  0, /*nb_inplace_remainder*/
  0, /*nb_inplace_power*/
  0, /*nb_inplace_lshift*/
  0, /*nb_inplace_rshift*/
  0, /*nb_inplace_and*/
  0, /*nb_inplace_xor*/
  0, /*nb_inplace_or*/
  0, /*nb_floor_divide*/
  0, /*nb_true_divide*/
  0, /*nb_inplace_floor_divide*/
  0, /*nb_inplace_true_divide*/
  0, /*nb_index*/
  #if PY_VERSION_HEX >= 0x03050000
  0, /*nb_matrix_multiply*/
  #endif
  #if PY_VERSION_HEX >= 0x03050000
  0, /*nb_inplace_matrix_multiply*/
  #endif
};

static PyTypeObject __pyx_type_4lupa_5_lupa__LuaThread = {
  PyVarObject_HEAD_INIT(0, 0)
  "lupa._lupa._LuaThread", /*tp_name*/
  sizeof(struct __pyx_obj_4lupa_5_lupa__LuaThread), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_4lupa_5_lupa__LuaThread, /*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
  #if CYTHON_COMPILING_IN_PYPY
  __pyx_pw_4lupa_5_lupa_10_LuaObject_13__repr__, /*tp_repr*/
  #else
  0, /*tp_repr*/
  #endif
  &__pyx_tp_as_number__LuaThread, /*tp_as_number*/
  0, /*tp_as_sequence*/
  0, /*tp_as_mapping*/
  0, /*tp_hash*/
  #if CYTHON_COMPILING_IN_PYPY
  __pyx_pw_4lupa_5_lupa_10_LuaObject_5__call__, /*tp_call*/
  #else
  0, /*tp_call*/
  #endif
  #if CYTHON_COMPILING_IN_PYPY
  __pyx_pw_4lupa_5_lupa_10_LuaObject_15__str__, /*tp_str*/
  #else
  0, /*tp_str*/
  #endif
  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_HAVE_GC, /*tp_flags*/
  "A Lua thread (coroutine).\n    ", /*tp_doc*/
  __pyx_tp_traverse_4lupa_5_lupa__LuaThread, /*tp_traverse*/
  0, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  __pyx_pw_4lupa_5_lupa_10_LuaThread_1__iter__, /*tp_iter*/
  __pyx_pw_4lupa_5_lupa_10_LuaThread_3__next__, /*tp_iternext*/
  __pyx_methods_4lupa_5_lupa__LuaThread, /*tp_methods*/
  0, /*tp_members*/
  0, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  #if CYTHON_COMPILING_IN_PYPY
  __pyx_pw_4lupa_5_lupa_10_LuaObject_1__init__, /*tp_init*/
  #else
  0, /*tp_init*/
  #endif
  0, /*tp_alloc*/
  __pyx_tp_new_4lupa_5_lupa__LuaThread, /*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 PyObject *__pyx_tp_new_4lupa_5_lupa__LuaIter(PyTypeObject *t, PyObject *a, PyObject *k) {
  struct __pyx_obj_4lupa_5_lupa__LuaIter *p;
  PyObject *o;
  o = (*t->tp_alloc)(t, 0);
  if (unlikely(!o)) return 0;
  p = ((struct __pyx_obj_4lupa_5_lupa__LuaIter *)o);
  p->_runtime = ((struct __pyx_obj_4lupa_5_lupa_LuaRuntime *)Py_None); Py_INCREF(Py_None);
  p->_obj = ((struct __pyx_obj_4lupa_5_lupa__LuaObject *)Py_None); Py_INCREF(Py_None);
  if (unlikely(__pyx_pw_4lupa_5_lupa_8_LuaIter_1__cinit__(o, a, k) < 0)) goto bad;
  return o;
  bad:
  Py_DECREF(o); o = 0;
  return NULL;
}

static void __pyx_tp_dealloc_4lupa_5_lupa__LuaIter(PyObject *o) {
  struct __pyx_obj_4lupa_5_lupa__LuaIter *p = (struct __pyx_obj_4lupa_5_lupa__LuaIter *)o;
  PyObject_GC_UnTrack(o);
  {
    PyObject *etype, *eval, *etb;
    PyErr_Fetch(&etype, &eval, &etb);
    __Pyx_SET_REFCNT(o, Py_REFCNT(o) + 1);
    __pyx_pw_4lupa_5_lupa_8_LuaIter_3__dealloc__(o);
    __Pyx_SET_REFCNT(o, Py_REFCNT(o) - 1);
    PyErr_Restore(etype, eval, etb);
  }
  Py_CLEAR(p->_runtime);
  Py_CLEAR(p->_obj);
  (*Py_TYPE(o)->tp_free)(o);
}

static int __pyx_tp_traverse_4lupa_5_lupa__LuaIter(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_4lupa_5_lupa__LuaIter *p = (struct __pyx_obj_4lupa_5_lupa__LuaIter *)o;
  if (p->_runtime) {
    e = (*v)(((PyObject *)p->_runtime), a); if (e) return e;
  }
  if (p->_obj) {
    e = (*v)(((PyObject *)p->_obj), a); if (e) return e;
  }
  return 0;
}

static PyObject *__pyx_specialmethod___pyx_pw_4lupa_5_lupa_8_LuaIter_9__next__(PyObject *self, CYTHON_UNUSED PyObject *arg) {return __pyx_pw_4lupa_5_lupa_8_LuaIter_9__next__(self);}

static PyMethodDef __pyx_methods_4lupa_5_lupa__LuaIter[] = {
  {"__next__", (PyCFunction)__pyx_specialmethod___pyx_pw_4lupa_5_lupa_8_LuaIter_9__next__, METH_NOARGS|METH_COEXIST, 0},
  {"__reduce_cython__", (PyCFunction)__pyx_pw_4lupa_5_lupa_8_LuaIter_11__reduce_cython__, METH_NOARGS, __pyx_doc_4lupa_5_lupa_8_LuaIter_10__reduce_cython__},
  {"__setstate_cython__", (PyCFunction)__pyx_pw_4lupa_5_lupa_8_LuaIter_13__setstate_cython__, METH_O, __pyx_doc_4lupa_5_lupa_8_LuaIter_12__setstate_cython__},
  {0, 0, 0, 0}
};

static PyTypeObject __pyx_type_4lupa_5_lupa__LuaIter = {
  PyVarObject_HEAD_INIT(0, 0)
  "lupa._lupa._LuaIter", /*tp_name*/
  sizeof(struct __pyx_obj_4lupa_5_lupa__LuaIter), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_4lupa_5_lupa__LuaIter, /*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_4lupa_5_lupa_8_LuaIter_5__repr__, /*tp_repr*/
  0, /*tp_as_number*/
  0, /*tp_as_sequence*/
  0, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*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_HAVE_GC, /*tp_flags*/
  0, /*tp_doc*/
  __pyx_tp_traverse_4lupa_5_lupa__LuaIter, /*tp_traverse*/
  0, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  __pyx_pw_4lupa_5_lupa_8_LuaIter_7__iter__, /*tp_iter*/
  __pyx_pw_4lupa_5_lupa_8_LuaIter_9__next__, /*tp_iternext*/
  __pyx_methods_4lupa_5_lupa__LuaIter, /*tp_methods*/
  0, /*tp_members*/
  0, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  0, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_4lupa_5_lupa__LuaIter, /*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 struct __pyx_obj_4lupa_5_lupa__PyProtocolWrapper *__pyx_freelist_4lupa_5_lupa__PyProtocolWrapper[8];
static int __pyx_freecount_4lupa_5_lupa__PyProtocolWrapper = 0;

static PyObject *__pyx_tp_new_4lupa_5_lupa__PyProtocolWrapper(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
  struct __pyx_obj_4lupa_5_lupa__PyProtocolWrapper *p;
  PyObject *o;
  if (CYTHON_COMPILING_IN_CPYTHON && likely((__pyx_freecount_4lupa_5_lupa__PyProtocolWrapper > 0) & (t->tp_basicsize == sizeof(struct __pyx_obj_4lupa_5_lupa__PyProtocolWrapper)))) {
    o = (PyObject*)__pyx_freelist_4lupa_5_lupa__PyProtocolWrapper[--__pyx_freecount_4lupa_5_lupa__PyProtocolWrapper];
    memset(o, 0, sizeof(struct __pyx_obj_4lupa_5_lupa__PyProtocolWrapper));
    (void) PyObject_INIT(o, t);
    PyObject_GC_Track(o);
  } else {
    o = (*t->tp_alloc)(t, 0);
    if (unlikely(!o)) return 0;
  }
  p = ((struct __pyx_obj_4lupa_5_lupa__PyProtocolWrapper *)o);
  p->_obj = Py_None; Py_INCREF(Py_None);
  if (unlikely(__pyx_pw_4lupa_5_lupa_18_PyProtocolWrapper_1__cinit__(o, __pyx_empty_tuple, NULL) < 0)) goto bad;
  return o;
  bad:
  Py_DECREF(o); o = 0;
  return NULL;
}

static void __pyx_tp_dealloc_4lupa_5_lupa__PyProtocolWrapper(PyObject *o) {
  struct __pyx_obj_4lupa_5_lupa__PyProtocolWrapper *p = (struct __pyx_obj_4lupa_5_lupa__PyProtocolWrapper *)o;
  PyObject_GC_UnTrack(o);
  Py_CLEAR(p->_obj);
  if (CYTHON_COMPILING_IN_CPYTHON && ((__pyx_freecount_4lupa_5_lupa__PyProtocolWrapper < 8) & (Py_TYPE(o)->tp_basicsize == sizeof(struct __pyx_obj_4lupa_5_lupa__PyProtocolWrapper)))) {
    __pyx_freelist_4lupa_5_lupa__PyProtocolWrapper[__pyx_freecount_4lupa_5_lupa__PyProtocolWrapper++] = ((struct __pyx_obj_4lupa_5_lupa__PyProtocolWrapper *)o);
  } else {
    (*Py_TYPE(o)->tp_free)(o);
  }
}

static int __pyx_tp_traverse_4lupa_5_lupa__PyProtocolWrapper(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_4lupa_5_lupa__PyProtocolWrapper *p = (struct __pyx_obj_4lupa_5_lupa__PyProtocolWrapper *)o;
  if (p->_obj) {
    e = (*v)(p->_obj, a); if (e) return e;
  }
  return 0;
}

static int __pyx_tp_clear_4lupa_5_lupa__PyProtocolWrapper(PyObject *o) {
  PyObject* tmp;
  struct __pyx_obj_4lupa_5_lupa__PyProtocolWrapper *p = (struct __pyx_obj_4lupa_5_lupa__PyProtocolWrapper *)o;
  tmp = ((PyObject*)p->_obj);
  p->_obj = Py_None; Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  return 0;
}

static PyMethodDef __pyx_methods_4lupa_5_lupa__PyProtocolWrapper[] = {
  {"__reduce_cython__", (PyCFunction)__pyx_pw_4lupa_5_lupa_18_PyProtocolWrapper_5__reduce_cython__, METH_NOARGS, __pyx_doc_4lupa_5_lupa_18_PyProtocolWrapper_4__reduce_cython__},
  {"__setstate_cython__", (PyCFunction)__pyx_pw_4lupa_5_lupa_18_PyProtocolWrapper_7__setstate_cython__, METH_O, __pyx_doc_4lupa_5_lupa_18_PyProtocolWrapper_6__setstate_cython__},
  {0, 0, 0, 0}
};

static PyTypeObject __pyx_type_4lupa_5_lupa__PyProtocolWrapper = {
  PyVarObject_HEAD_INIT(0, 0)
  "lupa._lupa._PyProtocolWrapper", /*tp_name*/
  sizeof(struct __pyx_obj_4lupa_5_lupa__PyProtocolWrapper), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_4lupa_5_lupa__PyProtocolWrapper, /*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
  0, /*tp_repr*/
  0, /*tp_as_number*/
  0, /*tp_as_sequence*/
  0, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*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_HAVE_GC, /*tp_flags*/
  "_PyProtocolWrapper()", /*tp_doc*/
  __pyx_tp_traverse_4lupa_5_lupa__PyProtocolWrapper, /*tp_traverse*/
  __pyx_tp_clear_4lupa_5_lupa__PyProtocolWrapper, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  __pyx_methods_4lupa_5_lupa__PyProtocolWrapper, /*tp_methods*/
  0, /*tp_members*/
  0, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  __pyx_pw_4lupa_5_lupa_18_PyProtocolWrapper_3__init__, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_4lupa_5_lupa__PyProtocolWrapper, /*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 struct __pyx_obj_4lupa_5_lupa___pyx_scope_struct__unpacks_lua_table *__pyx_freelist_4lupa_5_lupa___pyx_scope_struct__unpacks_lua_table[8];
static int __pyx_freecount_4lupa_5_lupa___pyx_scope_struct__unpacks_lua_table = 0;

static PyObject *__pyx_tp_new_4lupa_5_lupa___pyx_scope_struct__unpacks_lua_table(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
  PyObject *o;
  if (CYTHON_COMPILING_IN_CPYTHON && likely((__pyx_freecount_4lupa_5_lupa___pyx_scope_struct__unpacks_lua_table > 0) & (t->tp_basicsize == sizeof(struct __pyx_obj_4lupa_5_lupa___pyx_scope_struct__unpacks_lua_table)))) {
    o = (PyObject*)__pyx_freelist_4lupa_5_lupa___pyx_scope_struct__unpacks_lua_table[--__pyx_freecount_4lupa_5_lupa___pyx_scope_struct__unpacks_lua_table];
    memset(o, 0, sizeof(struct __pyx_obj_4lupa_5_lupa___pyx_scope_struct__unpacks_lua_table));
    (void) PyObject_INIT(o, t);
    PyObject_GC_Track(o);
  } else {
    o = (*t->tp_alloc)(t, 0);
    if (unlikely(!o)) return 0;
  }
  return o;
}

static void __pyx_tp_dealloc_4lupa_5_lupa___pyx_scope_struct__unpacks_lua_table(PyObject *o) {
  struct __pyx_obj_4lupa_5_lupa___pyx_scope_struct__unpacks_lua_table *p = (struct __pyx_obj_4lupa_5_lupa___pyx_scope_struct__unpacks_lua_table *)o;
  PyObject_GC_UnTrack(o);
  Py_CLEAR(p->__pyx_v_func);
  if (CYTHON_COMPILING_IN_CPYTHON && ((__pyx_freecount_4lupa_5_lupa___pyx_scope_struct__unpacks_lua_table < 8) & (Py_TYPE(o)->tp_basicsize == sizeof(struct __pyx_obj_4lupa_5_lupa___pyx_scope_struct__unpacks_lua_table)))) {
    __pyx_freelist_4lupa_5_lupa___pyx_scope_struct__unpacks_lua_table[__pyx_freecount_4lupa_5_lupa___pyx_scope_struct__unpacks_lua_table++] = ((struct __pyx_obj_4lupa_5_lupa___pyx_scope_struct__unpacks_lua_table *)o);
  } else {
    (*Py_TYPE(o)->tp_free)(o);
  }
}

static int __pyx_tp_traverse_4lupa_5_lupa___pyx_scope_struct__unpacks_lua_table(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_4lupa_5_lupa___pyx_scope_struct__unpacks_lua_table *p = (struct __pyx_obj_4lupa_5_lupa___pyx_scope_struct__unpacks_lua_table *)o;
  if (p->__pyx_v_func) {
    e = (*v)(p->__pyx_v_func, a); if (e) return e;
  }
  return 0;
}

static int __pyx_tp_clear_4lupa_5_lupa___pyx_scope_struct__unpacks_lua_table(PyObject *o) {
  PyObject* tmp;
  struct __pyx_obj_4lupa_5_lupa___pyx_scope_struct__unpacks_lua_table *p = (struct __pyx_obj_4lupa_5_lupa___pyx_scope_struct__unpacks_lua_table *)o;
  tmp = ((PyObject*)p->__pyx_v_func);
  p->__pyx_v_func = Py_None; Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  return 0;
}

static PyTypeObject __pyx_type_4lupa_5_lupa___pyx_scope_struct__unpacks_lua_table = {
  PyVarObject_HEAD_INIT(0, 0)
  "lupa._lupa.__pyx_scope_struct__unpacks_lua_table", /*tp_name*/
  sizeof(struct __pyx_obj_4lupa_5_lupa___pyx_scope_struct__unpacks_lua_table), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_4lupa_5_lupa___pyx_scope_struct__unpacks_lua_table, /*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
  0, /*tp_repr*/
  0, /*tp_as_number*/
  0, /*tp_as_sequence*/
  0, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*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_HAVE_GC, /*tp_flags*/
  0, /*tp_doc*/
  __pyx_tp_traverse_4lupa_5_lupa___pyx_scope_struct__unpacks_lua_table, /*tp_traverse*/
  __pyx_tp_clear_4lupa_5_lupa___pyx_scope_struct__unpacks_lua_table, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  0, /*tp_methods*/
  0, /*tp_members*/
  0, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  0, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_4lupa_5_lupa___pyx_scope_struct__unpacks_lua_table, /*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 struct __pyx_obj_4lupa_5_lupa___pyx_scope_struct_1_unpacks_lua_table_method *__pyx_freelist_4lupa_5_lupa___pyx_scope_struct_1_unpacks_lua_table_method[8];
static int __pyx_freecount_4lupa_5_lupa___pyx_scope_struct_1_unpacks_lua_table_method = 0;

static PyObject *__pyx_tp_new_4lupa_5_lupa___pyx_scope_struct_1_unpacks_lua_table_method(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
  PyObject *o;
  if (CYTHON_COMPILING_IN_CPYTHON && likely((__pyx_freecount_4lupa_5_lupa___pyx_scope_struct_1_unpacks_lua_table_method > 0) & (t->tp_basicsize == sizeof(struct __pyx_obj_4lupa_5_lupa___pyx_scope_struct_1_unpacks_lua_table_method)))) {
    o = (PyObject*)__pyx_freelist_4lupa_5_lupa___pyx_scope_struct_1_unpacks_lua_table_method[--__pyx_freecount_4lupa_5_lupa___pyx_scope_struct_1_unpacks_lua_table_method];
    memset(o, 0, sizeof(struct __pyx_obj_4lupa_5_lupa___pyx_scope_struct_1_unpacks_lua_table_method));
    (void) PyObject_INIT(o, t);
    PyObject_GC_Track(o);
  } else {
    o = (*t->tp_alloc)(t, 0);
    if (unlikely(!o)) return 0;
  }
  return o;
}

static void __pyx_tp_dealloc_4lupa_5_lupa___pyx_scope_struct_1_unpacks_lua_table_method(PyObject *o) {
  struct __pyx_obj_4lupa_5_lupa___pyx_scope_struct_1_unpacks_lua_table_method *p = (struct __pyx_obj_4lupa_5_lupa___pyx_scope_struct_1_unpacks_lua_table_method *)o;
  PyObject_GC_UnTrack(o);
  Py_CLEAR(p->__pyx_v_meth);
  if (CYTHON_COMPILING_IN_CPYTHON && ((__pyx_freecount_4lupa_5_lupa___pyx_scope_struct_1_unpacks_lua_table_method < 8) & (Py_TYPE(o)->tp_basicsize == sizeof(struct __pyx_obj_4lupa_5_lupa___pyx_scope_struct_1_unpacks_lua_table_method)))) {
    __pyx_freelist_4lupa_5_lupa___pyx_scope_struct_1_unpacks_lua_table_method[__pyx_freecount_4lupa_5_lupa___pyx_scope_struct_1_unpacks_lua_table_method++] = ((struct __pyx_obj_4lupa_5_lupa___pyx_scope_struct_1_unpacks_lua_table_method *)o);
  } else {
    (*Py_TYPE(o)->tp_free)(o);
  }
}

static int __pyx_tp_traverse_4lupa_5_lupa___pyx_scope_struct_1_unpacks_lua_table_method(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_4lupa_5_lupa___pyx_scope_struct_1_unpacks_lua_table_method *p = (struct __pyx_obj_4lupa_5_lupa___pyx_scope_struct_1_unpacks_lua_table_method *)o;
  if (p->__pyx_v_meth) {
    e = (*v)(p->__pyx_v_meth, a); if (e) return e;
  }
  return 0;
}

static int __pyx_tp_clear_4lupa_5_lupa___pyx_scope_struct_1_unpacks_lua_table_method(PyObject *o) {
  PyObject* tmp;
  struct __pyx_obj_4lupa_5_lupa___pyx_scope_struct_1_unpacks_lua_table_method *p = (struct __pyx_obj_4lupa_5_lupa___pyx_scope_struct_1_unpacks_lua_table_method *)o;
  tmp = ((PyObject*)p->__pyx_v_meth);
  p->__pyx_v_meth = Py_None; Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  return 0;
}

static PyTypeObject __pyx_type_4lupa_5_lupa___pyx_scope_struct_1_unpacks_lua_table_method = {
  PyVarObject_HEAD_INIT(0, 0)
  "lupa._lupa.__pyx_scope_struct_1_unpacks_lua_table_method", /*tp_name*/
  sizeof(struct __pyx_obj_4lupa_5_lupa___pyx_scope_struct_1_unpacks_lua_table_method), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_4lupa_5_lupa___pyx_scope_struct_1_unpacks_lua_table_method, /*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
  0, /*tp_repr*/
  0, /*tp_as_number*/
  0, /*tp_as_sequence*/
  0, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*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_HAVE_GC, /*tp_flags*/
  0, /*tp_doc*/
  __pyx_tp_traverse_4lupa_5_lupa___pyx_scope_struct_1_unpacks_lua_table_method, /*tp_traverse*/
  __pyx_tp_clear_4lupa_5_lupa___pyx_scope_struct_1_unpacks_lua_table_method, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  0, /*tp_methods*/
  0, /*tp_members*/
  0, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  0, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_4lupa_5_lupa___pyx_scope_struct_1_unpacks_lua_table_method, /*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__lupa(PyObject* module); /*proto*/
static PyModuleDef_Slot __pyx_moduledef_slots[] = {
  {Py_mod_create, (void*)__pyx_pymod_create},
  {Py_mod_exec, (void*)__pyx_pymod_exec__lupa},
  {0, NULL}
};
#endif

static struct PyModuleDef __pyx_moduledef = {
    PyModuleDef_HEAD_INIT,
    "_lupa",
    __pyx_k_A_fast_Python_wrapper_around_Lu, /* 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_n_s_AttributeError, __pyx_k_AttributeError, sizeof(__pyx_k_AttributeError), 0, 0, 1, 1},
  {&__pyx_n_s_BaseException, __pyx_k_BaseException, sizeof(__pyx_k_BaseException), 0, 0, 1, 1},
  {&__pyx_kp_s_Base_class_for_errors_in_the_Lua, __pyx_k_Base_class_for_errors_in_the_Lua, sizeof(__pyx_k_Base_class_for_errors_in_the_Lua), 0, 0, 1, 0},
  {&__pyx_kp_s_Failed_to_acquire_thread_lock, __pyx_k_Failed_to_acquire_thread_lock, sizeof(__pyx_k_Failed_to_acquire_thread_lock), 0, 0, 1, 0},
  {&__pyx_kp_s_Failed_to_initialise_Lua_runtime, __pyx_k_Failed_to_initialise_Lua_runtime, sizeof(__pyx_k_Failed_to_initialise_Lua_runtime), 0, 0, 1, 0},
  {&__pyx_n_s_FastRLock, __pyx_k_FastRLock, sizeof(__pyx_k_FastRLock), 0, 0, 1, 1},
  {&__pyx_n_s_FastRLock___enter, __pyx_k_FastRLock___enter, sizeof(__pyx_k_FastRLock___enter), 0, 0, 1, 1},
  {&__pyx_n_s_FastRLock___exit, __pyx_k_FastRLock___exit, sizeof(__pyx_k_FastRLock___exit), 0, 0, 1, 1},
  {&__pyx_n_s_FastRLock___reduce_cython, __pyx_k_FastRLock___reduce_cython, sizeof(__pyx_k_FastRLock___reduce_cython), 0, 0, 1, 1},
  {&__pyx_n_s_FastRLock___setstate_cython, __pyx_k_FastRLock___setstate_cython, sizeof(__pyx_k_FastRLock___setstate_cython), 0, 0, 1, 1},
  {&__pyx_n_s_FastRLock__is_owned, __pyx_k_FastRLock__is_owned, sizeof(__pyx_k_FastRLock__is_owned), 0, 0, 1, 1},
  {&__pyx_n_s_FastRLock_acquire, __pyx_k_FastRLock_acquire, sizeof(__pyx_k_FastRLock_acquire), 0, 0, 1, 1},
  {&__pyx_n_s_FastRLock_release, __pyx_k_FastRLock_release, sizeof(__pyx_k_FastRLock_release), 0, 0, 1, 1},
  {&__pyx_n_s_ImportError, __pyx_k_ImportError, sizeof(__pyx_k_ImportError), 0, 0, 1, 1},
  {&__pyx_n_s_KeyError, __pyx_k_KeyError, sizeof(__pyx_k_KeyError), 0, 0, 1, 1},
  {&__pyx_n_s_L, __pyx_k_L, sizeof(__pyx_k_L), 0, 0, 1, 1},
  {&__pyx_n_s_LUA_VERSION, __pyx_k_LUA_VERSION, sizeof(__pyx_k_LUA_VERSION), 0, 0, 1, 1},
  {&__pyx_n_s_LuaCoroutineFunction___reduce_c, __pyx_k_LuaCoroutineFunction___reduce_c, sizeof(__pyx_k_LuaCoroutineFunction___reduce_c), 0, 0, 1, 1},
  {&__pyx_n_s_LuaCoroutineFunction___setstate, __pyx_k_LuaCoroutineFunction___setstate, sizeof(__pyx_k_LuaCoroutineFunction___setstate), 0, 0, 1, 1},
  {&__pyx_n_s_LuaError, __pyx_k_LuaError, sizeof(__pyx_k_LuaError), 0, 0, 1, 1},
  {&__pyx_n_s_LuaFunction___reduce_cython, __pyx_k_LuaFunction___reduce_cython, sizeof(__pyx_k_LuaFunction___reduce_cython), 0, 0, 1, 1},
  {&__pyx_n_s_LuaFunction___setstate_cython, __pyx_k_LuaFunction___setstate_cython, sizeof(__pyx_k_LuaFunction___setstate_cython), 0, 0, 1, 1},
  {&__pyx_n_s_LuaFunction_coroutine, __pyx_k_LuaFunction_coroutine, sizeof(__pyx_k_LuaFunction_coroutine), 0, 0, 1, 1},
  {&__pyx_n_s_LuaIter___reduce_cython, __pyx_k_LuaIter___reduce_cython, sizeof(__pyx_k_LuaIter___reduce_cython), 0, 0, 1, 1},
  {&__pyx_n_s_LuaIter___setstate_cython, __pyx_k_LuaIter___setstate_cython, sizeof(__pyx_k_LuaIter___setstate_cython), 0, 0, 1, 1},
  {&__pyx_kp_u_LuaIter_r, __pyx_k_LuaIter_r, sizeof(__pyx_k_LuaIter_r), 0, 1, 0, 0},
  {&__pyx_n_s_LuaObject___reduce_cython, __pyx_k_LuaObject___reduce_cython, sizeof(__pyx_k_LuaObject___reduce_cython), 0, 0, 1, 1},
  {&__pyx_n_s_LuaObject___setstate_cython, __pyx_k_LuaObject___setstate_cython, sizeof(__pyx_k_LuaObject___setstate_cython), 0, 0, 1, 1},
  {&__pyx_n_s_LuaRuntime, __pyx_k_LuaRuntime, sizeof(__pyx_k_LuaRuntime), 0, 0, 1, 1},
  {&__pyx_n_s_LuaRuntime___reduce_cython, __pyx_k_LuaRuntime___reduce_cython, sizeof(__pyx_k_LuaRuntime___reduce_cython), 0, 0, 1, 1},
  {&__pyx_n_s_LuaRuntime___setstate_cython, __pyx_k_LuaRuntime___setstate_cython, sizeof(__pyx_k_LuaRuntime___setstate_cython), 0, 0, 1, 1},
  {&__pyx_n_s_LuaRuntime_compile, __pyx_k_LuaRuntime_compile, sizeof(__pyx_k_LuaRuntime_compile), 0, 0, 1, 1},
  {&__pyx_n_s_LuaRuntime_eval, __pyx_k_LuaRuntime_eval, sizeof(__pyx_k_LuaRuntime_eval), 0, 0, 1, 1},
  {&__pyx_n_s_LuaRuntime_execute, __pyx_k_LuaRuntime_execute, sizeof(__pyx_k_LuaRuntime_execute), 0, 0, 1, 1},
  {&__pyx_n_s_LuaRuntime_globals, __pyx_k_LuaRuntime_globals, sizeof(__pyx_k_LuaRuntime_globals), 0, 0, 1, 1},
  {&__pyx_n_s_LuaRuntime_require, __pyx_k_LuaRuntime_require, sizeof(__pyx_k_LuaRuntime_require), 0, 0, 1, 1},
  {&__pyx_n_s_LuaRuntime_table, __pyx_k_LuaRuntime_table, sizeof(__pyx_k_LuaRuntime_table), 0, 0, 1, 1},
  {&__pyx_n_s_LuaRuntime_table_from, __pyx_k_LuaRuntime_table_from, sizeof(__pyx_k_LuaRuntime_table_from), 0, 0, 1, 1},
  {&__pyx_n_s_LuaSyntaxError, __pyx_k_LuaSyntaxError, sizeof(__pyx_k_LuaSyntaxError), 0, 0, 1, 1},
  {&__pyx_n_s_LuaTable___reduce_cython, __pyx_k_LuaTable___reduce_cython, sizeof(__pyx_k_LuaTable___reduce_cython), 0, 0, 1, 1},
  {&__pyx_n_s_LuaTable___setstate_cython, __pyx_k_LuaTable___setstate_cython, sizeof(__pyx_k_LuaTable___setstate_cython), 0, 0, 1, 1},
  {&__pyx_n_s_LuaTable_items, __pyx_k_LuaTable_items, sizeof(__pyx_k_LuaTable_items), 0, 0, 1, 1},
  {&__pyx_n_s_LuaTable_keys, __pyx_k_LuaTable_keys, sizeof(__pyx_k_LuaTable_keys), 0, 0, 1, 1},
  {&__pyx_n_s_LuaTable_values, __pyx_k_LuaTable_values, sizeof(__pyx_k_LuaTable_values), 0, 0, 1, 1},
  {&__pyx_n_s_LuaThread___reduce_cython, __pyx_k_LuaThread___reduce_cython, sizeof(__pyx_k_LuaThread___reduce_cython), 0, 0, 1, 1},
  {&__pyx_n_s_LuaThread___setstate_cython, __pyx_k_LuaThread___setstate_cython, sizeof(__pyx_k_LuaThread___setstate_cython), 0, 0, 1, 1},
  {&__pyx_n_s_LuaThread_send, __pyx_k_LuaThread_send, sizeof(__pyx_k_LuaThread_send), 0, 0, 1, 1},
  {&__pyx_kp_s_Lua_object_is_not_a_function, __pyx_k_Lua_object_is_not_a_function, sizeof(__pyx_k_Lua_object_is_not_a_function), 0, 0, 1, 0},
  {&__pyx_n_s_Mapping, __pyx_k_Mapping, sizeof(__pyx_k_Mapping), 0, 0, 1, 1},
  {&__pyx_n_s_MemoryError, __pyx_k_MemoryError, sizeof(__pyx_k_MemoryError), 0, 0, 1, 1},
  {&__pyx_n_s_PyProtocolWrapper___reduce_cyth, __pyx_k_PyProtocolWrapper___reduce_cyth, sizeof(__pyx_k_PyProtocolWrapper___reduce_cyth), 0, 0, 1, 1},
  {&__pyx_n_s_PyProtocolWrapper___setstate_cy, __pyx_k_PyProtocolWrapper___setstate_cy, sizeof(__pyx_k_PyProtocolWrapper___setstate_cy), 0, 0, 1, 1},
  {&__pyx_n_b_Py_None, __pyx_k_Py_None, sizeof(__pyx_k_Py_None), 0, 0, 0, 1},
  {&__pyx_n_s_RuntimeError, __pyx_k_RuntimeError, sizeof(__pyx_k_RuntimeError), 0, 0, 1, 1},
  {&__pyx_n_s_StopIteration, __pyx_k_StopIteration, sizeof(__pyx_k_StopIteration), 0, 0, 1, 1},
  {&__pyx_kp_s_Syntax_error_in_Lua_code, __pyx_k_Syntax_error_in_Lua_code, sizeof(__pyx_k_Syntax_error_in_Lua_code), 0, 0, 1, 0},
  {&__pyx_n_s_TypeError, __pyx_k_TypeError, sizeof(__pyx_k_TypeError), 0, 0, 1, 1},
  {&__pyx_kp_s_Type_cannot_be_instantiated_from, __pyx_k_Type_cannot_be_instantiated_from, sizeof(__pyx_k_Type_cannot_be_instantiated_from), 0, 0, 1, 0},
  {&__pyx_kp_s_Type_cannot_be_instantiated_manu, __pyx_k_Type_cannot_be_instantiated_manu, sizeof(__pyx_k_Type_cannot_be_instantiated_manu), 0, 0, 1, 0},
  {&__pyx_kp_b_UTF_8, __pyx_k_UTF_8, sizeof(__pyx_k_UTF_8), 0, 0, 0, 0},
  {&__pyx_kp_s_UTF_8, __pyx_k_UTF_8, sizeof(__pyx_k_UTF_8), 0, 0, 1, 0},
  {&__pyx_n_s_UnicodeDecodeError, __pyx_k_UnicodeDecodeError, sizeof(__pyx_k_UnicodeDecodeError), 0, 0, 1, 1},
  {&__pyx_n_s_ValueError, __pyx_k_ValueError, sizeof(__pyx_k_ValueError), 0, 0, 1, 1},
  {&__pyx_n_b__16, __pyx_k__16, sizeof(__pyx_k__16), 0, 0, 0, 1},
  {&__pyx_n_u__16, __pyx_k__16, sizeof(__pyx_k__16), 0, 1, 0, 1},
  {&__pyx_n_s_acquire, __pyx_k_acquire, sizeof(__pyx_k_acquire), 0, 0, 1, 1},
  {&__pyx_n_s_all, __pyx_k_all, sizeof(__pyx_k_all), 0, 0, 1, 1},
  {&__pyx_n_s_append, __pyx_k_append, sizeof(__pyx_k_append), 0, 0, 1, 1},
  {&__pyx_n_s_arg, __pyx_k_arg, sizeof(__pyx_k_arg), 0, 0, 1, 1},
  {&__pyx_n_s_args, __pyx_k_args, sizeof(__pyx_k_args), 0, 0, 1, 1},
  {&__pyx_n_s_as_attrgetter, __pyx_k_as_attrgetter, sizeof(__pyx_k_as_attrgetter), 0, 0, 1, 1},
  {&__pyx_n_s_as_itemgetter, __pyx_k_as_itemgetter, sizeof(__pyx_k_as_itemgetter), 0, 0, 1, 1},
  {&__pyx_n_s_attribute_filter, __pyx_k_attribute_filter, sizeof(__pyx_k_attribute_filter), 0, 0, 1, 1},
  {&__pyx_kp_s_attribute_filter_and_attribute_h, __pyx_k_attribute_filter_and_attribute_h, sizeof(__pyx_k_attribute_filter_and_attribute_h), 0, 0, 1, 0},
  {&__pyx_kp_s_attribute_filter_must_be_callabl, __pyx_k_attribute_filter_must_be_callabl, sizeof(__pyx_k_attribute_filter_must_be_callabl), 0, 0, 1, 0},
  {&__pyx_n_s_attribute_handlers, __pyx_k_attribute_handlers, sizeof(__pyx_k_attribute_handlers), 0, 0, 1, 1},
  {&__pyx_kp_s_attribute_handlers_must_be_a_seq, __pyx_k_attribute_handlers_must_be_a_seq, sizeof(__pyx_k_attribute_handlers_must_be_a_seq), 0, 0, 1, 0},
  {&__pyx_n_s_blocking, __pyx_k_blocking, sizeof(__pyx_k_blocking), 0, 0, 1, 1},
  {&__pyx_n_s_builtin, __pyx_k_builtin, sizeof(__pyx_k_builtin), 0, 0, 1, 1},
  {&__pyx_n_b_builtins, __pyx_k_builtins, sizeof(__pyx_k_builtins), 0, 0, 0, 1},
  {&__pyx_n_s_builtins, __pyx_k_builtins, sizeof(__pyx_k_builtins), 0, 0, 1, 1},
  {&__pyx_kp_s_byte_string_input_has_unknown_en, __pyx_k_byte_string_input_has_unknown_en, sizeof(__pyx_k_byte_string_input_has_unknown_en), 0, 0, 1, 0},
  {&__pyx_kp_s_can_t_send_non_None_value_to_a_j, __pyx_k_can_t_send_non_None_value_to_a_j, sizeof(__pyx_k_can_t_send_non_None_value_to_a_j), 0, 0, 1, 0},
  {&__pyx_kp_s_cannot_iterate_over_non_table_fo, __pyx_k_cannot_iterate_over_non_table_fo, sizeof(__pyx_k_cannot_iterate_over_non_table_fo), 0, 0, 1, 0},
  {&__pyx_kp_s_cannot_mix_objects_from_differen, __pyx_k_cannot_mix_objects_from_differen, sizeof(__pyx_k_cannot_mix_objects_from_differen), 0, 0, 1, 0},
  {&__pyx_kp_s_cannot_release_un_acquired_lock, __pyx_k_cannot_release_un_acquired_lock, sizeof(__pyx_k_cannot_release_un_acquired_lock), 0, 0, 1, 0},
  {&__pyx_n_s_cline_in_traceback, __pyx_k_cline_in_traceback, sizeof(__pyx_k_cline_in_traceback), 0, 0, 1, 1},
  {&__pyx_n_s_co, __pyx_k_co, sizeof(__pyx_k_co), 0, 0, 1, 1},
  {&__pyx_n_s_collections, __pyx_k_collections, sizeof(__pyx_k_collections), 0, 0, 1, 1},
  {&__pyx_n_s_collections_abc, __pyx_k_collections_abc, sizeof(__pyx_k_collections_abc), 0, 0, 1, 1},
  {&__pyx_n_s_compile, __pyx_k_compile, sizeof(__pyx_k_compile), 0, 0, 1, 1},
  {&__pyx_n_s_coroutine, __pyx_k_coroutine, sizeof(__pyx_k_coroutine), 0, 0, 1, 1},
  {&__pyx_n_s_delattr, __pyx_k_delattr, sizeof(__pyx_k_delattr), 0, 0, 1, 1},
  {&__pyx_n_s_doc, __pyx_k_doc, sizeof(__pyx_k_doc), 0, 0, 1, 1},
  {&__pyx_n_s_encoding, __pyx_k_encoding, sizeof(__pyx_k_encoding), 0, 0, 1, 1},
  {&__pyx_n_s_enter, __pyx_k_enter, sizeof(__pyx_k_enter), 0, 0, 1, 1},
  {&__pyx_n_s_enumerate, __pyx_k_enumerate, sizeof(__pyx_k_enumerate), 0, 0, 1, 1},
  {&__pyx_n_s_err, __pyx_k_err, sizeof(__pyx_k_err), 0, 0, 1, 1},
  {&__pyx_n_s_error, __pyx_k_error, sizeof(__pyx_k_error), 0, 0, 1, 1},
  {&__pyx_kp_b_error_creating_an_iterator, __pyx_k_error_creating_an_iterator, sizeof(__pyx_k_error_creating_an_iterator), 0, 0, 0, 0},
  {&__pyx_kp_b_error_creating_an_iterator_with, __pyx_k_error_creating_an_iterator_with, sizeof(__pyx_k_error_creating_an_iterator_with), 0, 0, 0, 0},
  {&__pyx_kp_b_error_during_Python_call, __pyx_k_error_during_Python_call, sizeof(__pyx_k_error_during_Python_call), 0, 0, 0, 0},
  {&__pyx_kp_b_error_during_Python_str_call, __pyx_k_error_during_Python_str_call, sizeof(__pyx_k_error_during_Python_str_call), 0, 0, 0, 0},
  {&__pyx_kp_u_error_loading_code_s, __pyx_k_error_loading_code_s, sizeof(__pyx_k_error_loading_code_s), 0, 1, 0, 0},
  {&__pyx_kp_b_error_reading_Python_attribute_i, __pyx_k_error_reading_Python_attribute_i, sizeof(__pyx_k_error_reading_Python_attribute_i), 0, 0, 0, 0},
  {&__pyx_kp_b_error_while_calling_next_iterato, __pyx_k_error_while_calling_next_iterato, sizeof(__pyx_k_error_while_calling_next_iterato), 0, 0, 0, 0},
  {&__pyx_kp_b_error_while_cleaning_up_a_Python, __pyx_k_error_while_cleaning_up_a_Python, sizeof(__pyx_k_error_while_cleaning_up_a_Python), 0, 0, 0, 0},
  {&__pyx_kp_b_error_writing_Python_attribute_i, __pyx_k_error_writing_Python_attribute_i, sizeof(__pyx_k_error_writing_Python_attribute_i), 0, 0, 0, 0},
  {&__pyx_n_b_eval, __pyx_k_eval, sizeof(__pyx_k_eval), 0, 0, 0, 1},
  {&__pyx_n_s_eval, __pyx_k_eval, sizeof(__pyx_k_eval), 0, 0, 1, 1},
  {&__pyx_n_s_exc_info, __pyx_k_exc_info, sizeof(__pyx_k_exc_info), 0, 0, 1, 1},
  {&__pyx_n_s_execute, __pyx_k_execute, sizeof(__pyx_k_execute), 0, 0, 1, 1},
  {&__pyx_n_s_exit, __pyx_k_exit, sizeof(__pyx_k_exit), 0, 0, 1, 1},
  {&__pyx_kp_s_expected_string_got_s, __pyx_k_expected_string_got_s, sizeof(__pyx_k_expected_string_got_s), 0, 0, 1, 0},
  {&__pyx_kp_s_failed_to_convert_argument_at_in, __pyx_k_failed_to_convert_argument_at_in, sizeof(__pyx_k_failed_to_convert_argument_at_in), 0, 0, 1, 0},
  {&__pyx_kp_s_failed_to_convert_s_object, __pyx_k_failed_to_convert_s_object, sizeof(__pyx_k_failed_to_convert_s_object), 0, 0, 1, 0},
  {&__pyx_n_s_func, __pyx_k_func, sizeof(__pyx_k_func), 0, 0, 1, 1},
  {&__pyx_n_s_function, __pyx_k_function, sizeof(__pyx_k_function), 0, 0, 1, 1},
  {&__pyx_kp_s_function_if_type_jit_table_then, __pyx_k_function_if_type_jit_table_then, sizeof(__pyx_k_function_if_type_jit_table_then), 0, 0, 1, 0},
  {&__pyx_n_s_functools, __pyx_k_functools, sizeof(__pyx_k_functools), 0, 0, 1, 1},
  {&__pyx_n_s_getattr, __pyx_k_getattr, sizeof(__pyx_k_getattr), 0, 0, 1, 1},
  {&__pyx_n_s_getitem, __pyx_k_getitem, sizeof(__pyx_k_getitem), 0, 0, 1, 1},
  {&__pyx_n_s_getstate, __pyx_k_getstate, sizeof(__pyx_k_getstate), 0, 0, 1, 1},
  {&__pyx_n_s_globals, __pyx_k_globals, sizeof(__pyx_k_globals), 0, 0, 1, 1},
  {&__pyx_kp_s_globals_not_defined, __pyx_k_globals_not_defined, sizeof(__pyx_k_globals_not_defined), 0, 0, 1, 0},
  {&__pyx_n_s_i, __pyx_k_i, sizeof(__pyx_k_i), 0, 0, 1, 1},
  {&__pyx_n_s_import, __pyx_k_import, sizeof(__pyx_k_import), 0, 0, 1, 1},
  {&__pyx_n_s_is_owned, __pyx_k_is_owned, sizeof(__pyx_k_is_owned), 0, 0, 1, 1},
  {&__pyx_kp_s_item_attribute_access_not_suppor, __pyx_k_item_attribute_access_not_suppor, sizeof(__pyx_k_item_attribute_access_not_suppor), 0, 0, 1, 0},
  {&__pyx_n_s_items, __pyx_k_items, sizeof(__pyx_k_items), 0, 0, 1, 1},
  {&__pyx_kp_s_iteration_is_only_supported_for, __pyx_k_iteration_is_only_supported_for, sizeof(__pyx_k_iteration_is_only_supported_for), 0, 0, 1, 0},
  {&__pyx_n_s_iteritems, __pyx_k_iteritems, sizeof(__pyx_k_iteritems), 0, 0, 1, 1},
  {&__pyx_n_s_key, __pyx_k_key, sizeof(__pyx_k_key), 0, 0, 1, 1},
  {&__pyx_n_s_keys, __pyx_k_keys, sizeof(__pyx_k_keys), 0, 0, 1, 1},
  {&__pyx_n_s_kwargs, __pyx_k_kwargs, sizeof(__pyx_k_kwargs), 0, 0, 1, 1},
  {&__pyx_kp_s_lost_reference, __pyx_k_lost_reference, sizeof(__pyx_k_lost_reference), 0, 0, 1, 0},
  {&__pyx_n_s_ltype, __pyx_k_ltype, sizeof(__pyx_k_ltype), 0, 0, 1, 1},
  {&__pyx_n_s_lua_code, __pyx_k_lua_code, sizeof(__pyx_k_lua_code), 0, 0, 1, 1},
  {&__pyx_n_s_lua_object, __pyx_k_lua_object, sizeof(__pyx_k_lua_object), 0, 0, 1, 1},
  {&__pyx_n_s_lua_type, __pyx_k_lua_type, sizeof(__pyx_k_lua_type), 0, 0, 1, 1},
  {&__pyx_n_s_lua_type_name, __pyx_k_lua_type_name, sizeof(__pyx_k_lua_type_name), 0, 0, 1, 1},
  {&__pyx_n_s_lupa__lupa, __pyx_k_lupa__lupa, sizeof(__pyx_k_lupa__lupa), 0, 0, 1, 1},
  {&__pyx_kp_s_lupa__lupa_pyx, __pyx_k_lupa__lupa_pyx, sizeof(__pyx_k_lupa__lupa_pyx), 0, 0, 1, 0},
  {&__pyx_kp_s_lupa_lock_pxi, __pyx_k_lupa_lock_pxi, sizeof(__pyx_k_lupa_lock_pxi), 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_meth, __pyx_k_meth, sizeof(__pyx_k_meth), 0, 0, 1, 1},
  {&__pyx_n_s_module, __pyx_k_module, sizeof(__pyx_k_module), 0, 0, 1, 1},
  {&__pyx_n_s_modulename, __pyx_k_modulename, sizeof(__pyx_k_modulename), 0, 0, 1, 1},
  {&__pyx_kp_s_modulename_must_be_a_string, __pyx_k_modulename_must_be_a_string, sizeof(__pyx_k_modulename_must_be_a_string), 0, 0, 1, 0},
  {&__pyx_n_s_name, __pyx_k_name, sizeof(__pyx_k_name), 0, 0, 1, 1},
  {&__pyx_n_s_name_2, __pyx_k_name_2, sizeof(__pyx_k_name_2), 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_none, __pyx_k_none, sizeof(__pyx_k_none), 0, 0, 0, 1},
  {&__pyx_kp_s_not_a_python_object, __pyx_k_not_a_python_object, sizeof(__pyx_k_not_a_python_object), 0, 0, 1, 0},
  {&__pyx_n_s_obj, __pyx_k_obj, sizeof(__pyx_k_obj), 0, 0, 1, 1},
  {&__pyx_n_s_object, __pyx_k_object, sizeof(__pyx_k_object), 0, 0, 1, 1},
  {&__pyx_n_s_old_top, __pyx_k_old_top, sizeof(__pyx_k_old_top), 0, 0, 1, 1},
  {&__pyx_n_s_oldtop, __pyx_k_oldtop, sizeof(__pyx_k_oldtop), 0, 0, 1, 1},
  {&__pyx_n_s_pop, __pyx_k_pop, sizeof(__pyx_k_pop), 0, 0, 1, 1},
  {&__pyx_n_s_prepare, __pyx_k_prepare, sizeof(__pyx_k_prepare), 0, 0, 1, 1},
  {&__pyx_n_s_pyx_state, __pyx_k_pyx_state, sizeof(__pyx_k_pyx_state), 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_qualname, __pyx_k_qualname, sizeof(__pyx_k_qualname), 0, 0, 1, 1},
  {&__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_register_builtins, __pyx_k_register_builtins, sizeof(__pyx_k_register_builtins), 0, 0, 1, 1},
  {&__pyx_n_s_register_eval, __pyx_k_register_eval, sizeof(__pyx_k_register_eval), 0, 0, 1, 1},
  {&__pyx_n_s_release, __pyx_k_release, sizeof(__pyx_k_release), 0, 0, 1, 1},
  {&__pyx_n_s_require, __pyx_k_require, sizeof(__pyx_k_require), 0, 0, 1, 1},
  {&__pyx_kp_s_require_is_not_defined, __pyx_k_require_is_not_defined, sizeof(__pyx_k_require_is_not_defined), 0, 0, 1, 0},
  {&__pyx_kp_b_return, __pyx_k_return, sizeof(__pyx_k_return), 0, 0, 0, 0},
  {&__pyx_n_s_self, __pyx_k_self, sizeof(__pyx_k_self), 0, 0, 1, 1},
  {&__pyx_kp_s_self__co_state_self__state_canno, __pyx_k_self__co_state_self__state_canno, sizeof(__pyx_k_self__co_state_self__state_canno), 0, 0, 1, 0},
  {&__pyx_kp_s_self__state_cannot_be_converted, __pyx_k_self__state_cannot_be_converted, sizeof(__pyx_k_self__state_cannot_be_converted), 0, 0, 1, 0},
  {&__pyx_n_s_send, __pyx_k_send, sizeof(__pyx_k_send), 0, 0, 1, 1},
  {&__pyx_n_s_setattr, __pyx_k_setattr, sizeof(__pyx_k_setattr), 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_size, __pyx_k_size, sizeof(__pyx_k_size), 0, 0, 1, 1},
  {&__pyx_n_s_source_encoding, __pyx_k_source_encoding, sizeof(__pyx_k_source_encoding), 0, 0, 1, 1},
  {&__pyx_n_s_status, __pyx_k_status, sizeof(__pyx_k_status), 0, 0, 1, 1},
  {&__pyx_kp_s_stringsource, __pyx_k_stringsource, sizeof(__pyx_k_stringsource), 0, 0, 1, 0},
  {&__pyx_n_s_sys, __pyx_k_sys, sizeof(__pyx_k_sys), 0, 0, 1, 1},
  {&__pyx_n_s_t, __pyx_k_t, sizeof(__pyx_k_t), 0, 0, 1, 1},
  {&__pyx_n_s_table, __pyx_k_table, sizeof(__pyx_k_table), 0, 0, 1, 1},
  {&__pyx_n_s_table_from, __pyx_k_table_from, sizeof(__pyx_k_table_from), 0, 0, 1, 1},
  {&__pyx_n_s_tb, __pyx_k_tb, sizeof(__pyx_k_tb), 0, 0, 1, 1},
  {&__pyx_n_s_test, __pyx_k_test, sizeof(__pyx_k_test), 0, 0, 1, 1},
  {&__pyx_n_s_thread, __pyx_k_thread, sizeof(__pyx_k_thread), 0, 0, 1, 1},
  {&__pyx_n_s_unpack_returned_tuples, __pyx_k_unpack_returned_tuples, sizeof(__pyx_k_unpack_returned_tuples), 0, 0, 1, 1},
  {&__pyx_n_s_unpacks_lua_table, __pyx_k_unpacks_lua_table, sizeof(__pyx_k_unpacks_lua_table), 0, 0, 1, 1},
  {&__pyx_n_s_unpacks_lua_table_locals_wrapper, __pyx_k_unpacks_lua_table_locals_wrapper, sizeof(__pyx_k_unpacks_lua_table_locals_wrapper), 0, 0, 1, 1},
  {&__pyx_n_s_unpacks_lua_table_method, __pyx_k_unpacks_lua_table_method, sizeof(__pyx_k_unpacks_lua_table_method), 0, 0, 1, 1},
  {&__pyx_n_s_unpacks_lua_table_method_locals, __pyx_k_unpacks_lua_table_method_locals, sizeof(__pyx_k_unpacks_lua_table_method_locals), 0, 0, 1, 1},
  {&__pyx_n_s_userdata, __pyx_k_userdata, sizeof(__pyx_k_userdata), 0, 0, 1, 1},
  {&__pyx_n_s_v, __pyx_k_v, sizeof(__pyx_k_v), 0, 0, 1, 1},
  {&__pyx_n_s_value, __pyx_k_value, sizeof(__pyx_k_value), 0, 0, 1, 1},
  {&__pyx_n_s_values, __pyx_k_values, sizeof(__pyx_k_values), 0, 0, 1, 1},
  {&__pyx_n_s_what, __pyx_k_what, sizeof(__pyx_k_what), 0, 0, 1, 1},
  {&__pyx_n_s_wrap, __pyx_k_wrap, sizeof(__pyx_k_wrap), 0, 0, 1, 1},
  {&__pyx_n_s_wrapper, __pyx_k_wrapper, sizeof(__pyx_k_wrapper), 0, 0, 1, 1},
  {&__pyx_n_s_wraps, __pyx_k_wraps, sizeof(__pyx_k_wraps), 0, 0, 1, 1},
  {0, 0, 0, 0, 0, 0, 0}
};
static CYTHON_SMALL_CODE int __Pyx_InitCachedBuiltins(void) {
  __pyx_builtin_ImportError = __Pyx_GetBuiltinName(__pyx_n_s_ImportError); if (!__pyx_builtin_ImportError) __PYX_ERR(0, 47, __pyx_L1_error)
  __pyx_builtin_MemoryError = __Pyx_GetBuiltinName(__pyx_n_s_MemoryError); if (!__pyx_builtin_MemoryError) __PYX_ERR(1, 27, __pyx_L1_error)
  __pyx_builtin_RuntimeError = __Pyx_GetBuiltinName(__pyx_n_s_RuntimeError); if (!__pyx_builtin_RuntimeError) __PYX_ERR(1, 39, __pyx_L1_error)
  __pyx_builtin_TypeError = __Pyx_GetBuiltinName(__pyx_n_s_TypeError); if (!__pyx_builtin_TypeError) __PYX_ERR(2, 2, __pyx_L1_error)
  __pyx_builtin_ValueError = __Pyx_GetBuiltinName(__pyx_n_s_ValueError); if (!__pyx_builtin_ValueError) __PYX_ERR(0, 226, __pyx_L1_error)
  __pyx_builtin_eval = __Pyx_GetBuiltinName(__pyx_n_s_eval); if (!__pyx_builtin_eval) __PYX_ERR(0, 451, __pyx_L1_error)
  __pyx_builtin_range = __Pyx_GetBuiltinName(__pyx_n_s_range); if (!__pyx_builtin_range) __PYX_ERR(0, 519, __pyx_L1_error)
  __pyx_builtin_UnicodeDecodeError = __Pyx_GetBuiltinName(__pyx_n_s_UnicodeDecodeError); if (!__pyx_builtin_UnicodeDecodeError) __PYX_ERR(0, 648, __pyx_L1_error)
  __pyx_builtin_object = __Pyx_GetBuiltinName(__pyx_n_s_object); if (!__pyx_builtin_object) __PYX_ERR(0, 663, __pyx_L1_error)
  __pyx_builtin_AttributeError = __Pyx_GetBuiltinName(__pyx_n_s_AttributeError); if (!__pyx_builtin_AttributeError) __PYX_ERR(0, 683, __pyx_L1_error)
  __pyx_builtin_StopIteration = __Pyx_GetBuiltinName(__pyx_n_s_StopIteration); if (!__pyx_builtin_StopIteration) __PYX_ERR(0, 955, __pyx_L1_error)
  __pyx_builtin_BaseException = __Pyx_GetBuiltinName(__pyx_n_s_BaseException); if (!__pyx_builtin_BaseException) __PYX_ERR(0, 1357, __pyx_L1_error)
  __pyx_builtin_enumerate = __Pyx_GetBuiltinName(__pyx_n_s_enumerate); if (!__pyx_builtin_enumerate) __PYX_ERR(0, 1367, __pyx_L1_error)
  __pyx_builtin_KeyError = __Pyx_GetBuiltinName(__pyx_n_s_KeyError); if (!__pyx_builtin_KeyError) __PYX_ERR(0, 1424, __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);

  /* "lupa/lock.pxi":39
 *     def release(self):
 *         if self._owner != pythread.PyThread_get_thread_ident():
 *             raise RuntimeError("cannot release un-acquired lock")             # <<<<<<<<<<<<<<
 *         unlock_lock(self)
 * 
 */
  __pyx_tuple_ = PyTuple_Pack(1, __pyx_kp_s_cannot_release_un_acquired_lock); if (unlikely(!__pyx_tuple_)) __PYX_ERR(1, 39, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple_);
  __Pyx_GIVEREF(__pyx_tuple_);

  /* "(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__2 = PyTuple_Pack(1, __pyx_kp_s_no_default___reduce___due_to_non); if (unlikely(!__pyx_tuple__2)) __PYX_ERR(2, 2, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__2);
  __Pyx_GIVEREF(__pyx_tuple__2);

  /* "(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__3 = PyTuple_Pack(1, __pyx_kp_s_no_default___reduce___due_to_non); if (unlikely(!__pyx_tuple__3)) __PYX_ERR(2, 4, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__3);
  __Pyx_GIVEREF(__pyx_tuple__3);

  /* "lupa/_lupa.pyx":226
 *         self._source_encoding = _asciiOrNone(source_encoding) or self._encoding or b'UTF-8'
 *         if attribute_filter is not None and not callable(attribute_filter):
 *             raise ValueError("attribute_filter must be callable")             # <<<<<<<<<<<<<<
 *         self._attribute_filter = attribute_filter
 *         self._unpack_returned_tuples = unpack_returned_tuples
 */
  __pyx_tuple__4 = PyTuple_Pack(1, __pyx_kp_s_attribute_filter_must_be_callabl); if (unlikely(!__pyx_tuple__4)) __PYX_ERR(0, 226, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__4);
  __Pyx_GIVEREF(__pyx_tuple__4);

  /* "lupa/_lupa.pyx":241
 *                     raise_error = True
 *             if raise_error:
 *                 raise ValueError("attribute_handlers must be a sequence of two callables")             # <<<<<<<<<<<<<<
 *             if attribute_filter and (getter is not None or setter is not None):
 *                 raise ValueError("attribute_filter and attribute_handlers are mutually exclusive")
 */
  __pyx_tuple__5 = PyTuple_Pack(1, __pyx_kp_s_attribute_handlers_must_be_a_seq); if (unlikely(!__pyx_tuple__5)) __PYX_ERR(0, 241, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__5);
  __Pyx_GIVEREF(__pyx_tuple__5);

  /* "lupa/_lupa.pyx":243
 *                 raise ValueError("attribute_handlers must be a sequence of two callables")
 *             if attribute_filter and (getter is not None or setter is not None):
 *                 raise ValueError("attribute_filter and attribute_handlers are mutually exclusive")             # <<<<<<<<<<<<<<
 *             self._attribute_getter, self._attribute_setter = getter, setter
 * 
 */
  __pyx_tuple__6 = PyTuple_Pack(1, __pyx_kp_s_attribute_filter_and_attribute_h); if (unlikely(!__pyx_tuple__6)) __PYX_ERR(0, 243, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__6);
  __Pyx_GIVEREF(__pyx_tuple__6);

  /* "lupa/_lupa.pyx":338
 *         cdef lua_State *L = self._state
 *         if not isinstance(modulename, (bytes, unicode)):
 *             raise TypeError("modulename must be a string")             # <<<<<<<<<<<<<<
 *         lock_runtime(self)
 *         old_top = lua.lua_gettop(L)
 */
  __pyx_tuple__7 = PyTuple_Pack(1, __pyx_kp_s_modulename_must_be_a_string); if (unlikely(!__pyx_tuple__7)) __PYX_ERR(0, 338, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__7);
  __Pyx_GIVEREF(__pyx_tuple__7);

  /* "(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__8 = PyTuple_Pack(1, __pyx_kp_s_no_default___reduce___due_to_non); if (unlikely(!__pyx_tuple__8)) __PYX_ERR(2, 2, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__8);
  __Pyx_GIVEREF(__pyx_tuple__8);

  /* "(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__9 = PyTuple_Pack(1, __pyx_kp_s_no_default___reduce___due_to_non); if (unlikely(!__pyx_tuple__9)) __PYX_ERR(2, 4, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__9);
  __Pyx_GIVEREF(__pyx_tuple__9);

  /* "lupa/_lupa.pyx":482
 *     """
 *     @wraps(func)
 *     def wrapper(*args):             # <<<<<<<<<<<<<<
 *         args, kwargs = _fix_args_kwargs(args)
 *         return func(*args, **kwargs)
 */
  __pyx_tuple__10 = PyTuple_Pack(2, __pyx_n_s_args, __pyx_n_s_kwargs); if (unlikely(!__pyx_tuple__10)) __PYX_ERR(0, 482, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__10);
  __Pyx_GIVEREF(__pyx_tuple__10);
  __pyx_codeobj__11 = (PyObject*)__Pyx_PyCode_New(0, 0, 2, 0, CO_OPTIMIZED|CO_NEWLOCALS|CO_VARARGS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__10, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_lupa__lupa_pyx, __pyx_n_s_wrapper, 482, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__11)) __PYX_ERR(0, 482, __pyx_L1_error)

  /* "lupa/_lupa.pyx":494
 *     """
 *     @wraps(meth)
 *     def wrapper(self, *args):             # <<<<<<<<<<<<<<
 *         args, kwargs = _fix_args_kwargs(args)
 *         return meth(self, *args, **kwargs)
 */
  __pyx_tuple__12 = PyTuple_Pack(3, __pyx_n_s_self, __pyx_n_s_args, __pyx_n_s_kwargs); if (unlikely(!__pyx_tuple__12)) __PYX_ERR(0, 494, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__12);
  __Pyx_GIVEREF(__pyx_tuple__12);
  __pyx_codeobj__13 = (PyObject*)__Pyx_PyCode_New(1, 0, 3, 0, CO_OPTIMIZED|CO_NEWLOCALS|CO_VARARGS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__12, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_lupa__lupa_pyx, __pyx_n_s_wrapper, 494, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__13)) __PYX_ERR(0, 494, __pyx_L1_error)

  /* "lupa/_lupa.pyx":557
 * 
 *     def __init__(self):
 *         raise TypeError("Type cannot be instantiated manually")             # <<<<<<<<<<<<<<
 * 
 *     def __dealloc__(self):
 */
  __pyx_tuple__14 = PyTuple_Pack(1, __pyx_kp_s_Type_cannot_be_instantiated_manu); if (unlikely(!__pyx_tuple__14)) __PYX_ERR(0, 557, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__14);
  __Pyx_GIVEREF(__pyx_tuple__14);

  /* "lupa/_lupa.pyx":614
 *     def __iter__(self):
 *         # if not provided, iteration will try item access and call into Lua
 *         raise TypeError("iteration is only supported for tables")             # <<<<<<<<<<<<<<
 * 
 *     def __repr__(self):
 */
  __pyx_tuple__15 = PyTuple_Pack(1, __pyx_kp_s_iteration_is_only_supported_for); if (unlikely(!__pyx_tuple__15)) __PYX_ERR(0, 614, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__15);
  __Pyx_GIVEREF(__pyx_tuple__15);

  /* "(tree fragment)":2
 * def __reduce_cython__(self):
 *     raise TypeError("self._state cannot be converted to a Python object for pickling")             # <<<<<<<<<<<<<<
 * def __setstate_cython__(self, __pyx_state):
 *     raise TypeError("self._state cannot be converted to a Python object for pickling")
 */
  __pyx_tuple__17 = PyTuple_Pack(1, __pyx_kp_s_self__state_cannot_be_converted); if (unlikely(!__pyx_tuple__17)) __PYX_ERR(2, 2, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__17);
  __Pyx_GIVEREF(__pyx_tuple__17);

  /* "(tree fragment)":4
 *     raise TypeError("self._state cannot be converted to a Python object for pickling")
 * def __setstate_cython__(self, __pyx_state):
 *     raise TypeError("self._state cannot be converted to a Python object for pickling")             # <<<<<<<<<<<<<<
 */
  __pyx_tuple__18 = PyTuple_Pack(1, __pyx_kp_s_self__state_cannot_be_converted); if (unlikely(!__pyx_tuple__18)) __PYX_ERR(2, 4, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__18);
  __Pyx_GIVEREF(__pyx_tuple__18);

  /* "(tree fragment)":2
 * def __reduce_cython__(self):
 *     raise TypeError("self._state cannot be converted to a Python object for pickling")             # <<<<<<<<<<<<<<
 * def __setstate_cython__(self, __pyx_state):
 *     raise TypeError("self._state cannot be converted to a Python object for pickling")
 */
  __pyx_tuple__19 = PyTuple_Pack(1, __pyx_kp_s_self__state_cannot_be_converted); if (unlikely(!__pyx_tuple__19)) __PYX_ERR(2, 2, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__19);
  __Pyx_GIVEREF(__pyx_tuple__19);

  /* "(tree fragment)":4
 *     raise TypeError("self._state cannot be converted to a Python object for pickling")
 * def __setstate_cython__(self, __pyx_state):
 *     raise TypeError("self._state cannot be converted to a Python object for pickling")             # <<<<<<<<<<<<<<
 */
  __pyx_tuple__20 = PyTuple_Pack(1, __pyx_kp_s_self__state_cannot_be_converted); if (unlikely(!__pyx_tuple__20)) __PYX_ERR(2, 4, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__20);
  __Pyx_GIVEREF(__pyx_tuple__20);

  /* "lupa/_lupa.pyx":839
 *             self.push_lua_object()
 *             if not lua.lua_isfunction(L, -1) or lua.lua_iscfunction(L, -1):
 *                 raise TypeError("Lua object is not a function")             # <<<<<<<<<<<<<<
 *             # create thread stack and push the function on it
 *             co = lua.lua_newthread(L)
 */
  __pyx_tuple__21 = PyTuple_Pack(1, __pyx_kp_s_Lua_object_is_not_a_function); if (unlikely(!__pyx_tuple__21)) __PYX_ERR(0, 839, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__21);
  __Pyx_GIVEREF(__pyx_tuple__21);

  /* "(tree fragment)":2
 * def __reduce_cython__(self):
 *     raise TypeError("self._state cannot be converted to a Python object for pickling")             # <<<<<<<<<<<<<<
 * def __setstate_cython__(self, __pyx_state):
 *     raise TypeError("self._state cannot be converted to a Python object for pickling")
 */
  __pyx_tuple__22 = PyTuple_Pack(1, __pyx_kp_s_self__state_cannot_be_converted); if (unlikely(!__pyx_tuple__22)) __PYX_ERR(2, 2, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__22);
  __Pyx_GIVEREF(__pyx_tuple__22);

  /* "(tree fragment)":4
 *     raise TypeError("self._state cannot be converted to a Python object for pickling")
 * def __setstate_cython__(self, __pyx_state):
 *     raise TypeError("self._state cannot be converted to a Python object for pickling")             # <<<<<<<<<<<<<<
 */
  __pyx_tuple__23 = PyTuple_Pack(1, __pyx_kp_s_self__state_cannot_be_converted); if (unlikely(!__pyx_tuple__23)) __PYX_ERR(2, 4, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__23);
  __Pyx_GIVEREF(__pyx_tuple__23);

  /* "(tree fragment)":2
 * def __reduce_cython__(self):
 *     raise TypeError("self._state cannot be converted to a Python object for pickling")             # <<<<<<<<<<<<<<
 * def __setstate_cython__(self, __pyx_state):
 *     raise TypeError("self._state cannot be converted to a Python object for pickling")
 */
  __pyx_tuple__24 = PyTuple_Pack(1, __pyx_kp_s_self__state_cannot_be_converted); if (unlikely(!__pyx_tuple__24)) __PYX_ERR(2, 2, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__24);
  __Pyx_GIVEREF(__pyx_tuple__24);

  /* "(tree fragment)":4
 *     raise TypeError("self._state cannot be converted to a Python object for pickling")
 * def __setstate_cython__(self, __pyx_state):
 *     raise TypeError("self._state cannot be converted to a Python object for pickling")             # <<<<<<<<<<<<<<
 */
  __pyx_tuple__25 = PyTuple_Pack(1, __pyx_kp_s_self__state_cannot_be_converted); if (unlikely(!__pyx_tuple__25)) __PYX_ERR(2, 4, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__25);
  __Pyx_GIVEREF(__pyx_tuple__25);

  /* "lupa/_lupa.pyx":898
 *         if value is not None:
 *             if self._arguments is not None:
 *                 raise TypeError("can't send non-None value to a just-started generator")             # <<<<<<<<<<<<<<
 *             if not isinstance(value, tuple):
 *                 value = (value,)
 */
  __pyx_tuple__26 = PyTuple_Pack(1, __pyx_kp_s_can_t_send_non_None_value_to_a_j); if (unlikely(!__pyx_tuple__26)) __PYX_ERR(0, 898, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__26);
  __Pyx_GIVEREF(__pyx_tuple__26);

  /* "(tree fragment)":2
 * def __reduce_cython__(self):
 *     raise TypeError("self._co_state,self._state cannot be converted to a Python object for pickling")             # <<<<<<<<<<<<<<
 * def __setstate_cython__(self, __pyx_state):
 *     raise TypeError("self._co_state,self._state cannot be converted to a Python object for pickling")
 */
  __pyx_tuple__27 = PyTuple_Pack(1, __pyx_kp_s_self__co_state_self__state_canno); if (unlikely(!__pyx_tuple__27)) __PYX_ERR(2, 2, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__27);
  __Pyx_GIVEREF(__pyx_tuple__27);

  /* "(tree fragment)":4
 *     raise TypeError("self._co_state,self._state cannot be converted to a Python object for pickling")
 * def __setstate_cython__(self, __pyx_state):
 *     raise TypeError("self._co_state,self._state cannot be converted to a Python object for pickling")             # <<<<<<<<<<<<<<
 */
  __pyx_tuple__28 = PyTuple_Pack(1, __pyx_kp_s_self__co_state_self__state_canno); if (unlikely(!__pyx_tuple__28)) __PYX_ERR(2, 4, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__28);
  __Pyx_GIVEREF(__pyx_tuple__28);

  /* "(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__29 = PyTuple_Pack(1, __pyx_kp_s_no_default___reduce___due_to_non); if (unlikely(!__pyx_tuple__29)) __PYX_ERR(2, 2, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__29);
  __Pyx_GIVEREF(__pyx_tuple__29);

  /* "(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__30 = PyTuple_Pack(1, __pyx_kp_s_no_default___reduce___due_to_non); if (unlikely(!__pyx_tuple__30)) __PYX_ERR(2, 4, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__30);
  __Pyx_GIVEREF(__pyx_tuple__30);

  /* "lupa/_lupa.pyx":1107
 *         self._type_flags = 0
 *     def __init__(self):
 *         raise TypeError("Type cannot be instantiated from Python")             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_tuple__31 = PyTuple_Pack(1, __pyx_kp_s_Type_cannot_be_instantiated_from); if (unlikely(!__pyx_tuple__31)) __PYX_ERR(0, 1107, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__31);
  __Pyx_GIVEREF(__pyx_tuple__31);

  /* "(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__32 = PyTuple_Pack(1, __pyx_kp_s_no_default___reduce___due_to_non); if (unlikely(!__pyx_tuple__32)) __PYX_ERR(2, 2, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__32);
  __Pyx_GIVEREF(__pyx_tuple__32);

  /* "(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__33 = PyTuple_Pack(1, __pyx_kp_s_no_default___reduce___due_to_non); if (unlikely(!__pyx_tuple__33)) __PYX_ERR(2, 4, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__33);
  __Pyx_GIVEREF(__pyx_tuple__33);

  /* "lupa/_lupa.pyx":1283
 *         raise ValueError("expected string, got %s" % type(s))
 *     if not _isascii(<bytes>s):
 *         raise ValueError("byte string input has unknown encoding, only ASCII is allowed")             # <<<<<<<<<<<<<<
 *     return <bytes>s
 * 
 */
  __pyx_tuple__34 = PyTuple_Pack(1, __pyx_kp_s_byte_string_input_has_unknown_en); if (unlikely(!__pyx_tuple__34)) __PYX_ERR(0, 1283, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__34);
  __Pyx_GIVEREF(__pyx_tuple__34);

  /* "lupa/_lupa.pyx":1451
 * 
 *     if not py_obj:
 *         raise TypeError("not a python object")             # <<<<<<<<<<<<<<
 * 
 *     f = <object>py_obj.obj
 */
  __pyx_tuple__35 = PyTuple_Pack(1, __pyx_kp_s_not_a_python_object); if (unlikely(!__pyx_tuple__35)) __PYX_ERR(0, 1451, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__35);
  __Pyx_GIVEREF(__pyx_tuple__35);

  /* "lupa/lock.pxi":34
 *             self._real_lock = NULL
 * 
 *     def acquire(self, bint blocking=True):             # <<<<<<<<<<<<<<
 *         return lock_lock(self, pythread.PyThread_get_thread_ident(), blocking)
 * 
 */
  __pyx_tuple__36 = PyTuple_Pack(2, __pyx_n_s_self, __pyx_n_s_blocking); if (unlikely(!__pyx_tuple__36)) __PYX_ERR(1, 34, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__36);
  __Pyx_GIVEREF(__pyx_tuple__36);
  __pyx_codeobj__37 = (PyObject*)__Pyx_PyCode_New(2, 0, 2, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__36, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_lupa_lock_pxi, __pyx_n_s_acquire, 34, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__37)) __PYX_ERR(1, 34, __pyx_L1_error)

  /* "lupa/lock.pxi":37
 *         return lock_lock(self, pythread.PyThread_get_thread_ident(), blocking)
 * 
 *     def release(self):             # <<<<<<<<<<<<<<
 *         if self._owner != pythread.PyThread_get_thread_ident():
 *             raise RuntimeError("cannot release un-acquired lock")
 */
  __pyx_tuple__38 = PyTuple_Pack(1, __pyx_n_s_self); if (unlikely(!__pyx_tuple__38)) __PYX_ERR(1, 37, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__38);
  __Pyx_GIVEREF(__pyx_tuple__38);
  __pyx_codeobj__39 = (PyObject*)__Pyx_PyCode_New(1, 0, 1, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__38, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_lupa_lock_pxi, __pyx_n_s_release, 37, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__39)) __PYX_ERR(1, 37, __pyx_L1_error)

  /* "lupa/lock.pxi":44
 *     # compatibility with RLock
 * 
 *     def __enter__(self):             # <<<<<<<<<<<<<<
 *         # self.acquire()
 *         return lock_lock(self, pythread.PyThread_get_thread_ident(), True)
 */
  __pyx_tuple__40 = PyTuple_Pack(1, __pyx_n_s_self); if (unlikely(!__pyx_tuple__40)) __PYX_ERR(1, 44, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__40);
  __Pyx_GIVEREF(__pyx_tuple__40);
  __pyx_codeobj__41 = (PyObject*)__Pyx_PyCode_New(1, 0, 1, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__40, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_lupa_lock_pxi, __pyx_n_s_enter, 44, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__41)) __PYX_ERR(1, 44, __pyx_L1_error)

  /* "lupa/lock.pxi":48
 *         return lock_lock(self, pythread.PyThread_get_thread_ident(), True)
 * 
 *     def __exit__(self, t, v, tb):             # <<<<<<<<<<<<<<
 *         # self.release()
 *         if self._owner != pythread.PyThread_get_thread_ident():
 */
  __pyx_tuple__42 = PyTuple_Pack(4, __pyx_n_s_self, __pyx_n_s_t, __pyx_n_s_v, __pyx_n_s_tb); if (unlikely(!__pyx_tuple__42)) __PYX_ERR(1, 48, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__42);
  __Pyx_GIVEREF(__pyx_tuple__42);
  __pyx_codeobj__43 = (PyObject*)__Pyx_PyCode_New(4, 0, 4, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__42, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_lupa_lock_pxi, __pyx_n_s_exit, 48, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__43)) __PYX_ERR(1, 48, __pyx_L1_error)

  /* "lupa/lock.pxi":54
 *         unlock_lock(self)
 * 
 *     def _is_owned(self):             # <<<<<<<<<<<<<<
 *         return self._owner == pythread.PyThread_get_thread_ident()
 * 
 */
  __pyx_tuple__44 = PyTuple_Pack(1, __pyx_n_s_self); if (unlikely(!__pyx_tuple__44)) __PYX_ERR(1, 54, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__44);
  __Pyx_GIVEREF(__pyx_tuple__44);
  __pyx_codeobj__45 = (PyObject*)__Pyx_PyCode_New(1, 0, 1, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__44, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_lupa_lock_pxi, __pyx_n_s_is_owned, 54, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__45)) __PYX_ERR(1, 54, __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):
 */
  __pyx_tuple__46 = PyTuple_Pack(1, __pyx_n_s_self); if (unlikely(!__pyx_tuple__46)) __PYX_ERR(2, 1, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__46);
  __Pyx_GIVEREF(__pyx_tuple__46);
  __pyx_codeobj__47 = (PyObject*)__Pyx_PyCode_New(1, 0, 1, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__46, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_stringsource, __pyx_n_s_reduce_cython, 1, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__47)) __PYX_ERR(2, 1, __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__")
 */
  __pyx_tuple__48 = PyTuple_Pack(2, __pyx_n_s_self, __pyx_n_s_pyx_state); if (unlikely(!__pyx_tuple__48)) __PYX_ERR(2, 3, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__48);
  __Pyx_GIVEREF(__pyx_tuple__48);
  __pyx_codeobj__49 = (PyObject*)__Pyx_PyCode_New(2, 0, 2, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__48, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_stringsource, __pyx_n_s_setstate_cython, 3, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__49)) __PYX_ERR(2, 3, __pyx_L1_error)

  /* "lupa/_lupa.pyx":101
 * 
 * 
 * def lua_type(obj):             # <<<<<<<<<<<<<<
 *     """
 *     Return the Lua type name of a wrapped object as string, as provided
 */
  __pyx_tuple__50 = PyTuple_Pack(6, __pyx_n_s_obj, __pyx_n_s_lua_object, __pyx_n_s_L, __pyx_n_s_old_top, __pyx_n_s_lua_type_name, __pyx_n_s_ltype); if (unlikely(!__pyx_tuple__50)) __PYX_ERR(0, 101, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__50);
  __Pyx_GIVEREF(__pyx_tuple__50);
  __pyx_codeobj__51 = (PyObject*)__Pyx_PyCode_New(1, 0, 6, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__50, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_lupa__lupa_pyx, __pyx_n_s_lua_type, 101, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__51)) __PYX_ERR(0, 101, __pyx_L1_error)

  /* "lupa/_lupa.pyx":294
 *         return 0
 * 
 *     def eval(self, lua_code, *args):             # <<<<<<<<<<<<<<
 *         """Evaluate a Lua expression passed in a string.
 *         """
 */
  __pyx_tuple__52 = PyTuple_Pack(3, __pyx_n_s_self, __pyx_n_s_lua_code, __pyx_n_s_args); if (unlikely(!__pyx_tuple__52)) __PYX_ERR(0, 294, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__52);
  __Pyx_GIVEREF(__pyx_tuple__52);
  __pyx_codeobj__53 = (PyObject*)__Pyx_PyCode_New(2, 0, 3, 0, CO_OPTIMIZED|CO_NEWLOCALS|CO_VARARGS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__52, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_lupa__lupa_pyx, __pyx_n_s_eval, 294, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__53)) __PYX_ERR(0, 294, __pyx_L1_error)

  /* "lupa/_lupa.pyx":302
 *         return run_lua(self, b'return ' + lua_code, args)
 * 
 *     def execute(self, lua_code, *args):             # <<<<<<<<<<<<<<
 *         """Execute a Lua program passed in a string.
 *         """
 */
  __pyx_tuple__54 = PyTuple_Pack(3, __pyx_n_s_self, __pyx_n_s_lua_code, __pyx_n_s_args); if (unlikely(!__pyx_tuple__54)) __PYX_ERR(0, 302, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__54);
  __Pyx_GIVEREF(__pyx_tuple__54);
  __pyx_codeobj__55 = (PyObject*)__Pyx_PyCode_New(2, 0, 3, 0, CO_OPTIMIZED|CO_NEWLOCALS|CO_VARARGS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__54, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_lupa__lupa_pyx, __pyx_n_s_execute, 302, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__55)) __PYX_ERR(0, 302, __pyx_L1_error)

  /* "lupa/_lupa.pyx":310
 *         return run_lua(self, lua_code, args)
 * 
 *     def compile(self, lua_code):             # <<<<<<<<<<<<<<
 *         """Compile a Lua program into a callable Lua function.
 *         """
 */
  __pyx_tuple__56 = PyTuple_Pack(8, __pyx_n_s_self, __pyx_n_s_lua_code, __pyx_n_s_err, __pyx_n_s_L, __pyx_n_s_oldtop, __pyx_n_s_size, __pyx_n_s_status, __pyx_n_s_error); if (unlikely(!__pyx_tuple__56)) __PYX_ERR(0, 310, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__56);
  __Pyx_GIVEREF(__pyx_tuple__56);
  __pyx_codeobj__57 = (PyObject*)__Pyx_PyCode_New(2, 0, 8, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__56, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_lupa__lupa_pyx, __pyx_n_s_compile, 310, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__57)) __PYX_ERR(0, 310, __pyx_L1_error)

  /* "lupa/_lupa.pyx":332
 *             unlock_runtime(self)
 * 
 *     def require(self, modulename):             # <<<<<<<<<<<<<<
 *         """Load a Lua library into the runtime.
 *         """
 */
  __pyx_tuple__58 = PyTuple_Pack(4, __pyx_n_s_self, __pyx_n_s_modulename, __pyx_n_s_L, __pyx_n_s_old_top); if (unlikely(!__pyx_tuple__58)) __PYX_ERR(0, 332, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__58);
  __Pyx_GIVEREF(__pyx_tuple__58);
  __pyx_codeobj__59 = (PyObject*)__Pyx_PyCode_New(2, 0, 4, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__58, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_lupa__lupa_pyx, __pyx_n_s_require, 332, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__59)) __PYX_ERR(0, 332, __pyx_L1_error)

  /* "lupa/_lupa.pyx":350
 *             unlock_runtime(self)
 * 
 *     def globals(self):             # <<<<<<<<<<<<<<
 *         """Return the globals defined in this Lua runtime as a Lua
 *         table.
 */
  __pyx_tuple__60 = PyTuple_Pack(3, __pyx_n_s_self, __pyx_n_s_L, __pyx_n_s_old_top); if (unlikely(!__pyx_tuple__60)) __PYX_ERR(0, 350, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__60);
  __Pyx_GIVEREF(__pyx_tuple__60);
  __pyx_codeobj__61 = (PyObject*)__Pyx_PyCode_New(1, 0, 3, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__60, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_lupa__lupa_pyx, __pyx_n_s_globals, 350, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__61)) __PYX_ERR(0, 350, __pyx_L1_error)

  /* "lupa/_lupa.pyx":367
 *             unlock_runtime(self)
 * 
 *     def table(self, *items, **kwargs):             # <<<<<<<<<<<<<<
 *         """Create a new table with the provided items.  Positional
 *         arguments are placed in the table in order, keyword arguments
 */
  __pyx_tuple__62 = PyTuple_Pack(3, __pyx_n_s_self, __pyx_n_s_items, __pyx_n_s_kwargs); if (unlikely(!__pyx_tuple__62)) __PYX_ERR(0, 367, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__62);
  __Pyx_GIVEREF(__pyx_tuple__62);
  __pyx_codeobj__63 = (PyObject*)__Pyx_PyCode_New(1, 0, 3, 0, CO_OPTIMIZED|CO_NEWLOCALS|CO_VARARGS|CO_VARKEYWORDS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__62, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_lupa__lupa_pyx, __pyx_n_s_table, 367, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__63)) __PYX_ERR(0, 367, __pyx_L1_error)

  /* "lupa/_lupa.pyx":374
 *         return self.table_from(items, kwargs)
 * 
 *     def table_from(self, *args):             # <<<<<<<<<<<<<<
 *         """Create a new table from Python mapping or iterable.
 * 
 */
  __pyx_tuple__64 = PyTuple_Pack(9, __pyx_n_s_self, __pyx_n_s_args, __pyx_n_s_L, __pyx_n_s_i, __pyx_n_s_old_top, __pyx_n_s_obj, __pyx_n_s_key, __pyx_n_s_value, __pyx_n_s_arg); if (unlikely(!__pyx_tuple__64)) __PYX_ERR(0, 374, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__64);
  __Pyx_GIVEREF(__pyx_tuple__64);
  __pyx_codeobj__65 = (PyObject*)__Pyx_PyCode_New(1, 0, 9, 0, CO_OPTIMIZED|CO_NEWLOCALS|CO_VARARGS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__64, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_lupa__lupa_pyx, __pyx_n_s_table_from, 374, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__65)) __PYX_ERR(0, 374, __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):
 */
  __pyx_tuple__66 = PyTuple_Pack(1, __pyx_n_s_self); if (unlikely(!__pyx_tuple__66)) __PYX_ERR(2, 1, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__66);
  __Pyx_GIVEREF(__pyx_tuple__66);
  __pyx_codeobj__67 = (PyObject*)__Pyx_PyCode_New(1, 0, 1, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__66, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_stringsource, __pyx_n_s_reduce_cython, 1, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__67)) __PYX_ERR(2, 1, __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__")
 */
  __pyx_tuple__68 = PyTuple_Pack(2, __pyx_n_s_self, __pyx_n_s_pyx_state); if (unlikely(!__pyx_tuple__68)) __PYX_ERR(2, 3, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__68);
  __Pyx_GIVEREF(__pyx_tuple__68);
  __pyx_codeobj__69 = (PyObject*)__Pyx_PyCode_New(2, 0, 2, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__68, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_stringsource, __pyx_n_s_setstate_cython, 3, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__69)) __PYX_ERR(2, 3, __pyx_L1_error)

  /* "lupa/_lupa.pyx":462
 * # from Lua scripts
 * 
 * def unpacks_lua_table(func):             # <<<<<<<<<<<<<<
 *     """
 *     A decorator to make the decorated function receive kwargs
 */
  __pyx_tuple__70 = PyTuple_Pack(3, __pyx_n_s_func, __pyx_n_s_wrapper, __pyx_n_s_wrapper); if (unlikely(!__pyx_tuple__70)) __PYX_ERR(0, 462, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__70);
  __Pyx_GIVEREF(__pyx_tuple__70);
  __pyx_codeobj__71 = (PyObject*)__Pyx_PyCode_New(1, 0, 3, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__70, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_lupa__lupa_pyx, __pyx_n_s_unpacks_lua_table, 462, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__71)) __PYX_ERR(0, 462, __pyx_L1_error)

  /* "lupa/_lupa.pyx":488
 * 
 * 
 * def unpacks_lua_table_method(meth):             # <<<<<<<<<<<<<<
 *     """
 *     This is :func:`unpacks_lua_table` for methods
 */
  __pyx_tuple__72 = PyTuple_Pack(3, __pyx_n_s_meth, __pyx_n_s_wrapper, __pyx_n_s_wrapper); if (unlikely(!__pyx_tuple__72)) __PYX_ERR(0, 488, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__72);
  __Pyx_GIVEREF(__pyx_tuple__72);
  __pyx_codeobj__73 = (PyObject*)__Pyx_PyCode_New(1, 0, 3, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__72, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_lupa__lupa_pyx, __pyx_n_s_unpacks_lua_table_method, 488, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__73)) __PYX_ERR(0, 488, __pyx_L1_error)

  /* "(tree fragment)":1
 * def __reduce_cython__(self):             # <<<<<<<<<<<<<<
 *     raise TypeError("self._state cannot be converted to a Python object for pickling")
 * def __setstate_cython__(self, __pyx_state):
 */
  __pyx_tuple__74 = PyTuple_Pack(1, __pyx_n_s_self); if (unlikely(!__pyx_tuple__74)) __PYX_ERR(2, 1, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__74);
  __Pyx_GIVEREF(__pyx_tuple__74);
  __pyx_codeobj__75 = (PyObject*)__Pyx_PyCode_New(1, 0, 1, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__74, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_stringsource, __pyx_n_s_reduce_cython, 1, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__75)) __PYX_ERR(2, 1, __pyx_L1_error)

  /* "(tree fragment)":3
 * def __reduce_cython__(self):
 *     raise TypeError("self._state cannot be converted to a Python object for pickling")
 * def __setstate_cython__(self, __pyx_state):             # <<<<<<<<<<<<<<
 *     raise TypeError("self._state cannot be converted to a Python object for pickling")
 */
  __pyx_tuple__76 = PyTuple_Pack(2, __pyx_n_s_self, __pyx_n_s_pyx_state); if (unlikely(!__pyx_tuple__76)) __PYX_ERR(2, 3, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__76);
  __Pyx_GIVEREF(__pyx_tuple__76);
  __pyx_codeobj__77 = (PyObject*)__Pyx_PyCode_New(2, 0, 2, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__76, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_stringsource, __pyx_n_s_setstate_cython, 3, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__77)) __PYX_ERR(2, 3, __pyx_L1_error)

  /* "lupa/_lupa.pyx":736
 *         return _LuaIter(self, KEYS)
 * 
 *     def keys(self):             # <<<<<<<<<<<<<<
 *         """Returns an iterator over the keys of a table that this
 *         object represents.  Same as iter(obj).
 */
  __pyx_tuple__78 = PyTuple_Pack(1, __pyx_n_s_self); if (unlikely(!__pyx_tuple__78)) __PYX_ERR(0, 736, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__78);
  __Pyx_GIVEREF(__pyx_tuple__78);
  __pyx_codeobj__79 = (PyObject*)__Pyx_PyCode_New(1, 0, 1, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__78, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_lupa__lupa_pyx, __pyx_n_s_keys, 736, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__79)) __PYX_ERR(0, 736, __pyx_L1_error)

  /* "lupa/_lupa.pyx":742
 *         return _LuaIter(self, KEYS)
 * 
 *     def values(self):             # <<<<<<<<<<<<<<
 *         """Returns an iterator over the values of a table that this
 *         object represents.
 */
  __pyx_tuple__80 = PyTuple_Pack(1, __pyx_n_s_self); if (unlikely(!__pyx_tuple__80)) __PYX_ERR(0, 742, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__80);
  __Pyx_GIVEREF(__pyx_tuple__80);
  __pyx_codeobj__81 = (PyObject*)__Pyx_PyCode_New(1, 0, 1, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__80, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_lupa__lupa_pyx, __pyx_n_s_values, 742, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__81)) __PYX_ERR(0, 742, __pyx_L1_error)

  /* "lupa/_lupa.pyx":748
 *         return _LuaIter(self, VALUES)
 * 
 *     def items(self):             # <<<<<<<<<<<<<<
 *         """Returns an iterator over the key-value pairs of a table
 *         that this object represents.
 */
  __pyx_tuple__82 = PyTuple_Pack(1, __pyx_n_s_self); if (unlikely(!__pyx_tuple__82)) __PYX_ERR(0, 748, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__82);
  __Pyx_GIVEREF(__pyx_tuple__82);
  __pyx_codeobj__83 = (PyObject*)__Pyx_PyCode_New(1, 0, 1, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__82, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_lupa__lupa_pyx, __pyx_n_s_items, 748, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__83)) __PYX_ERR(0, 748, __pyx_L1_error)

  /* "(tree fragment)":1
 * def __reduce_cython__(self):             # <<<<<<<<<<<<<<
 *     raise TypeError("self._state cannot be converted to a Python object for pickling")
 * def __setstate_cython__(self, __pyx_state):
 */
  __pyx_tuple__84 = PyTuple_Pack(1, __pyx_n_s_self); if (unlikely(!__pyx_tuple__84)) __PYX_ERR(2, 1, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__84);
  __Pyx_GIVEREF(__pyx_tuple__84);
  __pyx_codeobj__85 = (PyObject*)__Pyx_PyCode_New(1, 0, 1, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__84, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_stringsource, __pyx_n_s_reduce_cython, 1, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__85)) __PYX_ERR(2, 1, __pyx_L1_error)

  /* "(tree fragment)":3
 * def __reduce_cython__(self):
 *     raise TypeError("self._state cannot be converted to a Python object for pickling")
 * def __setstate_cython__(self, __pyx_state):             # <<<<<<<<<<<<<<
 *     raise TypeError("self._state cannot be converted to a Python object for pickling")
 */
  __pyx_tuple__86 = PyTuple_Pack(2, __pyx_n_s_self, __pyx_n_s_pyx_state); if (unlikely(!__pyx_tuple__86)) __PYX_ERR(2, 3, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__86);
  __Pyx_GIVEREF(__pyx_tuple__86);
  __pyx_codeobj__87 = (PyObject*)__Pyx_PyCode_New(2, 0, 2, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__86, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_stringsource, __pyx_n_s_setstate_cython, 3, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__87)) __PYX_ERR(2, 3, __pyx_L1_error)

  /* "lupa/_lupa.pyx":826
 *     """A Lua function (which may become a coroutine).
 *     """
 *     def coroutine(self, *args):             # <<<<<<<<<<<<<<
 *         """Create a Lua coroutine from a Lua function and call it with
 *         the passed parameters to start it up.
 */
  __pyx_tuple__88 = PyTuple_Pack(6, __pyx_n_s_self, __pyx_n_s_args, __pyx_n_s_L, __pyx_n_s_co, __pyx_n_s_thread, __pyx_n_s_old_top); if (unlikely(!__pyx_tuple__88)) __PYX_ERR(0, 826, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__88);
  __Pyx_GIVEREF(__pyx_tuple__88);
  __pyx_codeobj__89 = (PyObject*)__Pyx_PyCode_New(1, 0, 6, 0, CO_OPTIMIZED|CO_NEWLOCALS|CO_VARARGS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__88, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_lupa__lupa_pyx, __pyx_n_s_coroutine, 826, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__89)) __PYX_ERR(0, 826, __pyx_L1_error)

  /* "(tree fragment)":1
 * def __reduce_cython__(self):             # <<<<<<<<<<<<<<
 *     raise TypeError("self._state cannot be converted to a Python object for pickling")
 * def __setstate_cython__(self, __pyx_state):
 */
  __pyx_tuple__90 = PyTuple_Pack(1, __pyx_n_s_self); if (unlikely(!__pyx_tuple__90)) __PYX_ERR(2, 1, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__90);
  __Pyx_GIVEREF(__pyx_tuple__90);
  __pyx_codeobj__91 = (PyObject*)__Pyx_PyCode_New(1, 0, 1, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__90, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_stringsource, __pyx_n_s_reduce_cython, 1, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__91)) __PYX_ERR(2, 1, __pyx_L1_error)

  /* "(tree fragment)":3
 * def __reduce_cython__(self):
 *     raise TypeError("self._state cannot be converted to a Python object for pickling")
 * def __setstate_cython__(self, __pyx_state):             # <<<<<<<<<<<<<<
 *     raise TypeError("self._state cannot be converted to a Python object for pickling")
 */
  __pyx_tuple__92 = PyTuple_Pack(2, __pyx_n_s_self, __pyx_n_s_pyx_state); if (unlikely(!__pyx_tuple__92)) __PYX_ERR(2, 3, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__92);
  __Pyx_GIVEREF(__pyx_tuple__92);
  __pyx_codeobj__93 = (PyObject*)__Pyx_PyCode_New(2, 0, 2, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__92, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_stringsource, __pyx_n_s_setstate_cython, 3, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__93)) __PYX_ERR(2, 3, __pyx_L1_error)

  /* "(tree fragment)":1
 * def __reduce_cython__(self):             # <<<<<<<<<<<<<<
 *     raise TypeError("self._state cannot be converted to a Python object for pickling")
 * def __setstate_cython__(self, __pyx_state):
 */
  __pyx_tuple__94 = PyTuple_Pack(1, __pyx_n_s_self); if (unlikely(!__pyx_tuple__94)) __PYX_ERR(2, 1, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__94);
  __Pyx_GIVEREF(__pyx_tuple__94);
  __pyx_codeobj__95 = (PyObject*)__Pyx_PyCode_New(1, 0, 1, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__94, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_stringsource, __pyx_n_s_reduce_cython, 1, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__95)) __PYX_ERR(2, 1, __pyx_L1_error)

  /* "(tree fragment)":3
 * def __reduce_cython__(self):
 *     raise TypeError("self._state cannot be converted to a Python object for pickling")
 * def __setstate_cython__(self, __pyx_state):             # <<<<<<<<<<<<<<
 *     raise TypeError("self._state cannot be converted to a Python object for pickling")
 */
  __pyx_tuple__96 = PyTuple_Pack(2, __pyx_n_s_self, __pyx_n_s_pyx_state); if (unlikely(!__pyx_tuple__96)) __PYX_ERR(2, 3, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__96);
  __Pyx_GIVEREF(__pyx_tuple__96);
  __pyx_codeobj__97 = (PyObject*)__Pyx_PyCode_New(2, 0, 2, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__96, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_stringsource, __pyx_n_s_setstate_cython, 3, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__97)) __PYX_ERR(2, 3, __pyx_L1_error)

  /* "lupa/_lupa.pyx":892
 *         return resume_lua_thread(self, args)
 * 
 *     def send(self, value):             # <<<<<<<<<<<<<<
 *         """Send a value into the coroutine.  If the value is a tuple,
 *         send the unpacked elements.
 */
  __pyx_tuple__98 = PyTuple_Pack(2, __pyx_n_s_self, __pyx_n_s_value); if (unlikely(!__pyx_tuple__98)) __PYX_ERR(0, 892, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__98);
  __Pyx_GIVEREF(__pyx_tuple__98);
  __pyx_codeobj__99 = (PyObject*)__Pyx_PyCode_New(2, 0, 2, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__98, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_lupa__lupa_pyx, __pyx_n_s_send, 892, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__99)) __PYX_ERR(0, 892, __pyx_L1_error)

  /* "(tree fragment)":1
 * def __reduce_cython__(self):             # <<<<<<<<<<<<<<
 *     raise TypeError("self._co_state,self._state cannot be converted to a Python object for pickling")
 * def __setstate_cython__(self, __pyx_state):
 */
  __pyx_tuple__100 = PyTuple_Pack(1, __pyx_n_s_self); if (unlikely(!__pyx_tuple__100)) __PYX_ERR(2, 1, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__100);
  __Pyx_GIVEREF(__pyx_tuple__100);
  __pyx_codeobj__101 = (PyObject*)__Pyx_PyCode_New(1, 0, 1, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__100, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_stringsource, __pyx_n_s_reduce_cython, 1, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__101)) __PYX_ERR(2, 1, __pyx_L1_error)

  /* "(tree fragment)":3
 * def __reduce_cython__(self):
 *     raise TypeError("self._co_state,self._state cannot be converted to a Python object for pickling")
 * def __setstate_cython__(self, __pyx_state):             # <<<<<<<<<<<<<<
 *     raise TypeError("self._co_state,self._state cannot be converted to a Python object for pickling")
 */
  __pyx_tuple__102 = PyTuple_Pack(2, __pyx_n_s_self, __pyx_n_s_pyx_state); if (unlikely(!__pyx_tuple__102)) __PYX_ERR(2, 3, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__102);
  __Pyx_GIVEREF(__pyx_tuple__102);
  __pyx_codeobj__103 = (PyObject*)__Pyx_PyCode_New(2, 0, 2, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__102, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_stringsource, __pyx_n_s_setstate_cython, 3, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__103)) __PYX_ERR(2, 3, __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):
 */
  __pyx_tuple__104 = PyTuple_Pack(1, __pyx_n_s_self); if (unlikely(!__pyx_tuple__104)) __PYX_ERR(2, 1, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__104);
  __Pyx_GIVEREF(__pyx_tuple__104);
  __pyx_codeobj__105 = (PyObject*)__Pyx_PyCode_New(1, 0, 1, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__104, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_stringsource, __pyx_n_s_reduce_cython, 1, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__105)) __PYX_ERR(2, 1, __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__")
 */
  __pyx_tuple__106 = PyTuple_Pack(2, __pyx_n_s_self, __pyx_n_s_pyx_state); if (unlikely(!__pyx_tuple__106)) __PYX_ERR(2, 3, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__106);
  __Pyx_GIVEREF(__pyx_tuple__106);
  __pyx_codeobj__107 = (PyObject*)__Pyx_PyCode_New(2, 0, 2, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__106, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_stringsource, __pyx_n_s_setstate_cython, 3, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__107)) __PYX_ERR(2, 3, __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):
 */
  __pyx_tuple__108 = PyTuple_Pack(1, __pyx_n_s_self); if (unlikely(!__pyx_tuple__108)) __PYX_ERR(2, 1, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__108);
  __Pyx_GIVEREF(__pyx_tuple__108);
  __pyx_codeobj__109 = (PyObject*)__Pyx_PyCode_New(1, 0, 1, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__108, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_stringsource, __pyx_n_s_reduce_cython, 1, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__109)) __PYX_ERR(2, 1, __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__")
 */
  __pyx_tuple__110 = PyTuple_Pack(2, __pyx_n_s_self, __pyx_n_s_pyx_state); if (unlikely(!__pyx_tuple__110)) __PYX_ERR(2, 3, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__110);
  __Pyx_GIVEREF(__pyx_tuple__110);
  __pyx_codeobj__111 = (PyObject*)__Pyx_PyCode_New(2, 0, 2, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__110, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_stringsource, __pyx_n_s_setstate_cython, 3, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__111)) __PYX_ERR(2, 3, __pyx_L1_error)

  /* "lupa/_lupa.pyx":1110
 * 
 * 
 * def as_attrgetter(obj):             # <<<<<<<<<<<<<<
 *     cdef _PyProtocolWrapper wrap = _PyProtocolWrapper.__new__(_PyProtocolWrapper)
 *     wrap._obj = obj
 */
  __pyx_tuple__112 = PyTuple_Pack(2, __pyx_n_s_obj, __pyx_n_s_wrap); if (unlikely(!__pyx_tuple__112)) __PYX_ERR(0, 1110, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__112);
  __Pyx_GIVEREF(__pyx_tuple__112);
  __pyx_codeobj__113 = (PyObject*)__Pyx_PyCode_New(1, 0, 2, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__112, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_lupa__lupa_pyx, __pyx_n_s_as_attrgetter, 1110, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__113)) __PYX_ERR(0, 1110, __pyx_L1_error)

  /* "lupa/_lupa.pyx":1116
 *     return wrap
 * 
 * def as_itemgetter(obj):             # <<<<<<<<<<<<<<
 *     cdef _PyProtocolWrapper wrap = _PyProtocolWrapper.__new__(_PyProtocolWrapper)
 *     wrap._obj = obj
 */
  __pyx_tuple__114 = PyTuple_Pack(2, __pyx_n_s_obj, __pyx_n_s_wrap); if (unlikely(!__pyx_tuple__114)) __PYX_ERR(0, 1116, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__114);
  __Pyx_GIVEREF(__pyx_tuple__114);
  __pyx_codeobj__115 = (PyObject*)__Pyx_PyCode_New(1, 0, 2, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__114, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_lupa__lupa_pyx, __pyx_n_s_as_itemgetter, 1116, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__115)) __PYX_ERR(0, 1116, __pyx_L1_error)
  __Pyx_RefNannyFinishContext();
  return 0;
  __pyx_L1_error:;
  __Pyx_RefNannyFinishContext();
  return -1;
}

static CYTHON_SMALL_CODE int __Pyx_InitGlobals(void) {
  __pyx_umethod_PyList_Type_pop.type = (PyObject*)&PyList_Type;
  if (__Pyx_InitStrings(__pyx_string_tab) < 0) __PYX_ERR(0, 1, __pyx_L1_error);
  __pyx_int_1 = PyInt_FromLong(1); if (unlikely(!__pyx_int_1)) __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_v_4lupa_5_lupa_exc_info = Py_None; Py_INCREF(Py_None);
  __pyx_v_4lupa_5_lupa_Mapping = Py_None; Py_INCREF(Py_None);
  __pyx_v_4lupa_5_lupa_wraps = Py_None; Py_INCREF(Py_None);
  __pyx_v_4lupa_5_lupa_builtins = Py_None; Py_INCREF(Py_None);
  __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
  __Pyx_RefNannySetupContext("__Pyx_modinit_function_export_code", 0);
  /*--- Function export code ---*/
  __Pyx_RefNannyFinishContext();
  return 0;
}

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 ---*/
  if (PyType_Ready(&__pyx_type_4lupa_5_lupa_FastRLock) < 0) __PYX_ERR(1, 5, __pyx_L1_error)
  #if PY_VERSION_HEX < 0x030800B1
  __pyx_type_4lupa_5_lupa_FastRLock.tp_print = 0;
  #endif
  if ((CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP) && likely(!__pyx_type_4lupa_5_lupa_FastRLock.tp_dictoffset && __pyx_type_4lupa_5_lupa_FastRLock.tp_getattro == PyObject_GenericGetAttr)) {
    __pyx_type_4lupa_5_lupa_FastRLock.tp_getattro = __Pyx_PyObject_GenericGetAttr;
  }
  if (PyObject_SetAttr(__pyx_m, __pyx_n_s_FastRLock, (PyObject *)&__pyx_type_4lupa_5_lupa_FastRLock) < 0) __PYX_ERR(1, 5, __pyx_L1_error)
  if (__Pyx_setup_reduce((PyObject*)&__pyx_type_4lupa_5_lupa_FastRLock) < 0) __PYX_ERR(1, 5, __pyx_L1_error)
  __pyx_ptype_4lupa_5_lupa_FastRLock = &__pyx_type_4lupa_5_lupa_FastRLock;
  __pyx_vtabptr_4lupa_5_lupa_LuaRuntime = &__pyx_vtable_4lupa_5_lupa_LuaRuntime;
  __pyx_vtable_4lupa_5_lupa_LuaRuntime.reraise_on_exception = (int (*)(struct __pyx_obj_4lupa_5_lupa_LuaRuntime *))__pyx_f_4lupa_5_lupa_10LuaRuntime_reraise_on_exception;
  __pyx_vtable_4lupa_5_lupa_LuaRuntime.store_raised_exception = (int (*)(struct __pyx_obj_4lupa_5_lupa_LuaRuntime *, lua_State *, PyObject *))__pyx_f_4lupa_5_lupa_10LuaRuntime_store_raised_exception;
  __pyx_vtable_4lupa_5_lupa_LuaRuntime.register_py_object = (int (*)(struct __pyx_obj_4lupa_5_lupa_LuaRuntime *, PyObject *, PyObject *, PyObject *))__pyx_f_4lupa_5_lupa_10LuaRuntime_register_py_object;
  __pyx_vtable_4lupa_5_lupa_LuaRuntime.init_python_lib = (int (*)(struct __pyx_obj_4lupa_5_lupa_LuaRuntime *, int, int))__pyx_f_4lupa_5_lupa_10LuaRuntime_init_python_lib;
  if (PyType_Ready(&__pyx_type_4lupa_5_lupa_LuaRuntime) < 0) __PYX_ERR(0, 136, __pyx_L1_error)
  #if PY_VERSION_HEX < 0x030800B1
  __pyx_type_4lupa_5_lupa_LuaRuntime.tp_print = 0;
  #endif
  if ((CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP) && likely(!__pyx_type_4lupa_5_lupa_LuaRuntime.tp_dictoffset && __pyx_type_4lupa_5_lupa_LuaRuntime.tp_getattro == PyObject_GenericGetAttr)) {
    __pyx_type_4lupa_5_lupa_LuaRuntime.tp_getattro = __Pyx_PyObject_GenericGetAttr;
  }
  if (__Pyx_SetVtable(__pyx_type_4lupa_5_lupa_LuaRuntime.tp_dict, __pyx_vtabptr_4lupa_5_lupa_LuaRuntime) < 0) __PYX_ERR(0, 136, __pyx_L1_error)
  if (PyObject_SetAttr(__pyx_m, __pyx_n_s_LuaRuntime, (PyObject *)&__pyx_type_4lupa_5_lupa_LuaRuntime) < 0) __PYX_ERR(0, 136, __pyx_L1_error)
  if (__Pyx_setup_reduce((PyObject*)&__pyx_type_4lupa_5_lupa_LuaRuntime) < 0) __PYX_ERR(0, 136, __pyx_L1_error)
  __pyx_ptype_4lupa_5_lupa_LuaRuntime = &__pyx_type_4lupa_5_lupa_LuaRuntime;
  __pyx_vtabptr_4lupa_5_lupa__LuaObject = &__pyx_vtable_4lupa_5_lupa__LuaObject;
  __pyx_vtable_4lupa_5_lupa__LuaObject.push_lua_object = (int (*)(struct __pyx_obj_4lupa_5_lupa__LuaObject *))__pyx_f_4lupa_5_lupa_10_LuaObject_push_lua_object;
  __pyx_vtable_4lupa_5_lupa__LuaObject._len = (size_t (*)(struct __pyx_obj_4lupa_5_lupa__LuaObject *))__pyx_f_4lupa_5_lupa_10_LuaObject__len;
  __pyx_vtable_4lupa_5_lupa__LuaObject._getitem = (PyObject *(*)(struct __pyx_obj_4lupa_5_lupa__LuaObject *, PyObject *, int))__pyx_f_4lupa_5_lupa_10_LuaObject__getitem;
  if (PyType_Ready(&__pyx_type_4lupa_5_lupa__LuaObject) < 0) __PYX_ERR(0, 549, __pyx_L1_error)
  #if PY_VERSION_HEX < 0x030800B1
  __pyx_type_4lupa_5_lupa__LuaObject.tp_print = 0;
  #endif
  if (__Pyx_SetVtable(__pyx_type_4lupa_5_lupa__LuaObject.tp_dict, __pyx_vtabptr_4lupa_5_lupa__LuaObject) < 0) __PYX_ERR(0, 549, __pyx_L1_error)
  if (__Pyx_setup_reduce((PyObject*)&__pyx_type_4lupa_5_lupa__LuaObject) < 0) __PYX_ERR(0, 549, __pyx_L1_error)
  __pyx_ptype_4lupa_5_lupa__LuaObject = &__pyx_type_4lupa_5_lupa__LuaObject;
  __pyx_vtabptr_4lupa_5_lupa__LuaTable = &__pyx_vtable_4lupa_5_lupa__LuaTable;
  __pyx_vtable_4lupa_5_lupa__LuaTable.__pyx_base = *__pyx_vtabptr_4lupa_5_lupa__LuaObject;
  __pyx_vtable_4lupa_5_lupa__LuaTable._setitem = (int (*)(struct __pyx_obj_4lupa_5_lupa__LuaTable *, PyObject *, PyObject *))__pyx_f_4lupa_5_lupa_9_LuaTable__setitem;
  __pyx_vtable_4lupa_5_lupa__LuaTable._delitem = (PyObject *(*)(struct __pyx_obj_4lupa_5_lupa__LuaTable *, PyObject *))__pyx_f_4lupa_5_lupa_9_LuaTable__delitem;
  __pyx_type_4lupa_5_lupa__LuaTable.tp_base = __pyx_ptype_4lupa_5_lupa__LuaObject;
  if (PyType_Ready(&__pyx_type_4lupa_5_lupa__LuaTable) < 0) __PYX_ERR(0, 732, __pyx_L1_error)
  #if PY_VERSION_HEX < 0x030800B1
  __pyx_type_4lupa_5_lupa__LuaTable.tp_print = 0;
  #endif
  if ((CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP) && likely(!__pyx_type_4lupa_5_lupa__LuaTable.tp_dictoffset && __pyx_type_4lupa_5_lupa__LuaTable.tp_getattro == PyObject_GenericGetAttr)) {
    __pyx_type_4lupa_5_lupa__LuaTable.tp_getattro = __Pyx_PyObject_GenericGetAttrNoDict;
  }
  if (__Pyx_SetVtable(__pyx_type_4lupa_5_lupa__LuaTable.tp_dict, __pyx_vtabptr_4lupa_5_lupa__LuaTable) < 0) __PYX_ERR(0, 732, __pyx_L1_error)
  if (__Pyx_setup_reduce((PyObject*)&__pyx_type_4lupa_5_lupa__LuaTable) < 0) __PYX_ERR(0, 732, __pyx_L1_error)
  __pyx_ptype_4lupa_5_lupa__LuaTable = &__pyx_type_4lupa_5_lupa__LuaTable;
  __pyx_vtabptr_4lupa_5_lupa__LuaFunction = &__pyx_vtable_4lupa_5_lupa__LuaFunction;
  __pyx_vtable_4lupa_5_lupa__LuaFunction.__pyx_base = *__pyx_vtabptr_4lupa_5_lupa__LuaObject;
  __pyx_type_4lupa_5_lupa__LuaFunction.tp_base = __pyx_ptype_4lupa_5_lupa__LuaObject;
  if (PyType_Ready(&__pyx_type_4lupa_5_lupa__LuaFunction) < 0) __PYX_ERR(0, 823, __pyx_L1_error)
  #if PY_VERSION_HEX < 0x030800B1
  __pyx_type_4lupa_5_lupa__LuaFunction.tp_print = 0;
  #endif
  if ((CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP) && likely(!__pyx_type_4lupa_5_lupa__LuaFunction.tp_dictoffset && __pyx_type_4lupa_5_lupa__LuaFunction.tp_getattro == PyObject_GenericGetAttr)) {
    __pyx_type_4lupa_5_lupa__LuaFunction.tp_getattro = __Pyx_PyObject_GenericGetAttr;
  }
  if (__Pyx_SetVtable(__pyx_type_4lupa_5_lupa__LuaFunction.tp_dict, __pyx_vtabptr_4lupa_5_lupa__LuaFunction) < 0) __PYX_ERR(0, 823, __pyx_L1_error)
  if (__Pyx_setup_reduce((PyObject*)&__pyx_type_4lupa_5_lupa__LuaFunction) < 0) __PYX_ERR(0, 823, __pyx_L1_error)
  __pyx_ptype_4lupa_5_lupa__LuaFunction = &__pyx_type_4lupa_5_lupa__LuaFunction;
  __pyx_vtabptr_4lupa_5_lupa__LuaCoroutineFunction = &__pyx_vtable_4lupa_5_lupa__LuaCoroutineFunction;
  __pyx_vtable_4lupa_5_lupa__LuaCoroutineFunction.__pyx_base = *__pyx_vtabptr_4lupa_5_lupa__LuaFunction;
  __pyx_type_4lupa_5_lupa__LuaCoroutineFunction.tp_base = __pyx_ptype_4lupa_5_lupa__LuaFunction;
  if (PyType_Ready(&__pyx_type_4lupa_5_lupa__LuaCoroutineFunction) < 0) __PYX_ERR(0, 862, __pyx_L1_error)
  #if PY_VERSION_HEX < 0x030800B1
  __pyx_type_4lupa_5_lupa__LuaCoroutineFunction.tp_print = 0;
  #endif
  if ((CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP) && likely(!__pyx_type_4lupa_5_lupa__LuaCoroutineFunction.tp_dictoffset && __pyx_type_4lupa_5_lupa__LuaCoroutineFunction.tp_getattro == PyObject_GenericGetAttr)) {
    __pyx_type_4lupa_5_lupa__LuaCoroutineFunction.tp_getattro = __Pyx_PyObject_GenericGetAttrNoDict;
  }
  if (__Pyx_SetVtable(__pyx_type_4lupa_5_lupa__LuaCoroutineFunction.tp_dict, __pyx_vtabptr_4lupa_5_lupa__LuaCoroutineFunction) < 0) __PYX_ERR(0, 862, __pyx_L1_error)
  if (__Pyx_setup_reduce((PyObject*)&__pyx_type_4lupa_5_lupa__LuaCoroutineFunction) < 0) __PYX_ERR(0, 862, __pyx_L1_error)
  __pyx_ptype_4lupa_5_lupa__LuaCoroutineFunction = &__pyx_type_4lupa_5_lupa__LuaCoroutineFunction;
  __pyx_vtabptr_4lupa_5_lupa__LuaThread = &__pyx_vtable_4lupa_5_lupa__LuaThread;
  __pyx_vtable_4lupa_5_lupa__LuaThread.__pyx_base = *__pyx_vtabptr_4lupa_5_lupa__LuaObject;
  __pyx_type_4lupa_5_lupa__LuaThread.tp_base = __pyx_ptype_4lupa_5_lupa__LuaObject;
  if (PyType_Ready(&__pyx_type_4lupa_5_lupa__LuaThread) < 0) __PYX_ERR(0, 877, __pyx_L1_error)
  #if PY_VERSION_HEX < 0x030800B1
  __pyx_type_4lupa_5_lupa__LuaThread.tp_print = 0;
  #endif
  if ((CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP) && likely(!__pyx_type_4lupa_5_lupa__LuaThread.tp_dictoffset && __pyx_type_4lupa_5_lupa__LuaThread.tp_getattro == PyObject_GenericGetAttr)) {
    __pyx_type_4lupa_5_lupa__LuaThread.tp_getattro = __Pyx_PyObject_GenericGetAttrNoDict;
  }
  if (__Pyx_SetVtable(__pyx_type_4lupa_5_lupa__LuaThread.tp_dict, __pyx_vtabptr_4lupa_5_lupa__LuaThread) < 0) __PYX_ERR(0, 877, __pyx_L1_error)
  if (__Pyx_setup_reduce((PyObject*)&__pyx_type_4lupa_5_lupa__LuaThread) < 0) __PYX_ERR(0, 877, __pyx_L1_error)
  __pyx_ptype_4lupa_5_lupa__LuaThread = &__pyx_type_4lupa_5_lupa__LuaThread;
  if (PyType_Ready(&__pyx_type_4lupa_5_lupa__LuaIter) < 0) __PYX_ERR(0, 990, __pyx_L1_error)
  #if PY_VERSION_HEX < 0x030800B1
  __pyx_type_4lupa_5_lupa__LuaIter.tp_print = 0;
  #endif
  if ((CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP) && likely(!__pyx_type_4lupa_5_lupa__LuaIter.tp_dictoffset && __pyx_type_4lupa_5_lupa__LuaIter.tp_getattro == PyObject_GenericGetAttr)) {
    __pyx_type_4lupa_5_lupa__LuaIter.tp_getattro = __Pyx_PyObject_GenericGetAttrNoDict;
  }
  if (__Pyx_setup_reduce((PyObject*)&__pyx_type_4lupa_5_lupa__LuaIter) < 0) __PYX_ERR(0, 990, __pyx_L1_error)
  __pyx_ptype_4lupa_5_lupa__LuaIter = &__pyx_type_4lupa_5_lupa__LuaIter;
  if (PyType_Ready(&__pyx_type_4lupa_5_lupa__PyProtocolWrapper) < 0) __PYX_ERR(0, 1101, __pyx_L1_error)
  #if PY_VERSION_HEX < 0x030800B1
  __pyx_type_4lupa_5_lupa__PyProtocolWrapper.tp_print = 0;
  #endif
  if ((CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP) && likely(!__pyx_type_4lupa_5_lupa__PyProtocolWrapper.tp_dictoffset && __pyx_type_4lupa_5_lupa__PyProtocolWrapper.tp_getattro == PyObject_GenericGetAttr)) {
    __pyx_type_4lupa_5_lupa__PyProtocolWrapper.tp_getattro = __Pyx_PyObject_GenericGetAttrNoDict;
  }
  if (__Pyx_setup_reduce((PyObject*)&__pyx_type_4lupa_5_lupa__PyProtocolWrapper) < 0) __PYX_ERR(0, 1101, __pyx_L1_error)
  __pyx_ptype_4lupa_5_lupa__PyProtocolWrapper = &__pyx_type_4lupa_5_lupa__PyProtocolWrapper;
  if (PyType_Ready(&__pyx_type_4lupa_5_lupa___pyx_scope_struct__unpacks_lua_table) < 0) __PYX_ERR(0, 462, __pyx_L1_error)
  #if PY_VERSION_HEX < 0x030800B1
  __pyx_type_4lupa_5_lupa___pyx_scope_struct__unpacks_lua_table.tp_print = 0;
  #endif
  if ((CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP) && likely(!__pyx_type_4lupa_5_lupa___pyx_scope_struct__unpacks_lua_table.tp_dictoffset && __pyx_type_4lupa_5_lupa___pyx_scope_struct__unpacks_lua_table.tp_getattro == PyObject_GenericGetAttr)) {
    __pyx_type_4lupa_5_lupa___pyx_scope_struct__unpacks_lua_table.tp_getattro = __Pyx_PyObject_GenericGetAttrNoDict;
  }
  __pyx_ptype_4lupa_5_lupa___pyx_scope_struct__unpacks_lua_table = &__pyx_type_4lupa_5_lupa___pyx_scope_struct__unpacks_lua_table;
  if (PyType_Ready(&__pyx_type_4lupa_5_lupa___pyx_scope_struct_1_unpacks_lua_table_method) < 0) __PYX_ERR(0, 488, __pyx_L1_error)
  #if PY_VERSION_HEX < 0x030800B1
  __pyx_type_4lupa_5_lupa___pyx_scope_struct_1_unpacks_lua_table_method.tp_print = 0;
  #endif
  if ((CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP) && likely(!__pyx_type_4lupa_5_lupa___pyx_scope_struct_1_unpacks_lua_table_method.tp_dictoffset && __pyx_type_4lupa_5_lupa___pyx_scope_struct_1_unpacks_lua_table_method.tp_getattro == PyObject_GenericGetAttr)) {
    __pyx_type_4lupa_5_lupa___pyx_scope_struct_1_unpacks_lua_table_method.tp_getattro = __Pyx_PyObject_GenericGetAttrNoDict;
  }
  __pyx_ptype_4lupa_5_lupa___pyx_scope_struct_1_unpacks_lua_table_method = &__pyx_type_4lupa_5_lupa___pyx_scope_struct_1_unpacks_lua_table_method;
  __Pyx_RefNannyFinishContext();
  return 0;
  __pyx_L1_error:;
  __Pyx_RefNannyFinishContext();
  return -1;
}

static int __Pyx_modinit_type_import_code(void) {
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__Pyx_modinit_type_import_code", 0);
  /*--- Type import code ---*/
  __pyx_t_1 = PyImport_ImportModule(__Pyx_BUILTIN_MODULE_NAME); if (unlikely(!__pyx_t_1)) __PYX_ERR(3, 9, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_ptype_7cpython_4type_type = __Pyx_ImportType(__pyx_t_1, __Pyx_BUILTIN_MODULE_NAME, "type", 
  #if defined(PYPY_VERSION_NUM) && PYPY_VERSION_NUM < 0x050B0000
  sizeof(PyTypeObject),
  #else
  sizeof(PyHeapTypeObject),
  #endif
  __Pyx_ImportType_CheckSize_Warn);
   if (!__pyx_ptype_7cpython_4type_type) __PYX_ERR(3, 9, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = PyImport_ImportModule(__Pyx_BUILTIN_MODULE_NAME); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 8, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_ptype_7cpython_4bool_bool = __Pyx_ImportType(__pyx_t_1, __Pyx_BUILTIN_MODULE_NAME, "bool", sizeof(PyBoolObject), __Pyx_ImportType_CheckSize_Warn);
   if (!__pyx_ptype_7cpython_4bool_bool) __PYX_ERR(4, 8, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = PyImport_ImportModule(__Pyx_BUILTIN_MODULE_NAME); if (unlikely(!__pyx_t_1)) __PYX_ERR(5, 15, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_ptype_7cpython_7complex_complex = __Pyx_ImportType(__pyx_t_1, __Pyx_BUILTIN_MODULE_NAME, "complex", sizeof(PyComplexObject), __Pyx_ImportType_CheckSize_Warn);
   if (!__pyx_ptype_7cpython_7complex_complex) __PYX_ERR(5, 15, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_RefNannyFinishContext();
  return 0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_RefNannyFinishContext();
  return -1;
}

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 init_lupa(void) CYTHON_SMALL_CODE; /*proto*/
__Pyx_PyMODINIT_FUNC init_lupa(void)
#else
__Pyx_PyMODINIT_FUNC PyInit__lupa(void) CYTHON_SMALL_CODE; /*proto*/
__Pyx_PyMODINIT_FUNC PyInit__lupa(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__lupa(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;
  PyObject *__pyx_t_5 = NULL;
  int __pyx_t_6;
  PyObject *__pyx_t_7 = NULL;
  PyObject *__pyx_t_8 = NULL;
  PyObject *__pyx_t_9 = NULL;
  luaL_Reg __pyx_t_10;
  luaL_Reg __pyx_t_11;
  luaL_Reg __pyx_t_12;
  luaL_Reg __pyx_t_13;
  luaL_Reg __pyx_t_14;
  luaL_Reg __pyx_t_15;
  static luaL_Reg __pyx_t_16[6];
  luaL_Reg __pyx_t_17;
  static luaL_Reg __pyx_t_18[7];
  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 '_lupa' 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__lupa(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("_lupa", __pyx_methods, __pyx_k_A_fast_Python_wrapper_around_Lu, 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_lupa___lupa) {
    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, "lupa._lupa")) {
      if (unlikely(PyDict_SetItemString(modules, "lupa._lupa", __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();
  (void)__Pyx_modinit_function_export_code();
  if (unlikely(__Pyx_modinit_type_init_code() < 0)) __PYX_ERR(0, 1, __pyx_L1_error)
  if (unlikely(__Pyx_modinit_type_import_code() < 0)) __PYX_ERR(0, 1, __pyx_L1_error)
  (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

  /* "lupa/_lupa.pyx":42
 * 
 * cdef object exc_info
 * from sys import exc_info             # <<<<<<<<<<<<<<
 * 
 * cdef object Mapping
 */
  __pyx_t_1 = PyList_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 42, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_INCREF(__pyx_n_s_exc_info);
  __Pyx_GIVEREF(__pyx_n_s_exc_info);
  PyList_SET_ITEM(__pyx_t_1, 0, __pyx_n_s_exc_info);
  __pyx_t_2 = __Pyx_Import(__pyx_n_s_sys, __pyx_t_1, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 42, __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_exc_info); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 42, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_INCREF(__pyx_t_1);
  __Pyx_XGOTREF(__pyx_v_4lupa_5_lupa_exc_info);
  __Pyx_DECREF_SET(__pyx_v_4lupa_5_lupa_exc_info, __pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "lupa/_lupa.pyx":45
 * 
 * cdef object Mapping
 * try:             # <<<<<<<<<<<<<<
 *     from collections.abc import Mapping
 * except ImportError:
 */
  {
    __Pyx_PyThreadState_declare
    __Pyx_PyThreadState_assign
    __Pyx_ExceptionSave(&__pyx_t_3, &__pyx_t_4, &__pyx_t_5);
    __Pyx_XGOTREF(__pyx_t_3);
    __Pyx_XGOTREF(__pyx_t_4);
    __Pyx_XGOTREF(__pyx_t_5);
    /*try:*/ {

      /* "lupa/_lupa.pyx":46
 * cdef object Mapping
 * try:
 *     from collections.abc import Mapping             # <<<<<<<<<<<<<<
 * except ImportError:
 *     from collections import Mapping  # Py2
 */
      __pyx_t_2 = PyList_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 46, __pyx_L2_error)
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_INCREF(__pyx_n_s_Mapping);
      __Pyx_GIVEREF(__pyx_n_s_Mapping);
      PyList_SET_ITEM(__pyx_t_2, 0, __pyx_n_s_Mapping);
      __pyx_t_1 = __Pyx_Import(__pyx_n_s_collections_abc, __pyx_t_2, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 46, __pyx_L2_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __pyx_t_2 = __Pyx_ImportFrom(__pyx_t_1, __pyx_n_s_Mapping); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 46, __pyx_L2_error)
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_2);
      __Pyx_XGOTREF(__pyx_v_4lupa_5_lupa_Mapping);
      __Pyx_DECREF_SET(__pyx_v_4lupa_5_lupa_Mapping, __pyx_t_2);
      __Pyx_GIVEREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

      /* "lupa/_lupa.pyx":45
 * 
 * cdef object Mapping
 * try:             # <<<<<<<<<<<<<<
 *     from collections.abc import Mapping
 * except ImportError:
 */
    }
    __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
    goto __pyx_L7_try_end;
    __pyx_L2_error:;
    __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;

    /* "lupa/_lupa.pyx":47
 * try:
 *     from collections.abc import Mapping
 * except ImportError:             # <<<<<<<<<<<<<<
 *     from collections import Mapping  # Py2
 * 
 */
    __pyx_t_6 = __Pyx_PyErr_ExceptionMatches(__pyx_builtin_ImportError);
    if (__pyx_t_6) {
      __Pyx_AddTraceback("lupa._lupa", __pyx_clineno, __pyx_lineno, __pyx_filename);
      if (__Pyx_GetException(&__pyx_t_1, &__pyx_t_2, &__pyx_t_7) < 0) __PYX_ERR(0, 47, __pyx_L4_except_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_GOTREF(__pyx_t_7);

      /* "lupa/_lupa.pyx":48
 *     from collections.abc import Mapping
 * except ImportError:
 *     from collections import Mapping  # Py2             # <<<<<<<<<<<<<<
 * 
 * cdef object wraps
 */
      __pyx_t_8 = PyList_New(1); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 48, __pyx_L4_except_error)
      __Pyx_GOTREF(__pyx_t_8);
      __Pyx_INCREF(__pyx_n_s_Mapping);
      __Pyx_GIVEREF(__pyx_n_s_Mapping);
      PyList_SET_ITEM(__pyx_t_8, 0, __pyx_n_s_Mapping);
      __pyx_t_9 = __Pyx_Import(__pyx_n_s_collections, __pyx_t_8, 0); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 48, __pyx_L4_except_error)
      __Pyx_GOTREF(__pyx_t_9);
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      __pyx_t_8 = __Pyx_ImportFrom(__pyx_t_9, __pyx_n_s_Mapping); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 48, __pyx_L4_except_error)
      __Pyx_GOTREF(__pyx_t_8);
      __Pyx_INCREF(__pyx_t_8);
      __Pyx_XGOTREF(__pyx_v_4lupa_5_lupa_Mapping);
      __Pyx_DECREF_SET(__pyx_v_4lupa_5_lupa_Mapping, __pyx_t_8);
      __Pyx_GIVEREF(__pyx_t_8);
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
      __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
      __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
      goto __pyx_L3_exception_handled;
    }
    goto __pyx_L4_except_error;
    __pyx_L4_except_error:;

    /* "lupa/_lupa.pyx":45
 * 
 * cdef object Mapping
 * try:             # <<<<<<<<<<<<<<
 *     from collections.abc import Mapping
 * except ImportError:
 */
    __Pyx_XGIVEREF(__pyx_t_3);
    __Pyx_XGIVEREF(__pyx_t_4);
    __Pyx_XGIVEREF(__pyx_t_5);
    __Pyx_ExceptionReset(__pyx_t_3, __pyx_t_4, __pyx_t_5);
    goto __pyx_L1_error;
    __pyx_L3_exception_handled:;
    __Pyx_XGIVEREF(__pyx_t_3);
    __Pyx_XGIVEREF(__pyx_t_4);
    __Pyx_XGIVEREF(__pyx_t_5);
    __Pyx_ExceptionReset(__pyx_t_3, __pyx_t_4, __pyx_t_5);
    __pyx_L7_try_end:;
  }

  /* "lupa/_lupa.pyx":51
 * 
 * cdef object wraps
 * from functools import wraps             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_t_7 = PyList_New(1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 51, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  __Pyx_INCREF(__pyx_n_s_wraps);
  __Pyx_GIVEREF(__pyx_n_s_wraps);
  PyList_SET_ITEM(__pyx_t_7, 0, __pyx_n_s_wraps);
  __pyx_t_2 = __Pyx_Import(__pyx_n_s_functools, __pyx_t_7, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 51, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  __pyx_t_7 = __Pyx_ImportFrom(__pyx_t_2, __pyx_n_s_wraps); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 51, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  __Pyx_INCREF(__pyx_t_7);
  __Pyx_XGOTREF(__pyx_v_4lupa_5_lupa_wraps);
  __Pyx_DECREF_SET(__pyx_v_4lupa_5_lupa_wraps, __pyx_t_7);
  __Pyx_GIVEREF(__pyx_t_7);
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "lupa/_lupa.pyx":54
 * 
 * 
 * __all__ = ['LUA_VERSION', 'LuaRuntime', 'LuaError', 'LuaSyntaxError',             # <<<<<<<<<<<<<<
 *            'as_itemgetter', 'as_attrgetter', 'lua_type',
 *            'unpacks_lua_table', 'unpacks_lua_table_method']
 */
  __pyx_t_2 = PyList_New(9); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 54, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_INCREF(__pyx_n_s_LUA_VERSION);
  __Pyx_GIVEREF(__pyx_n_s_LUA_VERSION);
  PyList_SET_ITEM(__pyx_t_2, 0, __pyx_n_s_LUA_VERSION);
  __Pyx_INCREF(__pyx_n_s_LuaRuntime);
  __Pyx_GIVEREF(__pyx_n_s_LuaRuntime);
  PyList_SET_ITEM(__pyx_t_2, 1, __pyx_n_s_LuaRuntime);
  __Pyx_INCREF(__pyx_n_s_LuaError);
  __Pyx_GIVEREF(__pyx_n_s_LuaError);
  PyList_SET_ITEM(__pyx_t_2, 2, __pyx_n_s_LuaError);
  __Pyx_INCREF(__pyx_n_s_LuaSyntaxError);
  __Pyx_GIVEREF(__pyx_n_s_LuaSyntaxError);
  PyList_SET_ITEM(__pyx_t_2, 3, __pyx_n_s_LuaSyntaxError);
  __Pyx_INCREF(__pyx_n_s_as_itemgetter);
  __Pyx_GIVEREF(__pyx_n_s_as_itemgetter);
  PyList_SET_ITEM(__pyx_t_2, 4, __pyx_n_s_as_itemgetter);
  __Pyx_INCREF(__pyx_n_s_as_attrgetter);
  __Pyx_GIVEREF(__pyx_n_s_as_attrgetter);
  PyList_SET_ITEM(__pyx_t_2, 5, __pyx_n_s_as_attrgetter);
  __Pyx_INCREF(__pyx_n_s_lua_type);
  __Pyx_GIVEREF(__pyx_n_s_lua_type);
  PyList_SET_ITEM(__pyx_t_2, 6, __pyx_n_s_lua_type);
  __Pyx_INCREF(__pyx_n_s_unpacks_lua_table);
  __Pyx_GIVEREF(__pyx_n_s_unpacks_lua_table);
  PyList_SET_ITEM(__pyx_t_2, 7, __pyx_n_s_unpacks_lua_table);
  __Pyx_INCREF(__pyx_n_s_unpacks_lua_table_method);
  __Pyx_GIVEREF(__pyx_n_s_unpacks_lua_table_method);
  PyList_SET_ITEM(__pyx_t_2, 8, __pyx_n_s_unpacks_lua_table_method);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_all, __pyx_t_2) < 0) __PYX_ERR(0, 54, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "lupa/_lupa.pyx":59
 * 
 * cdef object builtins
 * try:             # <<<<<<<<<<<<<<
 *     import __builtin__ as builtins
 * except ImportError:
 */
  {
    __Pyx_PyThreadState_declare
    __Pyx_PyThreadState_assign
    __Pyx_ExceptionSave(&__pyx_t_5, &__pyx_t_4, &__pyx_t_3);
    __Pyx_XGOTREF(__pyx_t_5);
    __Pyx_XGOTREF(__pyx_t_4);
    __Pyx_XGOTREF(__pyx_t_3);
    /*try:*/ {

      /* "lupa/_lupa.pyx":60
 * cdef object builtins
 * try:
 *     import __builtin__ as builtins             # <<<<<<<<<<<<<<
 * except ImportError:
 *     import builtins
 */
      __pyx_t_2 = __Pyx_Import(__pyx_n_s_builtin, 0, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 60, __pyx_L10_error)
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_XGOTREF(__pyx_v_4lupa_5_lupa_builtins);
      __Pyx_DECREF_SET(__pyx_v_4lupa_5_lupa_builtins, __pyx_t_2);
      __Pyx_GIVEREF(__pyx_t_2);
      __pyx_t_2 = 0;

      /* "lupa/_lupa.pyx":59
 * 
 * cdef object builtins
 * try:             # <<<<<<<<<<<<<<
 *     import __builtin__ as builtins
 * except ImportError:
 */
    }
    __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
    goto __pyx_L15_try_end;
    __pyx_L10_error:;
    __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
    __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
    __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;

    /* "lupa/_lupa.pyx":61
 * try:
 *     import __builtin__ as builtins
 * except ImportError:             # <<<<<<<<<<<<<<
 *     import builtins
 * 
 */
    __pyx_t_6 = __Pyx_PyErr_ExceptionMatches(__pyx_builtin_ImportError);
    if (__pyx_t_6) {
      __Pyx_AddTraceback("lupa._lupa", __pyx_clineno, __pyx_lineno, __pyx_filename);
      if (__Pyx_GetException(&__pyx_t_2, &__pyx_t_7, &__pyx_t_1) < 0) __PYX_ERR(0, 61, __pyx_L12_except_error)
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_GOTREF(__pyx_t_7);
      __Pyx_GOTREF(__pyx_t_1);

      /* "lupa/_lupa.pyx":62
 *     import __builtin__ as builtins
 * except ImportError:
 *     import builtins             # <<<<<<<<<<<<<<
 * 
 * DEF POBJECT = b"POBJECT" # as used by LunaticPython
 */
      __pyx_t_9 = __Pyx_Import(__pyx_n_s_builtins, 0, 0); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 62, __pyx_L12_except_error)
      __Pyx_GOTREF(__pyx_t_9);
      __Pyx_XGOTREF(__pyx_v_4lupa_5_lupa_builtins);
      __Pyx_DECREF_SET(__pyx_v_4lupa_5_lupa_builtins, __pyx_t_9);
      __Pyx_GIVEREF(__pyx_t_9);
      __pyx_t_9 = 0;
      __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
      __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
      goto __pyx_L11_exception_handled;
    }
    goto __pyx_L12_except_error;
    __pyx_L12_except_error:;

    /* "lupa/_lupa.pyx":59
 * 
 * cdef object builtins
 * try:             # <<<<<<<<<<<<<<
 *     import __builtin__ as builtins
 * except ImportError:
 */
    __Pyx_XGIVEREF(__pyx_t_5);
    __Pyx_XGIVEREF(__pyx_t_4);
    __Pyx_XGIVEREF(__pyx_t_3);
    __Pyx_ExceptionReset(__pyx_t_5, __pyx_t_4, __pyx_t_3);
    goto __pyx_L1_error;
    __pyx_L11_exception_handled:;
    __Pyx_XGIVEREF(__pyx_t_5);
    __Pyx_XGIVEREF(__pyx_t_4);
    __Pyx_XGIVEREF(__pyx_t_3);
    __Pyx_ExceptionReset(__pyx_t_5, __pyx_t_4, __pyx_t_3);
    __pyx_L15_try_end:;
  }

  /* "lupa/lock.pxi":34
 *             self._real_lock = NULL
 * 
 *     def acquire(self, bint blocking=True):             # <<<<<<<<<<<<<<
 *         return lock_lock(self, pythread.PyThread_get_thread_ident(), blocking)
 * 
 */
  __pyx_t_1 = __Pyx_CyFunction_New(&__pyx_mdef_4lupa_5_lupa_9FastRLock_5acquire, __Pyx_CYFUNCTION_CCLASS, __pyx_n_s_FastRLock_acquire, NULL, __pyx_n_s_lupa__lupa, __pyx_d, ((PyObject *)__pyx_codeobj__37)); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 34, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem((PyObject *)__pyx_ptype_4lupa_5_lupa_FastRLock->tp_dict, __pyx_n_s_acquire, __pyx_t_1) < 0) __PYX_ERR(1, 34, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  PyType_Modified(__pyx_ptype_4lupa_5_lupa_FastRLock);

  /* "lupa/lock.pxi":37
 *         return lock_lock(self, pythread.PyThread_get_thread_ident(), blocking)
 * 
 *     def release(self):             # <<<<<<<<<<<<<<
 *         if self._owner != pythread.PyThread_get_thread_ident():
 *             raise RuntimeError("cannot release un-acquired lock")
 */
  __pyx_t_1 = __Pyx_CyFunction_New(&__pyx_mdef_4lupa_5_lupa_9FastRLock_7release, __Pyx_CYFUNCTION_CCLASS, __pyx_n_s_FastRLock_release, NULL, __pyx_n_s_lupa__lupa, __pyx_d, ((PyObject *)__pyx_codeobj__39)); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 37, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem((PyObject *)__pyx_ptype_4lupa_5_lupa_FastRLock->tp_dict, __pyx_n_s_release, __pyx_t_1) < 0) __PYX_ERR(1, 37, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  PyType_Modified(__pyx_ptype_4lupa_5_lupa_FastRLock);

  /* "lupa/lock.pxi":44
 *     # compatibility with RLock
 * 
 *     def __enter__(self):             # <<<<<<<<<<<<<<
 *         # self.acquire()
 *         return lock_lock(self, pythread.PyThread_get_thread_ident(), True)
 */
  __pyx_t_1 = __Pyx_CyFunction_New(&__pyx_mdef_4lupa_5_lupa_9FastRLock_9__enter__, __Pyx_CYFUNCTION_CCLASS, __pyx_n_s_FastRLock___enter, NULL, __pyx_n_s_lupa__lupa, __pyx_d, ((PyObject *)__pyx_codeobj__41)); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 44, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem((PyObject *)__pyx_ptype_4lupa_5_lupa_FastRLock->tp_dict, __pyx_n_s_enter, __pyx_t_1) < 0) __PYX_ERR(1, 44, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  PyType_Modified(__pyx_ptype_4lupa_5_lupa_FastRLock);

  /* "lupa/lock.pxi":48
 *         return lock_lock(self, pythread.PyThread_get_thread_ident(), True)
 * 
 *     def __exit__(self, t, v, tb):             # <<<<<<<<<<<<<<
 *         # self.release()
 *         if self._owner != pythread.PyThread_get_thread_ident():
 */
  __pyx_t_1 = __Pyx_CyFunction_New(&__pyx_mdef_4lupa_5_lupa_9FastRLock_11__exit__, __Pyx_CYFUNCTION_CCLASS, __pyx_n_s_FastRLock___exit, NULL, __pyx_n_s_lupa__lupa, __pyx_d, ((PyObject *)__pyx_codeobj__43)); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 48, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem((PyObject *)__pyx_ptype_4lupa_5_lupa_FastRLock->tp_dict, __pyx_n_s_exit, __pyx_t_1) < 0) __PYX_ERR(1, 48, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  PyType_Modified(__pyx_ptype_4lupa_5_lupa_FastRLock);

  /* "lupa/lock.pxi":54
 *         unlock_lock(self)
 * 
 *     def _is_owned(self):             # <<<<<<<<<<<<<<
 *         return self._owner == pythread.PyThread_get_thread_ident()
 * 
 */
  __pyx_t_1 = __Pyx_CyFunction_New(&__pyx_mdef_4lupa_5_lupa_9FastRLock_13_is_owned, __Pyx_CYFUNCTION_CCLASS, __pyx_n_s_FastRLock__is_owned, NULL, __pyx_n_s_lupa__lupa, __pyx_d, ((PyObject *)__pyx_codeobj__45)); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 54, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem((PyObject *)__pyx_ptype_4lupa_5_lupa_FastRLock->tp_dict, __pyx_n_s_is_owned, __pyx_t_1) < 0) __PYX_ERR(1, 54, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  PyType_Modified(__pyx_ptype_4lupa_5_lupa_FastRLock);

  /* "(tree fragment)":1
 * def __reduce_cython__(self):             # <<<<<<<<<<<<<<
 *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")
 * def __setstate_cython__(self, __pyx_state):
 */
  __pyx_t_1 = __Pyx_CyFunction_New(&__pyx_mdef_4lupa_5_lupa_9FastRLock_15__reduce_cython__, __Pyx_CYFUNCTION_CCLASS, __pyx_n_s_FastRLock___reduce_cython, NULL, __pyx_n_s_lupa__lupa, __pyx_d, ((PyObject *)__pyx_codeobj__47)); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 1, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_reduce_cython, __pyx_t_1) < 0) __PYX_ERR(2, 1, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "(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__")
 */
  __pyx_t_1 = __Pyx_CyFunction_New(&__pyx_mdef_4lupa_5_lupa_9FastRLock_17__setstate_cython__, __Pyx_CYFUNCTION_CCLASS, __pyx_n_s_FastRLock___setstate_cython, NULL, __pyx_n_s_lupa__lupa, __pyx_d, ((PyObject *)__pyx_codeobj__49)); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 3, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_setstate_cython, __pyx_t_1) < 0) __PYX_ERR(2, 3, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "lupa/_lupa.pyx":87
 * 
 * 
 * cdef int _LUA_VERSION = lua.read_lua_version(NULL)             # <<<<<<<<<<<<<<
 * LUA_VERSION = (_LUA_VERSION // 100, _LUA_VERSION % 100)
 * 
 */
  __pyx_v_4lupa_5_lupa__LUA_VERSION = read_lua_version(NULL);

  /* "lupa/_lupa.pyx":88
 * 
 * cdef int _LUA_VERSION = lua.read_lua_version(NULL)
 * LUA_VERSION = (_LUA_VERSION // 100, _LUA_VERSION % 100)             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_t_1 = __Pyx_PyInt_From_long(__Pyx_div_long(__pyx_v_4lupa_5_lupa__LUA_VERSION, 0x64)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 88, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_7 = __Pyx_PyInt_From_long(__Pyx_mod_long(__pyx_v_4lupa_5_lupa__LUA_VERSION, 0x64)); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 88, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 88, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_GIVEREF(__pyx_t_1);
  PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_7);
  PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_t_7);
  __pyx_t_1 = 0;
  __pyx_t_7 = 0;
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_LUA_VERSION, __pyx_t_2) < 0) __PYX_ERR(0, 88, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "lupa/_lupa.pyx":91
 * 
 * 
 * class LuaError(Exception):             # <<<<<<<<<<<<<<
 *     """Base class for errors in the Lua runtime.
 *     """
 */
  __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 91, __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_7 = __Pyx_CalculateMetaclass(NULL, __pyx_t_2); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 91, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  __pyx_t_1 = __Pyx_Py3MetaclassPrepare(__pyx_t_7, __pyx_t_2, __pyx_n_s_LuaError, __pyx_n_s_LuaError, (PyObject *) NULL, __pyx_n_s_lupa__lupa, __pyx_kp_s_Base_class_for_errors_in_the_Lua); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 91, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_9 = __Pyx_Py3ClassCreate(__pyx_t_7, __pyx_n_s_LuaError, __pyx_t_2, __pyx_t_1, NULL, 0, 0); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 91, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_9);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_LuaError, __pyx_t_9) < 0) __PYX_ERR(0, 91, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "lupa/_lupa.pyx":96
 * 
 * 
 * class LuaSyntaxError(LuaError):             # <<<<<<<<<<<<<<
 *     """Syntax error in Lua code.
 *     """
 */
  __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_LuaError); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 96, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_7 = PyTuple_New(1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 96, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  __Pyx_GIVEREF(__pyx_t_2);
  PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_2);
  __pyx_t_2 = 0;
  __pyx_t_2 = __Pyx_CalculateMetaclass(NULL, __pyx_t_7); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 96, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_1 = __Pyx_Py3MetaclassPrepare(__pyx_t_2, __pyx_t_7, __pyx_n_s_LuaSyntaxError, __pyx_n_s_LuaSyntaxError, (PyObject *) NULL, __pyx_n_s_lupa__lupa, __pyx_kp_s_Syntax_error_in_Lua_code); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 96, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_9 = __Pyx_Py3ClassCreate(__pyx_t_2, __pyx_n_s_LuaSyntaxError, __pyx_t_7, __pyx_t_1, NULL, 0, 0); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 96, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_9);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_LuaSyntaxError, __pyx_t_9) < 0) __PYX_ERR(0, 96, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;

  /* "lupa/_lupa.pyx":101
 * 
 * 
 * def lua_type(obj):             # <<<<<<<<<<<<<<
 *     """
 *     Return the Lua type name of a wrapped object as string, as provided
 */
  __pyx_t_7 = __Pyx_CyFunction_New(&__pyx_mdef_4lupa_5_lupa_1lua_type, 0, __pyx_n_s_lua_type, NULL, __pyx_n_s_lupa__lupa, __pyx_d, ((PyObject *)__pyx_codeobj__51)); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 101, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_lua_type, __pyx_t_7) < 0) __PYX_ERR(0, 101, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;

  /* "lupa/_lupa.pyx":294
 *         return 0
 * 
 *     def eval(self, lua_code, *args):             # <<<<<<<<<<<<<<
 *         """Evaluate a Lua expression passed in a string.
 *         """
 */
  __pyx_t_7 = __Pyx_CyFunction_New(&__pyx_mdef_4lupa_5_lupa_10LuaRuntime_5eval, __Pyx_CYFUNCTION_CCLASS, __pyx_n_s_LuaRuntime_eval, NULL, __pyx_n_s_lupa__lupa, __pyx_d, ((PyObject *)__pyx_codeobj__53)); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 294, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  if (PyDict_SetItem((PyObject *)__pyx_ptype_4lupa_5_lupa_LuaRuntime->tp_dict, __pyx_n_s_eval, __pyx_t_7) < 0) __PYX_ERR(0, 294, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  PyType_Modified(__pyx_ptype_4lupa_5_lupa_LuaRuntime);

  /* "lupa/_lupa.pyx":302
 *         return run_lua(self, b'return ' + lua_code, args)
 * 
 *     def execute(self, lua_code, *args):             # <<<<<<<<<<<<<<
 *         """Execute a Lua program passed in a string.
 *         """
 */
  __pyx_t_7 = __Pyx_CyFunction_New(&__pyx_mdef_4lupa_5_lupa_10LuaRuntime_7execute, __Pyx_CYFUNCTION_CCLASS, __pyx_n_s_LuaRuntime_execute, NULL, __pyx_n_s_lupa__lupa, __pyx_d, ((PyObject *)__pyx_codeobj__55)); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 302, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  if (PyDict_SetItem((PyObject *)__pyx_ptype_4lupa_5_lupa_LuaRuntime->tp_dict, __pyx_n_s_execute, __pyx_t_7) < 0) __PYX_ERR(0, 302, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  PyType_Modified(__pyx_ptype_4lupa_5_lupa_LuaRuntime);

  /* "lupa/_lupa.pyx":310
 *         return run_lua(self, lua_code, args)
 * 
 *     def compile(self, lua_code):             # <<<<<<<<<<<<<<
 *         """Compile a Lua program into a callable Lua function.
 *         """
 */
  __pyx_t_7 = __Pyx_CyFunction_New(&__pyx_mdef_4lupa_5_lupa_10LuaRuntime_9compile, __Pyx_CYFUNCTION_CCLASS, __pyx_n_s_LuaRuntime_compile, NULL, __pyx_n_s_lupa__lupa, __pyx_d, ((PyObject *)__pyx_codeobj__57)); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 310, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  if (PyDict_SetItem((PyObject *)__pyx_ptype_4lupa_5_lupa_LuaRuntime->tp_dict, __pyx_n_s_compile, __pyx_t_7) < 0) __PYX_ERR(0, 310, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  PyType_Modified(__pyx_ptype_4lupa_5_lupa_LuaRuntime);

  /* "lupa/_lupa.pyx":332
 *             unlock_runtime(self)
 * 
 *     def require(self, modulename):             # <<<<<<<<<<<<<<
 *         """Load a Lua library into the runtime.
 *         """
 */
  __pyx_t_7 = __Pyx_CyFunction_New(&__pyx_mdef_4lupa_5_lupa_10LuaRuntime_11require, __Pyx_CYFUNCTION_CCLASS, __pyx_n_s_LuaRuntime_require, NULL, __pyx_n_s_lupa__lupa, __pyx_d, ((PyObject *)__pyx_codeobj__59)); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 332, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  if (PyDict_SetItem((PyObject *)__pyx_ptype_4lupa_5_lupa_LuaRuntime->tp_dict, __pyx_n_s_require, __pyx_t_7) < 0) __PYX_ERR(0, 332, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  PyType_Modified(__pyx_ptype_4lupa_5_lupa_LuaRuntime);

  /* "lupa/_lupa.pyx":350
 *             unlock_runtime(self)
 * 
 *     def globals(self):             # <<<<<<<<<<<<<<
 *         """Return the globals defined in this Lua runtime as a Lua
 *         table.
 */
  __pyx_t_7 = __Pyx_CyFunction_New(&__pyx_mdef_4lupa_5_lupa_10LuaRuntime_13globals, __Pyx_CYFUNCTION_CCLASS, __pyx_n_s_LuaRuntime_globals, NULL, __pyx_n_s_lupa__lupa, __pyx_d, ((PyObject *)__pyx_codeobj__61)); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 350, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  if (PyDict_SetItem((PyObject *)__pyx_ptype_4lupa_5_lupa_LuaRuntime->tp_dict, __pyx_n_s_globals, __pyx_t_7) < 0) __PYX_ERR(0, 350, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  PyType_Modified(__pyx_ptype_4lupa_5_lupa_LuaRuntime);

  /* "lupa/_lupa.pyx":367
 *             unlock_runtime(self)
 * 
 *     def table(self, *items, **kwargs):             # <<<<<<<<<<<<<<
 *         """Create a new table with the provided items.  Positional
 *         arguments are placed in the table in order, keyword arguments
 */
  __pyx_t_7 = __Pyx_CyFunction_New(&__pyx_mdef_4lupa_5_lupa_10LuaRuntime_15table, __Pyx_CYFUNCTION_CCLASS, __pyx_n_s_LuaRuntime_table, NULL, __pyx_n_s_lupa__lupa, __pyx_d, ((PyObject *)__pyx_codeobj__63)); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 367, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  if (PyDict_SetItem((PyObject *)__pyx_ptype_4lupa_5_lupa_LuaRuntime->tp_dict, __pyx_n_s_table, __pyx_t_7) < 0) __PYX_ERR(0, 367, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  PyType_Modified(__pyx_ptype_4lupa_5_lupa_LuaRuntime);

  /* "lupa/_lupa.pyx":374
 *         return self.table_from(items, kwargs)
 * 
 *     def table_from(self, *args):             # <<<<<<<<<<<<<<
 *         """Create a new table from Python mapping or iterable.
 * 
 */
  __pyx_t_7 = __Pyx_CyFunction_New(&__pyx_mdef_4lupa_5_lupa_10LuaRuntime_17table_from, __Pyx_CYFUNCTION_CCLASS, __pyx_n_s_LuaRuntime_table_from, NULL, __pyx_n_s_lupa__lupa, __pyx_d, ((PyObject *)__pyx_codeobj__65)); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 374, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  if (PyDict_SetItem((PyObject *)__pyx_ptype_4lupa_5_lupa_LuaRuntime->tp_dict, __pyx_n_s_table_from, __pyx_t_7) < 0) __PYX_ERR(0, 374, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  PyType_Modified(__pyx_ptype_4lupa_5_lupa_LuaRuntime);

  /* "(tree fragment)":1
 * def __reduce_cython__(self):             # <<<<<<<<<<<<<<
 *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")
 * def __setstate_cython__(self, __pyx_state):
 */
  __pyx_t_7 = __Pyx_CyFunction_New(&__pyx_mdef_4lupa_5_lupa_10LuaRuntime_19__reduce_cython__, __Pyx_CYFUNCTION_CCLASS, __pyx_n_s_LuaRuntime___reduce_cython, NULL, __pyx_n_s_lupa__lupa, __pyx_d, ((PyObject *)__pyx_codeobj__67)); if (unlikely(!__pyx_t_7)) __PYX_ERR(2, 1, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_reduce_cython, __pyx_t_7) < 0) __PYX_ERR(2, 1, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;

  /* "(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__")
 */
  __pyx_t_7 = __Pyx_CyFunction_New(&__pyx_mdef_4lupa_5_lupa_10LuaRuntime_21__setstate_cython__, __Pyx_CYFUNCTION_CCLASS, __pyx_n_s_LuaRuntime___setstate_cython, NULL, __pyx_n_s_lupa__lupa, __pyx_d, ((PyObject *)__pyx_codeobj__69)); if (unlikely(!__pyx_t_7)) __PYX_ERR(2, 3, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_setstate_cython, __pyx_t_7) < 0) __PYX_ERR(2, 3, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;

  /* "lupa/_lupa.pyx":462
 * # from Lua scripts
 * 
 * def unpacks_lua_table(func):             # <<<<<<<<<<<<<<
 *     """
 *     A decorator to make the decorated function receive kwargs
 */
  __pyx_t_7 = __Pyx_CyFunction_New(&__pyx_mdef_4lupa_5_lupa_3unpacks_lua_table, 0, __pyx_n_s_unpacks_lua_table, NULL, __pyx_n_s_lupa__lupa, __pyx_d, ((PyObject *)__pyx_codeobj__71)); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 462, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_unpacks_lua_table, __pyx_t_7) < 0) __PYX_ERR(0, 462, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;

  /* "lupa/_lupa.pyx":488
 * 
 * 
 * def unpacks_lua_table_method(meth):             # <<<<<<<<<<<<<<
 *     """
 *     This is :func:`unpacks_lua_table` for methods
 */
  __pyx_t_7 = __Pyx_CyFunction_New(&__pyx_mdef_4lupa_5_lupa_5unpacks_lua_table_method, 0, __pyx_n_s_unpacks_lua_table_method, NULL, __pyx_n_s_lupa__lupa, __pyx_d, ((PyObject *)__pyx_codeobj__73)); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 488, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_unpacks_lua_table_method, __pyx_t_7) < 0) __PYX_ERR(0, 488, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;

  /* "(tree fragment)":1
 * def __reduce_cython__(self):             # <<<<<<<<<<<<<<
 *     raise TypeError("self._state cannot be converted to a Python object for pickling")
 * def __setstate_cython__(self, __pyx_state):
 */
  __pyx_t_7 = __Pyx_CyFunction_New(&__pyx_mdef_4lupa_5_lupa_10_LuaObject_21__reduce_cython__, __Pyx_CYFUNCTION_CCLASS, __pyx_n_s_LuaObject___reduce_cython, NULL, __pyx_n_s_lupa__lupa, __pyx_d, ((PyObject *)__pyx_codeobj__75)); if (unlikely(!__pyx_t_7)) __PYX_ERR(2, 1, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_reduce_cython, __pyx_t_7) < 0) __PYX_ERR(2, 1, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;

  /* "(tree fragment)":3
 * def __reduce_cython__(self):
 *     raise TypeError("self._state cannot be converted to a Python object for pickling")
 * def __setstate_cython__(self, __pyx_state):             # <<<<<<<<<<<<<<
 *     raise TypeError("self._state cannot be converted to a Python object for pickling")
 */
  __pyx_t_7 = __Pyx_CyFunction_New(&__pyx_mdef_4lupa_5_lupa_10_LuaObject_23__setstate_cython__, __Pyx_CYFUNCTION_CCLASS, __pyx_n_s_LuaObject___setstate_cython, NULL, __pyx_n_s_lupa__lupa, __pyx_d, ((PyObject *)__pyx_codeobj__77)); if (unlikely(!__pyx_t_7)) __PYX_ERR(2, 3, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_setstate_cython, __pyx_t_7) < 0) __PYX_ERR(2, 3, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;

  /* "lupa/_lupa.pyx":736
 *         return _LuaIter(self, KEYS)
 * 
 *     def keys(self):             # <<<<<<<<<<<<<<
 *         """Returns an iterator over the keys of a table that this
 *         object represents.  Same as iter(obj).
 */
  __pyx_t_7 = __Pyx_CyFunction_New(&__pyx_mdef_4lupa_5_lupa_9_LuaTable_3keys, __Pyx_CYFUNCTION_CCLASS, __pyx_n_s_LuaTable_keys, NULL, __pyx_n_s_lupa__lupa, __pyx_d, ((PyObject *)__pyx_codeobj__79)); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 736, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  if (PyDict_SetItem((PyObject *)__pyx_ptype_4lupa_5_lupa__LuaTable->tp_dict, __pyx_n_s_keys, __pyx_t_7) < 0) __PYX_ERR(0, 736, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  PyType_Modified(__pyx_ptype_4lupa_5_lupa__LuaTable);

  /* "lupa/_lupa.pyx":742
 *         return _LuaIter(self, KEYS)
 * 
 *     def values(self):             # <<<<<<<<<<<<<<
 *         """Returns an iterator over the values of a table that this
 *         object represents.
 */
  __pyx_t_7 = __Pyx_CyFunction_New(&__pyx_mdef_4lupa_5_lupa_9_LuaTable_5values, __Pyx_CYFUNCTION_CCLASS, __pyx_n_s_LuaTable_values, NULL, __pyx_n_s_lupa__lupa, __pyx_d, ((PyObject *)__pyx_codeobj__81)); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 742, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  if (PyDict_SetItem((PyObject *)__pyx_ptype_4lupa_5_lupa__LuaTable->tp_dict, __pyx_n_s_values, __pyx_t_7) < 0) __PYX_ERR(0, 742, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  PyType_Modified(__pyx_ptype_4lupa_5_lupa__LuaTable);

  /* "lupa/_lupa.pyx":748
 *         return _LuaIter(self, VALUES)
 * 
 *     def items(self):             # <<<<<<<<<<<<<<
 *         """Returns an iterator over the key-value pairs of a table
 *         that this object represents.
 */
  __pyx_t_7 = __Pyx_CyFunction_New(&__pyx_mdef_4lupa_5_lupa_9_LuaTable_7items, __Pyx_CYFUNCTION_CCLASS, __pyx_n_s_LuaTable_items, NULL, __pyx_n_s_lupa__lupa, __pyx_d, ((PyObject *)__pyx_codeobj__83)); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 748, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  if (PyDict_SetItem((PyObject *)__pyx_ptype_4lupa_5_lupa__LuaTable->tp_dict, __pyx_n_s_items, __pyx_t_7) < 0) __PYX_ERR(0, 748, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  PyType_Modified(__pyx_ptype_4lupa_5_lupa__LuaTable);

  /* "(tree fragment)":1
 * def __reduce_cython__(self):             # <<<<<<<<<<<<<<
 *     raise TypeError("self._state cannot be converted to a Python object for pickling")
 * def __setstate_cython__(self, __pyx_state):
 */
  __pyx_t_7 = __Pyx_CyFunction_New(&__pyx_mdef_4lupa_5_lupa_9_LuaTable_17__reduce_cython__, __Pyx_CYFUNCTION_CCLASS, __pyx_n_s_LuaTable___reduce_cython, NULL, __pyx_n_s_lupa__lupa, __pyx_d, ((PyObject *)__pyx_codeobj__85)); if (unlikely(!__pyx_t_7)) __PYX_ERR(2, 1, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_reduce_cython, __pyx_t_7) < 0) __PYX_ERR(2, 1, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;

  /* "(tree fragment)":3
 * def __reduce_cython__(self):
 *     raise TypeError("self._state cannot be converted to a Python object for pickling")
 * def __setstate_cython__(self, __pyx_state):             # <<<<<<<<<<<<<<
 *     raise TypeError("self._state cannot be converted to a Python object for pickling")
 */
  __pyx_t_7 = __Pyx_CyFunction_New(&__pyx_mdef_4lupa_5_lupa_9_LuaTable_19__setstate_cython__, __Pyx_CYFUNCTION_CCLASS, __pyx_n_s_LuaTable___setstate_cython, NULL, __pyx_n_s_lupa__lupa, __pyx_d, ((PyObject *)__pyx_codeobj__87)); if (unlikely(!__pyx_t_7)) __PYX_ERR(2, 3, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_setstate_cython, __pyx_t_7) < 0) __PYX_ERR(2, 3, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;

  /* "lupa/_lupa.pyx":826
 *     """A Lua function (which may become a coroutine).
 *     """
 *     def coroutine(self, *args):             # <<<<<<<<<<<<<<
 *         """Create a Lua coroutine from a Lua function and call it with
 *         the passed parameters to start it up.
 */
  __pyx_t_7 = __Pyx_CyFunction_New(&__pyx_mdef_4lupa_5_lupa_12_LuaFunction_1coroutine, __Pyx_CYFUNCTION_CCLASS, __pyx_n_s_LuaFunction_coroutine, NULL, __pyx_n_s_lupa__lupa, __pyx_d, ((PyObject *)__pyx_codeobj__89)); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 826, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  if (PyDict_SetItem((PyObject *)__pyx_ptype_4lupa_5_lupa__LuaFunction->tp_dict, __pyx_n_s_coroutine, __pyx_t_7) < 0) __PYX_ERR(0, 826, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  PyType_Modified(__pyx_ptype_4lupa_5_lupa__LuaFunction);

  /* "(tree fragment)":1
 * def __reduce_cython__(self):             # <<<<<<<<<<<<<<
 *     raise TypeError("self._state cannot be converted to a Python object for pickling")
 * def __setstate_cython__(self, __pyx_state):
 */
  __pyx_t_7 = __Pyx_CyFunction_New(&__pyx_mdef_4lupa_5_lupa_12_LuaFunction_3__reduce_cython__, __Pyx_CYFUNCTION_CCLASS, __pyx_n_s_LuaFunction___reduce_cython, NULL, __pyx_n_s_lupa__lupa, __pyx_d, ((PyObject *)__pyx_codeobj__91)); if (unlikely(!__pyx_t_7)) __PYX_ERR(2, 1, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_reduce_cython, __pyx_t_7) < 0) __PYX_ERR(2, 1, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;

  /* "(tree fragment)":3
 * def __reduce_cython__(self):
 *     raise TypeError("self._state cannot be converted to a Python object for pickling")
 * def __setstate_cython__(self, __pyx_state):             # <<<<<<<<<<<<<<
 *     raise TypeError("self._state cannot be converted to a Python object for pickling")
 */
  __pyx_t_7 = __Pyx_CyFunction_New(&__pyx_mdef_4lupa_5_lupa_12_LuaFunction_5__setstate_cython__, __Pyx_CYFUNCTION_CCLASS, __pyx_n_s_LuaFunction___setstate_cython, NULL, __pyx_n_s_lupa__lupa, __pyx_d, ((PyObject *)__pyx_codeobj__93)); if (unlikely(!__pyx_t_7)) __PYX_ERR(2, 3, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_setstate_cython, __pyx_t_7) < 0) __PYX_ERR(2, 3, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;

  /* "(tree fragment)":1
 * def __reduce_cython__(self):             # <<<<<<<<<<<<<<
 *     raise TypeError("self._state cannot be converted to a Python object for pickling")
 * def __setstate_cython__(self, __pyx_state):
 */
  __pyx_t_7 = __Pyx_CyFunction_New(&__pyx_mdef_4lupa_5_lupa_21_LuaCoroutineFunction_3__reduce_cython__, __Pyx_CYFUNCTION_CCLASS, __pyx_n_s_LuaCoroutineFunction___reduce_c, NULL, __pyx_n_s_lupa__lupa, __pyx_d, ((PyObject *)__pyx_codeobj__95)); if (unlikely(!__pyx_t_7)) __PYX_ERR(2, 1, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_reduce_cython, __pyx_t_7) < 0) __PYX_ERR(2, 1, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;

  /* "(tree fragment)":3
 * def __reduce_cython__(self):
 *     raise TypeError("self._state cannot be converted to a Python object for pickling")
 * def __setstate_cython__(self, __pyx_state):             # <<<<<<<<<<<<<<
 *     raise TypeError("self._state cannot be converted to a Python object for pickling")
 */
  __pyx_t_7 = __Pyx_CyFunction_New(&__pyx_mdef_4lupa_5_lupa_21_LuaCoroutineFunction_5__setstate_cython__, __Pyx_CYFUNCTION_CCLASS, __pyx_n_s_LuaCoroutineFunction___setstate, NULL, __pyx_n_s_lupa__lupa, __pyx_d, ((PyObject *)__pyx_codeobj__97)); if (unlikely(!__pyx_t_7)) __PYX_ERR(2, 3, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_setstate_cython, __pyx_t_7) < 0) __PYX_ERR(2, 3, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;

  /* "lupa/_lupa.pyx":892
 *         return resume_lua_thread(self, args)
 * 
 *     def send(self, value):             # <<<<<<<<<<<<<<
 *         """Send a value into the coroutine.  If the value is a tuple,
 *         send the unpacked elements.
 */
  __pyx_t_7 = __Pyx_CyFunction_New(&__pyx_mdef_4lupa_5_lupa_10_LuaThread_5send, __Pyx_CYFUNCTION_CCLASS, __pyx_n_s_LuaThread_send, NULL, __pyx_n_s_lupa__lupa, __pyx_d, ((PyObject *)__pyx_codeobj__99)); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 892, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  if (PyDict_SetItem((PyObject *)__pyx_ptype_4lupa_5_lupa__LuaThread->tp_dict, __pyx_n_s_send, __pyx_t_7) < 0) __PYX_ERR(0, 892, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  PyType_Modified(__pyx_ptype_4lupa_5_lupa__LuaThread);

  /* "(tree fragment)":1
 * def __reduce_cython__(self):             # <<<<<<<<<<<<<<
 *     raise TypeError("self._co_state,self._state cannot be converted to a Python object for pickling")
 * def __setstate_cython__(self, __pyx_state):
 */
  __pyx_t_7 = __Pyx_CyFunction_New(&__pyx_mdef_4lupa_5_lupa_10_LuaThread_9__reduce_cython__, __Pyx_CYFUNCTION_CCLASS, __pyx_n_s_LuaThread___reduce_cython, NULL, __pyx_n_s_lupa__lupa, __pyx_d, ((PyObject *)__pyx_codeobj__101)); if (unlikely(!__pyx_t_7)) __PYX_ERR(2, 1, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_reduce_cython, __pyx_t_7) < 0) __PYX_ERR(2, 1, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;

  /* "(tree fragment)":3
 * def __reduce_cython__(self):
 *     raise TypeError("self._co_state,self._state cannot be converted to a Python object for pickling")
 * def __setstate_cython__(self, __pyx_state):             # <<<<<<<<<<<<<<
 *     raise TypeError("self._co_state,self._state cannot be converted to a Python object for pickling")
 */
  __pyx_t_7 = __Pyx_CyFunction_New(&__pyx_mdef_4lupa_5_lupa_10_LuaThread_11__setstate_cython__, __Pyx_CYFUNCTION_CCLASS, __pyx_n_s_LuaThread___setstate_cython, NULL, __pyx_n_s_lupa__lupa, __pyx_d, ((PyObject *)__pyx_codeobj__103)); if (unlikely(!__pyx_t_7)) __PYX_ERR(2, 3, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_setstate_cython, __pyx_t_7) < 0) __PYX_ERR(2, 3, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;

  /* "(tree fragment)":1
 * def __reduce_cython__(self):             # <<<<<<<<<<<<<<
 *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")
 * def __setstate_cython__(self, __pyx_state):
 */
  __pyx_t_7 = __Pyx_CyFunction_New(&__pyx_mdef_4lupa_5_lupa_8_LuaIter_11__reduce_cython__, __Pyx_CYFUNCTION_CCLASS, __pyx_n_s_LuaIter___reduce_cython, NULL, __pyx_n_s_lupa__lupa, __pyx_d, ((PyObject *)__pyx_codeobj__105)); if (unlikely(!__pyx_t_7)) __PYX_ERR(2, 1, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_reduce_cython, __pyx_t_7) < 0) __PYX_ERR(2, 1, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;

  /* "(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__")
 */
  __pyx_t_7 = __Pyx_CyFunction_New(&__pyx_mdef_4lupa_5_lupa_8_LuaIter_13__setstate_cython__, __Pyx_CYFUNCTION_CCLASS, __pyx_n_s_LuaIter___setstate_cython, NULL, __pyx_n_s_lupa__lupa, __pyx_d, ((PyObject *)__pyx_codeobj__107)); if (unlikely(!__pyx_t_7)) __PYX_ERR(2, 3, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_setstate_cython, __pyx_t_7) < 0) __PYX_ERR(2, 3, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;

  /* "(tree fragment)":1
 * def __reduce_cython__(self):             # <<<<<<<<<<<<<<
 *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")
 * def __setstate_cython__(self, __pyx_state):
 */
  __pyx_t_7 = __Pyx_CyFunction_New(&__pyx_mdef_4lupa_5_lupa_18_PyProtocolWrapper_5__reduce_cython__, __Pyx_CYFUNCTION_CCLASS, __pyx_n_s_PyProtocolWrapper___reduce_cyth, NULL, __pyx_n_s_lupa__lupa, __pyx_d, ((PyObject *)__pyx_codeobj__109)); if (unlikely(!__pyx_t_7)) __PYX_ERR(2, 1, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_reduce_cython, __pyx_t_7) < 0) __PYX_ERR(2, 1, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;

  /* "(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__")
 */
  __pyx_t_7 = __Pyx_CyFunction_New(&__pyx_mdef_4lupa_5_lupa_18_PyProtocolWrapper_7__setstate_cython__, __Pyx_CYFUNCTION_CCLASS, __pyx_n_s_PyProtocolWrapper___setstate_cy, NULL, __pyx_n_s_lupa__lupa, __pyx_d, ((PyObject *)__pyx_codeobj__111)); if (unlikely(!__pyx_t_7)) __PYX_ERR(2, 3, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_setstate_cython, __pyx_t_7) < 0) __PYX_ERR(2, 3, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;

  /* "lupa/_lupa.pyx":1110
 * 
 * 
 * def as_attrgetter(obj):             # <<<<<<<<<<<<<<
 *     cdef _PyProtocolWrapper wrap = _PyProtocolWrapper.__new__(_PyProtocolWrapper)
 *     wrap._obj = obj
 */
  __pyx_t_7 = __Pyx_CyFunction_New(&__pyx_mdef_4lupa_5_lupa_7as_attrgetter, 0, __pyx_n_s_as_attrgetter, NULL, __pyx_n_s_lupa__lupa, __pyx_d, ((PyObject *)__pyx_codeobj__113)); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1110, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_as_attrgetter, __pyx_t_7) < 0) __PYX_ERR(0, 1110, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;

  /* "lupa/_lupa.pyx":1116
 *     return wrap
 * 
 * def as_itemgetter(obj):             # <<<<<<<<<<<<<<
 *     cdef _PyProtocolWrapper wrap = _PyProtocolWrapper.__new__(_PyProtocolWrapper)
 *     wrap._obj = obj
 */
  __pyx_t_7 = __Pyx_CyFunction_New(&__pyx_mdef_4lupa_5_lupa_9as_itemgetter, 0, __pyx_n_s_as_itemgetter, NULL, __pyx_n_s_lupa__lupa, __pyx_d, ((PyObject *)__pyx_codeobj__115)); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1116, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_as_itemgetter, __pyx_t_7) < 0) __PYX_ERR(0, 1116, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;

  /* "lupa/_lupa.pyx":1642
 * 
 * cdef lua.luaL_Reg *py_object_lib = [
 *     lua.luaL_Reg(name = "__call",     func = <lua.lua_CFunction> py_object_call),             # <<<<<<<<<<<<<<
 *     lua.luaL_Reg(name = "__index",    func = <lua.lua_CFunction> py_object_getindex),
 *     lua.luaL_Reg(name = "__newindex", func = <lua.lua_CFunction> py_object_setindex),
 */
  __pyx_t_10.name = ((char *)"__call");
  __pyx_t_10.func = ((lua_CFunction)__pyx_f_4lupa_5_lupa_py_object_call);

  /* "lupa/_lupa.pyx":1643
 * cdef lua.luaL_Reg *py_object_lib = [
 *     lua.luaL_Reg(name = "__call",     func = <lua.lua_CFunction> py_object_call),
 *     lua.luaL_Reg(name = "__index",    func = <lua.lua_CFunction> py_object_getindex),             # <<<<<<<<<<<<<<
 *     lua.luaL_Reg(name = "__newindex", func = <lua.lua_CFunction> py_object_setindex),
 *     lua.luaL_Reg(name = "__tostring", func = <lua.lua_CFunction> py_object_str),
 */
  __pyx_t_11.name = ((char *)"__index");
  __pyx_t_11.func = ((lua_CFunction)__pyx_f_4lupa_5_lupa_py_object_getindex);

  /* "lupa/_lupa.pyx":1644
 *     lua.luaL_Reg(name = "__call",     func = <lua.lua_CFunction> py_object_call),
 *     lua.luaL_Reg(name = "__index",    func = <lua.lua_CFunction> py_object_getindex),
 *     lua.luaL_Reg(name = "__newindex", func = <lua.lua_CFunction> py_object_setindex),             # <<<<<<<<<<<<<<
 *     lua.luaL_Reg(name = "__tostring", func = <lua.lua_CFunction> py_object_str),
 *     lua.luaL_Reg(name = "__gc",       func = <lua.lua_CFunction> py_object_gc),
 */
  __pyx_t_12.name = ((char *)"__newindex");
  __pyx_t_12.func = ((lua_CFunction)__pyx_f_4lupa_5_lupa_py_object_setindex);

  /* "lupa/_lupa.pyx":1645
 *     lua.luaL_Reg(name = "__index",    func = <lua.lua_CFunction> py_object_getindex),
 *     lua.luaL_Reg(name = "__newindex", func = <lua.lua_CFunction> py_object_setindex),
 *     lua.luaL_Reg(name = "__tostring", func = <lua.lua_CFunction> py_object_str),             # <<<<<<<<<<<<<<
 *     lua.luaL_Reg(name = "__gc",       func = <lua.lua_CFunction> py_object_gc),
 *     lua.luaL_Reg(name = NULL, func = NULL),
 */
  __pyx_t_13.name = ((char *)"__tostring");
  __pyx_t_13.func = ((lua_CFunction)__pyx_f_4lupa_5_lupa_py_object_str);

  /* "lupa/_lupa.pyx":1646
 *     lua.luaL_Reg(name = "__newindex", func = <lua.lua_CFunction> py_object_setindex),
 *     lua.luaL_Reg(name = "__tostring", func = <lua.lua_CFunction> py_object_str),
 *     lua.luaL_Reg(name = "__gc",       func = <lua.lua_CFunction> py_object_gc),             # <<<<<<<<<<<<<<
 *     lua.luaL_Reg(name = NULL, func = NULL),
 * ]
 */
  __pyx_t_14.name = ((char *)"__gc");
  __pyx_t_14.func = ((lua_CFunction)__pyx_f_4lupa_5_lupa_py_object_gc);

  /* "lupa/_lupa.pyx":1647
 *     lua.luaL_Reg(name = "__tostring", func = <lua.lua_CFunction> py_object_str),
 *     lua.luaL_Reg(name = "__gc",       func = <lua.lua_CFunction> py_object_gc),
 *     lua.luaL_Reg(name = NULL, func = NULL),             # <<<<<<<<<<<<<<
 * ]
 * 
 */
  __pyx_t_15.name = NULL;
  __pyx_t_15.func = NULL;

  /* "lupa/_lupa.pyx":1641
 * # special methods for Lua wrapped Python objects
 * 
 * cdef lua.luaL_Reg *py_object_lib = [             # <<<<<<<<<<<<<<
 *     lua.luaL_Reg(name = "__call",     func = <lua.lua_CFunction> py_object_call),
 *     lua.luaL_Reg(name = "__index",    func = <lua.lua_CFunction> py_object_getindex),
 */
  __pyx_t_16[0] = __pyx_t_10;
  __pyx_t_16[1] = __pyx_t_11;
  __pyx_t_16[2] = __pyx_t_12;
  __pyx_t_16[3] = __pyx_t_13;
  __pyx_t_16[4] = __pyx_t_14;
  __pyx_t_16[5] = __pyx_t_15;
  __pyx_v_4lupa_5_lupa_py_object_lib = __pyx_t_16;

  /* "lupa/_lupa.pyx":1804
 * 
 * cdef lua.luaL_Reg *py_lib = [
 *     lua.luaL_Reg(name = "as_attrgetter", func = <lua.lua_CFunction> py_as_attrgetter),             # <<<<<<<<<<<<<<
 *     lua.luaL_Reg(name = "as_itemgetter", func = <lua.lua_CFunction> py_as_itemgetter),
 *     lua.luaL_Reg(name = "as_function",   func = <lua.lua_CFunction> py_as_function),
 */
  __pyx_t_15.name = ((char *)"as_attrgetter");
  __pyx_t_15.func = ((lua_CFunction)__pyx_f_4lupa_5_lupa_py_as_attrgetter);

  /* "lupa/_lupa.pyx":1805
 * cdef lua.luaL_Reg *py_lib = [
 *     lua.luaL_Reg(name = "as_attrgetter", func = <lua.lua_CFunction> py_as_attrgetter),
 *     lua.luaL_Reg(name = "as_itemgetter", func = <lua.lua_CFunction> py_as_itemgetter),             # <<<<<<<<<<<<<<
 *     lua.luaL_Reg(name = "as_function",   func = <lua.lua_CFunction> py_as_function),
 *     lua.luaL_Reg(name = "iter",          func = <lua.lua_CFunction> py_iter),
 */
  __pyx_t_14.name = ((char *)"as_itemgetter");
  __pyx_t_14.func = ((lua_CFunction)__pyx_f_4lupa_5_lupa_py_as_itemgetter);

  /* "lupa/_lupa.pyx":1806
 *     lua.luaL_Reg(name = "as_attrgetter", func = <lua.lua_CFunction> py_as_attrgetter),
 *     lua.luaL_Reg(name = "as_itemgetter", func = <lua.lua_CFunction> py_as_itemgetter),
 *     lua.luaL_Reg(name = "as_function",   func = <lua.lua_CFunction> py_as_function),             # <<<<<<<<<<<<<<
 *     lua.luaL_Reg(name = "iter",          func = <lua.lua_CFunction> py_iter),
 *     lua.luaL_Reg(name = "iterex",        func = <lua.lua_CFunction> py_iterex),
 */
  __pyx_t_13.name = ((char *)"as_function");
  __pyx_t_13.func = ((lua_CFunction)__pyx_f_4lupa_5_lupa_py_as_function);

  /* "lupa/_lupa.pyx":1807
 *     lua.luaL_Reg(name = "as_itemgetter", func = <lua.lua_CFunction> py_as_itemgetter),
 *     lua.luaL_Reg(name = "as_function",   func = <lua.lua_CFunction> py_as_function),
 *     lua.luaL_Reg(name = "iter",          func = <lua.lua_CFunction> py_iter),             # <<<<<<<<<<<<<<
 *     lua.luaL_Reg(name = "iterex",        func = <lua.lua_CFunction> py_iterex),
 *     lua.luaL_Reg(name = "enumerate",     func = <lua.lua_CFunction> py_enumerate),
 */
  __pyx_t_12.name = ((char *)"iter");
  __pyx_t_12.func = ((lua_CFunction)__pyx_f_4lupa_5_lupa_py_iter);

  /* "lupa/_lupa.pyx":1808
 *     lua.luaL_Reg(name = "as_function",   func = <lua.lua_CFunction> py_as_function),
 *     lua.luaL_Reg(name = "iter",          func = <lua.lua_CFunction> py_iter),
 *     lua.luaL_Reg(name = "iterex",        func = <lua.lua_CFunction> py_iterex),             # <<<<<<<<<<<<<<
 *     lua.luaL_Reg(name = "enumerate",     func = <lua.lua_CFunction> py_enumerate),
 *     lua.luaL_Reg(name = NULL, func = NULL),
 */
  __pyx_t_11.name = ((char *)"iterex");
  __pyx_t_11.func = ((lua_CFunction)__pyx_f_4lupa_5_lupa_py_iterex);

  /* "lupa/_lupa.pyx":1809
 *     lua.luaL_Reg(name = "iter",          func = <lua.lua_CFunction> py_iter),
 *     lua.luaL_Reg(name = "iterex",        func = <lua.lua_CFunction> py_iterex),
 *     lua.luaL_Reg(name = "enumerate",     func = <lua.lua_CFunction> py_enumerate),             # <<<<<<<<<<<<<<
 *     lua.luaL_Reg(name = NULL, func = NULL),
 * ]
 */
  __pyx_t_10.name = ((char *)"enumerate");
  __pyx_t_10.func = ((lua_CFunction)__pyx_f_4lupa_5_lupa_py_enumerate);

  /* "lupa/_lupa.pyx":1810
 *     lua.luaL_Reg(name = "iterex",        func = <lua.lua_CFunction> py_iterex),
 *     lua.luaL_Reg(name = "enumerate",     func = <lua.lua_CFunction> py_enumerate),
 *     lua.luaL_Reg(name = NULL, func = NULL),             # <<<<<<<<<<<<<<
 * ]
 * 
 */
  __pyx_t_17.name = NULL;
  __pyx_t_17.func = NULL;

  /* "lupa/_lupa.pyx":1803
 * # 'python' module functions in Lua
 * 
 * cdef lua.luaL_Reg *py_lib = [             # <<<<<<<<<<<<<<
 *     lua.luaL_Reg(name = "as_attrgetter", func = <lua.lua_CFunction> py_as_attrgetter),
 *     lua.luaL_Reg(name = "as_itemgetter", func = <lua.lua_CFunction> py_as_itemgetter),
 */
  __pyx_t_18[0] = __pyx_t_15;
  __pyx_t_18[1] = __pyx_t_14;
  __pyx_t_18[2] = __pyx_t_13;
  __pyx_t_18[3] = __pyx_t_12;
  __pyx_t_18[4] = __pyx_t_11;
  __pyx_t_18[5] = __pyx_t_10;
  __pyx_t_18[6] = __pyx_t_17;
  __pyx_v_4lupa_5_lupa_py_lib = __pyx_t_18;

  /* "lupa/_lupa.pyx":1
 * # cython: embedsignature=True, binding=True, language_level=3str             # <<<<<<<<<<<<<<
 * 
 * """
 */
  __pyx_t_7 = __Pyx_PyDict_NewPresized(0); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_test, __pyx_t_7) < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;

  /*--- Wrapped vars code ---*/

  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);
  if (__pyx_m) {
    if (__pyx_d) {
      __Pyx_AddTraceback("init lupa._lupa", __pyx_clineno, __pyx_lineno, __pyx_filename);
    }
    Py_CLEAR(__pyx_m);
  } else if (!PyErr_Occurred()) {
    PyErr_SetString(PyExc_ImportError, "init lupa._lupa");
  }
  __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;
}

/* 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);
}

/* KeywordStringCheck */
static int __Pyx_CheckKeywordStrings(
    PyObject *kwdict,
    const char* function_name,
    int kw_allowed)
{
    PyObject* key = 0;
    Py_ssize_t pos = 0;
#if CYTHON_COMPILING_IN_PYPY
    if (!kw_allowed && PyDict_Next(kwdict, &pos, &key, 0))
        goto invalid_keyword;
    return 1;
#else
    while (PyDict_Next(kwdict, &pos, &key, 0)) {
        #if PY_MAJOR_VERSION < 3
        if (unlikely(!PyString_Check(key)))
        #endif
            if (unlikely(!PyUnicode_Check(key)))
                goto invalid_keyword_type;
    }
    if ((!kw_allowed) && unlikely(key))
        goto invalid_keyword;
    return 1;
invalid_keyword_type:
    PyErr_Format(PyExc_TypeError,
        "%.200s() keywords must be strings", function_name);
    return 0;
#endif
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
    return 0;
}

/* 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;
}

/* 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

/* 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

/* decode_c_string */
static CYTHON_INLINE PyObject* __Pyx_decode_c_string(
         const char* cstring, Py_ssize_t start, Py_ssize_t stop,
         const char* encoding, const char* errors,
         PyObject* (*decode_func)(const char *s, Py_ssize_t size, const char *errors)) {
    Py_ssize_t length;
    if (unlikely((start < 0) | (stop < 0))) {
        size_t slen = strlen(cstring);
        if (unlikely(slen > (size_t) PY_SSIZE_T_MAX)) {
            PyErr_SetString(PyExc_OverflowError,
                            "c-string too long to convert to Python");
            return NULL;
        }
        length = (Py_ssize_t) slen;
        if (start < 0) {
            start += length;
            if (start < 0)
                start = 0;
        }
        if (stop < 0)
            stop += length;
    }
    if (unlikely(stop <= start))
        return __Pyx_NewRef(__pyx_empty_unicode);
    length = stop - start;
    cstring += start;
    if (decode_func) {
        return decode_func(cstring, length, errors);
    } else {
        return PyUnicode_Decode(cstring, length, encoding, errors);
    }
}

/* 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;
}

/* SwapException */
#if CYTHON_FAST_THREAD_STATE
static CYTHON_INLINE void __Pyx__ExceptionSwap(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
    *type = tmp_type;
    *value = tmp_value;
    *tb = tmp_tb;
}
#else
static CYTHON_INLINE void __Pyx_ExceptionSwap(PyObject **type, PyObject **value, PyObject **tb) {
    PyObject *tmp_type, *tmp_value, *tmp_tb;
    PyErr_GetExcInfo(&tmp_type, &tmp_value, &tmp_tb);
    PyErr_SetExcInfo(*type, *value, *tb);
    *type = tmp_type;
    *value = tmp_value;
    *tb = tmp_tb;
}
#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

/* 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);
}

/* 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

/* 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;
}

/* 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

/* 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

/* RaiseTooManyValuesToUnpack */
static CYTHON_INLINE void __Pyx_RaiseTooManyValuesError(Py_ssize_t expected) {
    PyErr_Format(PyExc_ValueError,
                 "too many values to unpack (expected %" CYTHON_FORMAT_SSIZE_T "d)", expected);
}

/* RaiseNeedMoreValuesToUnpack */
static CYTHON_INLINE void __Pyx_RaiseNeedMoreValuesError(Py_ssize_t index) {
    PyErr_Format(PyExc_ValueError,
                 "need more than %" CYTHON_FORMAT_SSIZE_T "d value%.1s to unpack",
                 index, (index == 1) ? "" : "s");
}

/* IterFinish */
static CYTHON_INLINE int __Pyx_IterFinish(void) {
#if CYTHON_FAST_THREAD_STATE
    PyThreadState *tstate = __Pyx_PyThreadState_Current;
    PyObject* exc_type = tstate->curexc_type;
    if (unlikely(exc_type)) {
        if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) {
            PyObject *exc_value, *exc_tb;
            exc_value = tstate->curexc_value;
            exc_tb = tstate->curexc_traceback;
            tstate->curexc_type = 0;
            tstate->curexc_value = 0;
            tstate->curexc_traceback = 0;
            Py_DECREF(exc_type);
            Py_XDECREF(exc_value);
            Py_XDECREF(exc_tb);
            return 0;
        } else {
            return -1;
        }
    }
    return 0;
#else
    if (unlikely(PyErr_Occurred())) {
        if (likely(PyErr_ExceptionMatches(PyExc_StopIteration))) {
            PyErr_Clear();
            return 0;
        } else {
            return -1;
        }
    }
    return 0;
#endif
}

/* UnpackItemEndCheck */
static int __Pyx_IternextUnpackEndCheck(PyObject *retval, Py_ssize_t expected) {
    if (unlikely(retval)) {
        Py_DECREF(retval);
        __Pyx_RaiseTooManyValuesError(expected);
        return -1;
    } else {
        return __Pyx_IterFinish();
    }
    return 0;
}

/* 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

/* None */
static CYTHON_INLINE void __Pyx_RaiseUnboundLocalError(const char *varname) {
    PyErr_Format(PyExc_UnboundLocalError, "local variable '%s' referenced before assignment", varname);
}

/* DivInt[long] */
static CYTHON_INLINE long __Pyx_div_long(long a, long b) {
    long q = a / b;
    long r = a - q*b;
    q -= ((r != 0) & ((r ^ b) < 0));
    return q;
}

/* ModInt[long] */
static CYTHON_INLINE long __Pyx_mod_long(long a, long b) {
    long r = a % b;
    r += ((r != 0) & ((r ^ b) < 0)) * b;
    return r;
}

/* 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));
}

/* PyObjectGetMethod */
static int __Pyx_PyObject_GetMethod(PyObject *obj, PyObject *name, PyObject **method) {
    PyObject *attr;
#if CYTHON_UNPACK_METHODS && CYTHON_COMPILING_IN_CPYTHON && CYTHON_USE_PYTYPE_LOOKUP
    PyTypeObject *tp = Py_TYPE(obj);
    PyObject *descr;
    descrgetfunc f = NULL;
    PyObject **dictptr, *dict;
    int meth_found = 0;
    assert (*method == NULL);
    if (unlikely(tp->tp_getattro != PyObject_GenericGetAttr)) {
        attr = __Pyx_PyObject_GetAttrStr(obj, name);
        goto try_unpack;
    }
    if (unlikely(tp->tp_dict == NULL) && unlikely(PyType_Ready(tp) < 0)) {
        return 0;
    }
    descr = _PyType_Lookup(tp, name);
    if (likely(descr != NULL)) {
        Py_INCREF(descr);
#if PY_MAJOR_VERSION >= 3
        #ifdef __Pyx_CyFunction_USED
        if (likely(PyFunction_Check(descr) || (Py_TYPE(descr) == &PyMethodDescr_Type) || __Pyx_CyFunction_Check(descr)))
        #else
        if (likely(PyFunction_Check(descr) || (Py_TYPE(descr) == &PyMethodDescr_Type)))
        #endif
#else
        #ifdef __Pyx_CyFunction_USED
        if (likely(PyFunction_Check(descr) || __Pyx_CyFunction_Check(descr)))
        #else
        if (likely(PyFunction_Check(descr)))
        #endif
#endif
        {
            meth_found = 1;
        } else {
            f = Py_TYPE(descr)->tp_descr_get;
            if (f != NULL && PyDescr_IsData(descr)) {
                attr = f(descr, obj, (PyObject *)Py_TYPE(obj));
                Py_DECREF(descr);
                goto try_unpack;
            }
        }
    }
    dictptr = _PyObject_GetDictPtr(obj);
    if (dictptr != NULL && (dict = *dictptr) != NULL) {
        Py_INCREF(dict);
        attr = __Pyx_PyDict_GetItemStr(dict, name);
        if (attr != NULL) {
            Py_INCREF(attr);
            Py_DECREF(dict);
            Py_XDECREF(descr);
            goto try_unpack;
        }
        Py_DECREF(dict);
    }
    if (meth_found) {
        *method = descr;
        return 1;
    }
    if (f != NULL) {
        attr = f(descr, obj, (PyObject *)Py_TYPE(obj));
        Py_DECREF(descr);
        goto try_unpack;
    }
    if (descr != NULL) {
        *method = descr;
        return 0;
    }
    PyErr_Format(PyExc_AttributeError,
#if PY_MAJOR_VERSION >= 3
                 "'%.50s' object has no attribute '%U'",
                 tp->tp_name, name);
#else
                 "'%.50s' object has no attribute '%.400s'",
                 tp->tp_name, PyString_AS_STRING(name));
#endif
    return 0;
#else
    attr = __Pyx_PyObject_GetAttrStr(obj, name);
    goto try_unpack;
#endif
try_unpack:
#if CYTHON_UNPACK_METHODS
    if (likely(attr) && PyMethod_Check(attr) && likely(PyMethod_GET_SELF(attr) == obj)) {
        PyObject *function = PyMethod_GET_FUNCTION(attr);
        Py_INCREF(function);
        Py_DECREF(attr);
        *method = function;
        return 1;
    }
#endif
    *method = attr;
    return 0;
}

/* PyObjectCallMethod0 */
static PyObject* __Pyx_PyObject_CallMethod0(PyObject* obj, PyObject* method_name) {
    PyObject *method = NULL, *result = NULL;
    int is_method = __Pyx_PyObject_GetMethod(obj, method_name, &method);
    if (likely(is_method)) {
        result = __Pyx_PyObject_CallOneArg(method, obj);
        Py_DECREF(method);
        return result;
    }
    if (unlikely(!method)) goto bad;
    result = __Pyx_PyObject_CallNoArg(method);
    Py_DECREF(method);
bad:
    return result;
}

/* RaiseNoneIterError */
static CYTHON_INLINE void __Pyx_RaiseNoneNotIterableError(void) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable");
}

/* UnpackTupleError */
static void __Pyx_UnpackTupleError(PyObject *t, Py_ssize_t index) {
    if (t == Py_None) {
      __Pyx_RaiseNoneNotIterableError();
    } else if (PyTuple_GET_SIZE(t) < index) {
      __Pyx_RaiseNeedMoreValuesError(PyTuple_GET_SIZE(t));
    } else {
      __Pyx_RaiseTooManyValuesError(index);
    }
}

/* UnpackTuple2 */
static CYTHON_INLINE int __Pyx_unpack_tuple2_exact(
        PyObject* tuple, PyObject** pvalue1, PyObject** pvalue2, int decref_tuple) {
    PyObject *value1 = NULL, *value2 = NULL;
#if CYTHON_COMPILING_IN_PYPY
    value1 = PySequence_ITEM(tuple, 0);  if (unlikely(!value1)) goto bad;
    value2 = PySequence_ITEM(tuple, 1);  if (unlikely(!value2)) goto bad;
#else
    value1 = PyTuple_GET_ITEM(tuple, 0);  Py_INCREF(value1);
    value2 = PyTuple_GET_ITEM(tuple, 1);  Py_INCREF(value2);
#endif
    if (decref_tuple) {
        Py_DECREF(tuple);
    }
    *pvalue1 = value1;
    *pvalue2 = value2;
    return 0;
#if CYTHON_COMPILING_IN_PYPY
bad:
    Py_XDECREF(value1);
    Py_XDECREF(value2);
    if (decref_tuple) { Py_XDECREF(tuple); }
    return -1;
#endif
}
static int __Pyx_unpack_tuple2_generic(PyObject* tuple, PyObject** pvalue1, PyObject** pvalue2,
                                       int has_known_size, int decref_tuple) {
    Py_ssize_t index;
    PyObject *value1 = NULL, *value2 = NULL, *iter = NULL;
    iternextfunc iternext;
    iter = PyObject_GetIter(tuple);
    if (unlikely(!iter)) goto bad;
    if (decref_tuple) { Py_DECREF(tuple); tuple = NULL; }
    iternext = Py_TYPE(iter)->tp_iternext;
    value1 = iternext(iter); if (unlikely(!value1)) { index = 0; goto unpacking_failed; }
    value2 = iternext(iter); if (unlikely(!value2)) { index = 1; goto unpacking_failed; }
    if (!has_known_size && unlikely(__Pyx_IternextUnpackEndCheck(iternext(iter), 2))) goto bad;
    Py_DECREF(iter);
    *pvalue1 = value1;
    *pvalue2 = value2;
    return 0;
unpacking_failed:
    if (!has_known_size && __Pyx_IterFinish() == 0)
        __Pyx_RaiseNeedMoreValuesError(index);
bad:
    Py_XDECREF(iter);
    Py_XDECREF(value1);
    Py_XDECREF(value2);
    if (decref_tuple) { Py_XDECREF(tuple); }
    return -1;
}

/* dict_iter */
static CYTHON_INLINE PyObject* __Pyx_dict_iterator(PyObject* iterable, int is_dict, PyObject* method_name,
                                                   Py_ssize_t* p_orig_length, int* p_source_is_dict) {
    is_dict = is_dict || likely(PyDict_CheckExact(iterable));
    *p_source_is_dict = is_dict;
    if (is_dict) {
#if !CYTHON_COMPILING_IN_PYPY
        *p_orig_length = PyDict_Size(iterable);
        Py_INCREF(iterable);
        return iterable;
#elif PY_MAJOR_VERSION >= 3
        static PyObject *py_items = NULL, *py_keys = NULL, *py_values = NULL;
        PyObject **pp = NULL;
        if (method_name) {
            const char *name = PyUnicode_AsUTF8(method_name);
            if (strcmp(name, "iteritems") == 0) pp = &py_items;
            else if (strcmp(name, "iterkeys") == 0) pp = &py_keys;
            else if (strcmp(name, "itervalues") == 0) pp = &py_values;
            if (pp) {
                if (!*pp) {
                    *pp = PyUnicode_FromString(name + 4);
                    if (!*pp)
                        return NULL;
                }
                method_name = *pp;
            }
        }
#endif
    }
    *p_orig_length = 0;
    if (method_name) {
        PyObject* iter;
        iterable = __Pyx_PyObject_CallMethod0(iterable, method_name);
        if (!iterable)
            return NULL;
#if !CYTHON_COMPILING_IN_PYPY
        if (PyTuple_CheckExact(iterable) || PyList_CheckExact(iterable))
            return iterable;
#endif
        iter = PyObject_GetIter(iterable);
        Py_DECREF(iterable);
        return iter;
    }
    return PyObject_GetIter(iterable);
}
static CYTHON_INLINE int __Pyx_dict_iter_next(
        PyObject* iter_obj, CYTHON_NCP_UNUSED Py_ssize_t orig_length, CYTHON_NCP_UNUSED Py_ssize_t* ppos,
        PyObject** pkey, PyObject** pvalue, PyObject** pitem, int source_is_dict) {
    PyObject* next_item;
#if !CYTHON_COMPILING_IN_PYPY
    if (source_is_dict) {
        PyObject *key, *value;
        if (unlikely(orig_length != PyDict_Size(iter_obj))) {
            PyErr_SetString(PyExc_RuntimeError, "dictionary changed size during iteration");
            return -1;
        }
        if (unlikely(!PyDict_Next(iter_obj, ppos, &key, &value))) {
            return 0;
        }
        if (pitem) {
            PyObject* tuple = PyTuple_New(2);
            if (unlikely(!tuple)) {
                return -1;
            }
            Py_INCREF(key);
            Py_INCREF(value);
            PyTuple_SET_ITEM(tuple, 0, key);
            PyTuple_SET_ITEM(tuple, 1, value);
            *pitem = tuple;
        } else {
            if (pkey) {
                Py_INCREF(key);
                *pkey = key;
            }
            if (pvalue) {
                Py_INCREF(value);
                *pvalue = value;
            }
        }
        return 1;
    } else if (PyTuple_CheckExact(iter_obj)) {
        Py_ssize_t pos = *ppos;
        if (unlikely(pos >= PyTuple_GET_SIZE(iter_obj))) return 0;
        *ppos = pos + 1;
        next_item = PyTuple_GET_ITEM(iter_obj, pos);
        Py_INCREF(next_item);
    } else if (PyList_CheckExact(iter_obj)) {
        Py_ssize_t pos = *ppos;
        if (unlikely(pos >= PyList_GET_SIZE(iter_obj))) return 0;
        *ppos = pos + 1;
        next_item = PyList_GET_ITEM(iter_obj, pos);
        Py_INCREF(next_item);
    } else
#endif
    {
        next_item = PyIter_Next(iter_obj);
        if (unlikely(!next_item)) {
            return __Pyx_IterFinish();
        }
    }
    if (pitem) {
        *pitem = next_item;
    } else if (pkey && pvalue) {
        if (__Pyx_unpack_tuple2(next_item, pkey, pvalue, source_is_dict, source_is_dict, 1))
            return -1;
    } else if (pkey) {
        *pkey = next_item;
    } else {
        *pvalue = next_item;
    }
    return 1;
}

/* 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

/* None */
static CYTHON_INLINE void __Pyx_RaiseClosureNameError(const char *varname) {
    PyErr_Format(PyExc_NameError, "free variable '%s' referenced before assignment in enclosing scope", varname);
}

/* 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);
            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;
}

/* decode_c_bytes */
static CYTHON_INLINE PyObject* __Pyx_decode_c_bytes(
         const char* cstring, Py_ssize_t length, Py_ssize_t start, Py_ssize_t stop,
         const char* encoding, const char* errors,
         PyObject* (*decode_func)(const char *s, Py_ssize_t size, const char *errors)) {
    if (unlikely((start < 0) | (stop < 0))) {
        if (start < 0) {
            start += length;
            if (start < 0)
                start = 0;
        }
        if (stop < 0)
            stop += length;
    }
    if (stop > length)
        stop = length;
    if (unlikely(stop <= start))
        return __Pyx_NewRef(__pyx_empty_unicode);
    length = stop - start;
    cstring += start;
    if (decode_func) {
        return decode_func(cstring, length, errors);
    } else {
        return PyUnicode_Decode(cstring, length, encoding, errors);
    }
}

/* 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
}

/* PyIntBinop */
#if !CYTHON_COMPILING_IN_PYPY
static PyObject* __Pyx_PyInt_AddObjC(PyObject *op1, PyObject *op2, CYTHON_UNUSED long intval, int inplace, int zerodivision_check) {
    (void)inplace;
    (void)zerodivision_check;
    #if PY_MAJOR_VERSION < 3
    if (likely(PyInt_CheckExact(op1))) {
        const long b = intval;
        long x;
        long a = PyInt_AS_LONG(op1);
            x = (long)((unsigned long)a + b);
            if (likely((x^a) >= 0 || (x^b) >= 0))
                return PyInt_FromLong(x);
            return PyLong_Type.tp_as_number->nb_add(op1, op2);
    }
    #endif
    #if CYTHON_USE_PYLONG_INTERNALS
    if (likely(PyLong_CheckExact(op1))) {
        const long b = intval;
        long a, x;
#ifdef HAVE_LONG_LONG
        const PY_LONG_LONG llb = intval;
        PY_LONG_LONG lla, llx;
#endif
        const digit* digits = ((PyLongObject*)op1)->ob_digit;
        const Py_ssize_t size = Py_SIZE(op1);
        if (likely(__Pyx_sst_abs(size) <= 1)) {
            a = likely(size) ? digits[0] : 0;
            if (size == -1) a = -a;
        } else {
            switch (size) {
                case -2:
                    if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) {
                        a = -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]));
                        break;
#ifdef HAVE_LONG_LONG
                    } else if (8 * sizeof(PY_LONG_LONG) - 1 > 2 * PyLong_SHIFT) {
                        lla = -(PY_LONG_LONG) (((((unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0]));
                        goto long_long;
#endif
                    }
                    CYTHON_FALLTHROUGH;
                case 2:
                    if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) {
                        a = (long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]));
                        break;
#ifdef HAVE_LONG_LONG
                    } else if (8 * sizeof(PY_LONG_LONG) - 1 > 2 * PyLong_SHIFT) {
                        lla = (PY_LONG_LONG) (((((unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0]));
                        goto long_long;
#endif
                    }
                    CYTHON_FALLTHROUGH;
                case -3:
                    if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) {
                        a = -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]));
                        break;
#ifdef HAVE_LONG_LONG
                    } else if (8 * sizeof(PY_LONG_LONG) - 1 > 3 * PyLong_SHIFT) {
                        lla = -(PY_LONG_LONG) (((((((unsigned PY_LONG_LONG)digits[2]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0]));
                        goto long_long;
#endif
                    }
                    CYTHON_FALLTHROUGH;
                case 3:
                    if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) {
                        a = (long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]));
                        break;
#ifdef HAVE_LONG_LONG
                    } else if (8 * sizeof(PY_LONG_LONG) - 1 > 3 * PyLong_SHIFT) {
                        lla = (PY_LONG_LONG) (((((((unsigned PY_LONG_LONG)digits[2]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0]));
                        goto long_long;
#endif
                    }
                    CYTHON_FALLTHROUGH;
                case -4:
                    if (8 * sizeof(long) - 1 > 4 * PyLong_SHIFT) {
                        a = -(long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]));
                        break;
#ifdef HAVE_LONG_LONG
                    } else if (8 * sizeof(PY_LONG_LONG) - 1 > 4 * PyLong_SHIFT) {
                        lla = -(PY_LONG_LONG) (((((((((unsigned PY_LONG_LONG)digits[3]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[2]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0]));
                        goto long_long;
#endif
                    }
                    CYTHON_FALLTHROUGH;
                case 4:
                    if (8 * sizeof(long) - 1 > 4 * PyLong_SHIFT) {
                        a = (long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]));
                        break;
#ifdef HAVE_LONG_LONG
                    } else if (8 * sizeof(PY_LONG_LONG) - 1 > 4 * PyLong_SHIFT) {
                        lla = (PY_LONG_LONG) (((((((((unsigned PY_LONG_LONG)digits[3]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[2]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0]));
                        goto long_long;
#endif
                    }
                    CYTHON_FALLTHROUGH;
                default: return PyLong_Type.tp_as_number->nb_add(op1, op2);
            }
        }
                x = a + b;
            return PyLong_FromLong(x);
#ifdef HAVE_LONG_LONG
        long_long:
                llx = lla + llb;
            return PyLong_FromLongLong(llx);
#endif
        
        
    }
    #endif
    if (PyFloat_CheckExact(op1)) {
        const long b = intval;
        double a = PyFloat_AS_DOUBLE(op1);
            double result;
            PyFPE_START_PROTECT("add", return NULL)
            result = ((double)a) + (double)b;
            PyFPE_END_PROTECT(result)
            return PyFloat_FromDouble(result);
    }
    return (inplace ? PyNumber_InPlaceAdd : PyNumber_Add)(op1, op2);
}
#endif

/* unicode_tailmatch */
static int __Pyx_PyUnicode_TailmatchTuple(PyObject* s, PyObject* substrings,
                                          Py_ssize_t start, Py_ssize_t end, int direction) {
    Py_ssize_t i, count = PyTuple_GET_SIZE(substrings);
    for (i = 0; i < count; i++) {
        Py_ssize_t result;
#if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
        result = PyUnicode_Tailmatch(s, PyTuple_GET_ITEM(substrings, i),
                                     start, end, direction);
#else
        PyObject* sub = PySequence_ITEM(substrings, i);
        if (unlikely(!sub)) return -1;
        result = PyUnicode_Tailmatch(s, sub, start, end, direction);
        Py_DECREF(sub);
#endif
        if (result) {
            return (int) result;
        }
    }
    return 0;
}
static int __Pyx_PyUnicode_Tailmatch(PyObject* s, PyObject* substr,
                                     Py_ssize_t start, Py_ssize_t end, int direction) {
    if (unlikely(PyTuple_Check(substr))) {
        return __Pyx_PyUnicode_TailmatchTuple(s, substr, start, end, direction);
    }
    return (int) PyUnicode_Tailmatch(s, substr, start, end, direction);
}

/* bytes_tailmatch */
static int __Pyx_PyBytes_SingleTailmatch(PyObject* self, PyObject* arg,
                                         Py_ssize_t start, Py_ssize_t end, int direction) {
    const char* self_ptr = PyBytes_AS_STRING(self);
    Py_ssize_t self_len = PyBytes_GET_SIZE(self);
    const char* sub_ptr;
    Py_ssize_t sub_len;
    int retval;
    Py_buffer view;
    view.obj = NULL;
    if ( PyBytes_Check(arg) ) {
        sub_ptr = PyBytes_AS_STRING(arg);
        sub_len = PyBytes_GET_SIZE(arg);
    }
#if PY_MAJOR_VERSION < 3
    else if ( PyUnicode_Check(arg) ) {
        return (int) PyUnicode_Tailmatch(self, arg, start, end, direction);
    }
#endif
    else {
        if (unlikely(PyObject_GetBuffer(self, &view, PyBUF_SIMPLE) == -1))
            return -1;
        sub_ptr = (const char*) view.buf;
        sub_len = view.len;
    }
    if (end > self_len)
        end = self_len;
    else if (end < 0)
        end += self_len;
    if (end < 0)
        end = 0;
    if (start < 0)
        start += self_len;
    if (start < 0)
        start = 0;
    if (direction > 0) {
        if (end-sub_len > start)
            start = end - sub_len;
    }
    if (start + sub_len <= end)
        retval = !memcmp(self_ptr+start, sub_ptr, (size_t)sub_len);
    else
        retval = 0;
    if (view.obj)
        PyBuffer_Release(&view);
    return retval;
}
static int __Pyx_PyBytes_TailmatchTuple(PyObject* self, PyObject* substrings,
                                        Py_ssize_t start, Py_ssize_t end, int direction) {
    Py_ssize_t i, count = PyTuple_GET_SIZE(substrings);
    for (i = 0; i < count; i++) {
        int result;
#if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
        result = __Pyx_PyBytes_SingleTailmatch(self, PyTuple_GET_ITEM(substrings, i),
                                               start, end, direction);
#else
        PyObject* sub = PySequence_ITEM(substrings, i);
        if (unlikely(!sub)) return -1;
        result = __Pyx_PyBytes_SingleTailmatch(self, sub, start, end, direction);
        Py_DECREF(sub);
#endif
        if (result) {
            return result;
        }
    }
    return 0;
}
static int __Pyx_PyBytes_Tailmatch(PyObject* self, PyObject* substr,
                                   Py_ssize_t start, Py_ssize_t end, int direction) {
    if (unlikely(PyTuple_Check(substr))) {
        return __Pyx_PyBytes_TailmatchTuple(self, substr, start, end, direction);
    }
    return __Pyx_PyBytes_SingleTailmatch(self, substr, start, end, direction);
}

/* ArgTypeTest */
static int __Pyx__ArgTypeTest(PyObject *obj, PyTypeObject *type, const char *name, int exact)
{
    if (unlikely(!type)) {
        PyErr_SetString(PyExc_SystemError, "Missing type object");
        return 0;
    }
    else if (exact) {
        #if PY_MAJOR_VERSION == 2
        if ((type == &PyBaseString_Type) && likely(__Pyx_PyBaseString_CheckExact(obj))) return 1;
        #endif
    }
    else {
        if (likely(__Pyx_TypeCheck(obj, type))) return 1;
    }
    PyErr_Format(PyExc_TypeError,
        "Argument '%.200s' has incorrect type (expected %.200s, got %.200s)",
        name, type->tp_name, Py_TYPE(obj)->tp_name);
    return 0;
}

/* GetAttr */
static CYTHON_INLINE PyObject *__Pyx_GetAttr(PyObject *o, PyObject *n) {
#if CYTHON_USE_TYPE_SLOTS
#if PY_MAJOR_VERSION >= 3
    if (likely(PyUnicode_Check(n)))
#else
    if (likely(PyString_Check(n)))
#endif
        return __Pyx_PyObject_GetAttrStr(o, n);
#endif
    return PyObject_GetAttr(o, n);
}

/* HasAttr */
static CYTHON_INLINE int __Pyx_HasAttr(PyObject *o, PyObject *n) {
    PyObject *r;
    if (unlikely(!__Pyx_PyBaseString_Check(n))) {
        PyErr_SetString(PyExc_TypeError,
                        "hasattr(): attribute name must be string");
        return -1;
    }
    r = __Pyx_GetAttr(o, n);
    if (unlikely(!r)) {
        PyErr_Clear();
        return 0;
    } else {
        Py_DECREF(r);
        return 1;
    }
}

/* PyObjectCallMethod1 */
static PyObject* __Pyx__PyObject_CallMethod1(PyObject* method, PyObject* arg) {
    PyObject *result = __Pyx_PyObject_CallOneArg(method, arg);
    Py_DECREF(method);
    return result;
}
static PyObject* __Pyx_PyObject_CallMethod1(PyObject* obj, PyObject* method_name, PyObject* arg) {
    PyObject *method = NULL, *result;
    int is_method = __Pyx_PyObject_GetMethod(obj, method_name, &method);
    if (likely(is_method)) {
        result = __Pyx_PyObject_Call2Args(method, obj, arg);
        Py_DECREF(method);
        return result;
    }
    if (unlikely(!method)) return NULL;
    return __Pyx__PyObject_CallMethod1(method, arg);
}

/* append */
static CYTHON_INLINE int __Pyx_PyObject_Append(PyObject* L, PyObject* x) {
    if (likely(PyList_CheckExact(L))) {
        if (unlikely(__Pyx_PyList_Append(L, x) < 0)) return -1;
    } else {
        PyObject* retval = __Pyx_PyObject_CallMethod1(L, __pyx_n_s_append, x);
        if (unlikely(!retval))
            return -1;
        Py_DECREF(retval);
    }
    return 0;
}

/* DictGetItem */
#if PY_MAJOR_VERSION >= 3 && !CYTHON_COMPILING_IN_PYPY
static PyObject *__Pyx_PyDict_GetItem(PyObject *d, PyObject* key) {
    PyObject *value;
    value = PyDict_GetItemWithError(d, key);
    if (unlikely(!value)) {
        if (!PyErr_Occurred()) {
            if (unlikely(PyTuple_Check(key))) {
                PyObject* args = PyTuple_Pack(1, key);
                if (likely(args)) {
                    PyErr_SetObject(PyExc_KeyError, args);
                    Py_DECREF(args);
                }
            } else {
                PyErr_SetObject(PyExc_KeyError, key);
            }
        }
        return NULL;
    }
    Py_INCREF(value);
    return value;
}
#endif

/* UnpackUnboundCMethod */
static int __Pyx_TryUnpackUnboundCMethod(__Pyx_CachedCFunction* target) {
    PyObject *method;
    method = __Pyx_PyObject_GetAttrStr(target->type, *target->method_name);
    if (unlikely(!method))
        return -1;
    target->method = method;
#if CYTHON_COMPILING_IN_CPYTHON
    #if PY_MAJOR_VERSION >= 3
    if (likely(__Pyx_TypeCheck(method, &PyMethodDescr_Type)))
    #endif
    {
        PyMethodDescrObject *descr = (PyMethodDescrObject*) method;
        target->func = descr->d_method->ml_meth;
        target->flag = descr->d_method->ml_flags & ~(METH_CLASS | METH_STATIC | METH_COEXIST | METH_STACKLESS);
    }
#endif
    return 0;
}

/* CallUnboundCMethod0 */
static PyObject* __Pyx__CallUnboundCMethod0(__Pyx_CachedCFunction* cfunc, PyObject* self) {
    PyObject *args, *result = NULL;
    if (unlikely(!cfunc->method) && unlikely(__Pyx_TryUnpackUnboundCMethod(cfunc) < 0)) return NULL;
#if CYTHON_ASSUME_SAFE_MACROS
    args = PyTuple_New(1);
    if (unlikely(!args)) goto bad;
    Py_INCREF(self);
    PyTuple_SET_ITEM(args, 0, self);
#else
    args = PyTuple_Pack(1, self);
    if (unlikely(!args)) goto bad;
#endif
    result = __Pyx_PyObject_Call(cfunc->method, args, NULL);
    Py_DECREF(args);
bad:
    return result;
}

/* pop */
static CYTHON_INLINE PyObject* __Pyx__PyObject_Pop(PyObject* L) {
    if (Py_TYPE(L) == &PySet_Type) {
        return PySet_Pop(L);
    }
    return __Pyx_PyObject_CallMethod0(L, __pyx_n_s_pop);
}
#if CYTHON_USE_PYLIST_INTERNALS && CYTHON_ASSUME_SAFE_MACROS
static CYTHON_INLINE PyObject* __Pyx_PyList_Pop(PyObject* L) {
    if (likely(PyList_GET_SIZE(L) > (((PyListObject*)L)->allocated >> 1))) {
        __Pyx_SET_SIZE(L, Py_SIZE(L) - 1);
        return PyList_GET_ITEM(L, PyList_GET_SIZE(L));
    }
    return __Pyx_CallUnboundCMethod0(&__pyx_umethod_PyList_Type_pop, L);
}
#endif

/* IterNext */
static PyObject *__Pyx_PyIter_Next2Default(PyObject* defval) {
    PyObject* exc_type;
    __Pyx_PyThreadState_declare
    __Pyx_PyThreadState_assign
    exc_type = __Pyx_PyErr_Occurred();
    if (unlikely(exc_type)) {
        if (!defval || unlikely(!__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration)))
            return NULL;
        __Pyx_PyErr_Clear();
        Py_INCREF(defval);
        return defval;
    }
    if (defval) {
        Py_INCREF(defval);
        return defval;
    }
    __Pyx_PyErr_SetNone(PyExc_StopIteration);
    return NULL;
}
static void __Pyx_PyIter_Next_ErrorNoIterator(PyObject *iterator) {
    PyErr_Format(PyExc_TypeError,
        "%.200s object is not an iterator", Py_TYPE(iterator)->tp_name);
}
static CYTHON_INLINE PyObject *__Pyx_PyIter_Next2(PyObject* iterator, PyObject* defval) {
    PyObject* next;
    iternextfunc iternext = Py_TYPE(iterator)->tp_iternext;
    if (likely(iternext)) {
#if CYTHON_USE_TYPE_SLOTS
        next = iternext(iterator);
        if (likely(next))
            return next;
        #if PY_VERSION_HEX >= 0x02070000
        if (unlikely(iternext == &_PyObject_NextNotImplemented))
            return NULL;
        #endif
#else
        next = PyIter_Next(iterator);
        if (likely(next))
            return next;
#endif
    } else if (CYTHON_USE_TYPE_SLOTS || unlikely(!PyIter_Check(iterator))) {
        __Pyx_PyIter_Next_ErrorNoIterator(iterator);
        return NULL;
    }
#if !CYTHON_USE_TYPE_SLOTS
    else {
        next = PyIter_Next(iterator);
        if (likely(next))
            return next;
    }
#endif
    return __Pyx_PyIter_Next2Default(defval);
}

/* 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

/* 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_reduce_ex = NULL;
    PyObject *reduce = NULL;
    PyObject *reduce_ex = NULL;
    PyObject *reduce_cython = NULL;
    PyObject *setstate = NULL;
    PyObject *setstate_cython = NULL;
#if CYTHON_USE_PYTYPE_LOOKUP
    if (_PyType_Lookup((PyTypeObject*)type_obj, __pyx_n_s_getstate)) goto __PYX_GOOD;
#else
    if (PyObject_HasAttr(type_obj, __pyx_n_s_getstate)) goto __PYX_GOOD;
#endif
#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);
#endif
    Py_XDECREF(reduce);
    Py_XDECREF(reduce_ex);
    Py_XDECREF(reduce_cython);
    Py_XDECREF(setstate);
    Py_XDECREF(setstate_cython);
    return ret;
}

/* 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;
}

/* TypeImport */
#ifndef __PYX_HAVE_RT_ImportType
#define __PYX_HAVE_RT_ImportType
static PyTypeObject *__Pyx_ImportType(PyObject *module, const char *module_name, const char *class_name,
    size_t size, enum __Pyx_ImportType_CheckSize check_size)
{
    PyObject *result = 0;
    char warning[200];
    Py_ssize_t basicsize;
#ifdef Py_LIMITED_API
    PyObject *py_basicsize;
#endif
    result = PyObject_GetAttrString(module, class_name);
    if (!result)
        goto bad;
    if (!PyType_Check(result)) {
        PyErr_Format(PyExc_TypeError,
            "%.200s.%.200s is not a type object",
            module_name, class_name);
        goto bad;
    }
#ifndef Py_LIMITED_API
    basicsize = ((PyTypeObject *)result)->tp_basicsize;
#else
    py_basicsize = PyObject_GetAttrString(result, "__basicsize__");
    if (!py_basicsize)
        goto bad;
    basicsize = PyLong_AsSsize_t(py_basicsize);
    Py_DECREF(py_basicsize);
    py_basicsize = 0;
    if (basicsize == (Py_ssize_t)-1 && PyErr_Occurred())
        goto bad;
#endif
    if ((size_t)basicsize < size) {
        PyErr_Format(PyExc_ValueError,
            "%.200s.%.200s size changed, may indicate binary incompatibility. "
            "Expected %zd from C header, got %zd from PyObject",
            module_name, class_name, size, basicsize);
        goto bad;
    }
    if (check_size == __Pyx_ImportType_CheckSize_Error && (size_t)basicsize != size) {
        PyErr_Format(PyExc_ValueError,
            "%.200s.%.200s size changed, may indicate binary incompatibility. "
            "Expected %zd from C header, got %zd from PyObject",
            module_name, class_name, size, basicsize);
        goto bad;
    }
    else if (check_size == __Pyx_ImportType_CheckSize_Warn && (size_t)basicsize > size) {
        PyOS_snprintf(warning, sizeof(warning),
            "%s.%s size changed, may indicate binary incompatibility. "
            "Expected %zd from C header, got %zd from PyObject",
            module_name, class_name, size, basicsize);
        if (PyErr_WarnEx(NULL, warning, 0) < 0) goto bad;
    }
    return (PyTypeObject *)result;
bad:
    Py_XDECREF(result);
    return NULL;
}
#endif

/* 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;
}

/* 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"
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;
    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) {
        py_code = __Pyx_CreateCodeObjectForTraceback(
            funcname, c_line, py_line, filename);
        if (!py_code) goto bad;
        __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;\
    }

/* 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 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;
}

/* CIntFromPy */
static CYTHON_INLINE size_t __Pyx_PyInt_As_size_t(PyObject *x) {
#ifdef __Pyx_HAS_GCC_DIAGNOSTIC
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wconversion"
#endif
    const size_t neg_one = (size_t) -1, const_zero = (size_t) 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(size_t) < sizeof(long)) {
            __PYX_VERIFY_RETURN_INT(size_t, long, PyInt_AS_LONG(x))
        } else {
            long val = PyInt_AS_LONG(x);
            if (is_unsigned && unlikely(val < 0)) {
                goto raise_neg_overflow;
            }
            return (size_t) 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 (size_t) 0;
                case  1: __PYX_VERIFY_RETURN_INT(size_t, digit, digits[0])
                case 2:
                    if (8 * sizeof(size_t) > 1 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(size_t, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(size_t) >= 2 * PyLong_SHIFT) {
                            return (size_t) (((((size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
                        }
                    }
                    break;
                case 3:
                    if (8 * sizeof(size_t) > 2 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(size_t, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(size_t) >= 3 * PyLong_SHIFT) {
                            return (size_t) (((((((size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
                        }
                    }
                    break;
                case 4:
                    if (8 * sizeof(size_t) > 3 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(size_t, 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(size_t) >= 4 * PyLong_SHIFT) {
                            return (size_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
#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 (size_t) -1;
                if (unlikely(result == 1))
                    goto raise_neg_overflow;
            }
#endif
            if (sizeof(size_t) <= sizeof(unsigned long)) {
                __PYX_VERIFY_RETURN_INT_EXC(size_t, unsigned long, PyLong_AsUnsignedLong(x))
#ifdef HAVE_LONG_LONG
            } else if (sizeof(size_t) <= sizeof(unsigned PY_LONG_LONG)) {
                __PYX_VERIFY_RETURN_INT_EXC(size_t, 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 (size_t) 0;
                case -1: __PYX_VERIFY_RETURN_INT(size_t, sdigit, (sdigit) (-(sdigit)digits[0]))
                case  1: __PYX_VERIFY_RETURN_INT(size_t,  digit, +digits[0])
                case -2:
                    if (8 * sizeof(size_t) - 1 > 1 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(size_t, long, -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(size_t) - 1 > 2 * PyLong_SHIFT) {
                            return (size_t) (((size_t)-1)*(((((size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0])));
                        }
                    }
                    break;
                case 2:
                    if (8 * sizeof(size_t) > 1 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(size_t, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(size_t) - 1 > 2 * PyLong_SHIFT) {
                            return (size_t) ((((((size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0])));
                        }
                    }
                    break;
                case -3:
                    if (8 * sizeof(size_t) - 1 > 2 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(size_t, long, -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(size_t) - 1 > 3 * PyLong_SHIFT) {
                            return (size_t) (((size_t)-1)*(((((((size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0])));
                        }
                    }
                    break;
                case 3:
                    if (8 * sizeof(size_t) > 2 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(size_t, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(size_t) - 1 > 3 * PyLong_SHIFT) {
                            return (size_t) ((((((((size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0])));
                        }
                    }
                    break;
                case -4:
                    if (8 * sizeof(size_t) - 1 > 3 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(size_t, 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(size_t) - 1 > 4 * PyLong_SHIFT) {
                            return (size_t) (((size_t)-1)*(((((((((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(size_t) > 3 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(size_t, 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(size_t) - 1 > 4 * PyLong_SHIFT) {
                            return (size_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
            if (sizeof(size_t) <= sizeof(long)) {
                __PYX_VERIFY_RETURN_INT_EXC(size_t, long, PyLong_AsLong(x))
#ifdef HAVE_LONG_LONG
            } else if (sizeof(size_t) <= sizeof(PY_LONG_LONG)) {
                __PYX_VERIFY_RETURN_INT_EXC(size_t, 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
            size_t 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 (size_t) -1;
        }
    } else {
        size_t val;
        PyObject *tmp = __Pyx_PyNumber_IntOrLong(x);
        if (!tmp) return (size_t) -1;
        val = __Pyx_PyInt_As_size_t(tmp);
        Py_DECREF(tmp);
        return val;
    }
raise_overflow:
    PyErr_SetString(PyExc_OverflowError,
        "value too large to convert to size_t");
    return (size_t) -1;
raise_neg_overflow:
    PyErr_SetString(PyExc_OverflowError,
        "can't convert negative value to size_t");
    return (size_t) -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);
    }
}

/* 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[4], rtversion[4];
    PyOS_snprintf(ctversion, 4, "%d.%d", PY_MAJOR_VERSION, PY_MINOR_VERSION);
    PyOS_snprintf(rtversion, 4, "%s", Py_GetVersion());
    if (ctversion[0] != rtversion[0] || ctversion[2] != rtversion[2]) {
        char message[200];
        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;
}

/* 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 */
