/* Generated by Cython 0.20.2 on Tue Jan  6 12:36:00 2015 */

#define PY_SSIZE_T_CLEAN
#ifndef CYTHON_USE_PYLONG_INTERNALS
#ifdef PYLONG_BITS_IN_DIGIT
#define CYTHON_USE_PYLONG_INTERNALS 0
#else
#include "pyconfig.h"
#ifdef PYLONG_BITS_IN_DIGIT
#define CYTHON_USE_PYLONG_INTERNALS 1
#else
#define CYTHON_USE_PYLONG_INTERNALS 0
#endif
#endif
#endif
#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 < 0x02040000
    #error Cython requires Python 2.4+.
#else
#define CYTHON_ABI "0_20_2"
#include <stddef.h> /* For offsetof */
#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
#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_CPYTHON 0
#else
#define CYTHON_COMPILING_IN_PYPY 0
#define CYTHON_COMPILING_IN_CPYTHON 1
#endif
#if CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX < 0x02070600
#define Py_OptimizeFlag 0
#endif
#if PY_VERSION_HEX < 0x02050000
  typedef int Py_ssize_t;
  #define PY_SSIZE_T_MAX INT_MAX
  #define PY_SSIZE_T_MIN INT_MIN
  #define PY_FORMAT_SIZE_T ""
  #define CYTHON_FORMAT_SSIZE_T ""
  #define PyInt_FromSsize_t(z) PyInt_FromLong(z)
  #define PyInt_AsSsize_t(o)   __Pyx_PyInt_As_int(o)
  #define PyNumber_Index(o)    ((PyNumber_Check(o) && !PyFloat_Check(o)) ? PyNumber_Int(o) : \
                                (PyErr_Format(PyExc_TypeError, \
                                              "expected index value, got %.200s", Py_TYPE(o)->tp_name), \
                                 (PyObject*)0))
  #define __Pyx_PyIndex_Check(o) (PyNumber_Check(o) && !PyFloat_Check(o) && \
                                  !PyComplex_Check(o))
  #define PyIndex_Check __Pyx_PyIndex_Check
  #define PyErr_WarnEx(category, message, stacklevel) PyErr_Warn(category, message)
  #define __PYX_BUILD_PY_SSIZE_T "i"
#else
  #define __PYX_BUILD_PY_SSIZE_T "n"
  #define CYTHON_FORMAT_SSIZE_T "z"
  #define __Pyx_PyIndex_Check PyIndex_Check
#endif
#if PY_VERSION_HEX < 0x02060000
  #define Py_REFCNT(ob) (((PyObject*)(ob))->ob_refcnt)
  #define Py_TYPE(ob)   (((PyObject*)(ob))->ob_type)
  #define Py_SIZE(ob)   (((PyVarObject*)(ob))->ob_size)
  #define PyVarObject_HEAD_INIT(type, size) \
          PyObject_HEAD_INIT(type) size,
  #define PyType_Modified(t)
  typedef struct {
     void *buf;
     PyObject *obj;
     Py_ssize_t len;
     Py_ssize_t itemsize;
     int readonly;
     int ndim;
     char *format;
     Py_ssize_t *shape;
     Py_ssize_t *strides;
     Py_ssize_t *suboffsets;
     void *internal;
  } Py_buffer;
  #define PyBUF_SIMPLE 0
  #define PyBUF_WRITABLE 0x0001
  #define PyBUF_FORMAT 0x0004
  #define PyBUF_ND 0x0008
  #define PyBUF_STRIDES (0x0010 | PyBUF_ND)
  #define PyBUF_C_CONTIGUOUS (0x0020 | PyBUF_STRIDES)
  #define PyBUF_F_CONTIGUOUS (0x0040 | PyBUF_STRIDES)
  #define PyBUF_ANY_CONTIGUOUS (0x0080 | PyBUF_STRIDES)
  #define PyBUF_INDIRECT (0x0100 | PyBUF_STRIDES)
  #define PyBUF_RECORDS (PyBUF_STRIDES | PyBUF_FORMAT | PyBUF_WRITABLE)
  #define PyBUF_FULL (PyBUF_INDIRECT | PyBUF_FORMAT | PyBUF_WRITABLE)
  typedef int (*getbufferproc)(PyObject *, Py_buffer *, int);
  typedef void (*releasebufferproc)(PyObject *, Py_buffer *);
#endif
#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_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 PyType_Type
#endif
#if PY_VERSION_HEX < 0x02060000
  #define PyUnicode_FromString(s) PyUnicode_Decode(s, strlen(s), "UTF-8", "strict")
#endif
#if PY_MAJOR_VERSION >= 3
  #define Py_TPFLAGS_CHECKTYPES 0
  #define Py_TPFLAGS_HAVE_INDEX 0
#endif
#if (PY_VERSION_HEX < 0x02060000) || (PY_MAJOR_VERSION >= 3)
  #define Py_TPFLAGS_HAVE_NEWBUFFER 0
#endif
#if PY_VERSION_HEX < 0x02060000
  #define Py_TPFLAGS_HAVE_VERSION_TAG 0
#endif
#if PY_VERSION_HEX < 0x02060000 && !defined(Py_TPFLAGS_IS_ABSTRACT)
  #define Py_TPFLAGS_IS_ABSTRACT 0
#endif
#if PY_VERSION_HEX < 0x030400a1 && !defined(Py_TPFLAGS_HAVE_FINALIZE)
  #define Py_TPFLAGS_HAVE_FINALIZE 0
#endif
#if PY_VERSION_HEX > 0x03030000 && defined(PyUnicode_KIND)
  #define CYTHON_PEP393_ENABLED 1
  #define __Pyx_PyUnicode_READY(op)       (likely(PyUnicode_IS_READY(op)) ? \
                                              0 : _PyUnicode_Ready((PyObject *)(op)))
  #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_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)
#else
  #define CYTHON_PEP393_ENABLED 0
  #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_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]))
#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
#define __Pyx_PyString_FormatSafe(a, b)  ((unlikely((a) == Py_None)) ? PyNumber_Remainder(a, b) : __Pyx_PyString_Format(a, b))
#define __Pyx_PyUnicode_FormatSafe(a, b)  ((unlikely((a) == Py_None)) ? 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
  #define PyBaseString_Type            PyUnicode_Type
  #define PyStringObject               PyUnicodeObject
  #define PyString_Type                PyUnicode_Type
  #define PyString_Check               PyUnicode_Check
  #define PyString_CheckExact          PyUnicode_CheckExact
#endif
#if PY_VERSION_HEX < 0x02060000
  #define PyBytesObject                PyStringObject
  #define PyBytes_Type                 PyString_Type
  #define PyBytes_Check                PyString_Check
  #define PyBytes_CheckExact           PyString_CheckExact
  #define PyBytes_FromString           PyString_FromString
  #define PyBytes_FromStringAndSize    PyString_FromStringAndSize
  #define PyBytes_FromFormat           PyString_FromFormat
  #define PyBytes_DecodeEscape         PyString_DecodeEscape
  #define PyBytes_AsString             PyString_AsString
  #define PyBytes_AsStringAndSize      PyString_AsStringAndSize
  #define PyBytes_Size                 PyString_Size
  #define PyBytes_AS_STRING            PyString_AS_STRING
  #define PyBytes_GET_SIZE             PyString_GET_SIZE
  #define PyBytes_Repr                 PyString_Repr
  #define PyBytes_Concat               PyString_Concat
  #define PyBytes_ConcatAndDel         PyString_ConcatAndDel
#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_CheckExact(obj) || PyUnicode_CheckExact(obj) || \
                                         PyString_Check(obj) || PyUnicode_Check(obj))
  #define __Pyx_PyBaseString_CheckExact(obj) (PyString_CheckExact(obj) || PyUnicode_CheckExact(obj))
#endif
#if PY_VERSION_HEX < 0x02060000
  #define PySet_Check(obj)             PyObject_TypeCheck(obj, &PySet_Type)
  #define PyFrozenSet_Check(obj)       PyObject_TypeCheck(obj, &PyFrozenSet_Type)
#endif
#ifndef PySet_CheckExact
  #define PySet_CheckExact(obj)        (Py_TYPE(obj) == &PySet_Type)
#endif
#define __Pyx_TypeCheck(obj, type) PyObject_TypeCheck(obj, (PyTypeObject *)type)
#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_VERSION_HEX < 0x030200A4
  typedef long Py_hash_t;
  #define __Pyx_PyInt_FromHash_t PyInt_FromLong
  #define __Pyx_PyInt_AsHash_t   PyInt_AsLong
#else
  #define __Pyx_PyInt_FromHash_t PyInt_FromSsize_t
  #define __Pyx_PyInt_AsHash_t   PyInt_AsSsize_t
#endif
#if (PY_MAJOR_VERSION < 3) || (PY_VERSION_HEX >= 0x03010300)
  #define __Pyx_PySequence_GetSlice(obj, a, b) PySequence_GetSlice(obj, a, b)
  #define __Pyx_PySequence_SetSlice(obj, a, b, value) PySequence_SetSlice(obj, a, b, value)
  #define __Pyx_PySequence_DelSlice(obj, a, b) PySequence_DelSlice(obj, a, b)
#else
  #define __Pyx_PySequence_GetSlice(obj, a, b) (unlikely(!(obj)) ? \
        (PyErr_SetString(PyExc_SystemError, "null argument to internal routine"), (PyObject*)0) : \
        (likely((obj)->ob_type->tp_as_mapping) ? (PySequence_GetSlice(obj, a, b)) : \
            (PyErr_Format(PyExc_TypeError, "'%.200s' object is unsliceable", (obj)->ob_type->tp_name), (PyObject*)0)))
  #define __Pyx_PySequence_SetSlice(obj, a, b, value) (unlikely(!(obj)) ? \
        (PyErr_SetString(PyExc_SystemError, "null argument to internal routine"), -1) : \
        (likely((obj)->ob_type->tp_as_mapping) ? (PySequence_SetSlice(obj, a, b, value)) : \
            (PyErr_Format(PyExc_TypeError, "'%.200s' object doesn't support slice assignment", (obj)->ob_type->tp_name), -1)))
  #define __Pyx_PySequence_DelSlice(obj, a, b) (unlikely(!(obj)) ? \
        (PyErr_SetString(PyExc_SystemError, "null argument to internal routine"), -1) : \
        (likely((obj)->ob_type->tp_as_mapping) ? (PySequence_DelSlice(obj, a, b)) : \
            (PyErr_Format(PyExc_TypeError, "'%.200s' object doesn't support slice deletion", (obj)->ob_type->tp_name), -1)))
#endif
#if PY_MAJOR_VERSION >= 3
  #define PyMethod_New(func, self, klass) ((self) ? PyMethod_New(func, self) : PyInstanceMethod_New(func))
#endif
#if PY_VERSION_HEX < 0x02050000
  #define __Pyx_GetAttrString(o,n)   PyObject_GetAttrString((o),((char *)(n)))
  #define __Pyx_SetAttrString(o,n,a) PyObject_SetAttrString((o),((char *)(n)),(a))
  #define __Pyx_DelAttrString(o,n)   PyObject_DelAttrString((o),((char *)(n)))
#else
  #define __Pyx_GetAttrString(o,n)   PyObject_GetAttrString((o),(n))
  #define __Pyx_SetAttrString(o,n,a) PyObject_SetAttrString((o),(n),(a))
  #define __Pyx_DelAttrString(o,n)   PyObject_DelAttrString((o),(n))
#endif
#if PY_VERSION_HEX < 0x02050000
  #define __Pyx_NAMESTR(n) ((char *)(n))
  #define __Pyx_DOCSTR(n)  ((char *)(n))
#else
  #define __Pyx_NAMESTR(n) (n)
  #define __Pyx_DOCSTR(n)  (n)
#endif
#ifndef CYTHON_INLINE
  #if 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
#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
#ifdef NAN
#define __PYX_NAN() ((float) NAN)
#else
static CYTHON_INLINE float __PYX_NAN() {
  /* Initialize NaN. The sign is irrelevant, an exponent with all bits 1 and
   a nonzero mantissa means NaN. If the first bit in the mantissa is 1, it is
   a quiet NaN. */
  float value;
  memset(&value, 0xFF, sizeof(value));
  return value;
}
#endif
#ifdef __cplusplus
template<typename T>
void __Pyx_call_destructor(T* x) {
    x->~T();
}
#endif


#if PY_MAJOR_VERSION >= 3
  #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

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

#if defined(WIN32) || defined(MS_WINDOWS)
#define _USE_MATH_DEFINES
#endif
#include <math.h>
#define __PYX_HAVE__lupa___lupa
#define __PYX_HAVE_API__lupa___lupa
#include "lua.h"
#include "lauxlib.h"
#include "lualib.h"
#include "lupa_defs.h"
#include "stdint.h"
#include "pythread.h"
#include "string.h"
#include "stdio.h"
#ifdef _OPENMP
#include <omp.h>
#endif /* _OPENMP */

#ifdef PYREX_WITHOUT_ASSERTIONS
#define CYTHON_WITHOUT_ASSERTIONS
#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
typedef struct {PyObject **p; char *s; const Py_ssize_t n; const char* encoding;
                const char is_unicode; const char is_str; const char intern; } __Pyx_StringTabEntry; /*proto*/

#define __PYX_DEFAULT_STRING_ENCODING_IS_ASCII 0
#define __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT 0
#define __PYX_DEFAULT_STRING_ENCODING ""
#define __Pyx_PyObject_FromString __Pyx_PyBytes_FromString
#define __Pyx_PyObject_FromStringAndSize __Pyx_PyBytes_FromStringAndSize
#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 char* __Pyx_PyObject_AsString(PyObject*);
static CYTHON_INLINE 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_PyObject_AsSString(s)    ((signed char*) __Pyx_PyObject_AsString(s))
#define __Pyx_PyObject_AsUString(s)    ((unsigned char*) __Pyx_PyObject_AsString(s))
#define __Pyx_PyObject_FromUString(s)  __Pyx_PyObject_FromString((const char*)s)
#define __Pyx_PyBytes_FromUString(s)   __Pyx_PyBytes_FromString((const char*)s)
#define __Pyx_PyByteArray_FromUString(s)   __Pyx_PyByteArray_FromString((const char*)s)
#define __Pyx_PyStr_FromUString(s)     __Pyx_PyStr_FromString((const char*)s)
#define __Pyx_PyUnicode_FromUString(s) __Pyx_PyUnicode_FromString((const char*)s)
#if PY_MAJOR_VERSION < 3
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);
}
#else
#define __Pyx_Py_UNICODE_strlen Py_UNICODE_strlen
#endif
#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_Owned_Py_None(b) (Py_INCREF(Py_None), Py_None)
#define __Pyx_PyBool_FromLong(b) ((b) ? (Py_INCREF(Py_True), Py_True) : (Py_INCREF(Py_False), Py_False))
static CYTHON_INLINE int __Pyx_PyObject_IsTrue(PyObject*);
static CYTHON_INLINE PyObject* __Pyx_PyNumber_Int(PyObject* x);
static CYTHON_INLINE Py_ssize_t __Pyx_PyIndex_AsSsize_t(PyObject*);
static CYTHON_INLINE PyObject * __Pyx_PyInt_FromSize_t(size_t);
#if CYTHON_COMPILING_IN_CPYTHON
#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 && __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*) (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;
    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));
    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 PyObject *__pyx_m;
static PyObject *__pyx_d;
static PyObject *__pyx_b;
static PyObject *__pyx_empty_tuple;
static PyObject *__pyx_empty_bytes;
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.pyx",
  "lock.pxi",
  "type.pxd",
  "bool.pxd",
  "complex.pxd",
};

/*--- 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":52
 * 
 * 
 * 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":900
 * 
 * 
 * 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":58
 *     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":1104
 *      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":1264
 *     return unpack_lua_results(runtime, L)
 * 
 * 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;
};

/* "/Users/ma/projects/immunio/agent-python/immunio/agent/deps/lupa/lupa/lock.pxi":5
 * from cpython.exc cimport PyErr_NoMemory
 * 
 * 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":112
 * 
 * @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":476
 * @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":659
 * @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":750
 * @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":789
 * @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":804
 * @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":909
 * @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":1020
 * @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":391
 * # 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":417
 * 
 * 
 * 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":112
 * 
 * @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 *);
  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 *);
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":476
 * @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":659
 * @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":750
 * @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":789
 * @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":804
 * @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;
#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); /*proto*/
  #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 /* CYTHON_REFNANNY */
#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)

#if CYTHON_COMPILING_IN_CPYTHON
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);
}
#else
#define __Pyx_PyObject_GetAttrStr(o,n) PyObject_GetAttr(o,n)
#endif

static PyObject *__Pyx_GetBuiltinName(PyObject *name); /*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); /*proto*/

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

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

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

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

static CYTHON_INLINE void __Pyx_ErrRestore(PyObject *type, PyObject *value, PyObject *tb); /*proto*/
static CYTHON_INLINE void __Pyx_ErrFetch(PyObject **type, PyObject **value, PyObject **tb); /*proto*/

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

#include <string.h>

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

static int __Pyx_GetException(PyObject **type, PyObject **value, PyObject **tb); /*proto*/

static CYTHON_INLINE void __Pyx_ExceptionSwap(PyObject **type, PyObject **value, PyObject **tb); /*proto*/

static CYTHON_INLINE void __Pyx_ExceptionSave(PyObject **type, PyObject **value, PyObject **tb); /*proto*/
static void __Pyx_ExceptionReset(PyObject *type, PyObject *value, PyObject *tb); /*proto*/

static CYTHON_INLINE PyObject *__Pyx_GetModuleGlobalName(PyObject *name); /*proto*/

#if CYTHON_COMPILING_IN_CPYTHON && PY_MAJOR_VERSION >= 3
#define __Pyx_PyCallable_Check(obj)   ((obj)->ob_type->tp_call != NULL)
#else
#define __Pyx_PyCallable_Check(obj)   PyCallable_Check(obj)
#endif

static CYTHON_INLINE void __Pyx_RaiseTooManyValuesError(Py_ssize_t expected);

static CYTHON_INLINE void __Pyx_RaiseNeedMoreValuesError(Py_ssize_t index);

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

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

static CYTHON_INLINE void __Pyx_RaiseUnboundLocalError(const char *varname);

#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 CYTHON_INLINE 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);

static PyObject* __Pyx_PyObject_CallMethodTuple(PyObject* obj, PyObject* method_name, PyObject* args) {
    PyObject *method, *result = NULL;
    if (unlikely(!args)) return NULL;
    method = __Pyx_PyObject_GetAttrStr(obj, method_name);
    if (unlikely(!method)) goto bad;
    result = __Pyx_PyObject_Call(method, args, NULL);
    Py_DECREF(method);
bad:
    Py_DECREF(args);
    return result;
}
#define __Pyx_PyObject_CallMethod3(obj, name, arg1, arg2, arg3) \
    __Pyx_PyObject_CallMethodTuple(obj, name, PyTuple_Pack(3, arg1, arg2, arg3))
#define __Pyx_PyObject_CallMethod2(obj, name, arg1, arg2) \
    __Pyx_PyObject_CallMethodTuple(obj, name, PyTuple_Pack(2, arg1, arg2))
#define __Pyx_PyObject_CallMethod1(obj, name, arg1) \
    __Pyx_PyObject_CallMethodTuple(obj, name, PyTuple_Pack(1, arg1))
#define __Pyx_PyObject_CallMethod0(obj, name) \
    __Pyx_PyObject_CallMethodTuple(obj, name, (Py_INCREF(__pyx_empty_tuple), __pyx_empty_tuple))

static CYTHON_INLINE void __Pyx_RaiseNoneNotIterableError(void);

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

static CYTHON_INLINE int __Pyx_unpack_tuple2(PyObject* tuple, PyObject** value1, PyObject** value2,
                                             int is_tuple, int has_known_size, int decref_tuple);

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

static CYTHON_INLINE void __Pyx_RaiseClosureNameError(const char *varname);

static PyTypeObject* __Pyx_FetchCommonType(PyTypeObject* type);

#define __Pyx_CyFunction_USED 1
#include <structmember.h>
#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;
    PyObject *func_dict;
    PyObject *func_weakreflist;
    PyObject *func_name;
    PyObject *func_qualname;
    PyObject *func_doc;
    PyObject *func_globals;
    PyObject *func_code;
    PyObject *func_closure;
    PyObject *func_classobj; /* No-args super() class cell */
    void *defaults;
    int defaults_pyobjects;
    int flags;
    PyObject *defaults_tuple;   /* Const defaults tuple */
    PyObject *defaults_kwdict;  /* Const kwonly defaults dict */
    PyObject *(*defaults_getter)(PyObject *);
    PyObject *func_annotations; /* function annotations dict */
} __pyx_CyFunctionObject;
static PyTypeObject *__pyx_CyFunctionType = 0;
#define __Pyx_CyFunction_NewEx(ml, flags, qualname, self, module, globals, code) \
    __Pyx_CyFunction_New(__pyx_CyFunctionType, ml, flags, qualname, self, module, globals, code)
static PyObject *__Pyx_CyFunction_New(PyTypeObject *, 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);

#if CYTHON_COMPILING_IN_CPYTHON
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);
        Py_SIZE(list) = len+1;
        return 0;
    }
    return PyList_Append(list, x);
}
#else
#define __Pyx_ListComp_Append(L,x) PyList_Append(L,x)
#endif

static void __Pyx_WriteUnraisable(const char *name, int clineno,
                                  int lineno, const char *filename,
                                  int full_traceback); /*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));

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);
}

static int __Pyx_PyUnicode_Tailmatch(PyObject* s, PyObject* substr,
                                     Py_ssize_t start, Py_ssize_t end, int direction) {
    if (unlikely(PyTuple_Check(substr))) {
        Py_ssize_t i, count = PyTuple_GET_SIZE(substr);
        for (i = 0; i < count; i++) {
            int result;
#if CYTHON_COMPILING_IN_CPYTHON
            result = PyUnicode_Tailmatch(s, PyTuple_GET_ITEM(substr, i),
                                         start, end, direction);
#else
            PyObject* sub = PySequence_GetItem(substr, i);
            if (unlikely(!sub)) return -1;
            result = PyUnicode_Tailmatch(s, sub, start, end, direction);
            Py_DECREF(sub);
#endif
            if (result) {
                return result;
            }
        }
        return 0;
    }
    return PyUnicode_Tailmatch(s, substr, start, end, direction);
}

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;
#if PY_VERSION_HEX >= 0x02060000
    Py_buffer view;
    view.obj = NULL;
#endif
    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 PyUnicode_Tailmatch(self, arg, start, end, direction);
    }
#endif
    else {
#if PY_VERSION_HEX < 0x02060000
        if (unlikely(PyObject_AsCharBuffer(arg, &sub_ptr, &sub_len)))
            return -1;
#else
        if (unlikely(PyObject_GetBuffer(self, &view, PyBUF_SIMPLE) == -1))
            return -1;
        sub_ptr = (const char*) view.buf;
        sub_len = view.len;
#endif
    }
    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 PY_VERSION_HEX >= 0x02060000
    if (view.obj)
        PyBuffer_Release(&view);
#endif
    return retval;
}
static int __Pyx_PyBytes_Tailmatch(PyObject* self, PyObject* substr, Py_ssize_t start,
                                   Py_ssize_t end, int direction)
{
    if (unlikely(PyTuple_Check(substr))) {
        Py_ssize_t i, count = PyTuple_GET_SIZE(substr);
        for (i = 0; i < count; i++) {
            int result;
#if CYTHON_COMPILING_IN_CPYTHON
            result = __Pyx_PyBytes_SingleTailmatch(self, PyTuple_GET_ITEM(substr, i),
                                                   start, end, direction);
#else
            PyObject* sub = PySequence_GetItem(substr, 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;
    }
    return __Pyx_PyBytes_SingleTailmatch(self, substr, start, end, direction);
}

static CYTHON_INLINE int __Pyx_TypeTest(PyObject *obj, PyTypeObject *type); /*proto*/

static CYTHON_INLINE int __Pyx_ArgTypeTest(PyObject *obj, PyTypeObject *type, int none_allowed,
    const char *name, int exact); /*proto*/

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

#if CYTHON_COMPILING_IN_CPYTHON
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);
        Py_SIZE(list) = len+1;
        return 0;
    }
    return PyList_Append(list, x);
}
#else
#define __Pyx_PyList_Append(L,x) PyList_Append(L,x)
#endif

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

#if PY_MAJOR_VERSION >= 3
static PyObject *__Pyx_PyDict_GetItem(PyObject *d, PyObject* key) {
    PyObject *value;
    value = PyDict_GetItemWithError(d, key);
    if (unlikely(!value)) {
        if (!PyErr_Occurred()) {
            PyObject* args = PyTuple_Pack(1, key);
            if (likely(args))
                PyErr_SetObject(PyExc_KeyError, args);
            Py_XDECREF(args);
        }
        return NULL;
    }
    Py_INCREF(value);
    return value;
}
#else
    #define __Pyx_PyDict_GetItem(d, key) PyObject_GetItem(d, key)
#endif

#ifndef __PYX_FORCE_INIT_THREADS
  #define __PYX_FORCE_INIT_THREADS 0
#endif

#define __Pyx_PyObject_Pop(L) (PyList_CheckExact(L) ? \
    __Pyx_PyList_Pop(L) : __Pyx__PyObject_Pop(L))
static CYTHON_INLINE PyObject* __Pyx_PyList_Pop(PyObject* L); /*proto*/
static CYTHON_INLINE PyObject* __Pyx__PyObject_Pop(PyObject* L); /*proto*/

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

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

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

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

static PyObject *__Pyx_CalculateMetaclass(PyTypeObject *metaclass, PyObject *bases);

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

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

static CYTHON_INLINE int __Pyx_PyInt_As_int(PyObject *);

static CYTHON_INLINE PyObject* __Pyx_PyInt_From_long(long value);

static CYTHON_INLINE size_t __Pyx_PyInt_As_size_t(PyObject *);

static CYTHON_INLINE PyObject* __Pyx_PyInt_From_int(int value);

static CYTHON_INLINE long __Pyx_PyInt_As_long(PyObject *);

static int __Pyx_check_binary_version(void);

#if !defined(__Pyx_PyIdentifier_FromString)
#if PY_MAJOR_VERSION < 3
  #define __Pyx_PyIdentifier_FromString(s) PyString_FromString(s)
#else
  #define __Pyx_PyIdentifier_FromString(s) PyUnicode_FromString(s)
#endif
#endif

static PyObject *__Pyx_ImportModule(const char *name); /*proto*/

static PyTypeObject *__Pyx_ImportType(const char *module_name, const char *class_name, size_t size, int strict);  /*proto*/

typedef struct {
    int code_line;
    PyCodeObject* code_object;
} __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);

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

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


/* Module declarations from 'cython' */

/* Module declarations from 'lupa' */

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

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

/* 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 'libc.string' */

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

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

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

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

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

/* Module declarations from '__builtin__' */

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

/* 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 'libc.stdint' */

/* 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 luaL_Reg __pyx_v_4lupa_5_lupa_py_object_lib[6];
static luaL_Reg __pyx_v_4lupa_5_lupa_py_lib[7];
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 *); /*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 *); /*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*/
#define __Pyx_MODULE_NAME "lupa._lupa"
int __pyx_module_is_main_lupa___lupa = 0;

/* Implementation of 'lupa._lupa' */
static PyObject *__pyx_builtin_ImportError;
static PyObject *__pyx_builtin_Exception;
static PyObject *__pyx_builtin_RuntimeError;
static PyObject *__pyx_builtin_ValueError;
static PyObject *__pyx_builtin_TypeError;
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_MemoryError;
static PyObject *__pyx_builtin_enumerate;
static PyObject *__pyx_builtin_KeyError;
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_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_4eval(struct __pyx_obj_4lupa_5_lupa_LuaRuntime *__pyx_v_self, PyObject *__pyx_v_lua_code); /* 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); /* proto */
static PyObject *__pyx_pf_4lupa_5_lupa_10LuaRuntime_8require(struct __pyx_obj_4lupa_5_lupa_LuaRuntime *__pyx_v_self, PyObject *__pyx_v_modulename); /* proto */
static PyObject *__pyx_pf_4lupa_5_lupa_10LuaRuntime_10globals(struct __pyx_obj_4lupa_5_lupa_LuaRuntime *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_4lupa_5_lupa_10LuaRuntime_12table(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_14table_from(struct __pyx_obj_4lupa_5_lupa_LuaRuntime *__pyx_v_self, PyObject *__pyx_v_args); /* 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_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_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_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_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 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 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_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 char __pyx_k_G[] = "_G";
static char __pyx_k_L[] = "L";
static char __pyx_k_t[] = "t";
static char __pyx_k_v[] = "v";
static char __pyx_k_gc[] = "__gc";
static char __pyx_k_tb[] = "tb";
static char __pyx_k__18[] = "__";
static char __pyx_k_all[] = "__all__";
static char __pyx_k_doc[] = "__doc__";
static char __pyx_k_obj[] = "obj";
static char __pyx_k_pop[] = "pop";
static char __pyx_k_sys[] = "sys";
static char __pyx_k_args[] = "args";
static char __pyx_k_call[] = "__call";
static char __pyx_k_eval[] = "eval";
static char __pyx_k_func[] = "func";
static char __pyx_k_iter[] = "iter";
static char __pyx_k_main[] = "__main__";
static char __pyx_k_meth[] = "meth";
static char __pyx_k_name[] = "name";
static char __pyx_k_none[] = "none";
static char __pyx_k_self[] = "self";
static char __pyx_k_test[] = "__test__";
static char __pyx_k_what[] = "what";
static char __pyx_k_wrap[] = "wrap";
static char __pyx_k_Lua_s[] = "<Lua %s>";
static char __pyx_k_UTF_8[] = "UTF-8";
static char __pyx_k_index[] = "__index";
static char __pyx_k_ltype[] = "ltype";
static char __pyx_k_range[] = "range";
static char __pyx_k_table[] = "table";
static char __pyx_k_wraps[] = "wraps";
static char __pyx_k_append[] = "append";
static char __pyx_k_decode[] = "decode";
static char __pyx_k_import[] = "__import__";
static char __pyx_k_iterex[] = "iterex";
static char __pyx_k_kwargs[] = "kwargs";
static char __pyx_k_module[] = "__module__";
static char __pyx_k_object[] = "object";
static char __pyx_k_python[] = "python";
static char __pyx_k_return[] = "return ";
static char __pyx_k_thread[] = "thread";
static char __pyx_k_Mapping[] = "Mapping";
static char __pyx_k_POBJECT[] = "POBJECT";
static char __pyx_k_Py_None[] = "Py_None";
static char __pyx_k_builtin[] = "__builtin__";
static char __pyx_k_delattr[] = "__delattr__";
static char __pyx_k_getattr[] = "__getattr__";
static char __pyx_k_getitem[] = "__getitem__";
static char __pyx_k_old_top[] = "old_top";
static char __pyx_k_prepare[] = "__prepare__";
static char __pyx_k_require[] = "require";
static char __pyx_k_setattr[] = "__setattr__";
static char __pyx_k_wrapper[] = "wrapper";
static char __pyx_k_KeyError[] = "KeyError";
static char __pyx_k_LuaError[] = "LuaError";
static char __pyx_k_blocking[] = "blocking";
static char __pyx_k_builtins[] = "builtins";
static char __pyx_k_encoding[] = "encoding";
static char __pyx_k_exc_info[] = "exc_info";
static char __pyx_k_function[] = "function";
static char __pyx_k_lua_type[] = "lua_type";
static char __pyx_k_newindex[] = "__newindex";
static char __pyx_k_python_2[] = "<python>";
static char __pyx_k_qualname[] = "__qualname__";
static char __pyx_k_tostring[] = "__tostring";
static char __pyx_k_userdata[] = "userdata";
static char __pyx_k_Exception[] = "Exception";
static char __pyx_k_LuaIter_r[] = "LuaIter(%r)";
static char __pyx_k_TypeError[] = "TypeError";
static char __pyx_k_coroutine[] = "coroutine";
static char __pyx_k_enumerate[] = "enumerate";
static char __pyx_k_functools[] = "functools";
static char __pyx_k_iteritems[] = "iteritems";
static char __pyx_k_metaclass[] = "__metaclass__";
static char __pyx_k_LuaRuntime[] = "LuaRuntime";
static char __pyx_k_Lua_s_at_p[] = "<Lua %s at %p>";
static char __pyx_k_ValueError[] = "ValueError";
static char __pyx_k_lua_object[] = "lua_object";
static char __pyx_k_lupa__lupa[] = "lupa._lupa";
static char __pyx_k_pyx_vtable[] = "__pyx_vtable__";
static char __pyx_k_table_from[] = "table_from";
static char __pyx_k_ImportError[] = "ImportError";
static char __pyx_k_MemoryError[] = "MemoryError";
static char __pyx_k_as_function[] = "as_function";
static char __pyx_k_collections[] = "collections";
static char __pyx_k_RuntimeError[] = "RuntimeError";
static char __pyx_k_StopIteration[] = "StopIteration";
static char __pyx_k_as_attrgetter[] = "as_attrgetter";
static char __pyx_k_as_itemgetter[] = "as_itemgetter";
static char __pyx_k_lua_type_name[] = "lua_type_name";
static char __pyx_k_register_eval[] = "register_eval";
static char __pyx_k_AttributeError[] = "AttributeError";
static char __pyx_k_LuaSyntaxError[] = "LuaSyntaxError";
static char __pyx_k_lost_reference[] = "lost reference";
static char __pyx_k_source_encoding[] = "source_encoding";
static char __pyx_k_attribute_filter[] = "attribute_filter";
static char __pyx_k_invalid_arguments[] = "invalid arguments";
static char __pyx_k_register_builtins[] = "register_builtins";
static char __pyx_k_unpacks_lua_table[] = "unpacks_lua_table";
static char __pyx_k_UnicodeDecodeError[] = "UnicodeDecodeError";
static char __pyx_k_attribute_handlers[] = "attribute_handlers";
static char __pyx_k_globals_not_defined[] = "globals not defined";
static char __pyx_k_not_a_python_object[] = "not a python object";
static char __pyx_k_error_loading_code_s[] = "error loading code: %s";
static char __pyx_k_expected_string_got_s[] = "expected string, got %s";
static char __pyx_k_require_is_not_defined[] = "require is not defined";
static char __pyx_k_unpack_returned_tuples[] = "unpack_returned_tuples";
static char __pyx_k_Syntax_error_in_Lua_code[] = "Syntax error in Lua code.\n    ";
static char __pyx_k_error_during_Python_call[] = "error during Python call";
static char __pyx_k_unpacks_lua_table_method[] = "unpacks_lua_table_method";
static char __pyx_k_error_creating_an_iterator[] = "error creating an iterator";
static char __pyx_k_failed_to_convert_s_object[] = "failed to convert %s object";
static char __pyx_k_modulename_must_be_a_string[] = "modulename must be a string";
static char __pyx_k_Lua_object_is_not_a_function[] = "Lua object is not a function";
static char __pyx_k_error_during_Python_str_call[] = "error during Python str() call";
static char __pyx_k_error_during_type_adaptation[] = "error during type adaptation";
static char __pyx_k_Failed_to_acquire_thread_lock[] = "Failed to acquire thread lock";
static char __pyx_k_A_fast_Python_wrapper_around_Lu[] = "\nA fast Python wrapper around Lua and LuaJIT2.\n";
static char __pyx_k_Users_ma_projects_immunio_agent[] = "/Users/ma/projects/immunio/agent-python/immunio/agent/deps/lupa/lupa/_lupa.pyx";
static char __pyx_k_cannot_release_un_acquired_lock[] = "cannot release un-acquired lock";
static char __pyx_k_error_creating_an_iterator_with[] = "error creating an iterator with enumerate()";
static char __pyx_k_iteration_is_only_supported_for[] = "iteration is only supported for tables";
static char __pyx_k_unpacks_lua_table_method_locals[] = "unpacks_lua_table_method.<locals>.wrapper";
static char __pyx_k_Base_class_for_errors_in_the_Lua[] = "Base class for errors in the Lua runtime.\n    ";
static char __pyx_k_Failed_to_initialise_Lua_runtime[] = "Failed to initialise Lua runtime";
static char __pyx_k_Type_cannot_be_instantiated_from[] = "Type cannot be instantiated from Python";
static char __pyx_k_Type_cannot_be_instantiated_manu[] = "Type cannot be instantiated manually";
static char __pyx_k_attribute_filter_and_attribute_h[] = "attribute_filter and attribute_handlers are mutually exclusive";
static char __pyx_k_attribute_filter_must_be_callabl[] = "attribute_filter must be callable";
static char __pyx_k_attribute_handlers_must_be_a_seq[] = "attribute_handlers must be a sequence of two callables";
static char __pyx_k_byte_string_input_has_unknown_en[] = "byte string input has unknown encoding, only ASCII is allowed";
static char __pyx_k_can_t_send_non_None_value_to_a_j[] = "can't send non-None value to a just-started generator";
static char __pyx_k_cannot_iterate_over_non_table_fo[] = "cannot iterate over non-table (found %r)";
static char __pyx_k_cannot_mix_objects_from_differen[] = "cannot mix objects from different Lua runtimes";
static char __pyx_k_error_reading_Python_attribute_i[] = "error reading Python attribute/item";
static char __pyx_k_error_while_calling_next_iterato[] = "error while calling next(iterator)";
static char __pyx_k_error_while_cleaning_up_a_Python[] = "error while cleaning up a Python object";
static char __pyx_k_error_writing_Python_attribute_i[] = "error writing Python attribute/item";
static char __pyx_k_failed_to_convert_argument_at_in[] = "failed to convert argument at index %d";
static char __pyx_k_item_attribute_access_not_suppor[] = "item/attribute access not supported on functions";
static char __pyx_k_unpacks_lua_table_locals_wrapper[] = "unpacks_lua_table.<locals>.wrapper";
static PyObject *__pyx_n_s_AttributeError;
static PyObject *__pyx_kp_s_Base_class_for_errors_in_the_Lua;
static PyObject *__pyx_n_s_Exception;
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_ImportError;
static PyObject *__pyx_n_s_KeyError;
static PyObject *__pyx_n_s_L;
static PyObject *__pyx_n_s_LuaError;
static PyObject *__pyx_kp_u_LuaIter_r;
static PyObject *__pyx_n_s_LuaRuntime;
static PyObject *__pyx_n_s_LuaSyntaxError;
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_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_kp_s_Users_ma_projects_immunio_agent;
static PyObject *__pyx_n_s_ValueError;
static PyObject *__pyx_n_b__18;
static PyObject *__pyx_n_u__18;
static PyObject *__pyx_n_s_all;
static PyObject *__pyx_n_s_append;
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_collections;
static PyObject *__pyx_n_s_coroutine;
static PyObject *__pyx_n_s_decode;
static PyObject *__pyx_n_s_delattr;
static PyObject *__pyx_n_s_doc;
static PyObject *__pyx_n_s_encoding;
static PyObject *__pyx_n_s_enumerate;
static PyObject *__pyx_kp_u_error_loading_code_s;
static PyObject *__pyx_n_b_eval;
static PyObject *__pyx_n_s_eval;
static PyObject *__pyx_n_s_exc_info;
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_n_s_functools;
static PyObject *__pyx_n_s_getattr;
static PyObject *__pyx_n_s_getitem;
static PyObject *__pyx_kp_s_globals_not_defined;
static PyObject *__pyx_n_s_import;
static PyObject *__pyx_kp_s_item_attribute_access_not_suppor;
static PyObject *__pyx_kp_s_iteration_is_only_supported_for;
static PyObject *__pyx_n_s_iteritems;
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_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_n_s_main;
static PyObject *__pyx_n_s_metaclass;
static PyObject *__pyx_n_s_meth;
static PyObject *__pyx_n_s_module;
static PyObject *__pyx_kp_s_modulename_must_be_a_string;
static PyObject *__pyx_n_s_name;
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_pop;
static PyObject *__pyx_n_s_prepare;
static PyObject *__pyx_n_s_pyx_vtable;
static PyObject *__pyx_n_s_qualname;
static PyObject *__pyx_n_s_range;
static PyObject *__pyx_n_s_register_builtins;
static PyObject *__pyx_n_s_register_eval;
static PyObject *__pyx_kp_s_require_is_not_defined;
static PyObject *__pyx_kp_b_return;
static PyObject *__pyx_n_s_self;
static PyObject *__pyx_n_s_setattr;
static PyObject *__pyx_n_s_source_encoding;
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_what;
static PyObject *__pyx_n_s_wrap;
static PyObject *__pyx_n_s_wrapper;
static PyObject *__pyx_n_s_wraps;
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__16;
static PyObject *__pyx_tuple__17;
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__29;
static PyObject *__pyx_tuple__31;
static PyObject *__pyx_tuple__33;
static PyObject *__pyx_tuple__35;
static PyObject *__pyx_codeobj__11;
static PyObject *__pyx_codeobj__13;
static PyObject *__pyx_codeobj__28;
static PyObject *__pyx_codeobj__30;
static PyObject *__pyx_codeobj__32;
static PyObject *__pyx_codeobj__34;
static PyObject *__pyx_codeobj__36;

/* "/Users/ma/projects/immunio/agent-python/immunio/agent/deps/lupa/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;
  PyObject *__pyx_t_2;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__cinit__", 0);

  /* "/Users/ma/projects/immunio/agent-python/immunio/agent/deps/lupa/lupa/lock.pxi":21
 * 
 *     def __cinit__(self):
 *         self._owner = -1             # <<<<<<<<<<<<<<
 *         self._count = 0
 *         self._is_locked = False
 */
  __pyx_v_self->_owner = -1;

  /* "/Users/ma/projects/immunio/agent-python/immunio/agent/deps/lupa/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;

  /* "/Users/ma/projects/immunio/agent-python/immunio/agent/deps/lupa/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;

  /* "/Users/ma/projects/immunio/agent-python/immunio/agent/deps/lupa/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;

  /* "/Users/ma/projects/immunio/agent-python/immunio/agent/deps/lupa/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:
 *             PyErr_NoMemory()
 */
  __pyx_v_self->_real_lock = PyThread_allocate_lock();

  /* "/Users/ma/projects/immunio/agent-python/immunio/agent/deps/lupa/lupa/lock.pxi":26
 *         self._pending_requests = 0
 *         self._real_lock = pythread.PyThread_allocate_lock()
 *         if self._real_lock is NULL:             # <<<<<<<<<<<<<<
 *             PyErr_NoMemory()
 * 
 */
  __pyx_t_1 = ((__pyx_v_self->_real_lock == NULL) != 0);
  if (__pyx_t_1) {

    /* "/Users/ma/projects/immunio/agent-python/immunio/agent/deps/lupa/lupa/lock.pxi":27
 *         self._real_lock = pythread.PyThread_allocate_lock()
 *         if self._real_lock is NULL:
 *             PyErr_NoMemory()             # <<<<<<<<<<<<<<
 * 
 *     def __dealloc__(self):
 */
    __pyx_t_2 = PyErr_NoMemory(); if (unlikely(__pyx_t_2 == NULL)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 27; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "/Users/ma/projects/immunio/agent-python/immunio/agent/deps/lupa/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;
}

/* "/Users/ma/projects/immunio/agent-python/immunio/agent/deps/lupa/lupa/lock.pxi":29
 *             PyErr_NoMemory()
 * 
 *     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);

  /* "/Users/ma/projects/immunio/agent-python/immunio/agent/deps/lupa/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) {

    /* "/Users/ma/projects/immunio/agent-python/immunio/agent/deps/lupa/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);

    /* "/Users/ma/projects/immunio/agent-python/immunio/agent/deps/lupa/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;
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "/Users/ma/projects/immunio/agent-python/immunio/agent/deps/lupa/lupa/lock.pxi":29
 *             PyErr_NoMemory()
 * 
 *     def __dealloc__(self):             # <<<<<<<<<<<<<<
 *         if self._real_lock is not NULL:
 *             pythread.PyThread_free_lock(self._real_lock)
 */

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

/* "/Users/ma/projects/immunio/agent-python/immunio/agent/deps/lupa/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 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);
        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 = PyDict_GetItem(__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_filename = __pyx_f[1]; __pyx_lineno = 34; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        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_filename = __pyx_f[1]; __pyx_lineno = 34; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 34; __pyx_clineno = __LINE__; goto __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);

  /* "/Users/ma/projects/immunio/agent-python/immunio/agent/deps/lupa/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_filename = __pyx_f[1]; __pyx_lineno = 35; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "/Users/ma/projects/immunio/agent-python/immunio/agent/deps/lupa/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;
}

/* "/Users/ma/projects/immunio/agent-python/immunio/agent/deps/lupa/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 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);

  /* "/Users/ma/projects/immunio/agent-python/immunio/agent/deps/lupa/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 (__pyx_t_1) {

    /* "/Users/ma/projects/immunio/agent-python/immunio/agent/deps/lupa/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_filename = __pyx_f[1]; __pyx_lineno = 39; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 39; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }

  /* "/Users/ma/projects/immunio/agent-python/immunio/agent/deps/lupa/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);

  /* "/Users/ma/projects/immunio/agent-python/immunio/agent/deps/lupa/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;
}

/* "/Users/ma/projects/immunio/agent-python/immunio/agent/deps/lupa/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 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);

  /* "/Users/ma/projects/immunio/agent-python/immunio/agent/deps/lupa/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_filename = __pyx_f[1]; __pyx_lineno = 46; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "/Users/ma/projects/immunio/agent-python/immunio/agent/deps/lupa/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;
}

/* "/Users/ma/projects/immunio/agent-python/immunio/agent/deps/lupa/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 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);
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_t)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        case  1:
        if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_v)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("__exit__", 1, 3, 3, 1); {__pyx_filename = __pyx_f[1]; __pyx_lineno = 48; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        }
        case  2:
        if (likely((values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_tb)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("__exit__", 1, 3, 3, 2); {__pyx_filename = __pyx_f[1]; __pyx_lineno = 48; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__exit__") < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 48; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 48; __pyx_clineno = __LINE__; goto __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);

  /* "/Users/ma/projects/immunio/agent-python/immunio/agent/deps/lupa/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 (__pyx_t_1) {

    /* "/Users/ma/projects/immunio/agent-python/immunio/agent/deps/lupa/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__2, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 51; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 51; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }

  /* "/Users/ma/projects/immunio/agent-python/immunio/agent/deps/lupa/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);

  /* "/Users/ma/projects/immunio/agent-python/immunio/agent/deps/lupa/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;
}

/* "/Users/ma/projects/immunio/agent-python/immunio/agent/deps/lupa/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 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);

  /* "/Users/ma/projects/immunio/agent-python/immunio/agent/deps/lupa/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_filename = __pyx_f[1]; __pyx_lineno = 55; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "/Users/ma/projects/immunio/agent-python/immunio/agent/deps/lupa/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;
}

/* "/Users/ma/projects/immunio/agent-python/immunio/agent/deps/lupa/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;

  /* "/Users/ma/projects/immunio/agent-python/immunio/agent/deps/lupa/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) {

    /* "/Users/ma/projects/immunio/agent-python/immunio/agent/deps/lupa/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) {

      /* "/Users/ma/projects/immunio/agent-python/immunio/agent/deps/lupa/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);

      /* "/Users/ma/projects/immunio/agent-python/immunio/agent/deps/lupa/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;
    }
    goto __pyx_L3;
  }

  /* "/Users/ma/projects/immunio/agent-python/immunio/agent/deps/lupa/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) {

    /* "/Users/ma/projects/immunio/agent-python/immunio/agent/deps/lupa/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;

    /* "/Users/ma/projects/immunio/agent-python/immunio/agent/deps/lupa/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;

    /* "/Users/ma/projects/immunio/agent-python/immunio/agent/deps/lupa/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;
  }
  __pyx_L3:;

  /* "/Users/ma/projects/immunio/agent-python/immunio/agent/deps/lupa/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;
  }

  /* "/Users/ma/projects/immunio/agent-python/immunio/agent/deps/lupa/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;

  /* "/Users/ma/projects/immunio/agent-python/immunio/agent/deps/lupa/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;
}

/* "/Users/ma/projects/immunio/agent-python/immunio/agent/deps/lupa/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;
  int __pyx_t_3;

  /* "/Users/ma/projects/immunio/agent-python/immunio/agent/deps/lupa/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_1 = ((!(__pyx_v_lock->_is_locked != 0)) != 0);
  if (__pyx_t_1) {
    __pyx_t_2 = ((!(__pyx_v_lock->_pending_requests != 0)) != 0);
    __pyx_t_3 = __pyx_t_2;
  } else {
    __pyx_t_3 = __pyx_t_1;
  }
  if (__pyx_t_3) {

    /* "/Users/ma/projects/immunio/agent-python/immunio/agent/deps/lupa/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_3 = ((!(PyThread_acquire_lock(__pyx_v_lock->_real_lock, __pyx_v_wait) != 0)) != 0);
    if (__pyx_t_3) {

      /* "/Users/ma/projects/immunio/agent-python/immunio/agent/deps/lupa/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;
    }

    /* "/Users/ma/projects/immunio/agent-python/immunio/agent/deps/lupa/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;
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "/Users/ma/projects/immunio/agent-python/immunio/agent/deps/lupa/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);

  /* "/Users/ma/projects/immunio/agent-python/immunio/agent/deps/lupa/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
      #endif
      /*try:*/ {

        /* "/Users/ma/projects/immunio/agent-python/immunio/agent/deps/lupa/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);
      }

      /* "/Users/ma/projects/immunio/agent-python/immunio/agent/deps/lupa/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
          Py_BLOCK_THREADS
          #endif
          goto __pyx_L7;
        }
        __pyx_L7:;
      }
  }

  /* "/Users/ma/projects/immunio/agent-python/immunio/agent/deps/lupa/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);

  /* "/Users/ma/projects/immunio/agent-python/immunio/agent/deps/lupa/lupa/lock.pxi":99
 *     #assert not lock._is_locked
 *     #assert lock._count == 0
 *     if not locked:             # <<<<<<<<<<<<<<
 *         return 0
 *     lock._is_locked = True
 */
  __pyx_t_3 = ((!(__pyx_v_locked != 0)) != 0);
  if (__pyx_t_3) {

    /* "/Users/ma/projects/immunio/agent-python/immunio/agent/deps/lupa/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;
  }

  /* "/Users/ma/projects/immunio/agent-python/immunio/agent/deps/lupa/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;

  /* "/Users/ma/projects/immunio/agent-python/immunio/agent/deps/lupa/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;

  /* "/Users/ma/projects/immunio/agent-python/immunio/agent/deps/lupa/lupa/lock.pxi":103
 *     lock._is_locked = True
 *     lock._owner = current_thread
 *     lock._count = 1             # <<<<<<<<<<<<<<
 *     return 1
 * 
 */
  __pyx_v_lock->_count = 1;

  /* "/Users/ma/projects/immunio/agent-python/immunio/agent/deps/lupa/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;

  /* "/Users/ma/projects/immunio/agent-python/immunio/agent/deps/lupa/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;
}

/* "/Users/ma/projects/immunio/agent-python/immunio/agent/deps/lupa/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;

  /* "/Users/ma/projects/immunio/agent-python/immunio/agent/deps/lupa/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);

  /* "/Users/ma/projects/immunio/agent-python/immunio/agent/deps/lupa/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) {

    /* "/Users/ma/projects/immunio/agent-python/immunio/agent/deps/lupa/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 = -1;

    /* "/Users/ma/projects/immunio/agent-python/immunio/agent/deps/lupa/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) {

      /* "/Users/ma/projects/immunio/agent-python/immunio/agent/deps/lupa/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);

      /* "/Users/ma/projects/immunio/agent-python/immunio/agent/deps/lupa/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;
      goto __pyx_L4;
    }
    __pyx_L4:;
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "/Users/ma/projects/immunio/agent-python/immunio/agent/deps/lupa/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":77
 * 
 * 
 * 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 = {__Pyx_NAMESTR("lua_type"), (PyCFunction)__pyx_pw_4lupa_5_lupa_1lua_type, METH_O, __Pyx_DOCSTR(__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":84
 *     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, ((PyObject*)__pyx_ptype_4lupa_5_lupa__LuaObject)); 
  __pyx_t_2 = ((!(__pyx_t_1 != 0)) != 0);
  if (__pyx_t_2) {

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

  /* "lupa/_lupa.pyx":86
 *     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":87
 *         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_filename = __pyx_f[0]; __pyx_lineno = 87; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
  }
  #endif

  /* "lupa/_lupa.pyx":88
 *     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 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 88; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

  /* "lupa/_lupa.pyx":89
 *     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":90
 *     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":92
 *     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":93
 *     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":94
 *     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":101
 *         elif ltype == lua.LUA_TTHREAD:
 *             return 'thread'
 *         elif ltype in (lua.LUA_TUSERDATA, lua.LUA_TLIGHTUSERDATA):             # <<<<<<<<<<<<<<
 *             return 'userdata'
 *         else:
 */
    switch (__pyx_v_ltype) {

      /* "lupa/_lupa.pyx":95
 *         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:
 */
      case LUA_TTABLE:

      /* "lupa/_lupa.pyx":96
 *         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;
      break;

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

      /* "lupa/_lupa.pyx":98
 *             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;
      break;

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

      /* "lupa/_lupa.pyx":100
 *             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;
      break;

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

      /* "lupa/_lupa.pyx":102
 *             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;
      break;
      default:

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

      /* "lupa/_lupa.pyx":105
 *         else:
 *             lua_type_name = lua.lua_typename(L, ltype)
 *             return lua_type_name.decode('ascii') if PY_MAJOR_VERSION >= 3 else lua_type_name             # <<<<<<<<<<<<<<
 *     finally:
 *         lua.lua_settop(L, old_top)
 */
      __Pyx_XDECREF(__pyx_r);
      if (((PY_MAJOR_VERSION >= 3) != 0)) {
        __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_filename = __pyx_f[0]; __pyx_lineno = 105; __pyx_clineno = __LINE__; goto __pyx_L5_error;}
        __Pyx_GOTREF(__pyx_t_6);
        __pyx_t_3 = __pyx_t_6;
        __pyx_t_6 = 0;
      } else {
        __pyx_t_6 = __Pyx_PyBytes_FromString(__pyx_v_lua_type_name); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 105; __pyx_clineno = __LINE__; goto __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":107
 *             return lua_type_name.decode('ascii') if PY_MAJOR_VERSION >= 3 else lua_type_name
 *     finally:
 *         lua.lua_settop(L, old_top)             # <<<<<<<<<<<<<<
 *         unlock_runtime(lua_object._runtime)
 * 
 */
  /*finally:*/ {
    /*exception exit:*/{
      __pyx_L5_error:;
      __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_6); __pyx_t_6 = 0;
      __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 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":108
 *     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":107
 *             return lua_type_name.decode('ascii') if PY_MAJOR_VERSION >= 3 else lua_type_name
 *     finally:
 *         lua.lua_settop(L, old_top)             # <<<<<<<<<<<<<<
 *         unlock_runtime(lua_object._runtime)
 * 
 */
      lua_settop(__pyx_v_L, __pyx_v_old_top);

      /* "lupa/_lupa.pyx":108
 *     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":77
 * 
 * 
 * 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":189
 *     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":190
 * 
 *     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);
        case  6: values[5] = PyTuple_GET_ITEM(__pyx_args, 5);
        case  5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        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 = PyDict_GetItem(__pyx_kwds, __pyx_n_s_encoding);
          if (value) { values[0] = value; kw_args--; }
        }
        case  1:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_source_encoding);
          if (value) { values[1] = value; kw_args--; }
        }
        case  2:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_attribute_filter);
          if (value) { values[2] = value; kw_args--; }
        }
        case  3:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_attribute_handlers);
          if (value) { values[3] = value; kw_args--; }
        }
        case  4:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_register_eval);
          if (value) { values[4] = value; kw_args--; }
        }
        case  5:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_unpack_returned_tuples);
          if (value) { values[5] = value; kw_args--; }
        }
        case  6:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__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_filename = __pyx_f[0]; __pyx_lineno = 189; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  7: values[6] = PyTuple_GET_ITEM(__pyx_args, 6);
        case  6: values[5] = PyTuple_GET_ITEM(__pyx_args, 5);
        case  5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        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_filename = __pyx_f[0]; __pyx_lineno = 191; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    } else {

      /* "lupa/_lupa.pyx":191
 *     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_filename = __pyx_f[0]; __pyx_lineno = 191; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 192; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    } else {

      /* "lupa/_lupa.pyx":192
 *                   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_filename = __pyx_f[0]; __pyx_lineno = 189; __pyx_clineno = __LINE__; goto __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":189
 *     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_t_12;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__cinit__", 0);

  /* "lupa/_lupa.pyx":193
 *                   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":194
 *                   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 (__pyx_t_1) {

    /* "lupa/_lupa.pyx":195
 *         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_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_LuaError); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 195; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_tuple__3, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 195; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_Raise(__pyx_t_3, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 195; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }

  /* "lupa/_lupa.pyx":196
 *         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":197
 *             raise LuaError("Failed to initialise Lua runtime")
 *         self._state = L
 *         self._lock = FastRLock()             # <<<<<<<<<<<<<<
 *         self._pyrefs_in_lua = {}
 *         self._encoding = _asciiOrNone(encoding)
 */
  __pyx_t_3 = __Pyx_PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_4lupa_5_lupa_FastRLock)), __pyx_empty_tuple, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 197; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_GIVEREF(__pyx_t_3);
  __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_3);
  __pyx_t_3 = 0;

  /* "lupa/_lupa.pyx":198
 *         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_3 = PyDict_New(); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 198; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_GIVEREF(__pyx_t_3);
  __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_3);
  __pyx_t_3 = 0;

  /* "lupa/_lupa.pyx":199
 *         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_3 = __pyx_f_4lupa_5_lupa__asciiOrNone(__pyx_v_encoding); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 199; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_GIVEREF(__pyx_t_3);
  __Pyx_GOTREF(__pyx_v_self->_encoding);
  __Pyx_DECREF(__pyx_v_self->_encoding);
  __pyx_v_self->_encoding = ((PyObject*)__pyx_t_3);
  __pyx_t_3 = 0;

  /* "lupa/_lupa.pyx":200
 *         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_filename = __pyx_f[0]; __pyx_lineno = 200; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_1 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 200; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (!__pyx_t_1) {
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_v_self->_encoding); if (unlikely(__pyx_t_1 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 200; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    if (!__pyx_t_1) {
      __Pyx_INCREF(__pyx_kp_b_UTF_8);
      __pyx_t_2 = __pyx_kp_b_UTF_8;
    } else {
      __Pyx_INCREF(__pyx_v_self->_encoding);
      __pyx_t_2 = __pyx_v_self->_encoding;
    }
    __pyx_t_4 = __pyx_t_2;
    __pyx_t_2 = 0;
  } else {
    __pyx_t_4 = __pyx_t_3;
    __pyx_t_3 = 0;
  }
  __Pyx_GIVEREF(__pyx_t_4);
  __Pyx_GOTREF(__pyx_v_self->_source_encoding);
  __Pyx_DECREF(__pyx_v_self->_source_encoding);
  __pyx_v_self->_source_encoding = ((PyObject*)__pyx_t_4);
  __pyx_t_4 = 0;

  /* "lupa/_lupa.pyx":201
 *         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_1 = (__pyx_v_attribute_filter != Py_None);
  if ((__pyx_t_1 != 0)) {
    __pyx_t_5 = __Pyx_PyCallable_Check(__pyx_v_attribute_filter); if (unlikely(__pyx_t_5 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 201; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_6 = ((!(__pyx_t_5 != 0)) != 0);
    __pyx_t_5 = __pyx_t_6;
  } else {
    __pyx_t_5 = (__pyx_t_1 != 0);
  }
  if (__pyx_t_5) {

    /* "lupa/_lupa.pyx":202
 *         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_4 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__4, NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 202; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 202; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }

  /* "lupa/_lupa.pyx":203
 *         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":204
 *             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":206
 *         self._unpack_returned_tuples = unpack_returned_tuples
 * 
 *         if attribute_handlers:             # <<<<<<<<<<<<<<
 *             raise_error = False
 *             try:
 */
  __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_v_attribute_handlers); if (unlikely(__pyx_t_5 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 206; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__pyx_t_5) {

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

    /* "lupa/_lupa.pyx":208
 *         if attribute_handlers:
 *             raise_error = False
 *             try:             # <<<<<<<<<<<<<<
 *                 getter, setter = attribute_handlers
 *             except (ValueError, TypeError):
 */
    {
      __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":209
 *             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;
          #if CYTHON_COMPILING_IN_CPYTHON
          Py_ssize_t size = Py_SIZE(sequence);
          #else
          Py_ssize_t size = PySequence_Size(sequence);
          #endif
          if (unlikely(size != 2)) {
            if (size > 2) __Pyx_RaiseTooManyValuesError(2);
            else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
            {__pyx_filename = __pyx_f[0]; __pyx_lineno = 209; __pyx_clineno = __LINE__; goto __pyx_L6_error;}
          }
          #if CYTHON_COMPILING_IN_CPYTHON
          if (likely(PyTuple_CheckExact(sequence))) {
            __pyx_t_4 = PyTuple_GET_ITEM(sequence, 0); 
            __pyx_t_3 = PyTuple_GET_ITEM(sequence, 1); 
          } else {
            __pyx_t_4 = PyList_GET_ITEM(sequence, 0); 
            __pyx_t_3 = PyList_GET_ITEM(sequence, 1); 
          }
          __Pyx_INCREF(__pyx_t_4);
          __Pyx_INCREF(__pyx_t_3);
          #else
          __pyx_t_4 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 209; __pyx_clineno = __LINE__; goto __pyx_L6_error;}
          __Pyx_GOTREF(__pyx_t_4);
          __pyx_t_3 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 209; __pyx_clineno = __LINE__; goto __pyx_L6_error;}
          __Pyx_GOTREF(__pyx_t_3);
          #endif
        } else {
          Py_ssize_t index = -1;
          __pyx_t_2 = PyObject_GetIter(__pyx_v_attribute_handlers); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 209; __pyx_clineno = __LINE__; goto __pyx_L6_error;}
          __Pyx_GOTREF(__pyx_t_2);
          __pyx_t_10 = Py_TYPE(__pyx_t_2)->tp_iternext;
          index = 0; __pyx_t_4 = __pyx_t_10(__pyx_t_2); if (unlikely(!__pyx_t_4)) goto __pyx_L14_unpacking_failed;
          __Pyx_GOTREF(__pyx_t_4);
          index = 1; __pyx_t_3 = __pyx_t_10(__pyx_t_2); if (unlikely(!__pyx_t_3)) goto __pyx_L14_unpacking_failed;
          __Pyx_GOTREF(__pyx_t_3);
          if (__Pyx_IternextUnpackEndCheck(__pyx_t_10(__pyx_t_2), 2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 209; __pyx_clineno = __LINE__; goto __pyx_L6_error;}
          __pyx_t_10 = NULL;
          __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
          goto __pyx_L15_unpacking_done;
          __pyx_L14_unpacking_failed:;
          __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
          __pyx_t_10 = NULL;
          if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
          {__pyx_filename = __pyx_f[0]; __pyx_lineno = 209; __pyx_clineno = __LINE__; goto __pyx_L6_error;}
          __pyx_L15_unpacking_done:;
        }
        __pyx_v_getter = __pyx_t_4;
        __pyx_t_4 = 0;
        __pyx_v_setter = __pyx_t_3;
        __pyx_t_3 = 0;
      }
      /*else:*/ {

        /* "lupa/_lupa.pyx":213
 *                 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_t_5 = (__pyx_v_getter != Py_None);
        if ((__pyx_t_5 != 0)) {
          __pyx_t_1 = __Pyx_PyCallable_Check(__pyx_v_getter); if (unlikely(__pyx_t_1 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 213; __pyx_clineno = __LINE__; goto __pyx_L8_except_error;}
          __pyx_t_6 = ((!(__pyx_t_1 != 0)) != 0);
          __pyx_t_1 = __pyx_t_6;
        } else {
          __pyx_t_1 = (__pyx_t_5 != 0);
        }
        if (!__pyx_t_1) {

          /* "lupa/_lupa.pyx":214
 *             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);
          if ((__pyx_t_5 != 0)) {
            __pyx_t_6 = __Pyx_PyCallable_Check(__pyx_v_setter); if (unlikely(__pyx_t_6 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 214; __pyx_clineno = __LINE__; goto __pyx_L8_except_error;}
            __pyx_t_11 = ((!(__pyx_t_6 != 0)) != 0);
            __pyx_t_6 = __pyx_t_11;
          } else {
            __pyx_t_6 = (__pyx_t_5 != 0);
          }
          __pyx_t_5 = __pyx_t_6;
        } else {
          __pyx_t_5 = __pyx_t_1;
        }
        if (__pyx_t_5) {

          /* "lupa/_lupa.pyx":215
 *                 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;
          goto __pyx_L16;
        }
        __pyx_L16:;
      }
      __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_L13_try_end;
      __pyx_L6_error:;
      __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
      __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;

      /* "lupa/_lupa.pyx":210
 *             try:
 *                 getter, setter = attribute_handlers
 *             except (ValueError, TypeError):             # <<<<<<<<<<<<<<
 *                 raise_error = True
 *             else:
 */
      __pyx_t_12 = PyErr_ExceptionMatches(__pyx_builtin_ValueError) || PyErr_ExceptionMatches(__pyx_builtin_TypeError);
      if (__pyx_t_12) {
        __Pyx_AddTraceback("lupa._lupa.LuaRuntime.__cinit__", __pyx_clineno, __pyx_lineno, __pyx_filename);
        if (__Pyx_GetException(&__pyx_t_3, &__pyx_t_4, &__pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 210; __pyx_clineno = __LINE__; goto __pyx_L8_except_error;}
        __Pyx_GOTREF(__pyx_t_3);
        __Pyx_GOTREF(__pyx_t_4);
        __Pyx_GOTREF(__pyx_t_2);

        /* "lupa/_lupa.pyx":211
 *                 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_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
        goto __pyx_L7_exception_handled;
      }
      goto __pyx_L8_except_error;
      __pyx_L8_except_error:;
      __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_L7_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_L13_try_end:;
    }

    /* "lupa/_lupa.pyx":216
 *                         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_5 = (__pyx_v_raise_error != 0);
    if (__pyx_t_5) {

      /* "lupa/_lupa.pyx":217
 *                     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_2 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__5, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 217; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 217; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }

    /* "lupa/_lupa.pyx":218
 *             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_filename = __pyx_f[0]; __pyx_lineno = 218; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    if (__pyx_t_5) {
      if (unlikely(!__pyx_v_getter)) { __Pyx_RaiseUnboundLocalError("getter"); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 218; __pyx_clineno = __LINE__; goto __pyx_L1_error;} }
      __pyx_t_1 = (__pyx_v_getter != Py_None);
      if (!__pyx_t_1) {
        if (unlikely(!__pyx_v_setter)) { __Pyx_RaiseUnboundLocalError("setter"); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 218; __pyx_clineno = __LINE__; goto __pyx_L1_error;} }
        __pyx_t_6 = (__pyx_v_setter != Py_None);
        __pyx_t_11 = __pyx_t_6;
      } else {
        __pyx_t_11 = __pyx_t_1;
      }
      __pyx_t_1 = __pyx_t_11;
    } else {
      __pyx_t_1 = __pyx_t_5;
    }
    if (__pyx_t_1) {

      /* "lupa/_lupa.pyx":219
 *                 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_2 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__6, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 219; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 219; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }

    /* "lupa/_lupa.pyx":220
 *             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_filename = __pyx_f[0]; __pyx_lineno = 220; __pyx_clineno = __LINE__; goto __pyx_L1_error;} }
    __pyx_t_2 = __pyx_v_getter;
    __Pyx_INCREF(__pyx_t_2);
    if (unlikely(!__pyx_v_setter)) { __Pyx_RaiseUnboundLocalError("setter"); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 220; __pyx_clineno = __LINE__; goto __pyx_L1_error;} }
    __pyx_t_4 = __pyx_v_setter;
    __Pyx_INCREF(__pyx_t_4);
    __Pyx_GIVEREF(__pyx_t_2);
    __Pyx_GOTREF(__pyx_v_self->_attribute_getter);
    __Pyx_DECREF(__pyx_v_self->_attribute_getter);
    __pyx_v_self->_attribute_getter = __pyx_t_2;
    __pyx_t_2 = 0;
    __Pyx_GIVEREF(__pyx_t_4);
    __Pyx_GOTREF(__pyx_v_self->_attribute_setter);
    __Pyx_DECREF(__pyx_v_self->_attribute_setter);
    __pyx_v_self->_attribute_setter = __pyx_t_4;
    __pyx_t_4 = 0;
    goto __pyx_L5;
  }
  __pyx_L5:;

  /* "lupa/_lupa.pyx":222
 *             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":223
 * 
 *         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_12 = __pyx_f_4lupa_5_lupa_10LuaRuntime_init_python_lib(__pyx_v_self, __pyx_v_register_eval, __pyx_v_register_builtins); if (unlikely(__pyx_t_12 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 223; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "lupa/_lupa.pyx":224
 *         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":225
 *         self.init_python_lib(register_eval, register_builtins)
 *         lua.lua_settop(L, 0)
 *         lua.lua_atpanic(L, <lua.lua_CFunction>1)             # <<<<<<<<<<<<<<
 * 
 *     def __dealloc__(self):
 */
  lua_atpanic(__pyx_v_L, ((lua_CFunction)1));

  /* "lupa/_lupa.pyx":189
 *     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":227
 *         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":228
 * 
 *     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":229
 *     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":230
 *         if self._state is not NULL:
 *             lua.lua_close(self._state)
 *             self._state = NULL             # <<<<<<<<<<<<<<
 * 
 *     @cython.final
 */
    __pyx_v_self->_state = NULL;
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "lupa/_lupa.pyx":227
 *         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":233
 * 
 *     @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":234
 *     @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 (__pyx_t_2) {

    /* "lupa/_lupa.pyx":235
 *     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":236
 *         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":237
 *             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_filename = __pyx_f[0]; __pyx_lineno = 237; __pyx_clineno = __LINE__; goto __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 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 237; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 237; __pyx_clineno = __LINE__; goto __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 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 237; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 237; __pyx_clineno = __LINE__; goto __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 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 237; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 237; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }

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

  /* "lupa/_lupa.pyx":233
 * 
 *     @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":241
 * 
 *     @cython.final
 *     cdef int store_raised_exception(self) except -1:             # <<<<<<<<<<<<<<
 *         self._raised_exception = exc_info()
 *         return 0
 */

static int __pyx_f_4lupa_5_lupa_10LuaRuntime_store_raised_exception(struct __pyx_obj_4lupa_5_lupa_LuaRuntime *__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("store_raised_exception", 0);

  /* "lupa/_lupa.pyx":242
 *     @cython.final
 *     cdef int store_raised_exception(self) except -1:
 *         self._raised_exception = exc_info()             # <<<<<<<<<<<<<<
 *         return 0
 * 
 */
  __pyx_t_1 = __Pyx_PyObject_Call(__pyx_v_4lupa_5_lupa_exc_info, __pyx_empty_tuple, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 242; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  if (!(likely(PyTuple_CheckExact(__pyx_t_1))||((__pyx_t_1) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "tuple", Py_TYPE(__pyx_t_1)->tp_name), 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 242; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v_self->_raised_exception);
  __Pyx_DECREF(__pyx_v_self->_raised_exception);
  __pyx_v_self->_raised_exception = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "lupa/_lupa.pyx":243
 *     cdef int store_raised_exception(self) except -1:
 *         self._raised_exception = exc_info()
 *         return 0             # <<<<<<<<<<<<<<
 * 
 *     def eval(self, lua_code):
 */
  __pyx_r = 0;
  goto __pyx_L0;

  /* "lupa/_lupa.pyx":241
 * 
 *     @cython.final
 *     cdef int store_raised_exception(self) except -1:             # <<<<<<<<<<<<<<
 *         self._raised_exception = exc_info()
 *         return 0
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __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":245
 *         return 0
 * 
 *     def eval(self, lua_code):             # <<<<<<<<<<<<<<
 *         """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_v_lua_code); /*proto*/
static char __pyx_doc_4lupa_5_lupa_10LuaRuntime_4eval[] = "LuaRuntime.eval(self, lua_code)\nEvaluate a Lua expression passed in a string.\n        ";
static PyObject *__pyx_pw_4lupa_5_lupa_10LuaRuntime_5eval(PyObject *__pyx_v_self, PyObject *__pyx_v_lua_code) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("eval (wrapper)", 0);
  __pyx_r = __pyx_pf_4lupa_5_lupa_10LuaRuntime_4eval(((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_4eval(struct __pyx_obj_4lupa_5_lupa_LuaRuntime *__pyx_v_self, PyObject *__pyx_v_lua_code) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  int __pyx_t_2;
  char *__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":248
 *         """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_filename = __pyx_f[0]; __pyx_lineno = 248; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
  }
  #endif

  /* "lupa/_lupa.pyx":249
 *         """
 *         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)
 */
  __pyx_t_1 = PyUnicode_Check(__pyx_v_lua_code); 
  __pyx_t_2 = (__pyx_t_1 != 0);
  if (__pyx_t_2) {

    /* "lupa/_lupa.pyx":250
 *         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)
 * 
 */
    if (unlikely(__pyx_v_lua_code == Py_None)) {
      PyErr_Format(PyExc_AttributeError, "'NoneType' object has no attribute '%s'", "encode");
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 250; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    __pyx_t_3 = __Pyx_PyObject_AsString(__pyx_v_self->_source_encoding); if (unlikely((!__pyx_t_3) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 250; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_4 = PyUnicode_AsEncodedString(((PyObject*)__pyx_v_lua_code), __pyx_t_3, NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 250; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF_SET(__pyx_v_lua_code, __pyx_t_4);
    __pyx_t_4 = 0;
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "lupa/_lupa.pyx":251
 *         if isinstance(lua_code, unicode):
 *             lua_code = (<unicode>lua_code).encode(self._source_encoding)
 *         return run_lua(self, b'return ' + lua_code)             # <<<<<<<<<<<<<<
 * 
 *     def execute(self, lua_code):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_4 = PyNumber_Add(__pyx_kp_b_return, __pyx_v_lua_code); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 251; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 251; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_5 = __pyx_f_4lupa_5_lupa_run_lua(__pyx_v_self, ((PyObject*)__pyx_t_4)); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 251; __pyx_clineno = __LINE__; goto __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":245
 *         return 0
 * 
 *     def eval(self, lua_code):             # <<<<<<<<<<<<<<
 *         """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":253
 *         return run_lua(self, b'return ' + lua_code)
 * 
 *     def execute(self, lua_code):             # <<<<<<<<<<<<<<
 *         """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_v_lua_code); /*proto*/
static char __pyx_doc_4lupa_5_lupa_10LuaRuntime_6execute[] = "LuaRuntime.execute(self, lua_code)\nExecute a Lua program passed in a string.\n        ";
static PyObject *__pyx_pw_4lupa_5_lupa_10LuaRuntime_7execute(PyObject *__pyx_v_self, PyObject *__pyx_v_lua_code) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("execute (wrapper)", 0);
  __pyx_r = __pyx_pf_4lupa_5_lupa_10LuaRuntime_6execute(((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_6execute(struct __pyx_obj_4lupa_5_lupa_LuaRuntime *__pyx_v_self, PyObject *__pyx_v_lua_code) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  int __pyx_t_2;
  char *__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":256
 *         """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_filename = __pyx_f[0]; __pyx_lineno = 256; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
  }
  #endif

  /* "lupa/_lupa.pyx":257
 *         """
 *         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)
 */
  __pyx_t_1 = PyUnicode_Check(__pyx_v_lua_code); 
  __pyx_t_2 = (__pyx_t_1 != 0);
  if (__pyx_t_2) {

    /* "lupa/_lupa.pyx":258
 *         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)
 * 
 */
    if (unlikely(__pyx_v_lua_code == Py_None)) {
      PyErr_Format(PyExc_AttributeError, "'NoneType' object has no attribute '%s'", "encode");
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 258; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    __pyx_t_3 = __Pyx_PyObject_AsString(__pyx_v_self->_source_encoding); if (unlikely((!__pyx_t_3) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 258; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_4 = PyUnicode_AsEncodedString(((PyObject*)__pyx_v_lua_code), __pyx_t_3, NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 258; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF_SET(__pyx_v_lua_code, __pyx_t_4);
    __pyx_t_4 = 0;
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "lupa/_lupa.pyx":259
 *         if isinstance(lua_code, unicode):
 *             lua_code = (<unicode>lua_code).encode(self._source_encoding)
 *         return run_lua(self, lua_code)             # <<<<<<<<<<<<<<
 * 
 *     def require(self, modulename):
 */
  __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_filename = __pyx_f[0]; __pyx_lineno = 259; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_4 = __pyx_f_4lupa_5_lupa_run_lua(__pyx_v_self, ((PyObject*)__pyx_v_lua_code)); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 259; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_r = __pyx_t_4;
  __pyx_t_4 = 0;
  goto __pyx_L0;

  /* "lupa/_lupa.pyx":253
 *         return run_lua(self, b'return ' + lua_code)
 * 
 *     def execute(self, lua_code):             # <<<<<<<<<<<<<<
 *         """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":261
 *         return run_lua(self, lua_code)
 * 
 *     def require(self, modulename):             # <<<<<<<<<<<<<<
 *         """Load a Lua library into the runtime.
 *         """
 */

/* Python wrapper */
static PyObject *__pyx_pw_4lupa_5_lupa_10LuaRuntime_9require(PyObject *__pyx_v_self, PyObject *__pyx_v_modulename); /*proto*/
static char __pyx_doc_4lupa_5_lupa_10LuaRuntime_8require[] = "LuaRuntime.require(self, modulename)\nLoad a Lua library into the runtime.\n        ";
static PyObject *__pyx_pw_4lupa_5_lupa_10LuaRuntime_9require(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_8require(((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_8require(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;
  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("require", 0);

  /* "lupa/_lupa.pyx":264
 *         """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_filename = __pyx_f[0]; __pyx_lineno = 264; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
  }
  #endif

  /* "lupa/_lupa.pyx":265
 *         """
 *         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":266
 *         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_2 = PyBytes_Check(__pyx_v_modulename); 
  if (!__pyx_t_2) {
    __pyx_t_3 = PyUnicode_Check(__pyx_v_modulename); 
    __pyx_t_4 = __pyx_t_3;
  } else {
    __pyx_t_4 = __pyx_t_2;
  }
  __pyx_t_2 = ((!(__pyx_t_4 != 0)) != 0);
  if (__pyx_t_2) {

    /* "lupa/_lupa.pyx":267
 *         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_filename = __pyx_f[0]; __pyx_lineno = 267; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 267; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }

  /* "lupa/_lupa.pyx":268
 *         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 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 268; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "lupa/_lupa.pyx":269
 *             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":270
 *         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":271
 *         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, __pyx_k_require);

    /* "lupa/_lupa.pyx":272
 *         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_2 = (lua_isnil(__pyx_v_L, -1) != 0);
    if (__pyx_t_2) {

      /* "lupa/_lupa.pyx":273
 *             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_t_5 = __Pyx_GetModuleGlobalName(__pyx_n_s_LuaError); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 273; __pyx_clineno = __LINE__; goto __pyx_L5_error;}
      __Pyx_GOTREF(__pyx_t_5);
      __pyx_t_7 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_tuple__8, NULL); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 273; __pyx_clineno = __LINE__; goto __pyx_L5_error;}
      __Pyx_GOTREF(__pyx_t_7);
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __Pyx_Raise(__pyx_t_7, 0, 0, 0);
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 273; __pyx_clineno = __LINE__; goto __pyx_L5_error;}
    }

    /* "lupa/_lupa.pyx":274
 *             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_7 = PyTuple_New(1); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 274; __pyx_clineno = __LINE__; goto __pyx_L5_error;}
    __Pyx_GOTREF(__pyx_t_7);
    __Pyx_INCREF(__pyx_v_modulename);
    PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_v_modulename);
    __Pyx_GIVEREF(__pyx_v_modulename);
    __pyx_t_5 = __pyx_f_4lupa_5_lupa_call_lua(__pyx_v_self, __pyx_v_L, ((PyObject*)__pyx_t_7)); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 274; __pyx_clineno = __LINE__; goto __pyx_L5_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    __pyx_r = __pyx_t_5;
    __pyx_t_5 = 0;
    goto __pyx_L4_return;
  }

  /* "lupa/_lupa.pyx":276
 *             return call_lua(self, L, (modulename,))
 *         finally:
 *             lua.lua_settop(L, old_top)             # <<<<<<<<<<<<<<
 *             unlock_runtime(self)
 * 
 */
  /*finally:*/ {
    /*exception exit:*/{
      __pyx_L5_error:;
      __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_7); __pyx_t_7 = 0;
      __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 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_6 = __pyx_lineno; __pyx_t_8 = __pyx_clineno; __pyx_t_9 = __pyx_filename;
      {
        lua_settop(__pyx_v_L, __pyx_v_old_top);

        /* "lupa/_lupa.pyx":277
 *         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_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_6; __pyx_clineno = __pyx_t_8; __pyx_filename = __pyx_t_9;
      goto __pyx_L1_error;
    }
    __pyx_L4_return: {
      __pyx_t_15 = __pyx_r;
      __pyx_r = 0;

      /* "lupa/_lupa.pyx":276
 *             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":277
 *         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_15;
      __pyx_t_15 = 0;
      goto __pyx_L0;
    }
  }

  /* "lupa/_lupa.pyx":261
 *         return run_lua(self, lua_code)
 * 
 *     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_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":279
 *             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_11globals(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static char __pyx_doc_4lupa_5_lupa_10LuaRuntime_10globals[] = "LuaRuntime.globals(self)\nReturn the globals defined in this Lua runtime as a Lua\n        table.\n        ";
static PyObject *__pyx_pw_4lupa_5_lupa_10LuaRuntime_11globals(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_10globals(((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_10globals(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;
  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("globals", 0);

  /* "lupa/_lupa.pyx":283
 *         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_filename = __pyx_f[0]; __pyx_lineno = 283; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
  }
  #endif

  /* "lupa/_lupa.pyx":284
 *         """
 *         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":285
 *         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 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 285; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "lupa/_lupa.pyx":286
 *         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":287
 *         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":288
 *         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, __pyx_k_G);

    /* "lupa/_lupa.pyx":289
 *         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 (__pyx_t_3) {

      /* "lupa/_lupa.pyx":290
 *             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_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_LuaError); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 290; __pyx_clineno = __LINE__; goto __pyx_L4_error;}
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_t_5 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_tuple__9, NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 290; __pyx_clineno = __LINE__; goto __pyx_L4_error;}
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __Pyx_Raise(__pyx_t_5, 0, 0, 0);
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 290; __pyx_clineno = __LINE__; goto __pyx_L4_error;}
    }

    /* "lupa/_lupa.pyx":291
 *             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_5 = __pyx_f_4lupa_5_lupa_py_from_lua(__pyx_v_self, __pyx_v_L, -1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 291; __pyx_clineno = __LINE__; goto __pyx_L4_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_r = __pyx_t_5;
    __pyx_t_5 = 0;
    goto __pyx_L3_return;
  }

  /* "lupa/_lupa.pyx":293
 *             return py_from_lua(self, L, -1)
 *         finally:
 *             lua.lua_settop(L, old_top)             # <<<<<<<<<<<<<<
 *             unlock_runtime(self)
 * 
 */
  /*finally:*/ {
    /*exception exit:*/{
      __pyx_L4_error:;
      __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_4); __pyx_t_4 = 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_2 = __pyx_lineno; __pyx_t_6 = __pyx_clineno; __pyx_t_7 = __pyx_filename;
      {
        lua_settop(__pyx_v_L, __pyx_v_old_top);

        /* "lupa/_lupa.pyx":294
 *         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_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_2; __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":293
 *             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":294
 *         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_13;
      __pyx_t_13 = 0;
      goto __pyx_L0;
    }
  }

  /* "lupa/_lupa.pyx":279
 *             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_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":296
 *             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_13table(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4lupa_5_lupa_10LuaRuntime_12table[] = "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 PyObject *__pyx_pw_4lupa_5_lupa_10LuaRuntime_13table(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_12table(((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_12table(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_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("table", 0);

  /* "lupa/_lupa.pyx":301
 *         are set as key-value pairs.
 *         """
 *         return self.table_from(items, kwargs)             # <<<<<<<<<<<<<<
 * 
 *     def table_from(self, *args):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_table_from); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 301; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 301; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_INCREF(__pyx_v_items);
  PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_items);
  __Pyx_GIVEREF(__pyx_v_items);
  __Pyx_INCREF(__pyx_v_kwargs);
  PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_v_kwargs);
  __Pyx_GIVEREF(__pyx_v_kwargs);
  __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_2, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 301; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_r = __pyx_t_3;
  __pyx_t_3 = 0;
  goto __pyx_L0;

  /* "lupa/_lupa.pyx":296
 *             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_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":303
 *         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_15table_from(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4lupa_5_lupa_10LuaRuntime_14table_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 PyObject *__pyx_pw_4lupa_5_lupa_10LuaRuntime_15table_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_14table_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_14table_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":313
 *         (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_filename = __pyx_f[0]; __pyx_lineno = 313; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
  }
  #endif

  /* "lupa/_lupa.pyx":314
 *         """
 *         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":315
 *         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":316
 *         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 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 316; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "lupa/_lupa.pyx":317
 *         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":318
 *         lock_runtime(self)
 *         old_top = lua.lua_gettop(L)
 *         try:             # <<<<<<<<<<<<<<
 *             lua.lua_newtable(L)
 *             # FIXME: how to check for failure?
 */
  /*try:*/ {

    /* "lupa/_lupa.pyx":319
 *         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":321
 *             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_COMPILING_IN_CPYTHON
      __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_filename = __pyx_f[0]; __pyx_lineno = 321; __pyx_clineno = __LINE__; goto __pyx_L4_error;}
      #else
      __pyx_t_5 = PySequence_ITEM(__pyx_t_3, __pyx_t_4); __pyx_t_4++; if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 321; __pyx_clineno = __LINE__; goto __pyx_L4_error;}
      #endif
      __Pyx_XDECREF_SET(__pyx_v_obj, __pyx_t_5);
      __pyx_t_5 = 0;

      /* "lupa/_lupa.pyx":322
 *             # 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":323
 *             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 '%s'", "iteritems");
          {__pyx_filename = __pyx_f[0]; __pyx_lineno = 323; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 323; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 323; __pyx_clineno = __LINE__; goto __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":324
 *                 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 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 324; __pyx_clineno = __LINE__; goto __pyx_L4_error;}

          /* "lupa/_lupa.pyx":325
 *                     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 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 325; __pyx_clineno = __LINE__; goto __pyx_L4_error;}

          /* "lupa/_lupa.pyx":326
 *                         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;
        goto __pyx_L8;
      }

      /* "lupa/_lupa.pyx":328
 *                         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, ((PyObject*)__pyx_ptype_4lupa_5_lupa__LuaTable)); 
      __pyx_t_6 = (__pyx_t_7 != 0);
      if (__pyx_t_6) {

        /* "lupa/_lupa.pyx":330
 *                 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 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 330; __pyx_clineno = __LINE__; goto __pyx_L4_error;}

        /* "lupa/_lupa.pyx":331
 *                     # 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":332
 *                     (<_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":333
 *                     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":334
 *                     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":335
 *                         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":336
 *                         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);
        goto __pyx_L8;
      }

      /* "lupa/_lupa.pyx":338
 *                     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 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 338; __pyx_clineno = __LINE__; goto __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":339
 * 
 *                 elif isinstance(obj, Mapping):
 *                     for key in obj:             # <<<<<<<<<<<<<<
 *                         value = obj[key]
 *                         py_to_lua(self, L, key)
 */
        if (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_filename = __pyx_f[0]; __pyx_lineno = 339; __pyx_clineno = __LINE__; goto __pyx_L4_error;}
          __Pyx_GOTREF(__pyx_t_5);
          __pyx_t_13 = Py_TYPE(__pyx_t_5)->tp_iternext;
        }
        for (;;) {
          if (!__pyx_t_13 && PyList_CheckExact(__pyx_t_5)) {
            if (__pyx_t_9 >= PyList_GET_SIZE(__pyx_t_5)) break;
            #if CYTHON_COMPILING_IN_CPYTHON
            __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_filename = __pyx_f[0]; __pyx_lineno = 339; __pyx_clineno = __LINE__; goto __pyx_L4_error;}
            #else
            __pyx_t_11 = PySequence_ITEM(__pyx_t_5, __pyx_t_9); __pyx_t_9++; if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 339; __pyx_clineno = __LINE__; goto __pyx_L4_error;}
            #endif
          } else if (!__pyx_t_13 && PyTuple_CheckExact(__pyx_t_5)) {
            if (__pyx_t_9 >= PyTuple_GET_SIZE(__pyx_t_5)) break;
            #if CYTHON_COMPILING_IN_CPYTHON
            __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_filename = __pyx_f[0]; __pyx_lineno = 339; __pyx_clineno = __LINE__; goto __pyx_L4_error;}
            #else
            __pyx_t_11 = PySequence_ITEM(__pyx_t_5, __pyx_t_9); __pyx_t_9++; if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 339; __pyx_clineno = __LINE__; goto __pyx_L4_error;}
            #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(exc_type == PyExc_StopIteration || PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
                else {__pyx_filename = __pyx_f[0]; __pyx_lineno = 339; __pyx_clineno = __LINE__; goto __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":340
 *                 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 = PyObject_GetItem(__pyx_v_obj, __pyx_v_key); if (unlikely(__pyx_t_11 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 340; __pyx_clineno = __LINE__; goto __pyx_L4_error;};
          __Pyx_GOTREF(__pyx_t_11);
          __Pyx_XDECREF_SET(__pyx_v_value, __pyx_t_11);
          __pyx_t_11 = 0;

          /* "lupa/_lupa.pyx":341
 *                     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 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 341; __pyx_clineno = __LINE__; goto __pyx_L4_error;}

          /* "lupa/_lupa.pyx":342
 *                         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 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 342; __pyx_clineno = __LINE__; goto __pyx_L4_error;}

          /* "lupa/_lupa.pyx":343
 *                         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);
        }
        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
        goto __pyx_L8;
      }
      /*else*/ {

        /* "lupa/_lupa.pyx":345
 *                         lua.lua_rawset(L, -3)
 *                 else:
 *                     for arg in obj:             # <<<<<<<<<<<<<<
 *                         py_to_lua(self, L, arg)
 *                         lua.lua_rawseti(L, -2, i)
 */
        if (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_filename = __pyx_f[0]; __pyx_lineno = 345; __pyx_clineno = __LINE__; goto __pyx_L4_error;}
          __Pyx_GOTREF(__pyx_t_5);
          __pyx_t_13 = Py_TYPE(__pyx_t_5)->tp_iternext;
        }
        for (;;) {
          if (!__pyx_t_13 && PyList_CheckExact(__pyx_t_5)) {
            if (__pyx_t_9 >= PyList_GET_SIZE(__pyx_t_5)) break;
            #if CYTHON_COMPILING_IN_CPYTHON
            __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_filename = __pyx_f[0]; __pyx_lineno = 345; __pyx_clineno = __LINE__; goto __pyx_L4_error;}
            #else
            __pyx_t_11 = PySequence_ITEM(__pyx_t_5, __pyx_t_9); __pyx_t_9++; if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 345; __pyx_clineno = __LINE__; goto __pyx_L4_error;}
            #endif
          } else if (!__pyx_t_13 && PyTuple_CheckExact(__pyx_t_5)) {
            if (__pyx_t_9 >= PyTuple_GET_SIZE(__pyx_t_5)) break;
            #if CYTHON_COMPILING_IN_CPYTHON
            __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_filename = __pyx_f[0]; __pyx_lineno = 345; __pyx_clineno = __LINE__; goto __pyx_L4_error;}
            #else
            __pyx_t_11 = PySequence_ITEM(__pyx_t_5, __pyx_t_9); __pyx_t_9++; if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 345; __pyx_clineno = __LINE__; goto __pyx_L4_error;}
            #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(exc_type == PyExc_StopIteration || PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
                else {__pyx_filename = __pyx_f[0]; __pyx_lineno = 345; __pyx_clineno = __LINE__; goto __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":346
 *                 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 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 346; __pyx_clineno = __LINE__; goto __pyx_L4_error;}

          /* "lupa/_lupa.pyx":347
 *                     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":348
 *                         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);
        }
        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      }
      __pyx_L8:;
    }
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

    /* "lupa/_lupa.pyx":349
 *                         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_filename = __pyx_f[0]; __pyx_lineno = 349; __pyx_clineno = __LINE__; goto __pyx_L4_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_r = __pyx_t_3;
    __pyx_t_3 = 0;
    goto __pyx_L3_return;
  }

  /* "lupa/_lupa.pyx":351
 *             return py_from_lua(self, L, -1)
 *         finally:
 *             lua.lua_settop(L, old_top)             # <<<<<<<<<<<<<<
 *             unlock_runtime(self)
 * 
 */
  /*finally:*/ {
    /*exception exit:*/{
      __pyx_L4_error:;
      __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_5); __pyx_t_5 = 0;
      __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 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":352
 *         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":351
 *             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":352
 *         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":303
 *         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":355
 * 
 *     @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;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("register_py_object", 0);

  /* "lupa/_lupa.pyx":356
 *     @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":357
 *     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)
 */
  __pyx_t_2 = __Pyx_PyObject_AsString(__pyx_v_cname); if (unlikely((!__pyx_t_2) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 357; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (unlikely(__pyx_v_cname == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()");
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 357; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_t_3 = PyBytes_GET_SIZE(__pyx_v_cname); if (unlikely(__pyx_t_3 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 357; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  lua_pushlstring(__pyx_v_L, __pyx_t_2, __pyx_t_3);

  /* "lupa/_lupa.pyx":358
 *         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 (__pyx_t_4) {

    /* "lupa/_lupa.pyx":359
 *         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":360
 *         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_t_5 = __Pyx_GetModuleGlobalName(__pyx_n_s_LuaError); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 360; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_6 = __Pyx_PyString_Format(__pyx_kp_s_failed_to_convert_s_object, __pyx_v_pyname); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 360; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_t_7 = PyTuple_New(1); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 360; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_7);
    PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_6);
    __Pyx_GIVEREF(__pyx_t_6);
    __pyx_t_6 = 0;
    __pyx_t_6 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_7, NULL); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 360; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __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_filename = __pyx_f[0]; __pyx_lineno = 360; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }

  /* "lupa/_lupa.pyx":361
 *             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)
 */
  __pyx_t_2 = __Pyx_PyObject_AsString(__pyx_v_pyname); if (unlikely((!__pyx_t_2) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 361; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (unlikely(__pyx_v_pyname == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()");
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 361; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_t_3 = PyBytes_GET_SIZE(__pyx_v_pyname); if (unlikely(__pyx_t_3 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 361; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  lua_pushlstring(__pyx_v_L, __pyx_t_2, __pyx_t_3);

  /* "lupa/_lupa.pyx":362
 *             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":363
 *         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":364
 *         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":365
 *         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":355
 * 
 *     @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_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":368
 * 
 *     @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":369
 *     @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":372
 * 
 *         # create 'python' lib and register our own object metatable
 *         lua.luaL_openlib(L, "python", py_lib, 0)             # <<<<<<<<<<<<<<
 *         lua.luaL_newmetatable(L, POBJECT)
 *         lua.luaL_openlib(L, NULL, py_object_lib, 0)
 */
  luaL_openlib(__pyx_v_L, __pyx_k_python, __pyx_v_4lupa_5_lupa_py_lib, 0);

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

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

  /* "lupa/_lupa.pyx":375
 *         lua.luaL_newmetatable(L, POBJECT)
 *         lua.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":378
 * 
 *         # 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 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 378; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "lupa/_lupa.pyx":379
 *         # 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":380
 *         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 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 380; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "lupa/_lupa.pyx":381
 *         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":382
 *             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 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 382; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    goto __pyx_L4;
  }
  __pyx_L4:;

  /* "lupa/_lupa.pyx":384
 *             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":368
 * 
 *     @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;
}

/* "lupa/_lupa.pyx":391
 * # 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 = {__Pyx_NAMESTR("unpacks_lua_table"), (PyCFunction)__pyx_pw_4lupa_5_lupa_3unpacks_lua_table, METH_O, __Pyx_DOCSTR(__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":411
 *     """
 *     @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 = {__Pyx_NAMESTR("wrapper"), (PyCFunction)__pyx_pw_4lupa_5_lupa_17unpacks_lua_table_1wrapper, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(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":412
 *     @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_filename = __pyx_f[0]; __pyx_lineno = 412; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_1 = __pyx_f_4lupa_5_lupa__fix_args_kwargs(((PyObject*)__pyx_v_args)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 412; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  if (likely(__pyx_t_1 != Py_None)) {
    PyObject* sequence = __pyx_t_1;
    #if CYTHON_COMPILING_IN_CPYTHON
    Py_ssize_t size = Py_SIZE(sequence);
    #else
    Py_ssize_t size = PySequence_Size(sequence);
    #endif
    if (unlikely(size != 2)) {
      if (size > 2) __Pyx_RaiseTooManyValuesError(2);
      else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 412; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    #if CYTHON_COMPILING_IN_CPYTHON
    __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_filename = __pyx_f[0]; __pyx_lineno = 412; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_3 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 412; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    #endif
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  } else {
    __Pyx_RaiseNoneNotIterableError(); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 412; __pyx_clineno = __LINE__; goto __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":413
 *     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_filename = __pyx_f[0]; __pyx_lineno = 413; __pyx_clineno = __LINE__; goto __pyx_L1_error;} }
  __pyx_t_1 = PySequence_Tuple(__pyx_v_args); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 413; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 413; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  if (likely(PyDict_Check(__pyx_v_kwargs))) {
    __pyx_t_3 = __pyx_v_kwargs;
    __Pyx_INCREF(__pyx_t_3);
  } else {
    __pyx_t_3 = PyObject_CallFunctionObjArgs((PyObject*)&PyDict_Type, __pyx_v_kwargs, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 413; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 413; __pyx_clineno = __LINE__; goto __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":411
 *     """
 *     @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":391
 * # 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;
  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_RefNannyFinishContext();
    return NULL;
  }
  __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":410
 *     robustly.
 *     """
 *     @wraps(func)             # <<<<<<<<<<<<<<
 *     def wrapper(*args):
 *         args, kwargs = _fix_args_kwargs(args)
 */
  __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 410; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_INCREF(__pyx_cur_scope->__pyx_v_func);
  PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_cur_scope->__pyx_v_func);
  __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_func);
  __pyx_t_2 = __Pyx_PyObject_Call(__pyx_v_4lupa_5_lupa_wraps, __pyx_t_1, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 410; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "lupa/_lupa.pyx":411
 *     """
 *     @wraps(func)
 *     def wrapper(*args):             # <<<<<<<<<<<<<<
 *         args, kwargs = _fix_args_kwargs(args)
 *         return func(*args, **kwargs)
 */
  __pyx_t_1 = __Pyx_CyFunction_NewEx(&__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, PyModule_GetDict(__pyx_m), ((PyObject *)__pyx_codeobj__11)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 411; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);

  /* "lupa/_lupa.pyx":410
 *     robustly.
 *     """
 *     @wraps(func)             # <<<<<<<<<<<<<<
 *     def wrapper(*args):
 *         args, kwargs = _fix_args_kwargs(args)
 */
  __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 410; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __pyx_t_1 = 0;
  __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_3, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 410; __pyx_clineno = __LINE__; goto __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_v_wrapper = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "lupa/_lupa.pyx":414
 *         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":391
 * # 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_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":417
 * 
 * 
 * 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 = {__Pyx_NAMESTR("unpacks_lua_table_method"), (PyCFunction)__pyx_pw_4lupa_5_lupa_5unpacks_lua_table_method, METH_O, __Pyx_DOCSTR(__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":423
 *     """
 *     @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 = {__Pyx_NAMESTR("wrapper"), (PyCFunction)__pyx_pw_4lupa_5_lupa_24unpacks_lua_table_method_1wrapper, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(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);
        case  0: break;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = PyDict_GetItem(__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_filename = __pyx_f[0]; __pyx_lineno = 423; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 423; __pyx_clineno = __LINE__; goto __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":424
 *     @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_filename = __pyx_f[0]; __pyx_lineno = 424; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_1 = __pyx_f_4lupa_5_lupa__fix_args_kwargs(((PyObject*)__pyx_v_args)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 424; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  if (likely(__pyx_t_1 != Py_None)) {
    PyObject* sequence = __pyx_t_1;
    #if CYTHON_COMPILING_IN_CPYTHON
    Py_ssize_t size = Py_SIZE(sequence);
    #else
    Py_ssize_t size = PySequence_Size(sequence);
    #endif
    if (unlikely(size != 2)) {
      if (size > 2) __Pyx_RaiseTooManyValuesError(2);
      else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 424; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    #if CYTHON_COMPILING_IN_CPYTHON
    __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_filename = __pyx_f[0]; __pyx_lineno = 424; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_3 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 424; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    #endif
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  } else {
    __Pyx_RaiseNoneNotIterableError(); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 424; __pyx_clineno = __LINE__; goto __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":425
 *     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_filename = __pyx_f[0]; __pyx_lineno = 425; __pyx_clineno = __LINE__; goto __pyx_L1_error;} }
  __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 425; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_INCREF(__pyx_v_self);
  PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_self);
  __Pyx_GIVEREF(__pyx_v_self);
  __pyx_t_3 = PySequence_Tuple(__pyx_v_args); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 425; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 425; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 425; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  if (likely(PyDict_Check(__pyx_v_kwargs))) {
    __pyx_t_3 = __pyx_v_kwargs;
    __Pyx_INCREF(__pyx_t_3);
  } else {
    __pyx_t_3 = PyObject_CallFunctionObjArgs((PyObject*)&PyDict_Type, __pyx_v_kwargs, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 425; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 425; __pyx_clineno = __LINE__; goto __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":423
 *     """
 *     @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":417
 * 
 * 
 * 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;
  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_RefNannyFinishContext();
    return NULL;
  }
  __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":422
 *     (i.e. it knows about the 'self' argument).
 *     """
 *     @wraps(meth)             # <<<<<<<<<<<<<<
 *     def wrapper(self, *args):
 *         args, kwargs = _fix_args_kwargs(args)
 */
  __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 422; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_INCREF(__pyx_cur_scope->__pyx_v_meth);
  PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_cur_scope->__pyx_v_meth);
  __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_meth);
  __pyx_t_2 = __Pyx_PyObject_Call(__pyx_v_4lupa_5_lupa_wraps, __pyx_t_1, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 422; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "lupa/_lupa.pyx":423
 *     """
 *     @wraps(meth)
 *     def wrapper(self, *args):             # <<<<<<<<<<<<<<
 *         args, kwargs = _fix_args_kwargs(args)
 *         return meth(self, *args, **kwargs)
 */
  __pyx_t_1 = __Pyx_CyFunction_NewEx(&__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, PyModule_GetDict(__pyx_m), ((PyObject *)__pyx_codeobj__13)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 423; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);

  /* "lupa/_lupa.pyx":422
 *     (i.e. it knows about the 'self' argument).
 *     """
 *     @wraps(meth)             # <<<<<<<<<<<<<<
 *     def wrapper(self, *args):
 *         args, kwargs = _fix_args_kwargs(args)
 */
  __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 422; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __pyx_t_1 = 0;
  __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_3, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 422; __pyx_clineno = __LINE__; goto __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_v_wrapper = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "lupa/_lupa.pyx":426
 *         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":417
 * 
 * 
 * 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_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":429
 * 
 * 
 * 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_new_args = NULL;
  PyObject *__pyx_v_new_kwargs = NULL;
  size_t __pyx_v_key;
  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;
  PyObject *__pyx_t_8 = NULL;
  PyObject *(*__pyx_t_9)(PyObject *);
  PyObject *__pyx_t_10 = NULL;
  PyObject *__pyx_t_11 = NULL;
  PyObject *__pyx_t_12 = NULL;
  PyObject *(*__pyx_t_13)(PyObject *);
  int __pyx_t_14;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("_fix_args_kwargs", 0);

  /* "lupa/_lupa.pyx":435
 *     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_filename = __pyx_f[0]; __pyx_lineno = 435; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_t_1 = PyTuple_GET_SIZE(__pyx_v_args); if (unlikely(__pyx_t_1 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 435; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_2 = ((__pyx_t_1 != 1) != 0);
  if (__pyx_t_2) {

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

  /* "lupa/_lupa.pyx":438
 *         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_filename = __pyx_f[0]; __pyx_lineno = 438; __pyx_clineno = __LINE__; goto __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 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 438; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_v_arg = __pyx_t_4;
  __pyx_t_4 = 0;

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

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

  /* "lupa/_lupa.pyx":442
 *         return args, {}
 * 
 *     table = <_LuaTable>arg             # <<<<<<<<<<<<<<
 * 
 *     # arguments with keys from 1 to #tbl are passed as positional
 */
  __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":445
 * 
 *     # 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_3 = PyList_New(0); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 445; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);

  /* "lupa/_lupa.pyx":447
 *     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);
  for (__pyx_t_7 = 1; __pyx_t_7 < __pyx_t_6; __pyx_t_7+=1) {
    __pyx_v_key = __pyx_t_7;

    /* "lupa/_lupa.pyx":446
 *     # 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_v_key); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 446; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_8 = __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_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 446; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_8);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    if (unlikely(__Pyx_ListComp_Append(__pyx_t_3, (PyObject*)__pyx_t_8))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 445; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  }
  __pyx_v_new_args = ((PyObject*)__pyx_t_3);
  __pyx_t_3 = 0;

  /* "lupa/_lupa.pyx":451
 * 
 *     # arguments with non-integer keys are passed as named
 *     new_kwargs = {             # <<<<<<<<<<<<<<
 *         key: value for key, value in _LuaIter(table, ITEMS)
 *         if not isinstance(key, (int, long))
 */
  { /* enter inner scope */
    PyObject *__pyx_7genexpr__pyx_v_key = NULL;
    PyObject *__pyx_7genexpr__pyx_v_value = NULL;
    __pyx_t_3 = PyDict_New(); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 451; __pyx_clineno = __LINE__; goto __pyx_L9_error;}
    __Pyx_GOTREF(__pyx_t_3);

    /* "lupa/_lupa.pyx":452
 *     # arguments with non-integer keys are passed as named
 *     new_kwargs = {
 *         key: value for key, value in _LuaIter(table, ITEMS)             # <<<<<<<<<<<<<<
 *         if not isinstance(key, (int, long))
 *     }
 */
    __pyx_t_8 = __Pyx_PyInt_From_int(__pyx_e_4lupa_5_lupa_ITEMS); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 452; __pyx_clineno = __LINE__; goto __pyx_L9_error;}
    __Pyx_GOTREF(__pyx_t_8);
    __pyx_t_4 = PyTuple_New(2); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 452; __pyx_clineno = __LINE__; goto __pyx_L9_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_INCREF(((PyObject *)__pyx_v_table));
    PyTuple_SET_ITEM(__pyx_t_4, 0, ((PyObject *)__pyx_v_table));
    __Pyx_GIVEREF(((PyObject *)__pyx_v_table));
    PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_t_8);
    __Pyx_GIVEREF(__pyx_t_8);
    __pyx_t_8 = 0;
    __pyx_t_8 = __Pyx_PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_4lupa_5_lupa__LuaIter)), __pyx_t_4, NULL); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 452; __pyx_clineno = __LINE__; goto __pyx_L9_error;}
    __Pyx_GOTREF(__pyx_t_8);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    if (PyList_CheckExact(__pyx_t_8) || PyTuple_CheckExact(__pyx_t_8)) {
      __pyx_t_4 = __pyx_t_8; __Pyx_INCREF(__pyx_t_4); __pyx_t_1 = 0;
      __pyx_t_9 = NULL;
    } else {
      __pyx_t_1 = -1; __pyx_t_4 = PyObject_GetIter(__pyx_t_8); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 452; __pyx_clineno = __LINE__; goto __pyx_L9_error;}
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_t_9 = Py_TYPE(__pyx_t_4)->tp_iternext;
    }
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    for (;;) {
      if (!__pyx_t_9 && PyList_CheckExact(__pyx_t_4)) {
        if (__pyx_t_1 >= PyList_GET_SIZE(__pyx_t_4)) break;
        #if CYTHON_COMPILING_IN_CPYTHON
        __pyx_t_8 = PyList_GET_ITEM(__pyx_t_4, __pyx_t_1); __Pyx_INCREF(__pyx_t_8); __pyx_t_1++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 452; __pyx_clineno = __LINE__; goto __pyx_L9_error;}
        #else
        __pyx_t_8 = PySequence_ITEM(__pyx_t_4, __pyx_t_1); __pyx_t_1++; if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 452; __pyx_clineno = __LINE__; goto __pyx_L9_error;}
        #endif
      } else if (!__pyx_t_9 && PyTuple_CheckExact(__pyx_t_4)) {
        if (__pyx_t_1 >= PyTuple_GET_SIZE(__pyx_t_4)) break;
        #if CYTHON_COMPILING_IN_CPYTHON
        __pyx_t_8 = PyTuple_GET_ITEM(__pyx_t_4, __pyx_t_1); __Pyx_INCREF(__pyx_t_8); __pyx_t_1++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 452; __pyx_clineno = __LINE__; goto __pyx_L9_error;}
        #else
        __pyx_t_8 = PySequence_ITEM(__pyx_t_4, __pyx_t_1); __pyx_t_1++; if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 452; __pyx_clineno = __LINE__; goto __pyx_L9_error;}
        #endif
      } else {
        __pyx_t_8 = __pyx_t_9(__pyx_t_4);
        if (unlikely(!__pyx_t_8)) {
          PyObject* exc_type = PyErr_Occurred();
          if (exc_type) {
            if (likely(exc_type == PyExc_StopIteration || PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
            else {__pyx_filename = __pyx_f[0]; __pyx_lineno = 452; __pyx_clineno = __LINE__; goto __pyx_L9_error;}
          }
          break;
        }
        __Pyx_GOTREF(__pyx_t_8);
      }
      if ((likely(PyTuple_CheckExact(__pyx_t_8))) || (PyList_CheckExact(__pyx_t_8))) {
        PyObject* sequence = __pyx_t_8;
        #if CYTHON_COMPILING_IN_CPYTHON
        Py_ssize_t size = Py_SIZE(sequence);
        #else
        Py_ssize_t size = PySequence_Size(sequence);
        #endif
        if (unlikely(size != 2)) {
          if (size > 2) __Pyx_RaiseTooManyValuesError(2);
          else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
          {__pyx_filename = __pyx_f[0]; __pyx_lineno = 452; __pyx_clineno = __LINE__; goto __pyx_L9_error;}
        }
        #if CYTHON_COMPILING_IN_CPYTHON
        if (likely(PyTuple_CheckExact(sequence))) {
          __pyx_t_10 = PyTuple_GET_ITEM(sequence, 0); 
          __pyx_t_11 = PyTuple_GET_ITEM(sequence, 1); 
        } else {
          __pyx_t_10 = PyList_GET_ITEM(sequence, 0); 
          __pyx_t_11 = PyList_GET_ITEM(sequence, 1); 
        }
        __Pyx_INCREF(__pyx_t_10);
        __Pyx_INCREF(__pyx_t_11);
        #else
        __pyx_t_10 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 452; __pyx_clineno = __LINE__; goto __pyx_L9_error;}
        __Pyx_GOTREF(__pyx_t_10);
        __pyx_t_11 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 452; __pyx_clineno = __LINE__; goto __pyx_L9_error;}
        __Pyx_GOTREF(__pyx_t_11);
        #endif
        __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      } else {
        Py_ssize_t index = -1;
        __pyx_t_12 = PyObject_GetIter(__pyx_t_8); if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 452; __pyx_clineno = __LINE__; goto __pyx_L9_error;}
        __Pyx_GOTREF(__pyx_t_12);
        __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
        __pyx_t_13 = Py_TYPE(__pyx_t_12)->tp_iternext;
        index = 0; __pyx_t_10 = __pyx_t_13(__pyx_t_12); if (unlikely(!__pyx_t_10)) goto __pyx_L12_unpacking_failed;
        __Pyx_GOTREF(__pyx_t_10);
        index = 1; __pyx_t_11 = __pyx_t_13(__pyx_t_12); if (unlikely(!__pyx_t_11)) goto __pyx_L12_unpacking_failed;
        __Pyx_GOTREF(__pyx_t_11);
        if (__Pyx_IternextUnpackEndCheck(__pyx_t_13(__pyx_t_12), 2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 452; __pyx_clineno = __LINE__; goto __pyx_L9_error;}
        __pyx_t_13 = NULL;
        __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
        goto __pyx_L13_unpacking_done;
        __pyx_L12_unpacking_failed:;
        __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
        __pyx_t_13 = NULL;
        if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
        {__pyx_filename = __pyx_f[0]; __pyx_lineno = 452; __pyx_clineno = __LINE__; goto __pyx_L9_error;}
        __pyx_L13_unpacking_done:;
      }
      __Pyx_XDECREF_SET(__pyx_7genexpr__pyx_v_key, __pyx_t_10);
      __pyx_t_10 = 0;
      __Pyx_XDECREF_SET(__pyx_7genexpr__pyx_v_value, __pyx_t_11);
      __pyx_t_11 = 0;

      /* "lupa/_lupa.pyx":453
 *     new_kwargs = {
 *         key: value for key, value in _LuaIter(table, ITEMS)
 *         if not isinstance(key, (int, long))             # <<<<<<<<<<<<<<
 *     }
 *     return new_args, new_kwargs
 */
      __pyx_t_5 = PyInt_Check(__pyx_7genexpr__pyx_v_key); 
      if (!__pyx_t_5) {
        __pyx_t_2 = PyLong_Check(__pyx_7genexpr__pyx_v_key); 
        __pyx_t_14 = __pyx_t_2;
      } else {
        __pyx_t_14 = __pyx_t_5;
      }
      __pyx_t_5 = ((!(__pyx_t_14 != 0)) != 0);
      if (__pyx_t_5) {

        /* "lupa/_lupa.pyx":452
 *     # arguments with non-integer keys are passed as named
 *     new_kwargs = {
 *         key: value for key, value in _LuaIter(table, ITEMS)             # <<<<<<<<<<<<<<
 *         if not isinstance(key, (int, long))
 *     }
 */
        if (unlikely(PyDict_SetItem(__pyx_t_3, (PyObject*)__pyx_7genexpr__pyx_v_key, (PyObject*)__pyx_7genexpr__pyx_v_value))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 452; __pyx_clineno = __LINE__; goto __pyx_L9_error;}
        goto __pyx_L14;
      }
      __pyx_L14:;
    }
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_XDECREF(__pyx_7genexpr__pyx_v_key);
    __Pyx_XDECREF(__pyx_7genexpr__pyx_v_value);
    goto __pyx_L15_exit_scope;
    __pyx_L9_error:;
    __Pyx_XDECREF(__pyx_7genexpr__pyx_v_key);
    __Pyx_XDECREF(__pyx_7genexpr__pyx_v_value);
    goto __pyx_L1_error;
    __pyx_L15_exit_scope:;
  } /* exit inner scope */
  __pyx_v_new_kwargs = ((PyObject*)__pyx_t_3);
  __pyx_t_3 = 0;

  /* "lupa/_lupa.pyx":455
 *         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_filename = __pyx_f[0]; __pyx_lineno = 455; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_INCREF(__pyx_v_new_args);
  PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_v_new_args);
  __Pyx_GIVEREF(__pyx_v_new_args);
  __Pyx_INCREF(__pyx_v_new_kwargs);
  PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_v_new_kwargs);
  __Pyx_GIVEREF(__pyx_v_new_kwargs);
  __pyx_r = ((PyObject*)__pyx_t_3);
  __pyx_t_3 = 0;
  goto __pyx_L0;

  /* "lupa/_lupa.pyx":429
 * 
 * 
 * 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_8);
  __Pyx_XDECREF(__pyx_t_10);
  __Pyx_XDECREF(__pyx_t_11);
  __Pyx_XDECREF(__pyx_t_12);
  __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_new_args);
  __Pyx_XDECREF(__pyx_v_new_kwargs);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lupa/_lupa.pyx":461
 * # 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;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("lock_runtime", 0);

  /* "lupa/_lupa.pyx":462
 * 
 * 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 (__pyx_t_2) {

    /* "lupa/_lupa.pyx":463
 * 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 = __Pyx_GetModuleGlobalName(__pyx_n_s_LuaError); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 463; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_tuple__14, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 463; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_Raise(__pyx_t_3, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 463; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }

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

/* "lupa/_lupa.pyx":466
 *     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":467
 * 
 * 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":466
 *     return 0
 * 
 * cdef inline void unlock_runtime(LuaRuntime runtime) nogil:             # <<<<<<<<<<<<<<
 *     unlock_lock(runtime._lock)
 * 
 */

  /* function exit code */
}

/* "lupa/_lupa.pyx":483
 *     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":484
 * 
 *     def __init__(self):
 *         raise TypeError("Type cannot be instantiated manually")             # <<<<<<<<<<<<<<
 * 
 *     def __dealloc__(self):
 */
  __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__15, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 484; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 484; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "lupa/_lupa.pyx":483
 *     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":486
 *         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":487
 * 
 *     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":488
 *     def __dealloc__(self):
 *         if self._runtime is None:
 *             return             # <<<<<<<<<<<<<<
 *         cdef lua_State* L = self._state
 *         try:
 */
    goto __pyx_L0;
  }

  /* "lupa/_lupa.pyx":489
 *         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":490
 *             return
 *         cdef lua_State* L = self._state
 *         try:             # <<<<<<<<<<<<<<
 *             lock_runtime(self._runtime)
 *             locked = True
 */
  {
    __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":491
 *         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 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 491; __pyx_clineno = __LINE__; goto __pyx_L4_error;}
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;

      /* "lupa/_lupa.pyx":492
 *         try:
 *             lock_runtime(self._runtime)
 *             locked = True             # <<<<<<<<<<<<<<
 *         except:
 *             locked = False
 */
      __pyx_v_locked = 1;
    }
    __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_L11_try_end;
    __pyx_L4_error:;
    __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;

    /* "lupa/_lupa.pyx":493
 *             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_filename = __pyx_f[0]; __pyx_lineno = 493; __pyx_clineno = __LINE__; goto __pyx_L6_except_error;}
      __Pyx_GOTREF(__pyx_t_7);
      __Pyx_GOTREF(__pyx_t_9);
      __Pyx_GOTREF(__pyx_t_10);

      /* "lupa/_lupa.pyx":494
 *             locked = True
 *         except:
 *             locked = False             # <<<<<<<<<<<<<<
 *         lua.luaL_unref(L, lua.LUA_REGISTRYINDEX, self._ref)
 *         if locked:
 */
      __pyx_v_locked = 0;
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
      __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
      goto __pyx_L5_exception_handled;
    }
    __pyx_L6_except_error:;
    __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_L11_try_end:;
  }

  /* "lupa/_lupa.pyx":495
 *         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":496
 *             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":497
 *         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;
    goto __pyx_L14;
  }
  __pyx_L14:;

  /* "lupa/_lupa.pyx":486
 *         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, 0);
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
}

/* "lupa/_lupa.pyx":500
 * 
 *     @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;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("push_lua_object", 0);

  /* "lupa/_lupa.pyx":501
 *     @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":502
 *     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":503
 *         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 (__pyx_t_2) {

    /* "lupa/_lupa.pyx":504
 *         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":505
 *         if lua.lua_isnil(L, -1):
 *             lua.lua_pop(L, 1)
 *             raise LuaError("lost reference")             # <<<<<<<<<<<<<<
 * 
 *     def __call__(self, *args):
 */
    __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_LuaError); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 505; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_tuple__16, NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 505; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 505; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }

  /* "lupa/_lupa.pyx":500
 * 
 *     @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_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":507
 *             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":508
 * 
 *     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_filename = __pyx_f[0]; __pyx_lineno = 508; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
  }
  #endif

  /* "lupa/_lupa.pyx":509
 *     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":510
 *         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 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 510; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

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

    /* "lupa/_lupa.pyx":512
 *         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":513
 *         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 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 513; __pyx_clineno = __LINE__; goto __pyx_L4_error;}

    /* "lupa/_lupa.pyx":514
 *             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_filename = __pyx_f[0]; __pyx_lineno = 514; __pyx_clineno = __LINE__; goto __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":516
 *             return call_lua(self._runtime, L, args)
 *         finally:
 *             lua.lua_settop(L, 0)             # <<<<<<<<<<<<<<
 *             unlock_runtime(self._runtime)
 * 
 */
  /*finally:*/ {
    /*exception exit:*/{
      __pyx_L4_error:;
      __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":517
 *         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":516
 *             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":517
 *         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":507
 *             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":519
 *             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":520
 * 
 *     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":519
 *             unlock_runtime(self._runtime)
 * 
 *     def __len__(self):             # <<<<<<<<<<<<<<
 *         return self._len()
 * 
 */

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

/* "lupa/_lupa.pyx":523
 * 
 *     @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":524
 *     @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_filename = __pyx_f[0]; __pyx_lineno = 524; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
  }
  #endif

  /* "lupa/_lupa.pyx":525
 *     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":526
 *         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 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 526; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

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

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

    /* "lupa/_lupa.pyx":529
 *         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 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 529; __pyx_clineno = __LINE__; goto __pyx_L4_error;}

    /* "lupa/_lupa.pyx":530
 *         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":531
 *             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":533
 *             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;
    }
    /*exception exit:*/{
      __pyx_L4_error:;
      __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":534
 *         finally:
 *             unlock_runtime(self._runtime)
 *         return size             # <<<<<<<<<<<<<<
 * 
 *     def __nonzero__(self):
 */
  __pyx_r = __pyx_v_size;
  goto __pyx_L0;

  /* "lupa/_lupa.pyx":523
 * 
 *     @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, 0);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lupa/_lupa.pyx":536
 *         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":537
 * 
 *     def __nonzero__(self):
 *         return True             # <<<<<<<<<<<<<<
 * 
 *     def __iter__(self):
 */
  __pyx_r = 1;
  goto __pyx_L0;

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

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

/* "lupa/_lupa.pyx":539
 *         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":541
 *     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__17, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 541; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 541; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "lupa/_lupa.pyx":539
 *         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":543
 *         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 = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  lua_State *__pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  int __pyx_t_5;
  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("__repr__", 0);

  /* "lupa/_lupa.pyx":544
 * 
 *     def __repr__(self):
 *         assert self._runtime is not None             # <<<<<<<<<<<<<<
 *         cdef lua_State* L = self._state
 *         encoding = self._runtime._encoding.decode('ASCII') if self._runtime._encoding else '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_filename = __pyx_f[0]; __pyx_lineno = 544; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
  }
  #endif

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

  /* "lupa/_lupa.pyx":546
 *         assert self._runtime is not None
 *         cdef lua_State* L = self._state
 *         encoding = self._runtime._encoding.decode('ASCII') if self._runtime._encoding else 'UTF-8'             # <<<<<<<<<<<<<<
 *         lock_runtime(self._runtime)
 *         try:
 */
  __pyx_t_1 = (__pyx_v_self->_runtime->_encoding != Py_None) && (PyBytes_GET_SIZE(__pyx_v_self->_runtime->_encoding) != 0);
  if (__pyx_t_1) {
    if (unlikely(__pyx_v_self->_runtime->_encoding == Py_None)) {
      PyErr_Format(PyExc_AttributeError, "'NoneType' object has no attribute '%s'", "decode");
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 546; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    __pyx_t_4 = __Pyx_decode_bytes(__pyx_v_self->_runtime->_encoding, 0, PY_SSIZE_T_MAX, NULL, NULL, PyUnicode_DecodeASCII); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 546; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_3 = __pyx_t_4;
    __pyx_t_4 = 0;
  } else {
    __Pyx_INCREF(__pyx_kp_s_UTF_8);
    __pyx_t_3 = __pyx_kp_s_UTF_8;
  }
  __pyx_v_encoding = __pyx_t_3;
  __pyx_t_3 = 0;

  /* "lupa/_lupa.pyx":547
 *         cdef lua_State* L = self._state
 *         encoding = self._runtime._encoding.decode('ASCII') if self._runtime._encoding else '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_5 = __pyx_f_4lupa_5_lupa_lock_runtime(((struct __pyx_obj_4lupa_5_lupa_LuaRuntime *)__pyx_t_3)); if (unlikely(__pyx_t_5 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 547; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

  /* "lupa/_lupa.pyx":548
 *         encoding = self._runtime._encoding.decode('ASCII') if self._runtime._encoding else 'UTF-8'
 *         lock_runtime(self._runtime)
 *         try:             # <<<<<<<<<<<<<<
 *             self.push_lua_object()
 *             return lua_object_repr(L, encoding)
 */
  /*try:*/ {

    /* "lupa/_lupa.pyx":549
 *         lock_runtime(self._runtime)
 *         try:
 *             self.push_lua_object()             # <<<<<<<<<<<<<<
 *             return lua_object_repr(L, encoding)
 *         finally:
 */
    __pyx_t_5 = __pyx_f_4lupa_5_lupa_10_LuaObject_push_lua_object(__pyx_v_self); if (unlikely(__pyx_t_5 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 549; __pyx_clineno = __LINE__; goto __pyx_L4_error;}

    /* "lupa/_lupa.pyx":550
 *         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_filename = __pyx_f[0]; __pyx_lineno = 550; __pyx_clineno = __LINE__; goto __pyx_L4_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_r = __pyx_t_3;
    __pyx_t_3 = 0;
    goto __pyx_L3_return;
  }

  /* "lupa/_lupa.pyx":552
 *             return lua_object_repr(L, encoding)
 *         finally:
 *             lua.lua_pop(L, 1)             # <<<<<<<<<<<<<<
 *             unlock_runtime(self._runtime)
 * 
 */
  /*finally:*/ {
    /*exception exit:*/{
      __pyx_L4_error:;
      __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_4); __pyx_t_4 = 0;
      __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 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_5 = __pyx_lineno; __pyx_t_6 = __pyx_clineno; __pyx_t_7 = __pyx_filename;
      {
        lua_pop(__pyx_v_L, 1);

        /* "lupa/_lupa.pyx":553
 *         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_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_5; __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":552
 *             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":553
 *         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_13;
      __pyx_t_13 = 0;
      goto __pyx_L0;
    }
  }

  /* "lupa/_lupa.pyx":543
 *         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_XDECREF(__pyx_t_4);
  __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":555
 *             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;
  const char* __pyx_v_s;
  size_t __pyx_v_size;
  PyObject *__pyx_v_encoding = NULL;
  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;
  PyObject *__pyx_t_4 = NULL;
  int __pyx_t_5;
  int __pyx_t_6;
  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;
  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":556
 * 
 *     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_filename = __pyx_f[0]; __pyx_lineno = 556; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
  }
  #endif

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

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

  /* "lupa/_lupa.pyx":560
 *         cdef unicode py_string = None
 *         cdef const_char_ptr s
 *         cdef size_t size = 0             # <<<<<<<<<<<<<<
 *         encoding = self._runtime._encoding.decode('ASCII') if self._runtime._encoding else 'UTF-8'
 *         lock_runtime(self._runtime)
 */
  __pyx_v_size = 0;

  /* "lupa/_lupa.pyx":561
 *         cdef const_char_ptr s
 *         cdef size_t size = 0
 *         encoding = self._runtime._encoding.decode('ASCII') if self._runtime._encoding else 'UTF-8'             # <<<<<<<<<<<<<<
 *         lock_runtime(self._runtime)
 *         old_top = lua.lua_gettop(L)
 */
  __pyx_t_1 = (__pyx_v_self->_runtime->_encoding != Py_None) && (PyBytes_GET_SIZE(__pyx_v_self->_runtime->_encoding) != 0);
  if (__pyx_t_1) {
    if (unlikely(__pyx_v_self->_runtime->_encoding == Py_None)) {
      PyErr_Format(PyExc_AttributeError, "'NoneType' object has no attribute '%s'", "decode");
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 561; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    __pyx_t_4 = __Pyx_decode_bytes(__pyx_v_self->_runtime->_encoding, 0, PY_SSIZE_T_MAX, NULL, NULL, PyUnicode_DecodeASCII); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 561; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_3 = __pyx_t_4;
    __pyx_t_4 = 0;
  } else {
    __Pyx_INCREF(__pyx_kp_s_UTF_8);
    __pyx_t_3 = __pyx_kp_s_UTF_8;
  }
  __pyx_v_encoding = __pyx_t_3;
  __pyx_t_3 = 0;

  /* "lupa/_lupa.pyx":562
 *         cdef size_t size = 0
 *         encoding = self._runtime._encoding.decode('ASCII') if self._runtime._encoding else '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_5 = __pyx_f_4lupa_5_lupa_lock_runtime(((struct __pyx_obj_4lupa_5_lupa_LuaRuntime *)__pyx_t_3)); if (unlikely(__pyx_t_5 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 562; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

  /* "lupa/_lupa.pyx":563
 *         encoding = self._runtime._encoding.decode('ASCII') if self._runtime._encoding else '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_filename = __pyx_f[0]; __pyx_lineno = 563; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_v_old_top = __pyx_t_3;
  __pyx_t_3 = 0;

  /* "lupa/_lupa.pyx":564
 *         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":565
 *         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_5 = __pyx_f_4lupa_5_lupa_10_LuaObject_push_lua_object(__pyx_v_self); if (unlikely(__pyx_t_5 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 565; __pyx_clineno = __LINE__; goto __pyx_L4_error;}

    /* "lupa/_lupa.pyx":567
 *             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":568
 *             # 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, __pyx_k_tostring, 10);

      /* "lupa/_lupa.pyx":569
 *             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":570
 *                 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_1 = ((!(lua_isnil(__pyx_v_L, -1) != 0)) != 0);
      if (__pyx_t_1) {
        __pyx_t_6 = ((lua_pcall(__pyx_v_L, 1, 1, 0) == 0) != 0);
        __pyx_t_7 = __pyx_t_6;
      } else {
        __pyx_t_7 = __pyx_t_1;
      }
      if (__pyx_t_7) {

        /* "lupa/_lupa.pyx":571
 *                 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":572
 *                 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_7 = (__pyx_v_s != 0);
        if (__pyx_t_7) {

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

              /* "lupa/_lupa.pyx":574
 *                     if s:
 *                         try:
 *                             py_string = s[:size].decode(encoding)             # <<<<<<<<<<<<<<
 *                         except UnicodeDecodeError:
 *                             # safe 'decode'
 */
              __pyx_t_3 = __Pyx_PyBytes_FromStringAndSize(((const char*)__pyx_v_s) + 0, __pyx_v_size - 0); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 574; __pyx_clineno = __LINE__; goto __pyx_L9_error;}
              __Pyx_GOTREF(__pyx_t_3);
              __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_decode); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 574; __pyx_clineno = __LINE__; goto __pyx_L9_error;}
              __Pyx_GOTREF(__pyx_t_4);
              __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
              __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 574; __pyx_clineno = __LINE__; goto __pyx_L9_error;}
              __Pyx_GOTREF(__pyx_t_3);
              __Pyx_INCREF(__pyx_v_encoding);
              PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_v_encoding);
              __Pyx_GIVEREF(__pyx_v_encoding);
              __pyx_t_11 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_3, NULL); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 574; __pyx_clineno = __LINE__; goto __pyx_L9_error;}
              __Pyx_GOTREF(__pyx_t_11);
              __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
              __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
              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_filename = __pyx_f[0]; __pyx_lineno = 574; __pyx_clineno = __LINE__; goto __pyx_L9_error;}
              __Pyx_DECREF_SET(__pyx_v_py_string, ((PyObject*)__pyx_t_11));
              __pyx_t_11 = 0;
            }
            __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;
            goto __pyx_L16_try_end;
            __pyx_L9_error:;
            __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
            __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
            __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0;

            /* "lupa/_lupa.pyx":575
 *                         try:
 *                             py_string = s[:size].decode(encoding)
 *                         except UnicodeDecodeError:             # <<<<<<<<<<<<<<
 *                             # safe 'decode'
 *                             py_string = s[:size].decode('ISO-8859-1')
 */
            __pyx_t_5 = PyErr_ExceptionMatches(__pyx_builtin_UnicodeDecodeError);
            if (__pyx_t_5) {
              __Pyx_AddTraceback("lupa._lupa._LuaObject.__str__", __pyx_clineno, __pyx_lineno, __pyx_filename);
              if (__Pyx_GetException(&__pyx_t_11, &__pyx_t_3, &__pyx_t_4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 575; __pyx_clineno = __LINE__; goto __pyx_L11_except_error;}
              __Pyx_GOTREF(__pyx_t_11);
              __Pyx_GOTREF(__pyx_t_3);
              __Pyx_GOTREF(__pyx_t_4);

              /* "lupa/_lupa.pyx":577
 *                         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_filename = __pyx_f[0]; __pyx_lineno = 577; __pyx_clineno = __LINE__; goto __pyx_L11_except_error;}
              __Pyx_GOTREF(__pyx_t_12);
              if (!(likely(PyUnicode_CheckExact(__pyx_t_12))||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "unicode", Py_TYPE(__pyx_t_12)->tp_name), 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 577; __pyx_clineno = __LINE__; goto __pyx_L11_except_error;}
              __Pyx_DECREF_SET(__pyx_v_py_string, ((PyObject*)__pyx_t_12));
              __pyx_t_12 = 0;
              __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
              __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
              __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
              goto __pyx_L10_exception_handled;
            }
            goto __pyx_L11_except_error;
            __pyx_L11_except_error:;
            __Pyx_XGIVEREF(__pyx_t_8);
            __Pyx_XGIVEREF(__pyx_t_9);
            __Pyx_XGIVEREF(__pyx_t_10);
            __Pyx_ExceptionReset(__pyx_t_8, __pyx_t_9, __pyx_t_10);
            goto __pyx_L4_error;
            __pyx_L10_exception_handled:;
            __Pyx_XGIVEREF(__pyx_t_8);
            __Pyx_XGIVEREF(__pyx_t_9);
            __Pyx_XGIVEREF(__pyx_t_10);
            __Pyx_ExceptionReset(__pyx_t_8, __pyx_t_9, __pyx_t_10);
            __pyx_L16_try_end:;
          }
          goto __pyx_L8;
        }
        __pyx_L8:;
        goto __pyx_L7;
      }
      __pyx_L7:;
      goto __pyx_L6;
    }
    __pyx_L6:;

    /* "lupa/_lupa.pyx":578
 *                             # 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_7 = (__pyx_v_py_string == ((PyObject*)Py_None));
    __pyx_t_1 = (__pyx_t_7 != 0);
    if (__pyx_t_1) {

      /* "lupa/_lupa.pyx":579
 *                             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_4 = PyNumber_Add(__pyx_v_old_top, __pyx_int_1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 579; __pyx_clineno = __LINE__; goto __pyx_L4_error;}
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_t_5 = __Pyx_PyInt_As_int(__pyx_t_4); if (unlikely((__pyx_t_5 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 579; __pyx_clineno = __LINE__; goto __pyx_L4_error;}
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      lua_settop(__pyx_v_L, __pyx_t_5);

      /* "lupa/_lupa.pyx":580
 *             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_4 = __pyx_f_4lupa_5_lupa_lua_object_repr(__pyx_v_L, __pyx_v_encoding); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 580; __pyx_clineno = __LINE__; goto __pyx_L4_error;}
      __Pyx_GOTREF(__pyx_t_4);
      if (!(likely(PyUnicode_CheckExact(__pyx_t_4))||((__pyx_t_4) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "unicode", Py_TYPE(__pyx_t_4)->tp_name), 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 580; __pyx_clineno = __LINE__; goto __pyx_L4_error;}
      __Pyx_DECREF_SET(__pyx_v_py_string, ((PyObject*)__pyx_t_4));
      __pyx_t_4 = 0;
      goto __pyx_L19;
    }
    __pyx_L19:;
  }

  /* "lupa/_lupa.pyx":582
 *                 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_5 = __Pyx_PyInt_As_int(__pyx_v_old_top); if (unlikely((__pyx_t_5 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 582; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      lua_settop(__pyx_v_L, __pyx_t_5);

      /* "lupa/_lupa.pyx":583
 *         finally:
 *             lua.lua_settop(L, old_top)
 *             unlock_runtime(self._runtime)             # <<<<<<<<<<<<<<
 *         return py_string
 * 
 */
      __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;
      goto __pyx_L5;
    }
    /*exception exit:*/{
      __pyx_L4_error:;
      __pyx_t_10 = 0; __pyx_t_9 = 0; __pyx_t_8 = 0; __pyx_t_15 = 0; __pyx_t_16 = 0; __pyx_t_17 = 0;
      __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0;
      __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0;
      __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 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_10, &__pyx_t_9, &__pyx_t_8) < 0)) __Pyx_ErrFetch(&__pyx_t_10, &__pyx_t_9, &__pyx_t_8);
      __Pyx_XGOTREF(__pyx_t_10);
      __Pyx_XGOTREF(__pyx_t_9);
      __Pyx_XGOTREF(__pyx_t_8);
      __Pyx_XGOTREF(__pyx_t_15);
      __Pyx_XGOTREF(__pyx_t_16);
      __Pyx_XGOTREF(__pyx_t_17);
      __pyx_t_5 = __pyx_lineno; __pyx_t_13 = __pyx_clineno; __pyx_t_14 = __pyx_filename;
      {

        /* "lupa/_lupa.pyx":582
 *                 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_filename = __pyx_f[0]; __pyx_lineno = 582; __pyx_clineno = __LINE__; goto __pyx_L21_error;}
        lua_settop(__pyx_v_L, __pyx_t_18);

        /* "lupa/_lupa.pyx":583
 *         finally:
 *             lua.lua_settop(L, old_top)
 *             unlock_runtime(self._runtime)             # <<<<<<<<<<<<<<
 *         return py_string
 * 
 */
        __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_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_10);
      __Pyx_XGIVEREF(__pyx_t_9);
      __Pyx_XGIVEREF(__pyx_t_8);
      __Pyx_ErrRestore(__pyx_t_10, __pyx_t_9, __pyx_t_8);
      __pyx_t_10 = 0; __pyx_t_9 = 0; __pyx_t_8 = 0; __pyx_t_15 = 0; __pyx_t_16 = 0; __pyx_t_17 = 0;
      __pyx_lineno = __pyx_t_5; __pyx_clineno = __pyx_t_13; __pyx_filename = __pyx_t_14;
      goto __pyx_L1_error;
      __pyx_L21_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_10); __pyx_t_10 = 0;
      __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
      __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
      __pyx_t_15 = 0; __pyx_t_16 = 0; __pyx_t_17 = 0;
      goto __pyx_L1_error;
    }
    __pyx_L5:;
  }

  /* "lupa/_lupa.pyx":584
 *             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":555
 *             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_4);
  __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":586
 *         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;
  int __pyx_t_3;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  char *__pyx_t_7;
  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":587
 * 
 *     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_filename = __pyx_f[0]; __pyx_lineno = 587; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
  }
  #endif

  /* "lupa/_lupa.pyx":588
 *     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":589
 *         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 '%s'", "startswith");
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 589; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    __pyx_t_2 = __Pyx_PyUnicode_Tailmatch(((PyObject*)__pyx_v_name), __pyx_n_u__18, 0, PY_SSIZE_T_MAX, -1); if (unlikely(__pyx_t_2 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 589; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    if ((__pyx_t_2 != 0)) {
      if (unlikely(__pyx_v_name == Py_None)) {
        PyErr_Format(PyExc_AttributeError, "'NoneType' object has no attribute '%s'", "endswith");
        {__pyx_filename = __pyx_f[0]; __pyx_lineno = 589; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      }
      __pyx_t_1 = __Pyx_PyUnicode_Tailmatch(((PyObject*)__pyx_v_name), __pyx_n_u__18, 0, PY_SSIZE_T_MAX, 1); if (unlikely(__pyx_t_1 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 589; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_t_3 = (__pyx_t_1 != 0);
    } else {
      __pyx_t_3 = (__pyx_t_2 != 0);
    }
    if (__pyx_t_3) {

      /* "lupa/_lupa.pyx":590
 *         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_filename = __pyx_f[0]; __pyx_lineno = 590; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_t_5 = PyTuple_New(2); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 590; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_INCREF(((PyObject *)__pyx_v_self));
      PyTuple_SET_ITEM(__pyx_t_5, 0, ((PyObject *)__pyx_v_self));
      __Pyx_GIVEREF(((PyObject *)__pyx_v_self));
      __Pyx_INCREF(__pyx_v_name);
      PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_v_name);
      __Pyx_GIVEREF(__pyx_v_name);
      __pyx_t_6 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_5, NULL); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 590; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_6);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __pyx_r = __pyx_t_6;
      __pyx_t_6 = 0;
      goto __pyx_L0;
    }

    /* "lupa/_lupa.pyx":591
 *             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 '%s'", "encode");
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 591; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    __pyx_t_7 = __Pyx_PyObject_AsString(__pyx_v_self->_runtime->_source_encoding); if (unlikely((!__pyx_t_7) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 591; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_6 = PyUnicode_AsEncodedString(((PyObject*)__pyx_v_name), __pyx_t_7, NULL); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 591; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_DECREF_SET(__pyx_v_name, __pyx_t_6);
    __pyx_t_6 = 0;
    goto __pyx_L3;
  }

  /* "lupa/_lupa.pyx":592
 *                 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_3 = PyBytes_Check(__pyx_v_name); 
  __pyx_t_2 = (__pyx_t_3 != 0);
  if (__pyx_t_2) {

    /* "lupa/_lupa.pyx":593
 *             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 '%s'", "startswith");
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 593; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    __pyx_t_2 = __Pyx_PyBytes_Tailmatch(((PyObject*)__pyx_v_name), __pyx_n_b__18, 0, PY_SSIZE_T_MAX, -1); if (unlikely(__pyx_t_2 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 593; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    if ((__pyx_t_2 != 0)) {
      if (unlikely(__pyx_v_name == Py_None)) {
        PyErr_Format(PyExc_AttributeError, "'NoneType' object has no attribute '%s'", "endswith");
        {__pyx_filename = __pyx_f[0]; __pyx_lineno = 593; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      }
      __pyx_t_3 = __Pyx_PyBytes_Tailmatch(((PyObject*)__pyx_v_name), __pyx_n_b__18, 0, PY_SSIZE_T_MAX, 1); if (unlikely(__pyx_t_3 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 593; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_t_1 = (__pyx_t_3 != 0);
    } else {
      __pyx_t_1 = (__pyx_t_2 != 0);
    }
    if (__pyx_t_1) {

      /* "lupa/_lupa.pyx":594
 *         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_6 = __Pyx_PyObject_GetAttrStr(__pyx_builtin_object, __pyx_n_s_getattr); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 594; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_6);
      __pyx_t_5 = PyTuple_New(2); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 594; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_INCREF(((PyObject *)__pyx_v_self));
      PyTuple_SET_ITEM(__pyx_t_5, 0, ((PyObject *)__pyx_v_self));
      __Pyx_GIVEREF(((PyObject *)__pyx_v_self));
      __Pyx_INCREF(__pyx_v_name);
      PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_v_name);
      __Pyx_GIVEREF(__pyx_v_name);
      __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_6, __pyx_t_5, NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 594; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __pyx_r = __pyx_t_4;
      __pyx_t_4 = 0;
      goto __pyx_L0;
    }
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "lupa/_lupa.pyx":595
 *             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_4 = __pyx_f_4lupa_5_lupa_10_LuaObject__getitem(__pyx_v_self, __pyx_v_name, 1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 595; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_r = __pyx_t_4;
  __pyx_t_4 = 0;
  goto __pyx_L0;

  /* "lupa/_lupa.pyx":586
 *         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_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __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":597
 *         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":598
 * 
 *     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_filename = __pyx_f[0]; __pyx_lineno = 598; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "lupa/_lupa.pyx":597
 *         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":601
 * 
 *     @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;
  struct __pyx_opt_args_4lupa_5_lupa_py_to_lua __pyx_t_5;
  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("_getitem", 0);

  /* "lupa/_lupa.pyx":602
 *     @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":603
 *     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 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 603; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "lupa/_lupa.pyx":604
 *         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":605
 *         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":606
 *         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 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 606; __pyx_clineno = __LINE__; goto __pyx_L4_error;}

    /* "lupa/_lupa.pyx":607
 *         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":608
 *             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":609
 *             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":610
 *             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_2 = __pyx_builtin_AttributeError;
      } else {
        __Pyx_INCREF(__pyx_builtin_TypeError);
        __pyx_t_2 = __pyx_builtin_TypeError;
      }
      __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_tuple__19, NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 610; __pyx_clineno = __LINE__; goto __pyx_L4_error;}
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_Raise(__pyx_t_4, 0, 0, 0);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 610; __pyx_clineno = __LINE__; goto __pyx_L4_error;}
      break;
      default: break;
    }

    /* "lupa/_lupa.pyx":613
 *                     "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_4 = ((PyObject *)__pyx_v_self->_runtime);
    __Pyx_INCREF(__pyx_t_4);
    __pyx_t_5.__pyx_n = 1;
    __pyx_t_5.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_4), __pyx_v_L, __pyx_v_name, &__pyx_t_5); if (unlikely(__pyx_t_3 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 613; __pyx_clineno = __LINE__; goto __pyx_L4_error;}
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

    /* "lupa/_lupa.pyx":614
 *             # 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":615
 *             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_4 = ((PyObject *)__pyx_v_self->_runtime);
    __Pyx_INCREF(__pyx_t_4);
    __pyx_t_2 = __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_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 615; __pyx_clineno = __LINE__; goto __pyx_L4_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_r = __pyx_t_2;
    __pyx_t_2 = 0;
    goto __pyx_L3_return;
  }

  /* "lupa/_lupa.pyx":617
 *             return py_from_lua(self._runtime, L, -1)
 *         finally:
 *             lua.lua_settop(L, old_top)             # <<<<<<<<<<<<<<
 *             unlock_runtime(self._runtime)
 * 
 */
  /*finally:*/ {
    /*exception exit:*/{
      __pyx_L4_error:;
      __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_4); __pyx_t_4 = 0;
      __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 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_3 = __pyx_lineno; __pyx_t_6 = __pyx_clineno; __pyx_t_7 = __pyx_filename;
      {
        lua_settop(__pyx_v_L, __pyx_v_old_top);

        /* "lupa/_lupa.pyx":618
 *         finally:
 *             lua.lua_settop(L, old_top)
 *             unlock_runtime(self._runtime)             # <<<<<<<<<<<<<<
 * 
 * 
 */
        __pyx_t_2 = ((PyObject *)__pyx_v_self->_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_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_3; __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":617
 *             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":618
 *         finally:
 *             lua.lua_settop(L, old_top)
 *             unlock_runtime(self._runtime)             # <<<<<<<<<<<<<<
 * 
 * 
 */
      __pyx_t_2 = ((PyObject *)__pyx_v_self->_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;
      __pyx_r = __pyx_t_13;
      __pyx_t_13 = 0;
      goto __pyx_L0;
    }
  }

  /* "lupa/_lupa.pyx":601
 * 
 *     @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_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;
}

/* "lupa/_lupa.pyx":621
 * 
 * 
 * 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":622
 * 
 * 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 = __pyx_tp_new_4lupa_5_lupa__LuaObject(((PyTypeObject *)((PyObject*)__pyx_ptype_4lupa_5_lupa__LuaObject)), __pyx_empty_tuple, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 622; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  if (!(likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_4lupa_5_lupa__LuaObject)))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 622; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_v_obj = ((struct __pyx_obj_4lupa_5_lupa__LuaObject *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "lupa/_lupa.pyx":623
 * 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":624
 *     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":621
 * 
 * 
 * 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":626
 *     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":627
 * 
 * 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":628
 * 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":629
 *     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":630
 *     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, encoding):
 */
  __pyx_v_obj->_ref = luaL_ref(__pyx_v_L, LUA_REGISTRYINDEX);

  /* "lupa/_lupa.pyx":626
 *     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":632
 *     obj._ref = lua.luaL_ref(L, lua.LUA_REGISTRYINDEX)
 * 
 * cdef object lua_object_repr(lua_State* L, 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;
  PyObject *__pyx_t_6 = NULL;
  PyObject *__pyx_t_7 = NULL;
  int __pyx_t_8;
  PyObject *__pyx_t_9 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("lua_object_repr", 0);

  /* "lupa/_lupa.pyx":634
 * cdef object lua_object_repr(lua_State* L, 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":639
 *     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:
 */
  switch (__pyx_v_lua_type) {

    /* "lupa/_lupa.pyx":635
 *     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):
 */
    case LUA_TTABLE:
    case LUA_TFUNCTION:

    /* "lupa/_lupa.pyx":636
 *     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));
    break;

    /* "lupa/_lupa.pyx":637
 *     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_TUSERDATA:
    case LUA_TLIGHTUSERDATA:

    /* "lupa/_lupa.pyx":638
 *         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));
    break;

    /* "lupa/_lupa.pyx":639
 *     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:
 */
    case LUA_TTHREAD:

    /* "lupa/_lupa.pyx":640
 *         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));
    break;
    default:

    /* "lupa/_lupa.pyx":642
 *         ptr = <void*>lua.lua_tothread(L, -1)
 *     else:
 *         ptr = NULL             # <<<<<<<<<<<<<<
 *     if ptr:
 *         py_bytes = PyBytes_FromFormat(
 */
    __pyx_v_ptr = NULL;
    break;
  }

  /* "lupa/_lupa.pyx":643
 *     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":644
 *         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(__pyx_k_Lua_s_at_p, lua_typename(__pyx_v_L, __pyx_v_lua_type), __pyx_v_ptr); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 644; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_v_py_bytes = ((PyObject*)__pyx_t_2);
    __pyx_t_2 = 0;
    goto __pyx_L3;
  }
  /*else*/ {

    /* "lupa/_lupa.pyx":647
 *             "<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:
 */
    __pyx_t_2 = PyBytes_FromFormat(__pyx_k_Lua_s, lua_typename(__pyx_v_L, __pyx_v_lua_type)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 647; __pyx_clineno = __LINE__; goto __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":649
 *         py_bytes = PyBytes_FromFormat(
 *             "<Lua %s>", lua.lua_typename(L, lua_type))
 *     try:             # <<<<<<<<<<<<<<
 *         return py_bytes.decode(encoding)
 *     except UnicodeDecodeError:
 */
  {
    __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":650
 *             "<Lua %s>", lua.lua_typename(L, lua_type))
 *     try:
 *         return py_bytes.decode(encoding)             # <<<<<<<<<<<<<<
 *     except UnicodeDecodeError:
 *         # safe 'decode'
 */
      __Pyx_XDECREF(__pyx_r);
      __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_py_bytes, __pyx_n_s_decode); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 650; __pyx_clineno = __LINE__; goto __pyx_L4_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_6 = PyTuple_New(1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 650; __pyx_clineno = __LINE__; goto __pyx_L4_error;}
      __Pyx_GOTREF(__pyx_t_6);
      __Pyx_INCREF(__pyx_v_encoding);
      PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_v_encoding);
      __Pyx_GIVEREF(__pyx_v_encoding);
      __pyx_t_7 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_6, NULL); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 650; __pyx_clineno = __LINE__; goto __pyx_L4_error;}
      __Pyx_GOTREF(__pyx_t_7);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      __pyx_r = __pyx_t_7;
      __pyx_t_7 = 0;
      goto __pyx_L8_try_return;
    }
    __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_L11_try_end;
    __pyx_L4_error:;
    __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
    __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;

    /* "lupa/_lupa.pyx":651
 *     try:
 *         return py_bytes.decode(encoding)
 *     except UnicodeDecodeError:             # <<<<<<<<<<<<<<
 *         # safe 'decode'
 *         return py_bytes.decode('ISO-8859-1')
 */
    __pyx_t_8 = PyErr_ExceptionMatches(__pyx_builtin_UnicodeDecodeError);
    if (__pyx_t_8) {
      __Pyx_AddTraceback("lupa._lupa.lua_object_repr", __pyx_clineno, __pyx_lineno, __pyx_filename);
      if (__Pyx_GetException(&__pyx_t_7, &__pyx_t_6, &__pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 651; __pyx_clineno = __LINE__; goto __pyx_L6_except_error;}
      __Pyx_GOTREF(__pyx_t_7);
      __Pyx_GOTREF(__pyx_t_6);
      __Pyx_GOTREF(__pyx_t_2);

      /* "lupa/_lupa.pyx":653
 *     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 '%s'", "decode");
        {__pyx_filename = __pyx_f[0]; __pyx_lineno = 653; __pyx_clineno = __LINE__; goto __pyx_L6_except_error;}
      }
      __pyx_t_9 = __Pyx_decode_bytes(__pyx_v_py_bytes, 0, PY_SSIZE_T_MAX, NULL, NULL, PyUnicode_DecodeLatin1); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 653; __pyx_clineno = __LINE__; goto __pyx_L6_except_error;}
      __Pyx_GOTREF(__pyx_t_9);
      __pyx_r = __pyx_t_9;
      __pyx_t_9 = 0;
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      goto __pyx_L7_except_return;
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      goto __pyx_L5_exception_handled;
    }
    goto __pyx_L6_except_error;
    __pyx_L6_except_error:;
    __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;
    __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_L11_try_end:;
  }

  /* "lupa/_lupa.pyx":632
 *     obj._ref = lua.luaL_ref(L, lua.LUA_REGISTRYINDEX)
 * 
 * cdef object lua_object_repr(lua_State* L, 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_6);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_XDECREF(__pyx_t_9);
  __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":660
 * @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":661
 * 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_filename = __pyx_f[0]; __pyx_lineno = 661; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 661; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_INCREF(((PyObject *)__pyx_v_self));
  PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_v_self));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_self));
  PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __pyx_t_1 = 0;
  __pyx_t_1 = __Pyx_PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_4lupa_5_lupa__LuaIter)), __pyx_t_2, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 661; __pyx_clineno = __LINE__; goto __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":660
 * @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":663
 *         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 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":667
 *         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_filename = __pyx_f[0]; __pyx_lineno = 667; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 667; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_INCREF(((PyObject *)__pyx_v_self));
  PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_v_self));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_self));
  PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __pyx_t_1 = 0;
  __pyx_t_1 = __Pyx_PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_4lupa_5_lupa__LuaIter)), __pyx_t_2, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 667; __pyx_clineno = __LINE__; goto __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":663
 *         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":669
 *         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 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":673
 *         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_filename = __pyx_f[0]; __pyx_lineno = 673; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 673; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_INCREF(((PyObject *)__pyx_v_self));
  PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_v_self));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_self));
  PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __pyx_t_1 = 0;
  __pyx_t_1 = __Pyx_PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_4lupa_5_lupa__LuaIter)), __pyx_t_2, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 673; __pyx_clineno = __LINE__; goto __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":669
 *         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":675
 *         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 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":679
 *         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_filename = __pyx_f[0]; __pyx_lineno = 679; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 679; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_INCREF(((PyObject *)__pyx_v_self));
  PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_v_self));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_self));
  PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __pyx_t_1 = 0;
  __pyx_t_1 = __Pyx_PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_4lupa_5_lupa__LuaIter)), __pyx_t_2, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 679; __pyx_clineno = __LINE__; goto __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":675
 *         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":681
 *         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;
  int __pyx_t_3;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  char *__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("__setattr__", 0);
  __Pyx_INCREF(__pyx_v_name);

  /* "lupa/_lupa.pyx":682
 * 
 *     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_filename = __pyx_f[0]; __pyx_lineno = 682; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
  }
  #endif

  /* "lupa/_lupa.pyx":683
 *     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":684
 *         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 '%s'", "startswith");
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 684; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    __pyx_t_2 = __Pyx_PyUnicode_Tailmatch(((PyObject*)__pyx_v_name), __pyx_n_u__18, 0, PY_SSIZE_T_MAX, -1); if (unlikely(__pyx_t_2 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 684; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    if ((__pyx_t_2 != 0)) {
      if (unlikely(__pyx_v_name == Py_None)) {
        PyErr_Format(PyExc_AttributeError, "'NoneType' object has no attribute '%s'", "endswith");
        {__pyx_filename = __pyx_f[0]; __pyx_lineno = 684; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      }
      __pyx_t_1 = __Pyx_PyUnicode_Tailmatch(((PyObject*)__pyx_v_name), __pyx_n_u__18, 0, PY_SSIZE_T_MAX, 1); if (unlikely(__pyx_t_1 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 684; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_t_3 = (__pyx_t_1 != 0);
    } else {
      __pyx_t_3 = (__pyx_t_2 != 0);
    }
    if (__pyx_t_3) {

      /* "lupa/_lupa.pyx":685
 *         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_filename = __pyx_f[0]; __pyx_lineno = 685; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_t_5 = PyTuple_New(3); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 685; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_INCREF(((PyObject *)__pyx_v_self));
      PyTuple_SET_ITEM(__pyx_t_5, 0, ((PyObject *)__pyx_v_self));
      __Pyx_GIVEREF(((PyObject *)__pyx_v_self));
      __Pyx_INCREF(__pyx_v_name);
      PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_v_name);
      __Pyx_GIVEREF(__pyx_v_name);
      __Pyx_INCREF(__pyx_v_value);
      PyTuple_SET_ITEM(__pyx_t_5, 2, __pyx_v_value);
      __Pyx_GIVEREF(__pyx_v_value);
      __pyx_t_6 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_5, NULL); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 685; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_6);
      __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;

      /* "lupa/_lupa.pyx":686
 *             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":687
 *                 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 '%s'", "encode");
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 687; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    __pyx_t_7 = __Pyx_PyObject_AsString(__pyx_v_self->__pyx_base._runtime->_source_encoding); if (unlikely((!__pyx_t_7) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 687; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_6 = PyUnicode_AsEncodedString(((PyObject*)__pyx_v_name), __pyx_t_7, NULL); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 687; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_DECREF_SET(__pyx_v_name, __pyx_t_6);
    __pyx_t_6 = 0;
    goto __pyx_L3;
  }

  /* "lupa/_lupa.pyx":688
 *                 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_3 = PyBytes_Check(__pyx_v_name); 
  if (__pyx_t_3) {
    if (unlikely(__pyx_v_name == Py_None)) {
      PyErr_Format(PyExc_AttributeError, "'NoneType' object has no attribute '%s'", "startswith");
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 688; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    __pyx_t_2 = __Pyx_PyBytes_Tailmatch(((PyObject*)__pyx_v_name), __pyx_n_b__18, 0, PY_SSIZE_T_MAX, -1); if (unlikely(__pyx_t_2 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 688; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    if ((__pyx_t_2 != 0)) {
      if (unlikely(__pyx_v_name == Py_None)) {
        PyErr_Format(PyExc_AttributeError, "'NoneType' object has no attribute '%s'", "endswith");
        {__pyx_filename = __pyx_f[0]; __pyx_lineno = 688; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      }
      __pyx_t_1 = __Pyx_PyBytes_Tailmatch(((PyObject*)__pyx_v_name), __pyx_n_b__18, 0, PY_SSIZE_T_MAX, 1); if (unlikely(__pyx_t_1 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 688; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_t_8 = (__pyx_t_1 != 0);
    } else {
      __pyx_t_8 = (__pyx_t_2 != 0);
    }
    __pyx_t_2 = __pyx_t_8;
  } else {
    __pyx_t_2 = __pyx_t_3;
  }
  if (__pyx_t_2) {

    /* "lupa/_lupa.pyx":689
 *             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_6 = __Pyx_PyObject_GetAttrStr(__pyx_builtin_object, __pyx_n_s_setattr); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 689; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_t_5 = PyTuple_New(3); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 689; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_INCREF(((PyObject *)__pyx_v_self));
    PyTuple_SET_ITEM(__pyx_t_5, 0, ((PyObject *)__pyx_v_self));
    __Pyx_GIVEREF(((PyObject *)__pyx_v_self));
    __Pyx_INCREF(__pyx_v_name);
    PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_v_name);
    __Pyx_GIVEREF(__pyx_v_name);
    __Pyx_INCREF(__pyx_v_value);
    PyTuple_SET_ITEM(__pyx_t_5, 2, __pyx_v_value);
    __Pyx_GIVEREF(__pyx_v_value);
    __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_6, __pyx_t_5, NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 689; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

    /* "lupa/_lupa.pyx":690
 *         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;
  }
  __pyx_L3:;

  /* "lupa/_lupa.pyx":691
 *             object.__setattr__(self, name, value)
 *             return
 *         self._setitem(name, value)             # <<<<<<<<<<<<<<
 * 
 *     def __setitem__(self, index_or_name, value):
 */
  __pyx_t_9 = __pyx_f_4lupa_5_lupa_9_LuaTable__setitem(__pyx_v_self, __pyx_v_name, __pyx_v_value); if (unlikely(__pyx_t_9 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 691; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "lupa/_lupa.pyx":681
 *         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_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __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":693
 *         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":694
 * 
 *     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 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 694; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "lupa/_lupa.pyx":693
 *         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":697
 * 
 *     @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":698
 *     @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":699
 *     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 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 699; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "lupa/_lupa.pyx":700
 *         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":701
 *         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":702
 *         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 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 702; __pyx_clineno = __LINE__; goto __pyx_L4_error;}

    /* "lupa/_lupa.pyx":704
 *             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 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 704; __pyx_clineno = __LINE__; goto __pyx_L4_error;}
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

    /* "lupa/_lupa.pyx":705
 *             # 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 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 705; __pyx_clineno = __LINE__; goto __pyx_L4_error;}
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

    /* "lupa/_lupa.pyx":706
 *             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":708
 *             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":709
 *         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;
    }
    /*exception exit:*/{
      __pyx_L4_error:;
      __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":708
 *             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":709
 *         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":710
 *             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":697
 * 
 *     @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":712
 *         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;
  int __pyx_t_3;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  char *__pyx_t_7;
  int __pyx_t_8;
  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":713
 * 
 *     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_filename = __pyx_f[0]; __pyx_lineno = 713; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
  }
  #endif

  /* "lupa/_lupa.pyx":714
 *     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":715
 *         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 '%s'", "startswith");
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 715; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    __pyx_t_2 = __Pyx_PyUnicode_Tailmatch(((PyObject*)__pyx_v_item), __pyx_n_u__18, 0, PY_SSIZE_T_MAX, -1); if (unlikely(__pyx_t_2 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 715; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    if ((__pyx_t_2 != 0)) {
      if (unlikely(__pyx_v_item == Py_None)) {
        PyErr_Format(PyExc_AttributeError, "'NoneType' object has no attribute '%s'", "endswith");
        {__pyx_filename = __pyx_f[0]; __pyx_lineno = 715; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      }
      __pyx_t_1 = __Pyx_PyUnicode_Tailmatch(((PyObject*)__pyx_v_item), __pyx_n_u__18, 0, PY_SSIZE_T_MAX, 1); if (unlikely(__pyx_t_1 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 715; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_t_3 = (__pyx_t_1 != 0);
    } else {
      __pyx_t_3 = (__pyx_t_2 != 0);
    }
    if (__pyx_t_3) {

      /* "lupa/_lupa.pyx":716
 *         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_filename = __pyx_f[0]; __pyx_lineno = 716; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_t_5 = PyTuple_New(2); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 716; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_INCREF(((PyObject *)__pyx_v_self));
      PyTuple_SET_ITEM(__pyx_t_5, 0, ((PyObject *)__pyx_v_self));
      __Pyx_GIVEREF(((PyObject *)__pyx_v_self));
      __Pyx_INCREF(__pyx_v_item);
      PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_v_item);
      __Pyx_GIVEREF(__pyx_v_item);
      __pyx_t_6 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_5, NULL); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 716; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_6);
      __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;

      /* "lupa/_lupa.pyx":717
 *             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":718
 *                 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 '%s'", "encode");
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 718; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    __pyx_t_7 = __Pyx_PyObject_AsString(__pyx_v_self->__pyx_base._runtime->_source_encoding); if (unlikely((!__pyx_t_7) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 718; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_6 = PyUnicode_AsEncodedString(((PyObject*)__pyx_v_item), __pyx_t_7, NULL); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 718; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_DECREF_SET(__pyx_v_item, __pyx_t_6);
    __pyx_t_6 = 0;
    goto __pyx_L3;
  }

  /* "lupa/_lupa.pyx":719
 *                 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_3 = PyBytes_Check(__pyx_v_item); 
  if (__pyx_t_3) {
    if (unlikely(__pyx_v_item == Py_None)) {
      PyErr_Format(PyExc_AttributeError, "'NoneType' object has no attribute '%s'", "startswith");
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 719; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    __pyx_t_2 = __Pyx_PyBytes_Tailmatch(((PyObject*)__pyx_v_item), __pyx_n_b__18, 0, PY_SSIZE_T_MAX, -1); if (unlikely(__pyx_t_2 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 719; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    if ((__pyx_t_2 != 0)) {
      if (unlikely(__pyx_v_item == Py_None)) {
        PyErr_Format(PyExc_AttributeError, "'NoneType' object has no attribute '%s'", "endswith");
        {__pyx_filename = __pyx_f[0]; __pyx_lineno = 719; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      }
      __pyx_t_1 = __Pyx_PyBytes_Tailmatch(((PyObject*)__pyx_v_item), __pyx_n_b__18, 0, PY_SSIZE_T_MAX, 1); if (unlikely(__pyx_t_1 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 719; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_t_8 = (__pyx_t_1 != 0);
    } else {
      __pyx_t_8 = (__pyx_t_2 != 0);
    }
    __pyx_t_2 = __pyx_t_8;
  } else {
    __pyx_t_2 = __pyx_t_3;
  }
  if (__pyx_t_2) {

    /* "lupa/_lupa.pyx":720
 *             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_6 = __Pyx_PyObject_GetAttrStr(__pyx_builtin_object, __pyx_n_s_delattr); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 720; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_t_5 = PyTuple_New(2); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 720; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_INCREF(((PyObject *)__pyx_v_self));
    PyTuple_SET_ITEM(__pyx_t_5, 0, ((PyObject *)__pyx_v_self));
    __Pyx_GIVEREF(((PyObject *)__pyx_v_self));
    __Pyx_INCREF(__pyx_v_item);
    PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_v_item);
    __Pyx_GIVEREF(__pyx_v_item);
    __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_6, __pyx_t_5, NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 720; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

    /* "lupa/_lupa.pyx":721
 *         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;
  }
  __pyx_L3:;

  /* "lupa/_lupa.pyx":722
 *             object.__delattr__(self, item)
 *             return
 *         self._delitem(item)             # <<<<<<<<<<<<<<
 * 
 *     def __delitem__(self, key):
 */
  __pyx_t_4 = __pyx_f_4lupa_5_lupa_9_LuaTable__delitem(__pyx_v_self, __pyx_v_item); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 722; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

  /* "lupa/_lupa.pyx":712
 *         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_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __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":724
 *         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":725
 * 
 *     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_filename = __pyx_f[0]; __pyx_lineno = 725; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "lupa/_lupa.pyx":724
 *         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":728
 * 
 *     @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":729
 *     @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":730
 *     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 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 730; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "lupa/_lupa.pyx":731
 *         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":732
 *         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":733
 *         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 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 733; __pyx_clineno = __LINE__; goto __pyx_L4_error;}

    /* "lupa/_lupa.pyx":734
 *         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 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 734; __pyx_clineno = __LINE__; goto __pyx_L4_error;}
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

    /* "lupa/_lupa.pyx":735
 *             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":736
 *             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":738
 *             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":739
 *         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;
    }
    /*exception exit:*/{
      __pyx_L4_error:;
      __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":738
 *             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":739
 *         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":728
 * 
 *     @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;
}

/* "lupa/_lupa.pyx":742
 * 
 * 
 * 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":743
 * 
 * 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 = __pyx_tp_new_4lupa_5_lupa__LuaTable(((PyTypeObject *)((PyObject*)__pyx_ptype_4lupa_5_lupa__LuaTable)), __pyx_empty_tuple, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 743; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  if (!(likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_4lupa_5_lupa__LuaTable)))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 743; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_v_obj = ((struct __pyx_obj_4lupa_5_lupa__LuaTable *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "lupa/_lupa.pyx":744
 * 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":745
 *     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":742
 * 
 * 
 * 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":753
 *     """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 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":757
 *         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_filename = __pyx_f[0]; __pyx_lineno = 757; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
  }
  #endif

  /* "lupa/_lupa.pyx":758
 *         """
 *         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":761
 *         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 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 761; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

  /* "lupa/_lupa.pyx":762
 *         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":763
 *         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":764
 *         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 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 764; __pyx_clineno = __LINE__; goto __pyx_L4_error;}

    /* "lupa/_lupa.pyx":765
 *         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_1 = (!(lua_isfunction(__pyx_v_L, -1) != 0));
    if (!__pyx_t_1) {
      __pyx_t_5 = (lua_iscfunction(__pyx_v_L, -1) != 0);
    } else {
      __pyx_t_5 = __pyx_t_1;
    }
    if (__pyx_t_5) {

      /* "lupa/_lupa.pyx":766
 *             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__20, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 766; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 766; __pyx_clineno = __LINE__; goto __pyx_L4_error;}
    }

    /* "lupa/_lupa.pyx":768
 *                 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":769
 *             # 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":770
 *             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":772
 *             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_filename = __pyx_f[0]; __pyx_lineno = 772; __pyx_clineno = __LINE__; goto __pyx_L4_error;}
      }
    }
    #endif

    /* "lupa/_lupa.pyx":773
 *             # 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_filename = __pyx_f[0]; __pyx_lineno = 773; __pyx_clineno = __LINE__; goto __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":774
 *             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":775
 *             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":777
 *             return thread
 *         finally:
 *             lua.lua_settop(L, old_top)             # <<<<<<<<<<<<<<
 *             unlock_runtime(self._runtime)
 * 
 */
  /*finally:*/ {
    /*exception exit:*/{
      __pyx_L4_error:;
      __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":778
 *         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":777
 *             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":778
 *         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":753
 *     """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;
}

/* "lupa/_lupa.pyx":780
 *             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":781
 * 
 * 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 = __pyx_tp_new_4lupa_5_lupa__LuaFunction(((PyTypeObject *)((PyObject*)__pyx_ptype_4lupa_5_lupa__LuaFunction)), __pyx_empty_tuple, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 781; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  if (!(likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_4lupa_5_lupa__LuaFunction)))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 781; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_v_obj = ((struct __pyx_obj_4lupa_5_lupa__LuaFunction *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "lupa/_lupa.pyx":782
 * 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":783
 *     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":780
 *             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":792
 *     """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;
  PyObject *__pyx_t_3 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__call__", 0);

  /* "lupa/_lupa.pyx":793
 *     """
 *     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_filename = __pyx_f[0]; __pyx_lineno = 793; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PySequence_Tuple(__pyx_v_args); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 793; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_2, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 793; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_r = __pyx_t_3;
  __pyx_t_3 = 0;
  goto __pyx_L0;

  /* "lupa/_lupa.pyx":792
 *     """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_XDECREF(__pyx_t_3);
  __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;
}

/* "lupa/_lupa.pyx":795
 *         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":796
 * 
 * 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 = __pyx_tp_new_4lupa_5_lupa__LuaCoroutineFunction(((PyTypeObject *)((PyObject*)__pyx_ptype_4lupa_5_lupa__LuaCoroutineFunction)), __pyx_empty_tuple, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 796; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  if (!(likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_4lupa_5_lupa__LuaCoroutineFunction)))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 796; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_v_obj = ((struct __pyx_obj_4lupa_5_lupa__LuaCoroutineFunction *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "lupa/_lupa.pyx":797
 * 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":798
 *     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":795
 *         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":809
 *     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":810
 *     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":809
 *     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":812
 *         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":813
 * 
 *     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_filename = __pyx_f[0]; __pyx_lineno = 813; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
  }
  #endif

  /* "lupa/_lupa.pyx":814
 *     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":815
 *         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":816
 *         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);
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "lupa/_lupa.pyx":817
 *         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_filename = __pyx_f[0]; __pyx_lineno = 817; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_r = __pyx_t_2;
  __pyx_t_2 = 0;
  goto __pyx_L0;

  /* "lupa/_lupa.pyx":812
 *         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":819
 *         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 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":823
 *         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":824
 *         """
 *         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 (__pyx_t_1) {

      /* "lupa/_lupa.pyx":825
 *         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__21, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 825; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 825; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }

    /* "lupa/_lupa.pyx":826
 *             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":827
 *                 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_filename = __pyx_f[0]; __pyx_lineno = 827; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_INCREF(__pyx_v_value);
      PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_v_value);
      __Pyx_GIVEREF(__pyx_v_value);
      __Pyx_DECREF_SET(__pyx_v_value, __pyx_t_3);
      __pyx_t_3 = 0;
      goto __pyx_L5;
    }
    __pyx_L5:;
    goto __pyx_L3;
  }

  /* "lupa/_lupa.pyx":828
 *             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":829
 *                 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":830
 *         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);
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "lupa/_lupa.pyx":831
 *             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_filename = __pyx_f[0]; __pyx_lineno = 831; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_r = __pyx_t_3;
  __pyx_t_3 = 0;
  goto __pyx_L0;

  /* "lupa/_lupa.pyx":819
 *         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":833
 *         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":835
 *     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_filename = __pyx_f[0]; __pyx_lineno = 835; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
  }
  #endif

  /* "lupa/_lupa.pyx":836
 *         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":837
 *         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":838
 *         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":839
 *         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":841
 *         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":842
 *             # 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":843
 *             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":844
 *                 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;
    }
    goto __pyx_L4;
  }
  __pyx_L4:;

  /* "lupa/_lupa.pyx":845
 *             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":833
 *         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;
}

/* "lupa/_lupa.pyx":847
 *         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":848
 * 
 * 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 = __pyx_tp_new_4lupa_5_lupa__LuaThread(((PyTypeObject *)((PyObject*)__pyx_ptype_4lupa_5_lupa__LuaThread)), __pyx_empty_tuple, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 848; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  if (!(likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_4lupa_5_lupa__LuaThread)))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 848; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_v_obj = ((struct __pyx_obj_4lupa_5_lupa__LuaThread *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "lupa/_lupa.pyx":849
 * 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":850
 *     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":851
 *     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":847
 *         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":854
 * 
 * 
 * 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;
  int __pyx_t_3;
  PyObject *__pyx_t_4 = NULL;
  int __pyx_t_5;
  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;
  struct __pyx_obj_4lupa_5_lupa__LuaObject *__pyx_t_14 = 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":858
 *     # 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":859
 *     # 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_filename = __pyx_f[0]; __pyx_lineno = 859; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
  }
  #endif

  /* "lupa/_lupa.pyx":860
 *     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_1 = ((lua_status(__pyx_v_co) == 0) != 0);
  if (__pyx_t_1) {
    __pyx_t_2 = ((lua_gettop(__pyx_v_co) == 1) != 0);
    __pyx_t_3 = __pyx_t_2;
  } else {
    __pyx_t_3 = __pyx_t_1;
  }
  if (__pyx_t_3) {

    /* "lupa/_lupa.pyx":862
 *     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":863
 *         # 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":864
 *         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":865
 *         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_4 = ((PyObject *)__pyx_f_4lupa_5_lupa_new_lua_coroutine_function(__pyx_v_runtime, __pyx_v_L, -1)); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 865; __pyx_clineno = __LINE__; goto __pyx_L5_error;}
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_r = ((struct __pyx_obj_4lupa_5_lupa__LuaObject *)__pyx_t_4);
      __pyx_t_4 = 0;
      goto __pyx_L4_return;
    }

    /* "lupa/_lupa.pyx":867
 *             return new_lua_coroutine_function(runtime, L, -1)
 *         finally:
 *             lua.lua_pop(L, 1)             # <<<<<<<<<<<<<<
 *     else:
 *         # already started => wrap the thread
 */
    /*finally:*/ {
      /*exception exit:*/{
        __pyx_L5_error:;
        __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_4); __pyx_t_4 = 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_5 = __pyx_lineno; __pyx_t_6 = __pyx_clineno; __pyx_t_7 = __pyx_filename;
        {
          lua_pop(__pyx_v_L, 1);
        }
        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_5; __pyx_clineno = __pyx_t_6; __pyx_filename = __pyx_t_7;
        goto __pyx_L1_error;
      }
      __pyx_L4_return: {
        __pyx_t_14 = __pyx_r;
        __pyx_r = 0;
        lua_pop(__pyx_v_L, 1);
        __pyx_r = __pyx_t_14;
        __pyx_t_14 = 0;
        goto __pyx_L0;
      }
    }
  }
  /*else*/ {

    /* "lupa/_lupa.pyx":870
 *     else:
 *         # already started => wrap the thread
 *         return new_lua_thread(runtime, L, n)             # <<<<<<<<<<<<<<
 * 
 * 
 */
    __Pyx_XDECREF(((PyObject *)__pyx_r));
    __pyx_t_4 = ((PyObject *)__pyx_f_4lupa_5_lupa_new_lua_thread(__pyx_v_runtime, __pyx_v_L, __pyx_v_n)); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 870; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_r = ((struct __pyx_obj_4lupa_5_lupa__LuaObject *)__pyx_t_4);
    __pyx_t_4 = 0;
    goto __pyx_L0;
  }

  /* "lupa/_lupa.pyx":854
 * 
 * 
 * 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_4);
  __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":873
 * 
 * 
 * cdef object resume_lua_thread(_LuaThread thread, tuple args):             # <<<<<<<<<<<<<<
 *     cdef lua_State* co = thread._co_state
 *     cdef int result, i, nargs = 0
 */

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;
  int __pyx_v_result;
  int __pyx_v_nargs;
  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;
  int __pyx_t_6;
  Py_ssize_t __pyx_t_7;
  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("resume_lua_thread", 0);

  /* "lupa/_lupa.pyx":874
 * 
 * cdef object resume_lua_thread(_LuaThread thread, tuple args):
 *     cdef lua_State* co = thread._co_state             # <<<<<<<<<<<<<<
 *     cdef int result, i, nargs = 0
 *     lock_runtime(thread._runtime)
 */
  __pyx_t_1 = __pyx_v_thread->_co_state;
  __pyx_v_co = __pyx_t_1;

  /* "lupa/_lupa.pyx":875
 * cdef object resume_lua_thread(_LuaThread thread, tuple args):
 *     cdef lua_State* co = thread._co_state
 *     cdef int result, i, nargs = 0             # <<<<<<<<<<<<<<
 *     lock_runtime(thread._runtime)
 *     try:
 */
  __pyx_v_nargs = 0;

  /* "lupa/_lupa.pyx":876
 *     cdef lua_State* co = thread._co_state
 *     cdef int result, i, nargs = 0
 *     lock_runtime(thread._runtime)             # <<<<<<<<<<<<<<
 *     try:
 *         if lua.lua_status(co) == 0 and lua.lua_gettop(co) == 0:
 */
  __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 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 876; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "lupa/_lupa.pyx":877
 *     cdef int result, i, nargs = 0
 *     lock_runtime(thread._runtime)
 *     try:             # <<<<<<<<<<<<<<
 *         if lua.lua_status(co) == 0 and lua.lua_gettop(co) == 0:
 *             # already terminated
 */
  /*try:*/ {

    /* "lupa/_lupa.pyx":878
 *     lock_runtime(thread._runtime)
 *     try:
 *         if lua.lua_status(co) == 0 and lua.lua_gettop(co) == 0:             # <<<<<<<<<<<<<<
 *             # already terminated
 *             raise StopIteration
 */
    __pyx_t_4 = ((lua_status(__pyx_v_co) == 0) != 0);
    if (__pyx_t_4) {
      __pyx_t_5 = ((lua_gettop(__pyx_v_co) == 0) != 0);
      __pyx_t_6 = __pyx_t_5;
    } else {
      __pyx_t_6 = __pyx_t_4;
    }
    if (__pyx_t_6) {

      /* "lupa/_lupa.pyx":880
 *         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_filename = __pyx_f[0]; __pyx_lineno = 880; __pyx_clineno = __LINE__; goto __pyx_L4_error;}
    }

    /* "lupa/_lupa.pyx":881
 *             # already terminated
 *             raise StopIteration
 *         if args:             # <<<<<<<<<<<<<<
 *             nargs = len(args)
 *             push_lua_arguments(thread._runtime, co, args)
 */
    __pyx_t_6 = (__pyx_v_args != Py_None) && (PyTuple_GET_SIZE(__pyx_v_args) != 0);
    if (__pyx_t_6) {

      /* "lupa/_lupa.pyx":882
 *             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_filename = __pyx_f[0]; __pyx_lineno = 882; __pyx_clineno = __LINE__; goto __pyx_L4_error;}
      }
      __pyx_t_7 = PyTuple_GET_SIZE(__pyx_v_args); if (unlikely(__pyx_t_7 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 882; __pyx_clineno = __LINE__; goto __pyx_L4_error;}
      __pyx_v_nargs = __pyx_t_7;

      /* "lupa/_lupa.pyx":883
 *         if args:
 *             nargs = len(args)
 *             push_lua_arguments(thread._runtime, co, args)             # <<<<<<<<<<<<<<
 *         with nogil:
 *             result = lua.lua_resume(co, nargs)
 */
      __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 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 883; __pyx_clineno = __LINE__; goto __pyx_L4_error;}
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      goto __pyx_L7;
    }
    __pyx_L7:;

    /* "lupa/_lupa.pyx":884
 *             nargs = len(args)
 *             push_lua_arguments(thread._runtime, co, args)
 *         with nogil:             # <<<<<<<<<<<<<<
 *             result = lua.lua_resume(co, nargs)
 *         if result != lua.LUA_YIELD:
 */
    {
        #ifdef WITH_THREAD
        PyThreadState *_save;
        Py_UNBLOCK_THREADS
        #endif
        /*try:*/ {

          /* "lupa/_lupa.pyx":885
 *             push_lua_arguments(thread._runtime, co, args)
 *         with nogil:
 *             result = lua.lua_resume(co, nargs)             # <<<<<<<<<<<<<<
 *         if result != lua.LUA_YIELD:
 *             if result == 0:
 */
          __pyx_v_result = __lupa_lua_resume(__pyx_v_co, __pyx_v_nargs);
        }

        /* "lupa/_lupa.pyx":884
 *             nargs = len(args)
 *             push_lua_arguments(thread._runtime, co, args)
 *         with nogil:             # <<<<<<<<<<<<<<
 *             result = lua.lua_resume(co, nargs)
 *         if result != lua.LUA_YIELD:
 */
        /*finally:*/ {
          /*normal exit:*/{
            #ifdef WITH_THREAD
            Py_BLOCK_THREADS
            #endif
            goto __pyx_L10;
          }
          __pyx_L10:;
        }
    }

    /* "lupa/_lupa.pyx":886
 *         with nogil:
 *             result = lua.lua_resume(co, nargs)
 *         if result != lua.LUA_YIELD:             # <<<<<<<<<<<<<<
 *             if result == 0:
 *                 # terminated
 */
    __pyx_t_6 = ((__pyx_v_result != LUA_YIELD) != 0);
    if (__pyx_t_6) {

      /* "lupa/_lupa.pyx":887
 *             result = lua.lua_resume(co, nargs)
 *         if result != lua.LUA_YIELD:
 *             if result == 0:             # <<<<<<<<<<<<<<
 *                 # terminated
 *                 if lua.lua_gettop(co) == 0:
 */
      __pyx_t_6 = ((__pyx_v_result == 0) != 0);
      if (__pyx_t_6) {

        /* "lupa/_lupa.pyx":889
 *             if result == 0:
 *                 # terminated
 *                 if lua.lua_gettop(co) == 0:             # <<<<<<<<<<<<<<
 *                     # no values left to return
 *                     raise StopIteration
 */
        __pyx_t_6 = ((lua_gettop(__pyx_v_co) == 0) != 0);
        if (__pyx_t_6) {

          /* "lupa/_lupa.pyx":891
 *                 if lua.lua_gettop(co) == 0:
 *                     # no values left to return
 *                     raise StopIteration             # <<<<<<<<<<<<<<
 *             else:
 *                 raise_lua_error(thread._runtime, co, result)
 */
          __Pyx_Raise(__pyx_builtin_StopIteration, 0, 0, 0);
          {__pyx_filename = __pyx_f[0]; __pyx_lineno = 891; __pyx_clineno = __LINE__; goto __pyx_L4_error;}
        }
        goto __pyx_L12;
      }
      /*else*/ {

        /* "lupa/_lupa.pyx":893
 *                     raise StopIteration
 *             else:
 *                 raise_lua_error(thread._runtime, co, result)             # <<<<<<<<<<<<<<
 *         return unpack_lua_results(thread._runtime, co)
 *     finally:
 */
        __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_result); if (unlikely(__pyx_t_3 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 893; __pyx_clineno = __LINE__; goto __pyx_L4_error;}
        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      }
      __pyx_L12:;
      goto __pyx_L11;
    }
    __pyx_L11:;

    /* "lupa/_lupa.pyx":894
 *             else:
 *                 raise_lua_error(thread._runtime, co, result)
 *         return unpack_lua_results(thread._runtime, co)             # <<<<<<<<<<<<<<
 *     finally:
 *         lua.lua_settop(co, 0)  # FIXME?
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_2 = ((PyObject *)__pyx_v_thread->__pyx_base._runtime);
    __Pyx_INCREF(__pyx_t_2);
    __pyx_t_8 = __pyx_f_4lupa_5_lupa_unpack_lua_results(((struct __pyx_obj_4lupa_5_lupa_LuaRuntime *)__pyx_t_2), __pyx_v_co); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 894; __pyx_clineno = __LINE__; goto __pyx_L4_error;}
    __Pyx_GOTREF(__pyx_t_8);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_r = __pyx_t_8;
    __pyx_t_8 = 0;
    goto __pyx_L3_return;
  }

  /* "lupa/_lupa.pyx":896
 *         return unpack_lua_results(thread._runtime, co)
 *     finally:
 *         lua.lua_settop(co, 0)  # FIXME?             # <<<<<<<<<<<<<<
 *         unlock_runtime(thread._runtime)
 * 
 */
  /*finally:*/ {
    /*exception exit:*/{
      __pyx_L4_error:;
      __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_2); __pyx_t_2 = 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_3 = __pyx_lineno; __pyx_t_9 = __pyx_clineno; __pyx_t_10 = __pyx_filename;
      {
        lua_settop(__pyx_v_co, 0);

        /* "lupa/_lupa.pyx":897
 *     finally:
 *         lua.lua_settop(co, 0)  # FIXME?
 *         unlock_runtime(thread._runtime)             # <<<<<<<<<<<<<<
 * 
 * 
 */
        __pyx_t_8 = ((PyObject *)__pyx_v_thread->__pyx_base._runtime);
        __Pyx_INCREF(__pyx_t_8);
        __pyx_f_4lupa_5_lupa_unlock_runtime(((struct __pyx_obj_4lupa_5_lupa_LuaRuntime *)__pyx_t_8));
        __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      }
      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_3; __pyx_clineno = __pyx_t_9; __pyx_filename = __pyx_t_10;
      goto __pyx_L1_error;
    }
    __pyx_L3_return: {
      __pyx_t_16 = __pyx_r;
      __pyx_r = 0;

      /* "lupa/_lupa.pyx":896
 *         return unpack_lua_results(thread._runtime, co)
 *     finally:
 *         lua.lua_settop(co, 0)  # FIXME?             # <<<<<<<<<<<<<<
 *         unlock_runtime(thread._runtime)
 * 
 */
      lua_settop(__pyx_v_co, 0);

      /* "lupa/_lupa.pyx":897
 *     finally:
 *         lua.lua_settop(co, 0)  # FIXME?
 *         unlock_runtime(thread._runtime)             # <<<<<<<<<<<<<<
 * 
 * 
 */
      __pyx_t_8 = ((PyObject *)__pyx_v_thread->__pyx_base._runtime);
      __Pyx_INCREF(__pyx_t_8);
      __pyx_f_4lupa_5_lupa_unlock_runtime(((struct __pyx_obj_4lupa_5_lupa_LuaRuntime *)__pyx_t_8));
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      __pyx_r = __pyx_t_16;
      __pyx_t_16 = 0;
      goto __pyx_L0;
    }
  }

  /* "lupa/_lupa.pyx":873
 * 
 * 
 * cdef object resume_lua_thread(_LuaThread thread, tuple args):             # <<<<<<<<<<<<<<
 *     cdef lua_State* co = thread._co_state
 *     cdef int result, i, nargs = 0
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_8);
  __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":916
 *     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);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_obj)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        case  1:
        if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_what)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("__cinit__", 1, 2, 2, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 916; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__cinit__") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 916; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 916; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 916; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 916; __pyx_clineno = __LINE__; goto __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":917
 * 
 *     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":918
 *     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_filename = __pyx_f[0]; __pyx_lineno = 918; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
  }
  #endif

  /* "lupa/_lupa.pyx":919
 *         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":920
 *         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":921
 *         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":922
 *         self._obj = obj
 *         self._state = obj._state
 *         self._refiter = 0             # <<<<<<<<<<<<<<
 *         self._what = what
 * 
 */
  __pyx_v_self->_refiter = 0;

  /* "lupa/_lupa.pyx":923
 *         self._state = obj._state
 *         self._refiter = 0
 *         self._what = what             # <<<<<<<<<<<<<<
 * 
 *     def __dealloc__(self):
 */
  __pyx_v_self->_what = __pyx_v_what;

  /* "lupa/_lupa.pyx":916
 *     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":925
 *         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;
  CYTHON_UNUSED int __pyx_lineno = 0;
  CYTHON_UNUSED const char *__pyx_filename = NULL;
  CYTHON_UNUSED int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__dealloc__", 0);

  /* "lupa/_lupa.pyx":926
 * 
 *     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":927
 *     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":928
 *         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":929
 *             return
 *         cdef lua_State* L = self._state
 *         if L is not NULL and self._refiter:             # <<<<<<<<<<<<<<
 *             locked = False
 *             try:
 */
  __pyx_t_2 = (__pyx_v_L != NULL);
  if (__pyx_t_2) {
    __pyx_t_1 = (__pyx_v_self->_refiter != 0);
  } else {
    __pyx_t_1 = __pyx_t_2;
  }
  if (__pyx_t_1) {

    /* "lupa/_lupa.pyx":930
 *         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":931
 *         if L is not NULL and self._refiter:
 *             locked = False
 *             try:             # <<<<<<<<<<<<<<
 *                 lock_runtime(self._runtime)
 *                 locked = True
 */
    {
      __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":932
 *             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 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 932; __pyx_clineno = __LINE__; goto __pyx_L5_error;}
        __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;

        /* "lupa/_lupa.pyx":933
 *             try:
 *                 lock_runtime(self._runtime)
 *                 locked = True             # <<<<<<<<<<<<<<
 *             except:
 *                 pass
 */
        __pyx_v_locked = 1;
      }
      __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_L5_error:;
      __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;

      /* "lupa/_lupa.pyx":934
 *                 lock_runtime(self._runtime)
 *                 locked = True
 *             except:             # <<<<<<<<<<<<<<
 *                 pass
 *             lua.luaL_unref(L, lua.LUA_REGISTRYINDEX, self._refiter)
 */
      /*except:*/ {
        PyErr_Restore(0,0,0);
        goto __pyx_L6_exception_handled;
      }
      __pyx_L6_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":936
 *             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":937
 *                 pass
 *             lua.luaL_unref(L, lua.LUA_REGISTRYINDEX, self._refiter)
 *             if locked:             # <<<<<<<<<<<<<<
 *                 unlock_runtime(self._runtime)
 * 
 */
    __pyx_t_1 = (__pyx_v_locked != 0);
    if (__pyx_t_1) {

      /* "lupa/_lupa.pyx":938
 *             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;
      goto __pyx_L13;
    }
    __pyx_L13:;
    goto __pyx_L4;
  }
  __pyx_L4:;

  /* "lupa/_lupa.pyx":925
 *         self._what = what
 * 
 *     def __dealloc__(self):             # <<<<<<<<<<<<<<
 *         if self._runtime is None:
 *             return
 */

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

/* "lupa/_lupa.pyx":940
 *                 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":941
 * 
 *     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_filename = __pyx_f[0]; __pyx_lineno = 941; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "lupa/_lupa.pyx":940
 *                 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":943
 *         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":944
 * 
 *     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":943
 *         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":946
 *         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":947
 * 
 *     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 (__pyx_t_2) {

    /* "lupa/_lupa.pyx":948
 *     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_filename = __pyx_f[0]; __pyx_lineno = 948; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }

  /* "lupa/_lupa.pyx":949
 *         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":950
 *             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 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 950; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

  /* "lupa/_lupa.pyx":951
 *         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":952
 *         lock_runtime(self._runtime)
 *         old_top = lua.lua_gettop(L)
 *         try:             # <<<<<<<<<<<<<<
 *             if self._obj is None:
 *                 raise StopIteration
 */
  /*try:*/ {

    /* "lupa/_lupa.pyx":953
 *         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 (__pyx_t_1) {

      /* "lupa/_lupa.pyx":954
 *         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_filename = __pyx_f[0]; __pyx_lineno = 954; __pyx_clineno = __LINE__; goto __pyx_L5_error;}
    }

    /* "lupa/_lupa.pyx":956
 *                 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":957
 *             # 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":958
 *             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 (__pyx_t_1) {

        /* "lupa/_lupa.pyx":959
 *             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":960
 *                 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_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_LuaError); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 960; __pyx_clineno = __LINE__; goto __pyx_L5_error;}
        __Pyx_GOTREF(__pyx_t_4);
        __pyx_t_6 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_tuple__22, NULL); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 960; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 960; __pyx_clineno = __LINE__; goto __pyx_L5_error;}
      }

      /* "lupa/_lupa.pyx":961
 *                     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_6 = __Pyx_PyString_Format(__pyx_kp_s_cannot_iterate_over_non_table_fo, ((PyObject *)__pyx_v_self->_obj)); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 961; __pyx_clineno = __LINE__; goto __pyx_L5_error;}
      __Pyx_GOTREF(__pyx_t_6);
      __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 961; __pyx_clineno = __LINE__; goto __pyx_L5_error;}
      __Pyx_GOTREF(__pyx_t_4);
      PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_6);
      __Pyx_GIVEREF(__pyx_t_6);
      __pyx_t_6 = 0;
      __pyx_t_6 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_t_4, NULL); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 961; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 961; __pyx_clineno = __LINE__; goto __pyx_L5_error;}
    }

    /* "lupa/_lupa.pyx":962
 *                     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":964
 *             if not self._refiter:
 *                 # initial key
 *                 lua.lua_pushnil(L)             # <<<<<<<<<<<<<<
 *             else:
 *                 # last key
 */
      lua_pushnil(__pyx_v_L);
      goto __pyx_L10;
    }
    /*else*/ {

      /* "lupa/_lupa.pyx":967
 *             else:
 *                 # last key
 *                 lua.lua_rawgeti(L, lua.LUA_REGISTRYINDEX, self._refiter)             # <<<<<<<<<<<<<<
 *             if lua.lua_next(L, -2):
 *                 try:
 */
      lua_rawgeti(__pyx_v_L, LUA_REGISTRYINDEX, __pyx_v_self->_refiter);
    }
    __pyx_L10:;

    /* "lupa/_lupa.pyx":968
 *                 # 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":969
 *                 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":972
 *                     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
 */
        switch (__pyx_v_self->_what) {

          /* "lupa/_lupa.pyx":970
 *             if lua.lua_next(L, -2):
 *                 try:
 *                     if self._what == KEYS:             # <<<<<<<<<<<<<<
 *                         retval = py_from_lua(self._runtime, L, -2)
 *                     elif self._what == VALUES:
 */
          case __pyx_e_4lupa_5_lupa_KEYS:

          /* "lupa/_lupa.pyx":971
 *                 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_filename = __pyx_f[0]; __pyx_lineno = 971; __pyx_clineno = __LINE__; goto __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;
          break;

          /* "lupa/_lupa.pyx":972
 *                     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
 */
          case __pyx_e_4lupa_5_lupa_VALUES:

          /* "lupa/_lupa.pyx":973
 *                         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_filename = __pyx_f[0]; __pyx_lineno = 973; __pyx_clineno = __LINE__; goto __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;
          break;
          default:

          /* "lupa/_lupa.pyx":975
 *                         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_filename = __pyx_f[0]; __pyx_lineno = 975; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 975; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 975; __pyx_clineno = __LINE__; goto __pyx_L13_error;}
          __Pyx_GOTREF(__pyx_t_6);
          PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_4);
          __Pyx_GIVEREF(__pyx_t_4);
          PyTuple_SET_ITEM(__pyx_t_6, 1, __pyx_t_7);
          __Pyx_GIVEREF(__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":978
 *                 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":980
 *                     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":981
 *                     # 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);
            goto __pyx_L15;
          }
          /*else*/ {

            /* "lupa/_lupa.pyx":983
 *                         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
 */
            lua_rawseti(__pyx_v_L, LUA_REGISTRYINDEX, __pyx_v_self->_refiter);
          }
          __pyx_L15:;
          goto __pyx_L14;
        }
        /*exception exit:*/{
          __pyx_L13_error:;
          __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_7); __pyx_t_7 = 0;
          __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 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":978
 *                 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":980
 *                     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":981
 *                     # 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);
              goto __pyx_L18;
            }
            /*else*/ {

              /* "lupa/_lupa.pyx":983
 *                         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
 */
              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":984
 *                     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":986
 *                 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":987
 *             # 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":988
 *             if self._refiter:
 *                 lua.luaL_unref(L, lua.LUA_REGISTRYINDEX, self._refiter)
 *                 self._refiter = 0             # <<<<<<<<<<<<<<
 *             self._obj = None
 *         finally:
 */
      __pyx_v_self->_refiter = 0;
      goto __pyx_L19;
    }
    __pyx_L19:;

    /* "lupa/_lupa.pyx":989
 *                 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":991
 *             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":992
 *         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;
    }
    /*exception exit:*/{
      __pyx_L5_error:;
      __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_7); __pyx_t_7 = 0;
      __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 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":991
 *             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":992
 *         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":991
 *             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":992
 *         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":993
 *             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_filename = __pyx_f[0]; __pyx_lineno = 993; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "lupa/_lupa.pyx":946
 *         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;
}

/* "lupa/_lupa.pyx":997
 * # 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;
  int __pyx_t_3;
  int __pyx_t_4;

  /* "lupa/_lupa.pyx":998
 * 
 * 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_1 = ((lua_gettop(__pyx_v_L) == 1) != 0);
  if (__pyx_t_1) {

    /* "lupa/_lupa.pyx":999
 * 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) {
      __pyx_t_3 = ((lua_topointer(__pyx_v_L, 1) == ((void *)__pyx_f_4lupa_5_lupa_unpack_wrapped_pyfunction)) != 0);
      __pyx_t_4 = __pyx_t_3;
    } else {
      __pyx_t_4 = __pyx_t_2;
    }
    __pyx_t_2 = __pyx_t_4;
  } else {
    __pyx_t_2 = __pyx_t_1;
  }
  if (__pyx_t_2) {

    /* "lupa/_lupa.pyx":1001
 *             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":1002
 *         # 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":1003
 *         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":1004
 *         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":1005
 *     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":997
 * # 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":1007
 *     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":1008
 * 
 * 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":1009
 * 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":1010
 *     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":1011
 *     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":1012
 *         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":1013
 *         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;
    }
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "lupa/_lupa.pyx":1014
 *         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":1007
 *     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":1023
 *     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":1024
 *     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":1023
 *     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":1025
 *     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":1026
 *         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__23, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1026; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 1026; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "lupa/_lupa.pyx":1025
 *     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;
}

/* "lupa/_lupa.pyx":1029
 * 
 * 
 * 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 = {__Pyx_NAMESTR("as_attrgetter"), (PyCFunction)__pyx_pw_4lupa_5_lupa_7as_attrgetter, METH_O, __Pyx_DOCSTR(__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":1030
 * 
 * def as_attrgetter(obj):
 *     cdef _PyProtocolWrapper wrap = _PyProtocolWrapper.__new__(_PyProtocolWrapper)             # <<<<<<<<<<<<<<
 *     wrap._obj = obj
 *     wrap._type_flags = 0
 */
  __pyx_t_1 = __pyx_tp_new_4lupa_5_lupa__PyProtocolWrapper(((PyTypeObject *)((PyObject*)__pyx_ptype_4lupa_5_lupa__PyProtocolWrapper)), __pyx_empty_tuple, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1030; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  if (!(likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_4lupa_5_lupa__PyProtocolWrapper)))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1030; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_v_wrap = ((struct __pyx_obj_4lupa_5_lupa__PyProtocolWrapper *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "lupa/_lupa.pyx":1031
 * 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":1032
 *     cdef _PyProtocolWrapper wrap = _PyProtocolWrapper.__new__(_PyProtocolWrapper)
 *     wrap._obj = obj
 *     wrap._type_flags = 0             # <<<<<<<<<<<<<<
 *     return wrap
 * 
 */
  __pyx_v_wrap->_type_flags = 0;

  /* "lupa/_lupa.pyx":1033
 *     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":1029
 * 
 * 
 * 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":1035
 *     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 = {__Pyx_NAMESTR("as_itemgetter"), (PyCFunction)__pyx_pw_4lupa_5_lupa_9as_itemgetter, METH_O, __Pyx_DOCSTR(__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":1036
 * 
 * def as_itemgetter(obj):
 *     cdef _PyProtocolWrapper wrap = _PyProtocolWrapper.__new__(_PyProtocolWrapper)             # <<<<<<<<<<<<<<
 *     wrap._obj = obj
 *     wrap._type_flags = OBJ_AS_INDEX
 */
  __pyx_t_1 = __pyx_tp_new_4lupa_5_lupa__PyProtocolWrapper(((PyTypeObject *)((PyObject*)__pyx_ptype_4lupa_5_lupa__PyProtocolWrapper)), __pyx_empty_tuple, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1036; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  if (!(likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_4lupa_5_lupa__PyProtocolWrapper)))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1036; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_v_wrap = ((struct __pyx_obj_4lupa_5_lupa__PyProtocolWrapper *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "lupa/_lupa.pyx":1037
 * 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":1038
 *     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":1039
 *     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":1035
 *     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":1041
 *     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;
  const char* __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 *__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":1046
 *     or unwrapping it.
 *     """
 *     cdef size_t size = 0             # <<<<<<<<<<<<<<
 *     cdef const_char_ptr s
 *     cdef lua.lua_Number number
 */
  __pyx_v_size = 0;

  /* "lupa/_lupa.pyx":1050
 *     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":1076
 *     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:
 */
  switch (__pyx_v_lua_type) {

    /* "lupa/_lupa.pyx":1052
 *     cdef int lua_type = lua.lua_type(L, n)
 * 
 *     if lua_type == lua.LUA_TNIL:             # <<<<<<<<<<<<<<
 *         return None
 *     elif lua_type == lua.LUA_TNUMBER:
 */
    case LUA_TNIL:

    /* "lupa/_lupa.pyx":1053
 * 
 *     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_INCREF(Py_None);
    __pyx_r = Py_None;
    goto __pyx_L0;
    break;

    /* "lupa/_lupa.pyx":1054
 *     if lua_type == lua.LUA_TNIL:
 *         return None
 *     elif lua_type == lua.LUA_TNUMBER:             # <<<<<<<<<<<<<<
 *         number = lua.lua_tonumber(L, n)
 *         if number != <long>number:
 */
    case LUA_TNUMBER:

    /* "lupa/_lupa.pyx":1055
 *         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":1056
 *     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":1057
 *         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_filename = __pyx_f[0]; __pyx_lineno = 1057; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_r = __pyx_t_2;
      __pyx_t_2 = 0;
      goto __pyx_L0;
    }
    /*else*/ {

      /* "lupa/_lupa.pyx":1059
 *             return <double>number
 *         else:
 *             return <long>number             # <<<<<<<<<<<<<<
 *     elif lua_type == lua.LUA_TSTRING:
 *         s = lua.lua_tolstring(L, n, &size)
 */
      __Pyx_XDECREF(__pyx_r);
      __pyx_t_2 = __Pyx_PyInt_From_long(((long)__pyx_v_number)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1059; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_r = __pyx_t_2;
      __pyx_t_2 = 0;
      goto __pyx_L0;
    }
    break;

    /* "lupa/_lupa.pyx":1060
 *         else:
 *             return <long>number
 *     elif lua_type == lua.LUA_TSTRING:             # <<<<<<<<<<<<<<
 *         s = lua.lua_tolstring(L, n, &size)
 *         if runtime._encoding is not None:
 */
    case LUA_TSTRING:

    /* "lupa/_lupa.pyx":1061
 *             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":1062
 *     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":1063
 *         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);
      __pyx_t_4 = __Pyx_PyObject_AsString(__pyx_v_runtime->_encoding); if (unlikely((!__pyx_t_4) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1063; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 1063; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_r = __pyx_t_2;
      __pyx_t_2 = 0;
      goto __pyx_L0;
    }
    /*else*/ {

      /* "lupa/_lupa.pyx":1065
 *             return s[:size].decode(runtime._encoding)
 *         else:
 *             return s[:size]             # <<<<<<<<<<<<<<
 *     elif lua_type == lua.LUA_TBOOLEAN:
 *         return lua.lua_toboolean(L, n)
 */
      __Pyx_XDECREF(__pyx_r);
      __pyx_t_2 = __Pyx_PyBytes_FromStringAndSize(((const char*)__pyx_v_s) + 0, __pyx_v_size - 0); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1065; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_r = __pyx_t_2;
      __pyx_t_2 = 0;
      goto __pyx_L0;
    }
    break;

    /* "lupa/_lupa.pyx":1066
 *         else:
 *             return s[:size]
 *     elif lua_type == lua.LUA_TBOOLEAN:             # <<<<<<<<<<<<<<
 *         return lua.lua_toboolean(L, n)
 *     elif lua_type == lua.LUA_TUSERDATA:
 */
    case LUA_TBOOLEAN:

    /* "lupa/_lupa.pyx":1067
 *             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_filename = __pyx_f[0]; __pyx_lineno = 1067; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_r = __pyx_t_2;
    __pyx_t_2 = 0;
    goto __pyx_L0;
    break;

    /* "lupa/_lupa.pyx":1068
 *     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:
 */
    case LUA_TUSERDATA:

    /* "lupa/_lupa.pyx":1069
 *         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":1070
 *     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":1071
 *         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;
    }
    break;

    /* "lupa/_lupa.pyx":1072
 *         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:
 */
    case LUA_TTABLE:

    /* "lupa/_lupa.pyx":1073
 *             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_filename = __pyx_f[0]; __pyx_lineno = 1073; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_r = __pyx_t_2;
    __pyx_t_2 = 0;
    goto __pyx_L0;
    break;

    /* "lupa/_lupa.pyx":1074
 *     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:
 */
    case LUA_TTHREAD:

    /* "lupa/_lupa.pyx":1075
 *         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_filename = __pyx_f[0]; __pyx_lineno = 1075; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_r = __pyx_t_2;
    __pyx_t_2 = 0;
    goto __pyx_L0;
    break;

    /* "lupa/_lupa.pyx":1076
 *     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:
 */
    case LUA_TFUNCTION:

    /* "lupa/_lupa.pyx":1077
 *         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":1078
 *     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":1079
 *         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":1080
 *         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_filename = __pyx_f[0]; __pyx_lineno = 1080; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_r = __pyx_t_2;
    __pyx_t_2 = 0;
    goto __pyx_L0;
    break;
    default: break;
  }

  /* "lupa/_lupa.pyx":1081
 *             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_filename = __pyx_f[0]; __pyx_lineno = 1081; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_r = __pyx_t_2;
  __pyx_t_2 = 0;
  goto __pyx_L0;

  /* "lupa/_lupa.pyx":1041
 *     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":1083
 *     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":1088
 *     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":1089
 *     """
 *     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)
 */
  if ((__pyx_v_p != 0)) {
    __pyx_t_1 = (lua_getmetatable(__pyx_v_L, __pyx_v_n) != 0);
    __pyx_t_2 = __pyx_t_1;
  } else {
    __pyx_t_2 = (__pyx_v_p != 0);
  }
  if (__pyx_t_2) {

    /* "lupa/_lupa.pyx":1091
 *     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, __pyx_k_POBJECT);

    /* "lupa/_lupa.pyx":1092
 *         # 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_2 = (lua_rawequal(__pyx_v_L, -1, -2) != 0);
    if (__pyx_t_2) {

      /* "lupa/_lupa.pyx":1093
 *         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":1094
 *         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":1095
 *             lua.lua_pop(L, 2)
 *             return <py_object*>p
 *         lua.lua_pop(L, 2)             # <<<<<<<<<<<<<<
 *     return NULL
 * 
 */
    lua_pop(__pyx_v_L, 2);
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "lupa/_lupa.pyx":1096
 *             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":1083
 *     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":1098
 *     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;
  Py_ssize_t __pyx_t_4;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("py_function_result_to_lua", 0);

  /* "lupa/_lupa.pyx":1099
 * 
 * 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)
 */
  if ((__pyx_v_runtime->_unpack_returned_tuples != 0)) {
    __pyx_t_1 = PyTuple_Check(__pyx_v_o); 
    __pyx_t_2 = (__pyx_t_1 != 0);
  } else {
    __pyx_t_2 = (__pyx_v_runtime->_unpack_returned_tuples != 0);
  }
  if (__pyx_t_2) {

    /* "lupa/_lupa.pyx":1100
 * 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_3 = __pyx_f_4lupa_5_lupa_push_lua_arguments(__pyx_v_runtime, __pyx_v_L, ((PyObject*)__pyx_v_o), NULL); if (unlikely(__pyx_t_3 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1100; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

    /* "lupa/_lupa.pyx":1101
 *      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_filename = __pyx_f[0]; __pyx_lineno = 1101; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    __pyx_t_4 = PyTuple_GET_SIZE(((PyObject*)__pyx_v_o)); if (unlikely(__pyx_t_4 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1101; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_r = __pyx_t_4;
    goto __pyx_L0;
  }

  /* "lupa/_lupa.pyx":1102
 *          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_3 = __pyx_f_4lupa_5_lupa_py_to_lua(__pyx_v_runtime, __pyx_v_L, __pyx_v_o, NULL); if (unlikely(__pyx_t_3 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1102; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_r = __pyx_t_3;
  goto __pyx_L0;

  /* "lupa/_lupa.pyx":1098
 *     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":1104
 *      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;
  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":1105
 * 
 * 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":1106
 * 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":1108
 *     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":1109
 * 
 *     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":1110
 *     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, __pyx_k_Py_None, 7);

      /* "lupa/_lupa.pyx":1111
 *         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":1112
 *             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":1113
 *             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":1114
 *             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":1115
 *                 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;
      goto __pyx_L4;
    }
    /*else*/ {

      /* "lupa/_lupa.pyx":1119
 *             # 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:
 */
      lua_pushnil(__pyx_v_L);

      /* "lupa/_lupa.pyx":1120
 *             # 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:;
    goto __pyx_L3;
  }

  /* "lupa/_lupa.pyx":1121
 *             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_2 = (__pyx_v_o == Py_True);
  if (!(__pyx_t_2 != 0)) {
    __pyx_t_1 = (__pyx_v_o == Py_False);
    __pyx_t_3 = (__pyx_t_1 != 0);
  } else {
    __pyx_t_3 = (__pyx_t_2 != 0);
  }
  if (__pyx_t_3) {

    /* "lupa/_lupa.pyx":1122
 *             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_3 = __Pyx_PyObject_IsTrue(__pyx_v_o); if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1122; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    lua_pushboolean(__pyx_v_L, __pyx_t_3);

    /* "lupa/_lupa.pyx":1123
 *     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;
    goto __pyx_L3;
  }

  /* "lupa/_lupa.pyx":1124
 *         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_3 = (((PyObject *)Py_TYPE(__pyx_v_o)) == ((PyObject *)((PyObject*)(&PyFloat_Type))));
  __pyx_t_2 = (__pyx_t_3 != 0);
  if (__pyx_t_2) {

    /* "lupa/_lupa.pyx":1125
 *         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":1126
 *     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;
    goto __pyx_L3;
  }

  /* "lupa/_lupa.pyx":1127
 *         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_2 = PyLong_Check(__pyx_v_o); 
  __pyx_t_3 = (__pyx_t_2 != 0);
  if (__pyx_t_3) {

    /* "lupa/_lupa.pyx":1128
 *         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 PY_MAJOR_VERSION < 3 and isinstance(o, int):
 */
    __pyx_t_4 = PyLong_AsDouble(__pyx_v_o); if (unlikely(__pyx_t_4 == (-1.0) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1128; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    lua_pushnumber(__pyx_v_L, ((lua_Number)__pyx_t_4));

    /* "lupa/_lupa.pyx":1129
 *     elif isinstance(o, long):
 *         lua.lua_pushnumber(L, <lua.lua_Number>cpython.long.PyLong_AsDouble(o))
 *         pushed_values_count = 1             # <<<<<<<<<<<<<<
 *     elif PY_MAJOR_VERSION < 3 and isinstance(o, int):
 *         lua.lua_pushnumber(L, <lua.lua_Number><long>o)
 */
    __pyx_v_pushed_values_count = 1;
    goto __pyx_L3;
  }

  /* "lupa/_lupa.pyx":1130
 *         lua.lua_pushnumber(L, <lua.lua_Number>cpython.long.PyLong_AsDouble(o))
 *         pushed_values_count = 1
 *     elif PY_MAJOR_VERSION < 3 and isinstance(o, int):             # <<<<<<<<<<<<<<
 *         lua.lua_pushnumber(L, <lua.lua_Number><long>o)
 *         pushed_values_count = 1
 */
  __pyx_t_3 = ((PY_MAJOR_VERSION < 3) != 0);
  if (__pyx_t_3) {
    __pyx_t_2 = PyInt_Check(__pyx_v_o); 
    __pyx_t_1 = (__pyx_t_2 != 0);
  } else {
    __pyx_t_1 = __pyx_t_3;
  }
  if (__pyx_t_1) {

    /* "lupa/_lupa.pyx":1131
 *         pushed_values_count = 1
 *     elif PY_MAJOR_VERSION < 3 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_filename = __pyx_f[0]; __pyx_lineno = 1131; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    lua_pushnumber(__pyx_v_L, ((lua_Number)((long)__pyx_t_5)));

    /* "lupa/_lupa.pyx":1132
 *     elif PY_MAJOR_VERSION < 3 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;
    goto __pyx_L3;
  }

  /* "lupa/_lupa.pyx":1133
 *         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_1 = PyBytes_Check(__pyx_v_o); 
  __pyx_t_3 = (__pyx_t_1 != 0);
  if (__pyx_t_3) {

    /* "lupa/_lupa.pyx":1134
 *         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:
 */
    __pyx_t_6 = __Pyx_PyObject_AsString(__pyx_v_o); if (unlikely((!__pyx_t_6) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1134; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    if (unlikely(__pyx_v_o == Py_None)) {
      PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()");
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1134; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    __pyx_t_7 = PyBytes_GET_SIZE(((PyObject*)__pyx_v_o)); if (unlikely(__pyx_t_7 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1134; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    lua_pushlstring(__pyx_v_L, ((char *)__pyx_t_6), __pyx_t_7);

    /* "lupa/_lupa.pyx":1135
 *     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;
    goto __pyx_L3;
  }

  /* "lupa/_lupa.pyx":1136
 *         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_3 = PyUnicode_Check(__pyx_v_o); 
  if ((__pyx_t_3 != 0)) {
    __pyx_t_1 = (__pyx_v_runtime->_encoding != ((PyObject*)Py_None));
    __pyx_t_2 = (__pyx_t_1 != 0);
  } else {
    __pyx_t_2 = (__pyx_t_3 != 0);
  }
  if (__pyx_t_2) {

    /* "lupa/_lupa.pyx":1137
 *         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 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1137; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_v_pushed_values_count = __pyx_t_8;
    goto __pyx_L3;
  }

  /* "lupa/_lupa.pyx":1138
 *     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_2 = __Pyx_TypeCheck(__pyx_v_o, ((PyObject*)__pyx_ptype_4lupa_5_lupa__LuaObject)); 
  __pyx_t_3 = (__pyx_t_2 != 0);
  if (__pyx_t_3) {

    /* "lupa/_lupa.pyx":1139
 *         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_3 = (((struct __pyx_obj_4lupa_5_lupa__LuaObject *)__pyx_v_o)->_runtime != __pyx_v_runtime);
    __pyx_t_2 = (__pyx_t_3 != 0);
    if (__pyx_t_2) {

      /* "lupa/_lupa.pyx":1140
 *     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_t_9 = __Pyx_GetModuleGlobalName(__pyx_n_s_LuaError); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1140; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_9);
      __pyx_t_10 = __Pyx_PyObject_Call(__pyx_t_9, __pyx_tuple__24, NULL); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1140; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_10);
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
      __Pyx_Raise(__pyx_t_10, 0, 0, 0);
      __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1140; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }

    /* "lupa/_lupa.pyx":1141
 *         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":1142
 *             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;
    goto __pyx_L3;
  }

  /* "lupa/_lupa.pyx":1143
 *         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_2 = PyFloat_Check(__pyx_v_o); 
  __pyx_t_3 = (__pyx_t_2 != 0);
  if (__pyx_t_3) {

    /* "lupa/_lupa.pyx":1144
 *         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_filename = __pyx_f[0]; __pyx_lineno = 1144; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    lua_pushnumber(__pyx_v_L, ((lua_Number)((double)__pyx_t_4)));

    /* "lupa/_lupa.pyx":1145
 *     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;
    goto __pyx_L3;
  }
  /*else*/ {

    /* "lupa/_lupa.pyx":1147
 *         pushed_values_count = 1
 *     else:
 *         if isinstance(o, _PyProtocolWrapper):             # <<<<<<<<<<<<<<
 *             type_flags = (<_PyProtocolWrapper>o)._type_flags
 *             o = (<_PyProtocolWrapper>o)._obj
 */
    __pyx_t_3 = __Pyx_TypeCheck(__pyx_v_o, ((PyObject*)__pyx_ptype_4lupa_5_lupa__PyProtocolWrapper)); 
    __pyx_t_2 = (__pyx_t_3 != 0);
    if (__pyx_t_2) {

      /* "lupa/_lupa.pyx":1148
 *     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":1149
 *         if isinstance(o, _PyProtocolWrapper):
 *             type_flags = (<_PyProtocolWrapper>o)._type_flags
 *             o = (<_PyProtocolWrapper>o)._obj             # <<<<<<<<<<<<<<
 *         else:
 *             # prefer __getitem__ over __getattr__ by default
 */
      __pyx_t_10 = ((struct __pyx_obj_4lupa_5_lupa__PyProtocolWrapper *)__pyx_v_o)->_obj;
      __Pyx_INCREF(__pyx_t_10);
      __Pyx_DECREF_SET(__pyx_v_o, __pyx_t_10);
      __pyx_t_10 = 0;
      goto __pyx_L7;
    }
    /*else*/ {

      /* "lupa/_lupa.pyx":1152
 *         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
 */
      __pyx_t_2 = PyObject_HasAttr(__pyx_v_o, __pyx_n_s_getitem); if (unlikely(__pyx_t_2 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1152; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      if ((__pyx_t_2 != 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_L7:;

    /* "lupa/_lupa.pyx":1153
 *             # 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":1154
 *             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":1104
 *      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_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":1156
 *     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 *__pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  Py_ssize_t __pyx_t_3;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("push_encoded_unicode_string", 0);

  /* "lupa/_lupa.pyx":1157
 * 
 * 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 '%s'", "encode");
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1157; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_t_1 = __Pyx_PyObject_AsString(__pyx_v_runtime->_encoding); if (unlikely((!__pyx_t_1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1157; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_2 = PyUnicode_AsEncodedString(__pyx_v_ustring, __pyx_t_1, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1157; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  if (!(likely(PyBytes_CheckExact(__pyx_t_2))||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "bytes", Py_TYPE(__pyx_t_2)->tp_name), 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1157; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_v_bytes_string = ((PyObject*)__pyx_t_2);
  __pyx_t_2 = 0;

  /* "lupa/_lupa.pyx":1158
 * 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
 * 
 */
  __pyx_t_1 = __Pyx_PyObject_AsString(__pyx_v_bytes_string); if (unlikely((!__pyx_t_1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1158; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (unlikely(__pyx_v_bytes_string == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()");
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1158; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_t_3 = PyBytes_GET_SIZE(__pyx_v_bytes_string); if (unlikely(__pyx_t_3 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1158; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  lua_pushlstring(__pyx_v_L, ((char *)__pyx_t_1), __pyx_t_3);

  /* "lupa/_lupa.pyx":1159
 *     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":1156
 *     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":1161
 *     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":1162
 * 
 * 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":1163
 * 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":1164
 *     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":1170
 *     # 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_filename = __pyx_f[0]; __pyx_lineno = 1170; __pyx_clineno = __LINE__; goto __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":1171
 *     # 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_filename = __pyx_f[0]; __pyx_lineno = 1171; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_t_1 = (__Pyx_PyDict_Contains(__pyx_v_obj_id, __pyx_v_runtime->_pyrefs_in_lua, Py_EQ)); if (unlikely(__pyx_t_1 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1171; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_4 = (__pyx_t_1 != 0);
  if (__pyx_t_4) {

    /* "lupa/_lupa.pyx":1172
 *     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_filename = __pyx_f[0]; __pyx_lineno = 1172; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    __pyx_t_3 = __Pyx_PyDict_GetItem(__pyx_v_runtime->_pyrefs_in_lua, __pyx_v_obj_id); if (unlikely(__pyx_t_3 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1172; __pyx_clineno = __LINE__; goto __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 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1172; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    goto __pyx_L4;
  }
  /*else*/ {

    /* "lupa/_lupa.pyx":1174
 *         runtime._pyrefs_in_lua[obj_id].append(o)
 *     else:
 *         runtime._pyrefs_in_lua[obj_id] = [o]             # <<<<<<<<<<<<<<
 * 
 *     py_obj.obj = <PyObject*>o
 */
    __pyx_t_3 = PyList_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1174; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_INCREF(__pyx_v_o);
    PyList_SET_ITEM(__pyx_t_3, 0, __pyx_v_o);
    __Pyx_GIVEREF(__pyx_v_o);
    if (unlikely(__pyx_v_runtime->_pyrefs_in_lua == Py_None)) {
      PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1174; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    if (unlikely(PyDict_SetItem(__pyx_v_runtime->_pyrefs_in_lua, __pyx_v_obj_id, __pyx_t_3) < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1174; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  }
  __pyx_L4:;

  /* "lupa/_lupa.pyx":1176
 *         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":1177
 * 
 *     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":1178
 *     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":1179
 *     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, __pyx_k_POBJECT);

  /* "lupa/_lupa.pyx":1180
 *     py_obj.type_flags = type_flags
 *     lua.luaL_getmetatable(L, POBJECT)
 *     lua.lua_setmetatable(L, -2)             # <<<<<<<<<<<<<<
 *     return 1 # values pushed
 * 
 */
  lua_setmetatable(__pyx_v_L, -2);

  /* "lupa/_lupa.pyx":1181
 *     lua.luaL_getmetatable(L, POBJECT)
 *     lua.lua_setmetatable(L, -2)
 *     return 1 # values pushed             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_r = 1;
  goto __pyx_L0;

  /* "lupa/_lupa.pyx":1161
 *     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, 0);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_obj_id);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "lupa/_lupa.pyx":1184
 * 
 * 
 * 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":1185
 * 
 * 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":1186
 * 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":1187
 *     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":1188
 *     while s[0]:
 *         c |= s[0]
 *         s += 1             # <<<<<<<<<<<<<<
 *     return c & 0x80 == 0
 * 
 */
    __pyx_v_s = (__pyx_v_s + 1);
  }

  /* "lupa/_lupa.pyx":1189
 *         c |= s[0]
 *         s += 1
 *     return c & 0x80 == 0             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_r = ((__pyx_v_c & 0x80) == 0);
  goto __pyx_L0;

  /* "lupa/_lupa.pyx":1184
 * 
 * 
 * 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":1192
 * 
 * 
 * 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":1193
 * 
 * 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":1194
 * 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_filename = __pyx_f[0]; __pyx_lineno = 1194; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_INCREF(__pyx_v_s);
    __pyx_r = ((PyObject*)__pyx_v_s);
    goto __pyx_L0;
  }

  /* "lupa/_lupa.pyx":1195
 *     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":1196
 *         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 '%s'", "encode");
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1196; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    __pyx_t_3 = PyUnicode_AsASCIIString(((PyObject*)__pyx_v_s)); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1196; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    if (!(likely(PyBytes_CheckExact(__pyx_t_3))||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "bytes", Py_TYPE(__pyx_t_3)->tp_name), 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1196; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_r = ((PyObject*)__pyx_t_3);
    __pyx_t_3 = 0;
    goto __pyx_L0;
  }

  /* "lupa/_lupa.pyx":1197
 *     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":1198
 *         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 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1198; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_INCREF(__pyx_v_s);
    PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_v_s);
    __Pyx_GIVEREF(__pyx_v_s);
    __pyx_t_4 = __Pyx_PyObject_Call(((PyObject *)((PyObject*)(&PyBytes_Type))), __pyx_t_3, NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1198; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_DECREF_SET(__pyx_v_s, __pyx_t_4);
    __pyx_t_4 = 0;
    goto __pyx_L3;
  }

  /* "lupa/_lupa.pyx":1199
 *     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 (__pyx_t_1) {

    /* "lupa/_lupa.pyx":1200
 *         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_4 = __Pyx_PyString_Format(__pyx_kp_s_expected_string_got_s, ((PyObject *)Py_TYPE(__pyx_v_s))); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1200; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1200; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_4);
    __Pyx_GIVEREF(__pyx_t_4);
    __pyx_t_4 = 0;
    __pyx_t_4 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_t_3, NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1200; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 1200; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_L3:;

  /* "lupa/_lupa.pyx":1201
 *     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
 */
  __pyx_t_5 = __Pyx_PyObject_AsUString(__pyx_v_s); if (unlikely((!__pyx_t_5) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1201; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_1 = ((!(__pyx_f_4lupa_5_lupa__isascii(__pyx_t_5) != 0)) != 0);
  if (__pyx_t_1) {

    /* "lupa/_lupa.pyx":1202
 *         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__25, NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1202; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 1202; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }

  /* "lupa/_lupa.pyx":1203
 *     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":1192
 * 
 * 
 * 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":1208
 * # 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;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("raise_lua_error", 0);

  /* "lupa/_lupa.pyx":1211
 *     if result == 0:
 *         return 0
 *     elif result == lua.LUA_ERRMEM:             # <<<<<<<<<<<<<<
 *         raise MemoryError()
 *     else:
 */
  switch (__pyx_v_result) {

    /* "lupa/_lupa.pyx":1209
 * 
 * cdef int raise_lua_error(LuaRuntime runtime, lua_State* L, int result) except -1:
 *     if result == 0:             # <<<<<<<<<<<<<<
 *         return 0
 *     elif result == lua.LUA_ERRMEM:
 */
    case 0:

    /* "lupa/_lupa.pyx":1210
 * 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;
    break;

    /* "lupa/_lupa.pyx":1211
 *     if result == 0:
 *         return 0
 *     elif result == lua.LUA_ERRMEM:             # <<<<<<<<<<<<<<
 *         raise MemoryError()
 *     else:
 */
    case LUA_ERRMEM:

    /* "lupa/_lupa.pyx":1212
 *         return 0
 *     elif result == lua.LUA_ERRMEM:
 *         raise MemoryError()             # <<<<<<<<<<<<<<
 *     else:
 *         raise LuaError( build_lua_error_message(runtime, L, None, -1) )
 */
    PyErr_NoMemory(); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1212; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    break;
    default:

    /* "lupa/_lupa.pyx":1214
 *         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_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_LuaError); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1214; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_2 = __pyx_f_4lupa_5_lupa_build_lua_error_message(__pyx_v_runtime, __pyx_v_L, ((PyObject*)Py_None), -1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1214; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1214; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_2);
    __Pyx_GIVEREF(__pyx_t_2);
    __pyx_t_2 = 0;
    __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_3, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1214; __pyx_clineno = __LINE__; goto __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_Raise(__pyx_t_2, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1214; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    break;
  }

  /* "lupa/_lupa.pyx":1208
 * # 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_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":1216
 *         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_ptr 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;
  const char* __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 *__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":1217
 * 
 * cdef build_lua_error_message(LuaRuntime runtime, lua_State* L, unicode err_message, int n):
 *     cdef size_t size = 0             # <<<<<<<<<<<<<<
 *     cdef const_char_ptr s = lua.lua_tolstring(L, n, &size)
 *     if runtime._encoding is not None:
 */
  __pyx_v_size = 0;

  /* "lupa/_lupa.pyx":1218
 * cdef build_lua_error_message(LuaRuntime runtime, lua_State* L, unicode err_message, int n):
 *     cdef size_t size = 0
 *     cdef const_char_ptr 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":1219
 *     cdef size_t size = 0
 *     cdef const_char_ptr 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":1220
 *     cdef const_char_ptr s = lua.lua_tolstring(L, n, &size)
 *     if runtime._encoding is not None:
 *         try:             # <<<<<<<<<<<<<<
 *             py_ustring = s[:size].decode(runtime._encoding)
 *         except UnicodeDecodeError:
 */
    {
      __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":1221
 *     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
 */
        __pyx_t_6 = __Pyx_PyObject_AsString(__pyx_v_runtime->_encoding); if (unlikely((!__pyx_t_6) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1221; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 1221; __pyx_clineno = __LINE__; goto __pyx_L4_error;}
        __Pyx_GOTREF(__pyx_t_7);
        __pyx_v_py_ustring = __pyx_t_7;
        __pyx_t_7 = 0;
      }
      __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_L11_try_end;
      __pyx_L4_error:;
      __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;

      /* "lupa/_lupa.pyx":1222
 *         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 = 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_filename = __pyx_f[0]; __pyx_lineno = 1222; __pyx_clineno = __LINE__; goto __pyx_L6_except_error;}
        __Pyx_GOTREF(__pyx_t_7);
        __Pyx_GOTREF(__pyx_t_9);
        __Pyx_GOTREF(__pyx_t_10);

        /* "lupa/_lupa.pyx":1223
 *             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_filename = __pyx_f[0]; __pyx_lineno = 1223; __pyx_clineno = __LINE__; goto __pyx_L6_except_error;}
        __Pyx_GOTREF(__pyx_t_11);
        __Pyx_XDECREF_SET(__pyx_v_py_ustring, __pyx_t_11);
        __pyx_t_11 = 0;
        __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
        __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
        __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
        goto __pyx_L5_exception_handled;
      }
      goto __pyx_L6_except_error;
      __pyx_L6_except_error:;
      __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_L11_try_end:;
    }
    goto __pyx_L3;
  }
  /*else*/ {

    /* "lupa/_lupa.pyx":1225
 *             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
 */
    __pyx_t_10 = __Pyx_decode_c_string(__pyx_v_s, 0, __pyx_v_size, NULL, NULL, PyUnicode_DecodeLatin1); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1225; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_10);
    __pyx_v_py_ustring = __pyx_t_10;
    __pyx_t_10 = 0;
  }
  __pyx_L3:;

  /* "lupa/_lupa.pyx":1226
 *     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":1227
 *         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;
  }
  /*else*/ {

    /* "lupa/_lupa.pyx":1229
 *         return py_ustring
 *     else:
 *         return err_message % py_ustring             # <<<<<<<<<<<<<<
 * 
 * # calling into Lua
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_10 = __Pyx_PyUnicode_FormatSafe(__pyx_v_err_message, __pyx_v_py_ustring); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1229; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_10);
    __pyx_r = __pyx_t_10;
    __pyx_t_10 = 0;
    goto __pyx_L0;
  }

  /* "lupa/_lupa.pyx":1216
 *         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_ptr 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":1233
 * # calling into Lua
 * 
 * cdef run_lua(LuaRuntime runtime, bytes lua_code):             # <<<<<<<<<<<<<<
 *     # 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) {
  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;
  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("run_lua", 0);

  /* "lupa/_lupa.pyx":1235
 * cdef run_lua(LuaRuntime runtime, bytes lua_code):
 *     # 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":1237
 *     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 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1237; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "lupa/_lupa.pyx":1238
 *     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":1239
 *     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":1240
 *     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))
 */
    __pyx_t_3 = __Pyx_PyObject_AsString(__pyx_v_lua_code); if (unlikely((!__pyx_t_3) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1240; __pyx_clineno = __LINE__; goto __pyx_L4_error;}
    if (unlikely(__pyx_v_lua_code == Py_None)) {
      PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()");
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1240; __pyx_clineno = __LINE__; goto __pyx_L4_error;}
    }
    __pyx_t_4 = PyBytes_GET_SIZE(__pyx_v_lua_code); if (unlikely(__pyx_t_4 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1240; __pyx_clineno = __LINE__; goto __pyx_L4_error;}
    __pyx_t_5 = (luaL_loadbuffer(__pyx_v_L, __pyx_t_3, __pyx_t_4, __pyx_k_python_2) != 0);
    if (__pyx_t_5) {

      /* "lupa/_lupa.pyx":1241
 *     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 execute_lua_call(runtime, L, 0)
 */
      __pyx_t_6 = __Pyx_GetModuleGlobalName(__pyx_n_s_LuaSyntaxError); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1241; __pyx_clineno = __LINE__; goto __pyx_L4_error;}
      __Pyx_GOTREF(__pyx_t_6);

      /* "lupa/_lupa.pyx":1242
 *         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 execute_lua_call(runtime, L, 0)
 *     finally:
 */
      __pyx_t_7 = __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_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1241; __pyx_clineno = __LINE__; goto __pyx_L4_error;}
      __Pyx_GOTREF(__pyx_t_7);

      /* "lupa/_lupa.pyx":1241
 *     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 execute_lua_call(runtime, L, 0)
 */
      __pyx_t_8 = PyTuple_New(1); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1241; __pyx_clineno = __LINE__; goto __pyx_L4_error;}
      __Pyx_GOTREF(__pyx_t_8);
      PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_7);
      __Pyx_GIVEREF(__pyx_t_7);
      __pyx_t_7 = 0;
      __pyx_t_7 = __Pyx_PyObject_Call(__pyx_t_6, __pyx_t_8, NULL); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1241; __pyx_clineno = __LINE__; goto __pyx_L4_error;}
      __Pyx_GOTREF(__pyx_t_7);
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      __Pyx_Raise(__pyx_t_7, 0, 0, 0);
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1241; __pyx_clineno = __LINE__; goto __pyx_L4_error;}
    }

    /* "lupa/_lupa.pyx":1243
 *             raise LuaSyntaxError(build_lua_error_message(
 *                 runtime, L, u"error loading code: %s", -1))
 *         return execute_lua_call(runtime, L, 0)             # <<<<<<<<<<<<<<
 *     finally:
 *         lua.lua_settop(L, old_top)
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_7 = __pyx_f_4lupa_5_lupa_execute_lua_call(__pyx_v_runtime, __pyx_v_L, 0); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1243; __pyx_clineno = __LINE__; goto __pyx_L4_error;}
    __Pyx_GOTREF(__pyx_t_7);
    __pyx_r = __pyx_t_7;
    __pyx_t_7 = 0;
    goto __pyx_L3_return;
  }

  /* "lupa/_lupa.pyx":1245
 *         return execute_lua_call(runtime, L, 0)
 *     finally:
 *         lua.lua_settop(L, old_top)             # <<<<<<<<<<<<<<
 *         unlock_runtime(runtime)
 * 
 */
  /*finally:*/ {
    /*exception exit:*/{
      __pyx_L4_error:;
      __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_6); __pyx_t_6 = 0;
      __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
      __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 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_2 = __pyx_lineno; __pyx_t_9 = __pyx_clineno; __pyx_t_10 = __pyx_filename;
      {
        lua_settop(__pyx_v_L, __pyx_v_old_top);

        /* "lupa/_lupa.pyx":1246
 *     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_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_2; __pyx_clineno = __pyx_t_9; __pyx_filename = __pyx_t_10;
      goto __pyx_L1_error;
    }
    __pyx_L3_return: {
      __pyx_t_16 = __pyx_r;
      __pyx_r = 0;

      /* "lupa/_lupa.pyx":1245
 *         return execute_lua_call(runtime, L, 0)
 *     finally:
 *         lua.lua_settop(L, old_top)             # <<<<<<<<<<<<<<
 *         unlock_runtime(runtime)
 * 
 */
      lua_settop(__pyx_v_L, __pyx_v_old_top);

      /* "lupa/_lupa.pyx":1246
 *     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_16;
      __pyx_t_16 = 0;
      goto __pyx_L0;
    }
  }

  /* "lupa/_lupa.pyx":1233
 * # calling into Lua
 * 
 * cdef run_lua(LuaRuntime runtime, bytes lua_code):             # <<<<<<<<<<<<<<
 *     # 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_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":1248
 *         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":1251
 *     # 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 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1251; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "lupa/_lupa.pyx":1252
 *     # 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_filename = __pyx_f[0]; __pyx_lineno = 1252; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_t_2 = PyTuple_GET_SIZE(__pyx_v_args); if (unlikely(__pyx_t_2 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1252; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 1252; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_r = __pyx_t_3;
  __pyx_t_3 = 0;
  goto __pyx_L0;

  /* "lupa/_lupa.pyx":1248
 *         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":1254
 *     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
 *     # call into Lua
 */

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;
  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("execute_lua_call", 0);

  /* "lupa/_lupa.pyx":1257
 *     cdef int result_status
 *     # call into Lua
 *     with nogil:             # <<<<<<<<<<<<<<
 *         result_status = lua.lua_pcall(L, nargs, lua.LUA_MULTRET, 0)
 *     runtime.reraise_on_exception()
 */
  {
      #ifdef WITH_THREAD
      PyThreadState *_save;
      Py_UNBLOCK_THREADS
      #endif
      /*try:*/ {

        /* "lupa/_lupa.pyx":1258
 *     # call into Lua
 *     with nogil:
 *         result_status = lua.lua_pcall(L, nargs, lua.LUA_MULTRET, 0)             # <<<<<<<<<<<<<<
 *     runtime.reraise_on_exception()
 *     if result_status:
 */
        __pyx_v_result_status = lua_pcall(__pyx_v_L, __pyx_v_nargs, LUA_MULTRET, 0);
      }

      /* "lupa/_lupa.pyx":1257
 *     cdef int result_status
 *     # call into Lua
 *     with nogil:             # <<<<<<<<<<<<<<
 *         result_status = lua.lua_pcall(L, nargs, lua.LUA_MULTRET, 0)
 *     runtime.reraise_on_exception()
 */
      /*finally:*/ {
        /*normal exit:*/{
          #ifdef WITH_THREAD
          Py_BLOCK_THREADS
          #endif
          goto __pyx_L5;
        }
        __pyx_L5:;
      }
  }

  /* "lupa/_lupa.pyx":1259
 *     with nogil:
 *         result_status = lua.lua_pcall(L, nargs, lua.LUA_MULTRET, 0)
 *     runtime.reraise_on_exception()             # <<<<<<<<<<<<<<
 *     if result_status:
 *         raise_lua_error(runtime, L, result_status)
 */
  __pyx_t_1 = __pyx_f_4lupa_5_lupa_10LuaRuntime_reraise_on_exception(__pyx_v_runtime); if (unlikely(__pyx_t_1 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1259; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "lupa/_lupa.pyx":1260
 *         result_status = lua.lua_pcall(L, nargs, lua.LUA_MULTRET, 0)
 *     runtime.reraise_on_exception()
 *     if result_status:             # <<<<<<<<<<<<<<
 *         raise_lua_error(runtime, L, result_status)
 *     return unpack_lua_results(runtime, L)
 */
  __pyx_t_2 = (__pyx_v_result_status != 0);
  if (__pyx_t_2) {

    /* "lupa/_lupa.pyx":1261
 *     runtime.reraise_on_exception()
 *     if result_status:
 *         raise_lua_error(runtime, L, result_status)             # <<<<<<<<<<<<<<
 *     return unpack_lua_results(runtime, L)
 * 
 */
    __pyx_t_1 = __pyx_f_4lupa_5_lupa_raise_lua_error(__pyx_v_runtime, __pyx_v_L, __pyx_v_result_status); if (unlikely(__pyx_t_1 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1261; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    goto __pyx_L6;
  }
  __pyx_L6:;

  /* "lupa/_lupa.pyx":1262
 *     if result_status:
 *         raise_lua_error(runtime, L, result_status)
 *     return unpack_lua_results(runtime, L)             # <<<<<<<<<<<<<<
 * 
 * cdef int push_lua_arguments(LuaRuntime runtime, lua_State *L,
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_3 = __pyx_f_4lupa_5_lupa_unpack_lua_results(__pyx_v_runtime, __pyx_v_L); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1262; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_r = __pyx_t_3;
  __pyx_t_3 = 0;
  goto __pyx_L0;

  /* "lupa/_lupa.pyx":1254
 *     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
 *     # call into Lua
 */

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

/* "lupa/_lupa.pyx":1264
 *     return unpack_lua_results(runtime, L)
 * 
 * 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":1265
 * 
 * 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":1267
 *                             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":1268
 *     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":1269
 *     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_COMPILING_IN_CPYTHON
      __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_filename = __pyx_f[0]; __pyx_lineno = 1269; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      #else
      __pyx_t_5 = PySequence_ITEM(__pyx_t_3, __pyx_t_4); __pyx_t_4++; if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1269; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      #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":1270
 *         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 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1270; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_t_1 = ((!(__pyx_t_6 != 0)) != 0);
      if (__pyx_t_1) {

        /* "lupa/_lupa.pyx":1271
 *         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":1272
 *             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_filename = __pyx_f[0]; __pyx_lineno = 1272; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 1272; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_8);
        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
        __pyx_t_5 = PyTuple_New(1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1272; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_5);
        PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_8);
        __Pyx_GIVEREF(__pyx_t_8);
        __pyx_t_8 = 0;
        __pyx_t_8 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_t_5, NULL); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1272; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_8);
        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
        __Pyx_Raise(__pyx_t_8, 0, 0, 0);
        __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
        {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1272; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      }

      /* "lupa/_lupa.pyx":1273
 *                 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;
    }
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "lupa/_lupa.pyx":1274
 *                 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":1264
 *     return unpack_lua_results(runtime, L)
 * 
 * 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":1276
 *     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":1277
 * 
 * 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":1278
 * 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":1279
 *     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_filename = __pyx_f[0]; __pyx_lineno = 1279; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_r = __pyx_t_2;
    __pyx_t_2 = 0;
    goto __pyx_L0;
  }

  /* "lupa/_lupa.pyx":1280
 *     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":1281
 *         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_INCREF(Py_None);
    __pyx_r = Py_None;
    goto __pyx_L0;
  }

  /* "lupa/_lupa.pyx":1282
 *     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_filename = __pyx_f[0]; __pyx_lineno = 1282; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_r = __pyx_t_2;
  __pyx_t_2 = 0;
  goto __pyx_L0;

  /* "lupa/_lupa.pyx":1276
 *     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":1284
 *     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_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("unpack_multiple_lua_results", 0);

  /* "lupa/_lupa.pyx":1285
 * 
 * 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_filename = __pyx_f[0]; __pyx_lineno = 1285; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_args = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "lupa/_lupa.pyx":1287
 *     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;
  for (__pyx_t_3 = 0; __pyx_t_3 < __pyx_t_2; __pyx_t_3+=1) {
    __pyx_v_i = __pyx_t_3;

    /* "lupa/_lupa.pyx":1288
 *     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_filename = __pyx_f[0]; __pyx_lineno = 1288; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_XDECREF_SET(__pyx_v_arg, __pyx_t_1);
    __pyx_t_1 = 0;

    /* "lupa/_lupa.pyx":1289
 *     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":1290
 *         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":1291
 *         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":1284
 *     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":1317
 * # ref-counting support for Python objects
 * 
 * cdef int decref_with_gil(py_object *py_obj) 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) {
  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 = PyGILState_Ensure();
  #endif
  __Pyx_RefNannySetupContext("decref_with_gil", 0);

  /* "lupa/_lupa.pyx":1321
 *     #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":1322
 *     # 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_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":1323
 *     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_filename = __pyx_f[0]; __pyx_lineno = 1323; __pyx_clineno = __LINE__; goto __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":1324
 *     try:
 *         obj_id = <object><uintptr_t>py_obj.obj
 *         try:             # <<<<<<<<<<<<<<
 *             refs = <list>runtime._pyrefs_in_lua[obj_id]
 *         except (TypeError, KeyError):
 */
      {
        __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":1325
 *         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_filename = __pyx_f[0]; __pyx_lineno = 1325; __pyx_clineno = __LINE__; goto __pyx_L11_error;}
          }
          __pyx_t_5 = __Pyx_PyDict_GetItem(__pyx_v_runtime->_pyrefs_in_lua, __pyx_v_obj_id); if (unlikely(__pyx_t_5 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1325; __pyx_clineno = __LINE__; goto __pyx_L11_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;
        }
        __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_L11_error:;
        __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
        __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;

        /* "lupa/_lupa.pyx":1326
 *         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 = PyErr_ExceptionMatches(__pyx_builtin_TypeError) || 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_filename = __pyx_f[0]; __pyx_lineno = 1326; __pyx_clineno = __LINE__; goto __pyx_L13_except_error;}
          __Pyx_GOTREF(__pyx_t_1);
          __Pyx_GOTREF(__pyx_t_5);
          __Pyx_GOTREF(__pyx_t_10);

          /* "lupa/_lupa.pyx":1327
 *             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_L14_except_return;
          __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_exception_handled;
        }
        goto __pyx_L13_except_error;
        __pyx_L13_except_error:;
        __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_L14_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_L12_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":1328
 *         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_filename = __pyx_f[0]; __pyx_lineno = 1328; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
      __pyx_t_11 = PyList_GET_SIZE(__pyx_v_refs); if (unlikely(__pyx_t_11 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1328; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      __pyx_t_12 = ((__pyx_t_11 == 1) != 0);
      if (__pyx_t_12) {

        /* "lupa/_lupa.pyx":1329
 *             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_filename = __pyx_f[0]; __pyx_lineno = 1329; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        }
        if (PyDict_DelItem(__pyx_v_runtime->_pyrefs_in_lua, __pyx_v_obj_id) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1329; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        goto __pyx_L21;
      }
      /*else*/ {

        /* "lupa/_lupa.pyx":1331
 *             del runtime._pyrefs_in_lua[obj_id]
 *         else:
 *             refs.pop()  # any, really             # <<<<<<<<<<<<<<
 *         return 0
 *     except:
 */
        if (unlikely(__pyx_v_refs == Py_None)) {
          PyErr_Format(PyExc_AttributeError, "'NoneType' object has no attribute '%s'", "pop");
          {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1331; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        }
        __pyx_t_10 = __Pyx_PyList_Pop(__pyx_v_refs); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1331; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        __Pyx_GOTREF(__pyx_t_10);
        __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
      }
      __pyx_L21:;

      /* "lupa/_lupa.pyx":1332
 *         else:
 *             refs.pop()  # any, really
 *         return 0             # <<<<<<<<<<<<<<
 *     except:
 *         try: runtime.store_raised_exception()
 */
      __pyx_r = 0;
      goto __pyx_L7_try_return;
    }
    __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;
    goto __pyx_L10_try_end;
    __pyx_L3_error:;
    __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;

    /* "lupa/_lupa.pyx":1333
 *             refs.pop()  # any, really
 *         return 0
 *     except:             # <<<<<<<<<<<<<<
 *         try: runtime.store_raised_exception()
 *         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_filename = __pyx_f[0]; __pyx_lineno = 1333; __pyx_clineno = __LINE__; goto __pyx_L5_except_error;}
      __Pyx_GOTREF(__pyx_t_10);
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_GOTREF(__pyx_t_1);

      /* "lupa/_lupa.pyx":1334
 *         return 0
 *     except:
 *         try: runtime.store_raised_exception()             # <<<<<<<<<<<<<<
 *         finally: return -1
 * 
 */
      /*try:*/ {
        __pyx_t_9 = __pyx_f_4lupa_5_lupa_10LuaRuntime_store_raised_exception(__pyx_v_runtime); if (unlikely(__pyx_t_9 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1334; __pyx_clineno = __LINE__; goto __pyx_L27_error;}
      }

      /* "lupa/_lupa.pyx":1335
 *     except:
 *         try: runtime.store_raised_exception()
 *         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;
        }
        /*exception exit:*/{
          __pyx_L27_error:;
          __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_L31_return;
          }
          __pyx_L31_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_DECREF(__pyx_t_10); __pyx_t_10 = 0;
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      goto __pyx_L4_exception_handled;
    }
    __pyx_L5_except_error:;
    __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;
    __pyx_L4_exception_handled:;
    __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);
    __pyx_L10_try_end:;
  }

  /* "lupa/_lupa.pyx":1317
 * # ref-counting support for Python objects
 * 
 * cdef int decref_with_gil(py_object *py_obj) 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, 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
  PyGILState_Release(__pyx_gilstate_save);
  #endif
  return __pyx_r;
}

/* "lupa/_lupa.pyx":1337
 *         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;
  int __pyx_t_3;

  /* "lupa/_lupa.pyx":1338
 * 
 * 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":1339
 * 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":1340
 *     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):
 */
  __pyx_v_py_obj = __pyx_f_4lupa_5_lupa_unpack_userdata(__pyx_v_L, 1);

  /* "lupa/_lupa.pyx":1341
 *         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):
 *             return lua.luaL_error(L, 'error while cleaning up a Python object')  # never returns!
 */
  __pyx_t_1 = ((__pyx_v_py_obj != NULL) != 0);
  if (__pyx_t_1) {
    __pyx_t_2 = ((__pyx_v_py_obj->obj != NULL) != 0);
    __pyx_t_3 = __pyx_t_2;
  } else {
    __pyx_t_3 = __pyx_t_1;
  }
  if (__pyx_t_3) {

    /* "lupa/_lupa.pyx":1342
 *     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):             # <<<<<<<<<<<<<<
 *             return lua.luaL_error(L, 'error while cleaning up a Python object')  # never returns!
 *     return 0
 */
    __pyx_t_3 = (__pyx_f_4lupa_5_lupa_decref_with_gil(__pyx_v_py_obj) != 0);
    if (__pyx_t_3) {

      /* "lupa/_lupa.pyx":1343
 *     if py_obj is not NULL and py_obj.obj is not NULL:
 *         if decref_with_gil(py_obj):
 *             return lua.luaL_error(L, 'error while cleaning up a Python object')  # never returns!             # <<<<<<<<<<<<<<
 *     return 0
 * 
 */
      __pyx_r = luaL_error(__pyx_v_L, __pyx_k_error_while_cleaning_up_a_Python);
      goto __pyx_L0;
    }
    goto __pyx_L4;
  }
  __pyx_L4:;

  /* "lupa/_lupa.pyx":1344
 *         if decref_with_gil(py_obj):
 *             return lua.luaL_error(L, 'error while cleaning up a Python object')  # never returns!
 *     return 0             # <<<<<<<<<<<<<<
 * 
 * # calling Python objects
 */
  __pyx_r = 0;
  goto __pyx_L0;

  /* "lupa/_lupa.pyx":1337
 *         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":1348
 * # 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;
  int __pyx_t_3;
  int __pyx_t_4;
  PyObject *__pyx_t_5;
  int __pyx_t_6;
  int __pyx_t_7;
  PyObject *__pyx_t_8 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("call_python", 0);

  /* "lupa/_lupa.pyx":1349
 * 
 * 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":1352
 *     cdef tuple args
 * 
 *     if not py_obj:             # <<<<<<<<<<<<<<
 *         raise TypeError("not a python object")
 * 
 */
  __pyx_t_1 = ((!(__pyx_v_py_obj != 0)) != 0);
  if (__pyx_t_1) {

    /* "lupa/_lupa.pyx":1353
 * 
 *     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__26, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1353; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 1353; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }

  /* "lupa/_lupa.pyx":1355
 *         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":1357
 *     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":1358
 * 
 *     if not nargs:
 *         lua.lua_settop(L, 0)  # FIXME             # <<<<<<<<<<<<<<
 *         result = f()
 *     else:
 */
    lua_settop(__pyx_v_L, 0);

    /* "lupa/_lupa.pyx":1359
 *     if not nargs:
 *         lua.lua_settop(L, 0)  # FIXME
 *         result = f()             # <<<<<<<<<<<<<<
 *     else:
 *         arg = py_from_lua(runtime, L, 2)
 */
    __pyx_t_2 = __Pyx_PyObject_Call(__pyx_v_f, __pyx_empty_tuple, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1359; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_v_result = __pyx_t_2;
    __pyx_t_2 = 0;
    goto __pyx_L4;
  }
  /*else*/ {

    /* "lupa/_lupa.pyx":1361
 *         result = f()
 *     else:
 *         arg = py_from_lua(runtime, L, 2)             # <<<<<<<<<<<<<<
 * 
 *         if PyMethod_Check(f) and (<PyObject*>arg) is PyMethod_GET_SELF(f):
 */
    __pyx_t_2 = __pyx_f_4lupa_5_lupa_py_from_lua(__pyx_v_runtime, __pyx_v_L, 2); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1361; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_v_arg = __pyx_t_2;
    __pyx_t_2 = 0;

    /* "lupa/_lupa.pyx":1363
 *         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_1 = (PyMethod_Check(__pyx_v_f) != 0);
    if (__pyx_t_1) {
      __pyx_t_3 = ((((PyObject *)__pyx_v_arg) == PyMethod_GET_SELF(__pyx_v_f)) != 0);
      __pyx_t_4 = __pyx_t_3;
    } else {
      __pyx_t_4 = __pyx_t_1;
    }
    if (__pyx_t_4) {

      /* "lupa/_lupa.pyx":1373
 *             # 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_5 = PyMethod_GET_FUNCTION(__pyx_v_f);
      __pyx_t_2 = ((PyObject *)__pyx_t_5);
      __Pyx_INCREF(__pyx_t_2);
      __Pyx_DECREF_SET(__pyx_v_f, __pyx_t_2);
      __pyx_t_2 = 0;
      goto __pyx_L5;
    }
    __pyx_L5:;

    /* "lupa/_lupa.pyx":1375
 *             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_filename = __pyx_f[0]; __pyx_lineno = 1375; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_v_args = ((PyObject*)__pyx_t_2);
    __pyx_t_2 = 0;

    /* "lupa/_lupa.pyx":1376
 * 
 *         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":1377
 *         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":1379
 *         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_6 = __pyx_v_nargs;
    for (__pyx_t_7 = 1; __pyx_t_7 < __pyx_t_6; __pyx_t_7+=1) {
      __pyx_v_i = __pyx_t_7;

      /* "lupa/_lupa.pyx":1380
 * 
 *         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_filename = __pyx_f[0]; __pyx_lineno = 1380; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF_SET(__pyx_v_arg, __pyx_t_2);
      __pyx_t_2 = 0;

      /* "lupa/_lupa.pyx":1381
 *         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":1382
 *             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":1384
 *             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":1385
 * 
 *         lua.lua_settop(L, 0)  # FIXME
 *         result = f(*args)             # <<<<<<<<<<<<<<
 * 
 *     return py_function_result_to_lua(runtime, L, result)
 */
    __pyx_t_2 = PySequence_Tuple(__pyx_v_args); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1385; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_8 = __Pyx_PyObject_Call(__pyx_v_f, __pyx_t_2, NULL); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1385; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_8);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_v_result = __pyx_t_8;
    __pyx_t_8 = 0;
  }
  __pyx_L4:;

  /* "lupa/_lupa.pyx":1387
 *         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_6 = __pyx_f_4lupa_5_lupa_py_function_result_to_lua(__pyx_v_runtime, __pyx_v_L, __pyx_v_result); if (unlikely(__pyx_t_6 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1387; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_r = __pyx_t_6;
  goto __pyx_L0;

  /* "lupa/_lupa.pyx":1348
 * # 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_8);
  __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":1389
 *     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
 *     try:
 */

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;
  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;
  PyObject *__pyx_t_6 = NULL;
  PyObject *__pyx_t_7 = NULL;
  int __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;
  #ifdef WITH_THREAD
  PyGILState_STATE __pyx_gilstate_save = PyGILState_Ensure();
  #endif
  __Pyx_RefNannySetupContext("py_call_with_gil", 0);

  /* "lupa/_lupa.pyx":1390
 * 
 * cdef int py_call_with_gil(lua_State* L, py_object *py_obj) with gil:
 *     cdef LuaRuntime runtime = None             # <<<<<<<<<<<<<<
 *     try:
 *         runtime = <LuaRuntime?>py_obj.runtime
 */
  __Pyx_INCREF(Py_None);
  __pyx_v_runtime = ((struct __pyx_obj_4lupa_5_lupa_LuaRuntime *)Py_None);

  /* "lupa/_lupa.pyx":1391
 * cdef int py_call_with_gil(lua_State* L, py_object *py_obj) with gil:
 *     cdef LuaRuntime runtime = None
 *     try:             # <<<<<<<<<<<<<<
 *         runtime = <LuaRuntime?>py_obj.runtime
 *         return call_python(runtime, L, py_obj)
 */
  {
    __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":1392
 *     cdef LuaRuntime runtime = None
 *     try:
 *         runtime = <LuaRuntime?>py_obj.runtime             # <<<<<<<<<<<<<<
 *         return call_python(runtime, L, py_obj)
 *     except:
 */
      __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":1393
 *     try:
 *         runtime = <LuaRuntime?>py_obj.runtime
 *         return call_python(runtime, L, py_obj)             # <<<<<<<<<<<<<<
 *     except:
 *         try: runtime.store_raised_exception()
 */
      __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 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1393; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      __pyx_r = __pyx_t_5;
      goto __pyx_L7_try_return;
    }
    __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_L10_try_end;
    __pyx_L3_error:;
    __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;

    /* "lupa/_lupa.pyx":1394
 *         runtime = <LuaRuntime?>py_obj.runtime
 *         return call_python(runtime, L, py_obj)
 *     except:             # <<<<<<<<<<<<<<
 *         try: runtime.store_raised_exception()
 *         finally: 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_6, &__pyx_t_7) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1394; __pyx_clineno = __LINE__; goto __pyx_L5_except_error;}
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_GOTREF(__pyx_t_6);
      __Pyx_GOTREF(__pyx_t_7);

      /* "lupa/_lupa.pyx":1395
 *         return call_python(runtime, L, py_obj)
 *     except:
 *         try: runtime.store_raised_exception()             # <<<<<<<<<<<<<<
 *         finally: return -1
 * 
 */
      /*try:*/ {
        __pyx_t_8 = __pyx_f_4lupa_5_lupa_10LuaRuntime_store_raised_exception(__pyx_v_runtime); if (unlikely(__pyx_t_8 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1395; __pyx_clineno = __LINE__; goto __pyx_L16_error;}
      }

      /* "lupa/_lupa.pyx":1396
 *     except:
 *         try: runtime.store_raised_exception()
 *         finally: return -1             # <<<<<<<<<<<<<<
 * 
 * cdef int py_object_call(lua_State* L) nogil:
 */
      /*finally:*/ {
        /*normal exit:*/{
          __pyx_r = -1;
          __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
          __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
          __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
          goto __pyx_L6_except_return;
        }
        /*exception exit:*/{
          __pyx_L16_error:;
          __pyx_t_9 = 0; __pyx_t_10 = 0; __pyx_t_11 = 0; __pyx_t_12 = 0; __pyx_t_13 = 0; __pyx_t_14 = 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_r = -1;
            __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
            __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
            __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
            goto __pyx_L20_return;
          }
          __pyx_L20_return:;
          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_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
          __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
          __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0;
          __pyx_t_12 = 0; __pyx_t_13 = 0; __pyx_t_14 = 0;
          goto __pyx_L6_except_return;
        }
      }
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      goto __pyx_L4_exception_handled;
    }
    __pyx_L5_except_error:;
    __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;
    __pyx_L4_exception_handled:;
    __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);
    __pyx_L10_try_end:;
  }

  /* "lupa/_lupa.pyx":1389
 *     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
 *     try:
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_WriteUnraisable("lupa._lupa.py_call_with_gil", __pyx_clineno, __pyx_lineno, __pyx_filename, 0);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_runtime);
  __Pyx_RefNannyFinishContext();
  #ifdef WITH_THREAD
  PyGILState_Release(__pyx_gilstate_save);
  #endif
  return __pyx_r;
}

/* "lupa/_lupa.pyx":1398
 *         finally: return -1
 * 
 * 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":1399
 * 
 * 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":1400
 * 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":1401
 *     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, __pyx_k_not_a_python_object);
    goto __pyx_L0;
  }

  /* "lupa/_lupa.pyx":1403
 *         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.luaL_error(L, 'error during Python call')  # never returns!
 */
  __pyx_v_result = __pyx_f_4lupa_5_lupa_py_call_with_gil(__pyx_v_L, __pyx_v_py_obj);

  /* "lupa/_lupa.pyx":1404
 * 
 *     result = py_call_with_gil(L, py_obj)
 *     if result < 0:             # <<<<<<<<<<<<<<
 *         return lua.luaL_error(L, 'error during Python call')  # never returns!
 *     return result
 */
  __pyx_t_1 = ((__pyx_v_result < 0) != 0);
  if (__pyx_t_1) {

    /* "lupa/_lupa.pyx":1405
 *     result = py_call_with_gil(L, py_obj)
 *     if result < 0:
 *         return lua.luaL_error(L, 'error during Python call')  # never returns!             # <<<<<<<<<<<<<<
 *     return result
 * 
 */
    __pyx_r = luaL_error(__pyx_v_L, __pyx_k_error_during_Python_call);
    goto __pyx_L0;
  }

  /* "lupa/_lupa.pyx":1406
 *     if result < 0:
 *         return lua.luaL_error(L, 'error during Python call')  # never returns!
 *     return result             # <<<<<<<<<<<<<<
 * 
 * # str() support for Python objects
 */
  __pyx_r = __pyx_v_result;
  goto __pyx_L0;

  /* "lupa/_lupa.pyx":1398
 *         finally: return -1
 * 
 * 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":1410
 * # 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;
  PyObject *__pyx_t_5 = NULL;
  int __pyx_t_6;
  int __pyx_t_7;
  char *__pyx_t_8;
  Py_ssize_t __pyx_t_9;
  PyObject *__pyx_t_10 = NULL;
  int __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;
  #ifdef WITH_THREAD
  PyGILState_STATE __pyx_gilstate_save = PyGILState_Ensure();
  #endif
  __Pyx_RefNannySetupContext("py_str_with_gil", 0);

  /* "lupa/_lupa.pyx":1412
 * 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_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":1413
 *     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":1414
 *     try:
 *         runtime = <LuaRuntime?>py_obj.runtime
 *         s = str(<object>py_obj.obj)             # <<<<<<<<<<<<<<
 *         if isinstance(s, unicode):
 *             s = (<unicode>s).encode(runtime._encoding)
 */
      __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1414; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_INCREF(((PyObject *)__pyx_v_py_obj->obj));
      PyTuple_SET_ITEM(__pyx_t_4, 0, ((PyObject *)__pyx_v_py_obj->obj));
      __Pyx_GIVEREF(((PyObject *)__pyx_v_py_obj->obj));
      __pyx_t_5 = __Pyx_PyObject_Call(((PyObject *)((PyObject*)(&PyString_Type))), __pyx_t_4, NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1414; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __pyx_v_s = __pyx_t_5;
      __pyx_t_5 = 0;

      /* "lupa/_lupa.pyx":1415
 *         runtime = <LuaRuntime?>py_obj.runtime
 *         s = str(<object>py_obj.obj)
 *         if isinstance(s, unicode):             # <<<<<<<<<<<<<<
 *             s = (<unicode>s).encode(runtime._encoding)
 *         else:
 */
      __pyx_t_6 = PyUnicode_Check(__pyx_v_s); 
      __pyx_t_7 = (__pyx_t_6 != 0);
      if (__pyx_t_7) {

        /* "lupa/_lupa.pyx":1416
 *         s = str(<object>py_obj.obj)
 *         if isinstance(s, unicode):
 *             s = (<unicode>s).encode(runtime._encoding)             # <<<<<<<<<<<<<<
 *         else:
 *             assert isinstance(s, bytes)
 */
        if (unlikely(__pyx_v_s == Py_None)) {
          PyErr_Format(PyExc_AttributeError, "'NoneType' object has no attribute '%s'", "encode");
          {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1416; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        }
        __pyx_t_8 = __Pyx_PyObject_AsString(__pyx_v_runtime->_encoding); if (unlikely((!__pyx_t_8) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1416; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        __pyx_t_5 = PyUnicode_AsEncodedString(((PyObject*)__pyx_v_s), __pyx_t_8, NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1416; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        __Pyx_GOTREF(__pyx_t_5);
        __Pyx_DECREF_SET(__pyx_v_s, __pyx_t_5);
        __pyx_t_5 = 0;
        goto __pyx_L11;
      }
      /*else*/ {

        /* "lupa/_lupa.pyx":1418
 *             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
 */
        #ifndef CYTHON_WITHOUT_ASSERTIONS
        if (unlikely(!Py_OptimizeFlag)) {
          __pyx_t_7 = PyBytes_Check(__pyx_v_s); 
          if (unlikely(!(__pyx_t_7 != 0))) {
            PyErr_SetNone(PyExc_AssertionError);
            {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1418; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
          }
        }
        #endif
      }
      __pyx_L11:;

      /* "lupa/_lupa.pyx":1419
 *         else:
 *             assert isinstance(s, bytes)
 *         lua.lua_pushlstring(L, <bytes>s, len(<bytes>s))             # <<<<<<<<<<<<<<
 *         return 1 # returning 1 value
 *     except:
 */
      __pyx_t_8 = __Pyx_PyObject_AsString(__pyx_v_s); if (unlikely((!__pyx_t_8) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1419; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      if (unlikely(__pyx_v_s == Py_None)) {
        PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()");
        {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1419; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
      __pyx_t_9 = PyBytes_GET_SIZE(((PyObject*)__pyx_v_s)); if (unlikely(__pyx_t_9 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1419; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      lua_pushlstring(__pyx_v_L, __pyx_t_8, __pyx_t_9);

      /* "lupa/_lupa.pyx":1420
 *             assert isinstance(s, bytes)
 *         lua.lua_pushlstring(L, <bytes>s, len(<bytes>s))
 *         return 1 # returning 1 value             # <<<<<<<<<<<<<<
 *     except:
 *         try: runtime.store_raised_exception()
 */
      __pyx_r = 1;
      goto __pyx_L7_try_return;
    }
    __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_L10_try_end;
    __pyx_L3_error:;
    __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;

    /* "lupa/_lupa.pyx":1421
 *         lua.lua_pushlstring(L, <bytes>s, len(<bytes>s))
 *         return 1 # returning 1 value
 *     except:             # <<<<<<<<<<<<<<
 *         try: runtime.store_raised_exception()
 *         finally: return -1
 */
    /*except:*/ {
      __Pyx_AddTraceback("lupa._lupa.py_str_with_gil", __pyx_clineno, __pyx_lineno, __pyx_filename);
      if (__Pyx_GetException(&__pyx_t_5, &__pyx_t_4, &__pyx_t_10) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1421; __pyx_clineno = __LINE__; goto __pyx_L5_except_error;}
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_GOTREF(__pyx_t_10);

      /* "lupa/_lupa.pyx":1422
 *         return 1 # returning 1 value
 *     except:
 *         try: runtime.store_raised_exception()             # <<<<<<<<<<<<<<
 *         finally: return -1
 * 
 */
      /*try:*/ {
        if (unlikely(!__pyx_v_runtime)) { __Pyx_RaiseUnboundLocalError("runtime"); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1422; __pyx_clineno = __LINE__; goto __pyx_L17_error;} }
        __pyx_t_11 = __pyx_f_4lupa_5_lupa_10LuaRuntime_store_raised_exception(__pyx_v_runtime); if (unlikely(__pyx_t_11 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1422; __pyx_clineno = __LINE__; goto __pyx_L17_error;}
      }

      /* "lupa/_lupa.pyx":1423
 *     except:
 *         try: runtime.store_raised_exception()
 *         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_5); __pyx_t_5 = 0;
          __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
          goto __pyx_L6_except_return;
        }
        /*exception exit:*/{
          __pyx_L17_error:;
          __pyx_t_12 = 0; __pyx_t_13 = 0; __pyx_t_14 = 0; __pyx_t_15 = 0; __pyx_t_16 = 0; __pyx_t_17 = 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_r = -1;
            __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
            __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
            __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
            goto __pyx_L21_return;
          }
          __pyx_L21_return:;
          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_12); __pyx_t_12 = 0;
          __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0;
          __Pyx_XDECREF(__pyx_t_14); __pyx_t_14 = 0;
          __pyx_t_15 = 0; __pyx_t_16 = 0; __pyx_t_17 = 0;
          goto __pyx_L6_except_return;
        }
      }
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
      goto __pyx_L4_exception_handled;
    }
    __pyx_L5_except_error:;
    __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;
    __pyx_L4_exception_handled:;
    __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);
    __pyx_L10_try_end:;
  }

  /* "lupa/_lupa.pyx":1410
 * # 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_5);
  __Pyx_XDECREF(__pyx_t_10);
  __Pyx_WriteUnraisable("lupa._lupa.py_str_with_gil", __pyx_clineno, __pyx_lineno, __pyx_filename, 0);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_runtime);
  __Pyx_XDECREF(__pyx_v_s);
  __Pyx_RefNannyFinishContext();
  #ifdef WITH_THREAD
  PyGILState_Release(__pyx_gilstate_save);
  #endif
  return __pyx_r;
}

/* "lupa/_lupa.pyx":1425
 *         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":1426
 * 
 * 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":1427
 * 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":1428
 *     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, __pyx_k_not_a_python_object);
    goto __pyx_L0;
  }

  /* "lupa/_lupa.pyx":1429
 *     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.luaL_error(L, 'error during Python str() call')  # never returns!
 */
  __pyx_v_result = __pyx_f_4lupa_5_lupa_py_str_with_gil(__pyx_v_L, __pyx_v_py_obj);

  /* "lupa/_lupa.pyx":1430
 *         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.luaL_error(L, 'error during Python str() call')  # never returns!
 *     return result
 */
  __pyx_t_1 = ((__pyx_v_result < 0) != 0);
  if (__pyx_t_1) {

    /* "lupa/_lupa.pyx":1431
 *     result = py_str_with_gil(L, py_obj)
 *     if result < 0:
 *         return lua.luaL_error(L, 'error during Python str() call')  # never returns!             # <<<<<<<<<<<<<<
 *     return result
 * 
 */
    __pyx_r = luaL_error(__pyx_v_L, __pyx_k_error_during_Python_str_call);
    goto __pyx_L0;
  }

  /* "lupa/_lupa.pyx":1432
 *     if result < 0:
 *         return lua.luaL_error(L, 'error during Python str() call')  # never returns!
 *     return result             # <<<<<<<<<<<<<<
 * 
 * # item access for Python objects
 */
  __pyx_r = __pyx_v_result;
  goto __pyx_L0;

  /* "lupa/_lupa.pyx":1425
 *         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":1452
 * #   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":1454
 * 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_filename = __pyx_f[0]; __pyx_lineno = 1454; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyObject_GetItem(((PyObject *)__pyx_v_py_obj->obj), __pyx_t_1); if (unlikely(__pyx_t_2 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1454; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "lupa/_lupa.pyx":1453
 * 
 * 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 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1453; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_r = __pyx_t_3;
  goto __pyx_L0;

  /* "lupa/_lupa.pyx":1452
 * #   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":1456
 *                      (<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":1457
 * 
 * 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_filename = __pyx_f[0]; __pyx_lineno = 1457; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 1457; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 1457; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "lupa/_lupa.pyx":1458
 * 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":1456
 *                      (<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":1460
 *     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;
  int __pyx_t_5;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("getattr_for_lua", 0);

  /* "lupa/_lupa.pyx":1461
 * 
 * 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":1462
 * 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_filename = __pyx_f[0]; __pyx_lineno = 1462; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_attr_name = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "lupa/_lupa.pyx":1463
 *     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":1464
 *     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_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1464; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_INCREF(__pyx_v_obj);
    PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_obj);
    __Pyx_GIVEREF(__pyx_v_obj);
    __Pyx_INCREF(__pyx_v_attr_name);
    PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_v_attr_name);
    __Pyx_GIVEREF(__pyx_v_attr_name);
    __pyx_t_4 = __Pyx_PyObject_Call(__pyx_v_runtime->_attribute_getter, __pyx_t_1, NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1464; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_v_value = __pyx_t_4;
    __pyx_t_4 = 0;

    /* "lupa/_lupa.pyx":1465
 *     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_5 = __pyx_f_4lupa_5_lupa_py_to_lua(__pyx_v_runtime, __pyx_v_L, __pyx_v_value, NULL); if (unlikely(__pyx_t_5 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1465; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_r = __pyx_t_5;
    goto __pyx_L0;
  }

  /* "lupa/_lupa.pyx":1466
 *         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)
 *     return py_to_lua(runtime, L, getattr(obj, attr_name))
 */
  __pyx_t_3 = (__pyx_v_runtime->_attribute_filter != Py_None);
  __pyx_t_2 = (__pyx_t_3 != 0);
  if (__pyx_t_2) {

    /* "lupa/_lupa.pyx":1467
 *         return py_to_lua(runtime, L, value)
 *     if runtime._attribute_filter is not None:
 *         attr_name = runtime._attribute_filter(obj, attr_name, False)             # <<<<<<<<<<<<<<
 *     return py_to_lua(runtime, L, getattr(obj, attr_name))
 * 
 */
    __pyx_t_4 = PyTuple_New(3); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1467; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_INCREF(__pyx_v_obj);
    PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_v_obj);
    __Pyx_GIVEREF(__pyx_v_obj);
    __Pyx_INCREF(__pyx_v_attr_name);
    PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_v_attr_name);
    __Pyx_GIVEREF(__pyx_v_attr_name);
    __Pyx_INCREF(Py_False);
    PyTuple_SET_ITEM(__pyx_t_4, 2, Py_False);
    __Pyx_GIVEREF(Py_False);
    __pyx_t_1 = __Pyx_PyObject_Call(__pyx_v_runtime->_attribute_filter, __pyx_t_4, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1467; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_DECREF_SET(__pyx_v_attr_name, __pyx_t_1);
    __pyx_t_1 = 0;
    goto __pyx_L4;
  }
  __pyx_L4:;

  /* "lupa/_lupa.pyx":1468
 *     if runtime._attribute_filter is not None:
 *         attr_name = runtime._attribute_filter(obj, attr_name, False)
 *     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_filename = __pyx_f[0]; __pyx_lineno = 1468; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_5 = __pyx_f_4lupa_5_lupa_py_to_lua(__pyx_v_runtime, __pyx_v_L, __pyx_t_1, NULL); if (unlikely(__pyx_t_5 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1468; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_r = __pyx_t_5;
  goto __pyx_L0;

  /* "lupa/_lupa.pyx":1460
 *     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_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":1470
 *     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;
  int __pyx_t_5;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("setattr_for_lua", 0);

  /* "lupa/_lupa.pyx":1471
 * 
 * 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":1472
 * 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_filename = __pyx_f[0]; __pyx_lineno = 1472; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_attr_name = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "lupa/_lupa.pyx":1473
 *     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_filename = __pyx_f[0]; __pyx_lineno = 1473; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_attr_value = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "lupa/_lupa.pyx":1474
 *     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":1475
 *     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_t_1 = PyTuple_New(3); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1475; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_INCREF(__pyx_v_obj);
    PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_obj);
    __Pyx_GIVEREF(__pyx_v_obj);
    __Pyx_INCREF(__pyx_v_attr_name);
    PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_v_attr_name);
    __Pyx_GIVEREF(__pyx_v_attr_name);
    __Pyx_INCREF(__pyx_v_attr_value);
    PyTuple_SET_ITEM(__pyx_t_1, 2, __pyx_v_attr_value);
    __Pyx_GIVEREF(__pyx_v_attr_value);
    __pyx_t_4 = __Pyx_PyObject_Call(__pyx_v_runtime->_attribute_setter, __pyx_t_1, NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1475; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    goto __pyx_L3;
  }
  /*else*/ {

    /* "lupa/_lupa.pyx":1477
 *         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)
 *         setattr(obj, attr_name, attr_value)
 */
    __pyx_t_3 = (__pyx_v_runtime->_attribute_filter != Py_None);
    __pyx_t_2 = (__pyx_t_3 != 0);
    if (__pyx_t_2) {

      /* "lupa/_lupa.pyx":1478
 *     else:
 *         if runtime._attribute_filter is not None:
 *             attr_name = runtime._attribute_filter(obj, attr_name, True)             # <<<<<<<<<<<<<<
 *         setattr(obj, attr_name, attr_value)
 *     return 0
 */
      __pyx_t_4 = PyTuple_New(3); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1478; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_INCREF(__pyx_v_obj);
      PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_v_obj);
      __Pyx_GIVEREF(__pyx_v_obj);
      __Pyx_INCREF(__pyx_v_attr_name);
      PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_v_attr_name);
      __Pyx_GIVEREF(__pyx_v_attr_name);
      __Pyx_INCREF(Py_True);
      PyTuple_SET_ITEM(__pyx_t_4, 2, Py_True);
      __Pyx_GIVEREF(Py_True);
      __pyx_t_1 = __Pyx_PyObject_Call(__pyx_v_runtime->_attribute_filter, __pyx_t_4, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1478; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __Pyx_DECREF_SET(__pyx_v_attr_name, __pyx_t_1);
      __pyx_t_1 = 0;
      goto __pyx_L4;
    }
    __pyx_L4:;

    /* "lupa/_lupa.pyx":1479
 *         if runtime._attribute_filter is not None:
 *             attr_name = runtime._attribute_filter(obj, attr_name, True)
 *         setattr(obj, attr_name, attr_value)             # <<<<<<<<<<<<<<
 *     return 0
 * 
 */
    __pyx_t_5 = PyObject_SetAttr(__pyx_v_obj, __pyx_v_attr_name, __pyx_v_attr_value); if (unlikely(__pyx_t_5 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1479; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_L3:;

  /* "lupa/_lupa.pyx":1480
 *             attr_name = runtime._attribute_filter(obj, attr_name, True)
 *         setattr(obj, attr_name, attr_value)
 *     return 0             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_r = 0;
  goto __pyx_L0;

  /* "lupa/_lupa.pyx":1470
 *     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_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":1483
 * 
 * 
 * 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;
  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;
  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 = PyGILState_Ensure();
  #endif
  __Pyx_RefNannySetupContext("py_object_getindex_with_gil", 0);

  /* "lupa/_lupa.pyx":1485
 * 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_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":1486
 *     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":1487
 *     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:
 */
      if (((__pyx_v_py_obj->type_flags & __pyx_e_4lupa_5_lupa_OBJ_AS_INDEX) != 0)) {
        __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_v_runtime->_attribute_getter); if (unlikely(__pyx_t_5 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1487; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        __pyx_t_6 = (!__pyx_t_5);
        __pyx_t_5 = __pyx_t_6;
      } else {
        __pyx_t_5 = ((__pyx_v_py_obj->type_flags & __pyx_e_4lupa_5_lupa_OBJ_AS_INDEX) != 0);
      }
      if (__pyx_t_5) {

        /* "lupa/_lupa.pyx":1488
 *         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_7 = __pyx_f_4lupa_5_lupa_getitem_for_lua(__pyx_v_runtime, __pyx_v_L, __pyx_v_py_obj, 2); if (unlikely(__pyx_t_7 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1488; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        __pyx_r = __pyx_t_7;
        goto __pyx_L7_try_return;
      }
      /*else*/ {

        /* "lupa/_lupa.pyx":1490
 *             return getitem_for_lua(runtime, L, py_obj, 2)
 *         else:
 *             return getattr_for_lua(runtime, L, py_obj, 2)             # <<<<<<<<<<<<<<
 *     except:
 *         try: runtime.store_raised_exception()
 */
        __pyx_t_7 = __pyx_f_4lupa_5_lupa_getattr_for_lua(__pyx_v_runtime, __pyx_v_L, __pyx_v_py_obj, 2); if (unlikely(__pyx_t_7 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1490; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        __pyx_r = __pyx_t_7;
        goto __pyx_L7_try_return;
      }
    }
    __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_L10_try_end;
    __pyx_L3_error:;
    __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;

    /* "lupa/_lupa.pyx":1491
 *         else:
 *             return getattr_for_lua(runtime, L, py_obj, 2)
 *     except:             # <<<<<<<<<<<<<<
 *         try: runtime.store_raised_exception()
 *         finally: 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_8, &__pyx_t_9) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1491; __pyx_clineno = __LINE__; goto __pyx_L5_except_error;}
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_GOTREF(__pyx_t_8);
      __Pyx_GOTREF(__pyx_t_9);

      /* "lupa/_lupa.pyx":1492
 *             return getattr_for_lua(runtime, L, py_obj, 2)
 *     except:
 *         try: runtime.store_raised_exception()             # <<<<<<<<<<<<<<
 *         finally: return -1
 * 
 */
      /*try:*/ {
        if (unlikely(!__pyx_v_runtime)) { __Pyx_RaiseUnboundLocalError("runtime"); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1492; __pyx_clineno = __LINE__; goto __pyx_L17_error;} }
        __pyx_t_7 = __pyx_f_4lupa_5_lupa_10LuaRuntime_store_raised_exception(__pyx_v_runtime); if (unlikely(__pyx_t_7 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1492; __pyx_clineno = __LINE__; goto __pyx_L17_error;}
      }

      /* "lupa/_lupa.pyx":1493
 *     except:
 *         try: runtime.store_raised_exception()
 *         finally: return -1             # <<<<<<<<<<<<<<
 * 
 * cdef int py_object_getindex(lua_State* L) nogil:
 */
      /*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_9); __pyx_t_9 = 0;
          goto __pyx_L6_except_return;
        }
        /*exception exit:*/{
          __pyx_L17_error:;
          __pyx_t_10 = 0; __pyx_t_11 = 0; __pyx_t_12 = 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_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_r = -1;
            __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
            __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
            __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
            goto __pyx_L21_return;
          }
          __pyx_L21_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_10); __pyx_t_10 = 0;
          __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0;
          __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0;
          __pyx_t_13 = 0; __pyx_t_14 = 0; __pyx_t_15 = 0;
          goto __pyx_L6_except_return;
        }
      }
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
      goto __pyx_L4_exception_handled;
    }
    __pyx_L5_except_error:;
    __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;
    __pyx_L4_exception_handled:;
    __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);
    __pyx_L10_try_end:;
  }

  /* "lupa/_lupa.pyx":1483
 * 
 * 
 * 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_8);
  __Pyx_XDECREF(__pyx_t_9);
  __Pyx_WriteUnraisable("lupa._lupa.py_object_getindex_with_gil", __pyx_clineno, __pyx_lineno, __pyx_filename, 0);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_runtime);
  __Pyx_RefNannyFinishContext();
  #ifdef WITH_THREAD
  PyGILState_Release(__pyx_gilstate_save);
  #endif
  return __pyx_r;
}

/* "lupa/_lupa.pyx":1495
 *         finally: 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":1496
 * 
 * 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":1497
 * 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":1498
 *     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, __pyx_k_not_a_python_object);
    goto __pyx_L0;
  }

  /* "lupa/_lupa.pyx":1499
 *     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.luaL_error(L, 'error reading Python attribute/item')  # 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":1500
 *         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.luaL_error(L, 'error reading Python attribute/item')  # never returns!
 *     return result
 */
  __pyx_t_1 = ((__pyx_v_result < 0) != 0);
  if (__pyx_t_1) {

    /* "lupa/_lupa.pyx":1501
 *     result = py_object_getindex_with_gil(L, py_obj)
 *     if result < 0:
 *         return lua.luaL_error(L, 'error reading Python attribute/item')  # never returns!             # <<<<<<<<<<<<<<
 *     return result
 * 
 */
    __pyx_r = luaL_error(__pyx_v_L, __pyx_k_error_reading_Python_attribute_i);
    goto __pyx_L0;
  }

  /* "lupa/_lupa.pyx":1502
 *     if result < 0:
 *         return lua.luaL_error(L, 'error reading Python attribute/item')  # never returns!
 *     return result             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_r = __pyx_v_result;
  goto __pyx_L0;

  /* "lupa/_lupa.pyx":1495
 *         finally: 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":1505
 * 
 * 
 * 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;
  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;
  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 = PyGILState_Ensure();
  #endif
  __Pyx_RefNannySetupContext("py_object_setindex_with_gil", 0);

  /* "lupa/_lupa.pyx":1507
 * 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_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":1508
 *     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":1509
 *     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:
 */
      if (((__pyx_v_py_obj->type_flags & __pyx_e_4lupa_5_lupa_OBJ_AS_INDEX) != 0)) {
        __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_v_runtime->_attribute_setter); if (unlikely(__pyx_t_5 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1509; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        __pyx_t_6 = (!__pyx_t_5);
        __pyx_t_5 = __pyx_t_6;
      } else {
        __pyx_t_5 = ((__pyx_v_py_obj->type_flags & __pyx_e_4lupa_5_lupa_OBJ_AS_INDEX) != 0);
      }
      if (__pyx_t_5) {

        /* "lupa/_lupa.pyx":1510
 *         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_7 = __pyx_f_4lupa_5_lupa_setitem_for_lua(__pyx_v_runtime, __pyx_v_L, __pyx_v_py_obj, 2, 3); if (unlikely(__pyx_t_7 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1510; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        __pyx_r = __pyx_t_7;
        goto __pyx_L7_try_return;
      }
      /*else*/ {

        /* "lupa/_lupa.pyx":1512
 *             return setitem_for_lua(runtime, L, py_obj, 2, 3)
 *         else:
 *             return setattr_for_lua(runtime, L, py_obj, 2, 3)             # <<<<<<<<<<<<<<
 *     except:
 *         try: runtime.store_raised_exception()
 */
        __pyx_t_7 = __pyx_f_4lupa_5_lupa_setattr_for_lua(__pyx_v_runtime, __pyx_v_L, __pyx_v_py_obj, 2, 3); if (unlikely(__pyx_t_7 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1512; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        __pyx_r = __pyx_t_7;
        goto __pyx_L7_try_return;
      }
    }
    __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_L10_try_end;
    __pyx_L3_error:;
    __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;

    /* "lupa/_lupa.pyx":1513
 *         else:
 *             return setattr_for_lua(runtime, L, py_obj, 2, 3)
 *     except:             # <<<<<<<<<<<<<<
 *         try: runtime.store_raised_exception()
 *         finally: 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_8, &__pyx_t_9) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1513; __pyx_clineno = __LINE__; goto __pyx_L5_except_error;}
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_GOTREF(__pyx_t_8);
      __Pyx_GOTREF(__pyx_t_9);

      /* "lupa/_lupa.pyx":1514
 *             return setattr_for_lua(runtime, L, py_obj, 2, 3)
 *     except:
 *         try: runtime.store_raised_exception()             # <<<<<<<<<<<<<<
 *         finally: return -1
 * 
 */
      /*try:*/ {
        if (unlikely(!__pyx_v_runtime)) { __Pyx_RaiseUnboundLocalError("runtime"); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1514; __pyx_clineno = __LINE__; goto __pyx_L17_error;} }
        __pyx_t_7 = __pyx_f_4lupa_5_lupa_10LuaRuntime_store_raised_exception(__pyx_v_runtime); if (unlikely(__pyx_t_7 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1514; __pyx_clineno = __LINE__; goto __pyx_L17_error;}
      }

      /* "lupa/_lupa.pyx":1515
 *     except:
 *         try: runtime.store_raised_exception()
 *         finally: return -1             # <<<<<<<<<<<<<<
 * 
 * cdef int py_object_setindex(lua_State* L) nogil:
 */
      /*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_9); __pyx_t_9 = 0;
          goto __pyx_L6_except_return;
        }
        /*exception exit:*/{
          __pyx_L17_error:;
          __pyx_t_10 = 0; __pyx_t_11 = 0; __pyx_t_12 = 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_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_r = -1;
            __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
            __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
            __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
            goto __pyx_L21_return;
          }
          __pyx_L21_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_10); __pyx_t_10 = 0;
          __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0;
          __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0;
          __pyx_t_13 = 0; __pyx_t_14 = 0; __pyx_t_15 = 0;
          goto __pyx_L6_except_return;
        }
      }
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
      goto __pyx_L4_exception_handled;
    }
    __pyx_L5_except_error:;
    __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;
    __pyx_L4_exception_handled:;
    __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);
    __pyx_L10_try_end:;
  }

  /* "lupa/_lupa.pyx":1505
 * 
 * 
 * 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_8);
  __Pyx_XDECREF(__pyx_t_9);
  __Pyx_WriteUnraisable("lupa._lupa.py_object_setindex_with_gil", __pyx_clineno, __pyx_lineno, __pyx_filename, 0);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_runtime);
  __Pyx_RefNannyFinishContext();
  #ifdef WITH_THREAD
  PyGILState_Release(__pyx_gilstate_save);
  #endif
  return __pyx_r;
}

/* "lupa/_lupa.pyx":1517
 *         finally: 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":1518
 * 
 * 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":1519
 * 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":1520
 *     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, __pyx_k_not_a_python_object);
    goto __pyx_L0;
  }

  /* "lupa/_lupa.pyx":1521
 *     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.luaL_error(L, 'error writing Python attribute/item')  # 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":1522
 *         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.luaL_error(L, 'error writing Python attribute/item')  # never returns!
 *     return result
 */
  __pyx_t_1 = ((__pyx_v_result < 0) != 0);
  if (__pyx_t_1) {

    /* "lupa/_lupa.pyx":1523
 *     result = py_object_setindex_with_gil(L, py_obj)
 *     if result < 0:
 *         return lua.luaL_error(L, 'error writing Python attribute/item')  # never returns!             # <<<<<<<<<<<<<<
 *     return result
 * 
 */
    __pyx_r = luaL_error(__pyx_v_L, __pyx_k_error_writing_Python_attribute_i);
    goto __pyx_L0;
  }

  /* "lupa/_lupa.pyx":1524
 *     if result < 0:
 *         return lua.luaL_error(L, 'error writing Python attribute/item')  # never returns!
 *     return result             # <<<<<<<<<<<<<<
 * 
 * # special methods for Lua wrapped Python objects
 */
  __pyx_r = __pyx_v_result;
  goto __pyx_L0;

  /* "lupa/_lupa.pyx":1517
 *         finally: 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":1538
 * ## # 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":1539
 * 
 * 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":1540
 * 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:
 */
    luaL_argerror(__pyx_v_L, 2, __pyx_k_invalid_arguments);
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "lupa/_lupa.pyx":1541
 *     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":1542
 *         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":1543
 *     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
 * 
 */
    luaL_argerror(__pyx_v_L, 1, __pyx_k_not_a_python_object);
    goto __pyx_L4;
  }
  __pyx_L4:;

  /* "lupa/_lupa.pyx":1544
 *     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":1538
 * ## # 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":1546
 *     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":1547
 * 
 * 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":1548
 * 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;
  }
  /*else*/ {

    /* "lupa/_lupa.pyx":1550
 *         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:
 */
    __pyx_r = __pyx_f_4lupa_5_lupa_unpack_wrapped_pyfunction(__pyx_v_L, __pyx_v_n);
    goto __pyx_L0;
  }

  /* "lupa/_lupa.pyx":1546
 *     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":1552
 *         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 = PyGILState_Ensure();
  #endif
  __Pyx_RefNannySetupContext("py_wrap_object_protocol_with_gil", 0);

  /* "lupa/_lupa.pyx":1554
 * 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)
 */
  {
    if (__pyx_t_1||__pyx_t_2||__pyx_t_3); else {/*mark used*/};
    /*try:*/ {

      /* "lupa/_lupa.pyx":1555
 *     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":1556
 *     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()
 */
      __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;
    }
    goto __pyx_L10_try_end;
    __pyx_L7_try_return:;
    goto __pyx_L0;
    __pyx_L10_try_end:;
  }

  /* "lupa/_lupa.pyx":1552
 *         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
  PyGILState_Release(__pyx_gilstate_save);
  #endif
  return __pyx_r;
}

/* "lupa/_lupa.pyx":1561
 *         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":1562
 * 
 * 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":1563
 * 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.luaL_error(L, 'error during type adaptation')  # 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":1564
 *     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.luaL_error(L, 'error during type adaptation')  # never returns!
 *     return result
 */
  __pyx_t_1 = ((__pyx_v_result < 0) != 0);
  if (__pyx_t_1) {

    /* "lupa/_lupa.pyx":1565
 *     result = py_wrap_object_protocol_with_gil(L, py_obj, type_flags)
 *     if result < 0:
 *         return lua.luaL_error(L, 'error during type adaptation')  # never returns!             # <<<<<<<<<<<<<<
 *     return result
 * 
 */
    __pyx_r = luaL_error(__pyx_v_L, __pyx_k_error_during_type_adaptation);
    goto __pyx_L0;
  }

  /* "lupa/_lupa.pyx":1566
 *     if result < 0:
 *         return lua.luaL_error(L, 'error during type adaptation')  # never returns!
 *     return result             # <<<<<<<<<<<<<<
 * 
 * cdef int py_as_attrgetter(lua_State* L) nogil:
 */
  __pyx_r = __pyx_v_result;
  goto __pyx_L0;

  /* "lupa/_lupa.pyx":1561
 *         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":1568
 *     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":1569
 * 
 * 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":1568
 *     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":1571
 *     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":1572
 * 
 * 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":1571
 *     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":1574
 *     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":1575
 * 
 * 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":1576
 * 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":1577
 *     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":1574
 *     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":1581
 * # 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":1582
 * 
 * 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":1583
 * 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.luaL_error(L, 'error creating an iterator')  # 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":1584
 *     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.luaL_error(L, 'error creating an iterator')  # never returns!
 *     return result
 */
  __pyx_t_1 = ((__pyx_v_result < 0) != 0);
  if (__pyx_t_1) {

    /* "lupa/_lupa.pyx":1585
 *     result = py_iter_with_gil(L, py_obj, 0)
 *     if result < 0:
 *         return lua.luaL_error(L, 'error creating an iterator')  # never returns!             # <<<<<<<<<<<<<<
 *     return result
 * 
 */
    __pyx_r = luaL_error(__pyx_v_L, __pyx_k_error_creating_an_iterator);
    goto __pyx_L0;
  }

  /* "lupa/_lupa.pyx":1586
 *     if result < 0:
 *         return lua.luaL_error(L, 'error creating an iterator')  # never returns!
 *     return result             # <<<<<<<<<<<<<<
 * 
 * cdef int py_iterex(lua_State* L) nogil:
 */
  __pyx_r = __pyx_v_result;
  goto __pyx_L0;

  /* "lupa/_lupa.pyx":1581
 * # 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":1588
 *     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":1589
 * 
 * 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":1590
 * 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.luaL_error(L, 'error creating an iterator')  # 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":1591
 *     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.luaL_error(L, 'error creating an iterator')  # never returns!
 *     return result
 */
  __pyx_t_1 = ((__pyx_v_result < 0) != 0);
  if (__pyx_t_1) {

    /* "lupa/_lupa.pyx":1592
 *     result = py_iter_with_gil(L, py_obj, OBJ_UNPACK_TUPLE)
 *     if result < 0:
 *         return lua.luaL_error(L, 'error creating an iterator')  # never returns!             # <<<<<<<<<<<<<<
 *     return result
 * 
 */
    __pyx_r = luaL_error(__pyx_v_L, __pyx_k_error_creating_an_iterator);
    goto __pyx_L0;
  }

  /* "lupa/_lupa.pyx":1593
 *     if result < 0:
 *         return lua.luaL_error(L, 'error creating an iterator')  # never returns!
 *     return result             # <<<<<<<<<<<<<<
 * 
 * cdef int py_enumerate(lua_State* L) nogil:
 */
  __pyx_r = __pyx_v_result;
  goto __pyx_L0;

  /* "lupa/_lupa.pyx":1588
 *     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":1595
 *     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":1596
 * 
 * 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":1597
 * 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:
 */
    luaL_argerror(__pyx_v_L, 3, __pyx_k_invalid_arguments);
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "lupa/_lupa.pyx":1598
 *     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":1599
 *         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":1600
 *     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)
 */
    luaL_argerror(__pyx_v_L, 1, __pyx_k_not_a_python_object);
    goto __pyx_L4;
  }
  __pyx_L4:;

  /* "lupa/_lupa.pyx":1601
 *     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":1602
 *         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.luaL_error(L, 'error creating an iterator with enumerate()')  # 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":1603
 *     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.luaL_error(L, 'error creating an iterator with enumerate()')  # never returns!
 *     return result
 */
  __pyx_t_1 = ((__pyx_v_result < 0) != 0);
  if (__pyx_t_1) {

    /* "lupa/_lupa.pyx":1604
 *     result = py_enumerate_with_gil(L, py_obj, start)
 *     if result < 0:
 *         return lua.luaL_error(L, 'error creating an iterator with enumerate()')  # never returns!             # <<<<<<<<<<<<<<
 *     return result
 * 
 */
    __pyx_r = luaL_error(__pyx_v_L, __pyx_k_error_creating_an_iterator_with);
    goto __pyx_L0;
  }

  /* "lupa/_lupa.pyx":1605
 *     if result < 0:
 *         return lua.luaL_error(L, 'error creating an iterator with enumerate()')  # never returns!
 *     return result             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_r = __pyx_v_result;
  goto __pyx_L0;

  /* "lupa/_lupa.pyx":1595
 *     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":1608
 * 
 * 
 * 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 = PyGILState_Ensure();
  #endif
  __Pyx_RefNannySetupContext("py_enumerate_with_gil", 0);

  /* "lupa/_lupa.pyx":1610
 * 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_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":1611
 *     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":1612
 *     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_filename = __pyx_f[0]; __pyx_lineno = 1612; __pyx_clineno = __LINE__; goto __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":1613
 *         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()
 */
      __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;
    }
    __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_L10_try_end;
    __pyx_L3_error:;
    __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;

    /* "lupa/_lupa.pyx":1614
 *         obj = iter(<object>py_obj.obj)
 *         return py_push_iterator(runtime, L, obj, OBJ_ENUMERATOR, start - 1.0)
 *     except:             # <<<<<<<<<<<<<<
 *         try: runtime.store_raised_exception()
 *         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_filename = __pyx_f[0]; __pyx_lineno = 1614; __pyx_clineno = __LINE__; goto __pyx_L5_except_error;}
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_GOTREF(__pyx_t_6);

      /* "lupa/_lupa.pyx":1615
 *         return py_push_iterator(runtime, L, obj, OBJ_ENUMERATOR, start - 1.0)
 *     except:
 *         try: runtime.store_raised_exception()             # <<<<<<<<<<<<<<
 *         finally: return -1
 * 
 */
      /*try:*/ {
        if (unlikely(!__pyx_v_runtime)) { __Pyx_RaiseUnboundLocalError("runtime"); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1615; __pyx_clineno = __LINE__; goto __pyx_L16_error;} }
        __pyx_t_7 = __pyx_f_4lupa_5_lupa_10LuaRuntime_store_raised_exception(__pyx_v_runtime); if (unlikely(__pyx_t_7 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1615; __pyx_clineno = __LINE__; goto __pyx_L16_error;}
      }

      /* "lupa/_lupa.pyx":1616
 *     except:
 *         try: runtime.store_raised_exception()
 *         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;
        }
        /*exception exit:*/{
          __pyx_L16_error:;
          __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_L20_return;
          }
          __pyx_L20_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_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      goto __pyx_L4_exception_handled;
    }
    __pyx_L5_except_error:;
    __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;
    __pyx_L4_exception_handled:;
    __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);
    __pyx_L10_try_end:;
  }

  /* "lupa/_lupa.pyx":1608
 * 
 * 
 * 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, 0);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_runtime);
  __Pyx_XDECREF(__pyx_v_obj);
  __Pyx_RefNannyFinishContext();
  #ifdef WITH_THREAD
  PyGILState_Release(__pyx_gilstate_save);
  #endif
  return __pyx_r;
}

/* "lupa/_lupa.pyx":1618
 *         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 = PyGILState_Ensure();
  #endif
  __Pyx_RefNannySetupContext("py_iter_with_gil", 0);

  /* "lupa/_lupa.pyx":1620
 * 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_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             # <<<<<<<<<<<<<<
 *         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":1622
 *     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_filename = __pyx_f[0]; __pyx_lineno = 1622; __pyx_clineno = __LINE__; goto __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":1623
 *         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()
 */
      __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;
    }
    __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_L10_try_end;
    __pyx_L3_error:;
    __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;

    /* "lupa/_lupa.pyx":1624
 *         obj = iter(<object>py_obj.obj)
 *         return py_push_iterator(runtime, L, obj, type_flags, 0.0)
 *     except:             # <<<<<<<<<<<<<<
 *         try: runtime.store_raised_exception()
 *         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_filename = __pyx_f[0]; __pyx_lineno = 1624; __pyx_clineno = __LINE__; goto __pyx_L5_except_error;}
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_GOTREF(__pyx_t_6);

      /* "lupa/_lupa.pyx":1625
 *         return py_push_iterator(runtime, L, obj, type_flags, 0.0)
 *     except:
 *         try: runtime.store_raised_exception()             # <<<<<<<<<<<<<<
 *         finally: return -1
 * 
 */
      /*try:*/ {
        if (unlikely(!__pyx_v_runtime)) { __Pyx_RaiseUnboundLocalError("runtime"); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1625; __pyx_clineno = __LINE__; goto __pyx_L16_error;} }
        __pyx_t_7 = __pyx_f_4lupa_5_lupa_10LuaRuntime_store_raised_exception(__pyx_v_runtime); if (unlikely(__pyx_t_7 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1625; __pyx_clineno = __LINE__; goto __pyx_L16_error;}
      }

      /* "lupa/_lupa.pyx":1626
 *     except:
 *         try: runtime.store_raised_exception()
 *         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;
        }
        /*exception exit:*/{
          __pyx_L16_error:;
          __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_L20_return;
          }
          __pyx_L20_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_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      goto __pyx_L4_exception_handled;
    }
    __pyx_L5_except_error:;
    __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;
    __pyx_L4_exception_handled:;
    __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);
    __pyx_L10_try_end:;
  }

  /* "lupa/_lupa.pyx":1618
 *         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, 0);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_runtime);
  __Pyx_XDECREF(__pyx_v_obj);
  __Pyx_RefNannyFinishContext();
  #ifdef WITH_THREAD
  PyGILState_Release(__pyx_gilstate_save);
  #endif
  return __pyx_r;
}

/* "lupa/_lupa.pyx":1628
 *         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":1631
 *                           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":1632
 *     # 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":1634
 *     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":1635
 *     # 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);
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "lupa/_lupa.pyx":1636
 *     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":1637
 *         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":1638
 *     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":1640
 *         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":1641
 *     # 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);
    goto __pyx_L5;
  }
  /*else*/ {

    /* "lupa/_lupa.pyx":1643
 *         lua.lua_pushnumber(L, initial_value)
 *     else:
 *         lua.lua_pushnil(L)             # <<<<<<<<<<<<<<
 *     return 3
 * 
 */
    lua_pushnil(__pyx_v_L);
  }
  __pyx_L5:;

  /* "lupa/_lupa.pyx":1644
 *     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":1628
 *         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":1646
 *     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":1648
 * 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":1649
 *     # 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":1650
 *     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, __pyx_k_not_a_python_object);
    goto __pyx_L0;
  }

  /* "lupa/_lupa.pyx":1651
 *     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.luaL_error(L, 'error while calling next(iterator)')  # 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":1652
 *         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.luaL_error(L, 'error while calling next(iterator)')  # never returns!
 *     return result
 */
  __pyx_t_1 = ((__pyx_v_result < 0) != 0);
  if (__pyx_t_1) {

    /* "lupa/_lupa.pyx":1653
 *     result = py_iter_next_with_gil(L, py_obj)
 *     if result < 0:
 *         return lua.luaL_error(L, 'error while calling next(iterator)')  # never returns!             # <<<<<<<<<<<<<<
 *     return result
 * 
 */
    __pyx_r = luaL_error(__pyx_v_L, __pyx_k_error_while_calling_next_iterato);
    goto __pyx_L0;
  }

  /* "lupa/_lupa.pyx":1654
 *     if result < 0:
 *         return lua.luaL_error(L, 'error while calling next(iterator)')  # 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":1646
 *     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":1656
 *     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;
  struct __pyx_opt_args_4lupa_5_lupa_push_lua_arguments __pyx_t_13;
  Py_ssize_t __pyx_t_14;
  struct __pyx_opt_args_4lupa_5_lupa_py_to_lua __pyx_t_15;
  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 = PyGILState_Ensure();
  #endif
  __Pyx_RefNannySetupContext("py_iter_next_with_gil", 0);

  /* "lupa/_lupa.pyx":1658
 * 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_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":1659
 *     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":1660
 *     try:
 *         runtime = <LuaRuntime?>py_iter.runtime
 *         try:             # <<<<<<<<<<<<<<
 *             obj = next(<object>py_iter.obj)
 *         except StopIteration:
 */
      {
        __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":1661
 *         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_filename = __pyx_f[0]; __pyx_lineno = 1661; __pyx_clineno = __LINE__; goto __pyx_L11_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;
        }
        __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_L18_try_end;
        __pyx_L11_error:;
        __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
        __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;

        /* "lupa/_lupa.pyx":1662
 *         try:
 *             obj = next(<object>py_iter.obj)
 *         except StopIteration:             # <<<<<<<<<<<<<<
 *             lua.lua_pushnil(L)
 *             return 1
 */
        __pyx_t_9 = 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_filename = __pyx_f[0]; __pyx_lineno = 1662; __pyx_clineno = __LINE__; goto __pyx_L13_except_error;}
          __Pyx_GOTREF(__pyx_t_8);
          __Pyx_GOTREF(__pyx_t_4);
          __Pyx_GOTREF(__pyx_t_10);

          /* "lupa/_lupa.pyx":1663
 *             obj = next(<object>py_iter.obj)
 *         except StopIteration:
 *             lua.lua_pushnil(L)             # <<<<<<<<<<<<<<
 *             return 1
 * 
 */
          lua_pushnil(__pyx_v_L);

          /* "lupa/_lupa.pyx":1664
 *         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_L14_except_return;
          __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
          __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
          __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
          goto __pyx_L12_exception_handled;
        }
        goto __pyx_L13_except_error;
        __pyx_L13_except_error:;
        __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_L14_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_L12_exception_handled:;
        __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);
        __pyx_L18_try_end:;
      }

      /* "lupa/_lupa.pyx":1668
 *         # 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":1669
 *         # 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":1670
 *         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":1671
 *         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;
        goto __pyx_L21;
      }
      __pyx_L21:;

      /* "lupa/_lupa.pyx":1672
 *             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)
 */
      if (((__pyx_v_py_iter->type_flags & __pyx_e_4lupa_5_lupa_OBJ_UNPACK_TUPLE) != 0)) {
        __pyx_t_11 = PyTuple_Check(__pyx_v_obj); 
        __pyx_t_12 = __pyx_t_11;
      } else {
        __pyx_t_12 = ((__pyx_v_py_iter->type_flags & __pyx_e_4lupa_5_lupa_OBJ_UNPACK_TUPLE) != 0);
      }
      if (__pyx_t_12) {

        /* "lupa/_lupa.pyx":1674
 *         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_13.__pyx_n = 1;
        __pyx_t_13.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_13); if (unlikely(__pyx_t_9 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1674; __pyx_clineno = __LINE__; goto __pyx_L3_error;}

        /* "lupa/_lupa.pyx":1675
 *             # 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_filename = __pyx_f[0]; __pyx_lineno = 1675; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        }
        __pyx_t_14 = PyTuple_GET_SIZE(((PyObject*)__pyx_v_obj)); if (unlikely(__pyx_t_14 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1675; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        __pyx_t_10 = PyInt_FromSsize_t(__pyx_t_14); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1675; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        __Pyx_GOTREF(__pyx_t_10);
        __pyx_v_result = __pyx_t_10;
        __pyx_t_10 = 0;
        goto __pyx_L22;
      }
      /*else*/ {

        /* "lupa/_lupa.pyx":1677
 *             result = len(<tuple>obj)
 *         else:
 *             result = py_to_lua(runtime, L, obj, wrap_none=not allow_nil)             # <<<<<<<<<<<<<<
 *             if result < 1:
 *                 return -1
 */
        __pyx_t_15.__pyx_n = 1;
        __pyx_t_15.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_15); if (unlikely(__pyx_t_9 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1677; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        __pyx_t_10 = __Pyx_PyInt_From_int(__pyx_t_9); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1677; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        __Pyx_GOTREF(__pyx_t_10);
        __pyx_v_result = __pyx_t_10;
        __pyx_t_10 = 0;

        /* "lupa/_lupa.pyx":1678
 *         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_filename = __pyx_f[0]; __pyx_lineno = 1678; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        __pyx_t_12 = __Pyx_PyObject_IsTrue(__pyx_t_10); if (unlikely(__pyx_t_12 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1678; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
        if (__pyx_t_12) {

          /* "lupa/_lupa.pyx":1679
 *             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;
        }
      }
      __pyx_L22:;

      /* "lupa/_lupa.pyx":1680
 *             if result < 1:
 *                 return -1
 *         if py_iter.type_flags & OBJ_ENUMERATOR:             # <<<<<<<<<<<<<<
 *             result += 1
 *         return result
 */
      __pyx_t_12 = ((__pyx_v_py_iter->type_flags & __pyx_e_4lupa_5_lupa_OBJ_ENUMERATOR) != 0);
      if (__pyx_t_12) {

        /* "lupa/_lupa.pyx":1681
 *                 return -1
 *         if py_iter.type_flags & OBJ_ENUMERATOR:
 *             result += 1             # <<<<<<<<<<<<<<
 *         return result
 *     except:
 */
        __pyx_t_10 = PyNumber_InPlaceAdd(__pyx_v_result, __pyx_int_1); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1681; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        __Pyx_GOTREF(__pyx_t_10);
        __Pyx_DECREF_SET(__pyx_v_result, __pyx_t_10);
        __pyx_t_10 = 0;
        goto __pyx_L24;
      }
      __pyx_L24:;

      /* "lupa/_lupa.pyx":1682
 *         if py_iter.type_flags & OBJ_ENUMERATOR:
 *             result += 1
 *         return result             # <<<<<<<<<<<<<<
 *     except:
 *         try: runtime.store_raised_exception()
 */
      __pyx_t_9 = __Pyx_PyInt_As_int(__pyx_v_result); if (unlikely((__pyx_t_9 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1682; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      __pyx_r = __pyx_t_9;
      goto __pyx_L7_try_return;
    }
    __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_L10_try_end;
    __pyx_L3_error:;
    __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
    __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;

    /* "lupa/_lupa.pyx":1683
 *             result += 1
 *         return result
 *     except:             # <<<<<<<<<<<<<<
 *         try: runtime.store_raised_exception()
 *         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_filename = __pyx_f[0]; __pyx_lineno = 1683; __pyx_clineno = __LINE__; goto __pyx_L5_except_error;}
      __Pyx_GOTREF(__pyx_t_10);
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_GOTREF(__pyx_t_8);

      /* "lupa/_lupa.pyx":1684
 *         return result
 *     except:
 *         try: runtime.store_raised_exception()             # <<<<<<<<<<<<<<
 *         finally: return -1
 * 
 */
      /*try:*/ {
        if (unlikely(!__pyx_v_runtime)) { __Pyx_RaiseUnboundLocalError("runtime"); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1684; __pyx_clineno = __LINE__; goto __pyx_L30_error;} }
        __pyx_t_9 = __pyx_f_4lupa_5_lupa_10LuaRuntime_store_raised_exception(__pyx_v_runtime); if (unlikely(__pyx_t_9 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1684; __pyx_clineno = __LINE__; goto __pyx_L30_error;}
      }

      /* "lupa/_lupa.pyx":1685
 *     except:
 *         try: runtime.store_raised_exception()
 *         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;
        }
        /*exception exit:*/{
          __pyx_L30_error:;
          __pyx_t_7 = 0; __pyx_t_6 = 0; __pyx_t_5 = 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_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_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_8); __pyx_t_8 = 0;
            __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
            goto __pyx_L34_return;
          }
          __pyx_L34_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_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_16 = 0; __pyx_t_17 = 0; __pyx_t_18 = 0;
          goto __pyx_L6_except_return;
        }
      }
      __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      goto __pyx_L4_exception_handled;
    }
    __pyx_L5_except_error:;
    __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;
    __pyx_L4_exception_handled:;
    __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);
    __pyx_L10_try_end:;
  }

  /* "lupa/_lupa.pyx":1656
 *     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, 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
  PyGILState_Release(__pyx_gilstate_save);
  #endif
  return __pyx_r;
}

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)) {
    Py_DECREF(o); o = 0;
  }
  return o;
}

static void __pyx_tp_dealloc_4lupa_5_lupa_FastRLock(PyObject *o) {
  #if PY_VERSION_HEX >= 0x030400a1
  if (unlikely(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);
    ++Py_REFCNT(o);
    __pyx_pw_4lupa_5_lupa_9FastRLock_3__dealloc__(o);
    --Py_REFCNT(o);
    PyErr_Restore(etype, eval, etb);
  }
  (*Py_TYPE(o)->tp_free)(o);
}

static PyMethodDef __pyx_methods_4lupa_5_lupa_FastRLock[] = {
  {__Pyx_NAMESTR("acquire"), (PyCFunction)__pyx_pw_4lupa_5_lupa_9FastRLock_5acquire, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(__pyx_doc_4lupa_5_lupa_9FastRLock_4acquire)},
  {__Pyx_NAMESTR("release"), (PyCFunction)__pyx_pw_4lupa_5_lupa_9FastRLock_7release, METH_NOARGS, __Pyx_DOCSTR(__pyx_doc_4lupa_5_lupa_9FastRLock_6release)},
  {__Pyx_NAMESTR("__enter__"), (PyCFunction)__pyx_pw_4lupa_5_lupa_9FastRLock_9__enter__, METH_NOARGS, __Pyx_DOCSTR(__pyx_doc_4lupa_5_lupa_9FastRLock_8__enter__)},
  {__Pyx_NAMESTR("__exit__"), (PyCFunction)__pyx_pw_4lupa_5_lupa_9FastRLock_11__exit__, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(__pyx_doc_4lupa_5_lupa_9FastRLock_10__exit__)},
  {__Pyx_NAMESTR("_is_owned"), (PyCFunction)__pyx_pw_4lupa_5_lupa_9FastRLock_13_is_owned, METH_NOARGS, __Pyx_DOCSTR(__pyx_doc_4lupa_5_lupa_9FastRLock_12_is_owned)},
  {0, 0, 0, 0}
};

static PyTypeObject __pyx_type_4lupa_5_lupa_FastRLock = {
  PyVarObject_HEAD_INIT(0, 0)
  __Pyx_NAMESTR("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*/
  0, /*tp_print*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  #if PY_MAJOR_VERSION < 3
  0, /*tp_compare*/
  #else
  0, /*reserved*/
  #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*/
  __Pyx_DOCSTR("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*/
  #if PY_VERSION_HEX >= 0x02060000
  0, /*tp_version_tag*/
  #endif
  #if PY_VERSION_HEX >= 0x030400a1
  0, /*tp_finalize*/
  #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)) {
    Py_DECREF(o); o = 0;
  }
  return o;
}

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 PY_VERSION_HEX >= 0x030400a1
  if (unlikely(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);
    ++Py_REFCNT(o);
    __pyx_pw_4lupa_5_lupa_10LuaRuntime_3__dealloc__(o);
    --Py_REFCNT(o);
    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 PyMethodDef __pyx_methods_4lupa_5_lupa_LuaRuntime[] = {
  {__Pyx_NAMESTR("eval"), (PyCFunction)__pyx_pw_4lupa_5_lupa_10LuaRuntime_5eval, METH_O, __Pyx_DOCSTR(__pyx_doc_4lupa_5_lupa_10LuaRuntime_4eval)},
  {__Pyx_NAMESTR("execute"), (PyCFunction)__pyx_pw_4lupa_5_lupa_10LuaRuntime_7execute, METH_O, __Pyx_DOCSTR(__pyx_doc_4lupa_5_lupa_10LuaRuntime_6execute)},
  {__Pyx_NAMESTR("require"), (PyCFunction)__pyx_pw_4lupa_5_lupa_10LuaRuntime_9require, METH_O, __Pyx_DOCSTR(__pyx_doc_4lupa_5_lupa_10LuaRuntime_8require)},
  {__Pyx_NAMESTR("globals"), (PyCFunction)__pyx_pw_4lupa_5_lupa_10LuaRuntime_11globals, METH_NOARGS, __Pyx_DOCSTR(__pyx_doc_4lupa_5_lupa_10LuaRuntime_10globals)},
  {__Pyx_NAMESTR("table"), (PyCFunction)__pyx_pw_4lupa_5_lupa_10LuaRuntime_13table, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(__pyx_doc_4lupa_5_lupa_10LuaRuntime_12table)},
  {__Pyx_NAMESTR("table_from"), (PyCFunction)__pyx_pw_4lupa_5_lupa_10LuaRuntime_15table_from, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(__pyx_doc_4lupa_5_lupa_10LuaRuntime_14table_from)},
  {0, 0, 0, 0}
};

static PyTypeObject __pyx_type_4lupa_5_lupa_LuaRuntime = {
  PyVarObject_HEAD_INIT(0, 0)
  __Pyx_NAMESTR("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*/
  0, /*tp_print*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  #if PY_MAJOR_VERSION < 3
  0, /*tp_compare*/
  #else
  0, /*reserved*/
  #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*/
  __Pyx_DOCSTR("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 that.\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*/
  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_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*/
  #if PY_VERSION_HEX >= 0x02060000
  0, /*tp_version_tag*/
  #endif
  #if PY_VERSION_HEX >= 0x030400a1
  0, /*tp_finalize*/
  #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 PY_VERSION_HEX >= 0x030400a1
  if (unlikely(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);
    ++Py_REFCNT(o);
    __pyx_pw_4lupa_5_lupa_10_LuaObject_3__dealloc__(o);
    --Py_REFCNT(o);
    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 = 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[] = {
  {__Pyx_NAMESTR("__getattr__"), (PyCFunction)__pyx_pw_4lupa_5_lupa_10_LuaObject_17__getattr__, METH_O|METH_COEXIST, __Pyx_DOCSTR(0)},
  {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
  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
  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
  0, /*nb_oct*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*nb_hex*/
  #endif
  0, /*nb_inplace_add*/
  0, /*nb_inplace_subtract*/
  0, /*nb_inplace_multiply*/
  #if PY_MAJOR_VERSION < 3
  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*/
  #if PY_VERSION_HEX >= 0x02050000
  0, /*nb_index*/
  #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)
  __Pyx_NAMESTR("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*/
  0, /*tp_print*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  #if PY_MAJOR_VERSION < 3
  0, /*tp_compare*/
  #else
  0, /*reserved*/
  #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*/
  __Pyx_DOCSTR("_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*/
  #if PY_VERSION_HEX >= 0x02060000
  0, /*tp_version_tag*/
  #endif
  #if PY_VERSION_HEX >= 0x030400a1
  0, /*tp_finalize*/
  #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[] = {
  {__Pyx_NAMESTR("keys"), (PyCFunction)__pyx_pw_4lupa_5_lupa_9_LuaTable_3keys, METH_NOARGS, __Pyx_DOCSTR(__pyx_doc_4lupa_5_lupa_9_LuaTable_2keys)},
  {__Pyx_NAMESTR("values"), (PyCFunction)__pyx_pw_4lupa_5_lupa_9_LuaTable_5values, METH_NOARGS, __Pyx_DOCSTR(__pyx_doc_4lupa_5_lupa_9_LuaTable_4values)},
  {__Pyx_NAMESTR("items"), (PyCFunction)__pyx_pw_4lupa_5_lupa_9_LuaTable_7items, METH_NOARGS, __Pyx_DOCSTR(__pyx_doc_4lupa_5_lupa_9_LuaTable_6items)},
  {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)
  __Pyx_NAMESTR("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*/
  0, /*tp_print*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  #if PY_MAJOR_VERSION < 3
  0, /*tp_compare*/
  #else
  0, /*reserved*/
  #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*/
  #if PY_VERSION_HEX >= 0x02060000
  0, /*tp_version_tag*/
  #endif
  #if PY_VERSION_HEX >= 0x030400a1
  0, /*tp_finalize*/
  #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[] = {
  {__Pyx_NAMESTR("coroutine"), (PyCFunction)__pyx_pw_4lupa_5_lupa_12_LuaFunction_1coroutine, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(__pyx_doc_4lupa_5_lupa_12_LuaFunction_coroutine)},
  {0, 0, 0, 0}
};

static PyTypeObject __pyx_type_4lupa_5_lupa__LuaFunction = {
  PyVarObject_HEAD_INIT(0, 0)
  __Pyx_NAMESTR("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*/
  0, /*tp_print*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  #if PY_MAJOR_VERSION < 3
  0, /*tp_compare*/
  #else
  0, /*reserved*/
  #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*/
  __Pyx_DOCSTR("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*/
  #if PY_VERSION_HEX >= 0x02060000
  0, /*tp_version_tag*/
  #endif
  #if PY_VERSION_HEX >= 0x030400a1
  0, /*tp_finalize*/
  #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[] = {
  {0, 0, 0, 0}
};

static PyTypeObject __pyx_type_4lupa_5_lupa__LuaCoroutineFunction = {
  PyVarObject_HEAD_INIT(0, 0)
  __Pyx_NAMESTR("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*/
  0, /*tp_print*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  #if PY_MAJOR_VERSION < 3
  0, /*tp_compare*/
  #else
  0, /*reserved*/
  #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*/
  __Pyx_DOCSTR("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*/
  #if PY_VERSION_HEX >= 0x02060000
  0, /*tp_version_tag*/
  #endif
  #if PY_VERSION_HEX >= 0x030400a1
  0, /*tp_finalize*/
  #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 PyMethodDef __pyx_methods_4lupa_5_lupa__LuaThread[] = {
  {__Pyx_NAMESTR("__next__"), (PyCFunction)__pyx_pw_4lupa_5_lupa_10_LuaThread_3__next__, METH_NOARGS|METH_COEXIST, __Pyx_DOCSTR(0)},
  {__Pyx_NAMESTR("send"), (PyCFunction)__pyx_pw_4lupa_5_lupa_10_LuaThread_5send, METH_O, __Pyx_DOCSTR(__pyx_doc_4lupa_5_lupa_10_LuaThread_4send)},
  {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
  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
  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
  0, /*nb_oct*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*nb_hex*/
  #endif
  0, /*nb_inplace_add*/
  0, /*nb_inplace_subtract*/
  0, /*nb_inplace_multiply*/
  #if PY_MAJOR_VERSION < 3
  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*/
  #if PY_VERSION_HEX >= 0x02050000
  0, /*nb_index*/
  #endif
};

static PyTypeObject __pyx_type_4lupa_5_lupa__LuaThread = {
  PyVarObject_HEAD_INIT(0, 0)
  __Pyx_NAMESTR("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*/
  0, /*tp_print*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  #if PY_MAJOR_VERSION < 3
  0, /*tp_compare*/
  #else
  0, /*reserved*/
  #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*/
  __Pyx_DOCSTR("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*/
  #if PY_VERSION_HEX >= 0x02060000
  0, /*tp_version_tag*/
  #endif
  #if PY_VERSION_HEX >= 0x030400a1
  0, /*tp_finalize*/
  #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)) {
    Py_DECREF(o); o = 0;
  }
  return o;
}

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);
    ++Py_REFCNT(o);
    __pyx_pw_4lupa_5_lupa_8_LuaIter_3__dealloc__(o);
    --Py_REFCNT(o);
    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 PyMethodDef __pyx_methods_4lupa_5_lupa__LuaIter[] = {
  {__Pyx_NAMESTR("__next__"), (PyCFunction)__pyx_pw_4lupa_5_lupa_8_LuaIter_9__next__, METH_NOARGS|METH_COEXIST, __Pyx_DOCSTR(0)},
  {0, 0, 0, 0}
};

static PyTypeObject __pyx_type_4lupa_5_lupa__LuaIter = {
  PyVarObject_HEAD_INIT(0, 0)
  __Pyx_NAMESTR("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*/
  0, /*tp_print*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  #if PY_MAJOR_VERSION < 3
  0, /*tp_compare*/
  #else
  0, /*reserved*/
  #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*/
  #if PY_VERSION_HEX >= 0x02060000
  0, /*tp_version_tag*/
  #endif
  #if PY_VERSION_HEX >= 0x030400a1
  0, /*tp_finalize*/
  #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)) {
    Py_DECREF(o); o = 0;
  }
  return o;
}

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[] = {
  {0, 0, 0, 0}
};

static PyTypeObject __pyx_type_4lupa_5_lupa__PyProtocolWrapper = {
  PyVarObject_HEAD_INIT(0, 0)
  __Pyx_NAMESTR("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*/
  0, /*tp_print*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  #if PY_MAJOR_VERSION < 3
  0, /*tp_compare*/
  #else
  0, /*reserved*/
  #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*/
  __Pyx_DOCSTR("_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*/
  #if PY_VERSION_HEX >= 0x02060000
  0, /*tp_version_tag*/
  #endif
  #if PY_VERSION_HEX >= 0x030400a1
  0, /*tp_finalize*/
  #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)
  __Pyx_NAMESTR("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*/
  0, /*tp_print*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  #if PY_MAJOR_VERSION < 3
  0, /*tp_compare*/
  #else
  0, /*reserved*/
  #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*/
  #if PY_VERSION_HEX >= 0x02060000
  0, /*tp_version_tag*/
  #endif
  #if PY_VERSION_HEX >= 0x030400a1
  0, /*tp_finalize*/
  #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)
  __Pyx_NAMESTR("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*/
  0, /*tp_print*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  #if PY_MAJOR_VERSION < 3
  0, /*tp_compare*/
  #else
  0, /*reserved*/
  #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*/
  #if PY_VERSION_HEX >= 0x02060000
  0, /*tp_version_tag*/
  #endif
  #if PY_VERSION_HEX >= 0x030400a1
  0, /*tp_finalize*/
  #endif
};

static PyMethodDef __pyx_methods[] = {
  {0, 0, 0, 0}
};

#if PY_MAJOR_VERSION >= 3
static struct PyModuleDef __pyx_moduledef = {
  #if PY_VERSION_HEX < 0x03020000
    { PyObject_HEAD_INIT(NULL) NULL, 0, NULL },
  #else
    PyModuleDef_HEAD_INIT,
  #endif
    __Pyx_NAMESTR("_lupa"),
    __Pyx_DOCSTR(__pyx_k_A_fast_Python_wrapper_around_Lu), /* m_doc */
    -1, /* m_size */
    __pyx_methods /* m_methods */,
    NULL, /* m_reload */
    NULL, /* m_traverse */
    NULL, /* m_clear */
    NULL /* m_free */
};
#endif

static __Pyx_StringTabEntry __pyx_string_tab[] = {
  {&__pyx_n_s_AttributeError, __pyx_k_AttributeError, sizeof(__pyx_k_AttributeError), 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_n_s_Exception, __pyx_k_Exception, sizeof(__pyx_k_Exception), 0, 0, 1, 1},
  {&__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_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_LuaError, __pyx_k_LuaError, sizeof(__pyx_k_LuaError), 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_LuaRuntime, __pyx_k_LuaRuntime, sizeof(__pyx_k_LuaRuntime), 0, 0, 1, 1},
  {&__pyx_n_s_LuaSyntaxError, __pyx_k_LuaSyntaxError, sizeof(__pyx_k_LuaSyntaxError), 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_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_kp_s_Users_ma_projects_immunio_agent, __pyx_k_Users_ma_projects_immunio_agent, sizeof(__pyx_k_Users_ma_projects_immunio_agent), 0, 0, 1, 0},
  {&__pyx_n_s_ValueError, __pyx_k_ValueError, sizeof(__pyx_k_ValueError), 0, 0, 1, 1},
  {&__pyx_n_b__18, __pyx_k__18, sizeof(__pyx_k__18), 0, 0, 0, 1},
  {&__pyx_n_u__18, __pyx_k__18, sizeof(__pyx_k__18), 0, 1, 0, 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_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_collections, __pyx_k_collections, sizeof(__pyx_k_collections), 0, 0, 1, 1},
  {&__pyx_n_s_coroutine, __pyx_k_coroutine, sizeof(__pyx_k_coroutine), 0, 0, 1, 1},
  {&__pyx_n_s_decode, __pyx_k_decode, sizeof(__pyx_k_decode), 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_enumerate, __pyx_k_enumerate, sizeof(__pyx_k_enumerate), 0, 0, 1, 1},
  {&__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_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_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_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_kp_s_globals_not_defined, __pyx_k_globals_not_defined, sizeof(__pyx_k_globals_not_defined), 0, 0, 1, 0},
  {&__pyx_n_s_import, __pyx_k_import, sizeof(__pyx_k_import), 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_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_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_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_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_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_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_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_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_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_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_n_s_setattr, __pyx_k_setattr, sizeof(__pyx_k_setattr), 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_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_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 int __Pyx_InitCachedBuiltins(void) {
  __pyx_builtin_ImportError = __Pyx_GetBuiltinName(__pyx_n_s_ImportError); if (!__pyx_builtin_ImportError) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 46; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_builtin_Exception = __Pyx_GetBuiltinName(__pyx_n_s_Exception); if (!__pyx_builtin_Exception) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 67; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_builtin_RuntimeError = __Pyx_GetBuiltinName(__pyx_n_s_RuntimeError); if (!__pyx_builtin_RuntimeError) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 39; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_builtin_ValueError = __Pyx_GetBuiltinName(__pyx_n_s_ValueError); if (!__pyx_builtin_ValueError) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 202; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_builtin_TypeError = __Pyx_GetBuiltinName(__pyx_n_s_TypeError); if (!__pyx_builtin_TypeError) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 210; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_builtin_eval = __Pyx_GetBuiltinName(__pyx_n_s_eval); if (!__pyx_builtin_eval) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 380; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_builtin_range = __Pyx_GetBuiltinName(__pyx_n_s_range); if (!__pyx_builtin_range) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 447; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_builtin_UnicodeDecodeError = __Pyx_GetBuiltinName(__pyx_n_s_UnicodeDecodeError); if (!__pyx_builtin_UnicodeDecodeError) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 575; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_builtin_object = __Pyx_GetBuiltinName(__pyx_n_s_object); if (!__pyx_builtin_object) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 590; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_builtin_AttributeError = __Pyx_GetBuiltinName(__pyx_n_s_AttributeError); if (!__pyx_builtin_AttributeError) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 610; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_builtin_StopIteration = __Pyx_GetBuiltinName(__pyx_n_s_StopIteration); if (!__pyx_builtin_StopIteration) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 880; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_builtin_MemoryError = __Pyx_GetBuiltinName(__pyx_n_s_MemoryError); if (!__pyx_builtin_MemoryError) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1212; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_builtin_enumerate = __Pyx_GetBuiltinName(__pyx_n_s_enumerate); if (!__pyx_builtin_enumerate) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1269; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_builtin_KeyError = __Pyx_GetBuiltinName(__pyx_n_s_KeyError); if (!__pyx_builtin_KeyError) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1326; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  return 0;
  __pyx_L1_error:;
  return -1;
}

static int __Pyx_InitCachedConstants(void) {
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__Pyx_InitCachedConstants", 0);

  /* "/Users/ma/projects/immunio/agent-python/immunio/agent/deps/lupa/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_filename = __pyx_f[1]; __pyx_lineno = 39; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple_);
  __Pyx_GIVEREF(__pyx_tuple_);

  /* "/Users/ma/projects/immunio/agent-python/immunio/agent/deps/lupa/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_tuple__2 = PyTuple_Pack(1, __pyx_kp_s_cannot_release_un_acquired_lock); if (unlikely(!__pyx_tuple__2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 51; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__2);
  __Pyx_GIVEREF(__pyx_tuple__2);

  /* "lupa/_lupa.pyx":195
 *         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_tuple__3 = PyTuple_Pack(1, __pyx_kp_s_Failed_to_initialise_Lua_runtime); if (unlikely(!__pyx_tuple__3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 195; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__3);
  __Pyx_GIVEREF(__pyx_tuple__3);

  /* "lupa/_lupa.pyx":202
 *         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_filename = __pyx_f[0]; __pyx_lineno = 202; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__4);
  __Pyx_GIVEREF(__pyx_tuple__4);

  /* "lupa/_lupa.pyx":217
 *                     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_filename = __pyx_f[0]; __pyx_lineno = 217; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__5);
  __Pyx_GIVEREF(__pyx_tuple__5);

  /* "lupa/_lupa.pyx":219
 *                 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_filename = __pyx_f[0]; __pyx_lineno = 219; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__6);
  __Pyx_GIVEREF(__pyx_tuple__6);

  /* "lupa/_lupa.pyx":267
 *         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_filename = __pyx_f[0]; __pyx_lineno = 267; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__7);
  __Pyx_GIVEREF(__pyx_tuple__7);

  /* "lupa/_lupa.pyx":273
 *             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_tuple__8 = PyTuple_Pack(1, __pyx_kp_s_require_is_not_defined); if (unlikely(!__pyx_tuple__8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 273; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__8);
  __Pyx_GIVEREF(__pyx_tuple__8);

  /* "lupa/_lupa.pyx":290
 *             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_tuple__9 = PyTuple_Pack(1, __pyx_kp_s_globals_not_defined); if (unlikely(!__pyx_tuple__9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 290; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__9);
  __Pyx_GIVEREF(__pyx_tuple__9);

  /* "lupa/_lupa.pyx":411
 *     """
 *     @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_filename = __pyx_f[0]; __pyx_lineno = 411; __pyx_clineno = __LINE__; goto __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_VARARGS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__10, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_Users_ma_projects_immunio_agent, __pyx_n_s_wrapper, 411, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 411; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "lupa/_lupa.pyx":423
 *     """
 *     @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_filename = __pyx_f[0]; __pyx_lineno = 423; __pyx_clineno = __LINE__; goto __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_VARARGS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__12, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_Users_ma_projects_immunio_agent, __pyx_n_s_wrapper, 423, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__13)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 423; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "lupa/_lupa.pyx":463
 * 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_tuple__14 = PyTuple_Pack(1, __pyx_kp_s_Failed_to_acquire_thread_lock); if (unlikely(!__pyx_tuple__14)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 463; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__14);
  __Pyx_GIVEREF(__pyx_tuple__14);

  /* "lupa/_lupa.pyx":484
 * 
 *     def __init__(self):
 *         raise TypeError("Type cannot be instantiated manually")             # <<<<<<<<<<<<<<
 * 
 *     def __dealloc__(self):
 */
  __pyx_tuple__15 = PyTuple_Pack(1, __pyx_kp_s_Type_cannot_be_instantiated_manu); if (unlikely(!__pyx_tuple__15)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 484; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__15);
  __Pyx_GIVEREF(__pyx_tuple__15);

  /* "lupa/_lupa.pyx":505
 *         if lua.lua_isnil(L, -1):
 *             lua.lua_pop(L, 1)
 *             raise LuaError("lost reference")             # <<<<<<<<<<<<<<
 * 
 *     def __call__(self, *args):
 */
  __pyx_tuple__16 = PyTuple_Pack(1, __pyx_kp_s_lost_reference); if (unlikely(!__pyx_tuple__16)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 505; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__16);
  __Pyx_GIVEREF(__pyx_tuple__16);

  /* "lupa/_lupa.pyx":541
 *     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__17 = PyTuple_Pack(1, __pyx_kp_s_iteration_is_only_supported_for); if (unlikely(!__pyx_tuple__17)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 541; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__17);
  __Pyx_GIVEREF(__pyx_tuple__17);

  /* "lupa/_lupa.pyx":610
 *             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
 */
  __pyx_tuple__19 = PyTuple_Pack(1, __pyx_kp_s_item_attribute_access_not_suppor); if (unlikely(!__pyx_tuple__19)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 610; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__19);
  __Pyx_GIVEREF(__pyx_tuple__19);

  /* "lupa/_lupa.pyx":766
 *             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__20 = PyTuple_Pack(1, __pyx_kp_s_Lua_object_is_not_a_function); if (unlikely(!__pyx_tuple__20)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 766; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__20);
  __Pyx_GIVEREF(__pyx_tuple__20);

  /* "lupa/_lupa.pyx":825
 *         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__21 = PyTuple_Pack(1, __pyx_kp_s_can_t_send_non_None_value_to_a_j); if (unlikely(!__pyx_tuple__21)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 825; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__21);
  __Pyx_GIVEREF(__pyx_tuple__21);

  /* "lupa/_lupa.pyx":960
 *                 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_tuple__22 = PyTuple_Pack(1, __pyx_kp_s_lost_reference); if (unlikely(!__pyx_tuple__22)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 960; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__22);
  __Pyx_GIVEREF(__pyx_tuple__22);

  /* "lupa/_lupa.pyx":1026
 *         self._type_flags = 0
 *     def __init__(self):
 *         raise TypeError("Type cannot be instantiated from Python")             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_tuple__23 = PyTuple_Pack(1, __pyx_kp_s_Type_cannot_be_instantiated_from); if (unlikely(!__pyx_tuple__23)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1026; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__23);
  __Pyx_GIVEREF(__pyx_tuple__23);

  /* "lupa/_lupa.pyx":1140
 *     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_tuple__24 = PyTuple_Pack(1, __pyx_kp_s_cannot_mix_objects_from_differen); if (unlikely(!__pyx_tuple__24)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1140; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__24);
  __Pyx_GIVEREF(__pyx_tuple__24);

  /* "lupa/_lupa.pyx":1202
 *         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__25 = PyTuple_Pack(1, __pyx_kp_s_byte_string_input_has_unknown_en); if (unlikely(!__pyx_tuple__25)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1202; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__25);
  __Pyx_GIVEREF(__pyx_tuple__25);

  /* "lupa/_lupa.pyx":1353
 * 
 *     if not py_obj:
 *         raise TypeError("not a python object")             # <<<<<<<<<<<<<<
 * 
 *     f = <object>py_obj.obj
 */
  __pyx_tuple__26 = PyTuple_Pack(1, __pyx_kp_s_not_a_python_object); if (unlikely(!__pyx_tuple__26)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1353; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__26);
  __Pyx_GIVEREF(__pyx_tuple__26);

  /* "lupa/_lupa.pyx":77
 * 
 * 
 * def lua_type(obj):             # <<<<<<<<<<<<<<
 *     """
 *     Return the Lua type name of a wrapped object as string, as provided
 */
  __pyx_tuple__27 = 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__27)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 77; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__27);
  __Pyx_GIVEREF(__pyx_tuple__27);
  __pyx_codeobj__28 = (PyObject*)__Pyx_PyCode_New(1, 0, 6, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__27, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_Users_ma_projects_immunio_agent, __pyx_n_s_lua_type, 77, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__28)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 77; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "lupa/_lupa.pyx":391
 * # from Lua scripts
 * 
 * def unpacks_lua_table(func):             # <<<<<<<<<<<<<<
 *     """
 *     A decorator to make the decorated function receive kwargs
 */
  __pyx_tuple__29 = PyTuple_Pack(3, __pyx_n_s_func, __pyx_n_s_wrapper, __pyx_n_s_wrapper); if (unlikely(!__pyx_tuple__29)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 391; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__29);
  __Pyx_GIVEREF(__pyx_tuple__29);
  __pyx_codeobj__30 = (PyObject*)__Pyx_PyCode_New(1, 0, 3, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__29, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_Users_ma_projects_immunio_agent, __pyx_n_s_unpacks_lua_table, 391, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__30)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 391; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "lupa/_lupa.pyx":417
 * 
 * 
 * def unpacks_lua_table_method(meth):             # <<<<<<<<<<<<<<
 *     """
 *     This is :func:`unpacks_lua_table` for methods
 */
  __pyx_tuple__31 = PyTuple_Pack(3, __pyx_n_s_meth, __pyx_n_s_wrapper, __pyx_n_s_wrapper); if (unlikely(!__pyx_tuple__31)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 417; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__31);
  __Pyx_GIVEREF(__pyx_tuple__31);
  __pyx_codeobj__32 = (PyObject*)__Pyx_PyCode_New(1, 0, 3, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__31, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_Users_ma_projects_immunio_agent, __pyx_n_s_unpacks_lua_table_method, 417, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__32)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 417; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "lupa/_lupa.pyx":1029
 * 
 * 
 * def as_attrgetter(obj):             # <<<<<<<<<<<<<<
 *     cdef _PyProtocolWrapper wrap = _PyProtocolWrapper.__new__(_PyProtocolWrapper)
 *     wrap._obj = obj
 */
  __pyx_tuple__33 = PyTuple_Pack(2, __pyx_n_s_obj, __pyx_n_s_wrap); if (unlikely(!__pyx_tuple__33)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1029; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__33);
  __Pyx_GIVEREF(__pyx_tuple__33);
  __pyx_codeobj__34 = (PyObject*)__Pyx_PyCode_New(1, 0, 2, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__33, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_Users_ma_projects_immunio_agent, __pyx_n_s_as_attrgetter, 1029, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__34)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1029; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "lupa/_lupa.pyx":1035
 *     return wrap
 * 
 * def as_itemgetter(obj):             # <<<<<<<<<<<<<<
 *     cdef _PyProtocolWrapper wrap = _PyProtocolWrapper.__new__(_PyProtocolWrapper)
 *     wrap._obj = obj
 */
  __pyx_tuple__35 = PyTuple_Pack(2, __pyx_n_s_obj, __pyx_n_s_wrap); if (unlikely(!__pyx_tuple__35)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1035; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__35);
  __Pyx_GIVEREF(__pyx_tuple__35);
  __pyx_codeobj__36 = (PyObject*)__Pyx_PyCode_New(1, 0, 2, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__35, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_Users_ma_projects_immunio_agent, __pyx_n_s_as_itemgetter, 1035, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__36)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1035; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_RefNannyFinishContext();
  return 0;
  __pyx_L1_error:;
  __Pyx_RefNannyFinishContext();
  return -1;
}

static int __Pyx_InitGlobals(void) {
  if (__Pyx_InitStrings(__pyx_string_tab) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
  __pyx_int_1 = PyInt_FromLong(1); if (unlikely(!__pyx_int_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  return 0;
  __pyx_L1_error:;
  return -1;
}

#if PY_MAJOR_VERSION < 3
PyMODINIT_FUNC init_lupa(void); /*proto*/
PyMODINIT_FUNC init_lupa(void)
#else
PyMODINIT_FUNC PyInit__lupa(void); /*proto*/
PyMODINIT_FUNC PyInit__lupa(void)
#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;
  luaL_Reg __pyx_t_9;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannyDeclarations
  #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("PyMODINIT_FUNC PyInit__lupa(void)", 0);
  if ( __Pyx_check_binary_version() < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_empty_tuple = PyTuple_New(0); if (unlikely(!__pyx_empty_tuple)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_empty_bytes = PyBytes_FromStringAndSize("", 0); if (unlikely(!__pyx_empty_bytes)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  #ifdef __Pyx_CyFunction_USED
  if (__Pyx_CyFunction_init() < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  #endif
  #ifdef __Pyx_FusedFunction_USED
  if (__pyx_FusedFunction_init() < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  #endif
  #ifdef __Pyx_Generator_USED
  if (__pyx_Generator_init() < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  #endif
  /*--- Library function declarations ---*/
  /*--- Threads initialization code ---*/
  #if defined(__PYX_FORCE_INIT_THREADS) && __PYX_FORCE_INIT_THREADS
  #ifdef WITH_THREAD /* Python build with threading support? */
  PyEval_InitThreads();
  #endif
  #endif
  /*--- Module creation code ---*/
  #if PY_MAJOR_VERSION < 3
  __pyx_m = Py_InitModule4(__Pyx_NAMESTR("_lupa"), __pyx_methods, __Pyx_DOCSTR(__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_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_d = PyModule_GetDict(__pyx_m); if (unlikely(!__pyx_d)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_INCREF(__pyx_d);
  __pyx_b = PyImport_AddModule(__Pyx_NAMESTR(__Pyx_BUILTIN_MODULE_NAME)); if (unlikely(!__pyx_b)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  #if CYTHON_COMPILING_IN_PYPY
  Py_INCREF(__pyx_b);
  #endif
  if (__Pyx_SetAttrString(__pyx_m, "__builtins__", __pyx_b) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
  /*--- Initialize various global constants etc. ---*/
  if (unlikely(__Pyx_InitGlobals() < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  #endif
  if (__pyx_module_is_main_lupa___lupa) {
    if (__Pyx_SetAttrString(__pyx_m, "__name__", __pyx_n_s_main) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
  }
  #if PY_MAJOR_VERSION >= 3
  {
    PyObject *modules = PyImport_GetModuleDict(); if (unlikely(!modules)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    if (!PyDict_GetItemString(modules, "lupa._lupa")) {
      if (unlikely(PyDict_SetItemString(modules, "lupa._lupa", __pyx_m) < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
  }
  #endif
  /*--- Builtin init code ---*/
  if (unlikely(__Pyx_InitCachedBuiltins() < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  /*--- Constants init code ---*/
  if (unlikely(__Pyx_InitCachedConstants() < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  /*--- 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);
  /*--- Variable export code ---*/
  /*--- Function export code ---*/
  /*--- Type init code ---*/
  if (PyType_Ready(&__pyx_type_4lupa_5_lupa_FastRLock) < 0) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 5; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_type_4lupa_5_lupa_FastRLock.tp_print = 0;
  if (__Pyx_SetAttrString(__pyx_m, "FastRLock", (PyObject *)&__pyx_type_4lupa_5_lupa_FastRLock) < 0) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 5; __pyx_clineno = __LINE__; goto __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 *))__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_filename = __pyx_f[0]; __pyx_lineno = 112; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_type_4lupa_5_lupa_LuaRuntime.tp_print = 0;
  if (__Pyx_SetVtable(__pyx_type_4lupa_5_lupa_LuaRuntime.tp_dict, __pyx_vtabptr_4lupa_5_lupa_LuaRuntime) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 112; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__Pyx_SetAttrString(__pyx_m, "LuaRuntime", (PyObject *)&__pyx_type_4lupa_5_lupa_LuaRuntime) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 112; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 476; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_type_4lupa_5_lupa__LuaObject.tp_print = 0;
  if (__Pyx_SetVtable(__pyx_type_4lupa_5_lupa__LuaObject.tp_dict, __pyx_vtabptr_4lupa_5_lupa__LuaObject) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 476; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 659; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_type_4lupa_5_lupa__LuaTable.tp_print = 0;
  if (__Pyx_SetVtable(__pyx_type_4lupa_5_lupa__LuaTable.tp_dict, __pyx_vtabptr_4lupa_5_lupa__LuaTable) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 659; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 750; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_type_4lupa_5_lupa__LuaFunction.tp_print = 0;
  if (__Pyx_SetVtable(__pyx_type_4lupa_5_lupa__LuaFunction.tp_dict, __pyx_vtabptr_4lupa_5_lupa__LuaFunction) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 750; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 789; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_type_4lupa_5_lupa__LuaCoroutineFunction.tp_print = 0;
  if (__Pyx_SetVtable(__pyx_type_4lupa_5_lupa__LuaCoroutineFunction.tp_dict, __pyx_vtabptr_4lupa_5_lupa__LuaCoroutineFunction) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 789; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 804; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_type_4lupa_5_lupa__LuaThread.tp_print = 0;
  if (__Pyx_SetVtable(__pyx_type_4lupa_5_lupa__LuaThread.tp_dict, __pyx_vtabptr_4lupa_5_lupa__LuaThread) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 804; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 909; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_type_4lupa_5_lupa__LuaIter.tp_print = 0;
  __pyx_ptype_4lupa_5_lupa__LuaIter = &__pyx_type_4lupa_5_lupa__LuaIter;
  if (PyType_Ready(&__pyx_type_4lupa_5_lupa__PyProtocolWrapper) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1020; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_type_4lupa_5_lupa__PyProtocolWrapper.tp_print = 0;
  __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_filename = __pyx_f[0]; __pyx_lineno = 391; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_type_4lupa_5_lupa___pyx_scope_struct__unpacks_lua_table.tp_print = 0;
  __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_filename = __pyx_f[0]; __pyx_lineno = 417; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_type_4lupa_5_lupa___pyx_scope_struct_1_unpacks_lua_table_method.tp_print = 0;
  __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;
  /*--- Type import code ---*/
  __pyx_ptype_7cpython_4type_type = __Pyx_ImportType(__Pyx_BUILTIN_MODULE_NAME, "type", 
  #if CYTHON_COMPILING_IN_PYPY
  sizeof(PyTypeObject),
  #else
  sizeof(PyHeapTypeObject),
  #endif
  0); if (unlikely(!__pyx_ptype_7cpython_4type_type)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 9; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_ptype_7cpython_4bool_bool = __Pyx_ImportType(__Pyx_BUILTIN_MODULE_NAME, "bool", sizeof(PyBoolObject), 0); if (unlikely(!__pyx_ptype_7cpython_4bool_bool)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 8; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_ptype_7cpython_7complex_complex = __Pyx_ImportType(__Pyx_BUILTIN_MODULE_NAME, "complex", sizeof(PyComplexObject), 0); if (unlikely(!__pyx_ptype_7cpython_7complex_complex)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 15; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  /*--- Variable import code ---*/
  /*--- Function import code ---*/
  /*--- Execution code ---*/

  /* "lupa/_lupa.pyx":30
 * 
 * cdef object exc_info
 * from sys import exc_info             # <<<<<<<<<<<<<<
 * 
 * cdef object Mapping
 */
  __pyx_t_1 = PyList_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 30; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_INCREF(__pyx_n_s_exc_info);
  PyList_SET_ITEM(__pyx_t_1, 0, __pyx_n_s_exc_info);
  __Pyx_GIVEREF(__pyx_n_s_exc_info);
  __pyx_t_2 = __Pyx_Import(__pyx_n_s_sys, __pyx_t_1, 0); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 30; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 30; __pyx_clineno = __LINE__; goto __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":33
 * 
 * cdef object Mapping
 * from collections import Mapping             # <<<<<<<<<<<<<<
 * 
 * cdef object wraps
 */
  __pyx_t_2 = PyList_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 33; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_INCREF(__pyx_n_s_Mapping);
  PyList_SET_ITEM(__pyx_t_2, 0, __pyx_n_s_Mapping);
  __Pyx_GIVEREF(__pyx_n_s_Mapping);
  __pyx_t_1 = __Pyx_Import(__pyx_n_s_collections, __pyx_t_2, 0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 33; __pyx_clineno = __LINE__; goto __pyx_L1_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_filename = __pyx_f[0]; __pyx_lineno = 33; __pyx_clineno = __LINE__; goto __pyx_L1_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":36
 * 
 * cdef object wraps
 * from functools import wraps             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_t_1 = PyList_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 36; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_INCREF(__pyx_n_s_wraps);
  PyList_SET_ITEM(__pyx_t_1, 0, __pyx_n_s_wraps);
  __Pyx_GIVEREF(__pyx_n_s_wraps);
  __pyx_t_2 = __Pyx_Import(__pyx_n_s_functools, __pyx_t_1, 0); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 36; __pyx_clineno = __LINE__; goto __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_wraps); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 36; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_INCREF(__pyx_t_1);
  __Pyx_XGOTREF(__pyx_v_4lupa_5_lupa_wraps);
  __Pyx_DECREF_SET(__pyx_v_4lupa_5_lupa_wraps, __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":39
 * 
 * 
 * __all__ = ['LuaRuntime', 'LuaError', 'LuaSyntaxError',             # <<<<<<<<<<<<<<
 *            'as_itemgetter', 'as_attrgetter', 'lua_type',
 *            'unpacks_lua_table', 'unpacks_lua_table_method']
 */
  __pyx_t_2 = PyList_New(8); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 39; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_INCREF(__pyx_n_s_LuaRuntime);
  PyList_SET_ITEM(__pyx_t_2, 0, __pyx_n_s_LuaRuntime);
  __Pyx_GIVEREF(__pyx_n_s_LuaRuntime);
  __Pyx_INCREF(__pyx_n_s_LuaError);
  PyList_SET_ITEM(__pyx_t_2, 1, __pyx_n_s_LuaError);
  __Pyx_GIVEREF(__pyx_n_s_LuaError);
  __Pyx_INCREF(__pyx_n_s_LuaSyntaxError);
  PyList_SET_ITEM(__pyx_t_2, 2, __pyx_n_s_LuaSyntaxError);
  __Pyx_GIVEREF(__pyx_n_s_LuaSyntaxError);
  __Pyx_INCREF(__pyx_n_s_as_itemgetter);
  PyList_SET_ITEM(__pyx_t_2, 3, __pyx_n_s_as_itemgetter);
  __Pyx_GIVEREF(__pyx_n_s_as_itemgetter);
  __Pyx_INCREF(__pyx_n_s_as_attrgetter);
  PyList_SET_ITEM(__pyx_t_2, 4, __pyx_n_s_as_attrgetter);
  __Pyx_GIVEREF(__pyx_n_s_as_attrgetter);
  __Pyx_INCREF(__pyx_n_s_lua_type);
  PyList_SET_ITEM(__pyx_t_2, 5, __pyx_n_s_lua_type);
  __Pyx_GIVEREF(__pyx_n_s_lua_type);
  __Pyx_INCREF(__pyx_n_s_unpacks_lua_table);
  PyList_SET_ITEM(__pyx_t_2, 6, __pyx_n_s_unpacks_lua_table);
  __Pyx_GIVEREF(__pyx_n_s_unpacks_lua_table);
  __Pyx_INCREF(__pyx_n_s_unpacks_lua_table_method);
  PyList_SET_ITEM(__pyx_t_2, 7, __pyx_n_s_unpacks_lua_table_method);
  __Pyx_GIVEREF(__pyx_n_s_unpacks_lua_table_method);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_all, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 39; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "lupa/_lupa.pyx":44
 * 
 * cdef object builtins
 * try:             # <<<<<<<<<<<<<<
 *     import __builtin__ as builtins
 * except ImportError:
 */
  {
    __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":45
 * 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_filename = __pyx_f[0]; __pyx_lineno = 45; __pyx_clineno = __LINE__; goto __pyx_L2_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;
    }
    __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_L2_error:;
    __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;

    /* "lupa/_lupa.pyx":46
 * try:
 *     import __builtin__ as builtins
 * except ImportError:             # <<<<<<<<<<<<<<
 *     import builtins
 * 
 */
    __pyx_t_6 = 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_1, &__pyx_t_7) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 46; __pyx_clineno = __LINE__; goto __pyx_L4_except_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_GOTREF(__pyx_t_7);

      /* "lupa/_lupa.pyx":47
 *     import __builtin__ as builtins
 * except ImportError:
 *     import builtins             # <<<<<<<<<<<<<<
 * 
 * DEF POBJECT = "POBJECT" # as used by LunaticPython
 */
      __pyx_t_8 = __Pyx_Import(__pyx_n_s_builtins, 0, 0); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 47; __pyx_clineno = __LINE__; goto __pyx_L4_except_error;}
      __Pyx_GOTREF(__pyx_t_8);
      __Pyx_XGOTREF(__pyx_v_4lupa_5_lupa_builtins);
      __Pyx_DECREF_SET(__pyx_v_4lupa_5_lupa_builtins, __pyx_t_8);
      __Pyx_GIVEREF(__pyx_t_8);
      __pyx_t_8 = 0;
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      goto __pyx_L3_exception_handled;
    }
    goto __pyx_L4_except_error;
    __pyx_L4_except_error:;
    __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_L9_try_end:;
  }

  /* "lupa/_lupa.pyx":67
 * 
 * 
 * class LuaError(Exception):             # <<<<<<<<<<<<<<
 *     """Base class for errors in the Lua runtime.
 *     """
 */
  __pyx_t_7 = PyTuple_New(1); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 67; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_7);
  __Pyx_INCREF(__pyx_builtin_Exception);
  PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_builtin_Exception);
  __Pyx_GIVEREF(__pyx_builtin_Exception);
  __pyx_t_1 = __Pyx_CalculateMetaclass(NULL, __pyx_t_7); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 67; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_Py3MetaclassPrepare(__pyx_t_1, __pyx_t_7, __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_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 67; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_8 = __Pyx_Py3ClassCreate(__pyx_t_1, __pyx_n_s_LuaError, __pyx_t_7, __pyx_t_2, NULL, 0, 1); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 67; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_8);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_LuaError, __pyx_t_8) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 67; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;

  /* "lupa/_lupa.pyx":72
 * 
 * 
 * class LuaSyntaxError(LuaError):             # <<<<<<<<<<<<<<
 *     """Syntax error in Lua code.
 *     """
 */
  __pyx_t_7 = __Pyx_GetModuleGlobalName(__pyx_n_s_LuaError); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 72; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_7);
  __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 72; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_7);
  __Pyx_GIVEREF(__pyx_t_7);
  __pyx_t_7 = 0;
  __pyx_t_7 = __Pyx_CalculateMetaclass(NULL, __pyx_t_1); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 72; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_7);
  __pyx_t_2 = __Pyx_Py3MetaclassPrepare(__pyx_t_7, __pyx_t_1, __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_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 72; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_8 = __Pyx_Py3ClassCreate(__pyx_t_7, __pyx_n_s_LuaSyntaxError, __pyx_t_1, __pyx_t_2, NULL, 0, 1); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 72; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_8);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_LuaSyntaxError, __pyx_t_8) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 72; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "lupa/_lupa.pyx":77
 * 
 * 
 * def lua_type(obj):             # <<<<<<<<<<<<<<
 *     """
 *     Return the Lua type name of a wrapped object as string, as provided
 */
  __pyx_t_1 = __Pyx_CyFunction_NewEx(&__pyx_mdef_4lupa_5_lupa_1lua_type, 0, __pyx_n_s_lua_type, NULL, __pyx_n_s_lupa__lupa, PyModule_GetDict(__pyx_m), ((PyObject *)__pyx_codeobj__28)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 77; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_lua_type, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 77; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "lupa/_lupa.pyx":391
 * # from Lua scripts
 * 
 * def unpacks_lua_table(func):             # <<<<<<<<<<<<<<
 *     """
 *     A decorator to make the decorated function receive kwargs
 */
  __pyx_t_1 = __Pyx_CyFunction_NewEx(&__pyx_mdef_4lupa_5_lupa_3unpacks_lua_table, 0, __pyx_n_s_unpacks_lua_table, NULL, __pyx_n_s_lupa__lupa, PyModule_GetDict(__pyx_m), ((PyObject *)__pyx_codeobj__30)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 391; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_unpacks_lua_table, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 391; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "lupa/_lupa.pyx":417
 * 
 * 
 * def unpacks_lua_table_method(meth):             # <<<<<<<<<<<<<<
 *     """
 *     This is :func:`unpacks_lua_table` for methods
 */
  __pyx_t_1 = __Pyx_CyFunction_NewEx(&__pyx_mdef_4lupa_5_lupa_5unpacks_lua_table_method, 0, __pyx_n_s_unpacks_lua_table_method, NULL, __pyx_n_s_lupa__lupa, PyModule_GetDict(__pyx_m), ((PyObject *)__pyx_codeobj__32)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 417; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_unpacks_lua_table_method, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 417; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "lupa/_lupa.pyx":1029
 * 
 * 
 * def as_attrgetter(obj):             # <<<<<<<<<<<<<<
 *     cdef _PyProtocolWrapper wrap = _PyProtocolWrapper.__new__(_PyProtocolWrapper)
 *     wrap._obj = obj
 */
  __pyx_t_1 = __Pyx_CyFunction_NewEx(&__pyx_mdef_4lupa_5_lupa_7as_attrgetter, 0, __pyx_n_s_as_attrgetter, NULL, __pyx_n_s_lupa__lupa, PyModule_GetDict(__pyx_m), ((PyObject *)__pyx_codeobj__34)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1029; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_as_attrgetter, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1029; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "lupa/_lupa.pyx":1035
 *     return wrap
 * 
 * def as_itemgetter(obj):             # <<<<<<<<<<<<<<
 *     cdef _PyProtocolWrapper wrap = _PyProtocolWrapper.__new__(_PyProtocolWrapper)
 *     wrap._obj = obj
 */
  __pyx_t_1 = __Pyx_CyFunction_NewEx(&__pyx_mdef_4lupa_5_lupa_9as_itemgetter, 0, __pyx_n_s_as_itemgetter, NULL, __pyx_n_s_lupa__lupa, PyModule_GetDict(__pyx_m), ((PyObject *)__pyx_codeobj__36)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1035; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_as_itemgetter, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1035; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "lupa/_lupa.pyx":1529
 * 
 * cdef lua.luaL_Reg py_object_lib[6]
 * py_object_lib[0] = lua.luaL_Reg(name = "__call",     func = <lua.lua_CFunction> py_object_call)             # <<<<<<<<<<<<<<
 * py_object_lib[1] = lua.luaL_Reg(name = "__index",    func = <lua.lua_CFunction> py_object_getindex)
 * py_object_lib[2] = lua.luaL_Reg(name = "__newindex", func = <lua.lua_CFunction> py_object_setindex)
 */
  __pyx_t_9.name = __pyx_k_call;
  __pyx_t_9.func = ((lua_CFunction)__pyx_f_4lupa_5_lupa_py_object_call);
  (__pyx_v_4lupa_5_lupa_py_object_lib[0]) = __pyx_t_9;

  /* "lupa/_lupa.pyx":1530
 * cdef lua.luaL_Reg py_object_lib[6]
 * py_object_lib[0] = lua.luaL_Reg(name = "__call",     func = <lua.lua_CFunction> py_object_call)
 * py_object_lib[1] = lua.luaL_Reg(name = "__index",    func = <lua.lua_CFunction> py_object_getindex)             # <<<<<<<<<<<<<<
 * py_object_lib[2] = lua.luaL_Reg(name = "__newindex", func = <lua.lua_CFunction> py_object_setindex)
 * py_object_lib[3] = lua.luaL_Reg(name = "__tostring", func = <lua.lua_CFunction> py_object_str)
 */
  __pyx_t_9.name = __pyx_k_index;
  __pyx_t_9.func = ((lua_CFunction)__pyx_f_4lupa_5_lupa_py_object_getindex);
  (__pyx_v_4lupa_5_lupa_py_object_lib[1]) = __pyx_t_9;

  /* "lupa/_lupa.pyx":1531
 * py_object_lib[0] = lua.luaL_Reg(name = "__call",     func = <lua.lua_CFunction> py_object_call)
 * py_object_lib[1] = lua.luaL_Reg(name = "__index",    func = <lua.lua_CFunction> py_object_getindex)
 * py_object_lib[2] = lua.luaL_Reg(name = "__newindex", func = <lua.lua_CFunction> py_object_setindex)             # <<<<<<<<<<<<<<
 * py_object_lib[3] = lua.luaL_Reg(name = "__tostring", func = <lua.lua_CFunction> py_object_str)
 * py_object_lib[4] = lua.luaL_Reg(name = "__gc",       func = <lua.lua_CFunction> py_object_gc)
 */
  __pyx_t_9.name = __pyx_k_newindex;
  __pyx_t_9.func = ((lua_CFunction)__pyx_f_4lupa_5_lupa_py_object_setindex);
  (__pyx_v_4lupa_5_lupa_py_object_lib[2]) = __pyx_t_9;

  /* "lupa/_lupa.pyx":1532
 * py_object_lib[1] = lua.luaL_Reg(name = "__index",    func = <lua.lua_CFunction> py_object_getindex)
 * py_object_lib[2] = lua.luaL_Reg(name = "__newindex", func = <lua.lua_CFunction> py_object_setindex)
 * py_object_lib[3] = lua.luaL_Reg(name = "__tostring", func = <lua.lua_CFunction> py_object_str)             # <<<<<<<<<<<<<<
 * py_object_lib[4] = lua.luaL_Reg(name = "__gc",       func = <lua.lua_CFunction> py_object_gc)
 * py_object_lib[5] = lua.luaL_Reg(name = NULL, func = NULL)
 */
  __pyx_t_9.name = __pyx_k_tostring;
  __pyx_t_9.func = ((lua_CFunction)__pyx_f_4lupa_5_lupa_py_object_str);
  (__pyx_v_4lupa_5_lupa_py_object_lib[3]) = __pyx_t_9;

  /* "lupa/_lupa.pyx":1533
 * py_object_lib[2] = lua.luaL_Reg(name = "__newindex", func = <lua.lua_CFunction> py_object_setindex)
 * py_object_lib[3] = lua.luaL_Reg(name = "__tostring", func = <lua.lua_CFunction> py_object_str)
 * py_object_lib[4] = lua.luaL_Reg(name = "__gc",       func = <lua.lua_CFunction> py_object_gc)             # <<<<<<<<<<<<<<
 * py_object_lib[5] = lua.luaL_Reg(name = NULL, func = NULL)
 * 
 */
  __pyx_t_9.name = __pyx_k_gc;
  __pyx_t_9.func = ((lua_CFunction)__pyx_f_4lupa_5_lupa_py_object_gc);
  (__pyx_v_4lupa_5_lupa_py_object_lib[4]) = __pyx_t_9;

  /* "lupa/_lupa.pyx":1534
 * py_object_lib[3] = lua.luaL_Reg(name = "__tostring", func = <lua.lua_CFunction> py_object_str)
 * py_object_lib[4] = lua.luaL_Reg(name = "__gc",       func = <lua.lua_CFunction> py_object_gc)
 * py_object_lib[5] = lua.luaL_Reg(name = NULL, func = NULL)             # <<<<<<<<<<<<<<
 * 
 * ## # Python helper functions for Lua
 */
  __pyx_t_9.name = NULL;
  __pyx_t_9.func = NULL;
  (__pyx_v_4lupa_5_lupa_py_object_lib[5]) = __pyx_t_9;

  /* "lupa/_lupa.pyx":1690
 * 
 * cdef lua.luaL_Reg py_lib[7]
 * py_lib[0] = lua.luaL_Reg(name = "as_attrgetter", func = <lua.lua_CFunction> py_as_attrgetter)             # <<<<<<<<<<<<<<
 * py_lib[1] = lua.luaL_Reg(name = "as_itemgetter", func = <lua.lua_CFunction> py_as_itemgetter)
 * py_lib[2] = lua.luaL_Reg(name = "as_function", func = <lua.lua_CFunction> py_as_function)
 */
  __pyx_t_9.name = __pyx_k_as_attrgetter;
  __pyx_t_9.func = ((lua_CFunction)__pyx_f_4lupa_5_lupa_py_as_attrgetter);
  (__pyx_v_4lupa_5_lupa_py_lib[0]) = __pyx_t_9;

  /* "lupa/_lupa.pyx":1691
 * cdef lua.luaL_Reg py_lib[7]
 * py_lib[0] = lua.luaL_Reg(name = "as_attrgetter", func = <lua.lua_CFunction> py_as_attrgetter)
 * py_lib[1] = lua.luaL_Reg(name = "as_itemgetter", func = <lua.lua_CFunction> py_as_itemgetter)             # <<<<<<<<<<<<<<
 * py_lib[2] = lua.luaL_Reg(name = "as_function", func = <lua.lua_CFunction> py_as_function)
 * py_lib[3] = lua.luaL_Reg(name = "iter", func = <lua.lua_CFunction> py_iter)
 */
  __pyx_t_9.name = __pyx_k_as_itemgetter;
  __pyx_t_9.func = ((lua_CFunction)__pyx_f_4lupa_5_lupa_py_as_itemgetter);
  (__pyx_v_4lupa_5_lupa_py_lib[1]) = __pyx_t_9;

  /* "lupa/_lupa.pyx":1692
 * py_lib[0] = lua.luaL_Reg(name = "as_attrgetter", func = <lua.lua_CFunction> py_as_attrgetter)
 * py_lib[1] = lua.luaL_Reg(name = "as_itemgetter", func = <lua.lua_CFunction> py_as_itemgetter)
 * py_lib[2] = lua.luaL_Reg(name = "as_function", func = <lua.lua_CFunction> py_as_function)             # <<<<<<<<<<<<<<
 * py_lib[3] = lua.luaL_Reg(name = "iter", func = <lua.lua_CFunction> py_iter)
 * py_lib[4] = lua.luaL_Reg(name = "iterex", func = <lua.lua_CFunction> py_iterex)
 */
  __pyx_t_9.name = __pyx_k_as_function;
  __pyx_t_9.func = ((lua_CFunction)__pyx_f_4lupa_5_lupa_py_as_function);
  (__pyx_v_4lupa_5_lupa_py_lib[2]) = __pyx_t_9;

  /* "lupa/_lupa.pyx":1693
 * py_lib[1] = lua.luaL_Reg(name = "as_itemgetter", func = <lua.lua_CFunction> py_as_itemgetter)
 * py_lib[2] = lua.luaL_Reg(name = "as_function", func = <lua.lua_CFunction> py_as_function)
 * py_lib[3] = lua.luaL_Reg(name = "iter", func = <lua.lua_CFunction> py_iter)             # <<<<<<<<<<<<<<
 * py_lib[4] = lua.luaL_Reg(name = "iterex", func = <lua.lua_CFunction> py_iterex)
 * py_lib[5] = lua.luaL_Reg(name = "enumerate", func = <lua.lua_CFunction> py_enumerate)
 */
  __pyx_t_9.name = __pyx_k_iter;
  __pyx_t_9.func = ((lua_CFunction)__pyx_f_4lupa_5_lupa_py_iter);
  (__pyx_v_4lupa_5_lupa_py_lib[3]) = __pyx_t_9;

  /* "lupa/_lupa.pyx":1694
 * py_lib[2] = lua.luaL_Reg(name = "as_function", func = <lua.lua_CFunction> py_as_function)
 * py_lib[3] = lua.luaL_Reg(name = "iter", func = <lua.lua_CFunction> py_iter)
 * py_lib[4] = lua.luaL_Reg(name = "iterex", func = <lua.lua_CFunction> py_iterex)             # <<<<<<<<<<<<<<
 * py_lib[5] = lua.luaL_Reg(name = "enumerate", func = <lua.lua_CFunction> py_enumerate)
 * py_lib[6] = lua.luaL_Reg(name = NULL, func = NULL)
 */
  __pyx_t_9.name = __pyx_k_iterex;
  __pyx_t_9.func = ((lua_CFunction)__pyx_f_4lupa_5_lupa_py_iterex);
  (__pyx_v_4lupa_5_lupa_py_lib[4]) = __pyx_t_9;

  /* "lupa/_lupa.pyx":1695
 * py_lib[3] = lua.luaL_Reg(name = "iter", func = <lua.lua_CFunction> py_iter)
 * py_lib[4] = lua.luaL_Reg(name = "iterex", func = <lua.lua_CFunction> py_iterex)
 * py_lib[5] = lua.luaL_Reg(name = "enumerate", func = <lua.lua_CFunction> py_enumerate)             # <<<<<<<<<<<<<<
 * py_lib[6] = lua.luaL_Reg(name = NULL, func = NULL)
 */
  __pyx_t_9.name = __pyx_k_enumerate;
  __pyx_t_9.func = ((lua_CFunction)__pyx_f_4lupa_5_lupa_py_enumerate);
  (__pyx_v_4lupa_5_lupa_py_lib[5]) = __pyx_t_9;

  /* "lupa/_lupa.pyx":1696
 * py_lib[4] = lua.luaL_Reg(name = "iterex", func = <lua.lua_CFunction> py_iterex)
 * py_lib[5] = lua.luaL_Reg(name = "enumerate", func = <lua.lua_CFunction> py_enumerate)
 * py_lib[6] = lua.luaL_Reg(name = NULL, func = NULL)             # <<<<<<<<<<<<<<
 */
  __pyx_t_9.name = NULL;
  __pyx_t_9.func = NULL;
  (__pyx_v_4lupa_5_lupa_py_lib[6]) = __pyx_t_9;

  /* "lupa/_lupa.pyx":1
 * # cython: embedsignature=True, binding=True             # <<<<<<<<<<<<<<
 * 
 * """
 */
  __pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_test, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  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);
  if (__pyx_m) {
    __Pyx_AddTraceback("init lupa._lupa", __pyx_clineno, __pyx_lineno, __pyx_filename);
    Py_DECREF(__pyx_m); __pyx_m = 0;
  } else if (!PyErr_Occurred()) {
    PyErr_SetString(PyExc_ImportError, "init lupa._lupa");
  }
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  #if PY_MAJOR_VERSION < 3
  return;
  #else
  return __pyx_m;
  #endif
}

/* Runtime support code */
#if CYTHON_REFNANNY
static __Pyx_RefNannyAPIStruct *__Pyx_RefNannyImportAPI(const char *modname) {
    PyObject *m = NULL, *p = NULL;
    void *r = NULL;
    m = PyImport_ImportModule((char *)modname);
    if (!m) goto end;
    p = PyObject_GetAttrString(m, (char *)"RefNannyAPI");
    if (!p) goto end;
    r = PyLong_AsVoidPtr(p);
end:
    Py_XDECREF(p);
    Py_XDECREF(m);
    return (__Pyx_RefNannyAPIStruct *)r;
}
#endif /* CYTHON_REFNANNY */

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

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);
}

static CYTHON_INLINE 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_CheckExact(key)) && 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;
}

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
}

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_CheckExact(key)) || 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
                    (PyUnicode_GET_SIZE(**name) != PyUnicode_GET_SIZE(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
                        (PyUnicode_GET_SIZE(**argname) != PyUnicode_GET_SIZE(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;
}

#if CYTHON_COMPILING_IN_CPYTHON
static CYTHON_INLINE PyObject* __Pyx_PyObject_Call(PyObject *func, PyObject *arg, PyObject *kw) {
    PyObject *result;
    ternaryfunc call = func->ob_type->tp_call;
    if (unlikely(!call))
        return PyObject_Call(func, arg, kw);
#if PY_VERSION_HEX >= 0x02060000
    if (unlikely(Py_EnterRecursiveCall((char*)" while calling a Python object")))
        return NULL;
#endif
    result = (*call)(func, arg, kw);
#if PY_VERSION_HEX >= 0x02060000
    Py_LeaveRecursiveCall();
#endif
    if (unlikely(!result) && unlikely(!PyErr_Occurred())) {
        PyErr_SetString(
            PyExc_SystemError,
            "NULL result without error in PyObject_Call");
    }
    return result;
}
#endif

static CYTHON_INLINE void __Pyx_ErrRestore(PyObject *type, PyObject *value, PyObject *tb) {
#if CYTHON_COMPILING_IN_CPYTHON
    PyObject *tmp_type, *tmp_value, *tmp_tb;
    PyThreadState *tstate = PyThreadState_GET();
    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);
#else
    PyErr_Restore(type, value, tb);
#endif
}
static CYTHON_INLINE void __Pyx_ErrFetch(PyObject **type, PyObject **value, PyObject **tb) {
#if CYTHON_COMPILING_IN_CPYTHON
    PyThreadState *tstate = PyThreadState_GET();
    *type = tstate->curexc_type;
    *value = tstate->curexc_value;
    *tb = tstate->curexc_traceback;
    tstate->curexc_type = 0;
    tstate->curexc_value = 0;
    tstate->curexc_traceback = 0;
#else
    PyErr_Fetch(type, value, tb);
#endif
}

#if PY_MAJOR_VERSION < 3
static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb,
                        CYTHON_UNUSED PyObject *cause) {
    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 PY_VERSION_HEX < 0x02050000
    if (PyClass_Check(type)) {
    #else
    if (PyType_Check(type)) {
    #endif
#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;
        #if PY_VERSION_HEX < 0x02050000
        if (PyInstance_Check(type)) {
            type = (PyObject*) ((PyInstanceObject*)type)->in_class;
            Py_INCREF(type);
        } else {
            type = 0;
            PyErr_SetString(PyExc_TypeError,
                "raise: exception must be an old-style class or instance");
            goto raise_error;
        }
        #else
        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;
        }
        #endif
    }
    __Pyx_ErrRestore(type, value, tb);
    return;
raise_error:
    Py_XDECREF(value);
    Py_XDECREF(type);
    Py_XDECREF(tb);
    return;
}
#else /* Python 3+ */
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) {
                if (PyObject_IsSubclass(instance_class, type)) {
                    type = instance_class;
                } else {
                    instance_class = NULL;
                }
            }
        }
        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 PY_VERSION_HEX >= 0x03030000
    if (cause) {
#else
    if (cause && cause != Py_None) {
#endif
        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) {
        PyThreadState *tstate = PyThreadState_GET();
        PyObject* tmp_tb = tstate->curexc_traceback;
        if (tb != tmp_tb) {
            Py_INCREF(tb);
            tstate->curexc_traceback = tb;
            Py_XDECREF(tmp_tb);
        }
    }
bad:
    Py_XDECREF(owned_instance);
    return;
}
#endif

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))) {
        length = strlen(cstring);
        if (start < 0) {
            start += length;
            if (start < 0)
                start = 0;
        }
        if (stop < 0)
            stop += length;
    }
    length = stop - start;
    if (unlikely(length <= 0))
        return PyUnicode_FromUnicode(NULL, 0);
    cstring += start;
    if (decode_func) {
        return decode_func(cstring, length, errors);
    } else {
        return PyUnicode_Decode(cstring, length, encoding, errors);
    }
}

static int __Pyx_GetException(PyObject **type, PyObject **value, PyObject **tb) {
    PyObject *local_type, *local_value, *local_tb;
#if CYTHON_COMPILING_IN_CPYTHON
    PyObject *tmp_type, *tmp_value, *tmp_tb;
    PyThreadState *tstate = PyThreadState_GET();
    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_COMPILING_IN_CPYTHON
    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_COMPILING_IN_CPYTHON
    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;
    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;
}

static CYTHON_INLINE void __Pyx_ExceptionSwap(PyObject **type, PyObject **value, PyObject **tb) {
    PyObject *tmp_type, *tmp_value, *tmp_tb;
#if CYTHON_COMPILING_IN_CPYTHON
    PyThreadState *tstate = PyThreadState_GET();
    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;
#else
    PyErr_GetExcInfo(&tmp_type, &tmp_value, &tmp_tb);
    PyErr_SetExcInfo(*type, *value, *tb);
#endif
    *type = tmp_type;
    *value = tmp_value;
    *tb = tmp_tb;
}

static CYTHON_INLINE void __Pyx_ExceptionSave(PyObject **type, PyObject **value, PyObject **tb) {
#if CYTHON_COMPILING_IN_CPYTHON
    PyThreadState *tstate = PyThreadState_GET();
    *type = tstate->exc_type;
    *value = tstate->exc_value;
    *tb = tstate->exc_traceback;
    Py_XINCREF(*type);
    Py_XINCREF(*value);
    Py_XINCREF(*tb);
#else
    PyErr_GetExcInfo(type, value, tb);
#endif
}
static void __Pyx_ExceptionReset(PyObject *type, PyObject *value, PyObject *tb) {
#if CYTHON_COMPILING_IN_CPYTHON
    PyObject *tmp_type, *tmp_value, *tmp_tb;
    PyThreadState *tstate = PyThreadState_GET();
    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;
    Py_XDECREF(tmp_type);
    Py_XDECREF(tmp_value);
    Py_XDECREF(tmp_tb);
#else
    PyErr_SetExcInfo(type, value, tb);
#endif
}

static CYTHON_INLINE PyObject *__Pyx_GetModuleGlobalName(PyObject *name) {
    PyObject *result;
#if CYTHON_COMPILING_IN_CPYTHON
    result = PyDict_GetItem(__pyx_d, name);
    if (result) {
        Py_INCREF(result);
    } else {
#else
    result = PyObject_GetItem(__pyx_d, name);
    if (!result) {
        PyErr_Clear();
#endif
        result = __Pyx_GetBuiltinName(name);
    }
    return result;
}

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);
}

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");
}

static CYTHON_INLINE int __Pyx_IterFinish(void) {
#if CYTHON_COMPILING_IN_CPYTHON
    PyThreadState *tstate = PyThreadState_GET();
    PyObject* exc_type = tstate->curexc_type;
    if (unlikely(exc_type)) {
        if (likely(exc_type == PyExc_StopIteration) || 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
}

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

static CYTHON_INLINE void __Pyx_RaiseUnboundLocalError(const char *varname) {
    PyErr_Format(PyExc_UnboundLocalError, "local variable '%s' referenced before assignment", varname);
}

static CYTHON_INLINE 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,
                                                              int wraparound, int boundscheck) {
#if CYTHON_COMPILING_IN_CPYTHON
    if (wraparound & unlikely(i < 0)) i += PyList_GET_SIZE(o);
    if ((!boundscheck) || likely((0 <= i) & (i < PyList_GET_SIZE(o)))) {
        PyObject *r = PyList_GET_ITEM(o, 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,
                                                              int wraparound, int boundscheck) {
#if CYTHON_COMPILING_IN_CPYTHON
    if (wraparound & unlikely(i < 0)) i += PyTuple_GET_SIZE(o);
    if ((!boundscheck) || likely((0 <= i) & (i < PyTuple_GET_SIZE(o)))) {
        PyObject *r = PyTuple_GET_ITEM(o, 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, int wraparound, int boundscheck) {
#if CYTHON_COMPILING_IN_CPYTHON
    if (is_list || PyList_CheckExact(o)) {
        Py_ssize_t n = ((!wraparound) | likely(i >= 0)) ? i : i + PyList_GET_SIZE(o);
        if ((!boundscheck) || (likely((n >= 0) & (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((n >= 0) & (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))
                        PyErr_Clear();
                    else
                        return NULL;
                }
            }
            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));
}

static CYTHON_INLINE void __Pyx_RaiseNoneNotIterableError(void) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable");
}

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);
    }
}

static CYTHON_INLINE int __Pyx_unpack_tuple2(PyObject* tuple, PyObject** pvalue1, PyObject** pvalue2,
                                             int is_tuple, int has_known_size, int decref_tuple) {
    Py_ssize_t index;
    PyObject *value1 = NULL, *value2 = NULL, *iter = NULL;
    if (!is_tuple && unlikely(!PyTuple_Check(tuple))) {
        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);
    } else {
        if (!has_known_size && unlikely(PyTuple_GET_SIZE(tuple) != 2)) {
            __Pyx_UnpackTupleError(tuple, 2);
            goto bad;
        }
#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);
        value2 = PyTuple_GET_ITEM(tuple, 1);
        Py_INCREF(value1);
        Py_INCREF(value2);
#endif
        if (decref_tuple) { Py_DECREF(tuple); }
    }
    *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;
}

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 !CYTHON_COMPILING_IN_PYPY
    if (is_dict) {
        *p_orig_length = PyDict_Size(iterable);
        Py_INCREF(iterable);
        return iterable;
    }
#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, Py_ssize_t orig_length, 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;
}

static CYTHON_INLINE void __Pyx_RaiseClosureNameError(const char *varname) {
    PyErr_Format(PyExc_NameError, "free variable '%s' referenced before assignment in enclosing scope", varname);
}

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

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)
{
    PyObject *tmp = op->func_doc;
    if (value == NULL)
        value = Py_None; /* Mark as deleted */
    Py_INCREF(value);
    op->func_doc = value;
    Py_XDECREF(tmp);
    return 0;
}
static PyObject *
__Pyx_CyFunction_get_name(__pyx_CyFunctionObject *op)
{
    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)
{
    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)
{
    Py_INCREF(op->func_qualname);
    return op->func_qualname;
}
static int
__Pyx_CyFunction_set_qualname(__pyx_CyFunctionObject *op, PyObject *value)
{
    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)
{
    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)
{
    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)
{
    Py_INCREF(op->func_globals);
    return op->func_globals;
}
static PyObject *
__Pyx_CyFunction_get_closure(CYTHON_UNUSED __pyx_CyFunctionObject *op)
{
    Py_INCREF(Py_None);
    return Py_None;
}
static PyObject *
__Pyx_CyFunction_get_code(__pyx_CyFunctionObject *op)
{
    PyObject* result = (op->func_code) ? op->func_code : Py_None;
    Py_INCREF(result);
    return result;
}
static int
__Pyx_CyFunction_init_defaults(__pyx_CyFunctionObject *op) {
    PyObject *res = op->defaults_getter((PyObject *) op);
    if (unlikely(!res))
        return -1;
    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);
    Py_DECREF(res);
    return 0;
}
static int
__Pyx_CyFunction_set_defaults(__pyx_CyFunctionObject *op, PyObject* value) {
    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) {
    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) {
    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) {
    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) {
    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) {
    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}
};
#ifndef PY_WRITE_RESTRICTED /* < Py2.5 */
#define PY_WRITE_RESTRICTED WRITE_RESTRICTED
#endif
static PyMemberDef __pyx_CyFunction_members[] = {
    {(char *) "__module__", T_OBJECT, offsetof(__pyx_CyFunctionObject, func.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
    return PyUnicode_FromString(m->func.m_ml->ml_name);
#else
    return PyString_FromString(m->func.m_ml->ml_name);
#endif
}
static PyMethodDef __pyx_CyFunction_methods[] = {
    {__Pyx_NAMESTR("__reduce__"), (PyCFunction)__Pyx_CyFunction_reduce, METH_VARARGS, 0},
    {0, 0, 0, 0}
};
static PyObject *__Pyx_CyFunction_New(PyTypeObject *type, PyMethodDef *ml, int flags, PyObject* qualname,
                                      PyObject *closure, PyObject *module, PyObject* globals, PyObject* code) {
    __pyx_CyFunctionObject *op = PyObject_GC_New(__pyx_CyFunctionObject, type);
    if (op == NULL)
        return NULL;
    op->flags = flags;
    op->func_weakreflist = 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 = NULL;
    op->defaults_tuple = NULL;
    op->defaults_kwdict = NULL;
    op->defaults_getter = NULL;
    op->func_annotations = NULL;
    PyObject_GC_Track(op);
    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]);
        PyMem_Free(m->defaults);
        m->defaults = NULL;
    }
    return 0;
}
static void __Pyx_CyFunction_dealloc(__pyx_CyFunctionObject *m)
{
    PyObject_GC_UnTrack(m);
    if (m->func_weakreflist != NULL)
        PyObject_ClearWeakRefs((PyObject *) m);
    __Pyx_CyFunction_clear(m);
    PyObject_GC_Del(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)
{
    __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 PyMethod_New(func,
                            type, (PyObject *)(Py_TYPE(type)));
    }
    if (obj == Py_None)
        obj = NULL;
    return 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
}
#if CYTHON_COMPILING_IN_PYPY
static PyObject * __Pyx_CyFunction_Call(PyObject *func, PyObject *arg, PyObject *kw) {
    PyCFunctionObject* f = (PyCFunctionObject*)func;
    PyCFunction meth = PyCFunction_GET_FUNCTION(func);
    PyObject *self = PyCFunction_GET_SELF(func);
    Py_ssize_t size;
    switch (PyCFunction_GET_FLAGS(func) & ~(METH_CLASS | METH_STATIC | METH_COEXIST)) {
    case METH_VARARGS:
        if (likely(kw == NULL) || PyDict_Size(kw) == 0)
            return (*meth)(self, arg);
        break;
    case METH_VARARGS | METH_KEYWORDS:
        return (*(PyCFunctionWithKeywords)meth)(self, arg, kw);
    case METH_NOARGS:
        if (likely(kw == NULL) || PyDict_Size(kw) == 0) {
            size = PyTuple_GET_SIZE(arg);
            if (size == 0)
                return (*meth)(self, NULL);
            PyErr_Format(PyExc_TypeError,
                "%.200s() takes no arguments (%zd 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 (size == 1)
                return (*meth)(self, PyTuple_GET_ITEM(arg, 0));
            PyErr_Format(PyExc_TypeError,
                "%.200s() takes exactly one argument (%zd 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;
}
#else
static PyObject * __Pyx_CyFunction_Call(PyObject *func, PyObject *arg, PyObject *kw) {
	return PyCFunction_Call(func, arg, kw);
}
#endif
static PyTypeObject __pyx_CyFunctionType_type = {
    PyVarObject_HEAD_INIT(0, 0)
    __Pyx_NAMESTR("cython_function_or_method"), /*tp_name*/
    sizeof(__pyx_CyFunctionObject),   /*tp_basicsize*/
    0,                                  /*tp_itemsize*/
    (destructor) __Pyx_CyFunction_dealloc, /*tp_dealloc*/
    0,                                  /*tp_print*/
    0,                                  /*tp_getattr*/
    0,                                  /*tp_setattr*/
#if PY_MAJOR_VERSION < 3
    0,                                  /*tp_compare*/
#else
    0,                                  /*reserved*/
#endif
    (reprfunc) __Pyx_CyFunction_repr,   /*tp_repr*/
    0,                                  /*tp_as_number*/
    0,                                  /*tp_as_sequence*/
    0,                                  /*tp_as_mapping*/
    0,                                  /*tp_hash*/
    __Pyx_CyFunction_Call,              /*tp_call*/
    0,                                  /*tp_str*/
    0,                                  /*tp_getattro*/
    0,                                  /*tp_setattro*/
    0,                                  /*tp_as_buffer*/
    Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC, /* tp_flags*/
    0,                                  /*tp_doc*/
    (traverseproc) __Pyx_CyFunction_traverse,   /*tp_traverse*/
    (inquiry) __Pyx_CyFunction_clear,   /*tp_clear*/
    0,                                  /*tp_richcompare*/
    offsetof(__pyx_CyFunctionObject, func_weakreflist), /* tp_weaklistoffse */
    0,                                  /*tp_iter*/
    0,                                  /*tp_iternext*/
    __pyx_CyFunction_methods,           /*tp_methods*/
    __pyx_CyFunction_members,           /*tp_members*/
    __pyx_CyFunction_getsets,           /*tp_getset*/
    0,                                  /*tp_base*/
    0,                                  /*tp_dict*/
    __Pyx_CyFunction_descr_get,         /*tp_descr_get*/
    0,                                  /*tp_descr_set*/
    offsetof(__pyx_CyFunctionObject, func_dict),/*tp_dictoffset*/
    0,                                  /*tp_init*/
    0,                                  /*tp_alloc*/
    0,                                  /*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*/
#if PY_VERSION_HEX >= 0x02060000
    0,                                  /*tp_version_tag*/
#endif
#if PY_VERSION_HEX >= 0x030400a1
    0,                                  /*tp_finalize*/
#endif
};
static int __Pyx_CyFunction_init(void) {
#if !CYTHON_COMPILING_IN_PYPY
    __pyx_CyFunctionType_type.tp_call = PyCFunction_Call;
#endif
    __pyx_CyFunctionType = __Pyx_FetchCommonType(&__pyx_CyFunctionType_type);
    if (__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 = PyMem_Malloc(size);
    if (!m->defaults)
        return PyErr_NoMemory();
    memset(m->defaults, 0, size);
    m->defaults_pyobjects = pyobjects;
    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);
}

static void __Pyx_WriteUnraisable(const char *name, CYTHON_UNUSED int clineno,
                                  CYTHON_UNUSED int lineno, CYTHON_UNUSED const char *filename,
                                  int full_traceback) {
    PyObject *old_exc, *old_val, *old_tb;
    PyObject *ctx;
    __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);
    }
}

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;
    length = stop - start;
    if (unlikely(length <= 0))
        return PyUnicode_FromUnicode(NULL, 0);
    cstring += start;
    if (decode_func) {
        return decode_func(cstring, length, errors);
    } else {
        return PyUnicode_Decode(cstring, length, encoding, errors);
    }
}

static CYTHON_INLINE int __Pyx_TypeTest(PyObject *obj, PyTypeObject *type) {
    if (unlikely(!type)) {
        PyErr_SetString(PyExc_SystemError, "Missing type object");
        return 0;
    }
    if (likely(PyObject_TypeCheck(obj, type)))
        return 1;
    PyErr_Format(PyExc_TypeError, "Cannot convert %.200s to %.200s",
                 Py_TYPE(obj)->tp_name, type->tp_name);
    return 0;
}

static void __Pyx_RaiseArgumentTypeInvalid(const char* name, PyObject *obj, PyTypeObject *type) {
    PyErr_Format(PyExc_TypeError,
        "Argument '%.200s' has incorrect type (expected %.200s, got %.200s)",
        name, type->tp_name, Py_TYPE(obj)->tp_name);
}
static CYTHON_INLINE int __Pyx_ArgTypeTest(PyObject *obj, PyTypeObject *type, int none_allowed,
    const char *name, int exact)
{
    if (unlikely(!type)) {
        PyErr_SetString(PyExc_SystemError, "Missing type object");
        return 0;
    }
    if (none_allowed && obj == Py_None) return 1;
    else if (exact) {
        if (likely(Py_TYPE(obj) == type)) return 1;
        #if PY_MAJOR_VERSION == 2
        else if ((type == &PyBaseString_Type) && likely(__Pyx_PyBaseString_CheckExact(obj))) return 1;
        #endif
    }
    else {
        if (likely(PyObject_TypeCheck(obj, type))) return 1;
    }
    __Pyx_RaiseArgumentTypeInvalid(name, obj, type);
    return 0;
}

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

static CYTHON_INLINE PyObject* __Pyx__PyObject_Pop(PyObject* L) {
#if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x02050000
    if (Py_TYPE(L) == &PySet_Type) {
        return PySet_Pop(L);
    }
#endif
    return __Pyx_PyObject_CallMethod0(L, __pyx_n_s_pop);
}
static CYTHON_INLINE PyObject* __Pyx_PyList_Pop(PyObject* L) {
#if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x02040000
    if (likely(PyList_GET_SIZE(L) > (((PyListObject*)L)->allocated >> 1))) {
        Py_SIZE(L) -= 1;
        return PyList_GET_ITEM(L, PyList_GET_SIZE(L));
    }
#endif
    return __Pyx_PyObject_CallMethod0(L, __pyx_n_s_pop);
}

static CYTHON_INLINE PyObject *__Pyx_GetAttr(PyObject *o, PyObject *n) {
#if CYTHON_COMPILING_IN_CPYTHON
#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);
}

static CYTHON_INLINE PyObject *__Pyx_PyIter_Next2(PyObject* iterator, PyObject* defval) {
    PyObject* next;
    iternextfunc iternext = Py_TYPE(iterator)->tp_iternext;
#if CYTHON_COMPILING_IN_CPYTHON
    if (unlikely(!iternext)) {
#else
    if (unlikely(!iternext) || unlikely(!PyIter_Check(iterator))) {
#endif
        PyErr_Format(PyExc_TypeError,
            "%.200s object is not an iterator", Py_TYPE(iterator)->tp_name);
        return NULL;
    }
    next = iternext(iterator);
    if (likely(next))
        return next;
#if CYTHON_COMPILING_IN_CPYTHON
#if PY_VERSION_HEX >= 0x03010000 || (PY_MAJOR_VERSION < 3 && PY_VERSION_HEX >= 0x02070000)
    if (unlikely(iternext == &_PyObject_NextNotImplemented))
        return NULL;
#endif
#endif
    if (defval) {
        PyObject* exc_type = PyErr_Occurred();
        if (exc_type) {
            if (unlikely(exc_type != PyExc_StopIteration) &&
                    !PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))
                return NULL;
            PyErr_Clear();
        }
        Py_INCREF(defval);
        return defval;
    }
    if (!PyErr_Occurred())
        PyErr_SetNone(PyExc_StopIteration);
    return NULL;
}

static int __Pyx_SetVtable(PyObject *dict, void *vtable) {
#if PY_VERSION_HEX >= 0x02070000 && !(PY_MAJOR_VERSION==3&&PY_MINOR_VERSION==0)
    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;
}

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

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

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

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_VERSION_HEX < 0x03030000
    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_VERSION_HEX >= 0x02050000
    {
        #if PY_MAJOR_VERSION >= 3
        if (level == -1) {
            if (strchr(__Pyx_MODULE_NAME, '.')) {
                #if PY_VERSION_HEX < 0x03030000
                PyObject *py_level = PyInt_FromLong(1);
                if (!py_level)
                    goto bad;
                module = PyObject_CallFunctionObjArgs(py_import,
                    name, global_dict, empty_dict, list, py_level, NULL);
                Py_DECREF(py_level);
                #else
                module = PyImport_ImportModuleLevelObject(
                    name, global_dict, empty_dict, list, 1);
                #endif
                if (!module) {
                    if (!PyErr_ExceptionMatches(PyExc_ImportError))
                        goto bad;
                    PyErr_Clear();
                }
            }
            level = 0; /* try absolute import on failure */
        }
        #endif
        if (!module) {
            #if PY_VERSION_HEX < 0x03030000
            PyObject *py_level = PyInt_FromLong(level);
            if (!py_level)
                goto bad;
            module = PyObject_CallFunctionObjArgs(py_import,
                name, global_dict, empty_dict, list, py_level, NULL);
            Py_DECREF(py_level);
            #else
            module = PyImport_ImportModuleLevelObject(
                name, global_dict, empty_dict, list, level);
            #endif
        }
    }
    #else
    if (level>0) {
        PyErr_SetString(PyExc_RuntimeError, "Relative import is not supported for Python <=2.4.");
        goto bad;
    }
    module = PyObject_CallFunctionObjArgs(py_import,
        name, global_dict, empty_dict, list, NULL);
    #endif
bad:
    #if PY_VERSION_HEX < 0x03030000
    Py_XDECREF(py_import);
    #endif
    Py_XDECREF(empty_list);
    Py_XDECREF(empty_dict);
    return module;
}

#define __PYX_VERIFY_RETURN_INT(target_type, func_type, func)             \
    {                                                                     \
        func_type value = func(x);                                        \
        if (sizeof(target_type) < sizeof(func_type)) {                    \
            if (unlikely(value != (func_type) (target_type) value)) {     \
                func_type zero = 0;                                       \
                PyErr_SetString(PyExc_OverflowError,                      \
                    (is_unsigned && unlikely(value < zero)) ?             \
                    "can't convert negative value to " #target_type :     \
                    "value too large to convert to " #target_type);       \
                return (target_type) -1;                                  \
            }                                                             \
        }                                                                 \
        return (target_type) value;                                       \
    }

#if CYTHON_COMPILING_IN_CPYTHON && PY_MAJOR_VERSION >= 3
 #if CYTHON_USE_PYLONG_INTERNALS
  #include "longintrepr.h"
 #endif
#endif
static CYTHON_INLINE int __Pyx_PyInt_As_int(PyObject *x) {
    const int neg_one = (int) -1, const_zero = 0;
    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)
        } else {
            long val = PyInt_AS_LONG(x);
            if (is_unsigned && unlikely(val < 0)) {
                PyErr_SetString(PyExc_OverflowError,
                                "can't convert negative value to int");
                return (int) -1;
            }
            return (int) val;
        }
    } else
#endif
    if (likely(PyLong_Check(x))) {
        if (is_unsigned) {
#if CYTHON_COMPILING_IN_CPYTHON && PY_MAJOR_VERSION >= 3
 #if CYTHON_USE_PYLONG_INTERNALS
            if (sizeof(digit) <= sizeof(int)) {
                switch (Py_SIZE(x)) {
                    case  0: return 0;
                    case  1: return (int) ((PyLongObject*)x)->ob_digit[0];
                }
            }
 #endif
#endif
            if (unlikely(Py_SIZE(x) < 0)) {
                PyErr_SetString(PyExc_OverflowError,
                                "can't convert negative value to int");
                return (int) -1;
            }
            if (sizeof(int) <= sizeof(unsigned long)) {
                __PYX_VERIFY_RETURN_INT(int, unsigned long, PyLong_AsUnsignedLong)
            } else if (sizeof(int) <= sizeof(unsigned long long)) {
                __PYX_VERIFY_RETURN_INT(int, unsigned long long, PyLong_AsUnsignedLongLong)
            }
        } else {
#if CYTHON_COMPILING_IN_CPYTHON && PY_MAJOR_VERSION >= 3
 #if CYTHON_USE_PYLONG_INTERNALS
            if (sizeof(digit) <= sizeof(int)) {
                switch (Py_SIZE(x)) {
                    case  0: return 0;
                    case  1: return +(int) ((PyLongObject*)x)->ob_digit[0];
                    case -1: return -(int) ((PyLongObject*)x)->ob_digit[0];
                }
            }
 #endif
#endif
            if (sizeof(int) <= sizeof(long)) {
                __PYX_VERIFY_RETURN_INT(int, long, PyLong_AsLong)
            } else if (sizeof(int) <= sizeof(long long)) {
                __PYX_VERIFY_RETURN_INT(int, long long, PyLong_AsLongLong)
            }
        }
        {
#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_Int(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_Int(x);
        if (!tmp) return (int) -1;
        val = __Pyx_PyInt_As_int(tmp);
        Py_DECREF(tmp);
        return val;
    }
}

static CYTHON_INLINE PyObject* __Pyx_PyInt_From_long(long value) {
    const long neg_one = (long) -1, const_zero = 0;
    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);
        } else if (sizeof(long) <= sizeof(unsigned long long)) {
            return PyLong_FromUnsignedLongLong((unsigned long long) value);
        }
    } else {
        if (sizeof(long) <= sizeof(long)) {
            return PyInt_FromLong((long) value);
        } else if (sizeof(long) <= sizeof(long long)) {
            return PyLong_FromLongLong((long long) value);
        }
    }
    {
        int one = 1; int little = (int)*(unsigned char *)&one;
        unsigned char *bytes = (unsigned char *)&value;
        return _PyLong_FromByteArray(bytes, sizeof(long),
                                     little, !is_unsigned);
    }
}

#if CYTHON_COMPILING_IN_CPYTHON && PY_MAJOR_VERSION >= 3
 #if CYTHON_USE_PYLONG_INTERNALS
  #include "longintrepr.h"
 #endif
#endif
static CYTHON_INLINE size_t __Pyx_PyInt_As_size_t(PyObject *x) {
    const size_t neg_one = (size_t) -1, const_zero = 0;
    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)
        } else {
            long val = PyInt_AS_LONG(x);
            if (is_unsigned && unlikely(val < 0)) {
                PyErr_SetString(PyExc_OverflowError,
                                "can't convert negative value to size_t");
                return (size_t) -1;
            }
            return (size_t) val;
        }
    } else
#endif
    if (likely(PyLong_Check(x))) {
        if (is_unsigned) {
#if CYTHON_COMPILING_IN_CPYTHON && PY_MAJOR_VERSION >= 3
 #if CYTHON_USE_PYLONG_INTERNALS
            if (sizeof(digit) <= sizeof(size_t)) {
                switch (Py_SIZE(x)) {
                    case  0: return 0;
                    case  1: return (size_t) ((PyLongObject*)x)->ob_digit[0];
                }
            }
 #endif
#endif
            if (unlikely(Py_SIZE(x) < 0)) {
                PyErr_SetString(PyExc_OverflowError,
                                "can't convert negative value to size_t");
                return (size_t) -1;
            }
            if (sizeof(size_t) <= sizeof(unsigned long)) {
                __PYX_VERIFY_RETURN_INT(size_t, unsigned long, PyLong_AsUnsignedLong)
            } else if (sizeof(size_t) <= sizeof(unsigned long long)) {
                __PYX_VERIFY_RETURN_INT(size_t, unsigned long long, PyLong_AsUnsignedLongLong)
            }
        } else {
#if CYTHON_COMPILING_IN_CPYTHON && PY_MAJOR_VERSION >= 3
 #if CYTHON_USE_PYLONG_INTERNALS
            if (sizeof(digit) <= sizeof(size_t)) {
                switch (Py_SIZE(x)) {
                    case  0: return 0;
                    case  1: return +(size_t) ((PyLongObject*)x)->ob_digit[0];
                    case -1: return -(size_t) ((PyLongObject*)x)->ob_digit[0];
                }
            }
 #endif
#endif
            if (sizeof(size_t) <= sizeof(long)) {
                __PYX_VERIFY_RETURN_INT(size_t, long, PyLong_AsLong)
            } else if (sizeof(size_t) <= sizeof(long long)) {
                __PYX_VERIFY_RETURN_INT(size_t, long long, PyLong_AsLongLong)
            }
        }
        {
#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_Int(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_Int(x);
        if (!tmp) return (size_t) -1;
        val = __Pyx_PyInt_As_size_t(tmp);
        Py_DECREF(tmp);
        return val;
    }
}

static CYTHON_INLINE PyObject* __Pyx_PyInt_From_int(int value) {
    const int neg_one = (int) -1, const_zero = 0;
    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);
        } else if (sizeof(int) <= sizeof(unsigned long long)) {
            return PyLong_FromUnsignedLongLong((unsigned long long) value);
        }
    } else {
        if (sizeof(int) <= sizeof(long)) {
            return PyInt_FromLong((long) value);
        } else if (sizeof(int) <= sizeof(long long)) {
            return PyLong_FromLongLong((long long) value);
        }
    }
    {
        int one = 1; int little = (int)*(unsigned char *)&one;
        unsigned char *bytes = (unsigned char *)&value;
        return _PyLong_FromByteArray(bytes, sizeof(int),
                                     little, !is_unsigned);
    }
}

#if CYTHON_COMPILING_IN_CPYTHON && PY_MAJOR_VERSION >= 3
 #if CYTHON_USE_PYLONG_INTERNALS
  #include "longintrepr.h"
 #endif
#endif
static CYTHON_INLINE long __Pyx_PyInt_As_long(PyObject *x) {
    const long neg_one = (long) -1, const_zero = 0;
    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)
        } else {
            long val = PyInt_AS_LONG(x);
            if (is_unsigned && unlikely(val < 0)) {
                PyErr_SetString(PyExc_OverflowError,
                                "can't convert negative value to long");
                return (long) -1;
            }
            return (long) val;
        }
    } else
#endif
    if (likely(PyLong_Check(x))) {
        if (is_unsigned) {
#if CYTHON_COMPILING_IN_CPYTHON && PY_MAJOR_VERSION >= 3
 #if CYTHON_USE_PYLONG_INTERNALS
            if (sizeof(digit) <= sizeof(long)) {
                switch (Py_SIZE(x)) {
                    case  0: return 0;
                    case  1: return (long) ((PyLongObject*)x)->ob_digit[0];
                }
            }
 #endif
#endif
            if (unlikely(Py_SIZE(x) < 0)) {
                PyErr_SetString(PyExc_OverflowError,
                                "can't convert negative value to long");
                return (long) -1;
            }
            if (sizeof(long) <= sizeof(unsigned long)) {
                __PYX_VERIFY_RETURN_INT(long, unsigned long, PyLong_AsUnsignedLong)
            } else if (sizeof(long) <= sizeof(unsigned long long)) {
                __PYX_VERIFY_RETURN_INT(long, unsigned long long, PyLong_AsUnsignedLongLong)
            }
        } else {
#if CYTHON_COMPILING_IN_CPYTHON && PY_MAJOR_VERSION >= 3
 #if CYTHON_USE_PYLONG_INTERNALS
            if (sizeof(digit) <= sizeof(long)) {
                switch (Py_SIZE(x)) {
                    case  0: return 0;
                    case  1: return +(long) ((PyLongObject*)x)->ob_digit[0];
                    case -1: return -(long) ((PyLongObject*)x)->ob_digit[0];
                }
            }
 #endif
#endif
            if (sizeof(long) <= sizeof(long)) {
                __PYX_VERIFY_RETURN_INT(long, long, PyLong_AsLong)
            } else if (sizeof(long) <= sizeof(long long)) {
                __PYX_VERIFY_RETURN_INT(long, long long, PyLong_AsLongLong)
            }
        }
        {
#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_Int(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_Int(x);
        if (!tmp) return (long) -1;
        val = __Pyx_PyInt_As_long(tmp);
        Py_DECREF(tmp);
        return val;
    }
}

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);
        #if PY_VERSION_HEX < 0x02050000
        return PyErr_Warn(NULL, message);
        #else
        return PyErr_WarnEx(NULL, message, 1);
        #endif
    }
    return 0;
}

#ifndef __PYX_HAVE_RT_ImportModule
#define __PYX_HAVE_RT_ImportModule
static PyObject *__Pyx_ImportModule(const char *name) {
    PyObject *py_name = 0;
    PyObject *py_module = 0;
    py_name = __Pyx_PyIdentifier_FromString(name);
    if (!py_name)
        goto bad;
    py_module = PyImport_Import(py_name);
    Py_DECREF(py_name);
    return py_module;
bad:
    Py_XDECREF(py_name);
    return 0;
}
#endif

#ifndef __PYX_HAVE_RT_ImportType
#define __PYX_HAVE_RT_ImportType
static PyTypeObject *__Pyx_ImportType(const char *module_name, const char *class_name,
    size_t size, int strict)
{
    PyObject *py_module = 0;
    PyObject *result = 0;
    PyObject *py_name = 0;
    char warning[200];
    Py_ssize_t basicsize;
#ifdef Py_LIMITED_API
    PyObject *py_basicsize;
#endif
    py_module = __Pyx_ImportModule(module_name);
    if (!py_module)
        goto bad;
    py_name = __Pyx_PyIdentifier_FromString(class_name);
    if (!py_name)
        goto bad;
    result = PyObject_GetAttr(py_module, py_name);
    Py_DECREF(py_name);
    py_name = 0;
    Py_DECREF(py_module);
    py_module = 0;
    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 (!strict && (size_t)basicsize > size) {
        PyOS_snprintf(warning, sizeof(warning),
            "%s.%s size changed, may indicate binary incompatibility",
            module_name, class_name);
        #if PY_VERSION_HEX < 0x02050000
        if (PyErr_Warn(NULL, warning) < 0) goto bad;
        #else
        if (PyErr_WarnEx(NULL, warning, 0) < 0) goto bad;
        #endif
    }
    else if ((size_t)basicsize != size) {
        PyErr_Format(PyExc_ValueError,
            "%.200s.%.200s has the wrong size, try recompiling",
            module_name, class_name);
        goto bad;
    }
    return (PyTypeObject *)result;
bad:
    Py_XDECREF(py_module);
    Py_XDECREF(result);
    return NULL;
}
#endif

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

#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 = 0;
    PyObject *py_srcfile = 0;
    PyObject *py_funcname = 0;
    #if PY_MAJOR_VERSION < 3
    py_srcfile = PyString_FromString(filename);
    #else
    py_srcfile = PyUnicode_FromString(filename);
    #endif
    if (!py_srcfile) goto bad;
    if (c_line) {
        #if PY_MAJOR_VERSION < 3
        py_funcname = PyString_FromFormat( "%s (%s:%d)", funcname, __pyx_cfilenm, c_line);
        #else
        py_funcname = PyUnicode_FromFormat( "%s (%s:%d)", funcname, __pyx_cfilenm, c_line);
        #endif
    }
    else {
        #if PY_MAJOR_VERSION < 3
        py_funcname = PyString_FromString(funcname);
        #else
        py_funcname = PyUnicode_FromString(funcname);
        #endif
    }
    if (!py_funcname) goto bad;
    py_code = __Pyx_PyCode_New(
        0,            /*int argcount,*/
        0,            /*int kwonlyargcount,*/
        0,            /*int nlocals,*/
        0,            /*int stacksize,*/
        0,            /*int flags,*/
        __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,      /*int firstlineno,*/
        __pyx_empty_bytes  /*PyObject *lnotab*/
    );
    Py_DECREF(py_srcfile);
    Py_DECREF(py_funcname);
    return py_code;
bad:
    Py_XDECREF(py_srcfile);
    Py_XDECREF(py_funcname);
    return NULL;
}
static void __Pyx_AddTraceback(const char *funcname, int c_line,
                               int py_line, const char *filename) {
    PyCodeObject *py_code = 0;
    PyObject *py_globals = 0;
    PyFrameObject *py_frame = 0;
    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_globals = PyModule_GetDict(__pyx_m);
    if (!py_globals) goto bad;
    py_frame = PyFrame_New(
        PyThreadState_GET(), /*PyThreadState *tstate,*/
        py_code,             /*PyCodeObject *code,*/
        py_globals,          /*PyObject *globals,*/
        0                    /*PyObject *locals*/
    );
    if (!py_frame) goto bad;
    py_frame->f_lineno = py_line;
    PyTraceBack_Here(py_frame);
bad:
    Py_XDECREF(py_code);
    Py_XDECREF(py_frame);
}

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  /* Python 3+ has unicode identifiers */
        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;
        ++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 char* __Pyx_PyObject_AsString(PyObject* o) {
    Py_ssize_t ignore;
    return __Pyx_PyObject_AsStringAndSize(o, &ignore);
}
static CYTHON_INLINE 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)) {
#if PY_VERSION_HEX < 0x03030000
        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 /*__PYX_DEFAULT_STRING_ENCODING_IS_ASCII*/
        *length = PyBytes_GET_SIZE(defenc);
        return defenc_c;
#else /* PY_VERSION_HEX < 0x03030000 */
        if (PyUnicode_READY(o) == -1) return NULL;
#if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII
        if (PyUnicode_IS_ASCII(o)) {
            *length = PyUnicode_GET_LENGTH(o);
            return PyUnicode_AsUTF8(o);
        } else {
            PyUnicode_AsASCIIString(o);
            return NULL;
        }
#else /* __PYX_DEFAULT_STRING_ENCODING_IS_ASCII */
        return PyUnicode_AsUTF8AndSize(o, length);
#endif /* __PYX_DEFAULT_STRING_ENCODING_IS_ASCII */
#endif /* PY_VERSION_HEX < 0x03030000 */
    } else
#endif /* __PYX_DEFAULT_STRING_ENCODING_IS_ASCII  || __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT */
#if !CYTHON_COMPILING_IN_PYPY
#if PY_VERSION_HEX >= 0x02060000
    if (PyByteArray_Check(o)) {
        *length = PyByteArray_GET_SIZE(o);
        return PyByteArray_AS_STRING(o);
    } else
#endif
#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 PyObject* __Pyx_PyNumber_Int(PyObject* x) {
  PyNumberMethods *m;
  const char *name = NULL;
  PyObject *res = NULL;
#if PY_MAJOR_VERSION < 3
  if (PyInt_Check(x) || PyLong_Check(x))
#else
  if (PyLong_Check(x))
#endif
    return Py_INCREF(x), x;
  m = Py_TYPE(x)->tp_as_number;
#if PY_MAJOR_VERSION < 3
  if (m && m->nb_int) {
    name = "int";
    res = PyNumber_Int(x);
  }
  else if (m && m->nb_long) {
    name = "long";
    res = PyNumber_Long(x);
  }
#else
  if (m && m->nb_int) {
    name = "int";
    res = PyNumber_Long(x);
  }
#endif
  if (res) {
#if PY_MAJOR_VERSION < 3
    if (!PyInt_Check(res) && !PyLong_Check(res)) {
#else
    if (!PyLong_Check(res)) {
#endif
      PyErr_Format(PyExc_TypeError,
                   "__%.4s__ returned non-%.4s (type %.200s)",
                   name, name, Py_TYPE(res)->tp_name);
      Py_DECREF(res);
      return NULL;
    }
  }
  else if (!PyErr_Occurred()) {
    PyErr_SetString(PyExc_TypeError,
                    "an integer is required");
  }
  return res;
}
#if CYTHON_COMPILING_IN_CPYTHON && PY_MAJOR_VERSION >= 3
 #if CYTHON_USE_PYLONG_INTERNALS
  #include "longintrepr.h"
 #endif
#endif
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)))
      return PyInt_AS_LONG(b);
#endif
  if (likely(PyLong_CheckExact(b))) {
    #if CYTHON_COMPILING_IN_CPYTHON && PY_MAJOR_VERSION >= 3
     #if CYTHON_USE_PYLONG_INTERNALS
       switch (Py_SIZE(b)) {
       case -1: return -(sdigit)((PyLongObject*)b)->ob_digit[0];
       case  0: return 0;
       case  1: return ((PyLongObject*)b)->ob_digit[0];
       }
     #endif
    #endif
  #if PY_VERSION_HEX < 0x02060000
    return PyInt_AsSsize_t(b);
  #else
    return PyLong_AsSsize_t(b);
  #endif
  }
  x = PyNumber_Index(b);
  if (!x) return -1;
  ival = PyInt_AsSsize_t(x);
  Py_DECREF(x);
  return ival;
}
static CYTHON_INLINE PyObject * __Pyx_PyInt_FromSize_t(size_t ival) {
#if PY_VERSION_HEX < 0x02050000
   if (ival <= LONG_MAX)
       return PyInt_FromLong((long)ival);
   else {
       unsigned char *bytes = (unsigned char *) &ival;
       int one = 1; int little = (int)*(unsigned char*)&one;
       return _PyLong_FromByteArray(bytes, sizeof(size_t), little, 0);
   }
#else
   return PyInt_FromSize_t(ival);
#endif
}


#endif /* Py_PYTHON_H */
