/* Generated by Cython 0.13 on Sat Nov  6 17:32:24 2010 */

#define PY_SSIZE_T_CLEAN
#include "Python.h"
#ifndef Py_PYTHON_H
    #error Python headers needed to compile C extensions, please install development version of Python.
#else

#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

#if PY_VERSION_HEX < 0x02040000
  #define METH_COEXIST 0
  #define PyDict_CheckExact(op) (Py_TYPE(op) == &PyDict_Type)
  #define PyDict_Contains(d,o)   PySequence_Contains(d,o)
#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 PyInt_FromSsize_t(z) PyInt_FromLong(z)
  #define PyInt_AsSsize_t(o)   PyInt_AsLong(o)
  #define PyNumber_Index(o)    PyNumber_Int(o)
  #define PyIndex_Check(o)     PyNumber_Check(o)
  #define PyErr_WarnEx(category, message, stacklevel) PyErr_Warn(category, message)
#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)

#endif

#if PY_MAJOR_VERSION < 3
  #define __Pyx_BUILTIN_MODULE_NAME "__builtin__"
#else
  #define __Pyx_BUILTIN_MODULE_NAME "builtins"
#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_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
  #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

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

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

#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

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

#if defined(WIN32) || defined(MS_WINDOWS)
#define _USE_MATH_DEFINES
#endif
#include <math.h>
#define __PYX_HAVE_API__lupa___lupa
#include "lua.h"
#include "lauxlib.h"
#include "lualib.h"
#include "stdio.h"
#include "pythread.h"

/* inline attribute */
#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

/* unused attribute */
#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)
#   define CYTHON_UNUSED __attribute__ ((__unused__)) 
# else
#   define CYTHON_UNUSED 
# endif
#endif

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


/* Type Conversion Predeclarations */

#define __Pyx_PyBytes_FromUString(s) PyBytes_FromString((char*)s)
#define __Pyx_PyBytes_AsUString(s)   ((unsigned char*) PyBytes_AsString(s))

#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);
static CYTHON_INLINE size_t __Pyx_PyInt_AsSize_t(PyObject*);

#define __pyx_PyFloat_AsDouble(x) (PyFloat_CheckExact(x) ? PyFloat_AS_DOUBLE(x) : PyFloat_AsDouble(x))


#ifdef __GNUC__
/* Test for GCC > 2.95 */
#if __GNUC__ > 2 || (__GNUC__ == 2 && (__GNUC_MINOR__ > 95)) 
#define likely(x)   __builtin_expect(!!(x), 1)
#define unlikely(x) __builtin_expect(!!(x), 0)
#else /* __GNUC__ > 2 ... */
#define likely(x)   (x)
#define unlikely(x) (x)
#endif /* __GNUC__ > 2 ... */
#else /* __GNUC__ */
#define likely(x)   (x)
#define unlikely(x) (x)
#endif /* __GNUC__ */
    
static PyObject *__pyx_m;
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",
  "bool.pxd",
};

/* Type declarations */

/* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":37
 * cdef class _LuaObject
 * 
 * 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
};

/* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":43
 *     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;
};

/* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":609
 * 
 * 
 * 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
};

/* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":35
 * DEF POBJECT = "POBJECT" # as used by LunaticPython
 * 
 * cdef class _LuaObject             # <<<<<<<<<<<<<<
 * 
 * cdef enum WrappedObjectFlags:
 */

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

/* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":513
 * 
 * 
 * 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;
};

/* "/home/sbehnel/source/Python/lua/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;
};

/* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":60
 *     pass
 * 
 * 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 *_raised_exception;
  PyObject *_encoding;
  PyObject *_source_encoding;
};

/* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":725
 *     return NULL
 * 
 * cdef class _PyProtocolWrapper:             # <<<<<<<<<<<<<<
 *     cdef object _obj
 *     cdef int _type_flags
 */

struct __pyx_obj_4lupa_5_lupa__PyProtocolWrapper {
  PyObject_HEAD
  PyObject *_obj;
  int _type_flags;
};

/* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":466
 * 
 * 
 * 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;
};

/* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":501
 * 
 * 
 * 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;
};

/* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":614
 *     ITEMS = 3
 * 
 * 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;
};

/* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":438
 * 
 * 
 * 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;
};


/* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":60
 *     pass
 * 
 * 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 *);
};
static struct __pyx_vtabstruct_4lupa_5_lupa_LuaRuntime *__pyx_vtabptr_4lupa_5_lupa_LuaRuntime;


/* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":248
 * # Lua object wrappers
 * 
 * cdef class _LuaObject:             # <<<<<<<<<<<<<<
 *     """A wrapper around a Lua object such as a table of function.
 *     """
 */

struct __pyx_vtabstruct_4lupa_5_lupa__LuaObject {
  int (*push_lua_object)(struct __pyx_obj_4lupa_5_lupa__LuaObject *);
};
static struct __pyx_vtabstruct_4lupa_5_lupa__LuaObject *__pyx_vtabptr_4lupa_5_lupa__LuaObject;


/* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":513
 * 
 * 
 * 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;


/* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":466
 * 
 * 
 * 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;


/* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":501
 * 
 * 
 * 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;


/* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":438
 * 
 * 
 * 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;
};
static struct __pyx_vtabstruct_4lupa_5_lupa__LuaTable *__pyx_vtabptr_4lupa_5_lupa__LuaTable;

#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) {
    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;
  }
  #define __Pyx_RefNannySetupContext(name)           void *__pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE__)
  #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_XDECREF(r) do { if((r) != NULL) {__Pyx_DECREF(r);} } while(0)
#else
  #define __Pyx_RefNannySetupContext(name)
  #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_XDECREF(r) Py_XDECREF(r)
#endif /* CYTHON_REFNANNY */
#define __Pyx_XGIVEREF(r) do { if((r) != NULL) {__Pyx_GIVEREF(r);} } while(0)
#define __Pyx_XGOTREF(r) do { if((r) != NULL) {__Pyx_GOTREF(r);} } while(0)

static PyObject *__Pyx_GetName(PyObject *dict, 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*/


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


#define __Pyx_GetItemInt_List(o, i, size, to_py_func) (((size) <= sizeof(Py_ssize_t)) ? \
                                                    __Pyx_GetItemInt_List_Fast(o, i) : \
                                                    __Pyx_GetItemInt_Generic(o, to_py_func(i)))

static CYTHON_INLINE PyObject *__Pyx_GetItemInt_List_Fast(PyObject *o, Py_ssize_t i) {
    if (likely(o != Py_None)) {
        if (likely((0 <= i) & (i < PyList_GET_SIZE(o)))) {
            PyObject *r = PyList_GET_ITEM(o, i);
            Py_INCREF(r);
            return r;
        }
        else if ((-PyList_GET_SIZE(o) <= i) & (i < 0)) {
            PyObject *r = PyList_GET_ITEM(o, PyList_GET_SIZE(o) + i);
            Py_INCREF(r);
            return r;
        }
    }
    return __Pyx_GetItemInt_Generic(o, PyInt_FromSsize_t(i));
}

#define __Pyx_GetItemInt_Tuple(o, i, size, to_py_func) (((size) <= sizeof(Py_ssize_t)) ? \
                                                    __Pyx_GetItemInt_Tuple_Fast(o, i) : \
                                                    __Pyx_GetItemInt_Generic(o, to_py_func(i)))

static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Tuple_Fast(PyObject *o, Py_ssize_t i) {
    if (likely(o != Py_None)) {
        if (likely((0 <= i) & (i < PyTuple_GET_SIZE(o)))) {
            PyObject *r = PyTuple_GET_ITEM(o, i);
            Py_INCREF(r);
            return r;
        }
        else if ((-PyTuple_GET_SIZE(o) <= i) & (i < 0)) {
            PyObject *r = PyTuple_GET_ITEM(o, PyTuple_GET_SIZE(o) + i);
            Py_INCREF(r);
            return r;
        }
    }
    return __Pyx_GetItemInt_Generic(o, PyInt_FromSsize_t(i));
}


#define __Pyx_GetItemInt(o, i, size, to_py_func) (((size) <= sizeof(Py_ssize_t)) ? \
                                                    __Pyx_GetItemInt_Fast(o, i) : \
                                                    __Pyx_GetItemInt_Generic(o, to_py_func(i)))

static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Fast(PyObject *o, Py_ssize_t i) {
    PyObject *r;
    if (PyList_CheckExact(o) && ((0 <= i) & (i < PyList_GET_SIZE(o)))) {
        r = PyList_GET_ITEM(o, i);
        Py_INCREF(r);
    }
    else if (PyTuple_CheckExact(o) && ((0 <= i) & (i < PyTuple_GET_SIZE(o)))) {
        r = PyTuple_GET_ITEM(o, i);
        Py_INCREF(r);
    }
    else if (Py_TYPE(o)->tp_as_sequence && Py_TYPE(o)->tp_as_sequence->sq_item && (likely(i >= 0))) {
        r = PySequence_GetItem(o, i);
    }
    else {
        r = __Pyx_GetItemInt_Generic(o, PyInt_FromSsize_t(i));
    }
    return r;
}

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 int __Pyx_GetException(PyObject **type, PyObject **value, PyObject **tb); /*proto*/

static int __Pyx_PyUnicode_Tailmatch(PyObject* s, PyObject* substr, Py_ssize_t start, Py_ssize_t end, int direction);

static CYTHON_INLINE PyObject* __Pyx_tp_new(PyObject* type_obj) {
    return (PyObject*) (((PyTypeObject*)(type_obj))->tp_new(
        (PyTypeObject*)(type_obj), __pyx_empty_tuple, NULL));
}

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

static int __Pyx_ArgTypeTest(PyObject *obj, PyTypeObject *type, int none_allowed,
    const char *name, int exact); /*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 PyObject *__Pyx_Import(PyObject *name, PyObject *from_list); /*proto*/

static PyObject *__Pyx_CreateClass(PyObject *bases, PyObject *dict, PyObject *name, PyObject *modname); /*proto*/

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

#ifndef __PYX_FORCE_INIT_THREADS
  #if PY_VERSION_HEX < 0x02040200
    #define __PYX_FORCE_INIT_THREADS 1
  #else
    #define __PYX_FORCE_INIT_THREADS 0
  #endif
#endif

static PyObject *__Pyx_GetAttr3(PyObject *, PyObject *, PyObject *); /*proto*/

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

static CYTHON_INLINE unsigned char __Pyx_PyInt_AsUnsignedChar(PyObject *);

static CYTHON_INLINE unsigned short __Pyx_PyInt_AsUnsignedShort(PyObject *);

static CYTHON_INLINE unsigned int __Pyx_PyInt_AsUnsignedInt(PyObject *);

static CYTHON_INLINE char __Pyx_PyInt_AsChar(PyObject *);

static CYTHON_INLINE short __Pyx_PyInt_AsShort(PyObject *);

static CYTHON_INLINE int __Pyx_PyInt_AsInt(PyObject *);

static CYTHON_INLINE signed char __Pyx_PyInt_AsSignedChar(PyObject *);

static CYTHON_INLINE signed short __Pyx_PyInt_AsSignedShort(PyObject *);

static CYTHON_INLINE signed int __Pyx_PyInt_AsSignedInt(PyObject *);

static CYTHON_INLINE int __Pyx_PyInt_AsLongDouble(PyObject *);

static CYTHON_INLINE unsigned long __Pyx_PyInt_AsUnsignedLong(PyObject *);

static CYTHON_INLINE unsigned PY_LONG_LONG __Pyx_PyInt_AsUnsignedLongLong(PyObject *);

static CYTHON_INLINE long __Pyx_PyInt_AsLong(PyObject *);

static CYTHON_INLINE PY_LONG_LONG __Pyx_PyInt_AsLongLong(PyObject *);

static CYTHON_INLINE signed long __Pyx_PyInt_AsSignedLong(PyObject *);

static CYTHON_INLINE signed PY_LONG_LONG __Pyx_PyInt_AsSignedLongLong(PyObject *);

static void __Pyx_WriteUnraisable(const char *name); /*proto*/

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

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

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

static void __Pyx_AddTraceback(const char *funcname); /*proto*/

static int __Pyx_InitStrings(__Pyx_StringTabEntry *t); /*proto*/
/* Module declarations from lupa.lua */

/* Module declarations from cpython.version */

/* Module declarations from cpython.ref */

/* Module declarations from cpython.exc */

/* Module declarations from cpython.module */

/* Module declarations from cpython.mem */

/* Module declarations from cpython.tuple */

/* Module declarations from cpython.list */

/* 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 cpython.type */

/* 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 cpython.long */

/* Module declarations from cpython.float */

/* Module declarations from cpython.complex */

/* 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.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 lupa._lupa */

static PyTypeObject *__pyx_ptype_4lupa_5_lupa__LuaObject = 0;
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__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 PyObject *__pyx_v_4lupa_5_lupa_exc_info = 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 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 int __pyx_f_4lupa_5_lupa_py_to_lua(struct __pyx_obj_4lupa_5_lupa_LuaRuntime *, lua_State *, PyObject *, int); /*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 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 *, int); /*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 void __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 struct __pyx_t_4lupa_5_lupa_py_object *__pyx_f_4lupa_5_lupa_unwrap_lua_object_from_cclosure(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, double); /*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_TypeError;
static PyObject *__pyx_builtin_enumerate;
static PyObject *__pyx_builtin_eval;
static PyObject *__pyx_builtin_UnicodeDecodeError;
static PyObject *__pyx_builtin_object;
static PyObject *__pyx_builtin_StopIteration;
static PyObject *__pyx_builtin_range;
static char __pyx_k_1[] = "cannot release un-acquired lock";
static char __pyx_k_2[] = "UTF-8";
static char __pyx_k_3[] = "Failed to initialise Lua runtime";
static char __pyx_k_4[] = "return ";
static char __pyx_k_5[] = "modulename must be a string";
static char __pyx_k_6[] = "require is not defined";
static char __pyx_k_7[] = "globals not defined";
static char __pyx_k_8[] = "failed to convert %s object";
static char __pyx_k_9[] = "Failed to acquire thread lock";
static char __pyx_k_10[] = "Type cannot be instantiated manually";
static char __pyx_k_11[] = "lost reference";
static char __pyx_k_12[] = "iteration is only supported for tables";
static char __pyx_k_13[] = "item/attribute access not supported on functions";
static char __pyx_k_14[] = "Lua object is not a table";
static char __pyx_k_15[] = "<Lua %s at %p>";
static char __pyx_k_16[] = "<Lua %s>";
static char __pyx_k_17[] = "ISO-8859-1";
static char __pyx_k_18[] = "Lua object is not a function";
static char __pyx_k_19[] = "can't send non-None value to a just-started generator";
static char __pyx_k_20[] = "LuaIter(%r)";
static char __pyx_k_21[] = "cannot iterate over non-table (found Lua %s)";
static char __pyx_k_22[] = "Type cannot be instantiated from Python";
static char __pyx_k_23[] = "cannot mix objects from different Lua runtimes";
static char __pyx_k_24[] = "<python>";
static char __pyx_k_25[] = "error loading code: %s";
static char __pyx_k_26[] = "reraise_on_exception";
static char __pyx_k_27[] = "failed to convert argument at index %d";
static char __pyx_k_28[] = "not a python object";
static char __pyx_k_29[] = "store_raised_exception";
static char __pyx_k_30[] = "error during Python call";
static char __pyx_k_31[] = "error during Python str() call";
static char __pyx_k_32[] = "invalid arguments";
static char __pyx_k_33[] = "error during type adaptation";
static char __pyx_k_34[] = "error creating an iterator";
static char __pyx_k_35[] = "error creating an iterator with enumerate()";
static char __pyx_k_36[] = "error while calling next(iterator)";
static char __pyx_k_37[] = "\nA fast Python wrapper around Lua and LuaJIT2.\n";
static char __pyx_k_38[] = "Base class for errors in the Lua runtime.\n    ";
static char __pyx_k_39[] = "lupa._lupa";
static char __pyx_k_40[] = "Syntax error in Lua code.\n    ";
static char __pyx_k__t[] = "t";
static char __pyx_k__v[] = "v";
static char __pyx_k___G[] = "_G";
static char __pyx_k____[] = "__";
static char __pyx_k__tb[] = "tb";
static char __pyx_k__exc[] = "exc";
static char __pyx_k__obj[] = "obj";
static char __pyx_k__sys[] = "sys";
static char __pyx_k____gc[] = "__gc";
static char __pyx_k___obj[] = "_obj";
static char __pyx_k___ref[] = "_ref";
static char __pyx_k__eval[] = "eval";
static char __pyx_k__func[] = "func";
static char __pyx_k__iter[] = "iter";
static char __pyx_k__name[] = "name";
static char __pyx_k__next[] = "next";
static char __pyx_k__none[] = "none";
static char __pyx_k__what[] = "what";
static char __pyx_k__ASCII[] = "ASCII";
static char __pyx_k___lock[] = "_lock";
static char __pyx_k___what[] = "_what";
static char __pyx_k__range[] = "range";
static char __pyx_k____call[] = "__call";
static char __pyx_k___count[] = "_count";
static char __pyx_k___owner[] = "_owner";
static char __pyx_k___state[] = "_state";
static char __pyx_k__decode[] = "decode";
static char __pyx_k__encode[] = "encode";
static char __pyx_k__iterex[] = "iterex";
static char __pyx_k__object[] = "object";
static char __pyx_k__python[] = "python";
static char __pyx_k__POBJECT[] = "POBJECT";
static char __pyx_k__Py_None[] = "Py_None";
static char __pyx_k____all__[] = "__all__";
static char __pyx_k____index[] = "__index";
static char __pyx_k__cpython[] = "cpython";
static char __pyx_k__require[] = "require";
static char __pyx_k__runtime[] = "runtime";
static char __pyx_k__LuaError[] = "LuaError";
static char __pyx_k____main__[] = "__main__";
static char __pyx_k____test__[] = "__test__";
static char __pyx_k___refiter[] = "_refiter";
static char __pyx_k___runtime[] = "_runtime";
static char __pyx_k__blocking[] = "blocking";
static char __pyx_k__builtins[] = "builtins";
static char __pyx_k__encoding[] = "encoding";
static char __pyx_k__endswith[] = "endswith";
static char __pyx_k__exc_info[] = "exc_info";
static char __pyx_k__Exception[] = "Exception";
static char __pyx_k__TypeError[] = "TypeError";
static char __pyx_k___co_state[] = "_co_state";
static char __pyx_k___encoding[] = "_encoding";
static char __pyx_k__coroutine[] = "coroutine";
static char __pyx_k__enumerate[] = "enumerate";
static char __pyx_k__LuaRuntime[] = "LuaRuntime";
static char __pyx_k____newindex[] = "__newindex";
static char __pyx_k____tostring[] = "__tostring";
static char __pyx_k___arguments[] = "_arguments";
static char __pyx_k___is_locked[] = "_is_locked";
static char __pyx_k___real_lock[] = "_real_lock";
static char __pyx_k__startswith[] = "startswith";
static char __pyx_k__type_flags[] = "type_flags";
static char __pyx_k__ImportError[] = "ImportError";
static char __pyx_k____builtin__[] = "__builtin__";
static char __pyx_k____getattr__[] = "__getattr__";
static char __pyx_k____getitem__[] = "__getitem__";
static char __pyx_k____setattr__[] = "__setattr__";
static char __pyx_k___type_flags[] = "_type_flags";
static char __pyx_k__as_function[] = "as_function";
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__LuaSyntaxError[] = "LuaSyntaxError";
static char __pyx_k__PyErr_NoMemory[] = "PyErr_NoMemory";
static char __pyx_k__init_python_lib[] = "init_python_lib";
static char __pyx_k__push_lua_object[] = "push_lua_object";
static char __pyx_k__source_encoding[] = "source_encoding";
static char __pyx_k___source_encoding[] = "_source_encoding";
static char __pyx_k___pending_requests[] = "_pending_requests";
static char __pyx_k___raised_exception[] = "_raised_exception";
static char __pyx_k__UnicodeDecodeError[] = "UnicodeDecodeError";
static char __pyx_k__register_py_object[] = "register_py_object";
static PyObject *__pyx_kp_s_1;
static PyObject *__pyx_kp_s_10;
static PyObject *__pyx_kp_s_11;
static PyObject *__pyx_kp_s_12;
static PyObject *__pyx_kp_s_13;
static PyObject *__pyx_kp_s_14;
static PyObject *__pyx_kp_s_17;
static PyObject *__pyx_kp_s_18;
static PyObject *__pyx_kp_s_19;
static PyObject *__pyx_kp_b_2;
static PyObject *__pyx_kp_s_2;
static PyObject *__pyx_kp_u_20;
static PyObject *__pyx_kp_s_22;
static PyObject *__pyx_kp_s_23;
static PyObject *__pyx_kp_u_25;
static PyObject *__pyx_n_s_26;
static PyObject *__pyx_kp_s_27;
static PyObject *__pyx_kp_s_28;
static PyObject *__pyx_n_s_29;
static PyObject *__pyx_kp_s_3;
static PyObject *__pyx_kp_s_38;
static PyObject *__pyx_n_s_39;
static PyObject *__pyx_kp_b_4;
static PyObject *__pyx_kp_s_40;
static PyObject *__pyx_kp_s_5;
static PyObject *__pyx_kp_s_6;
static PyObject *__pyx_kp_s_7;
static PyObject *__pyx_kp_s_8;
static PyObject *__pyx_kp_s_9;
static PyObject *__pyx_n_s__ASCII;
static PyObject *__pyx_n_s__Exception;
static PyObject *__pyx_n_s__ImportError;
static PyObject *__pyx_n_s__LuaError;
static PyObject *__pyx_n_s__LuaRuntime;
static PyObject *__pyx_n_s__LuaSyntaxError;
static PyObject *__pyx_n_s__PyErr_NoMemory;
static PyObject *__pyx_n_b__Py_None;
static PyObject *__pyx_n_s__RuntimeError;
static PyObject *__pyx_n_s__StopIteration;
static PyObject *__pyx_n_s__TypeError;
static PyObject *__pyx_n_s__UnicodeDecodeError;
static PyObject *__pyx_n_b____;
static PyObject *__pyx_n_u____;
static PyObject *__pyx_n_s____all__;
static PyObject *__pyx_n_s____builtin__;
static PyObject *__pyx_n_s____getattr__;
static PyObject *__pyx_n_s____getitem__;
static PyObject *__pyx_n_s____main__;
static PyObject *__pyx_n_s____setattr__;
static PyObject *__pyx_n_s____test__;
static PyObject *__pyx_n_s___arguments;
static PyObject *__pyx_n_s___co_state;
static PyObject *__pyx_n_s___count;
static PyObject *__pyx_n_s___encoding;
static PyObject *__pyx_n_s___is_locked;
static PyObject *__pyx_n_s___lock;
static PyObject *__pyx_n_s___obj;
static PyObject *__pyx_n_s___owner;
static PyObject *__pyx_n_s___pending_requests;
static PyObject *__pyx_n_s___raised_exception;
static PyObject *__pyx_n_s___real_lock;
static PyObject *__pyx_n_s___ref;
static PyObject *__pyx_n_s___refiter;
static PyObject *__pyx_n_s___runtime;
static PyObject *__pyx_n_s___source_encoding;
static PyObject *__pyx_n_s___state;
static PyObject *__pyx_n_s___type_flags;
static PyObject *__pyx_n_s___what;
static PyObject *__pyx_n_s__as_attrgetter;
static PyObject *__pyx_n_s__as_itemgetter;
static PyObject *__pyx_n_s__blocking;
static PyObject *__pyx_n_b__builtins;
static PyObject *__pyx_n_s__builtins;
static PyObject *__pyx_n_s__coroutine;
static PyObject *__pyx_n_s__cpython;
static PyObject *__pyx_n_s__decode;
static PyObject *__pyx_n_s__encode;
static PyObject *__pyx_n_s__encoding;
static PyObject *__pyx_n_s__endswith;
static PyObject *__pyx_n_s__enumerate;
static PyObject *__pyx_n_b__eval;
static PyObject *__pyx_n_s__eval;
static PyObject *__pyx_n_s__exc;
static PyObject *__pyx_n_s__exc_info;
static PyObject *__pyx_n_s__func;
static PyObject *__pyx_n_s__init_python_lib;
static PyObject *__pyx_n_s__name;
static PyObject *__pyx_n_s__next;
static PyObject *__pyx_n_b__none;
static PyObject *__pyx_n_s__obj;
static PyObject *__pyx_n_s__object;
static PyObject *__pyx_n_s__push_lua_object;
static PyObject *__pyx_n_s__range;
static PyObject *__pyx_n_s__register_py_object;
static PyObject *__pyx_n_s__runtime;
static PyObject *__pyx_n_s__source_encoding;
static PyObject *__pyx_n_s__startswith;
static PyObject *__pyx_n_s__sys;
static PyObject *__pyx_n_s__t;
static PyObject *__pyx_n_s__tb;
static PyObject *__pyx_n_s__type_flags;
static PyObject *__pyx_n_s__v;
static PyObject *__pyx_n_s__what;
static PyObject *__pyx_int_1;

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

static int __pyx_pf_4lupa_5_lupa_9FastRLock___cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static int __pyx_pf_4lupa_5_lupa_9FastRLock___cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  int __pyx_r;
  int __pyx_t_1;
  PyObject *__pyx_t_2;
  __Pyx_RefNannySetupContext("__cinit__");
  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;

  /* "/home/sbehnel/source/Python/lua/lupa/lupa/lock.pxi":21
 * 
 *     def __cinit__(self):
 *         self._owner = -1             # <<<<<<<<<<<<<<
 *         self._count = 0
 *         self._is_locked = False
 */
  ((struct __pyx_obj_4lupa_5_lupa_FastRLock *)__pyx_v_self)->_owner = -1;

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

  /* "/home/sbehnel/source/Python/lua/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()
 */
  ((struct __pyx_obj_4lupa_5_lupa_FastRLock *)__pyx_v_self)->_is_locked = 0;

  /* "/home/sbehnel/source/Python/lua/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:
 */
  ((struct __pyx_obj_4lupa_5_lupa_FastRLock *)__pyx_v_self)->_pending_requests = 0;

  /* "/home/sbehnel/source/Python/lua/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()
 */
  ((struct __pyx_obj_4lupa_5_lupa_FastRLock *)__pyx_v_self)->_real_lock = PyThread_allocate_lock();

  /* "/home/sbehnel/source/Python/lua/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 = (((struct __pyx_obj_4lupa_5_lupa_FastRLock *)__pyx_v_self)->_real_lock == NULL);
  if (__pyx_t_1) {

    /* "/home/sbehnel/source/Python/lua/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_L5;
  }
  __pyx_L5:;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_AddTraceback("lupa._lupa.FastRLock.__cinit__");
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lua/lupa/lupa/lock.pxi":29
 *             PyErr_NoMemory()
 * 
 *     def __dealloc__(self):             # <<<<<<<<<<<<<<
 *         if self._real_lock is not NULL:
 *             pythread.PyThread_free_lock(self._real_lock)
 */

static void __pyx_pf_4lupa_5_lupa_9FastRLock___dealloc__(PyObject *__pyx_v_self); /*proto*/
static void __pyx_pf_4lupa_5_lupa_9FastRLock___dealloc__(PyObject *__pyx_v_self) {
  int __pyx_t_1;
  __Pyx_RefNannySetupContext("__dealloc__");

  /* "/home/sbehnel/source/Python/lua/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 = (((struct __pyx_obj_4lupa_5_lupa_FastRLock *)__pyx_v_self)->_real_lock != NULL);
  if (__pyx_t_1) {

    /* "/home/sbehnel/source/Python/lua/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(((struct __pyx_obj_4lupa_5_lupa_FastRLock *)__pyx_v_self)->_real_lock);

    /* "/home/sbehnel/source/Python/lua/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):
 */
    ((struct __pyx_obj_4lupa_5_lupa_FastRLock *)__pyx_v_self)->_real_lock = NULL;
    goto __pyx_L5;
  }
  __pyx_L5:;

  __Pyx_RefNannyFinishContext();
}

/* "/home/sbehnel/source/Python/lua/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)
 * 
 */

static PyObject *__pyx_pf_4lupa_5_lupa_9FastRLock_acquire(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4lupa_5_lupa_9FastRLock_acquire[] = "FastRLock.acquire(self, int blocking=True)";
static PyObject *__pyx_pf_4lupa_5_lupa_9FastRLock_acquire(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  int __pyx_v_blocking;
  PyObject *__pyx_r = NULL;
  PyObject *__pyx_t_1 = NULL;
  static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__blocking,0};
  __Pyx_RefNannySetupContext("acquire");
  if (unlikely(__pyx_kwds)) {
    Py_ssize_t kw_args = PyDict_Size(__pyx_kwds);
    PyObject* values[1] = {0};
    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;
    }
    switch (PyTuple_GET_SIZE(__pyx_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, PyTuple_GET_SIZE(__pyx_args), "acquire") < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 34; __pyx_clineno = __LINE__; goto __pyx_L3_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);
    }
  } else {
    __pyx_v_blocking = ((int)1);
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  1: __pyx_v_blocking = __Pyx_PyObject_IsTrue(PyTuple_GET_ITEM(__pyx_args, 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;}
      case  0: break;
      default: goto __pyx_L5_argtuple_error;
    }
  }
  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_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;

  /* "/home/sbehnel/source/Python/lua/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(((struct __pyx_obj_4lupa_5_lupa_FastRLock *)__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;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("lupa._lupa.FastRLock.acquire");
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lua/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")
 */

static PyObject *__pyx_pf_4lupa_5_lupa_9FastRLock_release(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static char __pyx_doc_4lupa_5_lupa_9FastRLock_release[] = "FastRLock.release(self)";
static PyObject *__pyx_pf_4lupa_5_lupa_9FastRLock_release(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = NULL;
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  __Pyx_RefNannySetupContext("release");

  /* "/home/sbehnel/source/Python/lua/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 = (((struct __pyx_obj_4lupa_5_lupa_FastRLock *)__pyx_v_self)->_owner != PyThread_get_thread_ident());
  if (__pyx_t_1) {

    /* "/home/sbehnel/source/Python/lua/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 = PyTuple_New(1); 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_INCREF(((PyObject *)__pyx_kp_s_1));
    PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_kp_s_1));
    __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_1));
    __pyx_t_3 = PyObject_Call(__pyx_builtin_RuntimeError, __pyx_t_2, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 39; __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);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    {__pyx_filename = __pyx_f[1]; __pyx_lineno = 39; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    goto __pyx_L5;
  }
  __pyx_L5:;

  /* "/home/sbehnel/source/Python/lua/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(((struct __pyx_obj_4lupa_5_lupa_FastRLock *)__pyx_v_self));

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("lupa._lupa.FastRLock.release");
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

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

static PyObject *__pyx_pf_4lupa_5_lupa_9FastRLock___enter__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static char __pyx_doc_4lupa_5_lupa_9FastRLock___enter__[] = "FastRLock.__enter__(self)";
static PyObject *__pyx_pf_4lupa_5_lupa_9FastRLock___enter__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = NULL;
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("__enter__");

  /* "/home/sbehnel/source/Python/lua/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(((struct __pyx_obj_4lupa_5_lupa_FastRLock *)__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;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("lupa._lupa.FastRLock.__enter__");
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lua/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():
 */

static PyObject *__pyx_pf_4lupa_5_lupa_9FastRLock___exit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4lupa_5_lupa_9FastRLock___exit__[] = "FastRLock.__exit__(self, t, v, tb)";
static PyObject *__pyx_pf_4lupa_5_lupa_9FastRLock___exit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_t = 0;
  PyObject *__pyx_v_v = 0;
  PyObject *__pyx_v_tb = 0;
  PyObject *__pyx_r = NULL;
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__t,&__pyx_n_s__v,&__pyx_n_s__tb,0};
  __Pyx_RefNannySetupContext("__exit__");
  if (unlikely(__pyx_kwds)) {
    Py_ssize_t kw_args = PyDict_Size(__pyx_kwds);
    PyObject* values[3] = {0,0,0};
    switch (PyTuple_GET_SIZE(__pyx_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;
    }
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  0:
      values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__t);
      if (likely(values[0])) kw_args--;
      else goto __pyx_L5_argtuple_error;
      case  1:
      values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__v);
      if (likely(values[1])) 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:
      values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__tb);
      if (likely(values[2])) 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, PyTuple_GET_SIZE(__pyx_args), "__exit__") < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 48; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    }
    __pyx_v_t = values[0];
    __pyx_v_v = values[1];
    __pyx_v_tb = values[2];
  } else if (PyTuple_GET_SIZE(__pyx_args) != 3) {
    goto __pyx_L5_argtuple_error;
  } else {
    __pyx_v_t = PyTuple_GET_ITEM(__pyx_args, 0);
    __pyx_v_v = PyTuple_GET_ITEM(__pyx_args, 1);
    __pyx_v_tb = PyTuple_GET_ITEM(__pyx_args, 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_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;

  /* "/home/sbehnel/source/Python/lua/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 = (((struct __pyx_obj_4lupa_5_lupa_FastRLock *)__pyx_v_self)->_owner != PyThread_get_thread_ident());
  if (__pyx_t_1) {

    /* "/home/sbehnel/source/Python/lua/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 = PyTuple_New(1); 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_INCREF(((PyObject *)__pyx_kp_s_1));
    PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_kp_s_1));
    __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_1));
    __pyx_t_3 = PyObject_Call(__pyx_builtin_RuntimeError, __pyx_t_2, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 51; __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);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    {__pyx_filename = __pyx_f[1]; __pyx_lineno = 51; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    goto __pyx_L6;
  }
  __pyx_L6:;

  /* "/home/sbehnel/source/Python/lua/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(((struct __pyx_obj_4lupa_5_lupa_FastRLock *)__pyx_v_self));

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("lupa._lupa.FastRLock.__exit__");
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

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

static PyObject *__pyx_pf_4lupa_5_lupa_9FastRLock__is_owned(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static char __pyx_doc_4lupa_5_lupa_9FastRLock__is_owned[] = "FastRLock._is_owned(self)";
static PyObject *__pyx_pf_4lupa_5_lupa_9FastRLock__is_owned(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = NULL;
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("_is_owned");

  /* "/home/sbehnel/source/Python/lua/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((((struct __pyx_obj_4lupa_5_lupa_FastRLock *)__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;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("lupa._lupa.FastRLock._is_owned");
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lua/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;

  /* "/home/sbehnel/source/Python/lua/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:
 */
  if (__pyx_v_lock->_count) {

    /* "/home/sbehnel/source/Python/lua/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);
    if (__pyx_t_1) {

      /* "/home/sbehnel/source/Python/lua/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 += 1;

      /* "/home/sbehnel/source/Python/lua/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_L4;
    }
    __pyx_L4:;
    goto __pyx_L3;
  }

  /* "/home/sbehnel/source/Python/lua/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);
  if (__pyx_t_1) {

    /* "/home/sbehnel/source/Python/lua/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;

    /* "/home/sbehnel/source/Python/lua/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;

    /* "/home/sbehnel/source/Python/lua/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;
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "/home/sbehnel/source/Python/lua/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) {
    __pyx_t_2 = WAIT_LOCK;
  } else {
    __pyx_t_2 = NOWAIT_LOCK;
  }
  __pyx_r = __pyx_f_4lupa_5_lupa__acquire_lock(__pyx_v_lock, __pyx_v_current_thread, __pyx_t_2);
  goto __pyx_L0;

  __pyx_r = 0;
  __pyx_L0:;
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lua/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;

  /* "/home/sbehnel/source/Python/lua/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);
  if (__pyx_t_1) {
    __pyx_t_2 = (!__pyx_v_lock->_pending_requests);
    __pyx_t_3 = __pyx_t_2;
  } else {
    __pyx_t_3 = __pyx_t_1;
  }
  if (__pyx_t_3) {

    /* "/home/sbehnel/source/Python/lua/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));
    if (__pyx_t_3) {

      /* "/home/sbehnel/source/Python/lua/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;
      goto __pyx_L4;
    }
    __pyx_L4:;

    /* "/home/sbehnel/source/Python/lua/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:;

  /* "/home/sbehnel/source/Python/lua/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 += 1;

  /* "/home/sbehnel/source/Python/lua/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;
    #endif
    Py_UNBLOCK_THREADS
    /*try:*/ {

      /* "/home/sbehnel/source/Python/lua/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);
    }

    /* "/home/sbehnel/source/Python/lua/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:*/ {
      Py_BLOCK_THREADS
    }
  }

  /* "/home/sbehnel/source/Python/lua/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 -= 1;

  /* "/home/sbehnel/source/Python/lua/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);
  if (__pyx_t_3) {

    /* "/home/sbehnel/source/Python/lua/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;
    goto __pyx_L8;
  }
  __pyx_L8:;

  /* "/home/sbehnel/source/Python/lua/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;

  /* "/home/sbehnel/source/Python/lua/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;

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

  /* "/home/sbehnel/source/Python/lua/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;

  __pyx_r = 0;
  __pyx_L0:;
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lua/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;

  /* "/home/sbehnel/source/Python/lua/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 -= 1;

  /* "/home/sbehnel/source/Python/lua/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);
  if (__pyx_t_1) {

    /* "/home/sbehnel/source/Python/lua/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;

    /* "/home/sbehnel/source/Python/lua/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
 */
    if (__pyx_v_lock->_is_locked) {

      /* "/home/sbehnel/source/Python/lua/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);

      /* "/home/sbehnel/source/Python/lua/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:;

}

/* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":95
 *     cdef bytes _source_encoding
 * 
 *     def __cinit__(self, encoding='UTF-8', source_encoding=None):             # <<<<<<<<<<<<<<
 *         self._state = NULL
 *         cdef lua_State* L = lua.lua_open()
 */

static int __pyx_pf_4lupa_5_lupa_10LuaRuntime___cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static int __pyx_pf_4lupa_5_lupa_10LuaRuntime___cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_encoding = 0;
  PyObject *__pyx_v_source_encoding = 0;
  lua_State *__pyx_v_L;
  int __pyx_r;
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  int __pyx_t_6;
  static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__encoding,&__pyx_n_s__source_encoding,0};
  __Pyx_RefNannySetupContext("__cinit__");
  if (unlikely(__pyx_kwds)) {
    Py_ssize_t kw_args = PyDict_Size(__pyx_kwds);
    PyObject* values[2] = {0,0};
    values[0] = ((PyObject *)__pyx_kp_s_2);
    values[1] = ((PyObject *)Py_None);
    switch (PyTuple_GET_SIZE(__pyx_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;
    }
    switch (PyTuple_GET_SIZE(__pyx_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--; }
      }
    }
    if (unlikely(kw_args > 0)) {
      if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "__cinit__") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 95; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    }
    __pyx_v_encoding = values[0];
    __pyx_v_source_encoding = values[1];
  } else {
    __pyx_v_encoding = ((PyObject *)__pyx_kp_s_2);
    __pyx_v_source_encoding = ((PyObject *)Py_None);
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  2: __pyx_v_source_encoding = PyTuple_GET_ITEM(__pyx_args, 1);
      case  1: __pyx_v_encoding = PyTuple_GET_ITEM(__pyx_args, 0);
      case  0: break;
      default: goto __pyx_L5_argtuple_error;
    }
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("__cinit__", 0, 0, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 95; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("lupa._lupa.LuaRuntime.__cinit__");
  __Pyx_RefNannyFinishContext();
  return -1;
  __pyx_L4_argument_unpacking_done:;

  /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":96
 * 
 *     def __cinit__(self, encoding='UTF-8', source_encoding=None):
 *         self._state = NULL             # <<<<<<<<<<<<<<
 *         cdef lua_State* L = lua.lua_open()
 *         if L is NULL:
 */
  ((struct __pyx_obj_4lupa_5_lupa_LuaRuntime *)__pyx_v_self)->_state = NULL;

  /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":97
 *     def __cinit__(self, encoding='UTF-8', source_encoding=None):
 *         self._state = NULL
 *         cdef lua_State* L = lua.lua_open()             # <<<<<<<<<<<<<<
 *         if L is NULL:
 *             raise LuaError("Failed to initialise Lua runtime")
 */
  __pyx_v_L = lua_open();

  /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":98
 *         self._state = NULL
 *         cdef lua_State* L = lua.lua_open()
 *         if L is NULL:             # <<<<<<<<<<<<<<
 *             raise LuaError("Failed to initialise Lua runtime")
 *         self._state = L
 */
  __pyx_t_1 = (__pyx_v_L == NULL);
  if (__pyx_t_1) {

    /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":99
 *         cdef lua_State* L = lua.lua_open()
 *         if L is NULL:
 *             raise LuaError("Failed to initialise Lua runtime")             # <<<<<<<<<<<<<<
 *         self._state = L
 *         self._lock = FastRLock()
 */
    __pyx_t_2 = __Pyx_GetName(__pyx_m, __pyx_n_s__LuaError); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 99; __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 = 99; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_INCREF(((PyObject *)__pyx_kp_s_3));
    PyTuple_SET_ITEM(__pyx_t_3, 0, ((PyObject *)__pyx_kp_s_3));
    __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_3));
    __pyx_t_4 = PyObject_Call(__pyx_t_2, __pyx_t_3, NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 99; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_Raise(__pyx_t_4, 0, 0);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 99; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    goto __pyx_L6;
  }
  __pyx_L6:;

  /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":100
 *         if L is NULL:
 *             raise LuaError("Failed to initialise Lua runtime")
 *         self._state = L             # <<<<<<<<<<<<<<
 *         self._lock = FastRLock()
 *         self._encoding = None if encoding is None else encoding.encode('ASCII')
 */
  ((struct __pyx_obj_4lupa_5_lupa_LuaRuntime *)__pyx_v_self)->_state = __pyx_v_L;

  /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":101
 *             raise LuaError("Failed to initialise Lua runtime")
 *         self._state = L
 *         self._lock = FastRLock()             # <<<<<<<<<<<<<<
 *         self._encoding = None if encoding is None else encoding.encode('ASCII')
 *         self._source_encoding = self._encoding or b'UTF-8'
 */
  __pyx_t_4 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_4lupa_5_lupa_FastRLock)), ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 101; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_GIVEREF(__pyx_t_4);
  __Pyx_GOTREF(((struct __pyx_obj_4lupa_5_lupa_LuaRuntime *)__pyx_v_self)->_lock);
  __Pyx_DECREF(((PyObject *)((struct __pyx_obj_4lupa_5_lupa_LuaRuntime *)__pyx_v_self)->_lock));
  ((struct __pyx_obj_4lupa_5_lupa_LuaRuntime *)__pyx_v_self)->_lock = ((struct __pyx_obj_4lupa_5_lupa_FastRLock *)__pyx_t_4);
  __pyx_t_4 = 0;

  /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":102
 *         self._state = L
 *         self._lock = FastRLock()
 *         self._encoding = None if encoding is None else encoding.encode('ASCII')             # <<<<<<<<<<<<<<
 *         self._source_encoding = self._encoding or b'UTF-8'
 * 
 */
  __pyx_t_1 = (__pyx_v_encoding == Py_None);
  if (__pyx_t_1) {
    __Pyx_INCREF(Py_None);
    __pyx_t_4 = Py_None;
  } else {
    __pyx_t_3 = PyObject_GetAttr(__pyx_v_encoding, __pyx_n_s__encode); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 102; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 102; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_INCREF(((PyObject *)__pyx_n_s__ASCII));
    PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_n_s__ASCII));
    __Pyx_GIVEREF(((PyObject *)__pyx_n_s__ASCII));
    __pyx_t_5 = PyObject_Call(__pyx_t_3, __pyx_t_2, NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 102; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_t_4 = __pyx_t_5;
    __pyx_t_5 = 0;
  }
  if (!(likely(PyBytes_CheckExact(__pyx_t_4))||((__pyx_t_4) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected bytes, got %.200s", Py_TYPE(__pyx_t_4)->tp_name), 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 102; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GIVEREF(__pyx_t_4);
  __Pyx_GOTREF(((struct __pyx_obj_4lupa_5_lupa_LuaRuntime *)__pyx_v_self)->_encoding);
  __Pyx_DECREF(((PyObject *)((struct __pyx_obj_4lupa_5_lupa_LuaRuntime *)__pyx_v_self)->_encoding));
  ((struct __pyx_obj_4lupa_5_lupa_LuaRuntime *)__pyx_v_self)->_encoding = ((PyObject *)__pyx_t_4);
  __pyx_t_4 = 0;

  /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":103
 *         self._lock = FastRLock()
 *         self._encoding = None if encoding is None else encoding.encode('ASCII')
 *         self._source_encoding = self._encoding or b'UTF-8'             # <<<<<<<<<<<<<<
 * 
 *         lua.luaL_openlibs(L)
 */
  __pyx_t_1 = __Pyx_PyObject_IsTrue(((PyObject *)((struct __pyx_obj_4lupa_5_lupa_LuaRuntime *)__pyx_v_self)->_encoding)); if (unlikely(__pyx_t_1 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 103; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (!__pyx_t_1) {
    __Pyx_INCREF(((PyObject *)__pyx_kp_b_2));
    __pyx_t_4 = __pyx_kp_b_2;
  } else {
    __Pyx_INCREF(((PyObject *)((struct __pyx_obj_4lupa_5_lupa_LuaRuntime *)__pyx_v_self)->_encoding));
    __pyx_t_4 = ((struct __pyx_obj_4lupa_5_lupa_LuaRuntime *)__pyx_v_self)->_encoding;
  }
  if (!(likely(PyBytes_CheckExact(__pyx_t_4))||(PyErr_Format(PyExc_TypeError, "Expected bytes, got %.200s", Py_TYPE(__pyx_t_4)->tp_name), 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 103; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GIVEREF(__pyx_t_4);
  __Pyx_GOTREF(((struct __pyx_obj_4lupa_5_lupa_LuaRuntime *)__pyx_v_self)->_source_encoding);
  __Pyx_DECREF(((PyObject *)((struct __pyx_obj_4lupa_5_lupa_LuaRuntime *)__pyx_v_self)->_source_encoding));
  ((struct __pyx_obj_4lupa_5_lupa_LuaRuntime *)__pyx_v_self)->_source_encoding = ((PyObject *)__pyx_t_4);
  __pyx_t_4 = 0;

  /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":105
 *         self._source_encoding = self._encoding or b'UTF-8'
 * 
 *         lua.luaL_openlibs(L)             # <<<<<<<<<<<<<<
 *         self.init_python_lib()
 *         lua.lua_settop(L, 0)
 */
  luaL_openlibs(__pyx_v_L);

  /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":106
 * 
 *         lua.luaL_openlibs(L)
 *         self.init_python_lib()             # <<<<<<<<<<<<<<
 *         lua.lua_settop(L, 0)
 *         lua.lua_atpanic(L, <lua.lua_CFunction>1)
 */
  __pyx_t_6 = ((struct __pyx_vtabstruct_4lupa_5_lupa_LuaRuntime *)((struct __pyx_obj_4lupa_5_lupa_LuaRuntime *)__pyx_v_self)->__pyx_vtab)->init_python_lib(((struct __pyx_obj_4lupa_5_lupa_LuaRuntime *)__pyx_v_self)); if (unlikely(__pyx_t_6 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 106; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":107
 *         lua.luaL_openlibs(L)
 *         self.init_python_lib()
 *         lua.lua_settop(L, 0)             # <<<<<<<<<<<<<<
 *         lua.lua_atpanic(L, <lua.lua_CFunction>1)
 * 
 */
  lua_settop(__pyx_v_L, 0);

  /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":108
 *         self.init_python_lib()
 *         lua.lua_settop(L, 0)
 *         lua.lua_atpanic(L, <lua.lua_CFunction>1)             # <<<<<<<<<<<<<<
 * 
 *     def __dealloc__(self):
 */
  lua_atpanic(__pyx_v_L, ((lua_CFunction)1));

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_AddTraceback("lupa._lupa.LuaRuntime.__cinit__");
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

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

static void __pyx_pf_4lupa_5_lupa_10LuaRuntime___dealloc__(PyObject *__pyx_v_self); /*proto*/
static void __pyx_pf_4lupa_5_lupa_10LuaRuntime___dealloc__(PyObject *__pyx_v_self) {
  int __pyx_t_1;
  __Pyx_RefNannySetupContext("__dealloc__");

  /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":111
 * 
 *     def __dealloc__(self):
 *         if self._state is not NULL:             # <<<<<<<<<<<<<<
 *             lua.lua_close(self._state)
 *             self._state = NULL
 */
  __pyx_t_1 = (((struct __pyx_obj_4lupa_5_lupa_LuaRuntime *)__pyx_v_self)->_state != NULL);
  if (__pyx_t_1) {

    /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":112
 *     def __dealloc__(self):
 *         if self._state is not NULL:
 *             lua.lua_close(self._state)             # <<<<<<<<<<<<<<
 *             self._state = NULL
 * 
 */
    lua_close(((struct __pyx_obj_4lupa_5_lupa_LuaRuntime *)__pyx_v_self)->_state);

    /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":113
 *         if self._state is not NULL:
 *             lua.lua_close(self._state)
 *             self._state = NULL             # <<<<<<<<<<<<<<
 * 
 *     cdef int reraise_on_exception(self) except -1:
 */
    ((struct __pyx_obj_4lupa_5_lupa_LuaRuntime *)__pyx_v_self)->_state = NULL;
    goto __pyx_L5;
  }
  __pyx_L5:;

  __Pyx_RefNannyFinishContext();
}

/* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":115
 *             self._state = NULL
 * 
 *     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;
  int __pyx_r;
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  __Pyx_RefNannySetupContext("reraise_on_exception");
  __pyx_v_exception = ((PyObject *)Py_None); __Pyx_INCREF(Py_None);

  /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":116
 * 
 *     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));
  if (__pyx_t_1) {

    /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":117
 *     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_INCREF(((PyObject *)__pyx_v_self->_raised_exception));
    __Pyx_DECREF(((PyObject *)__pyx_v_exception));
    __pyx_v_exception = __pyx_v_self->_raised_exception;

    /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":118
 *         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(((PyObject *)__pyx_v_self->_raised_exception));
    __pyx_v_self->_raised_exception = ((PyObject *)Py_None);

    /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":119
 *             exception = self._raised_exception
 *             self._raised_exception = None
 *             raise exception[0], exception[1], exception[2]             # <<<<<<<<<<<<<<
 *         return 0
 * 
 */
    __pyx_t_2 = __Pyx_GetItemInt_Tuple(((PyObject *)__pyx_v_exception), 0, sizeof(long), PyInt_FromLong); if (!__pyx_t_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 119; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_3 = __Pyx_GetItemInt_Tuple(((PyObject *)__pyx_v_exception), 1, sizeof(long), PyInt_FromLong); if (!__pyx_t_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 119; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_4 = __Pyx_GetItemInt_Tuple(((PyObject *)__pyx_v_exception), 2, sizeof(long), PyInt_FromLong); if (!__pyx_t_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 119; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_Raise(__pyx_t_2, __pyx_t_3, __pyx_t_4);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 119; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":120
 *             self._raised_exception = None
 *             raise exception[0], exception[1], exception[2]
 *         return 0             # <<<<<<<<<<<<<<
 * 
 *     cdef int store_raised_exception(self) except -1:
 */
  __pyx_r = 0;
  goto __pyx_L0;

  __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.reraise_on_exception");
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_DECREF(__pyx_v_exception);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":122
 *         return 0
 * 
 *     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;
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("store_raised_exception");

  /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":123
 * 
 *     cdef int store_raised_exception(self) except -1:
 *         self._raised_exception = exc_info()             # <<<<<<<<<<<<<<
 *         return 0
 * 
 */
  __pyx_t_1 = PyObject_Call(__pyx_v_4lupa_5_lupa_exc_info, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 123; __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 tuple, got %.200s", Py_TYPE(__pyx_t_1)->tp_name), 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 123; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v_self->_raised_exception);
  __Pyx_DECREF(((PyObject *)__pyx_v_self->_raised_exception));
  __pyx_v_self->_raised_exception = ((PyObject *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":124
 *     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;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("lupa._lupa.LuaRuntime.store_raised_exception");
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":126
 *         return 0
 * 
 *     def eval(self, lua_code):             # <<<<<<<<<<<<<<
 *         """Evaluate a Lua expression passed in a string.
 *         """
 */

static PyObject *__pyx_pf_4lupa_5_lupa_10LuaRuntime_eval(PyObject *__pyx_v_self, PyObject *__pyx_v_lua_code); /*proto*/
static char __pyx_doc_4lupa_5_lupa_10LuaRuntime_eval[] = "LuaRuntime.eval(self, lua_code)\nEvaluate a Lua expression passed in a string.\n        ";
static PyObject *__pyx_pf_4lupa_5_lupa_10LuaRuntime_eval(PyObject *__pyx_v_self, PyObject *__pyx_v_lua_code) {
  PyObject *__pyx_r = NULL;
  int __pyx_t_1;
  char *__pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  __Pyx_RefNannySetupContext("eval");
  __Pyx_INCREF(__pyx_v_lua_code);

  /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":129
 *         """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 PYREX_WITHOUT_ASSERTIONS
  if (unlikely(!(((struct __pyx_obj_4lupa_5_lupa_LuaRuntime *)__pyx_v_self)->_state != NULL))) {
    PyErr_SetNone(PyExc_AssertionError);
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 129; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  #endif

  /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":130
 *         """
 *         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); 
  if (__pyx_t_1) {

    /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":131
 *         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(((PyObject *)__pyx_v_lua_code) == Py_None)) {
      PyErr_SetString(PyExc_AttributeError, "'NoneType' object has no attribute 'encode'"); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 131; __pyx_clineno = __LINE__; goto __pyx_L1_error;} 
    }
    __pyx_t_2 = PyBytes_AsString(((PyObject *)((struct __pyx_obj_4lupa_5_lupa_LuaRuntime *)__pyx_v_self)->_source_encoding)); if (unlikely((!__pyx_t_2) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 131; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_3 = ((PyObject *)PyUnicode_AsEncodedString(((PyObject *)__pyx_v_lua_code), __pyx_t_2, NULL)); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 131; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(((PyObject *)__pyx_t_3));
    __Pyx_DECREF(__pyx_v_lua_code);
    __pyx_v_lua_code = ((PyObject *)__pyx_t_3);
    __pyx_t_3 = 0;
    goto __pyx_L5;
  }
  __pyx_L5:;

  /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":132
 *         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_3 = PyNumber_Add(((PyObject *)__pyx_kp_b_4), __pyx_v_lua_code); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 132; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  if (!(likely(PyBytes_CheckExact(__pyx_t_3))||((__pyx_t_3) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected bytes, got %.200s", Py_TYPE(__pyx_t_3)->tp_name), 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 132; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_4 = __pyx_f_4lupa_5_lupa_run_lua(((struct __pyx_obj_4lupa_5_lupa_LuaRuntime *)__pyx_v_self), ((PyObject *)__pyx_t_3)); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 132; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_r = __pyx_t_4;
  __pyx_t_4 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_AddTraceback("lupa._lupa.LuaRuntime.eval");
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_DECREF(__pyx_v_lua_code);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":134
 *         return run_lua(self, b'return ' + lua_code)
 * 
 *     def execute(self, lua_code):             # <<<<<<<<<<<<<<
 *         """Execute a Lua program passed in a string.
 *         """
 */

static PyObject *__pyx_pf_4lupa_5_lupa_10LuaRuntime_execute(PyObject *__pyx_v_self, PyObject *__pyx_v_lua_code); /*proto*/
static char __pyx_doc_4lupa_5_lupa_10LuaRuntime_execute[] = "LuaRuntime.execute(self, lua_code)\nExecute a Lua program passed in a string.\n        ";
static PyObject *__pyx_pf_4lupa_5_lupa_10LuaRuntime_execute(PyObject *__pyx_v_self, PyObject *__pyx_v_lua_code) {
  PyObject *__pyx_r = NULL;
  int __pyx_t_1;
  char *__pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  __Pyx_RefNannySetupContext("execute");
  __Pyx_INCREF(__pyx_v_lua_code);

  /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":137
 *         """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 PYREX_WITHOUT_ASSERTIONS
  if (unlikely(!(((struct __pyx_obj_4lupa_5_lupa_LuaRuntime *)__pyx_v_self)->_state != NULL))) {
    PyErr_SetNone(PyExc_AssertionError);
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 137; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  #endif

  /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":138
 *         """
 *         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); 
  if (__pyx_t_1) {

    /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":139
 *         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(((PyObject *)__pyx_v_lua_code) == Py_None)) {
      PyErr_SetString(PyExc_AttributeError, "'NoneType' object has no attribute 'encode'"); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 139; __pyx_clineno = __LINE__; goto __pyx_L1_error;} 
    }
    __pyx_t_2 = PyBytes_AsString(((PyObject *)((struct __pyx_obj_4lupa_5_lupa_LuaRuntime *)__pyx_v_self)->_source_encoding)); if (unlikely((!__pyx_t_2) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 139; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_3 = ((PyObject *)PyUnicode_AsEncodedString(((PyObject *)__pyx_v_lua_code), __pyx_t_2, NULL)); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 139; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(((PyObject *)__pyx_t_3));
    __Pyx_DECREF(__pyx_v_lua_code);
    __pyx_v_lua_code = ((PyObject *)__pyx_t_3);
    __pyx_t_3 = 0;
    goto __pyx_L5;
  }
  __pyx_L5:;

  /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":140
 *         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 bytes, got %.200s", Py_TYPE(__pyx_v_lua_code)->tp_name), 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 140; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_3 = __pyx_f_4lupa_5_lupa_run_lua(((struct __pyx_obj_4lupa_5_lupa_LuaRuntime *)__pyx_v_self), ((PyObject *)__pyx_v_lua_code)); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 140; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_r = __pyx_t_3;
  __pyx_t_3 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("lupa._lupa.LuaRuntime.execute");
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_DECREF(__pyx_v_lua_code);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":142
 *         return run_lua(self, lua_code)
 * 
 *     def require(self, modulename):             # <<<<<<<<<<<<<<
 *         """Load a Lua library into the runtime.
 *         """
 */

static PyObject *__pyx_pf_4lupa_5_lupa_10LuaRuntime_require(PyObject *__pyx_v_self, PyObject *__pyx_v_modulename); /*proto*/
static char __pyx_doc_4lupa_5_lupa_10LuaRuntime_require[] = "LuaRuntime.require(self, modulename)\nLoad a Lua library into the runtime.\n        ";
static PyObject *__pyx_pf_4lupa_5_lupa_10LuaRuntime_require(PyObject *__pyx_v_self, PyObject *__pyx_v_modulename) {
  lua_State *__pyx_v_L;
  PyObject *__pyx_r = NULL;
  PyObject *__pyx_t_1 = NULL;
  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;
  __Pyx_RefNannySetupContext("require");

  /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":145
 *         """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 PYREX_WITHOUT_ASSERTIONS
  if (unlikely(!(((struct __pyx_obj_4lupa_5_lupa_LuaRuntime *)__pyx_v_self)->_state != NULL))) {
    PyErr_SetNone(PyExc_AssertionError);
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 145; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  #endif

  /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":146
 *         """
 *         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_v_L = ((struct __pyx_obj_4lupa_5_lupa_LuaRuntime *)__pyx_v_self)->_state;

  /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":147
 *         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_INCREF(__pyx_v_modulename);
  __pyx_t_1 = __pyx_v_modulename;
  __pyx_t_2 = PyBytes_Check(__pyx_t_1); 
  if (!__pyx_t_2) {
    __pyx_t_3 = PyUnicode_Check(__pyx_t_1); 
    __pyx_t_4 = __pyx_t_3;
  } else {
    __pyx_t_4 = __pyx_t_2;
  }
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_2 = (!__pyx_t_4);
  if (__pyx_t_2) {

    /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":148
 *         cdef lua_State *L = self._state
 *         if not isinstance(modulename, (bytes, unicode)):
 *             raise TypeError("modulename must be a string")             # <<<<<<<<<<<<<<
 *         lock_runtime(self)
 *         try:
 */
    __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 148; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_INCREF(((PyObject *)__pyx_kp_s_5));
    PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)__pyx_kp_s_5));
    __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_5));
    __pyx_t_5 = PyObject_Call(__pyx_builtin_TypeError, __pyx_t_1, NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 148; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_Raise(__pyx_t_5, 0, 0);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 148; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    goto __pyx_L5;
  }
  __pyx_L5:;

  /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":149
 *         if not isinstance(modulename, (bytes, unicode)):
 *             raise TypeError("modulename must be a string")
 *         lock_runtime(self)             # <<<<<<<<<<<<<<
 *         try:
 *             lua.lua_pushlstring(L, 'require', 7)
 */
  __pyx_t_6 = __pyx_f_4lupa_5_lupa_lock_runtime(((struct __pyx_obj_4lupa_5_lupa_LuaRuntime *)__pyx_v_self)); if (unlikely(__pyx_t_6 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 149; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":150
 *             raise TypeError("modulename must be a string")
 *         lock_runtime(self)
 *         try:             # <<<<<<<<<<<<<<
 *             lua.lua_pushlstring(L, 'require', 7)
 *             lua.lua_rawget(L, lua.LUA_GLOBALSINDEX)
 */
  /*try:*/ {

    /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":151
 *         lock_runtime(self)
 *         try:
 *             lua.lua_pushlstring(L, 'require', 7)             # <<<<<<<<<<<<<<
 *             lua.lua_rawget(L, lua.LUA_GLOBALSINDEX)
 *             if lua.lua_isnil(L, -1):
 */
    lua_pushlstring(__pyx_v_L, __pyx_k__require, 7);

    /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":152
 *         try:
 *             lua.lua_pushlstring(L, 'require', 7)
 *             lua.lua_rawget(L, lua.LUA_GLOBALSINDEX)             # <<<<<<<<<<<<<<
 *             if lua.lua_isnil(L, -1):
 *                 lua.lua_pop(L, 1)
 */
    lua_rawget(__pyx_v_L, LUA_GLOBALSINDEX);

    /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":153
 *             lua.lua_pushlstring(L, 'require', 7)
 *             lua.lua_rawget(L, lua.LUA_GLOBALSINDEX)
 *             if lua.lua_isnil(L, -1):             # <<<<<<<<<<<<<<
 *                 lua.lua_pop(L, 1)
 *                 raise LuaError("require is not defined")
 */
    __pyx_t_2 = lua_isnil(__pyx_v_L, -1);
    if (__pyx_t_2) {

      /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":154
 *             lua.lua_rawget(L, lua.LUA_GLOBALSINDEX)
 *             if lua.lua_isnil(L, -1):
 *                 lua.lua_pop(L, 1)             # <<<<<<<<<<<<<<
 *                 raise LuaError("require is not defined")
 *             return call_lua(self, L, (modulename,))
 */
      lua_pop(__pyx_v_L, 1);

      /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":155
 *             if lua.lua_isnil(L, -1):
 *                 lua.lua_pop(L, 1)
 *                 raise LuaError("require is not defined")             # <<<<<<<<<<<<<<
 *             return call_lua(self, L, (modulename,))
 *         finally:
 */
      __pyx_t_5 = __Pyx_GetName(__pyx_m, __pyx_n_s__LuaError); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 155; __pyx_clineno = __LINE__; goto __pyx_L7;}
      __Pyx_GOTREF(__pyx_t_5);
      __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 155; __pyx_clineno = __LINE__; goto __pyx_L7;}
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_INCREF(((PyObject *)__pyx_kp_s_6));
      PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)__pyx_kp_s_6));
      __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_6));
      __pyx_t_7 = PyObject_Call(__pyx_t_5, __pyx_t_1, NULL); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 155; __pyx_clineno = __LINE__; goto __pyx_L7;}
      __Pyx_GOTREF(__pyx_t_7);
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __Pyx_Raise(__pyx_t_7, 0, 0);
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 155; __pyx_clineno = __LINE__; goto __pyx_L7;}
      goto __pyx_L9;
    }
    __pyx_L9:;

    /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":156
 *                 lua.lua_pop(L, 1)
 *                 raise LuaError("require is not defined")
 *             return call_lua(self, L, (modulename,))             # <<<<<<<<<<<<<<
 *         finally:
 *             unlock_runtime(self)
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_7 = PyTuple_New(1); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 156; __pyx_clineno = __LINE__; goto __pyx_L7;}
    __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);
    if (!(likely(PyTuple_CheckExact(__pyx_t_7))||(PyErr_Format(PyExc_TypeError, "Expected tuple, got %.200s", Py_TYPE(__pyx_t_7)->tp_name), 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 156; __pyx_clineno = __LINE__; goto __pyx_L7;}
    __pyx_t_1 = __pyx_f_4lupa_5_lupa_call_lua(((struct __pyx_obj_4lupa_5_lupa_LuaRuntime *)__pyx_v_self), __pyx_v_L, ((PyObject *)__pyx_t_7)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 156; __pyx_clineno = __LINE__; goto __pyx_L7;}
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    __pyx_r = __pyx_t_1;
    __pyx_t_1 = 0;
    goto __pyx_L6;
  }

  /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":158
 *             return call_lua(self, L, (modulename,))
 *         finally:
 *             unlock_runtime(self)             # <<<<<<<<<<<<<<
 * 
 *     def globals(self):
 */
  /*finally:*/ {
    int __pyx_why;
    PyObject *__pyx_exc_type, *__pyx_exc_value, *__pyx_exc_tb;
    int __pyx_exc_lineno;
    __pyx_exc_type = 0; __pyx_exc_value = 0; __pyx_exc_tb = 0; __pyx_exc_lineno = 0;
    __pyx_why = 0; goto __pyx_L8;
    __pyx_L6: __pyx_exc_type = 0; __pyx_exc_value = 0; __pyx_exc_tb = 0; __pyx_exc_lineno = 0;
    __pyx_why = 3; goto __pyx_L8;
    __pyx_L7: {
      __pyx_why = 4;
      __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
      __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
      __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
      __Pyx_ErrFetch(&__pyx_exc_type, &__pyx_exc_value, &__pyx_exc_tb);
      __pyx_exc_lineno = __pyx_lineno;
      goto __pyx_L8;
    }
    __pyx_L8:;
    __pyx_f_4lupa_5_lupa_unlock_runtime(((struct __pyx_obj_4lupa_5_lupa_LuaRuntime *)__pyx_v_self));
    switch (__pyx_why) {
      case 3: goto __pyx_L0;
      case 4: {
        __Pyx_ErrRestore(__pyx_exc_type, __pyx_exc_value, __pyx_exc_tb);
        __pyx_lineno = __pyx_exc_lineno;
        __pyx_exc_type = 0;
        __pyx_exc_value = 0;
        __pyx_exc_tb = 0;
        goto __pyx_L1_error;
      }
    }
  }

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_AddTraceback("lupa._lupa.LuaRuntime.require");
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":160
 *             unlock_runtime(self)
 * 
 *     def globals(self):             # <<<<<<<<<<<<<<
 *         """Return the globals defined in this Lua runtime as a Lua
 *         table.
 */

static PyObject *__pyx_pf_4lupa_5_lupa_10LuaRuntime_globals(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static char __pyx_doc_4lupa_5_lupa_10LuaRuntime_globals[] = "LuaRuntime.globals(self)\nReturn the globals defined in this Lua runtime as a Lua\n        table.\n        ";
static PyObject *__pyx_pf_4lupa_5_lupa_10LuaRuntime_globals(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  lua_State *__pyx_v_L;
  PyObject *__pyx_r = NULL;
  int __pyx_t_1;
  int __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  __Pyx_RefNannySetupContext("globals");

  /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":164
 *         table.
 *         """
 *         assert self._state is not NULL             # <<<<<<<<<<<<<<
 *         cdef lua_State *L = self._state
 *         lock_runtime(self)
 */
  #ifndef PYREX_WITHOUT_ASSERTIONS
  if (unlikely(!(((struct __pyx_obj_4lupa_5_lupa_LuaRuntime *)__pyx_v_self)->_state != NULL))) {
    PyErr_SetNone(PyExc_AssertionError);
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 164; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  #endif

  /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":165
 *         """
 *         assert self._state is not NULL
 *         cdef lua_State *L = self._state             # <<<<<<<<<<<<<<
 *         lock_runtime(self)
 *         try:
 */
  __pyx_v_L = ((struct __pyx_obj_4lupa_5_lupa_LuaRuntime *)__pyx_v_self)->_state;

  /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":166
 *         assert self._state is not NULL
 *         cdef lua_State *L = self._state
 *         lock_runtime(self)             # <<<<<<<<<<<<<<
 *         try:
 *             lua.lua_pushlstring(L, '_G', 2)
 */
  __pyx_t_1 = __pyx_f_4lupa_5_lupa_lock_runtime(((struct __pyx_obj_4lupa_5_lupa_LuaRuntime *)__pyx_v_self)); if (unlikely(__pyx_t_1 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 166; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":167
 *         cdef lua_State *L = self._state
 *         lock_runtime(self)
 *         try:             # <<<<<<<<<<<<<<
 *             lua.lua_pushlstring(L, '_G', 2)
 *             lua.lua_rawget(L, lua.LUA_GLOBALSINDEX)
 */
  /*try:*/ {

    /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":168
 *         lock_runtime(self)
 *         try:
 *             lua.lua_pushlstring(L, '_G', 2)             # <<<<<<<<<<<<<<
 *             lua.lua_rawget(L, lua.LUA_GLOBALSINDEX)
 *             if lua.lua_isnil(L, -1):
 */
    lua_pushlstring(__pyx_v_L, __pyx_k___G, 2);

    /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":169
 *         try:
 *             lua.lua_pushlstring(L, '_G', 2)
 *             lua.lua_rawget(L, lua.LUA_GLOBALSINDEX)             # <<<<<<<<<<<<<<
 *             if lua.lua_isnil(L, -1):
 *                 lua.lua_pop(L, 1)
 */
    lua_rawget(__pyx_v_L, LUA_GLOBALSINDEX);

    /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":170
 *             lua.lua_pushlstring(L, '_G', 2)
 *             lua.lua_rawget(L, lua.LUA_GLOBALSINDEX)
 *             if lua.lua_isnil(L, -1):             # <<<<<<<<<<<<<<
 *                 lua.lua_pop(L, 1)
 *                 raise LuaError("globals not defined")
 */
    __pyx_t_2 = lua_isnil(__pyx_v_L, -1);
    if (__pyx_t_2) {

      /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":171
 *             lua.lua_rawget(L, lua.LUA_GLOBALSINDEX)
 *             if lua.lua_isnil(L, -1):
 *                 lua.lua_pop(L, 1)             # <<<<<<<<<<<<<<
 *                 raise LuaError("globals not defined")
 *             try:
 */
      lua_pop(__pyx_v_L, 1);

      /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":172
 *             if lua.lua_isnil(L, -1):
 *                 lua.lua_pop(L, 1)
 *                 raise LuaError("globals not defined")             # <<<<<<<<<<<<<<
 *             try:
 *                 return py_from_lua(self, L, -1)
 */
      __pyx_t_3 = __Pyx_GetName(__pyx_m, __pyx_n_s__LuaError); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 172; __pyx_clineno = __LINE__; goto __pyx_L6;}
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 172; __pyx_clineno = __LINE__; goto __pyx_L6;}
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_INCREF(((PyObject *)__pyx_kp_s_7));
      PyTuple_SET_ITEM(__pyx_t_4, 0, ((PyObject *)__pyx_kp_s_7));
      __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_7));
      __pyx_t_5 = PyObject_Call(__pyx_t_3, __pyx_t_4, NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 172; __pyx_clineno = __LINE__; goto __pyx_L6;}
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __Pyx_Raise(__pyx_t_5, 0, 0);
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 172; __pyx_clineno = __LINE__; goto __pyx_L6;}
      goto __pyx_L8;
    }
    __pyx_L8:;

    /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":173
 *                 lua.lua_pop(L, 1)
 *                 raise LuaError("globals not defined")
 *             try:             # <<<<<<<<<<<<<<
 *                 return py_from_lua(self, L, -1)
 *             finally:
 */
    /*try:*/ {

      /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":174
 *                 raise LuaError("globals not defined")
 *             try:
 *                 return py_from_lua(self, L, -1)             # <<<<<<<<<<<<<<
 *             finally:
 *                 lua.lua_settop(L, 0)
 */
      __Pyx_XDECREF(__pyx_r);
      __pyx_t_5 = __pyx_f_4lupa_5_lupa_py_from_lua(((struct __pyx_obj_4lupa_5_lupa_LuaRuntime *)__pyx_v_self), __pyx_v_L, -1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 174; __pyx_clineno = __LINE__; goto __pyx_L10;}
      __Pyx_GOTREF(__pyx_t_5);
      __pyx_r = __pyx_t_5;
      __pyx_t_5 = 0;
      goto __pyx_L9;
    }

    /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":176
 *                 return py_from_lua(self, L, -1)
 *             finally:
 *                 lua.lua_settop(L, 0)             # <<<<<<<<<<<<<<
 *         finally:
 *             unlock_runtime(self)
 */
    /*finally:*/ {
      int __pyx_why;
      PyObject *__pyx_exc_type, *__pyx_exc_value, *__pyx_exc_tb;
      int __pyx_exc_lineno;
      __pyx_exc_type = 0; __pyx_exc_value = 0; __pyx_exc_tb = 0; __pyx_exc_lineno = 0;
      __pyx_why = 0; goto __pyx_L11;
      __pyx_L9: __pyx_exc_type = 0; __pyx_exc_value = 0; __pyx_exc_tb = 0; __pyx_exc_lineno = 0;
      __pyx_why = 3; goto __pyx_L11;
      __pyx_L10: {
        __pyx_why = 4;
        __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;
        __Pyx_ErrFetch(&__pyx_exc_type, &__pyx_exc_value, &__pyx_exc_tb);
        __pyx_exc_lineno = __pyx_lineno;
        goto __pyx_L11;
      }
      __pyx_L11:;
      lua_settop(__pyx_v_L, 0);
      switch (__pyx_why) {
        case 3: goto __pyx_L5;
        case 4: {
          __Pyx_ErrRestore(__pyx_exc_type, __pyx_exc_value, __pyx_exc_tb);
          __pyx_lineno = __pyx_exc_lineno;
          __pyx_exc_type = 0;
          __pyx_exc_value = 0;
          __pyx_exc_tb = 0;
          goto __pyx_L6;
        }
      }
    }
  }

  /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":178
 *                 lua.lua_settop(L, 0)
 *         finally:
 *             unlock_runtime(self)             # <<<<<<<<<<<<<<
 * 
 *     def table(self, *items, **kwargs):
 */
  /*finally:*/ {
    int __pyx_why;
    PyObject *__pyx_exc_type, *__pyx_exc_value, *__pyx_exc_tb;
    int __pyx_exc_lineno;
    __pyx_exc_type = 0; __pyx_exc_value = 0; __pyx_exc_tb = 0; __pyx_exc_lineno = 0;
    __pyx_why = 0; goto __pyx_L7;
    __pyx_L5: __pyx_exc_type = 0; __pyx_exc_value = 0; __pyx_exc_tb = 0; __pyx_exc_lineno = 0;
    __pyx_why = 3; goto __pyx_L7;
    __pyx_L6: {
      __pyx_why = 4;
      __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;
      __Pyx_ErrFetch(&__pyx_exc_type, &__pyx_exc_value, &__pyx_exc_tb);
      __pyx_exc_lineno = __pyx_lineno;
      goto __pyx_L7;
    }
    __pyx_L7:;
    __pyx_f_4lupa_5_lupa_unlock_runtime(((struct __pyx_obj_4lupa_5_lupa_LuaRuntime *)__pyx_v_self));
    switch (__pyx_why) {
      case 3: goto __pyx_L0;
      case 4: {
        __Pyx_ErrRestore(__pyx_exc_type, __pyx_exc_value, __pyx_exc_tb);
        __pyx_lineno = __pyx_exc_lineno;
        __pyx_exc_type = 0;
        __pyx_exc_value = 0;
        __pyx_exc_tb = 0;
        goto __pyx_L1_error;
      }
    }
  }

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_AddTraceback("lupa._lupa.LuaRuntime.globals");
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":180
 *             unlock_runtime(self)
 * 
 *     def table(self, *items, **kwargs):             # <<<<<<<<<<<<<<
 *         """Creates a new table with the provided items.  Positional
 *         arguments are placed in the table in order, keyword arguments
 */

static PyObject *__pyx_pf_4lupa_5_lupa_10LuaRuntime_table(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4lupa_5_lupa_10LuaRuntime_table[] = "LuaRuntime.table(self, *items, **kwargs)\nCreates 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_pf_4lupa_5_lupa_10LuaRuntime_table(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_items = 0;
  PyObject *__pyx_v_kwargs = 0;
  lua_State *__pyx_v_L;
  int __pyx_v_i;
  PyObject *__pyx_v_arg;
  PyObject *__pyx_v_key;
  PyObject *__pyx_v_value;
  PyObject *__pyx_r = NULL;
  int __pyx_t_1;
  Py_ssize_t __pyx_t_2;
  Py_ssize_t __pyx_t_3;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  int __pyx_t_6;
  void *__pyx_t_7;
  void *__pyx_t_8;
  __Pyx_RefNannySetupContext("table");
  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_v_arg = Py_None; __Pyx_INCREF(Py_None);
  __pyx_v_key = Py_None; __Pyx_INCREF(Py_None);
  __pyx_v_value = Py_None; __Pyx_INCREF(Py_None);

  /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":185
 *         are set as key-value pairs.
 *         """
 *         assert self._state is not NULL             # <<<<<<<<<<<<<<
 *         cdef lua_State *L = self._state
 *         cdef int i
 */
  #ifndef PYREX_WITHOUT_ASSERTIONS
  if (unlikely(!(((struct __pyx_obj_4lupa_5_lupa_LuaRuntime *)__pyx_v_self)->_state != NULL))) {
    PyErr_SetNone(PyExc_AssertionError);
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 185; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  #endif

  /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":186
 *         """
 *         assert self._state is not NULL
 *         cdef lua_State *L = self._state             # <<<<<<<<<<<<<<
 *         cdef int i
 *         lock_runtime(self)
 */
  __pyx_v_L = ((struct __pyx_obj_4lupa_5_lupa_LuaRuntime *)__pyx_v_self)->_state;

  /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":188
 *         cdef lua_State *L = self._state
 *         cdef int i
 *         lock_runtime(self)             # <<<<<<<<<<<<<<
 *         try:
 *             lua.lua_createtable(L, len(items), len(kwargs))
 */
  __pyx_t_1 = __pyx_f_4lupa_5_lupa_lock_runtime(((struct __pyx_obj_4lupa_5_lupa_LuaRuntime *)__pyx_v_self)); if (unlikely(__pyx_t_1 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 188; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":189
 *         cdef int i
 *         lock_runtime(self)
 *         try:             # <<<<<<<<<<<<<<
 *             lua.lua_createtable(L, len(items), len(kwargs))
 *             # FIXME: how to check for failure?
 */
  /*try:*/ {

    /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":190
 *         lock_runtime(self)
 *         try:
 *             lua.lua_createtable(L, len(items), len(kwargs))             # <<<<<<<<<<<<<<
 *             # FIXME: how to check for failure?
 *             for i, arg in enumerate(items):
 */
    if (unlikely(__pyx_v_items == Py_None)) {
      PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()"); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 190; __pyx_clineno = __LINE__; goto __pyx_L6;} 
    }
    __pyx_t_2 = PyTuple_GET_SIZE(((PyObject *)__pyx_v_items)); 
    if (unlikely(__pyx_v_kwargs == Py_None)) {
      PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()"); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 190; __pyx_clineno = __LINE__; goto __pyx_L6;} 
    }
    __pyx_t_3 = PyDict_Size(((PyObject *)__pyx_v_kwargs)); 
    lua_createtable(__pyx_v_L, __pyx_t_2, __pyx_t_3);

    /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":192
 *             lua.lua_createtable(L, len(items), len(kwargs))
 *             # FIXME: how to check for failure?
 *             for i, arg in enumerate(items):             # <<<<<<<<<<<<<<
 *                 py_to_lua(self, L, arg, 1)
 *                 lua.lua_rawseti(L, -2, i+1)
 */
    __pyx_t_1 = 0;
    if (likely(((PyObject *)__pyx_v_items) != Py_None)) {
      __pyx_t_3 = 0; __pyx_t_4 = ((PyObject *)__pyx_v_items); __Pyx_INCREF(__pyx_t_4);
    } else {
      PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable"); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 192; __pyx_clineno = __LINE__; goto __pyx_L6;}
    }
    for (;;) {
      if (__pyx_t_3 >= PyTuple_GET_SIZE(__pyx_t_4)) break;
      __pyx_t_5 = PyTuple_GET_ITEM(__pyx_t_4, __pyx_t_3); __Pyx_INCREF(__pyx_t_5); __pyx_t_3++;
      __Pyx_DECREF(__pyx_v_arg);
      __pyx_v_arg = __pyx_t_5;
      __pyx_t_5 = 0;
      __pyx_v_i = __pyx_t_1;
      __pyx_t_1 = (__pyx_t_1 + 1);

      /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":193
 *             # FIXME: how to check for failure?
 *             for i, arg in enumerate(items):
 *                 py_to_lua(self, L, arg, 1)             # <<<<<<<<<<<<<<
 *                 lua.lua_rawseti(L, -2, i+1)
 *             for key, value in kwargs.iteritems():
 */
      __pyx_t_6 = __pyx_f_4lupa_5_lupa_py_to_lua(((struct __pyx_obj_4lupa_5_lupa_LuaRuntime *)__pyx_v_self), __pyx_v_L, __pyx_v_arg, 1); if (unlikely(__pyx_t_6 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 193; __pyx_clineno = __LINE__; goto __pyx_L6;}

      /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":194
 *             for i, arg in enumerate(items):
 *                 py_to_lua(self, L, arg, 1)
 *                 lua.lua_rawseti(L, -2, i+1)             # <<<<<<<<<<<<<<
 *             for key, value in kwargs.iteritems():
 *                 py_to_lua(self, L, key, 1)
 */
      lua_rawseti(__pyx_v_L, -2, (__pyx_v_i + 1));
    }
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

    /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":195
 *                 py_to_lua(self, L, arg, 1)
 *                 lua.lua_rawseti(L, -2, i+1)
 *             for key, value in kwargs.iteritems():             # <<<<<<<<<<<<<<
 *                 py_to_lua(self, L, key, 1)
 *                 py_to_lua(self, L, value, 1)
 */
    __Pyx_INCREF(((PyObject *)__pyx_v_kwargs));
    __Pyx_XDECREF(__pyx_t_4);
    __pyx_t_4 = ((PyObject *)__pyx_v_kwargs);
    __pyx_t_3 = 0;
    while (1) {
      if (!PyDict_Next(__pyx_t_4, (&__pyx_t_3), ((PyObject **)(&__pyx_t_7)), ((PyObject **)(&__pyx_t_8)))) break;
      __Pyx_INCREF(((PyObject *)__pyx_t_7));
      __Pyx_DECREF(__pyx_v_key);
      __pyx_v_key = ((PyObject *)__pyx_t_7);
      __Pyx_INCREF(((PyObject *)__pyx_t_8));
      __Pyx_DECREF(__pyx_v_value);
      __pyx_v_value = ((PyObject *)__pyx_t_8);

      /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":196
 *                 lua.lua_rawseti(L, -2, i+1)
 *             for key, value in kwargs.iteritems():
 *                 py_to_lua(self, L, key, 1)             # <<<<<<<<<<<<<<
 *                 py_to_lua(self, L, value, 1)
 *                 lua.lua_rawset(L, -3)
 */
      __pyx_t_1 = __pyx_f_4lupa_5_lupa_py_to_lua(((struct __pyx_obj_4lupa_5_lupa_LuaRuntime *)__pyx_v_self), __pyx_v_L, __pyx_v_key, 1); if (unlikely(__pyx_t_1 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 196; __pyx_clineno = __LINE__; goto __pyx_L6;}

      /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":197
 *             for key, value in kwargs.iteritems():
 *                 py_to_lua(self, L, key, 1)
 *                 py_to_lua(self, L, value, 1)             # <<<<<<<<<<<<<<
 *                 lua.lua_rawset(L, -3)
 *             return py_from_lua(self, L, -1)
 */
      __pyx_t_1 = __pyx_f_4lupa_5_lupa_py_to_lua(((struct __pyx_obj_4lupa_5_lupa_LuaRuntime *)__pyx_v_self), __pyx_v_L, __pyx_v_value, 1); if (unlikely(__pyx_t_1 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 197; __pyx_clineno = __LINE__; goto __pyx_L6;}

      /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":198
 *                 py_to_lua(self, L, key, 1)
 *                 py_to_lua(self, L, value, 1)
 *                 lua.lua_rawset(L, -3)             # <<<<<<<<<<<<<<
 *             return py_from_lua(self, L, -1)
 *         finally:
 */
      lua_rawset(__pyx_v_L, -3);
    }
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

    /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":199
 *                 py_to_lua(self, L, value, 1)
 *                 lua.lua_rawset(L, -3)
 *             return py_from_lua(self, L, -1)             # <<<<<<<<<<<<<<
 *         finally:
 *             lua.lua_settop(L, 0)
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_4 = __pyx_f_4lupa_5_lupa_py_from_lua(((struct __pyx_obj_4lupa_5_lupa_LuaRuntime *)__pyx_v_self), __pyx_v_L, -1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 199; __pyx_clineno = __LINE__; goto __pyx_L6;}
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_r = __pyx_t_4;
    __pyx_t_4 = 0;
    goto __pyx_L5;
  }

  /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":201
 *             return py_from_lua(self, L, -1)
 *         finally:
 *             lua.lua_settop(L, 0)             # <<<<<<<<<<<<<<
 *             unlock_runtime(self)
 * 
 */
  /*finally:*/ {
    int __pyx_why;
    PyObject *__pyx_exc_type, *__pyx_exc_value, *__pyx_exc_tb;
    int __pyx_exc_lineno;
    __pyx_exc_type = 0; __pyx_exc_value = 0; __pyx_exc_tb = 0; __pyx_exc_lineno = 0;
    __pyx_why = 0; goto __pyx_L7;
    __pyx_L5: __pyx_exc_type = 0; __pyx_exc_value = 0; __pyx_exc_tb = 0; __pyx_exc_lineno = 0;
    __pyx_why = 3; goto __pyx_L7;
    __pyx_L6: {
      __pyx_why = 4;
      __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
      __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
      __Pyx_ErrFetch(&__pyx_exc_type, &__pyx_exc_value, &__pyx_exc_tb);
      __pyx_exc_lineno = __pyx_lineno;
      goto __pyx_L7;
    }
    __pyx_L7:;
    lua_settop(__pyx_v_L, 0);

    /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":202
 *         finally:
 *             lua.lua_settop(L, 0)
 *             unlock_runtime(self)             # <<<<<<<<<<<<<<
 * 
 *     cdef int register_py_object(self, bytes cname, bytes pyname, object obj) except -1:
 */
    __pyx_f_4lupa_5_lupa_unlock_runtime(((struct __pyx_obj_4lupa_5_lupa_LuaRuntime *)__pyx_v_self));
    switch (__pyx_why) {
      case 3: goto __pyx_L0;
      case 4: {
        __Pyx_ErrRestore(__pyx_exc_type, __pyx_exc_value, __pyx_exc_tb);
        __pyx_lineno = __pyx_exc_lineno;
        __pyx_exc_type = 0;
        __pyx_exc_value = 0;
        __pyx_exc_tb = 0;
        goto __pyx_L1_error;
      }
    }
  }

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_AddTraceback("lupa._lupa.LuaRuntime.table");
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_DECREF(__pyx_v_items);
  __Pyx_DECREF(__pyx_v_kwargs);
  __Pyx_DECREF(__pyx_v_arg);
  __Pyx_DECREF(__pyx_v_key);
  __Pyx_DECREF(__pyx_v_value);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":204
 *             unlock_runtime(self)
 * 
 *     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;
  char *__pyx_t_1;
  Py_ssize_t __pyx_t_2;
  int __pyx_t_3;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  __Pyx_RefNannySetupContext("register_py_object");

  /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":205
 * 
 *     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_v_L = __pyx_v_self->_state;

  /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":206
 *     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_1 = PyBytes_AsString(((PyObject *)__pyx_v_cname)); if (unlikely((!__pyx_t_1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 206; __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 = 206; __pyx_clineno = __LINE__; goto __pyx_L1_error;} 
  }
  __pyx_t_2 = PyBytes_GET_SIZE(((PyObject *)__pyx_v_cname)); 
  lua_pushlstring(__pyx_v_L, __pyx_t_1, __pyx_t_2);

  /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":207
 *         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_3 = (!__pyx_f_4lupa_5_lupa_py_to_lua_custom(__pyx_v_self, __pyx_v_L, __pyx_v_obj, 0));
  if (__pyx_t_3) {

    /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":208
 *         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);

    /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":209
 *         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_4 = __Pyx_GetName(__pyx_m, __pyx_n_s__LuaError); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 209; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_5 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_8), ((PyObject *)__pyx_v_pyname)); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 209; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(((PyObject *)__pyx_t_5));
    __pyx_t_6 = PyTuple_New(1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 209; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_6);
    PyTuple_SET_ITEM(__pyx_t_6, 0, ((PyObject *)__pyx_t_5));
    __Pyx_GIVEREF(((PyObject *)__pyx_t_5));
    __pyx_t_5 = 0;
    __pyx_t_5 = PyObject_Call(__pyx_t_4, __pyx_t_6, NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 209; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __Pyx_Raise(__pyx_t_5, 0, 0);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 209; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":210
 *             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_1 = PyBytes_AsString(((PyObject *)__pyx_v_pyname)); if (unlikely((!__pyx_t_1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 210; __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 = 210; __pyx_clineno = __LINE__; goto __pyx_L1_error;} 
  }
  __pyx_t_2 = PyBytes_GET_SIZE(((PyObject *)__pyx_v_pyname)); 
  lua_pushlstring(__pyx_v_L, __pyx_t_1, __pyx_t_2);

  /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":211
 *             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);

  /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":212
 *         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);

  /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":213
 *         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);

  /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":214
 *         lua.lua_rawset(L, -5)
 *         lua.lua_rawset(L, lua.LUA_REGISTRYINDEX)
 *         return 0             # <<<<<<<<<<<<<<
 * 
 *     cdef int init_python_lib(self) except -1:
 */
  __pyx_r = 0;
  goto __pyx_L0;

  __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.LuaRuntime.register_py_object");
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":216
 *         return 0
 * 
 *     cdef int init_python_lib(self) 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) {
  lua_State *__pyx_v_L;
  int __pyx_r;
  int __pyx_t_1;
  __Pyx_RefNannySetupContext("init_python_lib");

  /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":217
 * 
 *     cdef int init_python_lib(self) except -1:
 *         cdef lua_State *L = self._state             # <<<<<<<<<<<<<<
 * 
 *         # create 'python' lib and register our own object metatable
 */
  __pyx_v_L = __pyx_v_self->_state;

  /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":220
 * 
 *         # 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);

  /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":221
 *         # 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);

  /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":222
 *         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);

  /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":223
 *         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);

  /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":226
 * 
 *         # register global names in the module
 *         self.register_py_object(b'Py_None',  b'none', None)             # <<<<<<<<<<<<<<
 *         self.register_py_object(b'eval',     b'eval', eval)
 *         self.register_py_object(b'builtins', b'builtins', builtins)
 */
  __pyx_t_1 = ((struct __pyx_vtabstruct_4lupa_5_lupa_LuaRuntime *)__pyx_v_self->__pyx_vtab)->register_py_object(__pyx_v_self, __pyx_n_b__Py_None, __pyx_n_b__none, Py_None); if (unlikely(__pyx_t_1 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 226; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":227
 *         # register global names in the module
 *         self.register_py_object(b'Py_None',  b'none', None)
 *         self.register_py_object(b'eval',     b'eval', eval)             # <<<<<<<<<<<<<<
 *         self.register_py_object(b'builtins', b'builtins', builtins)
 * 
 */
  __pyx_t_1 = ((struct __pyx_vtabstruct_4lupa_5_lupa_LuaRuntime *)__pyx_v_self->__pyx_vtab)->register_py_object(__pyx_v_self, __pyx_n_b__eval, __pyx_n_b__eval, __pyx_builtin_eval); if (unlikely(__pyx_t_1 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 227; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":228
 *         self.register_py_object(b'Py_None',  b'none', None)
 *         self.register_py_object(b'eval',     b'eval', eval)
 *         self.register_py_object(b'builtins', b'builtins', builtins)             # <<<<<<<<<<<<<<
 * 
 *         return 0 # nothing left to return on the stack
 */
  __pyx_t_1 = ((struct __pyx_vtabstruct_4lupa_5_lupa_LuaRuntime *)__pyx_v_self->__pyx_vtab)->register_py_object(__pyx_v_self, __pyx_n_b__builtins, __pyx_n_b__builtins, __pyx_v_4lupa_5_lupa_builtins); if (unlikely(__pyx_t_1 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 228; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

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

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_AddTraceback("lupa._lupa.LuaRuntime.init_python_lib");
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":236
 * # 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;
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  __Pyx_RefNannySetupContext("lock_runtime");

  /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":237
 * 
 * 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_f_4lupa_5_lupa_lock_lock(__pyx_v_runtime->_lock, PyThread_get_thread_ident(), 1));
  if (__pyx_t_1) {

    /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":238
 * 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_2 = __Pyx_GetName(__pyx_m, __pyx_n_s__LuaError); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 238; __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 = 238; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_INCREF(((PyObject *)__pyx_kp_s_9));
    PyTuple_SET_ITEM(__pyx_t_3, 0, ((PyObject *)__pyx_kp_s_9));
    __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_9));
    __pyx_t_4 = PyObject_Call(__pyx_t_2, __pyx_t_3, NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 238; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_Raise(__pyx_t_4, 0, 0);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 238; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":239
 *     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;

  __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.lock_runtime");
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":241
 *     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) {

  /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":242
 * 
 * cdef inline void unlock_runtime(LuaRuntime runtime) nogil:
 *     unlock_lock(runtime._lock)             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_f_4lupa_5_lupa_unlock_lock(__pyx_v_runtime->_lock);

}

/* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":255
 *     cdef int _ref
 * 
 *     def __init__(self):             # <<<<<<<<<<<<<<
 *         raise TypeError("Type cannot be instantiated manually")
 * 
 */

static int __pyx_pf_4lupa_5_lupa_10_LuaObject___init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static int __pyx_pf_4lupa_5_lupa_10_LuaObject___init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  int __pyx_r;
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  __Pyx_RefNannySetupContext("__init__");
  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;

  /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":256
 * 
 *     def __init__(self):
 *         raise TypeError("Type cannot be instantiated manually")             # <<<<<<<<<<<<<<
 * 
 *     def __dealloc__(self):
 */
  __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 256; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_INCREF(((PyObject *)__pyx_kp_s_10));
  PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)__pyx_kp_s_10));
  __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_10));
  __pyx_t_2 = PyObject_Call(__pyx_builtin_TypeError, __pyx_t_1, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 256; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_Raise(__pyx_t_2, 0, 0);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  {__pyx_filename = __pyx_f[0]; __pyx_lineno = 256; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_AddTraceback("lupa._lupa._LuaObject.__init__");
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":258
 *         raise TypeError("Type cannot be instantiated manually")
 * 
 *     def __dealloc__(self):             # <<<<<<<<<<<<<<
 *         if self._runtime is None:
 *             return
 */

static void __pyx_pf_4lupa_5_lupa_10_LuaObject___dealloc__(PyObject *__pyx_v_self); /*proto*/
static void __pyx_pf_4lupa_5_lupa_10_LuaObject___dealloc__(PyObject *__pyx_v_self) {
  lua_State *__pyx_v_L;
  int __pyx_v_locked;
  int __pyx_t_1;
  int __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  __Pyx_RefNannySetupContext("__dealloc__");

  /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":259
 * 
 *     def __dealloc__(self):
 *         if self._runtime is None:             # <<<<<<<<<<<<<<
 *             return
 *         cdef lua_State* L = self._state
 */
  __pyx_t_1 = (((PyObject *)((struct __pyx_obj_4lupa_5_lupa__LuaObject *)__pyx_v_self)->_runtime) == Py_None);
  if (__pyx_t_1) {

    /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":260
 *     def __dealloc__(self):
 *         if self._runtime is None:
 *             return             # <<<<<<<<<<<<<<
 *         cdef lua_State* L = self._state
 *         try:
 */
    goto __pyx_L0;
    goto __pyx_L5;
  }
  __pyx_L5:;

  /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":261
 *         if self._runtime is None:
 *             return
 *         cdef lua_State* L = self._state             # <<<<<<<<<<<<<<
 *         try:
 *             lock_runtime(self._runtime)
 */
  __pyx_v_L = ((struct __pyx_obj_4lupa_5_lupa__LuaObject *)__pyx_v_self)->_state;

  /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":262
 *             return
 *         cdef lua_State* L = self._state
 *         try:             # <<<<<<<<<<<<<<
 *             lock_runtime(self._runtime)
 *             locked = True
 */
  {
    PyObject *__pyx_save_exc_type, *__pyx_save_exc_value, *__pyx_save_exc_tb;
    __Pyx_ExceptionSave(&__pyx_save_exc_type, &__pyx_save_exc_value, &__pyx_save_exc_tb);
    __Pyx_XGOTREF(__pyx_save_exc_type);
    __Pyx_XGOTREF(__pyx_save_exc_value);
    __Pyx_XGOTREF(__pyx_save_exc_tb);
    /*try:*/ {

      /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":263
 *         cdef lua_State* L = self._state
 *         try:
 *             lock_runtime(self._runtime)             # <<<<<<<<<<<<<<
 *             locked = True
 *         except:
 */
      __pyx_t_2 = __pyx_f_4lupa_5_lupa_lock_runtime(((struct __pyx_obj_4lupa_5_lupa__LuaObject *)__pyx_v_self)->_runtime); if (unlikely(__pyx_t_2 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 263; __pyx_clineno = __LINE__; goto __pyx_L6_error;}

      /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":264
 *         try:
 *             lock_runtime(self._runtime)
 *             locked = True             # <<<<<<<<<<<<<<
 *         except:
 *             locked = False
 */
      __pyx_v_locked = 1;
    }
    __Pyx_XDECREF(__pyx_save_exc_type); __pyx_save_exc_type = 0;
    __Pyx_XDECREF(__pyx_save_exc_value); __pyx_save_exc_value = 0;
    __Pyx_XDECREF(__pyx_save_exc_tb); __pyx_save_exc_tb = 0;
    goto __pyx_L13_try_end;
    __pyx_L6_error:;

    /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":265
 *             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__");
      if (__Pyx_GetException(&__pyx_t_3, &__pyx_t_4, &__pyx_t_5) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 265; __pyx_clineno = __LINE__; goto __pyx_L8_except_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_GOTREF(__pyx_t_5);

      /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":266
 *             locked = True
 *         except:
 *             locked = False             # <<<<<<<<<<<<<<
 *         lua.luaL_unref(L, lua.LUA_REGISTRYINDEX, self._ref)
 *         if locked:
 */
      __pyx_v_locked = 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;
      goto __pyx_L7_exception_handled;
    }
    __pyx_L8_except_error:;
    __Pyx_XGIVEREF(__pyx_save_exc_type);
    __Pyx_XGIVEREF(__pyx_save_exc_value);
    __Pyx_XGIVEREF(__pyx_save_exc_tb);
    __Pyx_ExceptionReset(__pyx_save_exc_type, __pyx_save_exc_value, __pyx_save_exc_tb);
    goto __pyx_L1_error;
    __pyx_L7_exception_handled:;
    __Pyx_XGIVEREF(__pyx_save_exc_type);
    __Pyx_XGIVEREF(__pyx_save_exc_value);
    __Pyx_XGIVEREF(__pyx_save_exc_tb);
    __Pyx_ExceptionReset(__pyx_save_exc_type, __pyx_save_exc_value, __pyx_save_exc_tb);
    __pyx_L13_try_end:;
  }

  /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":267
 *         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, ((struct __pyx_obj_4lupa_5_lupa__LuaObject *)__pyx_v_self)->_ref);

  /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":268
 *             locked = False
 *         lua.luaL_unref(L, lua.LUA_REGISTRYINDEX, self._ref)
 *         if locked:             # <<<<<<<<<<<<<<
 *             unlock_runtime(self._runtime)
 *         # undo additional INCREF at instantiation time
 */
  if (__pyx_v_locked) {

    /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":269
 *         lua.luaL_unref(L, lua.LUA_REGISTRYINDEX, self._ref)
 *         if locked:
 *             unlock_runtime(self._runtime)             # <<<<<<<<<<<<<<
 *         # undo additional INCREF at instantiation time
 *         cpython.ref.Py_DECREF(self._runtime)
 */
    __pyx_f_4lupa_5_lupa_unlock_runtime(((struct __pyx_obj_4lupa_5_lupa__LuaObject *)__pyx_v_self)->_runtime);
    goto __pyx_L16;
  }
  __pyx_L16:;

  /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":271
 *             unlock_runtime(self._runtime)
 *         # undo additional INCREF at instantiation time
 *         cpython.ref.Py_DECREF(self._runtime)             # <<<<<<<<<<<<<<
 * 
 *     cdef inline int push_lua_object(self) except -1:
 */
  Py_DECREF(((PyObject *)((struct __pyx_obj_4lupa_5_lupa__LuaObject *)__pyx_v_self)->_runtime));

  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_AddTraceback("lupa._lupa._LuaObject.__dealloc__");
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
}

/* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":273
 *         cpython.ref.Py_DECREF(self._runtime)
 * 
 *     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;
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  __Pyx_RefNannySetupContext("push_lua_object");

  /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":274
 * 
 *     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_v_L = __pyx_v_self->_state;

  /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":275
 *     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);

  /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":276
 *         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_1 = lua_isnil(__pyx_v_L, -1);
  if (__pyx_t_1) {

    /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":277
 *         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);

    /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":278
 *         if lua.lua_isnil(L, -1):
 *             lua.lua_pop(L, 1)
 *             raise LuaError("lost reference")             # <<<<<<<<<<<<<<
 * 
 *     def __call__(self, *args):
 */
    __pyx_t_2 = __Pyx_GetName(__pyx_m, __pyx_n_s__LuaError); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 278; __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 = 278; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_INCREF(((PyObject *)__pyx_kp_s_11));
    PyTuple_SET_ITEM(__pyx_t_3, 0, ((PyObject *)__pyx_kp_s_11));
    __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_11));
    __pyx_t_4 = PyObject_Call(__pyx_t_2, __pyx_t_3, NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 278; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_Raise(__pyx_t_4, 0, 0);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 278; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    goto __pyx_L3;
  }
  __pyx_L3:;

  __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._LuaObject.push_lua_object");
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

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

static PyObject *__pyx_pf_4lupa_5_lupa_10_LuaObject___call__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_pf_4lupa_5_lupa_10_LuaObject___call__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_args = 0;
  lua_State *__pyx_v_L;
  PyObject *__pyx_r = NULL;
  int __pyx_t_1;
  int __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  __Pyx_RefNannySetupContext("__call__");
  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;

  /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":281
 * 
 *     def __call__(self, *args):
 *         assert self._runtime is not None             # <<<<<<<<<<<<<<
 *         cdef lua_State* L = self._state
 *         lock_runtime(self._runtime)
 */
  #ifndef PYREX_WITHOUT_ASSERTIONS
  __pyx_t_1 = (((PyObject *)((struct __pyx_obj_4lupa_5_lupa__LuaObject *)__pyx_v_self)->_runtime) != Py_None);
  if (unlikely(!__pyx_t_1)) {
    PyErr_SetNone(PyExc_AssertionError);
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 281; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  #endif

  /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":282
 *     def __call__(self, *args):
 *         assert self._runtime is not None
 *         cdef lua_State* L = self._state             # <<<<<<<<<<<<<<
 *         lock_runtime(self._runtime)
 *         try:
 */
  __pyx_v_L = ((struct __pyx_obj_4lupa_5_lupa__LuaObject *)__pyx_v_self)->_state;

  /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":283
 *         assert self._runtime is not None
 *         cdef lua_State* L = self._state
 *         lock_runtime(self._runtime)             # <<<<<<<<<<<<<<
 *         try:
 *             lua.lua_settop(L, 0)
 */
  __pyx_t_2 = __pyx_f_4lupa_5_lupa_lock_runtime(((struct __pyx_obj_4lupa_5_lupa__LuaObject *)__pyx_v_self)->_runtime); if (unlikely(__pyx_t_2 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 283; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

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

    /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":285
 *         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);

    /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":286
 *         try:
 *             lua.lua_settop(L, 0)
 *             self.push_lua_object()             # <<<<<<<<<<<<<<
 *             return call_lua(self._runtime, L, args)
 *         finally:
 */
    __pyx_t_2 = ((struct __pyx_vtabstruct_4lupa_5_lupa__LuaObject *)((struct __pyx_obj_4lupa_5_lupa__LuaObject *)__pyx_v_self)->__pyx_vtab)->push_lua_object(((struct __pyx_obj_4lupa_5_lupa__LuaObject *)__pyx_v_self)); if (unlikely(__pyx_t_2 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 286; __pyx_clineno = __LINE__; goto __pyx_L6;}

    /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":287
 *             lua.lua_settop(L, 0)
 *             self.push_lua_object()
 *             return call_lua(self._runtime, L, args)             # <<<<<<<<<<<<<<
 *         finally:
 *             unlock_runtime(self._runtime)
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_3 = __pyx_f_4lupa_5_lupa_call_lua(((struct __pyx_obj_4lupa_5_lupa__LuaObject *)__pyx_v_self)->_runtime, __pyx_v_L, __pyx_v_args); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 287; __pyx_clineno = __LINE__; goto __pyx_L6;}
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_r = __pyx_t_3;
    __pyx_t_3 = 0;
    goto __pyx_L5;
  }

  /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":289
 *             return call_lua(self._runtime, L, args)
 *         finally:
 *             unlock_runtime(self._runtime)             # <<<<<<<<<<<<<<
 * 
 *     def __len__(self):
 */
  /*finally:*/ {
    int __pyx_why;
    PyObject *__pyx_exc_type, *__pyx_exc_value, *__pyx_exc_tb;
    int __pyx_exc_lineno;
    __pyx_exc_type = 0; __pyx_exc_value = 0; __pyx_exc_tb = 0; __pyx_exc_lineno = 0;
    __pyx_why = 0; goto __pyx_L7;
    __pyx_L5: __pyx_exc_type = 0; __pyx_exc_value = 0; __pyx_exc_tb = 0; __pyx_exc_lineno = 0;
    __pyx_why = 3; goto __pyx_L7;
    __pyx_L6: {
      __pyx_why = 4;
      __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_ErrFetch(&__pyx_exc_type, &__pyx_exc_value, &__pyx_exc_tb);
      __pyx_exc_lineno = __pyx_lineno;
      goto __pyx_L7;
    }
    __pyx_L7:;
    __pyx_f_4lupa_5_lupa_unlock_runtime(((struct __pyx_obj_4lupa_5_lupa__LuaObject *)__pyx_v_self)->_runtime);
    switch (__pyx_why) {
      case 3: goto __pyx_L0;
      case 4: {
        __Pyx_ErrRestore(__pyx_exc_type, __pyx_exc_value, __pyx_exc_tb);
        __pyx_lineno = __pyx_exc_lineno;
        __pyx_exc_type = 0;
        __pyx_exc_value = 0;
        __pyx_exc_tb = 0;
        goto __pyx_L1_error;
      }
    }
  }

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("lupa._lupa._LuaObject.__call__");
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_DECREF(__pyx_v_args);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":291
 *             unlock_runtime(self._runtime)
 * 
 *     def __len__(self):             # <<<<<<<<<<<<<<
 *         assert self._runtime is not None
 *         cdef lua_State* L = self._state
 */

static Py_ssize_t __pyx_pf_4lupa_5_lupa_10_LuaObject___len__(PyObject *__pyx_v_self); /*proto*/
static Py_ssize_t __pyx_pf_4lupa_5_lupa_10_LuaObject___len__(PyObject *__pyx_v_self) {
  lua_State *__pyx_v_L;
  Py_ssize_t __pyx_r;
  int __pyx_t_1;
  int __pyx_t_2;
  __Pyx_RefNannySetupContext("__len__");

  /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":292
 * 
 *     def __len__(self):
 *         assert self._runtime is not None             # <<<<<<<<<<<<<<
 *         cdef lua_State* L = self._state
 *         lock_runtime(self._runtime)
 */
  #ifndef PYREX_WITHOUT_ASSERTIONS
  __pyx_t_1 = (((PyObject *)((struct __pyx_obj_4lupa_5_lupa__LuaObject *)__pyx_v_self)->_runtime) != Py_None);
  if (unlikely(!__pyx_t_1)) {
    PyErr_SetNone(PyExc_AssertionError);
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 292; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  #endif

  /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":293
 *     def __len__(self):
 *         assert self._runtime is not None
 *         cdef lua_State* L = self._state             # <<<<<<<<<<<<<<
 *         lock_runtime(self._runtime)
 *         try:
 */
  __pyx_v_L = ((struct __pyx_obj_4lupa_5_lupa__LuaObject *)__pyx_v_self)->_state;

  /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":294
 *         assert self._runtime is not None
 *         cdef lua_State* L = self._state
 *         lock_runtime(self._runtime)             # <<<<<<<<<<<<<<
 *         try:
 *             self.push_lua_object()
 */
  __pyx_t_2 = __pyx_f_4lupa_5_lupa_lock_runtime(((struct __pyx_obj_4lupa_5_lupa__LuaObject *)__pyx_v_self)->_runtime); if (unlikely(__pyx_t_2 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 294; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":295
 *         cdef lua_State* L = self._state
 *         lock_runtime(self._runtime)
 *         try:             # <<<<<<<<<<<<<<
 *             self.push_lua_object()
 *             return lua.lua_objlen(L, -1)
 */
  /*try:*/ {

    /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":296
 *         lock_runtime(self._runtime)
 *         try:
 *             self.push_lua_object()             # <<<<<<<<<<<<<<
 *             return lua.lua_objlen(L, -1)
 *         finally:
 */
    __pyx_t_2 = ((struct __pyx_vtabstruct_4lupa_5_lupa__LuaObject *)((struct __pyx_obj_4lupa_5_lupa__LuaObject *)__pyx_v_self)->__pyx_vtab)->push_lua_object(((struct __pyx_obj_4lupa_5_lupa__LuaObject *)__pyx_v_self)); if (unlikely(__pyx_t_2 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 296; __pyx_clineno = __LINE__; goto __pyx_L6;}

    /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":297
 *         try:
 *             self.push_lua_object()
 *             return lua.lua_objlen(L, -1)             # <<<<<<<<<<<<<<
 *         finally:
 *             lua.lua_settop(L, 0)
 */
    __pyx_r = lua_objlen(__pyx_v_L, -1);
    goto __pyx_L5;
  }

  /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":299
 *             return lua.lua_objlen(L, -1)
 *         finally:
 *             lua.lua_settop(L, 0)             # <<<<<<<<<<<<<<
 *             unlock_runtime(self._runtime)
 * 
 */
  /*finally:*/ {
    int __pyx_why;
    PyObject *__pyx_exc_type, *__pyx_exc_value, *__pyx_exc_tb;
    int __pyx_exc_lineno;
    __pyx_exc_type = 0; __pyx_exc_value = 0; __pyx_exc_tb = 0; __pyx_exc_lineno = 0;
    __pyx_why = 0; goto __pyx_L7;
    __pyx_L5: __pyx_exc_type = 0; __pyx_exc_value = 0; __pyx_exc_tb = 0; __pyx_exc_lineno = 0;
    __pyx_why = 3; goto __pyx_L7;
    __pyx_L6: {
      __pyx_why = 4;
      __Pyx_ErrFetch(&__pyx_exc_type, &__pyx_exc_value, &__pyx_exc_tb);
      __pyx_exc_lineno = __pyx_lineno;
      goto __pyx_L7;
    }
    __pyx_L7:;
    lua_settop(__pyx_v_L, 0);

    /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":300
 *         finally:
 *             lua.lua_settop(L, 0)
 *             unlock_runtime(self._runtime)             # <<<<<<<<<<<<<<
 * 
 *     def __nonzero__(self):
 */
    __pyx_f_4lupa_5_lupa_unlock_runtime(((struct __pyx_obj_4lupa_5_lupa__LuaObject *)__pyx_v_self)->_runtime);
    switch (__pyx_why) {
      case 3: goto __pyx_L0;
      case 4: {
        __Pyx_ErrRestore(__pyx_exc_type, __pyx_exc_value, __pyx_exc_tb);
        __pyx_lineno = __pyx_exc_lineno;
        __pyx_exc_type = 0;
        __pyx_exc_value = 0;
        __pyx_exc_tb = 0;
        goto __pyx_L1_error;
      }
    }
  }

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_AddTraceback("lupa._lupa._LuaObject.__len__");
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":302
 *             unlock_runtime(self._runtime)
 * 
 *     def __nonzero__(self):             # <<<<<<<<<<<<<<
 *         return True
 * 
 */

static int __pyx_pf_4lupa_5_lupa_10_LuaObject___nonzero__(PyObject *__pyx_v_self); /*proto*/
static int __pyx_pf_4lupa_5_lupa_10_LuaObject___nonzero__(PyObject *__pyx_v_self) {
  int __pyx_r;
  __Pyx_RefNannySetupContext("__nonzero__");

  /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":303
 * 
 *     def __nonzero__(self):
 *         return True             # <<<<<<<<<<<<<<
 * 
 *     def __iter__(self):
 */
  __pyx_r = 1;
  goto __pyx_L0;

  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":305
 *         return True
 * 
 *     def __iter__(self):             # <<<<<<<<<<<<<<
 *         raise TypeError("iteration is only supported for tables")
 * 
 */

static PyObject *__pyx_pf_4lupa_5_lupa_10_LuaObject___iter__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pf_4lupa_5_lupa_10_LuaObject___iter__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  __Pyx_RefNannySetupContext("__iter__");

  /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":306
 * 
 *     def __iter__(self):
 *         raise TypeError("iteration is only supported for tables")             # <<<<<<<<<<<<<<
 * 
 *     def __repr__(self):
 */
  __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 306; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_INCREF(((PyObject *)__pyx_kp_s_12));
  PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)__pyx_kp_s_12));
  __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_12));
  __pyx_t_2 = PyObject_Call(__pyx_builtin_TypeError, __pyx_t_1, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 306; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_Raise(__pyx_t_2, 0, 0);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  {__pyx_filename = __pyx_f[0]; __pyx_lineno = 306; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_AddTraceback("lupa._lupa._LuaObject.__iter__");
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

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

static PyObject *__pyx_pf_4lupa_5_lupa_10_LuaObject___repr__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pf_4lupa_5_lupa_10_LuaObject___repr__(PyObject *__pyx_v_self) {
  lua_State *__pyx_v_L;
  PyObject *__pyx_v_encoding;
  PyObject *__pyx_r = NULL;
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  int __pyx_t_6;
  __Pyx_RefNannySetupContext("__repr__");
  __pyx_v_encoding = Py_None; __Pyx_INCREF(Py_None);

  /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":309
 * 
 *     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 PYREX_WITHOUT_ASSERTIONS
  __pyx_t_1 = (((PyObject *)((struct __pyx_obj_4lupa_5_lupa__LuaObject *)__pyx_v_self)->_runtime) != Py_None);
  if (unlikely(!__pyx_t_1)) {
    PyErr_SetNone(PyExc_AssertionError);
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 309; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  #endif

  /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":310
 *     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_v_L = ((struct __pyx_obj_4lupa_5_lupa__LuaObject *)__pyx_v_self)->_state;

  /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":311
 *         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 = (((PyObject *)((struct __pyx_obj_4lupa_5_lupa__LuaObject *)__pyx_v_self)->_runtime->_encoding) != Py_None) && (PyBytes_GET_SIZE(((PyObject *)((struct __pyx_obj_4lupa_5_lupa__LuaObject *)__pyx_v_self)->_runtime->_encoding)) != 0);
  if (__pyx_t_1) {
    __pyx_t_3 = PyObject_GetAttr(((PyObject *)((struct __pyx_obj_4lupa_5_lupa__LuaObject *)__pyx_v_self)->_runtime->_encoding), __pyx_n_s__decode); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 311; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 311; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_INCREF(((PyObject *)__pyx_n_s__ASCII));
    PyTuple_SET_ITEM(__pyx_t_4, 0, ((PyObject *)__pyx_n_s__ASCII));
    __Pyx_GIVEREF(((PyObject *)__pyx_n_s__ASCII));
    __pyx_t_5 = PyObject_Call(__pyx_t_3, __pyx_t_4, NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 311; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_2 = __pyx_t_5;
    __pyx_t_5 = 0;
  } else {
    __Pyx_INCREF(((PyObject *)__pyx_kp_s_2));
    __pyx_t_2 = __pyx_kp_s_2;
  }
  __Pyx_DECREF(__pyx_v_encoding);
  __pyx_v_encoding = __pyx_t_2;
  __pyx_t_2 = 0;

  /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":312
 *         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_6 = __pyx_f_4lupa_5_lupa_lock_runtime(((struct __pyx_obj_4lupa_5_lupa__LuaObject *)__pyx_v_self)->_runtime); if (unlikely(__pyx_t_6 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 312; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":313
 *         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:*/ {

    /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":314
 *         lock_runtime(self._runtime)
 *         try:
 *             self.push_lua_object()             # <<<<<<<<<<<<<<
 *             return lua_object_repr(L, encoding)
 *         finally:
 */
    __pyx_t_6 = ((struct __pyx_vtabstruct_4lupa_5_lupa__LuaObject *)((struct __pyx_obj_4lupa_5_lupa__LuaObject *)__pyx_v_self)->__pyx_vtab)->push_lua_object(((struct __pyx_obj_4lupa_5_lupa__LuaObject *)__pyx_v_self)); if (unlikely(__pyx_t_6 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 314; __pyx_clineno = __LINE__; goto __pyx_L6;}

    /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":315
 *         try:
 *             self.push_lua_object()
 *             return lua_object_repr(L, encoding)             # <<<<<<<<<<<<<<
 *         finally:
 *             lua.lua_pop(L, 1)
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_2 = __pyx_f_4lupa_5_lupa_lua_object_repr(__pyx_v_L, __pyx_v_encoding); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 315; __pyx_clineno = __LINE__; goto __pyx_L6;}
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_r = __pyx_t_2;
    __pyx_t_2 = 0;
    goto __pyx_L5;
  }

  /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":317
 *             return lua_object_repr(L, encoding)
 *         finally:
 *             lua.lua_pop(L, 1)             # <<<<<<<<<<<<<<
 *             unlock_runtime(self._runtime)
 * 
 */
  /*finally:*/ {
    int __pyx_why;
    PyObject *__pyx_exc_type, *__pyx_exc_value, *__pyx_exc_tb;
    int __pyx_exc_lineno;
    __pyx_exc_type = 0; __pyx_exc_value = 0; __pyx_exc_tb = 0; __pyx_exc_lineno = 0;
    __pyx_why = 0; goto __pyx_L7;
    __pyx_L5: __pyx_exc_type = 0; __pyx_exc_value = 0; __pyx_exc_tb = 0; __pyx_exc_lineno = 0;
    __pyx_why = 3; goto __pyx_L7;
    __pyx_L6: {
      __pyx_why = 4;
      __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;
      __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_ErrFetch(&__pyx_exc_type, &__pyx_exc_value, &__pyx_exc_tb);
      __pyx_exc_lineno = __pyx_lineno;
      goto __pyx_L7;
    }
    __pyx_L7:;
    lua_pop(__pyx_v_L, 1);

    /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":318
 *         finally:
 *             lua.lua_pop(L, 1)
 *             unlock_runtime(self._runtime)             # <<<<<<<<<<<<<<
 * 
 *     def __str__(self):
 */
    __pyx_f_4lupa_5_lupa_unlock_runtime(((struct __pyx_obj_4lupa_5_lupa__LuaObject *)__pyx_v_self)->_runtime);
    switch (__pyx_why) {
      case 3: goto __pyx_L0;
      case 4: {
        __Pyx_ErrRestore(__pyx_exc_type, __pyx_exc_value, __pyx_exc_tb);
        __pyx_lineno = __pyx_exc_lineno;
        __pyx_exc_type = 0;
        __pyx_exc_value = 0;
        __pyx_exc_tb = 0;
        goto __pyx_L1_error;
      }
    }
  }

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_AddTraceback("lupa._lupa._LuaObject.__repr__");
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_DECREF(__pyx_v_encoding);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":320
 *             unlock_runtime(self._runtime)
 * 
 *     def __str__(self):             # <<<<<<<<<<<<<<
 *         assert self._runtime is not None
 *         cdef lua_State* L = self._state
 */

static PyObject *__pyx_pf_4lupa_5_lupa_10_LuaObject___str__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pf_4lupa_5_lupa_10_LuaObject___str__(PyObject *__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;
  PyObject *__pyx_r = NULL;
  int __pyx_t_1;
  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;
  int __pyx_t_8;
  __Pyx_RefNannySetupContext("__str__");
  __pyx_v_encoding = Py_None; __Pyx_INCREF(Py_None);

  /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":321
 * 
 *     def __str__(self):
 *         assert self._runtime is not None             # <<<<<<<<<<<<<<
 *         cdef lua_State* L = self._state
 *         cdef unicode py_string = None
 */
  #ifndef PYREX_WITHOUT_ASSERTIONS
  __pyx_t_1 = (((PyObject *)((struct __pyx_obj_4lupa_5_lupa__LuaObject *)__pyx_v_self)->_runtime) != Py_None);
  if (unlikely(!__pyx_t_1)) {
    PyErr_SetNone(PyExc_AssertionError);
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 321; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  #endif

  /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":322
 *     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_v_L = ((struct __pyx_obj_4lupa_5_lupa__LuaObject *)__pyx_v_self)->_state;

  /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":323
 *         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
 */
  __Pyx_INCREF(Py_None);
  __pyx_v_py_string = ((PyObject *)Py_None);

  /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":326
 *         cdef const_char_ptr s
 *         cdef size_t size
 *         encoding = self._runtime._encoding.decode('ASCII') if self._runtime._encoding else 'UTF-8'             # <<<<<<<<<<<<<<
 *         lock_runtime(self._runtime)
 *         try:
 */
  __pyx_t_1 = (((PyObject *)((struct __pyx_obj_4lupa_5_lupa__LuaObject *)__pyx_v_self)->_runtime->_encoding) != Py_None) && (PyBytes_GET_SIZE(((PyObject *)((struct __pyx_obj_4lupa_5_lupa__LuaObject *)__pyx_v_self)->_runtime->_encoding)) != 0);
  if (__pyx_t_1) {
    __pyx_t_3 = PyObject_GetAttr(((PyObject *)((struct __pyx_obj_4lupa_5_lupa__LuaObject *)__pyx_v_self)->_runtime->_encoding), __pyx_n_s__decode); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 326; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 326; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_INCREF(((PyObject *)__pyx_n_s__ASCII));
    PyTuple_SET_ITEM(__pyx_t_4, 0, ((PyObject *)__pyx_n_s__ASCII));
    __Pyx_GIVEREF(((PyObject *)__pyx_n_s__ASCII));
    __pyx_t_5 = PyObject_Call(__pyx_t_3, __pyx_t_4, NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 326; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_2 = __pyx_t_5;
    __pyx_t_5 = 0;
  } else {
    __Pyx_INCREF(((PyObject *)__pyx_kp_s_2));
    __pyx_t_2 = __pyx_kp_s_2;
  }
  __Pyx_DECREF(__pyx_v_encoding);
  __pyx_v_encoding = __pyx_t_2;
  __pyx_t_2 = 0;

  /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":327
 *         cdef size_t size
 *         encoding = self._runtime._encoding.decode('ASCII') if self._runtime._encoding else 'UTF-8'
 *         lock_runtime(self._runtime)             # <<<<<<<<<<<<<<
 *         try:
 *             self.push_lua_object()
 */
  __pyx_t_6 = __pyx_f_4lupa_5_lupa_lock_runtime(((struct __pyx_obj_4lupa_5_lupa__LuaObject *)__pyx_v_self)->_runtime); if (unlikely(__pyx_t_6 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 327; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":328
 *         encoding = self._runtime._encoding.decode('ASCII') if self._runtime._encoding else 'UTF-8'
 *         lock_runtime(self._runtime)
 *         try:             # <<<<<<<<<<<<<<
 *             self.push_lua_object()
 *             # lookup and call "__tostring" metatable method manually to catch any errors
 */
  /*try:*/ {

    /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":329
 *         lock_runtime(self._runtime)
 *         try:
 *             self.push_lua_object()             # <<<<<<<<<<<<<<
 *             # lookup and call "__tostring" metatable method manually to catch any errors
 *             if lua.lua_getmetatable(L, -1):
 */
    __pyx_t_6 = ((struct __pyx_vtabstruct_4lupa_5_lupa__LuaObject *)((struct __pyx_obj_4lupa_5_lupa__LuaObject *)__pyx_v_self)->__pyx_vtab)->push_lua_object(((struct __pyx_obj_4lupa_5_lupa__LuaObject *)__pyx_v_self)); if (unlikely(__pyx_t_6 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 329; __pyx_clineno = __LINE__; goto __pyx_L6;}

    /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":331
 *             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_6 = lua_getmetatable(__pyx_v_L, -1);
    if (__pyx_t_6) {

      /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":332
 *             # 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);

      /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":333
 *             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);

      /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":334
 *                 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));
      if (__pyx_t_1) {
        __pyx_t_7 = (lua_pcall(__pyx_v_L, 1, 1, 0) == 0);
        __pyx_t_8 = __pyx_t_7;
      } else {
        __pyx_t_8 = __pyx_t_1;
      }
      if (__pyx_t_8) {

        /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":335
 *                 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));

        /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":336
 *                 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_8 = (__pyx_v_s != 0);
        if (__pyx_t_8) {

          /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":337
 *                     s = lua.lua_tolstring(L, -1, &size)
 *                     if s:
 *                         try:             # <<<<<<<<<<<<<<
 *                             py_string = s[:size].decode(encoding)
 *                         except UnicodeDecodeError:
 */
          {
            PyObject *__pyx_save_exc_type, *__pyx_save_exc_value, *__pyx_save_exc_tb;
            __Pyx_ExceptionSave(&__pyx_save_exc_type, &__pyx_save_exc_value, &__pyx_save_exc_tb);
            __Pyx_XGOTREF(__pyx_save_exc_type);
            __Pyx_XGOTREF(__pyx_save_exc_value);
            __Pyx_XGOTREF(__pyx_save_exc_tb);
            /*try:*/ {

              /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":338
 *                     if s:
 *                         try:
 *                             py_string = s[:size].decode(encoding)             # <<<<<<<<<<<<<<
 *                         except UnicodeDecodeError:
 *                             # safe 'decode'
 */
              __pyx_t_2 = PyBytes_FromStringAndSize(__pyx_v_s + 0, __pyx_v_size - 0); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 338; __pyx_clineno = __LINE__; goto __pyx_L11_error;}
              __Pyx_GOTREF(((PyObject *)__pyx_t_2));
              __pyx_t_5 = PyObject_GetAttr(((PyObject *)__pyx_t_2), __pyx_n_s__decode); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 338; __pyx_clineno = __LINE__; goto __pyx_L11_error;}
              __Pyx_GOTREF(__pyx_t_5);
              __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
              __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 338; __pyx_clineno = __LINE__; goto __pyx_L11_error;}
              __Pyx_GOTREF(__pyx_t_2);
              __Pyx_INCREF(__pyx_v_encoding);
              PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_encoding);
              __Pyx_GIVEREF(__pyx_v_encoding);
              __pyx_t_4 = PyObject_Call(__pyx_t_5, __pyx_t_2, NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 338; __pyx_clineno = __LINE__; goto __pyx_L11_error;}
              __Pyx_GOTREF(__pyx_t_4);
              __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
              __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
              if (!(likely(PyUnicode_CheckExact(__pyx_t_4))||((__pyx_t_4) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected unicode, got %.200s", Py_TYPE(__pyx_t_4)->tp_name), 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 338; __pyx_clineno = __LINE__; goto __pyx_L11_error;}
              __Pyx_DECREF(((PyObject *)__pyx_v_py_string));
              __pyx_v_py_string = ((PyObject *)__pyx_t_4);
              __pyx_t_4 = 0;
            }
            __Pyx_XDECREF(__pyx_save_exc_type); __pyx_save_exc_type = 0;
            __Pyx_XDECREF(__pyx_save_exc_value); __pyx_save_exc_value = 0;
            __Pyx_XDECREF(__pyx_save_exc_tb); __pyx_save_exc_tb = 0;
            goto __pyx_L18_try_end;
            __pyx_L11_error:;
            __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
            __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
            __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
            __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;

            /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":339
 *                         try:
 *                             py_string = s[:size].decode(encoding)
 *                         except UnicodeDecodeError:             # <<<<<<<<<<<<<<
 *                             # safe 'decode'
 *                             py_string = s[:size].decode('ISO-8859-1')
 */
            __pyx_t_6 = PyErr_ExceptionMatches(__pyx_builtin_UnicodeDecodeError);
            if (__pyx_t_6) {
              __Pyx_AddTraceback("lupa._lupa._LuaObject.__str__");
              if (__Pyx_GetException(&__pyx_t_4, &__pyx_t_2, &__pyx_t_5) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 339; __pyx_clineno = __LINE__; goto __pyx_L13_except_error;}
              __Pyx_GOTREF(__pyx_t_4);
              __Pyx_GOTREF(__pyx_t_2);
              __Pyx_GOTREF(__pyx_t_5);

              /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":341
 *                         except UnicodeDecodeError:
 *                             # safe 'decode'
 *                             py_string = s[:size].decode('ISO-8859-1')             # <<<<<<<<<<<<<<
 *             if py_string is None:
 *                 lua.lua_settop(L, 1)
 */
              __pyx_t_3 = ((PyObject *)PyUnicode_DecodeLatin1(__pyx_v_s, __pyx_v_size, NULL)); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 341; __pyx_clineno = __LINE__; goto __pyx_L13_except_error;}
              __Pyx_GOTREF(((PyObject *)__pyx_t_3));
              if (!(likely(PyUnicode_CheckExact(((PyObject *)__pyx_t_3)))||(PyErr_Format(PyExc_TypeError, "Expected unicode, got %.200s", Py_TYPE(((PyObject *)__pyx_t_3))->tp_name), 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 341; __pyx_clineno = __LINE__; goto __pyx_L13_except_error;}
              __Pyx_DECREF(((PyObject *)__pyx_v_py_string));
              __pyx_v_py_string = ((PyObject *)__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;
              __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
              goto __pyx_L12_exception_handled;
            }
            __pyx_L13_except_error:;
            __Pyx_XGIVEREF(__pyx_save_exc_type);
            __Pyx_XGIVEREF(__pyx_save_exc_value);
            __Pyx_XGIVEREF(__pyx_save_exc_tb);
            __Pyx_ExceptionReset(__pyx_save_exc_type, __pyx_save_exc_value, __pyx_save_exc_tb);
            goto __pyx_L6;
            __pyx_L12_exception_handled:;
            __Pyx_XGIVEREF(__pyx_save_exc_type);
            __Pyx_XGIVEREF(__pyx_save_exc_value);
            __Pyx_XGIVEREF(__pyx_save_exc_tb);
            __Pyx_ExceptionReset(__pyx_save_exc_type, __pyx_save_exc_value, __pyx_save_exc_tb);
            __pyx_L18_try_end:;
          }
          goto __pyx_L10;
        }
        __pyx_L10:;
        goto __pyx_L9;
      }
      __pyx_L9:;
      goto __pyx_L8;
    }
    __pyx_L8:;

    /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":342
 *                             # safe 'decode'
 *                             py_string = s[:size].decode('ISO-8859-1')
 *             if py_string is None:             # <<<<<<<<<<<<<<
 *                 lua.lua_settop(L, 1)
 *                 py_string = lua_object_repr(L, encoding)
 */
    __pyx_t_8 = (__pyx_v_py_string == ((PyObject *)Py_None));
    if (__pyx_t_8) {

      /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":343
 *                             py_string = s[:size].decode('ISO-8859-1')
 *             if py_string is None:
 *                 lua.lua_settop(L, 1)             # <<<<<<<<<<<<<<
 *                 py_string = lua_object_repr(L, encoding)
 *         finally:
 */
      lua_settop(__pyx_v_L, 1);

      /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":344
 *             if py_string is None:
 *                 lua.lua_settop(L, 1)
 *                 py_string = lua_object_repr(L, encoding)             # <<<<<<<<<<<<<<
 *         finally:
 *             lua.lua_settop(L, 0)
 */
      __pyx_t_5 = __pyx_f_4lupa_5_lupa_lua_object_repr(__pyx_v_L, __pyx_v_encoding); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 344; __pyx_clineno = __LINE__; goto __pyx_L6;}
      __Pyx_GOTREF(__pyx_t_5);
      if (!(likely(PyUnicode_CheckExact(__pyx_t_5))||((__pyx_t_5) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected unicode, got %.200s", Py_TYPE(__pyx_t_5)->tp_name), 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 344; __pyx_clineno = __LINE__; goto __pyx_L6;}
      __Pyx_DECREF(((PyObject *)__pyx_v_py_string));
      __pyx_v_py_string = ((PyObject *)__pyx_t_5);
      __pyx_t_5 = 0;
      goto __pyx_L21;
    }
    __pyx_L21:;
  }

  /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":346
 *                 py_string = lua_object_repr(L, encoding)
 *         finally:
 *             lua.lua_settop(L, 0)             # <<<<<<<<<<<<<<
 *             unlock_runtime(self._runtime)
 *         return py_string
 */
  /*finally:*/ {
    int __pyx_why;
    PyObject *__pyx_exc_type, *__pyx_exc_value, *__pyx_exc_tb;
    int __pyx_exc_lineno;
    __pyx_exc_type = 0; __pyx_exc_value = 0; __pyx_exc_tb = 0; __pyx_exc_lineno = 0;
    __pyx_why = 0; goto __pyx_L7;
    __pyx_L6: {
      __pyx_why = 4;
      __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
      __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
      __Pyx_ErrFetch(&__pyx_exc_type, &__pyx_exc_value, &__pyx_exc_tb);
      __pyx_exc_lineno = __pyx_lineno;
      goto __pyx_L7;
    }
    __pyx_L7:;
    lua_settop(__pyx_v_L, 0);

    /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":347
 *         finally:
 *             lua.lua_settop(L, 0)
 *             unlock_runtime(self._runtime)             # <<<<<<<<<<<<<<
 *         return py_string
 * 
 */
    __pyx_f_4lupa_5_lupa_unlock_runtime(((struct __pyx_obj_4lupa_5_lupa__LuaObject *)__pyx_v_self)->_runtime);
    switch (__pyx_why) {
      case 4: {
        __Pyx_ErrRestore(__pyx_exc_type, __pyx_exc_value, __pyx_exc_tb);
        __pyx_lineno = __pyx_exc_lineno;
        __pyx_exc_type = 0;
        __pyx_exc_value = 0;
        __pyx_exc_tb = 0;
        goto __pyx_L1_error;
      }
    }
  }

  /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":348
 *             lua.lua_settop(L, 0)
 *             unlock_runtime(self._runtime)
 *         return py_string             # <<<<<<<<<<<<<<
 * 
 *     def __getattr__(self, name):
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(((PyObject *)__pyx_v_py_string));
  __pyx_r = ((PyObject *)__pyx_v_py_string);
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_AddTraceback("lupa._lupa._LuaObject.__str__");
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_py_string);
  __Pyx_DECREF(__pyx_v_encoding);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":350
 *         return py_string
 * 
 *     def __getattr__(self, name):             # <<<<<<<<<<<<<<
 *         assert self._runtime is not None
 *         cdef lua_State* L = self._state
 */

static PyObject *__pyx_pf_4lupa_5_lupa_10_LuaObject___getattr__(PyObject *__pyx_v_self, PyObject *__pyx_v_name); /*proto*/
static PyObject *__pyx_pf_4lupa_5_lupa_10_LuaObject___getattr__(PyObject *__pyx_v_self, PyObject *__pyx_v_name) {
  lua_State *__pyx_v_L;
  PyObject *__pyx_r = NULL;
  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;
  __Pyx_RefNannySetupContext("__getattr__");
  __Pyx_INCREF(__pyx_v_name);

  /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":351
 * 
 *     def __getattr__(self, name):
 *         assert self._runtime is not None             # <<<<<<<<<<<<<<
 *         cdef lua_State* L = self._state
 *         if isinstance(name, unicode):
 */
  #ifndef PYREX_WITHOUT_ASSERTIONS
  __pyx_t_1 = (((PyObject *)((struct __pyx_obj_4lupa_5_lupa__LuaObject *)__pyx_v_self)->_runtime) != Py_None);
  if (unlikely(!__pyx_t_1)) {
    PyErr_SetNone(PyExc_AssertionError);
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 351; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  #endif

  /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":352
 *     def __getattr__(self, name):
 *         assert self._runtime is not None
 *         cdef lua_State* L = self._state             # <<<<<<<<<<<<<<
 *         if isinstance(name, unicode):
 *             if (<unicode>name).startswith(u'__') and (<unicode>name).endswith(u'__'):
 */
  __pyx_v_L = ((struct __pyx_obj_4lupa_5_lupa__LuaObject *)__pyx_v_self)->_state;

  /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":353
 *         assert self._runtime is not None
 *         cdef lua_State* L = self._state
 *         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); 
  if (__pyx_t_1) {

    /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":354
 *         cdef lua_State* L = self._state
 *         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(((PyObject *)__pyx_v_name) == Py_None)) {
      PyErr_SetString(PyExc_AttributeError, "'NoneType' object has no attribute 'startswith'"); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 354; __pyx_clineno = __LINE__; goto __pyx_L1_error;} 
    }
    __pyx_t_1 = __Pyx_PyUnicode_Tailmatch(((PyObject *)__pyx_v_name), ((PyObject *)__pyx_n_u____), 0, PY_SSIZE_T_MAX, -1); if (unlikely(__pyx_t_1 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 354; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    if (__pyx_t_1) {
      if (unlikely(((PyObject *)__pyx_v_name) == Py_None)) {
        PyErr_SetString(PyExc_AttributeError, "'NoneType' object has no attribute 'endswith'"); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 354; __pyx_clineno = __LINE__; goto __pyx_L1_error;} 
      }
      __pyx_t_2 = __Pyx_PyUnicode_Tailmatch(((PyObject *)__pyx_v_name), ((PyObject *)__pyx_n_u____), 0, PY_SSIZE_T_MAX, 1); if (unlikely(__pyx_t_2 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 354; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_t_3 = __pyx_t_2;
    } else {
      __pyx_t_3 = __pyx_t_1;
    }
    if (__pyx_t_3) {

      /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":355
 *         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) and (<bytes>name).startswith(b'__') and (<bytes>name).endswith(b'__'):
 */
      __Pyx_XDECREF(__pyx_r);
      __pyx_t_4 = PyObject_GetAttr(__pyx_builtin_object, __pyx_n_s____getattr__); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 355; __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 = 355; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_INCREF(__pyx_v_self);
      PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_v_self);
      __Pyx_GIVEREF(__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 = PyObject_Call(__pyx_t_4, __pyx_t_5, NULL); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 355; __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;
      goto __pyx_L6;
    }
    __pyx_L6:;

    /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":356
 *             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) and (<bytes>name).startswith(b'__') and (<bytes>name).endswith(b'__'):
 *             return object.__getattr__(self, name)
 */
    if (unlikely(((PyObject *)__pyx_v_name) == Py_None)) {
      PyErr_SetString(PyExc_AttributeError, "'NoneType' object has no attribute 'encode'"); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 356; __pyx_clineno = __LINE__; goto __pyx_L1_error;} 
    }
    __pyx_t_7 = PyBytes_AsString(((PyObject *)((struct __pyx_obj_4lupa_5_lupa__LuaObject *)__pyx_v_self)->_runtime->_source_encoding)); if (unlikely((!__pyx_t_7) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 356; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_6 = ((PyObject *)PyUnicode_AsEncodedString(((PyObject *)__pyx_v_name), __pyx_t_7, NULL)); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 356; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(((PyObject *)__pyx_t_6));
    __Pyx_DECREF(__pyx_v_name);
    __pyx_v_name = ((PyObject *)__pyx_t_6);
    __pyx_t_6 = 0;
    goto __pyx_L5;
  }

  /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":357
 *                 return object.__getattr__(self, name)
 *             name = (<unicode>name).encode(self._runtime._source_encoding)
 *         elif isinstance(name, bytes) and (<bytes>name).startswith(b'__') and (<bytes>name).endswith(b'__'):             # <<<<<<<<<<<<<<
 *             return object.__getattr__(self, name)
 *         lock_runtime(self._runtime)
 */
  __pyx_t_3 = PyBytes_Check(__pyx_v_name); 
  if (__pyx_t_3) {
    __pyx_t_6 = PyObject_GetAttr(__pyx_v_name, __pyx_n_s__startswith); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 357; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_t_5 = PyTuple_New(1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 357; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_INCREF(((PyObject *)__pyx_n_b____));
    PyTuple_SET_ITEM(__pyx_t_5, 0, ((PyObject *)__pyx_n_b____));
    __Pyx_GIVEREF(((PyObject *)__pyx_n_b____));
    __pyx_t_4 = PyObject_Call(__pyx_t_6, __pyx_t_5, NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 357; __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_t_1 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_1 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 357; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    if (__pyx_t_1) {
      __pyx_t_4 = PyObject_GetAttr(__pyx_v_name, __pyx_n_s__endswith); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 357; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_t_5 = PyTuple_New(1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 357; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_INCREF(((PyObject *)__pyx_n_b____));
      PyTuple_SET_ITEM(__pyx_t_5, 0, ((PyObject *)__pyx_n_b____));
      __Pyx_GIVEREF(((PyObject *)__pyx_n_b____));
      __pyx_t_6 = PyObject_Call(__pyx_t_4, __pyx_t_5, NULL); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 357; __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_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_6); if (unlikely(__pyx_t_2 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 357; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      __pyx_t_8 = __pyx_t_2;
    } else {
      __pyx_t_8 = __pyx_t_1;
    }
    __pyx_t_1 = __pyx_t_8;
  } else {
    __pyx_t_1 = __pyx_t_3;
  }
  if (__pyx_t_1) {

    /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":358
 *             name = (<unicode>name).encode(self._runtime._source_encoding)
 *         elif isinstance(name, bytes) and (<bytes>name).startswith(b'__') and (<bytes>name).endswith(b'__'):
 *             return object.__getattr__(self, name)             # <<<<<<<<<<<<<<
 *         lock_runtime(self._runtime)
 *         try:
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_6 = PyObject_GetAttr(__pyx_builtin_object, __pyx_n_s____getattr__); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 358; __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 = 358; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_INCREF(__pyx_v_self);
    PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_v_self);
    __Pyx_GIVEREF(__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 = PyObject_Call(__pyx_t_6, __pyx_t_5, NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 358; __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_L5;
  }
  __pyx_L5:;

  /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":359
 *         elif isinstance(name, bytes) and (<bytes>name).startswith(b'__') and (<bytes>name).endswith(b'__'):
 *             return object.__getattr__(self, name)
 *         lock_runtime(self._runtime)             # <<<<<<<<<<<<<<
 *         try:
 *             self.push_lua_object()
 */
  __pyx_t_9 = __pyx_f_4lupa_5_lupa_lock_runtime(((struct __pyx_obj_4lupa_5_lupa__LuaObject *)__pyx_v_self)->_runtime); if (unlikely(__pyx_t_9 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 359; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":360
 *             return object.__getattr__(self, name)
 *         lock_runtime(self._runtime)
 *         try:             # <<<<<<<<<<<<<<
 *             self.push_lua_object()
 *             if lua.lua_isfunction(L, -1):
 */
  /*try:*/ {

    /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":361
 *         lock_runtime(self._runtime)
 *         try:
 *             self.push_lua_object()             # <<<<<<<<<<<<<<
 *             if lua.lua_isfunction(L, -1):
 *                 lua.lua_pop(L, 1)
 */
    __pyx_t_9 = ((struct __pyx_vtabstruct_4lupa_5_lupa__LuaObject *)((struct __pyx_obj_4lupa_5_lupa__LuaObject *)__pyx_v_self)->__pyx_vtab)->push_lua_object(((struct __pyx_obj_4lupa_5_lupa__LuaObject *)__pyx_v_self)); if (unlikely(__pyx_t_9 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 361; __pyx_clineno = __LINE__; goto __pyx_L8;}

    /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":362
 *         try:
 *             self.push_lua_object()
 *             if lua.lua_isfunction(L, -1):             # <<<<<<<<<<<<<<
 *                 lua.lua_pop(L, 1)
 *                 raise TypeError("item/attribute access not supported on functions")
 */
    __pyx_t_1 = lua_isfunction(__pyx_v_L, -1);
    if (__pyx_t_1) {

      /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":363
 *             self.push_lua_object()
 *             if lua.lua_isfunction(L, -1):
 *                 lua.lua_pop(L, 1)             # <<<<<<<<<<<<<<
 *                 raise TypeError("item/attribute access not supported on functions")
 *             py_to_lua(self._runtime, L, name, 1)
 */
      lua_pop(__pyx_v_L, 1);

      /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":364
 *             if lua.lua_isfunction(L, -1):
 *                 lua.lua_pop(L, 1)
 *                 raise TypeError("item/attribute access not supported on functions")             # <<<<<<<<<<<<<<
 *             py_to_lua(self._runtime, L, name, 1)
 *             lua.lua_gettable(L, -2)
 */
      __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 364; __pyx_clineno = __LINE__; goto __pyx_L8;}
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_INCREF(((PyObject *)__pyx_kp_s_13));
      PyTuple_SET_ITEM(__pyx_t_4, 0, ((PyObject *)__pyx_kp_s_13));
      __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_13));
      __pyx_t_5 = PyObject_Call(__pyx_builtin_TypeError, __pyx_t_4, NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 364; __pyx_clineno = __LINE__; goto __pyx_L8;}
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __Pyx_Raise(__pyx_t_5, 0, 0);
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 364; __pyx_clineno = __LINE__; goto __pyx_L8;}
      goto __pyx_L10;
    }
    __pyx_L10:;

    /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":365
 *                 lua.lua_pop(L, 1)
 *                 raise TypeError("item/attribute access not supported on functions")
 *             py_to_lua(self._runtime, L, name, 1)             # <<<<<<<<<<<<<<
 *             lua.lua_gettable(L, -2)
 *             return py_from_lua(self._runtime, L, -1)
 */
    __pyx_t_9 = __pyx_f_4lupa_5_lupa_py_to_lua(((struct __pyx_obj_4lupa_5_lupa__LuaObject *)__pyx_v_self)->_runtime, __pyx_v_L, __pyx_v_name, 1); if (unlikely(__pyx_t_9 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 365; __pyx_clineno = __LINE__; goto __pyx_L8;}

    /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":366
 *                 raise TypeError("item/attribute access not supported on functions")
 *             py_to_lua(self._runtime, L, name, 1)
 *             lua.lua_gettable(L, -2)             # <<<<<<<<<<<<<<
 *             return py_from_lua(self._runtime, L, -1)
 *         finally:
 */
    lua_gettable(__pyx_v_L, -2);

    /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":367
 *             py_to_lua(self._runtime, L, name, 1)
 *             lua.lua_gettable(L, -2)
 *             return py_from_lua(self._runtime, L, -1)             # <<<<<<<<<<<<<<
 *         finally:
 *             lua.lua_settop(L, 0)
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_5 = __pyx_f_4lupa_5_lupa_py_from_lua(((struct __pyx_obj_4lupa_5_lupa__LuaObject *)__pyx_v_self)->_runtime, __pyx_v_L, -1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 367; __pyx_clineno = __LINE__; goto __pyx_L8;}
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_r = __pyx_t_5;
    __pyx_t_5 = 0;
    goto __pyx_L7;
  }

  /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":369
 *             return py_from_lua(self._runtime, L, -1)
 *         finally:
 *             lua.lua_settop(L, 0)             # <<<<<<<<<<<<<<
 *             unlock_runtime(self._runtime)
 * 
 */
  /*finally:*/ {
    int __pyx_why;
    PyObject *__pyx_exc_type, *__pyx_exc_value, *__pyx_exc_tb;
    int __pyx_exc_lineno;
    __pyx_exc_type = 0; __pyx_exc_value = 0; __pyx_exc_tb = 0; __pyx_exc_lineno = 0;
    __pyx_why = 0; goto __pyx_L9;
    __pyx_L7: __pyx_exc_type = 0; __pyx_exc_value = 0; __pyx_exc_tb = 0; __pyx_exc_lineno = 0;
    __pyx_why = 3; goto __pyx_L9;
    __pyx_L8: {
      __pyx_why = 4;
      __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
      __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
      __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
      __Pyx_ErrFetch(&__pyx_exc_type, &__pyx_exc_value, &__pyx_exc_tb);
      __pyx_exc_lineno = __pyx_lineno;
      goto __pyx_L9;
    }
    __pyx_L9:;
    lua_settop(__pyx_v_L, 0);

    /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":370
 *         finally:
 *             lua.lua_settop(L, 0)
 *             unlock_runtime(self._runtime)             # <<<<<<<<<<<<<<
 * 
 *     def __setattr__(self, name, value):
 */
    __pyx_f_4lupa_5_lupa_unlock_runtime(((struct __pyx_obj_4lupa_5_lupa__LuaObject *)__pyx_v_self)->_runtime);
    switch (__pyx_why) {
      case 3: goto __pyx_L0;
      case 4: {
        __Pyx_ErrRestore(__pyx_exc_type, __pyx_exc_value, __pyx_exc_tb);
        __pyx_lineno = __pyx_exc_lineno;
        __pyx_exc_type = 0;
        __pyx_exc_value = 0;
        __pyx_exc_tb = 0;
        goto __pyx_L1_error;
      }
    }
  }

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  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._LuaObject.__getattr__");
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_DECREF(__pyx_v_name);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":372
 *             unlock_runtime(self._runtime)
 * 
 *     def __setattr__(self, name, value):             # <<<<<<<<<<<<<<
 *         assert self._runtime is not None
 *         cdef lua_State* L = self._state
 */

static int __pyx_pf_4lupa_5_lupa_10_LuaObject___setattr__(PyObject *__pyx_v_self, PyObject *__pyx_v_name, PyObject *__pyx_v_value); /*proto*/
static int __pyx_pf_4lupa_5_lupa_10_LuaObject___setattr__(PyObject *__pyx_v_self, PyObject *__pyx_v_name, PyObject *__pyx_v_value) {
  lua_State *__pyx_v_L;
  int __pyx_r;
  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;
  __Pyx_RefNannySetupContext("__setattr__");
  __Pyx_INCREF(__pyx_v_name);

  /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":373
 * 
 *     def __setattr__(self, name, value):
 *         assert self._runtime is not None             # <<<<<<<<<<<<<<
 *         cdef lua_State* L = self._state
 *         if isinstance(name, unicode):
 */
  #ifndef PYREX_WITHOUT_ASSERTIONS
  __pyx_t_1 = (((PyObject *)((struct __pyx_obj_4lupa_5_lupa__LuaObject *)__pyx_v_self)->_runtime) != Py_None);
  if (unlikely(!__pyx_t_1)) {
    PyErr_SetNone(PyExc_AssertionError);
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 373; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  #endif

  /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":374
 *     def __setattr__(self, name, value):
 *         assert self._runtime is not None
 *         cdef lua_State* L = self._state             # <<<<<<<<<<<<<<
 *         if isinstance(name, unicode):
 *             if (<unicode>name).startswith(u'__') and (<unicode>name).endswith(u'__'):
 */
  __pyx_v_L = ((struct __pyx_obj_4lupa_5_lupa__LuaObject *)__pyx_v_self)->_state;

  /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":375
 *         assert self._runtime is not None
 *         cdef lua_State* L = self._state
 *         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); 
  if (__pyx_t_1) {

    /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":376
 *         cdef lua_State* L = self._state
 *         if isinstance(name, unicode):
 *             if (<unicode>name).startswith(u'__') and (<unicode>name).endswith(u'__'):             # <<<<<<<<<<<<<<
 *                 object.__setattr__(self, name, value)
 *             name = (<unicode>name).encode(self._runtime._source_encoding)
 */
    if (unlikely(((PyObject *)__pyx_v_name) == Py_None)) {
      PyErr_SetString(PyExc_AttributeError, "'NoneType' object has no attribute 'startswith'"); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 376; __pyx_clineno = __LINE__; goto __pyx_L1_error;} 
    }
    __pyx_t_1 = __Pyx_PyUnicode_Tailmatch(((PyObject *)__pyx_v_name), ((PyObject *)__pyx_n_u____), 0, PY_SSIZE_T_MAX, -1); if (unlikely(__pyx_t_1 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 376; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    if (__pyx_t_1) {
      if (unlikely(((PyObject *)__pyx_v_name) == Py_None)) {
        PyErr_SetString(PyExc_AttributeError, "'NoneType' object has no attribute 'endswith'"); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 376; __pyx_clineno = __LINE__; goto __pyx_L1_error;} 
      }
      __pyx_t_2 = __Pyx_PyUnicode_Tailmatch(((PyObject *)__pyx_v_name), ((PyObject *)__pyx_n_u____), 0, PY_SSIZE_T_MAX, 1); if (unlikely(__pyx_t_2 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 376; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_t_3 = __pyx_t_2;
    } else {
      __pyx_t_3 = __pyx_t_1;
    }
    if (__pyx_t_3) {

      /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":377
 *         if isinstance(name, unicode):
 *             if (<unicode>name).startswith(u'__') and (<unicode>name).endswith(u'__'):
 *                 object.__setattr__(self, name, value)             # <<<<<<<<<<<<<<
 *             name = (<unicode>name).encode(self._runtime._source_encoding)
 *         elif isinstance(name, bytes) and (<bytes>name).startswith(b'__') and (<bytes>name).endswith(b'__'):
 */
      __pyx_t_4 = PyObject_GetAttr(__pyx_builtin_object, __pyx_n_s____setattr__); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 377; __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 = 377; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_INCREF(__pyx_v_self);
      PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_v_self);
      __Pyx_GIVEREF(__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 = PyObject_Call(__pyx_t_4, __pyx_t_5, NULL); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 377; __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;
      goto __pyx_L6;
    }
    __pyx_L6:;

    /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":378
 *             if (<unicode>name).startswith(u'__') and (<unicode>name).endswith(u'__'):
 *                 object.__setattr__(self, name, value)
 *             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(((PyObject *)__pyx_v_name) == Py_None)) {
      PyErr_SetString(PyExc_AttributeError, "'NoneType' object has no attribute 'encode'"); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 378; __pyx_clineno = __LINE__; goto __pyx_L1_error;} 
    }
    __pyx_t_7 = PyBytes_AsString(((PyObject *)((struct __pyx_obj_4lupa_5_lupa__LuaObject *)__pyx_v_self)->_runtime->_source_encoding)); if (unlikely((!__pyx_t_7) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 378; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_6 = ((PyObject *)PyUnicode_AsEncodedString(((PyObject *)__pyx_v_name), __pyx_t_7, NULL)); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 378; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(((PyObject *)__pyx_t_6));
    __Pyx_DECREF(__pyx_v_name);
    __pyx_v_name = ((PyObject *)__pyx_t_6);
    __pyx_t_6 = 0;
    goto __pyx_L5;
  }

  /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":379
 *                 object.__setattr__(self, name, value)
 *             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)
 *         lock_runtime(self._runtime)
 */
  __pyx_t_3 = PyBytes_Check(__pyx_v_name); 
  if (__pyx_t_3) {
    __pyx_t_6 = PyObject_GetAttr(__pyx_v_name, __pyx_n_s__startswith); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 379; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_t_5 = PyTuple_New(1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 379; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_INCREF(((PyObject *)__pyx_n_b____));
    PyTuple_SET_ITEM(__pyx_t_5, 0, ((PyObject *)__pyx_n_b____));
    __Pyx_GIVEREF(((PyObject *)__pyx_n_b____));
    __pyx_t_4 = PyObject_Call(__pyx_t_6, __pyx_t_5, NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 379; __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_t_1 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_1 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 379; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    if (__pyx_t_1) {
      __pyx_t_4 = PyObject_GetAttr(__pyx_v_name, __pyx_n_s__endswith); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 379; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_t_5 = PyTuple_New(1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 379; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_INCREF(((PyObject *)__pyx_n_b____));
      PyTuple_SET_ITEM(__pyx_t_5, 0, ((PyObject *)__pyx_n_b____));
      __Pyx_GIVEREF(((PyObject *)__pyx_n_b____));
      __pyx_t_6 = PyObject_Call(__pyx_t_4, __pyx_t_5, NULL); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 379; __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_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_6); if (unlikely(__pyx_t_2 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 379; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      __pyx_t_8 = __pyx_t_2;
    } else {
      __pyx_t_8 = __pyx_t_1;
    }
    __pyx_t_1 = __pyx_t_8;
  } else {
    __pyx_t_1 = __pyx_t_3;
  }
  if (__pyx_t_1) {

    /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":380
 *             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)             # <<<<<<<<<<<<<<
 *         lock_runtime(self._runtime)
 *         try:
 */
    __pyx_t_6 = PyObject_GetAttr(__pyx_builtin_object, __pyx_n_s____setattr__); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 380; __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 = 380; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_INCREF(__pyx_v_self);
    PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_v_self);
    __Pyx_GIVEREF(__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 = PyObject_Call(__pyx_t_6, __pyx_t_5, NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 380; __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;
    goto __pyx_L5;
  }
  __pyx_L5:;

  /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":381
 *         elif isinstance(name, bytes) and (<bytes>name).startswith(b'__') and (<bytes>name).endswith(b'__'):
 *             object.__setattr__(self, name, value)
 *         lock_runtime(self._runtime)             # <<<<<<<<<<<<<<
 *         try:
 *             self.push_lua_object()
 */
  __pyx_t_9 = __pyx_f_4lupa_5_lupa_lock_runtime(((struct __pyx_obj_4lupa_5_lupa__LuaObject *)__pyx_v_self)->_runtime); if (unlikely(__pyx_t_9 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 381; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":382
 *             object.__setattr__(self, name, value)
 *         lock_runtime(self._runtime)
 *         try:             # <<<<<<<<<<<<<<
 *             self.push_lua_object()
 *             if not lua.lua_istable(L, -1):
 */
  /*try:*/ {

    /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":383
 *         lock_runtime(self._runtime)
 *         try:
 *             self.push_lua_object()             # <<<<<<<<<<<<<<
 *             if not lua.lua_istable(L, -1):
 *                 lua.lua_pop(L, -1)
 */
    __pyx_t_9 = ((struct __pyx_vtabstruct_4lupa_5_lupa__LuaObject *)((struct __pyx_obj_4lupa_5_lupa__LuaObject *)__pyx_v_self)->__pyx_vtab)->push_lua_object(((struct __pyx_obj_4lupa_5_lupa__LuaObject *)__pyx_v_self)); if (unlikely(__pyx_t_9 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 383; __pyx_clineno = __LINE__; goto __pyx_L8;}

    /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":384
 *         try:
 *             self.push_lua_object()
 *             if not lua.lua_istable(L, -1):             # <<<<<<<<<<<<<<
 *                 lua.lua_pop(L, -1)
 *                 raise TypeError("Lua object is not a table")
 */
    __pyx_t_1 = (!lua_istable(__pyx_v_L, -1));
    if (__pyx_t_1) {

      /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":385
 *             self.push_lua_object()
 *             if not lua.lua_istable(L, -1):
 *                 lua.lua_pop(L, -1)             # <<<<<<<<<<<<<<
 *                 raise TypeError("Lua object is not a table")
 *             try:
 */
      lua_pop(__pyx_v_L, -1);

      /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":386
 *             if not lua.lua_istable(L, -1):
 *                 lua.lua_pop(L, -1)
 *                 raise TypeError("Lua object is not a table")             # <<<<<<<<<<<<<<
 *             try:
 *                 py_to_lua(self._runtime, L, name, 1)
 */
      __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 386; __pyx_clineno = __LINE__; goto __pyx_L8;}
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_INCREF(((PyObject *)__pyx_kp_s_14));
      PyTuple_SET_ITEM(__pyx_t_4, 0, ((PyObject *)__pyx_kp_s_14));
      __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_14));
      __pyx_t_5 = PyObject_Call(__pyx_builtin_TypeError, __pyx_t_4, NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 386; __pyx_clineno = __LINE__; goto __pyx_L8;}
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __Pyx_Raise(__pyx_t_5, 0, 0);
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 386; __pyx_clineno = __LINE__; goto __pyx_L8;}
      goto __pyx_L10;
    }
    __pyx_L10:;

    /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":387
 *                 lua.lua_pop(L, -1)
 *                 raise TypeError("Lua object is not a table")
 *             try:             # <<<<<<<<<<<<<<
 *                 py_to_lua(self._runtime, L, name, 1)
 *                 py_to_lua(self._runtime, L, value, 1)
 */
    /*try:*/ {

      /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":388
 *                 raise TypeError("Lua object is not a table")
 *             try:
 *                 py_to_lua(self._runtime, L, name, 1)             # <<<<<<<<<<<<<<
 *                 py_to_lua(self._runtime, L, value, 1)
 *                 lua.lua_settable(L, -3)
 */
      __pyx_t_9 = __pyx_f_4lupa_5_lupa_py_to_lua(((struct __pyx_obj_4lupa_5_lupa__LuaObject *)__pyx_v_self)->_runtime, __pyx_v_L, __pyx_v_name, 1); if (unlikely(__pyx_t_9 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 388; __pyx_clineno = __LINE__; goto __pyx_L12;}

      /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":389
 *             try:
 *                 py_to_lua(self._runtime, L, name, 1)
 *                 py_to_lua(self._runtime, L, value, 1)             # <<<<<<<<<<<<<<
 *                 lua.lua_settable(L, -3)
 *             finally:
 */
      __pyx_t_9 = __pyx_f_4lupa_5_lupa_py_to_lua(((struct __pyx_obj_4lupa_5_lupa__LuaObject *)__pyx_v_self)->_runtime, __pyx_v_L, __pyx_v_value, 1); if (unlikely(__pyx_t_9 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 389; __pyx_clineno = __LINE__; goto __pyx_L12;}

      /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":390
 *                 py_to_lua(self._runtime, L, name, 1)
 *                 py_to_lua(self._runtime, L, value, 1)
 *                 lua.lua_settable(L, -3)             # <<<<<<<<<<<<<<
 *             finally:
 *                 lua.lua_settop(L, 0)
 */
      lua_settable(__pyx_v_L, -3);
    }

    /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":392
 *                 lua.lua_settable(L, -3)
 *             finally:
 *                 lua.lua_settop(L, 0)             # <<<<<<<<<<<<<<
 *         finally:
 *             unlock_runtime(self._runtime)
 */
    /*finally:*/ {
      int __pyx_why;
      PyObject *__pyx_exc_type, *__pyx_exc_value, *__pyx_exc_tb;
      int __pyx_exc_lineno;
      __pyx_exc_type = 0; __pyx_exc_value = 0; __pyx_exc_tb = 0; __pyx_exc_lineno = 0;
      __pyx_why = 0; goto __pyx_L13;
      __pyx_L12: {
        __pyx_why = 4;
        __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
        __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
        __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
        __Pyx_ErrFetch(&__pyx_exc_type, &__pyx_exc_value, &__pyx_exc_tb);
        __pyx_exc_lineno = __pyx_lineno;
        goto __pyx_L13;
      }
      __pyx_L13:;
      lua_settop(__pyx_v_L, 0);
      switch (__pyx_why) {
        case 4: {
          __Pyx_ErrRestore(__pyx_exc_type, __pyx_exc_value, __pyx_exc_tb);
          __pyx_lineno = __pyx_exc_lineno;
          __pyx_exc_type = 0;
          __pyx_exc_value = 0;
          __pyx_exc_tb = 0;
          goto __pyx_L8;
        }
      }
    }
  }

  /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":394
 *                 lua.lua_settop(L, 0)
 *         finally:
 *             unlock_runtime(self._runtime)             # <<<<<<<<<<<<<<
 * 
 *     def __getitem__(self, index_or_name):
 */
  /*finally:*/ {
    int __pyx_why;
    PyObject *__pyx_exc_type, *__pyx_exc_value, *__pyx_exc_tb;
    int __pyx_exc_lineno;
    __pyx_exc_type = 0; __pyx_exc_value = 0; __pyx_exc_tb = 0; __pyx_exc_lineno = 0;
    __pyx_why = 0; goto __pyx_L9;
    __pyx_L8: {
      __pyx_why = 4;
      __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
      __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
      __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
      __Pyx_ErrFetch(&__pyx_exc_type, &__pyx_exc_value, &__pyx_exc_tb);
      __pyx_exc_lineno = __pyx_lineno;
      goto __pyx_L9;
    }
    __pyx_L9:;
    __pyx_f_4lupa_5_lupa_unlock_runtime(((struct __pyx_obj_4lupa_5_lupa__LuaObject *)__pyx_v_self)->_runtime);
    switch (__pyx_why) {
      case 4: {
        __Pyx_ErrRestore(__pyx_exc_type, __pyx_exc_value, __pyx_exc_tb);
        __pyx_lineno = __pyx_exc_lineno;
        __pyx_exc_type = 0;
        __pyx_exc_value = 0;
        __pyx_exc_tb = 0;
        goto __pyx_L1_error;
      }
    }
  }

  __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._LuaObject.__setattr__");
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_DECREF(__pyx_v_name);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":396
 *             unlock_runtime(self._runtime)
 * 
 *     def __getitem__(self, index_or_name):             # <<<<<<<<<<<<<<
 *         return self.__getattr__(index_or_name)
 * 
 */

static PyObject *__pyx_pf_4lupa_5_lupa_10_LuaObject___getitem__(PyObject *__pyx_v_self, PyObject *__pyx_v_index_or_name); /*proto*/
static PyObject *__pyx_pf_4lupa_5_lupa_10_LuaObject___getitem__(PyObject *__pyx_v_self, PyObject *__pyx_v_index_or_name) {
  PyObject *__pyx_r = NULL;
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  __Pyx_RefNannySetupContext("__getitem__");

  /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":397
 * 
 *     def __getitem__(self, index_or_name):
 *         return self.__getattr__(index_or_name)             # <<<<<<<<<<<<<<
 * 
 *     def __setitem__(self, index_or_name, value):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s____getattr__); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 397; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 397; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_INCREF(__pyx_v_index_or_name);
  PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_index_or_name);
  __Pyx_GIVEREF(__pyx_v_index_or_name);
  __pyx_t_3 = PyObject_Call(__pyx_t_1, __pyx_t_2, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 397; __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;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("lupa._lupa._LuaObject.__getitem__");
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":399
 *         return self.__getattr__(index_or_name)
 * 
 *     def __setitem__(self, index_or_name, value):             # <<<<<<<<<<<<<<
 *         self.__setattr__(index_or_name, value)
 * 
 */

static int __pyx_pf_4lupa_5_lupa_10_LuaObject___setitem__(PyObject *__pyx_v_self, PyObject *__pyx_v_index_or_name, PyObject *__pyx_v_value); /*proto*/
static int __pyx_pf_4lupa_5_lupa_10_LuaObject___setitem__(PyObject *__pyx_v_self, PyObject *__pyx_v_index_or_name, PyObject *__pyx_v_value) {
  int __pyx_r;
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  __Pyx_RefNannySetupContext("__setitem__");

  /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":400
 * 
 *     def __setitem__(self, index_or_name, value):
 *         self.__setattr__(index_or_name, value)             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_t_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s____setattr__); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 400; __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 = 400; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_INCREF(__pyx_v_index_or_name);
  PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_index_or_name);
  __Pyx_GIVEREF(__pyx_v_index_or_name);
  __Pyx_INCREF(__pyx_v_value);
  PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_v_value);
  __Pyx_GIVEREF(__pyx_v_value);
  __pyx_t_3 = PyObject_Call(__pyx_t_1, __pyx_t_2, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 400; __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_DECREF(__pyx_t_3); __pyx_t_3 = 0;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("lupa._lupa._LuaObject.__setitem__");
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":403
 * 
 * 
 * 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;
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("new_lua_object");

  /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":404
 * 
 * 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(((PyObject*)__pyx_ptype_4lupa_5_lupa__LuaObject)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 404; __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 = 404; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_v_obj = ((struct __pyx_obj_4lupa_5_lupa__LuaObject *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":405
 * 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);

  /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":406
 *     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;

  __pyx_r = ((struct __pyx_obj_4lupa_5_lupa__LuaObject *)Py_None); __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("lupa._lupa.new_lua_object");
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_obj);
  __Pyx_XGIVEREF((PyObject *)__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":408
 *     return obj
 * 
 * cdef void init_lua_object(_LuaObject obj, LuaRuntime runtime, lua_State* L, int n):             # <<<<<<<<<<<<<<
 *     # additional INCREF to keep runtime from disappearing in GC runs
 *     cpython.ref.Py_INCREF(runtime)
 */

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_RefNannySetupContext("init_lua_object");

  /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":410
 * cdef void init_lua_object(_LuaObject obj, LuaRuntime runtime, lua_State* L, int n):
 *     # additional INCREF to keep runtime from disappearing in GC runs
 *     cpython.ref.Py_INCREF(runtime)             # <<<<<<<<<<<<<<
 *     obj._runtime = runtime
 *     obj._state = L
 */
  Py_INCREF(((PyObject *)__pyx_v_runtime));

  /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":411
 *     # additional INCREF to keep runtime from disappearing in GC runs
 *     cpython.ref.Py_INCREF(runtime)
 *     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;

  /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":412
 *     cpython.ref.Py_INCREF(runtime)
 *     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;

  /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":413
 *     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);

  /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":414
 *     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);

  __Pyx_RefNannyFinishContext();
}

/* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":416
 *     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;
  int __pyx_v_lua_type;
  void *__pyx_v_ptr;
  PyObject *__pyx_r = NULL;
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  int __pyx_t_5;
  PyObject *__pyx_t_6 = NULL;
  PyObject *__pyx_t_7 = NULL;
  PyObject *__pyx_t_8 = NULL;
  __Pyx_RefNannySetupContext("lua_object_repr");
  __pyx_v_py_bytes = ((PyObject *)Py_None); __Pyx_INCREF(Py_None);

  /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":418
 * 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);

  /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":419
 *     cdef bytes py_bytes
 *     lua_type = lua.lua_type(L, -1)
 *     if lua_type in (lua.LUA_TTABLE, lua.LUA_TFUNCTION):             # <<<<<<<<<<<<<<
 *         ptr = <void*>lua.lua_topointer(L, -1)
 *     elif lua_type in (lua.LUA_TUSERDATA, lua.LUA_TLIGHTUSERDATA):
 */
  switch (__pyx_v_lua_type) {
    case LUA_TTABLE:
    case LUA_TFUNCTION:

    /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":420
 *     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;

    /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":421
 *     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:

    /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":422
 *         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;

    /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":423
 *     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)
 *     if ptr:
 */
    case LUA_TTHREAD:

    /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":424
 *         ptr = <void*>lua.lua_touserdata(L, -1)
 *     elif lua_type == lua.LUA_TTHREAD:
 *         ptr = <void*>lua.lua_tothread(L, -1)             # <<<<<<<<<<<<<<
 *     if ptr:
 *         py_bytes = cpython.bytes.PyBytes_FromFormat(
 */
    __pyx_v_ptr = ((void *)lua_tothread(__pyx_v_L, -1));
    break;
  }

  /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":425
 *     elif lua_type == lua.LUA_TTHREAD:
 *         ptr = <void*>lua.lua_tothread(L, -1)
 *     if ptr:             # <<<<<<<<<<<<<<
 *         py_bytes = cpython.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) {

    /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":427
 *     if ptr:
 *         py_bytes = cpython.bytes.PyBytes_FromFormat(
 *             "<Lua %s at %p>", lua.lua_typename(L, lua_type), ptr)             # <<<<<<<<<<<<<<
 *     else:
 *         py_bytes = cpython.bytes.PyBytes_FromFormat(
 */
    __pyx_t_2 = ((PyObject *)PyBytes_FromFormat(__pyx_k_15, lua_typename(__pyx_v_L, __pyx_v_lua_type), __pyx_v_ptr)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 426; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(((PyObject *)__pyx_v_py_bytes));
    __pyx_v_py_bytes = ((PyObject *)__pyx_t_2);
    __pyx_t_2 = 0;
    goto __pyx_L3;
  }
  /*else*/ {

    /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":430
 *     else:
 *         py_bytes = cpython.bytes.PyBytes_FromFormat(
 *             "<Lua %s>", lua.lua_typename(L, lua_type))             # <<<<<<<<<<<<<<
 *     try:
 *         return py_bytes.decode(encoding)
 */
    __pyx_t_2 = ((PyObject *)PyBytes_FromFormat(__pyx_k_16, lua_typename(__pyx_v_L, __pyx_v_lua_type))); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 429; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(((PyObject *)__pyx_v_py_bytes));
    __pyx_v_py_bytes = ((PyObject *)__pyx_t_2);
    __pyx_t_2 = 0;
  }
  __pyx_L3:;

  /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":431
 *         py_bytes = cpython.bytes.PyBytes_FromFormat(
 *             "<Lua %s>", lua.lua_typename(L, lua_type))
 *     try:             # <<<<<<<<<<<<<<
 *         return py_bytes.decode(encoding)
 *     except UnicodeDecodeError:
 */
  {
    PyObject *__pyx_save_exc_type, *__pyx_save_exc_value, *__pyx_save_exc_tb;
    __Pyx_ExceptionSave(&__pyx_save_exc_type, &__pyx_save_exc_value, &__pyx_save_exc_tb);
    __Pyx_XGOTREF(__pyx_save_exc_type);
    __Pyx_XGOTREF(__pyx_save_exc_value);
    __Pyx_XGOTREF(__pyx_save_exc_tb);
    /*try:*/ {

      /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":432
 *             "<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 = PyObject_GetAttr(((PyObject *)__pyx_v_py_bytes), __pyx_n_s__decode); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 432; __pyx_clineno = __LINE__; goto __pyx_L4_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 432; __pyx_clineno = __LINE__; goto __pyx_L4_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_4 = PyObject_Call(__pyx_t_2, __pyx_t_3, NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 432; __pyx_clineno = __LINE__; goto __pyx_L4_error;}
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_r = __pyx_t_4;
      __pyx_t_4 = 0;
      goto __pyx_L8_try_return;
    }
    __Pyx_XDECREF(__pyx_save_exc_type); __pyx_save_exc_type = 0;
    __Pyx_XDECREF(__pyx_save_exc_value); __pyx_save_exc_value = 0;
    __Pyx_XDECREF(__pyx_save_exc_tb); __pyx_save_exc_tb = 0;
    goto __pyx_L11_try_end;
    __pyx_L8_try_return:;
    __Pyx_XGIVEREF(__pyx_save_exc_type);
    __Pyx_XGIVEREF(__pyx_save_exc_value);
    __Pyx_XGIVEREF(__pyx_save_exc_tb);
    __Pyx_ExceptionReset(__pyx_save_exc_type, __pyx_save_exc_value, __pyx_save_exc_tb);
    goto __pyx_L0;
    __pyx_L4_error:;
    __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;

    /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":433
 *     try:
 *         return py_bytes.decode(encoding)
 *     except UnicodeDecodeError:             # <<<<<<<<<<<<<<
 *         # safe 'decode'
 *         return py_bytes.decode('ISO-8859-1')
 */
    __pyx_t_5 = PyErr_ExceptionMatches(__pyx_builtin_UnicodeDecodeError);
    if (__pyx_t_5) {
      __Pyx_AddTraceback("lupa._lupa.lua_object_repr");
      if (__Pyx_GetException(&__pyx_t_4, &__pyx_t_3, &__pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 433; __pyx_clineno = __LINE__; goto __pyx_L6_except_error;}
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_GOTREF(__pyx_t_2);

      /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":435
 *     except UnicodeDecodeError:
 *         # safe 'decode'
 *         return py_bytes.decode('ISO-8859-1')             # <<<<<<<<<<<<<<
 * 
 * 
 */
      __Pyx_XDECREF(__pyx_r);
      __pyx_t_6 = PyObject_GetAttr(((PyObject *)__pyx_v_py_bytes), __pyx_n_s__decode); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 435; __pyx_clineno = __LINE__; goto __pyx_L6_except_error;}
      __Pyx_GOTREF(__pyx_t_6);
      __pyx_t_7 = PyTuple_New(1); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 435; __pyx_clineno = __LINE__; goto __pyx_L6_except_error;}
      __Pyx_GOTREF(__pyx_t_7);
      __Pyx_INCREF(((PyObject *)__pyx_kp_s_17));
      PyTuple_SET_ITEM(__pyx_t_7, 0, ((PyObject *)__pyx_kp_s_17));
      __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_17));
      __pyx_t_8 = PyObject_Call(__pyx_t_6, __pyx_t_7, NULL); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 435; __pyx_clineno = __LINE__; goto __pyx_L6_except_error;}
      __Pyx_GOTREF(__pyx_t_8);
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      __pyx_r = __pyx_t_8;
      __pyx_t_8 = 0;
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      goto __pyx_L7_except_return;
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      goto __pyx_L5_exception_handled;
    }
    __pyx_L6_except_error:;
    __Pyx_XGIVEREF(__pyx_save_exc_type);
    __Pyx_XGIVEREF(__pyx_save_exc_value);
    __Pyx_XGIVEREF(__pyx_save_exc_tb);
    __Pyx_ExceptionReset(__pyx_save_exc_type, __pyx_save_exc_value, __pyx_save_exc_tb);
    goto __pyx_L1_error;
    __pyx_L7_except_return:;
    __Pyx_XGIVEREF(__pyx_save_exc_type);
    __Pyx_XGIVEREF(__pyx_save_exc_value);
    __Pyx_XGIVEREF(__pyx_save_exc_tb);
    __Pyx_ExceptionReset(__pyx_save_exc_type, __pyx_save_exc_value, __pyx_save_exc_tb);
    goto __pyx_L0;
    __pyx_L5_exception_handled:;
    __Pyx_XGIVEREF(__pyx_save_exc_type);
    __Pyx_XGIVEREF(__pyx_save_exc_value);
    __Pyx_XGIVEREF(__pyx_save_exc_tb);
    __Pyx_ExceptionReset(__pyx_save_exc_type, __pyx_save_exc_value, __pyx_save_exc_tb);
    __pyx_L11_try_end:;
  }

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_AddTraceback("lupa._lupa.lua_object_repr");
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_DECREF(__pyx_v_py_bytes);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":439
 * 
 * cdef class _LuaTable(_LuaObject):
 *     def __iter__(self):             # <<<<<<<<<<<<<<
 *         return _LuaIter(self, KEYS)
 * 
 */

static PyObject *__pyx_pf_4lupa_5_lupa_9_LuaTable___iter__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pf_4lupa_5_lupa_9_LuaTable___iter__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  __Pyx_RefNannySetupContext("__iter__");

  /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":440
 * cdef class _LuaTable(_LuaObject):
 *     def __iter__(self):
 *         return _LuaIter(self, KEYS)             # <<<<<<<<<<<<<<
 * 
 *     def keys(self):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = PyInt_FromLong(__pyx_e_4lupa_5_lupa_KEYS); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 440; __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 = 440; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_INCREF(__pyx_v_self);
  PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_self);
  __Pyx_GIVEREF(__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 = 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 = 440; __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;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_AddTraceback("lupa._lupa._LuaTable.__iter__");
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":442
 *         return _LuaIter(self, KEYS)
 * 
 *     def keys(self):             # <<<<<<<<<<<<<<
 *         """Returns an iterator over the keys of a table that this
 *         object represents.  Same as iter(obj).
 */

static PyObject *__pyx_pf_4lupa_5_lupa_9_LuaTable_keys(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static char __pyx_doc_4lupa_5_lupa_9_LuaTable_keys[] = "_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_pf_4lupa_5_lupa_9_LuaTable_keys(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = NULL;
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  __Pyx_RefNannySetupContext("keys");

  /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":446
 *         object represents.  Same as iter(obj).
 *         """
 *         return _LuaIter(self, KEYS)             # <<<<<<<<<<<<<<
 * 
 *     def values(self):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = PyInt_FromLong(__pyx_e_4lupa_5_lupa_KEYS); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 446; __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 = 446; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_INCREF(__pyx_v_self);
  PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_self);
  __Pyx_GIVEREF(__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 = 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 = 446; __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;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_AddTraceback("lupa._lupa._LuaTable.keys");
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":448
 *         return _LuaIter(self, KEYS)
 * 
 *     def values(self):             # <<<<<<<<<<<<<<
 *         """Returns an iterator over the values of a table that this
 *         object represents.
 */

static PyObject *__pyx_pf_4lupa_5_lupa_9_LuaTable_values(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static char __pyx_doc_4lupa_5_lupa_9_LuaTable_values[] = "_LuaTable.values(self)\nReturns an iterator over the values of a table that this\n        object represents.\n        ";
static PyObject *__pyx_pf_4lupa_5_lupa_9_LuaTable_values(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = NULL;
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  __Pyx_RefNannySetupContext("values");

  /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":452
 *         object represents.
 *         """
 *         return _LuaIter(self, VALUES)             # <<<<<<<<<<<<<<
 * 
 *     def items(self):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = PyInt_FromLong(__pyx_e_4lupa_5_lupa_VALUES); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 452; __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 = 452; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_INCREF(__pyx_v_self);
  PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_self);
  __Pyx_GIVEREF(__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 = 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 = 452; __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;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_AddTraceback("lupa._lupa._LuaTable.values");
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":454
 *         return _LuaIter(self, VALUES)
 * 
 *     def items(self):             # <<<<<<<<<<<<<<
 *         """Returns an iterator over the key-value pairs of a table
 *         that this object represents.
 */

static PyObject *__pyx_pf_4lupa_5_lupa_9_LuaTable_items(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static char __pyx_doc_4lupa_5_lupa_9_LuaTable_items[] = "_LuaTable.items(self)\nReturns an iterator over the key-value pairs of a table\n        that this object represents.\n        ";
static PyObject *__pyx_pf_4lupa_5_lupa_9_LuaTable_items(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = NULL;
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  __Pyx_RefNannySetupContext("items");

  /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":458
 *         that this object represents.
 *         """
 *         return _LuaIter(self, ITEMS)             # <<<<<<<<<<<<<<
 * 
 * cdef _LuaTable new_lua_table(LuaRuntime runtime, lua_State* L, int n):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = PyInt_FromLong(__pyx_e_4lupa_5_lupa_ITEMS); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 458; __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 = 458; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_INCREF(__pyx_v_self);
  PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_self);
  __Pyx_GIVEREF(__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 = 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 = 458; __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;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_AddTraceback("lupa._lupa._LuaTable.items");
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":460
 *         return _LuaIter(self, ITEMS)
 * 
 * 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;
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("new_lua_table");

  /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":461
 * 
 * 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(((PyObject*)__pyx_ptype_4lupa_5_lupa__LuaTable)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 461; __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 = 461; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_v_obj = ((struct __pyx_obj_4lupa_5_lupa__LuaTable *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":462
 * 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);

  /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":463
 *     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;

  __pyx_r = ((struct __pyx_obj_4lupa_5_lupa__LuaTable *)Py_None); __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("lupa._lupa.new_lua_table");
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_obj);
  __Pyx_XGIVEREF((PyObject *)__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":469
 *     """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.
 */

static PyObject *__pyx_pf_4lupa_5_lupa_12_LuaFunction_coroutine(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_pf_4lupa_5_lupa_12_LuaFunction_coroutine(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_args = 0;
  lua_State *__pyx_v_L;
  lua_State *__pyx_v_co;
  struct __pyx_obj_4lupa_5_lupa__LuaThread *__pyx_v_thread;
  PyObject *__pyx_r = NULL;
  int __pyx_t_1;
  int __pyx_t_2;
  int __pyx_t_3;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  __Pyx_RefNannySetupContext("coroutine");
  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_v_thread = ((struct __pyx_obj_4lupa_5_lupa__LuaThread *)Py_None); __Pyx_INCREF(Py_None);

  /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":473
 *         the passed parameters to start it up.
 *         """
 *         assert self._runtime is not None             # <<<<<<<<<<<<<<
 *         cdef lua_State* L = self._state
 *         cdef lua_State* co
 */
  #ifndef PYREX_WITHOUT_ASSERTIONS
  __pyx_t_1 = (((PyObject *)((struct __pyx_obj_4lupa_5_lupa__LuaFunction *)__pyx_v_self)->__pyx_base._runtime) != Py_None);
  if (unlikely(!__pyx_t_1)) {
    PyErr_SetNone(PyExc_AssertionError);
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 473; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  #endif

  /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":474
 *         """
 *         assert self._runtime is not None
 *         cdef lua_State* L = self._state             # <<<<<<<<<<<<<<
 *         cdef lua_State* co
 *         cdef _LuaThread thread
 */
  __pyx_v_L = ((struct __pyx_obj_4lupa_5_lupa__LuaFunction *)__pyx_v_self)->__pyx_base._state;

  /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":477
 *         cdef lua_State* co
 *         cdef _LuaThread thread
 *         lock_runtime(self._runtime)             # <<<<<<<<<<<<<<
 *         try:
 *             self.push_lua_object()
 */
  __pyx_t_2 = __pyx_f_4lupa_5_lupa_lock_runtime(((struct __pyx_obj_4lupa_5_lupa__LuaFunction *)__pyx_v_self)->__pyx_base._runtime); if (unlikely(__pyx_t_2 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 477; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":478
 *         cdef _LuaThread thread
 *         lock_runtime(self._runtime)
 *         try:             # <<<<<<<<<<<<<<
 *             self.push_lua_object()
 *             if not lua.lua_isfunction(L, -1) or lua.lua_iscfunction(L, -1):
 */
  /*try:*/ {

    /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":479
 *         lock_runtime(self._runtime)
 *         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_2 = ((struct __pyx_vtabstruct_4lupa_5_lupa__LuaFunction *)((struct __pyx_obj_4lupa_5_lupa__LuaFunction *)__pyx_v_self)->__pyx_base.__pyx_vtab)->__pyx_base.push_lua_object(((struct __pyx_obj_4lupa_5_lupa__LuaObject *)__pyx_v_self)); if (unlikely(__pyx_t_2 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 479; __pyx_clineno = __LINE__; goto __pyx_L6;}

    /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":480
 *         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));
    if (!__pyx_t_1) {
      __pyx_t_3 = lua_iscfunction(__pyx_v_L, -1);
    } else {
      __pyx_t_3 = __pyx_t_1;
    }
    if (__pyx_t_3) {

      /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":481
 *             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_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 481; __pyx_clineno = __LINE__; goto __pyx_L6;}
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_INCREF(((PyObject *)__pyx_kp_s_18));
      PyTuple_SET_ITEM(__pyx_t_4, 0, ((PyObject *)__pyx_kp_s_18));
      __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_18));
      __pyx_t_5 = PyObject_Call(__pyx_builtin_TypeError, __pyx_t_4, NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 481; __pyx_clineno = __LINE__; goto __pyx_L6;}
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __Pyx_Raise(__pyx_t_5, 0, 0);
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 481; __pyx_clineno = __LINE__; goto __pyx_L6;}
      goto __pyx_L8;
    }
    __pyx_L8:;

    /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":483
 *                 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);

    /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":484
 *             # 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);

    /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":485
 *             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);

    /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":487
 *             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 PYREX_WITHOUT_ASSERTIONS
    if (unlikely(!lua_isthread(__pyx_v_L, -1))) {
      PyErr_SetNone(PyExc_AssertionError);
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 487; __pyx_clineno = __LINE__; goto __pyx_L6;}
    }
    #endif

    /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":488
 *             # 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_5 = ((PyObject *)__pyx_f_4lupa_5_lupa_new_lua_thread(((struct __pyx_obj_4lupa_5_lupa__LuaFunction *)__pyx_v_self)->__pyx_base._runtime, __pyx_v_L, -1)); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 488; __pyx_clineno = __LINE__; goto __pyx_L6;}
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(((PyObject *)__pyx_v_thread));
    __pyx_v_thread = ((struct __pyx_obj_4lupa_5_lupa__LuaThread *)__pyx_t_5);
    __pyx_t_5 = 0;

    /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":489
 *             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(((PyObject *)__pyx_v_args));
    __Pyx_GIVEREF(((PyObject *)__pyx_v_args));
    __Pyx_GOTREF(__pyx_v_thread->_arguments);
    __Pyx_DECREF(((PyObject *)__pyx_v_thread->_arguments));
    __pyx_v_thread->_arguments = __pyx_v_args;

    /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":490
 *             thread = new_lua_thread(self._runtime, L, -1)
 *             thread._arguments = args # always a tuple, not None !
 *             return thread             # <<<<<<<<<<<<<<
 *         finally:
 *             lua.lua_settop(L, 0)
 */
    __Pyx_XDECREF(__pyx_r);
    __Pyx_INCREF(((PyObject *)__pyx_v_thread));
    __pyx_r = ((PyObject *)__pyx_v_thread);
    goto __pyx_L5;
  }

  /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":492
 *             return thread
 *         finally:
 *             lua.lua_settop(L, 0)             # <<<<<<<<<<<<<<
 *             unlock_runtime(self._runtime)
 * 
 */
  /*finally:*/ {
    int __pyx_why;
    PyObject *__pyx_exc_type, *__pyx_exc_value, *__pyx_exc_tb;
    int __pyx_exc_lineno;
    __pyx_exc_type = 0; __pyx_exc_value = 0; __pyx_exc_tb = 0; __pyx_exc_lineno = 0;
    __pyx_why = 0; goto __pyx_L7;
    __pyx_L5: __pyx_exc_type = 0; __pyx_exc_value = 0; __pyx_exc_tb = 0; __pyx_exc_lineno = 0;
    __pyx_why = 3; goto __pyx_L7;
    __pyx_L6: {
      __pyx_why = 4;
      __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
      __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
      __Pyx_ErrFetch(&__pyx_exc_type, &__pyx_exc_value, &__pyx_exc_tb);
      __pyx_exc_lineno = __pyx_lineno;
      goto __pyx_L7;
    }
    __pyx_L7:;
    lua_settop(__pyx_v_L, 0);

    /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":493
 *         finally:
 *             lua.lua_settop(L, 0)
 *             unlock_runtime(self._runtime)             # <<<<<<<<<<<<<<
 * 
 * cdef _LuaFunction new_lua_function(LuaRuntime runtime, lua_State* L, int n):
 */
    __pyx_f_4lupa_5_lupa_unlock_runtime(((struct __pyx_obj_4lupa_5_lupa__LuaFunction *)__pyx_v_self)->__pyx_base._runtime);
    switch (__pyx_why) {
      case 3: goto __pyx_L0;
      case 4: {
        __Pyx_ErrRestore(__pyx_exc_type, __pyx_exc_value, __pyx_exc_tb);
        __pyx_lineno = __pyx_exc_lineno;
        __pyx_exc_type = 0;
        __pyx_exc_value = 0;
        __pyx_exc_tb = 0;
        goto __pyx_L1_error;
      }
    }
  }

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_AddTraceback("lupa._lupa._LuaFunction.coroutine");
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_DECREF(__pyx_v_args);
  __Pyx_DECREF((PyObject *)__pyx_v_thread);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":495
 *             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;
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("new_lua_function");

  /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":496
 * 
 * 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(((PyObject*)__pyx_ptype_4lupa_5_lupa__LuaFunction)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 496; __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 = 496; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_v_obj = ((struct __pyx_obj_4lupa_5_lupa__LuaFunction *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":497
 * 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);

  /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":498
 *     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;

  __pyx_r = ((struct __pyx_obj_4lupa_5_lupa__LuaFunction *)Py_None); __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("lupa._lupa.new_lua_function");
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_obj);
  __Pyx_XGIVEREF((PyObject *)__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":504
 *     """A function that returns a new coroutine when called.
 *     """
 *     def __call__(self, *args):             # <<<<<<<<<<<<<<
 *         return self.coroutine(*args)
 * 
 */

static PyObject *__pyx_pf_4lupa_5_lupa_21_LuaCoroutineFunction___call__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_pf_4lupa_5_lupa_21_LuaCoroutineFunction___call__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_args = 0;
  PyObject *__pyx_r = NULL;
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  __Pyx_RefNannySetupContext("__call__");
  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;

  /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":505
 *     """
 *     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 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__coroutine); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 505; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PySequence_Tuple(((PyObject *)__pyx_v_args)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 505; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_2));
  __pyx_t_3 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_2), NULL); 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_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
  __pyx_r = __pyx_t_3;
  __pyx_t_3 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("lupa._lupa._LuaCoroutineFunction.__call__");
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_DECREF(__pyx_v_args);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":507
 *         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;
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("new_lua_coroutine_function");

  /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":508
 * 
 * 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(((PyObject*)__pyx_ptype_4lupa_5_lupa__LuaCoroutineFunction)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 508; __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 = 508; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_v_obj = ((struct __pyx_obj_4lupa_5_lupa__LuaCoroutineFunction *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":509
 * 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);

  /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":510
 *     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;

  __pyx_r = ((struct __pyx_obj_4lupa_5_lupa__LuaCoroutineFunction *)Py_None); __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("lupa._lupa.new_lua_coroutine_function");
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_obj);
  __Pyx_XGIVEREF((PyObject *)__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":518
 *     cdef lua_State* _co_state
 *     cdef tuple _arguments
 *     def __iter__(self):             # <<<<<<<<<<<<<<
 *         return self
 * 
 */

static PyObject *__pyx_pf_4lupa_5_lupa_10_LuaThread___iter__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pf_4lupa_5_lupa_10_LuaThread___iter__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannySetupContext("__iter__");

  /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":519
 *     cdef tuple _arguments
 *     def __iter__(self):
 *         return self             # <<<<<<<<<<<<<<
 * 
 *     def __next__(self):
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v_self);
  __pyx_r = __pyx_v_self;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":521
 *         return self
 * 
 *     def __next__(self):             # <<<<<<<<<<<<<<
 *         assert self._runtime is not None
 *         cdef tuple args = self._arguments
 */

static PyObject *__pyx_pf_4lupa_5_lupa_10_LuaThread___next__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pf_4lupa_5_lupa_10_LuaThread___next__(PyObject *__pyx_v_self) {
  PyObject *__pyx_v_args = 0;
  PyObject *__pyx_r = NULL;
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  __Pyx_RefNannySetupContext("__next__");

  /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":522
 * 
 *     def __next__(self):
 *         assert self._runtime is not None             # <<<<<<<<<<<<<<
 *         cdef tuple args = self._arguments
 *         if args is not None:
 */
  #ifndef PYREX_WITHOUT_ASSERTIONS
  __pyx_t_1 = (((PyObject *)((struct __pyx_obj_4lupa_5_lupa__LuaThread *)__pyx_v_self)->__pyx_base._runtime) != Py_None);
  if (unlikely(!__pyx_t_1)) {
    PyErr_SetNone(PyExc_AssertionError);
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 522; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  #endif

  /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":523
 *     def __next__(self):
 *         assert self._runtime is not None
 *         cdef tuple args = self._arguments             # <<<<<<<<<<<<<<
 *         if args is not None:
 *             self._arguments = None
 */
  __Pyx_INCREF(((PyObject *)((struct __pyx_obj_4lupa_5_lupa__LuaThread *)__pyx_v_self)->_arguments));
  __pyx_v_args = ((struct __pyx_obj_4lupa_5_lupa__LuaThread *)__pyx_v_self)->_arguments;

  /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":524
 *         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));
  if (__pyx_t_1) {

    /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":525
 *         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(((struct __pyx_obj_4lupa_5_lupa__LuaThread *)__pyx_v_self)->_arguments);
    __Pyx_DECREF(((PyObject *)((struct __pyx_obj_4lupa_5_lupa__LuaThread *)__pyx_v_self)->_arguments));
    ((struct __pyx_obj_4lupa_5_lupa__LuaThread *)__pyx_v_self)->_arguments = ((PyObject *)Py_None);
    goto __pyx_L5;
  }
  __pyx_L5:;

  /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":526
 *         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(((struct __pyx_obj_4lupa_5_lupa__LuaThread *)__pyx_v_self), __pyx_v_args); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 526; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_r = __pyx_t_2;
  __pyx_t_2 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_AddTraceback("lupa._lupa._LuaThread.__next__");
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_args);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":528
 *         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.
 */

static PyObject *__pyx_pf_4lupa_5_lupa_10_LuaThread_send(PyObject *__pyx_v_self, PyObject *__pyx_v_value); /*proto*/
static char __pyx_doc_4lupa_5_lupa_10_LuaThread_send[] = "_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_pf_4lupa_5_lupa_10_LuaThread_send(PyObject *__pyx_v_self, PyObject *__pyx_v_value) {
  PyObject *__pyx_r = NULL;
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  int __pyx_t_4;
  __Pyx_RefNannySetupContext("send");
  __Pyx_INCREF(__pyx_v_value);

  /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":532
 *         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);
  if (__pyx_t_1) {

    /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":533
 *         """
 *         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_1 = (((struct __pyx_obj_4lupa_5_lupa__LuaThread *)__pyx_v_self)->_arguments != ((PyObject *)Py_None));
    if (__pyx_t_1) {

      /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":534
 *         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_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 534; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_INCREF(((PyObject *)__pyx_kp_s_19));
      PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_kp_s_19));
      __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_19));
      __pyx_t_3 = PyObject_Call(__pyx_builtin_TypeError, __pyx_t_2, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 534; __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);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 534; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      goto __pyx_L6;
    }
    __pyx_L6:;

    /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":535
 *             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_4 = (!__pyx_t_1);
    if (__pyx_t_4) {

      /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":536
 *                 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 = 536; __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(__pyx_v_value);
      __pyx_v_value = __pyx_t_3;
      __pyx_t_3 = 0;
      goto __pyx_L7;
    }
    __pyx_L7:;
    goto __pyx_L5;
  }

  /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":537
 *             if not isinstance(value, tuple):
 *                 value = (value,)
 *         elif self._arguments is not None:             # <<<<<<<<<<<<<<
 *             value = self._arguments
 *             self._arguments = None
 */
  __pyx_t_4 = (((struct __pyx_obj_4lupa_5_lupa__LuaThread *)__pyx_v_self)->_arguments != ((PyObject *)Py_None));
  if (__pyx_t_4) {

    /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":538
 *                 value = (value,)
 *         elif self._arguments is not None:
 *             value = self._arguments             # <<<<<<<<<<<<<<
 *             self._arguments = None
 *         return resume_lua_thread(self, <tuple>value)
 */
    __Pyx_INCREF(((PyObject *)((struct __pyx_obj_4lupa_5_lupa__LuaThread *)__pyx_v_self)->_arguments));
    __Pyx_DECREF(__pyx_v_value);
    __pyx_v_value = ((PyObject *)((struct __pyx_obj_4lupa_5_lupa__LuaThread *)__pyx_v_self)->_arguments);

    /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":539
 *         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(((struct __pyx_obj_4lupa_5_lupa__LuaThread *)__pyx_v_self)->_arguments);
    __Pyx_DECREF(((PyObject *)((struct __pyx_obj_4lupa_5_lupa__LuaThread *)__pyx_v_self)->_arguments));
    ((struct __pyx_obj_4lupa_5_lupa__LuaThread *)__pyx_v_self)->_arguments = ((PyObject *)Py_None);
    goto __pyx_L5;
  }
  __pyx_L5:;

  /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":540
 *             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(((struct __pyx_obj_4lupa_5_lupa__LuaThread *)__pyx_v_self), ((PyObject *)__pyx_v_value)); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 540; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_r = __pyx_t_3;
  __pyx_t_3 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("lupa._lupa._LuaThread.send");
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_DECREF(__pyx_v_value);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":542
 *         return resume_lua_thread(self, <tuple>value)
 * 
 *     def __bool__(self):             # <<<<<<<<<<<<<<
 *         cdef lua.lua_Debug dummy
 *         assert self._runtime is not None
 */

static int __pyx_pf_4lupa_5_lupa_10_LuaThread___bool__(PyObject *__pyx_v_self); /*proto*/
static int __pyx_pf_4lupa_5_lupa_10_LuaThread___bool__(PyObject *__pyx_v_self) {
  lua_Debug __pyx_v_dummy;
  int __pyx_v_status;
  int __pyx_r;
  int __pyx_t_1;
  __Pyx_RefNannySetupContext("__bool__");

  /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":544
 *     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 PYREX_WITHOUT_ASSERTIONS
  __pyx_t_1 = (((PyObject *)((struct __pyx_obj_4lupa_5_lupa__LuaThread *)__pyx_v_self)->__pyx_base._runtime) != Py_None);
  if (unlikely(!__pyx_t_1)) {
    PyErr_SetNone(PyExc_AssertionError);
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 544; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  #endif

  /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":545
 *         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(((struct __pyx_obj_4lupa_5_lupa__LuaThread *)__pyx_v_self)->_co_state);

  /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":546
 *         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);
  if (__pyx_t_1) {

    /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":547
 *         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;
    goto __pyx_L5;
  }
  __pyx_L5:;

  /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":548
 *         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);
  if (__pyx_t_1) {

    /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":550
 *         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(((struct __pyx_obj_4lupa_5_lupa__LuaThread *)__pyx_v_self)->_co_state, 0, (&__pyx_v_dummy)) > 0);
    if (__pyx_t_1) {

      /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":551
 *             # 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;
      goto __pyx_L7;
    }

    /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":552
 *             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(((struct __pyx_obj_4lupa_5_lupa__LuaThread *)__pyx_v_self)->_co_state) > 0);
    if (__pyx_t_1) {

      /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":553
 *                 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_L7;
    }
    __pyx_L7:;
    goto __pyx_L6;
  }
  __pyx_L6:;

  /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":554
 *             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;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_AddTraceback("lupa._lupa._LuaThread.__bool__");
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":556
 *         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;
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("new_lua_thread");

  /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":557
 * 
 * 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(((PyObject*)__pyx_ptype_4lupa_5_lupa__LuaThread)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 557; __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 = 557; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_v_obj = ((struct __pyx_obj_4lupa_5_lupa__LuaThread *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":558
 * 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);

  /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":559
 *     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);

  /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":560
 *     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;

  __pyx_r = ((struct __pyx_obj_4lupa_5_lupa__LuaThread *)Py_None); __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("lupa._lupa.new_lua_thread");
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_obj);
  __Pyx_XGIVEREF((PyObject *)__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":563
 * 
 * 
 * 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;
  int __pyx_t_1;
  int __pyx_t_2;
  int __pyx_t_3;
  PyObject *__pyx_t_4 = NULL;
  __Pyx_RefNannySetupContext("new_lua_thread_or_function");

  /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":567
 *     # 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);

  /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":568
 *     # 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 PYREX_WITHOUT_ASSERTIONS
  if (unlikely(!(__pyx_v_co != NULL))) {
    PyErr_SetNone(PyExc_AssertionError);
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 568; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  #endif

  /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":569
 *     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);
  if (__pyx_t_1) {
    __pyx_t_2 = (lua_gettop(__pyx_v_co) == 1);
    __pyx_t_3 = __pyx_t_2;
  } else {
    __pyx_t_3 = __pyx_t_1;
  }
  if (__pyx_t_3) {

    /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":571
 *     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);

    /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":572
 *         # 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);

    /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":573
 *         lua.lua_pushvalue(co, 1)
 *         lua.lua_xmove(co, L, 1)
 *         try:             # <<<<<<<<<<<<<<
 *             return new_lua_coroutine_function(runtime, L, -1)
 *         finally:
 */
    /*try:*/ {

      /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":574
 *         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 = 574; __pyx_clineno = __LINE__; goto __pyx_L5;}
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_r = ((struct __pyx_obj_4lupa_5_lupa__LuaObject *)__pyx_t_4);
      __pyx_t_4 = 0;
      goto __pyx_L4;
    }

    /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":576
 *             return new_lua_coroutine_function(runtime, L, -1)
 *         finally:
 *             lua.lua_pop(L, 1)             # <<<<<<<<<<<<<<
 *     else:
 *         # already started => wrap the thread
 */
    /*finally:*/ {
      int __pyx_why;
      PyObject *__pyx_exc_type, *__pyx_exc_value, *__pyx_exc_tb;
      int __pyx_exc_lineno;
      __pyx_exc_type = 0; __pyx_exc_value = 0; __pyx_exc_tb = 0; __pyx_exc_lineno = 0;
      __pyx_why = 0; goto __pyx_L6;
      __pyx_L4: __pyx_exc_type = 0; __pyx_exc_value = 0; __pyx_exc_tb = 0; __pyx_exc_lineno = 0;
      __pyx_why = 3; goto __pyx_L6;
      __pyx_L5: {
        __pyx_why = 4;
        __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
        __Pyx_ErrFetch(&__pyx_exc_type, &__pyx_exc_value, &__pyx_exc_tb);
        __pyx_exc_lineno = __pyx_lineno;
        goto __pyx_L6;
      }
      __pyx_L6:;
      lua_pop(__pyx_v_L, 1);
      switch (__pyx_why) {
        case 3: goto __pyx_L0;
        case 4: {
          __Pyx_ErrRestore(__pyx_exc_type, __pyx_exc_value, __pyx_exc_tb);
          __pyx_lineno = __pyx_exc_lineno;
          __pyx_exc_type = 0;
          __pyx_exc_value = 0;
          __pyx_exc_tb = 0;
          goto __pyx_L1_error;
        }
      }
    }
    goto __pyx_L3;
  }
  /*else*/ {

    /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":579
 *     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 = 579; __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;
  }
  __pyx_L3:;

  __pyx_r = ((struct __pyx_obj_4lupa_5_lupa__LuaObject *)Py_None); __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_AddTraceback("lupa._lupa.new_lua_thread_or_function");
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XGIVEREF((PyObject *)__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":582
 * 
 * 
 * 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;
  int __pyx_t_1;
  int __pyx_t_2;
  int __pyx_t_3;
  int __pyx_t_4;
  Py_ssize_t __pyx_t_5;
  PyObject *__pyx_t_6 = NULL;
  __Pyx_RefNannySetupContext("resume_lua_thread");

  /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":583
 * 
 * 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_v_co = __pyx_v_thread->_co_state;

  /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":584
 * 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;

  /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":585
 *     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_1 = __pyx_f_4lupa_5_lupa_lock_runtime(__pyx_v_thread->__pyx_base._runtime); if (unlikely(__pyx_t_1 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 585; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":586
 *     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:*/ {

    /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":587
 *     lock_runtime(thread._runtime)
 *     try:
 *         if lua.lua_status(co) == 0 and lua.lua_gettop(co) == 0:             # <<<<<<<<<<<<<<
 *             # already terminated
 *             raise StopIteration
 */
    __pyx_t_2 = (lua_status(__pyx_v_co) == 0);
    if (__pyx_t_2) {
      __pyx_t_3 = (lua_gettop(__pyx_v_co) == 0);
      __pyx_t_4 = __pyx_t_3;
    } else {
      __pyx_t_4 = __pyx_t_2;
    }
    if (__pyx_t_4) {

      /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":589
 *         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);
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 589; __pyx_clineno = __LINE__; goto __pyx_L4;}
      goto __pyx_L6;
    }
    __pyx_L6:;

    /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":590
 *             # already terminated
 *             raise StopIteration
 *         if args:             # <<<<<<<<<<<<<<
 *             nargs = len(args)
 *             push_lua_arguments(thread._runtime, co, args, 0)
 */
    __pyx_t_4 = (((PyObject *)__pyx_v_args) != Py_None) && (PyTuple_GET_SIZE(((PyObject *)__pyx_v_args)) != 0);
    if (__pyx_t_4) {

      /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":591
 *             raise StopIteration
 *         if args:
 *             nargs = len(args)             # <<<<<<<<<<<<<<
 *             push_lua_arguments(thread._runtime, co, args, 0)
 *         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 = 591; __pyx_clineno = __LINE__; goto __pyx_L4;} 
      }
      __pyx_t_5 = PyTuple_GET_SIZE(((PyObject *)__pyx_v_args)); 
      __pyx_v_nargs = __pyx_t_5;

      /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":592
 *         if args:
 *             nargs = len(args)
 *             push_lua_arguments(thread._runtime, co, args, 0)             # <<<<<<<<<<<<<<
 *         with nogil:
 *             result = lua.lua_resume(co, nargs)
 */
      __pyx_t_1 = __pyx_f_4lupa_5_lupa_push_lua_arguments(__pyx_v_thread->__pyx_base._runtime, __pyx_v_co, __pyx_v_args, 0); if (unlikely(__pyx_t_1 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 592; __pyx_clineno = __LINE__; goto __pyx_L4;}
      goto __pyx_L7;
    }
    __pyx_L7:;

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

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

      /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":593
 *             nargs = len(args)
 *             push_lua_arguments(thread._runtime, co, args, 0)
 *         with nogil:             # <<<<<<<<<<<<<<
 *             result = lua.lua_resume(co, nargs)
 *         if result != lua.LUA_YIELD:
 */
      /*finally:*/ {
        Py_BLOCK_THREADS
      }
    }

    /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":595
 *         with nogil:
 *             result = lua.lua_resume(co, nargs)
 *         if result != lua.LUA_YIELD:             # <<<<<<<<<<<<<<
 *             if result == 0:
 *                 # terminated
 */
    __pyx_t_4 = (__pyx_v_result != LUA_YIELD);
    if (__pyx_t_4) {

      /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":596
 *             result = lua.lua_resume(co, nargs)
 *         if result != lua.LUA_YIELD:
 *             if result == 0:             # <<<<<<<<<<<<<<
 *                 # terminated
 *                 if lua.lua_gettop(co) == 0:
 */
      __pyx_t_4 = (__pyx_v_result == 0);
      if (__pyx_t_4) {

        /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":598
 *             if result == 0:
 *                 # terminated
 *                 if lua.lua_gettop(co) == 0:             # <<<<<<<<<<<<<<
 *                     # no values left to return
 *                     raise StopIteration
 */
        __pyx_t_4 = (lua_gettop(__pyx_v_co) == 0);
        if (__pyx_t_4) {

          /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":600
 *                 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);
          {__pyx_filename = __pyx_f[0]; __pyx_lineno = 600; __pyx_clineno = __LINE__; goto __pyx_L4;}
          goto __pyx_L13;
        }
        __pyx_L13:;
        goto __pyx_L12;
      }
      /*else*/ {

        /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":602
 *                     raise StopIteration
 *             else:
 *                 raise_lua_error(thread._runtime, co, result)             # <<<<<<<<<<<<<<
 *         return unpack_lua_results(thread._runtime, co)
 *     finally:
 */
        __pyx_t_1 = __pyx_f_4lupa_5_lupa_raise_lua_error(__pyx_v_thread->__pyx_base._runtime, __pyx_v_co, __pyx_v_result); if (unlikely(__pyx_t_1 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 602; __pyx_clineno = __LINE__; goto __pyx_L4;}
      }
      __pyx_L12:;
      goto __pyx_L11;
    }
    __pyx_L11:;

    /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":603
 *             else:
 *                 raise_lua_error(thread._runtime, co, result)
 *         return unpack_lua_results(thread._runtime, co)             # <<<<<<<<<<<<<<
 *     finally:
 *         lua.lua_settop(co, 0)
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_6 = __pyx_f_4lupa_5_lupa_unpack_lua_results(__pyx_v_thread->__pyx_base._runtime, __pyx_v_co); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 603; __pyx_clineno = __LINE__; goto __pyx_L4;}
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_r = __pyx_t_6;
    __pyx_t_6 = 0;
    goto __pyx_L3;
  }

  /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":605
 *         return unpack_lua_results(thread._runtime, co)
 *     finally:
 *         lua.lua_settop(co, 0)             # <<<<<<<<<<<<<<
 *         unlock_runtime(thread._runtime)
 * 
 */
  /*finally:*/ {
    int __pyx_why;
    PyObject *__pyx_exc_type, *__pyx_exc_value, *__pyx_exc_tb;
    int __pyx_exc_lineno;
    __pyx_exc_type = 0; __pyx_exc_value = 0; __pyx_exc_tb = 0; __pyx_exc_lineno = 0;
    __pyx_why = 0; goto __pyx_L5;
    __pyx_L3: __pyx_exc_type = 0; __pyx_exc_value = 0; __pyx_exc_tb = 0; __pyx_exc_lineno = 0;
    __pyx_why = 3; goto __pyx_L5;
    __pyx_L4: {
      __pyx_why = 4;
      __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
      __Pyx_ErrFetch(&__pyx_exc_type, &__pyx_exc_value, &__pyx_exc_tb);
      __pyx_exc_lineno = __pyx_lineno;
      goto __pyx_L5;
    }
    __pyx_L5:;
    lua_settop(__pyx_v_co, 0);

    /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":606
 *     finally:
 *         lua.lua_settop(co, 0)
 *         unlock_runtime(thread._runtime)             # <<<<<<<<<<<<<<
 * 
 * 
 */
    __pyx_f_4lupa_5_lupa_unlock_runtime(__pyx_v_thread->__pyx_base._runtime);
    switch (__pyx_why) {
      case 3: goto __pyx_L0;
      case 4: {
        __Pyx_ErrRestore(__pyx_exc_type, __pyx_exc_value, __pyx_exc_tb);
        __pyx_lineno = __pyx_exc_lineno;
        __pyx_exc_type = 0;
        __pyx_exc_value = 0;
        __pyx_exc_tb = 0;
        goto __pyx_L1_error;
      }
    }
  }

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_AddTraceback("lupa._lupa.resume_lua_thread");
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":621
 *     cdef char _what
 * 
 *     def __cinit__(self, _LuaObject obj not None, int what):             # <<<<<<<<<<<<<<
 *         assert obj._runtime is not None
 *         self._runtime = obj._runtime
 */

static int __pyx_pf_4lupa_5_lupa_8_LuaIter___cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static int __pyx_pf_4lupa_5_lupa_8_LuaIter___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_r;
  int __pyx_t_1;
  static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__obj,&__pyx_n_s__what,0};
  __Pyx_RefNannySetupContext("__cinit__");
  if (unlikely(__pyx_kwds)) {
    Py_ssize_t kw_args = PyDict_Size(__pyx_kwds);
    PyObject* values[2] = {0,0};
    switch (PyTuple_GET_SIZE(__pyx_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;
    }
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  0:
      values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__obj);
      if (likely(values[0])) kw_args--;
      else goto __pyx_L5_argtuple_error;
      case  1:
      values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__what);
      if (likely(values[1])) kw_args--;
      else {
        __Pyx_RaiseArgtupleInvalid("__cinit__", 1, 2, 2, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 621; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    }
    if (unlikely(kw_args > 0)) {
      if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "__cinit__") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 621; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    }
    __pyx_v_obj = ((struct __pyx_obj_4lupa_5_lupa__LuaObject *)values[0]);
    __pyx_v_what = __Pyx_PyInt_AsInt(values[1]); if (unlikely((__pyx_v_what == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 621; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  } else if (PyTuple_GET_SIZE(__pyx_args) != 2) {
    goto __pyx_L5_argtuple_error;
  } else {
    __pyx_v_obj = ((struct __pyx_obj_4lupa_5_lupa__LuaObject *)PyTuple_GET_ITEM(__pyx_args, 0));
    __pyx_v_what = __Pyx_PyInt_AsInt(PyTuple_GET_ITEM(__pyx_args, 1)); if (unlikely((__pyx_v_what == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 621; __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 = 621; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("lupa._lupa._LuaIter.__cinit__");
  __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 = 621; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":622
 * 
 *     def __cinit__(self, _LuaObject obj not None, int what):
 *         assert obj._runtime is not None             # <<<<<<<<<<<<<<
 *         self._runtime = obj._runtime
 *         # additional INCREF to keep object from disappearing in GC runs
 */
  #ifndef PYREX_WITHOUT_ASSERTIONS
  __pyx_t_1 = (((PyObject *)__pyx_v_obj->_runtime) != Py_None);
  if (unlikely(!__pyx_t_1)) {
    PyErr_SetNone(PyExc_AssertionError);
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 622; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  #endif

  /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":623
 *     def __cinit__(self, _LuaObject obj not None, int what):
 *         assert obj._runtime is not None
 *         self._runtime = obj._runtime             # <<<<<<<<<<<<<<
 *         # additional INCREF to keep object from disappearing in GC runs
 *         cpython.ref.Py_INCREF(obj)
 */
  __Pyx_INCREF(((PyObject *)__pyx_v_obj->_runtime));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_obj->_runtime));
  __Pyx_GOTREF(((struct __pyx_obj_4lupa_5_lupa__LuaIter *)__pyx_v_self)->_runtime);
  __Pyx_DECREF(((PyObject *)((struct __pyx_obj_4lupa_5_lupa__LuaIter *)__pyx_v_self)->_runtime));
  ((struct __pyx_obj_4lupa_5_lupa__LuaIter *)__pyx_v_self)->_runtime = __pyx_v_obj->_runtime;

  /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":625
 *         self._runtime = obj._runtime
 *         # additional INCREF to keep object from disappearing in GC runs
 *         cpython.ref.Py_INCREF(obj)             # <<<<<<<<<<<<<<
 * 
 *         self._obj = obj
 */
  Py_INCREF(((PyObject *)__pyx_v_obj));

  /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":627
 *         cpython.ref.Py_INCREF(obj)
 * 
 *         self._obj = obj             # <<<<<<<<<<<<<<
 *         self._state = obj._state
 *         self._refiter = 0
 */
  __Pyx_INCREF(((PyObject *)__pyx_v_obj));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_obj));
  __Pyx_GOTREF(((struct __pyx_obj_4lupa_5_lupa__LuaIter *)__pyx_v_self)->_obj);
  __Pyx_DECREF(((PyObject *)((struct __pyx_obj_4lupa_5_lupa__LuaIter *)__pyx_v_self)->_obj));
  ((struct __pyx_obj_4lupa_5_lupa__LuaIter *)__pyx_v_self)->_obj = __pyx_v_obj;

  /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":628
 * 
 *         self._obj = obj
 *         self._state = obj._state             # <<<<<<<<<<<<<<
 *         self._refiter = 0
 *         self._what = what
 */
  ((struct __pyx_obj_4lupa_5_lupa__LuaIter *)__pyx_v_self)->_state = __pyx_v_obj->_state;

  /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":629
 *         self._obj = obj
 *         self._state = obj._state
 *         self._refiter = 0             # <<<<<<<<<<<<<<
 *         self._what = what
 * 
 */
  ((struct __pyx_obj_4lupa_5_lupa__LuaIter *)__pyx_v_self)->_refiter = 0;

  /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":630
 *         self._state = obj._state
 *         self._refiter = 0
 *         self._what = what             # <<<<<<<<<<<<<<
 * 
 *     def __dealloc__(self):
 */
  ((struct __pyx_obj_4lupa_5_lupa__LuaIter *)__pyx_v_self)->_what = __pyx_v_what;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_AddTraceback("lupa._lupa._LuaIter.__cinit__");
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":632
 *         self._what = what
 * 
 *     def __dealloc__(self):             # <<<<<<<<<<<<<<
 *         if self._runtime is None:
 *             return
 */

static void __pyx_pf_4lupa_5_lupa_8_LuaIter___dealloc__(PyObject *__pyx_v_self); /*proto*/
static void __pyx_pf_4lupa_5_lupa_8_LuaIter___dealloc__(PyObject *__pyx_v_self) {
  lua_State *__pyx_v_L;
  int __pyx_v_locked;
  int __pyx_t_1;
  int __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  __Pyx_RefNannySetupContext("__dealloc__");

  /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":633
 * 
 *     def __dealloc__(self):
 *         if self._runtime is None:             # <<<<<<<<<<<<<<
 *             return
 *         cdef lua_State* L = self._state
 */
  __pyx_t_1 = (((PyObject *)((struct __pyx_obj_4lupa_5_lupa__LuaIter *)__pyx_v_self)->_runtime) == Py_None);
  if (__pyx_t_1) {

    /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":634
 *     def __dealloc__(self):
 *         if self._runtime is None:
 *             return             # <<<<<<<<<<<<<<
 *         cdef lua_State* L = self._state
 *         if self._refiter:
 */
    goto __pyx_L0;
    goto __pyx_L5;
  }
  __pyx_L5:;

  /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":635
 *         if self._runtime is None:
 *             return
 *         cdef lua_State* L = self._state             # <<<<<<<<<<<<<<
 *         if self._refiter:
 *             try:
 */
  __pyx_v_L = ((struct __pyx_obj_4lupa_5_lupa__LuaIter *)__pyx_v_self)->_state;

  /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":636
 *             return
 *         cdef lua_State* L = self._state
 *         if self._refiter:             # <<<<<<<<<<<<<<
 *             try:
 *                 lock_runtime(self._runtime)
 */
  if (((struct __pyx_obj_4lupa_5_lupa__LuaIter *)__pyx_v_self)->_refiter) {

    /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":637
 *         cdef lua_State* L = self._state
 *         if self._refiter:
 *             try:             # <<<<<<<<<<<<<<
 *                 lock_runtime(self._runtime)
 *                 locked = True
 */
    {
      PyObject *__pyx_save_exc_type, *__pyx_save_exc_value, *__pyx_save_exc_tb;
      __Pyx_ExceptionSave(&__pyx_save_exc_type, &__pyx_save_exc_value, &__pyx_save_exc_tb);
      __Pyx_XGOTREF(__pyx_save_exc_type);
      __Pyx_XGOTREF(__pyx_save_exc_value);
      __Pyx_XGOTREF(__pyx_save_exc_tb);
      /*try:*/ {

        /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":638
 *         if self._refiter:
 *             try:
 *                 lock_runtime(self._runtime)             # <<<<<<<<<<<<<<
 *                 locked = True
 *             except:
 */
        __pyx_t_2 = __pyx_f_4lupa_5_lupa_lock_runtime(((struct __pyx_obj_4lupa_5_lupa__LuaIter *)__pyx_v_self)->_runtime); if (unlikely(__pyx_t_2 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 638; __pyx_clineno = __LINE__; goto __pyx_L7_error;}

        /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":639
 *             try:
 *                 lock_runtime(self._runtime)
 *                 locked = True             # <<<<<<<<<<<<<<
 *             except:
 *                 locked = False
 */
        __pyx_v_locked = 1;
      }
      __Pyx_XDECREF(__pyx_save_exc_type); __pyx_save_exc_type = 0;
      __Pyx_XDECREF(__pyx_save_exc_value); __pyx_save_exc_value = 0;
      __Pyx_XDECREF(__pyx_save_exc_tb); __pyx_save_exc_tb = 0;
      goto __pyx_L14_try_end;
      __pyx_L7_error:;

      /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":640
 *                 lock_runtime(self._runtime)
 *                 locked = True
 *             except:             # <<<<<<<<<<<<<<
 *                 locked = False
 *             lua.luaL_unref(L, lua.LUA_REGISTRYINDEX, self._refiter)
 */
      /*except:*/ {
        __Pyx_AddTraceback("lupa._lupa._LuaIter.__dealloc__");
        if (__Pyx_GetException(&__pyx_t_3, &__pyx_t_4, &__pyx_t_5) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 640; __pyx_clineno = __LINE__; goto __pyx_L9_except_error;}
        __Pyx_GOTREF(__pyx_t_3);
        __Pyx_GOTREF(__pyx_t_4);
        __Pyx_GOTREF(__pyx_t_5);

        /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":641
 *                 locked = True
 *             except:
 *                 locked = False             # <<<<<<<<<<<<<<
 *             lua.luaL_unref(L, lua.LUA_REGISTRYINDEX, self._refiter)
 *             if locked:
 */
        __pyx_v_locked = 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;
        goto __pyx_L8_exception_handled;
      }
      __pyx_L9_except_error:;
      __Pyx_XGIVEREF(__pyx_save_exc_type);
      __Pyx_XGIVEREF(__pyx_save_exc_value);
      __Pyx_XGIVEREF(__pyx_save_exc_tb);
      __Pyx_ExceptionReset(__pyx_save_exc_type, __pyx_save_exc_value, __pyx_save_exc_tb);
      goto __pyx_L1_error;
      __pyx_L8_exception_handled:;
      __Pyx_XGIVEREF(__pyx_save_exc_type);
      __Pyx_XGIVEREF(__pyx_save_exc_value);
      __Pyx_XGIVEREF(__pyx_save_exc_tb);
      __Pyx_ExceptionReset(__pyx_save_exc_type, __pyx_save_exc_value, __pyx_save_exc_tb);
      __pyx_L14_try_end:;
    }

    /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":642
 *             except:
 *                 locked = False
 *             lua.luaL_unref(L, lua.LUA_REGISTRYINDEX, self._refiter)             # <<<<<<<<<<<<<<
 *             if locked:
 *                 unlock_runtime(self._runtime)
 */
    luaL_unref(__pyx_v_L, LUA_REGISTRYINDEX, ((struct __pyx_obj_4lupa_5_lupa__LuaIter *)__pyx_v_self)->_refiter);

    /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":643
 *                 locked = False
 *             lua.luaL_unref(L, lua.LUA_REGISTRYINDEX, self._refiter)
 *             if locked:             # <<<<<<<<<<<<<<
 *                 unlock_runtime(self._runtime)
 *         # undo additional INCREF at instantiation time
 */
    if (__pyx_v_locked) {

      /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":644
 *             lua.luaL_unref(L, lua.LUA_REGISTRYINDEX, self._refiter)
 *             if locked:
 *                 unlock_runtime(self._runtime)             # <<<<<<<<<<<<<<
 *         # undo additional INCREF at instantiation time
 *         cpython.ref.Py_DECREF(self._obj)
 */
      __pyx_f_4lupa_5_lupa_unlock_runtime(((struct __pyx_obj_4lupa_5_lupa__LuaIter *)__pyx_v_self)->_runtime);
      goto __pyx_L17;
    }
    __pyx_L17:;
    goto __pyx_L6;
  }
  __pyx_L6:;

  /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":646
 *                 unlock_runtime(self._runtime)
 *         # undo additional INCREF at instantiation time
 *         cpython.ref.Py_DECREF(self._obj)             # <<<<<<<<<<<<<<
 * 
 *     def __repr__(self):
 */
  Py_DECREF(((PyObject *)((struct __pyx_obj_4lupa_5_lupa__LuaIter *)__pyx_v_self)->_obj));

  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_AddTraceback("lupa._lupa._LuaIter.__dealloc__");
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
}

/* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":648
 *         cpython.ref.Py_DECREF(self._obj)
 * 
 *     def __repr__(self):             # <<<<<<<<<<<<<<
 *         return u"LuaIter(%r)" % (self._obj)
 * 
 */

static PyObject *__pyx_pf_4lupa_5_lupa_8_LuaIter___repr__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pf_4lupa_5_lupa_8_LuaIter___repr__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("__repr__");

  /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":649
 * 
 *     def __repr__(self):
 *         return u"LuaIter(%r)" % (self._obj)             # <<<<<<<<<<<<<<
 * 
 *     def __iter__(self):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = PyNumber_Remainder(((PyObject *)__pyx_kp_u_20), ((PyObject *)((struct __pyx_obj_4lupa_5_lupa__LuaIter *)__pyx_v_self)->_obj)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 649; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_1));
  __pyx_r = ((PyObject *)__pyx_t_1);
  __pyx_t_1 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("lupa._lupa._LuaIter.__repr__");
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":651
 *         return u"LuaIter(%r)" % (self._obj)
 * 
 *     def __iter__(self):             # <<<<<<<<<<<<<<
 *         return self
 * 
 */

static PyObject *__pyx_pf_4lupa_5_lupa_8_LuaIter___iter__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pf_4lupa_5_lupa_8_LuaIter___iter__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannySetupContext("__iter__");

  /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":652
 * 
 *     def __iter__(self):
 *         return self             # <<<<<<<<<<<<<<
 * 
 *     def __next__(self):
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v_self);
  __pyx_r = __pyx_v_self;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":654
 *         return self
 * 
 *     def __next__(self):             # <<<<<<<<<<<<<<
 *         if self._obj is None:
 *             raise StopIteration
 */

static PyObject *__pyx_pf_4lupa_5_lupa_8_LuaIter___next__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pf_4lupa_5_lupa_8_LuaIter___next__(PyObject *__pyx_v_self) {
  lua_State *__pyx_v_L;
  PyObject *__pyx_v_retval;
  PyObject *__pyx_r = NULL;
  int __pyx_t_1;
  int __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  __Pyx_RefNannySetupContext("__next__");
  __pyx_v_retval = Py_None; __Pyx_INCREF(Py_None);

  /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":655
 * 
 *     def __next__(self):
 *         if self._obj is None:             # <<<<<<<<<<<<<<
 *             raise StopIteration
 *         cdef lua_State* L = self._obj._state
 */
  __pyx_t_1 = (((PyObject *)((struct __pyx_obj_4lupa_5_lupa__LuaIter *)__pyx_v_self)->_obj) == Py_None);
  if (__pyx_t_1) {

    /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":656
 *     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);
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 656; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    goto __pyx_L5;
  }
  __pyx_L5:;

  /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":657
 *         if self._obj is None:
 *             raise StopIteration
 *         cdef lua_State* L = self._obj._state             # <<<<<<<<<<<<<<
 *         lock_runtime(self._runtime)
 *         try:
 */
  __pyx_v_L = ((struct __pyx_obj_4lupa_5_lupa__LuaIter *)__pyx_v_self)->_obj->_state;

  /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":658
 *             raise StopIteration
 *         cdef lua_State* L = self._obj._state
 *         lock_runtime(self._runtime)             # <<<<<<<<<<<<<<
 *         try:
 *             if self._obj is None:
 */
  __pyx_t_2 = __pyx_f_4lupa_5_lupa_lock_runtime(((struct __pyx_obj_4lupa_5_lupa__LuaIter *)__pyx_v_self)->_runtime); if (unlikely(__pyx_t_2 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 658; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":659
 *         cdef lua_State* L = self._obj._state
 *         lock_runtime(self._runtime)
 *         try:             # <<<<<<<<<<<<<<
 *             if self._obj is None:
 *                 raise StopIteration
 */
  /*try:*/ {

    /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":660
 *         lock_runtime(self._runtime)
 *         try:
 *             if self._obj is None:             # <<<<<<<<<<<<<<
 *                 raise StopIteration
 *             # iterable object
 */
    __pyx_t_1 = (((PyObject *)((struct __pyx_obj_4lupa_5_lupa__LuaIter *)__pyx_v_self)->_obj) == Py_None);
    if (__pyx_t_1) {

      /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":661
 *         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);
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 661; __pyx_clineno = __LINE__; goto __pyx_L7;}
      goto __pyx_L9;
    }
    __pyx_L9:;

    /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":663
 *                 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, ((struct __pyx_obj_4lupa_5_lupa__LuaIter *)__pyx_v_self)->_obj->_ref);

    /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":664
 *             # 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));
    if (__pyx_t_1) {

      /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":665
 *             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);
      if (__pyx_t_1) {

        /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":666
 *             if not lua.lua_istable(L, -1):
 *                 if lua.lua_isnil(L, -1):
 *                     lua.lua_pop(L, 1)             # <<<<<<<<<<<<<<
 *                     raise LuaError("lost reference")
 *                 raise TypeError(cpython.bytes.PyBytes_FromFormat(
 */
        lua_pop(__pyx_v_L, 1);

        /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":667
 *                 if lua.lua_isnil(L, -1):
 *                     lua.lua_pop(L, 1)
 *                     raise LuaError("lost reference")             # <<<<<<<<<<<<<<
 *                 raise TypeError(cpython.bytes.PyBytes_FromFormat(
 *                     "cannot iterate over non-table (found Lua %s)",
 */
        __pyx_t_3 = __Pyx_GetName(__pyx_m, __pyx_n_s__LuaError); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 667; __pyx_clineno = __LINE__; goto __pyx_L7;}
        __Pyx_GOTREF(__pyx_t_3);
        __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 667; __pyx_clineno = __LINE__; goto __pyx_L7;}
        __Pyx_GOTREF(__pyx_t_4);
        __Pyx_INCREF(((PyObject *)__pyx_kp_s_11));
        PyTuple_SET_ITEM(__pyx_t_4, 0, ((PyObject *)__pyx_kp_s_11));
        __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_11));
        __pyx_t_5 = PyObject_Call(__pyx_t_3, __pyx_t_4, NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 667; __pyx_clineno = __LINE__; goto __pyx_L7;}
        __Pyx_GOTREF(__pyx_t_5);
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
        __Pyx_Raise(__pyx_t_5, 0, 0);
        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
        {__pyx_filename = __pyx_f[0]; __pyx_lineno = 667; __pyx_clineno = __LINE__; goto __pyx_L7;}
        goto __pyx_L11;
      }
      __pyx_L11:;

      /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":670
 *                 raise TypeError(cpython.bytes.PyBytes_FromFormat(
 *                     "cannot iterate over non-table (found Lua %s)",
 *                     lua.lua_typename(L, lua.lua_type(L, -1))))             # <<<<<<<<<<<<<<
 *             if not self._refiter:
 *                 # initial key
 */
      __pyx_t_5 = ((PyObject *)PyBytes_FromFormat(__pyx_k_21, lua_typename(__pyx_v_L, lua_type(__pyx_v_L, -1)))); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 668; __pyx_clineno = __LINE__; goto __pyx_L7;}
      __Pyx_GOTREF(__pyx_t_5);
      __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 668; __pyx_clineno = __LINE__; goto __pyx_L7;}
      __Pyx_GOTREF(__pyx_t_4);
      PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_5);
      __Pyx_GIVEREF(__pyx_t_5);
      __pyx_t_5 = 0;
      __pyx_t_5 = PyObject_Call(__pyx_builtin_TypeError, __pyx_t_4, NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 668; __pyx_clineno = __LINE__; goto __pyx_L7;}
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __Pyx_Raise(__pyx_t_5, 0, 0);
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 668; __pyx_clineno = __LINE__; goto __pyx_L7;}
      goto __pyx_L10;
    }
    __pyx_L10:;

    /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":671
 *                     "cannot iterate over non-table (found Lua %s)",
 *                     lua.lua_typename(L, lua.lua_type(L, -1))))
 *             if not self._refiter:             # <<<<<<<<<<<<<<
 *                 # initial key
 *                 lua.lua_pushnil(L)
 */
    __pyx_t_1 = (!((struct __pyx_obj_4lupa_5_lupa__LuaIter *)__pyx_v_self)->_refiter);
    if (__pyx_t_1) {

      /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":673
 *             if not self._refiter:
 *                 # initial key
 *                 lua.lua_pushnil(L)             # <<<<<<<<<<<<<<
 *             else:
 *                 # last key
 */
      lua_pushnil(__pyx_v_L);
      goto __pyx_L12;
    }
    /*else*/ {

      /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":676
 *             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, ((struct __pyx_obj_4lupa_5_lupa__LuaIter *)__pyx_v_self)->_refiter);
    }
    __pyx_L12:;

    /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":677
 *                 # last key
 *                 lua.lua_rawgeti(L, lua.LUA_REGISTRYINDEX, self._refiter)
 *             if lua.lua_next(L, -2):             # <<<<<<<<<<<<<<
 *                 try:
 *                     if self._what == KEYS:
 */
    __pyx_t_2 = lua_next(__pyx_v_L, -2);
    if (__pyx_t_2) {

      /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":678
 *                 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:*/ {

        /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":679
 *             if lua.lua_next(L, -2):
 *                 try:
 *                     if self._what == KEYS:             # <<<<<<<<<<<<<<
 *                         retval = py_from_lua(self._runtime, L, -2)
 *                     elif self._what == VALUES:
 */
        switch (((struct __pyx_obj_4lupa_5_lupa__LuaIter *)__pyx_v_self)->_what) {
          case __pyx_e_4lupa_5_lupa_KEYS:

          /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":680
 *                 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_5 = __pyx_f_4lupa_5_lupa_py_from_lua(((struct __pyx_obj_4lupa_5_lupa__LuaIter *)__pyx_v_self)->_runtime, __pyx_v_L, -2); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 680; __pyx_clineno = __LINE__; goto __pyx_L15;}
          __Pyx_GOTREF(__pyx_t_5);
          __Pyx_DECREF(__pyx_v_retval);
          __pyx_v_retval = __pyx_t_5;
          __pyx_t_5 = 0;
          break;

          /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":681
 *                     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:

          /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":682
 *                         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_5 = __pyx_f_4lupa_5_lupa_py_from_lua(((struct __pyx_obj_4lupa_5_lupa__LuaIter *)__pyx_v_self)->_runtime, __pyx_v_L, -1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 682; __pyx_clineno = __LINE__; goto __pyx_L15;}
          __Pyx_GOTREF(__pyx_t_5);
          __Pyx_DECREF(__pyx_v_retval);
          __pyx_v_retval = __pyx_t_5;
          __pyx_t_5 = 0;
          break;
          default:

          /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":684
 *                         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_5 = __pyx_f_4lupa_5_lupa_py_from_lua(((struct __pyx_obj_4lupa_5_lupa__LuaIter *)__pyx_v_self)->_runtime, __pyx_v_L, -2); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 684; __pyx_clineno = __LINE__; goto __pyx_L15;}
          __Pyx_GOTREF(__pyx_t_5);
          __pyx_t_4 = __pyx_f_4lupa_5_lupa_py_from_lua(((struct __pyx_obj_4lupa_5_lupa__LuaIter *)__pyx_v_self)->_runtime, __pyx_v_L, -1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 684; __pyx_clineno = __LINE__; goto __pyx_L15;}
          __Pyx_GOTREF(__pyx_t_4);
          __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 684; __pyx_clineno = __LINE__; goto __pyx_L15;}
          __Pyx_GOTREF(__pyx_t_3);
          PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_5);
          __Pyx_GIVEREF(__pyx_t_5);
          PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_t_4);
          __Pyx_GIVEREF(__pyx_t_4);
          __pyx_t_5 = 0;
          __pyx_t_4 = 0;
          __Pyx_DECREF(__pyx_v_retval);
          __pyx_v_retval = __pyx_t_3;
          __pyx_t_3 = 0;
          break;
        }
      }

      /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":687
 *                 finally:
 *                     # pop value
 *                     lua.lua_pop(L, 1)             # <<<<<<<<<<<<<<
 *                     # pop and store key
 *                     if not self._refiter:
 */
      /*finally:*/ {
        int __pyx_why;
        PyObject *__pyx_exc_type, *__pyx_exc_value, *__pyx_exc_tb;
        int __pyx_exc_lineno;
        __pyx_exc_type = 0; __pyx_exc_value = 0; __pyx_exc_tb = 0; __pyx_exc_lineno = 0;
        __pyx_why = 0; goto __pyx_L16;
        __pyx_L15: {
          __pyx_why = 4;
          __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
          __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
          __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
          __Pyx_ErrFetch(&__pyx_exc_type, &__pyx_exc_value, &__pyx_exc_tb);
          __pyx_exc_lineno = __pyx_lineno;
          goto __pyx_L16;
        }
        __pyx_L16:;
        lua_pop(__pyx_v_L, 1);

        /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":689
 *                     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 = (!((struct __pyx_obj_4lupa_5_lupa__LuaIter *)__pyx_v_self)->_refiter);
        if (__pyx_t_1) {

          /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":690
 *                     # 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)
 */
          ((struct __pyx_obj_4lupa_5_lupa__LuaIter *)__pyx_v_self)->_refiter = luaL_ref(__pyx_v_L, LUA_REGISTRYINDEX);
          goto __pyx_L18;
        }
        /*else*/ {

          /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":692
 *                         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, ((struct __pyx_obj_4lupa_5_lupa__LuaIter *)__pyx_v_self)->_refiter);
        }
        __pyx_L18:;
        switch (__pyx_why) {
          case 4: {
            __Pyx_ErrRestore(__pyx_exc_type, __pyx_exc_value, __pyx_exc_tb);
            __pyx_lineno = __pyx_exc_lineno;
            __pyx_exc_type = 0;
            __pyx_exc_value = 0;
            __pyx_exc_tb = 0;
            goto __pyx_L7;
          }
        }
      }

      /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":693
 *                     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_L6;
      goto __pyx_L13;
    }
    __pyx_L13:;

    /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":695
 *                 return retval
 *             # iteration done, clean up
 *             if self._refiter:             # <<<<<<<<<<<<<<
 *                 lua.luaL_unref(L, lua.LUA_REGISTRYINDEX, self._refiter)
 *                 self._refiter = 0
 */
    if (((struct __pyx_obj_4lupa_5_lupa__LuaIter *)__pyx_v_self)->_refiter) {

      /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":696
 *             # 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, ((struct __pyx_obj_4lupa_5_lupa__LuaIter *)__pyx_v_self)->_refiter);

      /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":697
 *             if self._refiter:
 *                 lua.luaL_unref(L, lua.LUA_REGISTRYINDEX, self._refiter)
 *                 self._refiter = 0             # <<<<<<<<<<<<<<
 *             self._obj = None
 *         finally:
 */
      ((struct __pyx_obj_4lupa_5_lupa__LuaIter *)__pyx_v_self)->_refiter = 0;
      goto __pyx_L19;
    }
    __pyx_L19:;

    /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":698
 *                 lua.luaL_unref(L, lua.LUA_REGISTRYINDEX, self._refiter)
 *                 self._refiter = 0
 *             self._obj = None             # <<<<<<<<<<<<<<
 *         finally:
 *             lua.lua_settop(L, 0)
 */
    __Pyx_INCREF(Py_None);
    __Pyx_GIVEREF(Py_None);
    __Pyx_GOTREF(((struct __pyx_obj_4lupa_5_lupa__LuaIter *)__pyx_v_self)->_obj);
    __Pyx_DECREF(((PyObject *)((struct __pyx_obj_4lupa_5_lupa__LuaIter *)__pyx_v_self)->_obj));
    ((struct __pyx_obj_4lupa_5_lupa__LuaIter *)__pyx_v_self)->_obj = ((struct __pyx_obj_4lupa_5_lupa__LuaObject *)Py_None);
  }

  /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":700
 *             self._obj = None
 *         finally:
 *             lua.lua_settop(L, 0)             # <<<<<<<<<<<<<<
 *             unlock_runtime(self._runtime)
 *         raise StopIteration
 */
  /*finally:*/ {
    int __pyx_why;
    PyObject *__pyx_exc_type, *__pyx_exc_value, *__pyx_exc_tb;
    int __pyx_exc_lineno;
    __pyx_exc_type = 0; __pyx_exc_value = 0; __pyx_exc_tb = 0; __pyx_exc_lineno = 0;
    __pyx_why = 0; goto __pyx_L8;
    __pyx_L6: __pyx_exc_type = 0; __pyx_exc_value = 0; __pyx_exc_tb = 0; __pyx_exc_lineno = 0;
    __pyx_why = 3; goto __pyx_L8;
    __pyx_L7: {
      __pyx_why = 4;
      __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
      __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
      __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_ErrFetch(&__pyx_exc_type, &__pyx_exc_value, &__pyx_exc_tb);
      __pyx_exc_lineno = __pyx_lineno;
      goto __pyx_L8;
    }
    __pyx_L8:;
    lua_settop(__pyx_v_L, 0);

    /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":701
 *         finally:
 *             lua.lua_settop(L, 0)
 *             unlock_runtime(self._runtime)             # <<<<<<<<<<<<<<
 *         raise StopIteration
 * 
 */
    __pyx_f_4lupa_5_lupa_unlock_runtime(((struct __pyx_obj_4lupa_5_lupa__LuaIter *)__pyx_v_self)->_runtime);
    switch (__pyx_why) {
      case 3: goto __pyx_L0;
      case 4: {
        __Pyx_ErrRestore(__pyx_exc_type, __pyx_exc_value, __pyx_exc_tb);
        __pyx_lineno = __pyx_exc_lineno;
        __pyx_exc_type = 0;
        __pyx_exc_value = 0;
        __pyx_exc_tb = 0;
        goto __pyx_L1_error;
      }
    }
  }

  /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":702
 *             lua.lua_settop(L, 0)
 *             unlock_runtime(self._runtime)
 *         raise StopIteration             # <<<<<<<<<<<<<<
 * 
 * # type conversions and protocol adaptations
 */
  __Pyx_Raise(__pyx_builtin_StopIteration, 0, 0);
  {__pyx_filename = __pyx_f[0]; __pyx_lineno = 702; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_AddTraceback("lupa._lupa._LuaIter.__next__");
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_DECREF(__pyx_v_retval);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":706
 * # 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;

  /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":707
 * 
 * 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);
  if (__pyx_t_1) {

    /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":708
 * 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);
    if (__pyx_t_2) {
      __pyx_t_3 = (lua_topointer(__pyx_v_L, 1) == ((void *)__pyx_f_4lupa_5_lupa_unpack_wrapped_pyfunction));
      __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) {

    /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":710
 *        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));

    /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":711
 *         # 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;
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":712
 *         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));

  /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":713
 *         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);

  /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":714
 *     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;

  __pyx_r = 0;
  __pyx_L0:;
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":716
 *     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;

  /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":717
 * 
 * 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);

  /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":718
 * 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));
  if (__pyx_t_1) {

    /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":719
 *     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);

    /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":720
 *     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 <py_object*> lua.luaL_checkudata(L, -1, POBJECT) # doesn't return on error!
 */
    lua_pushlightuserdata(__pyx_v_L, ((void *)__pyx_f_4lupa_5_lupa_unpack_wrapped_pyfunction));

    /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":721
 *         lua.lua_pushvalue(L, n)
 *         lua.lua_pushlightuserdata(L, <void*>unpack_wrapped_pyfunction)
 *         if lua.lua_pcall(L, 1, 1, 0) == 0:             # <<<<<<<<<<<<<<
 *             return <py_object*> lua.luaL_checkudata(L, -1, POBJECT) # doesn't return on error!
 *     return NULL
 */
    __pyx_t_1 = (lua_pcall(__pyx_v_L, 1, 1, 0) == 0);
    if (__pyx_t_1) {

      /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":722
 *         lua.lua_pushlightuserdata(L, <void*>unpack_wrapped_pyfunction)
 *         if lua.lua_pcall(L, 1, 1, 0) == 0:
 *             return <py_object*> lua.luaL_checkudata(L, -1, POBJECT) # doesn't return on error!             # <<<<<<<<<<<<<<
 *     return NULL
 * 
 */
      __pyx_r = ((struct __pyx_t_4lupa_5_lupa_py_object *)luaL_checkudata(__pyx_v_L, -1, __pyx_k__POBJECT));
      goto __pyx_L0;
      goto __pyx_L4;
    }
    __pyx_L4:;
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":723
 *         if lua.lua_pcall(L, 1, 1, 0) == 0:
 *             return <py_object*> lua.luaL_checkudata(L, -1, POBJECT) # doesn't return on error!
 *     return NULL             # <<<<<<<<<<<<<<
 * 
 * cdef class _PyProtocolWrapper:
 */
  __pyx_r = NULL;
  goto __pyx_L0;

  __pyx_r = 0;
  __pyx_L0:;
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":728
 *     cdef object _obj
 *     cdef int _type_flags
 *     def __cinit__(self):             # <<<<<<<<<<<<<<
 *         self._type_flags = 0
 *     def __init__(self):
 */

static int __pyx_pf_4lupa_5_lupa_18_PyProtocolWrapper___cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static int __pyx_pf_4lupa_5_lupa_18_PyProtocolWrapper___cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  int __pyx_r;
  __Pyx_RefNannySetupContext("__cinit__");
  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;

  /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":729
 *     cdef int _type_flags
 *     def __cinit__(self):
 *         self._type_flags = 0             # <<<<<<<<<<<<<<
 *     def __init__(self):
 *         raise TypeError("Type cannot be instantiated from Python")
 */
  ((struct __pyx_obj_4lupa_5_lupa__PyProtocolWrapper *)__pyx_v_self)->_type_flags = 0;

  __pyx_r = 0;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":730
 *     def __cinit__(self):
 *         self._type_flags = 0
 *     def __init__(self):             # <<<<<<<<<<<<<<
 *         raise TypeError("Type cannot be instantiated from Python")
 * 
 */

static int __pyx_pf_4lupa_5_lupa_18_PyProtocolWrapper___init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static int __pyx_pf_4lupa_5_lupa_18_PyProtocolWrapper___init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  int __pyx_r;
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  __Pyx_RefNannySetupContext("__init__");
  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;

  /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":731
 *         self._type_flags = 0
 *     def __init__(self):
 *         raise TypeError("Type cannot be instantiated from Python")             # <<<<<<<<<<<<<<
 * 
 * def as_attrgetter(obj):
 */
  __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 731; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_INCREF(((PyObject *)__pyx_kp_s_22));
  PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)__pyx_kp_s_22));
  __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_22));
  __pyx_t_2 = PyObject_Call(__pyx_builtin_TypeError, __pyx_t_1, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 731; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_Raise(__pyx_t_2, 0, 0);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  {__pyx_filename = __pyx_f[0]; __pyx_lineno = 731; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_AddTraceback("lupa._lupa._PyProtocolWrapper.__init__");
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":733
 *         raise TypeError("Type cannot be instantiated from Python")
 * 
 * def as_attrgetter(obj):             # <<<<<<<<<<<<<<
 *     cdef _PyProtocolWrapper wrap = _PyProtocolWrapper.__new__(_PyProtocolWrapper)
 *     wrap._obj = obj
 */

static PyObject *__pyx_pf_4lupa_5_lupa_as_attrgetter(PyObject *__pyx_self, PyObject *__pyx_v_obj); /*proto*/
static char __pyx_doc_4lupa_5_lupa_as_attrgetter[] = "as_attrgetter(obj)";
static PyObject *__pyx_pf_4lupa_5_lupa_as_attrgetter(PyObject *__pyx_self, PyObject *__pyx_v_obj) {
  struct __pyx_obj_4lupa_5_lupa__PyProtocolWrapper *__pyx_v_wrap = 0;
  PyObject *__pyx_r = NULL;
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("as_attrgetter");
  __pyx_self = __pyx_self;

  /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":734
 * 
 * def as_attrgetter(obj):
 *     cdef _PyProtocolWrapper wrap = _PyProtocolWrapper.__new__(_PyProtocolWrapper)             # <<<<<<<<<<<<<<
 *     wrap._obj = obj
 *     wrap._type_flags = 0
 */
  __pyx_t_1 = __Pyx_tp_new(((PyObject*)__pyx_ptype_4lupa_5_lupa__PyProtocolWrapper)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 734; __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 = 734; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_v_wrap = ((struct __pyx_obj_4lupa_5_lupa__PyProtocolWrapper *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":735
 * 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;

  /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":736
 *     cdef _PyProtocolWrapper wrap = _PyProtocolWrapper.__new__(_PyProtocolWrapper)
 *     wrap._obj = obj
 *     wrap._type_flags = 0             # <<<<<<<<<<<<<<
 *     return wrap
 * 
 */
  __pyx_v_wrap->_type_flags = 0;

  /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":737
 *     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;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("lupa._lupa.as_attrgetter");
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_wrap);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":739
 *     return wrap
 * 
 * def as_itemgetter(obj):             # <<<<<<<<<<<<<<
 *     cdef _PyProtocolWrapper wrap = _PyProtocolWrapper.__new__(_PyProtocolWrapper)
 *     wrap._obj = obj
 */

static PyObject *__pyx_pf_4lupa_5_lupa_as_itemgetter(PyObject *__pyx_self, PyObject *__pyx_v_obj); /*proto*/
static char __pyx_doc_4lupa_5_lupa_as_itemgetter[] = "as_itemgetter(obj)";
static PyObject *__pyx_pf_4lupa_5_lupa_as_itemgetter(PyObject *__pyx_self, PyObject *__pyx_v_obj) {
  struct __pyx_obj_4lupa_5_lupa__PyProtocolWrapper *__pyx_v_wrap = 0;
  PyObject *__pyx_r = NULL;
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("as_itemgetter");
  __pyx_self = __pyx_self;

  /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":740
 * 
 * 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(((PyObject*)__pyx_ptype_4lupa_5_lupa__PyProtocolWrapper)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 740; __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 = 740; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_v_wrap = ((struct __pyx_obj_4lupa_5_lupa__PyProtocolWrapper *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":741
 * 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;

  /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":742
 *     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;

  /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":743
 *     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;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("lupa._lupa.as_itemgetter");
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_wrap);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":745
 *     return wrap
 * 
 * cdef object py_from_lua(LuaRuntime runtime, lua_State *L, int n):             # <<<<<<<<<<<<<<
 *     cdef size_t size
 *     cdef const_char_ptr s
 */

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;
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  char *__pyx_t_3;
  __Pyx_RefNannySetupContext("py_from_lua");

  /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":750
 *     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);

  /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":752
 *     cdef int lua_type = lua.lua_type(L, n)
 * 
 *     if lua_type == lua.LUA_TNIL:             # <<<<<<<<<<<<<<
 *         return None
 *     elif lua_type == lua.LUA_TNUMBER:
 */
  switch (__pyx_v_lua_type) {
    case LUA_TNIL:

    /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":753
 * 
 *     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;

    /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":754
 *     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:

    /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":755
 *         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);

    /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":756
 *     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));
    if (__pyx_t_1) {

      /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":757
 *         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 = 757; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_r = __pyx_t_2;
      __pyx_t_2 = 0;
      goto __pyx_L0;
      goto __pyx_L3;
    }
    /*else*/ {

      /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":759
 *             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 = PyInt_FromLong(((long)__pyx_v_number)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 759; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_r = __pyx_t_2;
      __pyx_t_2 = 0;
      goto __pyx_L0;
    }
    __pyx_L3:;
    break;

    /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":760
 *         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:

    /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":761
 *             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));

    /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":762
 *     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));
    if (__pyx_t_1) {

      /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":763
 *         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_3 = PyBytes_AsString(((PyObject *)__pyx_v_runtime->_encoding)); if (unlikely((!__pyx_t_3) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 763; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_t_2 = ((PyObject *)PyUnicode_Decode(__pyx_v_s, __pyx_v_size, __pyx_t_3, NULL)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 763; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(((PyObject *)__pyx_t_2));
      __pyx_r = ((PyObject *)__pyx_t_2);
      __pyx_t_2 = 0;
      goto __pyx_L0;
      goto __pyx_L4;
    }
    /*else*/ {

      /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":765
 *             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 = PyBytes_FromStringAndSize(__pyx_v_s + 0, __pyx_v_size - 0); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 765; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(((PyObject *)__pyx_t_2));
      __pyx_r = ((PyObject *)__pyx_t_2);
      __pyx_t_2 = 0;
      goto __pyx_L0;
    }
    __pyx_L4:;
    break;

    /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":766
 *         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:

    /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":767
 *             return s[:size]
 *     elif lua_type == lua.LUA_TBOOLEAN:
 *         return lua.lua_toboolean(L, n)             # <<<<<<<<<<<<<<
 *     elif lua_type == lua.LUA_TUSERDATA:
 *         py_obj = <py_object*>lua.luaL_checkudata(L, n, POBJECT) # FIXME: doesn't return on error!
 */
    __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 = 767; __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;

    /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":768
 *     elif lua_type == lua.LUA_TBOOLEAN:
 *         return lua.lua_toboolean(L, n)
 *     elif lua_type == lua.LUA_TUSERDATA:             # <<<<<<<<<<<<<<
 *         py_obj = <py_object*>lua.luaL_checkudata(L, n, POBJECT) # FIXME: doesn't return on error!
 *         if py_obj:
 */
    case LUA_TUSERDATA:

    /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":769
 *         return lua.lua_toboolean(L, n)
 *     elif lua_type == lua.LUA_TUSERDATA:
 *         py_obj = <py_object*>lua.luaL_checkudata(L, n, POBJECT) # FIXME: doesn't return on error!             # <<<<<<<<<<<<<<
 *         if py_obj:
 *             return <object>py_obj.obj
 */
    __pyx_v_py_obj = ((struct __pyx_t_4lupa_5_lupa_py_object *)luaL_checkudata(__pyx_v_L, __pyx_v_n, __pyx_k__POBJECT));

    /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":770
 *     elif lua_type == lua.LUA_TUSERDATA:
 *         py_obj = <py_object*>lua.luaL_checkudata(L, n, POBJECT) # FIXME: doesn't return on error!
 *         if py_obj:             # <<<<<<<<<<<<<<
 *             return <object>py_obj.obj
 *     elif lua_type == lua.LUA_TTABLE:
 */
    __pyx_t_1 = (__pyx_v_py_obj != 0);
    if (__pyx_t_1) {

      /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":771
 *         py_obj = <py_object*>lua.luaL_checkudata(L, n, POBJECT) # FIXME: doesn't return on error!
 *         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;
      goto __pyx_L5;
    }
    __pyx_L5:;
    break;

    /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":772
 *         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:

    /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":773
 *             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 = 773; __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;

    /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":774
 *     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:

    /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":775
 *         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 = 775; __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;

    /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":776
 *     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:

    /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":777
 *         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);

    /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":778
 *     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_1 = (__pyx_v_py_obj != 0);
    if (__pyx_t_1) {

      /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":779
 *         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;
      goto __pyx_L6;
    }
    __pyx_L6:;

    /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":780
 *         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 = 780; __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;
  }

  /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":781
 *             return <object>py_obj.obj
 *         return new_lua_function(runtime, L, n)
 *     return new_lua_object(runtime, L, n)             # <<<<<<<<<<<<<<
 * 
 * cdef int py_to_lua(LuaRuntime runtime, lua_State *L, object o, bint withnone) except -1:
 */
  __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 = 781; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_r = __pyx_t_2;
  __pyx_t_2 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_AddTraceback("lupa._lupa.py_from_lua");
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":783
 *     return new_lua_object(runtime, L, n)
 * 
 * cdef int py_to_lua(LuaRuntime runtime, lua_State *L, object o, bint withnone) 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, int __pyx_v_withnone) {
  int __pyx_v_pushed_values_count;
  int __pyx_v_type_flags;
  int __pyx_r;
  int __pyx_t_1;
  double __pyx_t_2;
  int __pyx_t_3;
  int __pyx_t_4;
  long __pyx_t_5;
  char *__pyx_t_6;
  Py_ssize_t __pyx_t_7;
  int __pyx_t_8;
  PyObject *__pyx_t_9 = NULL;
  PyObject *__pyx_t_10 = NULL;
  PyObject *__pyx_t_11 = NULL;
  __Pyx_RefNannySetupContext("py_to_lua");
  __Pyx_INCREF(__pyx_v_o);

  /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":784
 * 
 * cdef int py_to_lua(LuaRuntime runtime, lua_State *L, object o, bint withnone) except -1:
 *     cdef int pushed_values_count = 0             # <<<<<<<<<<<<<<
 *     cdef int type_flags = 0
 * 
 */
  __pyx_v_pushed_values_count = 0;

  /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":785
 * cdef int py_to_lua(LuaRuntime runtime, lua_State *L, object o, bint withnone) except -1:
 *     cdef int pushed_values_count = 0
 *     cdef int type_flags = 0             # <<<<<<<<<<<<<<
 * 
 *     if o is None:
 */
  __pyx_v_type_flags = 0;

  /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":787
 *     cdef int type_flags = 0
 * 
 *     if o is None:             # <<<<<<<<<<<<<<
 *         if withnone:
 *             lua.lua_pushlstring(L, "Py_None", 7)
 */
  __pyx_t_1 = (__pyx_v_o == Py_None);
  if (__pyx_t_1) {

    /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":788
 * 
 *     if o is None:
 *         if withnone:             # <<<<<<<<<<<<<<
 *             lua.lua_pushlstring(L, "Py_None", 7)
 *             lua.lua_rawget(L, lua.LUA_REGISTRYINDEX)
 */
    if (__pyx_v_withnone) {

      /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":789
 *     if o is None:
 *         if withnone:
 *             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);

      /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":790
 *         if withnone:
 *             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);

      /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":791
 *             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_1 = lua_isnil(__pyx_v_L, -1);
      if (__pyx_t_1) {

        /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":792
 *             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);

        /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":793
 *             if lua.lua_isnil(L, -1):
 *                 lua.lua_pop(L, 1)
 *                 return 0             # <<<<<<<<<<<<<<
 *             pushed_values_count = 1
 *         else:
 */
        __pyx_r = 0;
        goto __pyx_L0;
        goto __pyx_L5;
      }
      __pyx_L5:;

      /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":794
 *                 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*/ {

      /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":798
 *             # 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 type(o) is bool:
 */
      lua_pushnil(__pyx_v_L);

      /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":799
 *             # with pushed_values_count == 0.
 *             lua.lua_pushnil(L)
 *             pushed_values_count = 1             # <<<<<<<<<<<<<<
 *     elif type(o) is bool:
 *         lua.lua_pushboolean(L, <bint>o)
 */
      __pyx_v_pushed_values_count = 1;
    }
    __pyx_L4:;
    goto __pyx_L3;
  }

  /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":800
 *             lua.lua_pushnil(L)
 *             pushed_values_count = 1
 *     elif type(o) is bool:             # <<<<<<<<<<<<<<
 *         lua.lua_pushboolean(L, <bint>o)
 *         pushed_values_count = 1
 */
  __pyx_t_1 = (((PyObject *)Py_TYPE(__pyx_v_o)) == ((PyObject*)&PyBool_Type));
  if (__pyx_t_1) {

    /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":801
 *             pushed_values_count = 1
 *     elif type(o) is bool:
 *         lua.lua_pushboolean(L, <bint>o)             # <<<<<<<<<<<<<<
 *         pushed_values_count = 1
 *     elif type(o) is float:
 */
    __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_v_o); if (unlikely((__pyx_t_1 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 801; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    lua_pushboolean(__pyx_v_L, __pyx_t_1);

    /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":802
 *     elif type(o) is bool:
 *         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;
  }

  /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":803
 *         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_1 = (((PyObject *)Py_TYPE(__pyx_v_o)) == ((PyObject *)((PyObject*)&PyFloat_Type)));
  if (__pyx_t_1) {

    /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":804
 *         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):
 */
    __pyx_t_2 = PyFloat_AS_DOUBLE(__pyx_v_o); if (unlikely(__pyx_t_2 == -1 && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 804; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    lua_pushnumber(__pyx_v_L, ((lua_Number)__pyx_t_2));

    /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":805
 *     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;
  }

  /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":806
 *         lua.lua_pushnumber(L, <lua.lua_Number>cpython.float.PyFloat_AS_DOUBLE(o))
 *         pushed_values_count = 1
 *     elif isinstance(o, long):             # <<<<<<<<<<<<<<
 *         lua.lua_pushnumber(L, <lua.lua_Number>cpython.long.PyLong_AsDouble(o))
 *         pushed_values_count = 1
 */
  __pyx_t_1 = PyLong_Check(__pyx_v_o); 
  if (__pyx_t_1) {

    /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":807
 *         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_2 = PyLong_AsDouble(__pyx_v_o); if (unlikely(__pyx_t_2 == (-1.0) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 807; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    lua_pushnumber(__pyx_v_L, ((lua_Number)__pyx_t_2));

    /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":808
 *     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;
  }

  /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":809
 *         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_1 = (PY_MAJOR_VERSION < 3);
  if (__pyx_t_1) {
    __pyx_t_3 = PyInt_Check(__pyx_v_o); 
    __pyx_t_4 = __pyx_t_3;
  } else {
    __pyx_t_4 = __pyx_t_1;
  }
  if (__pyx_t_4) {

    /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":810
 *         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_AsLong(__pyx_v_o); if (unlikely((__pyx_t_5 == (long)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 810; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    lua_pushnumber(__pyx_v_L, ((lua_Number)__pyx_t_5));

    /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":811
 *     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;
  }

  /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":812
 *         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_4 = PyBytes_Check(__pyx_v_o); 
  if (__pyx_t_4) {

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

    /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":814
 *     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;
  }

  /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":815
 *         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_4 = PyUnicode_Check(__pyx_v_o); 
  if (__pyx_t_4) {
    __pyx_t_1 = (__pyx_v_runtime->_encoding != ((PyObject *)Py_None));
    __pyx_t_3 = __pyx_t_1;
  } else {
    __pyx_t_3 = __pyx_t_4;
  }
  if (__pyx_t_3) {

    /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":816
 *         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 = 816; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_v_pushed_values_count = __pyx_t_8;
    goto __pyx_L3;
  }

  /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":817
 *     elif isinstance(o, unicode) and runtime._encoding is not None:
 *         pushed_values_count = push_encoded_unicode_string(runtime, L, <unicode>o)
 *     elif isinstance(o, _LuaObject):             # <<<<<<<<<<<<<<
 *         if (<_LuaObject>o)._runtime is not runtime:
 *             raise LuaError("cannot mix objects from different Lua runtimes")
 */
  __pyx_t_3 = PyObject_TypeCheck(__pyx_v_o, ((PyTypeObject *)((PyObject*)__pyx_ptype_4lupa_5_lupa__LuaObject))); 
  if (__pyx_t_3) {

    /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":818
 *         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);
    if (__pyx_t_3) {

      /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":819
 *     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_GetName(__pyx_m, __pyx_n_s__LuaError); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 819; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_9);
      __pyx_t_10 = PyTuple_New(1); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 819; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_10);
      __Pyx_INCREF(((PyObject *)__pyx_kp_s_23));
      PyTuple_SET_ITEM(__pyx_t_10, 0, ((PyObject *)__pyx_kp_s_23));
      __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_23));
      __pyx_t_11 = PyObject_Call(__pyx_t_9, __pyx_t_10, NULL); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 819; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_11);
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
      __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
      __Pyx_Raise(__pyx_t_11, 0, 0);
      __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 819; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      goto __pyx_L6;
    }
    __pyx_L6:;

    /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":820
 *         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);

    /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":821
 *             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;
  }

  /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":822
 *         lua.lua_rawgeti(L, lua.LUA_REGISTRYINDEX, (<_LuaObject>o)._ref)
 *         pushed_values_count = 1
 *     elif isinstance(o, float):             # <<<<<<<<<<<<<<
 *         lua.lua_pushnumber(L, <lua.lua_Number><double>o)
 *         pushed_values_count = 1
 */
  __pyx_t_3 = PyFloat_Check(__pyx_v_o); 
  if (__pyx_t_3) {

    /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":823
 *         pushed_values_count = 1
 *     elif isinstance(o, float):
 *         lua.lua_pushnumber(L, <lua.lua_Number><double>o)             # <<<<<<<<<<<<<<
 *         pushed_values_count = 1
 *     else:
 */
    __pyx_t_2 = __pyx_PyFloat_AsDouble(__pyx_v_o); if (unlikely((__pyx_t_2 == (double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 823; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    lua_pushnumber(__pyx_v_L, ((lua_Number)__pyx_t_2));

    /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":824
 *     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*/ {

    /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":826
 *         pushed_values_count = 1
 *     else:
 *         if isinstance(o, _PyProtocolWrapper):             # <<<<<<<<<<<<<<
 *             type_flags = (<_PyProtocolWrapper>o)._type_flags
 *             o = (<_PyProtocolWrapper>o)._obj
 */
    __pyx_t_3 = PyObject_TypeCheck(__pyx_v_o, ((PyTypeObject *)((PyObject*)__pyx_ptype_4lupa_5_lupa__PyProtocolWrapper))); 
    if (__pyx_t_3) {

      /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":827
 *     else:
 *         if isinstance(o, _PyProtocolWrapper):
 *             type_flags = (<_PyProtocolWrapper>o)._type_flags             # <<<<<<<<<<<<<<
 *             o = (<_PyProtocolWrapper>o)._obj
 *         else:
 */
      __pyx_v_type_flags = ((struct __pyx_obj_4lupa_5_lupa__PyProtocolWrapper *)__pyx_v_o)->_type_flags;

      /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":828
 *         if isinstance(o, _PyProtocolWrapper):
 *             type_flags = (<_PyProtocolWrapper>o)._type_flags
 *             o = (<_PyProtocolWrapper>o)._obj             # <<<<<<<<<<<<<<
 *         else:
 *             # prefer __getitem__ over __getattr__ by default
 */
      __Pyx_INCREF(((struct __pyx_obj_4lupa_5_lupa__PyProtocolWrapper *)__pyx_v_o)->_obj);
      __Pyx_DECREF(__pyx_v_o);
      __pyx_v_o = ((struct __pyx_obj_4lupa_5_lupa__PyProtocolWrapper *)__pyx_v_o)->_obj;
      goto __pyx_L7;
    }
    /*else*/ {

      /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":831
 *         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_3 = PyObject_HasAttr(__pyx_v_o, ((PyObject *)__pyx_n_s____getitem__)); if (unlikely(__pyx_t_3 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 831; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      if (__pyx_t_3) {
        __pyx_t_5 = __pyx_e_4lupa_5_lupa_OBJ_AS_INDEX;
      } else {
        __pyx_t_5 = 0;
      }
      __pyx_v_type_flags = __pyx_t_5;
    }
    __pyx_L7:;

    /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":832
 *             # 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:;

  /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":833
 *             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;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_9);
  __Pyx_XDECREF(__pyx_t_10);
  __Pyx_XDECREF(__pyx_t_11);
  __Pyx_AddTraceback("lupa._lupa.py_to_lua");
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_DECREF(__pyx_v_o);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":835
 *     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;
  char *__pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  Py_ssize_t __pyx_t_3;
  __Pyx_RefNannySetupContext("push_encoded_unicode_string");

  /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":836
 * 
 * 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_SetString(PyExc_AttributeError, "'NoneType' object has no attribute 'encode'"); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 836; __pyx_clineno = __LINE__; goto __pyx_L1_error;} 
  }
  __pyx_t_1 = PyBytes_AsString(((PyObject *)__pyx_v_runtime->_encoding)); if (unlikely((!__pyx_t_1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 836; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_2 = ((PyObject *)PyUnicode_AsEncodedString(__pyx_v_ustring, __pyx_t_1, NULL)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 836; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_2));
  if (!(likely(PyBytes_CheckExact(((PyObject *)__pyx_t_2)))||(PyErr_Format(PyExc_TypeError, "Expected bytes, got %.200s", Py_TYPE(((PyObject *)__pyx_t_2))->tp_name), 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 836; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_v_bytes_string = ((PyObject *)__pyx_t_2);
  __pyx_t_2 = 0;

  /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":837
 * 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 = PyBytes_AsString(((PyObject *)__pyx_v_bytes_string)); if (unlikely((!__pyx_t_1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 837; __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 = 837; __pyx_clineno = __LINE__; goto __pyx_L1_error;} 
  }
  __pyx_t_3 = PyBytes_GET_SIZE(((PyObject *)__pyx_v_bytes_string)); 
  lua_pushlstring(__pyx_v_L, __pyx_t_1, __pyx_t_3);

  /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":838
 *     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;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_AddTraceback("lupa._lupa.push_encoded_unicode_string");
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_bytes_string);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":840
 *     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;
  int __pyx_r;
  int __pyx_t_1;
  __Pyx_RefNannySetupContext("py_to_lua_custom");

  /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":841
 * 
 * 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))));

  /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":842
 * 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
 *     cpython.ref.Py_INCREF(o)
 */
  __pyx_t_1 = (!(__pyx_v_py_obj != 0));
  if (__pyx_t_1) {

    /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":843
 *     cdef py_object *py_obj = <py_object*> lua.lua_newuserdata(L, sizeof(py_object))
 *     if not py_obj:
 *         return 0 # values pushed             # <<<<<<<<<<<<<<
 *     cpython.ref.Py_INCREF(o)
 *     cpython.ref.Py_INCREF(runtime)
 */
    __pyx_r = 0;
    goto __pyx_L0;
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":844
 *     if not py_obj:
 *         return 0 # values pushed
 *     cpython.ref.Py_INCREF(o)             # <<<<<<<<<<<<<<
 *     cpython.ref.Py_INCREF(runtime)
 *     py_obj.obj = <PyObject*>o
 */
  Py_INCREF(__pyx_v_o);

  /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":845
 *         return 0 # values pushed
 *     cpython.ref.Py_INCREF(o)
 *     cpython.ref.Py_INCREF(runtime)             # <<<<<<<<<<<<<<
 *     py_obj.obj = <PyObject*>o
 *     py_obj.runtime = <PyObject*>runtime
 */
  Py_INCREF(((PyObject *)__pyx_v_runtime));

  /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":846
 *     cpython.ref.Py_INCREF(o)
 *     cpython.ref.Py_INCREF(runtime)
 *     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);

  /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":847
 *     cpython.ref.Py_INCREF(runtime)
 *     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);

  /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":848
 *     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;

  /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":849
 *     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);

  /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":850
 *     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);

  /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":851
 *     lua.luaL_getmetatable(L, POBJECT)
 *     lua.lua_setmetatable(L, -2)
 *     return 1 # values pushed             # <<<<<<<<<<<<<<
 * 
 * # error handling
 */
  __pyx_r = 1;
  goto __pyx_L0;

  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":855
 * # 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;
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  __Pyx_RefNannySetupContext("raise_lua_error");

  /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":856
 * 
 * cdef int raise_lua_error(LuaRuntime runtime, lua_State* L, int result) except -1:
 *     if result == 0:             # <<<<<<<<<<<<<<
 *         return 0
 *     elif result == lua.LUA_ERRMEM:
 */
  switch (__pyx_v_result) {
    case 0:

    /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":857
 * cdef int raise_lua_error(LuaRuntime runtime, lua_State* L, int result) except -1:
 *     if result == 0:
 *         return 0             # <<<<<<<<<<<<<<
 *     elif result == lua.LUA_ERRMEM:
 *         cpython.exc.PyErr_NoMemory()
 */
    __pyx_r = 0;
    goto __pyx_L0;
    break;

    /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":858
 *     if result == 0:
 *         return 0
 *     elif result == lua.LUA_ERRMEM:             # <<<<<<<<<<<<<<
 *         cpython.exc.PyErr_NoMemory()
 *     else:
 */
    case LUA_ERRMEM:

    /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":859
 *         return 0
 *     elif result == lua.LUA_ERRMEM:
 *         cpython.exc.PyErr_NoMemory()             # <<<<<<<<<<<<<<
 *     else:
 *         raise LuaError( build_lua_error_message(runtime, L, None, -1) )
 */
    __pyx_t_1 = __Pyx_GetName(__pyx_m, __pyx_n_s__cpython); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 859; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_2 = PyObject_GetAttr(__pyx_t_1, __pyx_n_s__exc); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 859; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_1 = PyObject_GetAttr(__pyx_t_2, __pyx_n_s__PyErr_NoMemory); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 859; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 859; __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_2); __pyx_t_2 = 0;
    break;
    default:

    /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":861
 *         cpython.exc.PyErr_NoMemory()
 *     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_2 = __Pyx_GetName(__pyx_m, __pyx_n_s__LuaError); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 861; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_1 = __pyx_f_4lupa_5_lupa_build_lua_error_message(__pyx_v_runtime, __pyx_v_L, ((PyObject *)Py_None), -1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 861; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 861; __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 = PyObject_Call(__pyx_t_2, __pyx_t_3, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 861; __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_Raise(__pyx_t_1, 0, 0);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 861; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    break;
  }

  __pyx_r = 0;
  goto __pyx_L0;
  __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_r = -1;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":863
 *         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
 *     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;
  PyObject *__pyx_r = NULL;
  int __pyx_t_1;
  char *__pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  int __pyx_t_4;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  PyObject *__pyx_t_7 = NULL;
  __Pyx_RefNannySetupContext("build_lua_error_message");
  __pyx_v_py_ustring = Py_None; __Pyx_INCREF(Py_None);

  /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":865
 * cdef build_lua_error_message(LuaRuntime runtime, lua_State* L, unicode err_message, int n):
 *     cdef size_t size
 *     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));

  /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":866
 *     cdef size_t size
 *     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));
  if (__pyx_t_1) {

    /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":867
 *     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:
 */
    {
      PyObject *__pyx_save_exc_type, *__pyx_save_exc_value, *__pyx_save_exc_tb;
      __Pyx_ExceptionSave(&__pyx_save_exc_type, &__pyx_save_exc_value, &__pyx_save_exc_tb);
      __Pyx_XGOTREF(__pyx_save_exc_type);
      __Pyx_XGOTREF(__pyx_save_exc_value);
      __Pyx_XGOTREF(__pyx_save_exc_tb);
      /*try:*/ {

        /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":868
 *     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_2 = PyBytes_AsString(((PyObject *)__pyx_v_runtime->_encoding)); if (unlikely((!__pyx_t_2) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 868; __pyx_clineno = __LINE__; goto __pyx_L4_error;}
        __pyx_t_3 = ((PyObject *)PyUnicode_Decode(__pyx_v_s, __pyx_v_size, __pyx_t_2, NULL)); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 868; __pyx_clineno = __LINE__; goto __pyx_L4_error;}
        __Pyx_GOTREF(((PyObject *)__pyx_t_3));
        __Pyx_DECREF(__pyx_v_py_ustring);
        __pyx_v_py_ustring = ((PyObject *)__pyx_t_3);
        __pyx_t_3 = 0;
      }
      __Pyx_XDECREF(__pyx_save_exc_type); __pyx_save_exc_type = 0;
      __Pyx_XDECREF(__pyx_save_exc_value); __pyx_save_exc_value = 0;
      __Pyx_XDECREF(__pyx_save_exc_tb); __pyx_save_exc_tb = 0;
      goto __pyx_L11_try_end;
      __pyx_L4_error:;
      __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;

      /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":869
 *         try:
 *             py_ustring = s[:size].decode(runtime._encoding)
 *         except UnicodeDecodeError:             # <<<<<<<<<<<<<<
 *             py_ustring = s[:size].decode('ISO-8859-1') # safe 'fake' decoding
 *     else:
 */
      __pyx_t_4 = PyErr_ExceptionMatches(__pyx_builtin_UnicodeDecodeError);
      if (__pyx_t_4) {
        __Pyx_AddTraceback("lupa._lupa.build_lua_error_message");
        if (__Pyx_GetException(&__pyx_t_3, &__pyx_t_5, &__pyx_t_6) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 869; __pyx_clineno = __LINE__; goto __pyx_L6_except_error;}
        __Pyx_GOTREF(__pyx_t_3);
        __Pyx_GOTREF(__pyx_t_5);
        __Pyx_GOTREF(__pyx_t_6);

        /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":870
 *             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_7 = ((PyObject *)PyUnicode_DecodeLatin1(__pyx_v_s, __pyx_v_size, NULL)); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 870; __pyx_clineno = __LINE__; goto __pyx_L6_except_error;}
        __Pyx_GOTREF(((PyObject *)__pyx_t_7));
        __Pyx_DECREF(__pyx_v_py_ustring);
        __pyx_v_py_ustring = ((PyObject *)__pyx_t_7);
        __pyx_t_7 = 0;
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
        goto __pyx_L5_exception_handled;
      }
      __pyx_L6_except_error:;
      __Pyx_XGIVEREF(__pyx_save_exc_type);
      __Pyx_XGIVEREF(__pyx_save_exc_value);
      __Pyx_XGIVEREF(__pyx_save_exc_tb);
      __Pyx_ExceptionReset(__pyx_save_exc_type, __pyx_save_exc_value, __pyx_save_exc_tb);
      goto __pyx_L1_error;
      __pyx_L5_exception_handled:;
      __Pyx_XGIVEREF(__pyx_save_exc_type);
      __Pyx_XGIVEREF(__pyx_save_exc_value);
      __Pyx_XGIVEREF(__pyx_save_exc_tb);
      __Pyx_ExceptionReset(__pyx_save_exc_type, __pyx_save_exc_value, __pyx_save_exc_tb);
      __pyx_L11_try_end:;
    }
    goto __pyx_L3;
  }
  /*else*/ {

    /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":872
 *             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_6 = ((PyObject *)PyUnicode_DecodeLatin1(__pyx_v_s, __pyx_v_size, NULL)); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 872; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(((PyObject *)__pyx_t_6));
    __Pyx_DECREF(__pyx_v_py_ustring);
    __pyx_v_py_ustring = ((PyObject *)__pyx_t_6);
    __pyx_t_6 = 0;
  }
  __pyx_L3:;

  /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":873
 *     else:
 *         py_ustring = s[:size].decode('ISO-8859-1')
 *     if err_message is None:             # <<<<<<<<<<<<<<
 *         return py_ustring
 *     else:
 */
  __pyx_t_1 = (__pyx_v_err_message == ((PyObject *)Py_None));
  if (__pyx_t_1) {

    /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":874
 *         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;
    goto __pyx_L14;
  }
  /*else*/ {

    /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":876
 *         return py_ustring
 *     else:
 *         return err_message % py_ustring             # <<<<<<<<<<<<<<
 * 
 * # calling into Lua
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_6 = PyNumber_Remainder(((PyObject *)__pyx_v_err_message), __pyx_v_py_ustring); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 876; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(((PyObject *)__pyx_t_6));
    __pyx_r = ((PyObject *)__pyx_t_6);
    __pyx_t_6 = 0;
    goto __pyx_L0;
  }
  __pyx_L14:;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_AddTraceback("lupa._lupa.build_lua_error_message");
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_DECREF(__pyx_v_py_ustring);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":880
 * # 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;
  PyObject *__pyx_r = NULL;
  int __pyx_t_1;
  char *__pyx_t_2;
  Py_ssize_t __pyx_t_3;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  __Pyx_RefNannySetupContext("run_lua");

  /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":882
 * cdef run_lua(LuaRuntime runtime, bytes lua_code):
 *     # locks the runtime
 *     cdef lua_State* L = runtime._state             # <<<<<<<<<<<<<<
 *     cdef bint result
 *     lock_runtime(runtime)
 */
  __pyx_v_L = __pyx_v_runtime->_state;

  /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":884
 *     cdef lua_State* L = runtime._state
 *     cdef bint result
 *     lock_runtime(runtime)             # <<<<<<<<<<<<<<
 *     try:
 *         if lua.luaL_loadbuffer(L, lua_code, len(lua_code), '<python>'):
 */
  __pyx_t_1 = __pyx_f_4lupa_5_lupa_lock_runtime(__pyx_v_runtime); if (unlikely(__pyx_t_1 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 884; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":885
 *     cdef bint result
 *     lock_runtime(runtime)
 *     try:             # <<<<<<<<<<<<<<
 *         if lua.luaL_loadbuffer(L, lua_code, len(lua_code), '<python>'):
 *             raise LuaSyntaxError(build_lua_error_message(
 */
  /*try:*/ {

    /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":886
 *     lock_runtime(runtime)
 *     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_2 = PyBytes_AsString(((PyObject *)__pyx_v_lua_code)); if (unlikely((!__pyx_t_2) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 886; __pyx_clineno = __LINE__; goto __pyx_L4;}
    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 = 886; __pyx_clineno = __LINE__; goto __pyx_L4;} 
    }
    __pyx_t_3 = PyBytes_GET_SIZE(((PyObject *)__pyx_v_lua_code)); 
    __pyx_t_1 = luaL_loadbuffer(__pyx_v_L, __pyx_t_2, __pyx_t_3, __pyx_k_24);
    if (__pyx_t_1) {

      /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":887
 *     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_4 = __Pyx_GetName(__pyx_m, __pyx_n_s__LuaSyntaxError); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 887; __pyx_clineno = __LINE__; goto __pyx_L4;}
      __Pyx_GOTREF(__pyx_t_4);

      /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":888
 *         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_5 = __pyx_f_4lupa_5_lupa_build_lua_error_message(__pyx_v_runtime, __pyx_v_L, __pyx_kp_u_25, -1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 887; __pyx_clineno = __LINE__; goto __pyx_L4;}
      __Pyx_GOTREF(__pyx_t_5);
      __pyx_t_6 = PyTuple_New(1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 887; __pyx_clineno = __LINE__; goto __pyx_L4;}
      __Pyx_GOTREF(__pyx_t_6);
      PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_5);
      __Pyx_GIVEREF(__pyx_t_5);
      __pyx_t_5 = 0;
      __pyx_t_5 = PyObject_Call(__pyx_t_4, __pyx_t_6, NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 887; __pyx_clineno = __LINE__; goto __pyx_L4;}
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      __Pyx_Raise(__pyx_t_5, 0, 0);
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 887; __pyx_clineno = __LINE__; goto __pyx_L4;}
      goto __pyx_L6;
    }
    __pyx_L6:;

    /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":889
 *             raise LuaSyntaxError(build_lua_error_message(
 *                 runtime, L, u"error loading code: %s", -1))
 *         return execute_lua_call(runtime, L, 0)             # <<<<<<<<<<<<<<
 *     finally:
 *         # resetting the stack is required in case of a syntax error
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_5 = __pyx_f_4lupa_5_lupa_execute_lua_call(__pyx_v_runtime, __pyx_v_L, 0); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 889; __pyx_clineno = __LINE__; goto __pyx_L4;}
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_r = __pyx_t_5;
    __pyx_t_5 = 0;
    goto __pyx_L3;
  }

  /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":894
 *         # above, so we repeat it here even if execute_lua_call() also
 *         # does it
 *         lua.lua_settop(L, 0)             # <<<<<<<<<<<<<<
 *         unlock_runtime(runtime)
 * 
 */
  /*finally:*/ {
    int __pyx_why;
    PyObject *__pyx_exc_type, *__pyx_exc_value, *__pyx_exc_tb;
    int __pyx_exc_lineno;
    __pyx_exc_type = 0; __pyx_exc_value = 0; __pyx_exc_tb = 0; __pyx_exc_lineno = 0;
    __pyx_why = 0; goto __pyx_L5;
    __pyx_L3: __pyx_exc_type = 0; __pyx_exc_value = 0; __pyx_exc_tb = 0; __pyx_exc_lineno = 0;
    __pyx_why = 3; goto __pyx_L5;
    __pyx_L4: {
      __pyx_why = 4;
      __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
      __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
      __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
      __Pyx_ErrFetch(&__pyx_exc_type, &__pyx_exc_value, &__pyx_exc_tb);
      __pyx_exc_lineno = __pyx_lineno;
      goto __pyx_L5;
    }
    __pyx_L5:;
    lua_settop(__pyx_v_L, 0);

    /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":895
 *         # does it
 *         lua.lua_settop(L, 0)
 *         unlock_runtime(runtime)             # <<<<<<<<<<<<<<
 * 
 * cdef call_lua(LuaRuntime runtime, lua_State *L, tuple args):
 */
    __pyx_f_4lupa_5_lupa_unlock_runtime(__pyx_v_runtime);
    switch (__pyx_why) {
      case 3: goto __pyx_L0;
      case 4: {
        __Pyx_ErrRestore(__pyx_exc_type, __pyx_exc_value, __pyx_exc_tb);
        __pyx_lineno = __pyx_exc_lineno;
        __pyx_exc_type = 0;
        __pyx_exc_value = 0;
        __pyx_exc_tb = 0;
        goto __pyx_L1_error;
      }
    }
  }

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  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.run_lua");
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":897
 *         unlock_runtime(runtime)
 * 
 * cdef call_lua(LuaRuntime runtime, lua_State *L, tuple args):             # <<<<<<<<<<<<<<
 *     # does not lock the runtime!
 *     push_lua_arguments(runtime, L, args, 0)
 */

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;
  int __pyx_t_1;
  Py_ssize_t __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  __Pyx_RefNannySetupContext("call_lua");

  /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":899
 * cdef call_lua(LuaRuntime runtime, lua_State *L, tuple args):
 *     # does not lock the runtime!
 *     push_lua_arguments(runtime, L, args, 0)             # <<<<<<<<<<<<<<
 *     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, 0); if (unlikely(__pyx_t_1 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 899; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":900
 *     # does not lock the runtime!
 *     push_lua_arguments(runtime, L, args, 0)
 *     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 = 900; __pyx_clineno = __LINE__; goto __pyx_L1_error;} 
  }
  __pyx_t_2 = PyTuple_GET_SIZE(((PyObject *)__pyx_v_args)); 
  __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 = 900; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_r = __pyx_t_3;
  __pyx_t_3 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("lupa._lupa.call_lua");
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":902
 *     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
 *     try:
 */

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;
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  __Pyx_RefNannySetupContext("execute_lua_call");

  /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":904
 * cdef object execute_lua_call(LuaRuntime runtime, lua_State *L, Py_ssize_t nargs):
 *     cdef int result_status
 *     try:             # <<<<<<<<<<<<<<
 *         # call into Lua
 *         with nogil:
 */
  /*try:*/ {

    /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":906
 *     try:
 *         # 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;
      #endif
      Py_UNBLOCK_THREADS
      /*try:*/ {

        /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":907
 *         # 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);
      }

      /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":906
 *     try:
 *         # call into Lua
 *         with nogil:             # <<<<<<<<<<<<<<
 *             result_status = lua.lua_pcall(L, nargs, lua.LUA_MULTRET, 0)
 *         runtime.reraise_on_exception()
 */
      /*finally:*/ {
        Py_BLOCK_THREADS
      }
    }

    /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":908
 *         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 = ((struct __pyx_vtabstruct_4lupa_5_lupa_LuaRuntime *)__pyx_v_runtime->__pyx_vtab)->reraise_on_exception(__pyx_v_runtime); if (unlikely(__pyx_t_1 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 908; __pyx_clineno = __LINE__; goto __pyx_L4;}

    /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":909
 *             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)
 */
    if (__pyx_v_result_status) {

      /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":910
 *         runtime.reraise_on_exception()
 *         if result_status:
 *             raise_lua_error(runtime, L, result_status)             # <<<<<<<<<<<<<<
 *         return unpack_lua_results(runtime, L)
 *     finally:
 */
      __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 = 910; __pyx_clineno = __LINE__; goto __pyx_L4;}
      goto __pyx_L9;
    }
    __pyx_L9:;

    /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":911
 *         if result_status:
 *             raise_lua_error(runtime, L, result_status)
 *         return unpack_lua_results(runtime, L)             # <<<<<<<<<<<<<<
 *     finally:
 *         lua.lua_settop(L, 0)
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_2 = __pyx_f_4lupa_5_lupa_unpack_lua_results(__pyx_v_runtime, __pyx_v_L); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 911; __pyx_clineno = __LINE__; goto __pyx_L4;}
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_r = __pyx_t_2;
    __pyx_t_2 = 0;
    goto __pyx_L3;
  }

  /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":913
 *         return unpack_lua_results(runtime, L)
 *     finally:
 *         lua.lua_settop(L, 0)             # <<<<<<<<<<<<<<
 * 
 * cdef int push_lua_arguments(LuaRuntime runtime, lua_State *L, tuple args, int withnone) except -1:
 */
  /*finally:*/ {
    int __pyx_why;
    PyObject *__pyx_exc_type, *__pyx_exc_value, *__pyx_exc_tb;
    int __pyx_exc_lineno;
    __pyx_exc_type = 0; __pyx_exc_value = 0; __pyx_exc_tb = 0; __pyx_exc_lineno = 0;
    __pyx_why = 0; goto __pyx_L5;
    __pyx_L3: __pyx_exc_type = 0; __pyx_exc_value = 0; __pyx_exc_tb = 0; __pyx_exc_lineno = 0;
    __pyx_why = 3; goto __pyx_L5;
    __pyx_L4: {
      __pyx_why = 4;
      __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_ErrFetch(&__pyx_exc_type, &__pyx_exc_value, &__pyx_exc_tb);
      __pyx_exc_lineno = __pyx_lineno;
      goto __pyx_L5;
    }
    __pyx_L5:;
    lua_settop(__pyx_v_L, 0);
    switch (__pyx_why) {
      case 3: goto __pyx_L0;
      case 4: {
        __Pyx_ErrRestore(__pyx_exc_type, __pyx_exc_value, __pyx_exc_tb);
        __pyx_lineno = __pyx_exc_lineno;
        __pyx_exc_type = 0;
        __pyx_exc_value = 0;
        __pyx_exc_tb = 0;
        goto __pyx_L1_error;
      }
    }
  }

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_AddTraceback("lupa._lupa.execute_lua_call");
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":915
 *         lua.lua_settop(L, 0)
 * 
 * cdef int push_lua_arguments(LuaRuntime runtime, lua_State *L, tuple args, int withnone) except -1:             # <<<<<<<<<<<<<<
 *     cdef int i
 *     if args:
 */

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, int __pyx_v_withnone) {
  int __pyx_v_i;
  PyObject *__pyx_v_arg;
  int __pyx_r;
  int __pyx_t_1;
  int __pyx_t_2;
  Py_ssize_t __pyx_t_3;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  int __pyx_t_6;
  PyObject *__pyx_t_7 = NULL;
  __Pyx_RefNannySetupContext("push_lua_arguments");
  __pyx_v_arg = Py_None; __Pyx_INCREF(Py_None);

  /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":917
 * cdef int push_lua_arguments(LuaRuntime runtime, lua_State *L, tuple args, int withnone) except -1:
 *     cdef int i
 *     if args:             # <<<<<<<<<<<<<<
 *         for i, arg in enumerate(args):
 *             if not py_to_lua(runtime, L, arg, withnone):
 */
  __pyx_t_1 = (((PyObject *)__pyx_v_args) != Py_None) && (PyTuple_GET_SIZE(((PyObject *)__pyx_v_args)) != 0);
  if (__pyx_t_1) {

    /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":918
 *     cdef int i
 *     if args:
 *         for i, arg in enumerate(args):             # <<<<<<<<<<<<<<
 *             if not py_to_lua(runtime, L, arg, withnone):
 *                 lua.lua_settop(L, 0)
 */
    __pyx_t_2 = 0;
    if (likely(((PyObject *)__pyx_v_args) != Py_None)) {
      __pyx_t_3 = 0; __pyx_t_4 = ((PyObject *)__pyx_v_args); __Pyx_INCREF(__pyx_t_4);
    } else {
      PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable"); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 918; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    for (;;) {
      if (__pyx_t_3 >= PyTuple_GET_SIZE(__pyx_t_4)) break;
      __pyx_t_5 = PyTuple_GET_ITEM(__pyx_t_4, __pyx_t_3); __Pyx_INCREF(__pyx_t_5); __pyx_t_3++;
      __Pyx_DECREF(__pyx_v_arg);
      __pyx_v_arg = __pyx_t_5;
      __pyx_t_5 = 0;
      __pyx_v_i = __pyx_t_2;
      __pyx_t_2 = (__pyx_t_2 + 1);

      /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":919
 *     if args:
 *         for i, arg in enumerate(args):
 *             if not py_to_lua(runtime, L, arg, withnone):             # <<<<<<<<<<<<<<
 *                 lua.lua_settop(L, 0)
 *                 raise TypeError("failed to convert argument at index %d" % i)
 */
      __pyx_t_6 = __pyx_f_4lupa_5_lupa_py_to_lua(__pyx_v_runtime, __pyx_v_L, __pyx_v_arg, __pyx_v_withnone); if (unlikely(__pyx_t_6 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 919; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_t_1 = (!__pyx_t_6);
      if (__pyx_t_1) {

        /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":920
 *         for i, arg in enumerate(args):
 *             if not py_to_lua(runtime, L, arg, withnone):
 *                 lua.lua_settop(L, 0)             # <<<<<<<<<<<<<<
 *                 raise TypeError("failed to convert argument at index %d" % i)
 *     return 0
 */
        lua_settop(__pyx_v_L, 0);

        /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":921
 *             if not py_to_lua(runtime, L, arg, withnone):
 *                 lua.lua_settop(L, 0)
 *                 raise TypeError("failed to convert argument at index %d" % i)             # <<<<<<<<<<<<<<
 *     return 0
 * 
 */
        __pyx_t_5 = PyInt_FromLong(__pyx_v_i); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 921; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_5);
        __pyx_t_7 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_27), __pyx_t_5); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 921; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(((PyObject *)__pyx_t_7));
        __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 = 921; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_5);
        PyTuple_SET_ITEM(__pyx_t_5, 0, ((PyObject *)__pyx_t_7));
        __Pyx_GIVEREF(((PyObject *)__pyx_t_7));
        __pyx_t_7 = 0;
        __pyx_t_7 = PyObject_Call(__pyx_builtin_TypeError, __pyx_t_5, NULL); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 921; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_7);
        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
        __Pyx_Raise(__pyx_t_7, 0, 0);
        __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
        {__pyx_filename = __pyx_f[0]; __pyx_lineno = 921; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        goto __pyx_L6;
      }
      __pyx_L6:;
    }
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":922
 *                 lua.lua_settop(L, 0)
 *                 raise TypeError("failed to convert argument at index %d" % i)
 *     return 0             # <<<<<<<<<<<<<<
 * 
 * cdef inline object unpack_lua_results(LuaRuntime runtime, lua_State *L):
 */
  __pyx_r = 0;
  goto __pyx_L0;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_AddTraceback("lupa._lupa.push_lua_arguments");
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_DECREF(__pyx_v_arg);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":924
 *     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;
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  __Pyx_RefNannySetupContext("unpack_lua_results");

  /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":925
 * 
 * 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);

  /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":926
 * 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);
  if (__pyx_t_1) {

    /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":927
 *     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 = 927; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_r = __pyx_t_2;
    __pyx_t_2 = 0;
    goto __pyx_L0;
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":928
 *     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);
  if (__pyx_t_1) {

    /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":929
 *         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;
    goto __pyx_L4;
  }
  __pyx_L4:;

  /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":930
 *     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 = ((PyObject *)__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 = 930; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_r = __pyx_t_2;
  __pyx_t_2 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_AddTraceback("lupa._lupa.unpack_lua_results");
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":932
 *     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;
  PyObject *__pyx_r = NULL;
  PyObject *__pyx_t_1 = NULL;
  int __pyx_t_2;
  int __pyx_t_3;
  __Pyx_RefNannySetupContext("unpack_multiple_lua_results");
  __pyx_v_arg = Py_None; __Pyx_INCREF(Py_None);

  /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":933
 * 
 * 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 = ((PyObject *)PyTuple_New(__pyx_v_nargs)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 933; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_args = ((PyObject *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":935
 *     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;

    /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":936
 *     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 = 936; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_v_arg);
    __pyx_v_arg = __pyx_t_1;
    __pyx_t_1 = 0;

    /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":937
 *     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);

    /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":938
 *         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(((PyObject *)__pyx_v_args), __pyx_v_i, __pyx_v_arg);
  }

  /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":939
 *         cpython.ref.Py_INCREF(arg)
 *         cpython.tuple.PyTuple_SET_ITEM(args, i, arg)
 *     return args             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_XDECREF(((PyObject *)__pyx_r));
  __Pyx_INCREF(((PyObject *)__pyx_v_args));
  __pyx_r = __pyx_v_args;
  goto __pyx_L0;

  __pyx_r = ((PyObject *)Py_None); __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("lupa._lupa.unpack_multiple_lua_results");
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_args);
  __Pyx_DECREF(__pyx_v_arg);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":965
 * # ref-counting support for Python objects
 * 
 * cdef void decref_with_gil(py_object *py_obj) with gil:             # <<<<<<<<<<<<<<
 *     cpython.ref.Py_XDECREF(py_obj.obj)
 *     cpython.ref.Py_XDECREF(py_obj.runtime)
 */

static  void __pyx_f_4lupa_5_lupa_decref_with_gil(struct __pyx_t_4lupa_5_lupa_py_object *__pyx_v_py_obj) {
  #ifdef WITH_THREAD
  PyGILState_STATE _save = PyGILState_Ensure();
  #endif
  __Pyx_RefNannySetupContext("decref_with_gil");

  /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":966
 * 
 * cdef void decref_with_gil(py_object *py_obj) with gil:
 *     cpython.ref.Py_XDECREF(py_obj.obj)             # <<<<<<<<<<<<<<
 *     cpython.ref.Py_XDECREF(py_obj.runtime)
 * 
 */
  Py_XDECREF(__pyx_v_py_obj->obj);

  /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":967
 * cdef void decref_with_gil(py_object *py_obj) with gil:
 *     cpython.ref.Py_XDECREF(py_obj.obj)
 *     cpython.ref.Py_XDECREF(py_obj.runtime)             # <<<<<<<<<<<<<<
 * 
 * cdef int py_object_gc(lua_State* L) nogil:
 */
  Py_XDECREF(__pyx_v_py_obj->runtime);

  __Pyx_RefNannyFinishContext();
  #ifdef WITH_THREAD
  PyGILState_Release(_save);
  #endif
}

/* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":969
 *     cpython.ref.Py_XDECREF(py_obj.runtime)
 * 
 * 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;

  /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":970
 * 
 * cdef int py_object_gc(lua_State* L) nogil:
 *     if not lua.lua_isuserdata(L, 1):             # <<<<<<<<<<<<<<
 *         return 0
 *     cdef py_object* py_obj = <py_object*> lua.luaL_checkudata(L, 1, POBJECT) # doesn't return on error!
 */
  __pyx_t_1 = (!lua_isuserdata(__pyx_v_L, 1));
  if (__pyx_t_1) {

    /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":971
 * cdef int py_object_gc(lua_State* L) nogil:
 *     if not lua.lua_isuserdata(L, 1):
 *         return 0             # <<<<<<<<<<<<<<
 *     cdef py_object* py_obj = <py_object*> lua.luaL_checkudata(L, 1, POBJECT) # doesn't return on error!
 *     if py_obj is not NULL and py_obj.obj is not NULL:
 */
    __pyx_r = 0;
    goto __pyx_L0;
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":972
 *     if not lua.lua_isuserdata(L, 1):
 *         return 0
 *     cdef py_object* py_obj = <py_object*> lua.luaL_checkudata(L, 1, POBJECT) # doesn't return on error!             # <<<<<<<<<<<<<<
 *     if py_obj is not NULL and py_obj.obj is not NULL:
 *         decref_with_gil(py_obj)
 */
  __pyx_v_py_obj = ((struct __pyx_t_4lupa_5_lupa_py_object *)luaL_checkudata(__pyx_v_L, 1, __pyx_k__POBJECT));

  /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":973
 *         return 0
 *     cdef py_object* py_obj = <py_object*> lua.luaL_checkudata(L, 1, POBJECT) # doesn't return on error!
 *     if py_obj is not NULL and py_obj.obj is not NULL:             # <<<<<<<<<<<<<<
 *         decref_with_gil(py_obj)
 *     return 0
 */
  __pyx_t_1 = (__pyx_v_py_obj != NULL);
  if (__pyx_t_1) {
    __pyx_t_2 = (__pyx_v_py_obj->obj != NULL);
    __pyx_t_3 = __pyx_t_2;
  } else {
    __pyx_t_3 = __pyx_t_1;
  }
  if (__pyx_t_3) {

    /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":974
 *     cdef py_object* py_obj = <py_object*> lua.luaL_checkudata(L, 1, POBJECT) # doesn't return on error!
 *     if py_obj is not NULL and py_obj.obj is not NULL:
 *         decref_with_gil(py_obj)             # <<<<<<<<<<<<<<
 *     return 0
 * 
 */
    __pyx_f_4lupa_5_lupa_decref_with_gil(__pyx_v_py_obj);
    goto __pyx_L4;
  }
  __pyx_L4:;

  /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":975
 *     if py_obj is not NULL and py_obj.obj is not NULL:
 *         decref_with_gil(py_obj)
 *     return 0             # <<<<<<<<<<<<<<
 * 
 * # calling Python objects
 */
  __pyx_r = 0;
  goto __pyx_L0;

  __pyx_r = 0;
  __pyx_L0:;
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":979
 * # 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 bint ret = 0
 */

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;
  int __pyx_v_ret;
  PyObject *__pyx_v_args = 0;
  PyObject *__pyx_v_arg;
  int __pyx_r;
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  int __pyx_t_4;
  int __pyx_t_5;
  __Pyx_RefNannySetupContext("call_python");
  __pyx_v_arg = Py_None; __Pyx_INCREF(Py_None);

  /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":980
 * 
 * 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 bint ret = 0
 * 
 */
  __pyx_v_nargs = (lua_gettop(__pyx_v_L) - 1);

  /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":981
 * 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 bint ret = 0             # <<<<<<<<<<<<<<
 * 
 *     if not py_obj:
 */
  __pyx_v_ret = 0;

  /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":983
 *     cdef bint ret = 0
 * 
 *     if not py_obj:             # <<<<<<<<<<<<<<
 *         raise TypeError("not a python object")
 * 
 */
  __pyx_t_1 = (!(__pyx_v_py_obj != 0));
  if (__pyx_t_1) {

    /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":984
 * 
 *     if not py_obj:
 *         raise TypeError("not a python object")             # <<<<<<<<<<<<<<
 * 
 *     cdef tuple args = cpython.tuple.PyTuple_New(nargs)
 */
    __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 984; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_INCREF(((PyObject *)__pyx_kp_s_28));
    PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_kp_s_28));
    __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_28));
    __pyx_t_3 = PyObject_Call(__pyx_builtin_TypeError, __pyx_t_2, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 984; __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);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 984; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":986
 *         raise TypeError("not a python object")
 * 
 *     cdef tuple args = cpython.tuple.PyTuple_New(nargs)             # <<<<<<<<<<<<<<
 *     for i in range(nargs):
 *         arg = py_from_lua(runtime, L, i+2)
 */
  __pyx_t_3 = ((PyObject *)PyTuple_New(__pyx_v_nargs)); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 986; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_v_args = ((PyObject *)__pyx_t_3);
  __pyx_t_3 = 0;

  /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":987
 * 
 *     cdef tuple args = cpython.tuple.PyTuple_New(nargs)
 *     for i in range(nargs):             # <<<<<<<<<<<<<<
 *         arg = py_from_lua(runtime, L, i+2)
 *         cpython.ref.Py_INCREF(arg)
 */
  __pyx_t_4 = __pyx_v_nargs;
  for (__pyx_t_5 = 0; __pyx_t_5 < __pyx_t_4; __pyx_t_5+=1) {
    __pyx_v_i = __pyx_t_5;

    /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":988
 *     cdef tuple args = cpython.tuple.PyTuple_New(nargs)
 *     for i in range(nargs):
 *         arg = py_from_lua(runtime, L, i+2)             # <<<<<<<<<<<<<<
 *         cpython.ref.Py_INCREF(arg)
 *         cpython.tuple.PyTuple_SET_ITEM(args, i, arg)
 */
    __pyx_t_3 = __pyx_f_4lupa_5_lupa_py_from_lua(__pyx_v_runtime, __pyx_v_L, (__pyx_v_i + 2)); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 988; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_v_arg);
    __pyx_v_arg = __pyx_t_3;
    __pyx_t_3 = 0;

    /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":989
 *     for i in range(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);

    /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":990
 *         arg = py_from_lua(runtime, L, i+2)
 *         cpython.ref.Py_INCREF(arg)
 *         cpython.tuple.PyTuple_SET_ITEM(args, i, arg)             # <<<<<<<<<<<<<<
 * 
 *     return py_to_lua(runtime, L, (<object>py_obj.obj)(*args), 0)
 */
    PyTuple_SET_ITEM(((PyObject *)__pyx_v_args), __pyx_v_i, __pyx_v_arg);
  }

  /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":992
 *         cpython.tuple.PyTuple_SET_ITEM(args, i, arg)
 * 
 *     return py_to_lua(runtime, L, (<object>py_obj.obj)(*args), 0)             # <<<<<<<<<<<<<<
 * 
 * cdef int py_call_with_gil(lua_State* L, py_object *py_obj) with gil:
 */
  __pyx_t_3 = PySequence_Tuple(((PyObject *)__pyx_v_args)); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 992; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_3));
  __pyx_t_2 = PyObject_Call(((PyObject *)__pyx_v_py_obj->obj), ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 992; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
  __pyx_t_4 = __pyx_f_4lupa_5_lupa_py_to_lua(__pyx_v_runtime, __pyx_v_L, __pyx_t_2, 0); if (unlikely(__pyx_t_4 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 992; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_r = __pyx_t_4;
  goto __pyx_L0;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("lupa._lupa.call_python");
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_args);
  __Pyx_DECREF(__pyx_v_arg);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":994
 *     return py_to_lua(runtime, L, (<object>py_obj.obj)(*args), 0)
 * 
 * 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;
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  int __pyx_t_5;
  #ifdef WITH_THREAD
  PyGILState_STATE _save = PyGILState_Ensure();
  #endif
  __Pyx_RefNannySetupContext("py_call_with_gil");

  /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":995
 * 
 * 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);

  /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":996
 * 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)
 */
  {
    PyObject *__pyx_save_exc_type, *__pyx_save_exc_value, *__pyx_save_exc_tb;
    __Pyx_ExceptionSave(&__pyx_save_exc_type, &__pyx_save_exc_value, &__pyx_save_exc_tb);
    __Pyx_XGOTREF(__pyx_save_exc_type);
    __Pyx_XGOTREF(__pyx_save_exc_value);
    __Pyx_XGOTREF(__pyx_save_exc_tb);
    /*try:*/ {

      /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":997
 *     cdef LuaRuntime runtime = None
 *     try:
 *         runtime = <LuaRuntime?>py_obj.runtime             # <<<<<<<<<<<<<<
 *         return call_python(runtime, L, py_obj)
 *     except:
 */
      __Pyx_INCREF(((PyObject *)((struct __pyx_obj_4lupa_5_lupa_LuaRuntime *)__pyx_v_py_obj->runtime)));
      __Pyx_DECREF(((PyObject *)__pyx_v_runtime));
      __pyx_v_runtime = ((struct __pyx_obj_4lupa_5_lupa_LuaRuntime *)__pyx_v_py_obj->runtime);

      /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":998
 *     try:
 *         runtime = <LuaRuntime?>py_obj.runtime
 *         return call_python(runtime, L, py_obj)             # <<<<<<<<<<<<<<
 *     except:
 *         try: runtime.store_raised_exception()
 */
      __pyx_t_1 = __pyx_f_4lupa_5_lupa_call_python(__pyx_v_runtime, __pyx_v_L, __pyx_v_py_obj); if (unlikely(__pyx_t_1 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 998; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      __pyx_r = __pyx_t_1;
      goto __pyx_L7_try_return;
    }
    __Pyx_XDECREF(__pyx_save_exc_type); __pyx_save_exc_type = 0;
    __Pyx_XDECREF(__pyx_save_exc_value); __pyx_save_exc_value = 0;
    __Pyx_XDECREF(__pyx_save_exc_tb); __pyx_save_exc_tb = 0;
    goto __pyx_L10_try_end;
    __pyx_L7_try_return:;
    __Pyx_XGIVEREF(__pyx_save_exc_type);
    __Pyx_XGIVEREF(__pyx_save_exc_value);
    __Pyx_XGIVEREF(__pyx_save_exc_tb);
    __Pyx_ExceptionReset(__pyx_save_exc_type, __pyx_save_exc_value, __pyx_save_exc_tb);
    goto __pyx_L0;
    __pyx_L3_error:;

    /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":999
 *         runtime = <LuaRuntime?>py_obj.runtime
 *         return call_python(runtime, L, py_obj)
 *     except:             # <<<<<<<<<<<<<<
 *         try: runtime.store_raised_exception()
 *         except: pass
 */
    /*except:*/ {
      __Pyx_AddTraceback("lupa._lupa.py_call_with_gil");
      if (__Pyx_GetException(&__pyx_t_2, &__pyx_t_3, &__pyx_t_4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 999; __pyx_clineno = __LINE__; goto __pyx_L5_except_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_GOTREF(__pyx_t_4);

      /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":1000
 *         return call_python(runtime, L, py_obj)
 *     except:
 *         try: runtime.store_raised_exception()             # <<<<<<<<<<<<<<
 *         except: pass
 *         return -1
 */
      {
        PyObject *__pyx_save_exc_type, *__pyx_save_exc_value, *__pyx_save_exc_tb;
        __Pyx_ExceptionSave(&__pyx_save_exc_type, &__pyx_save_exc_value, &__pyx_save_exc_tb);
        __Pyx_XGOTREF(__pyx_save_exc_type);
        __Pyx_XGOTREF(__pyx_save_exc_value);
        __Pyx_XGOTREF(__pyx_save_exc_tb);
        /*try:*/ {
          __pyx_t_5 = ((struct __pyx_vtabstruct_4lupa_5_lupa_LuaRuntime *)__pyx_v_runtime->__pyx_vtab)->store_raised_exception(__pyx_v_runtime); if (unlikely(__pyx_t_5 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1000; __pyx_clineno = __LINE__; goto __pyx_L13_error;}
        }
        __Pyx_XDECREF(__pyx_save_exc_type); __pyx_save_exc_type = 0;
        __Pyx_XDECREF(__pyx_save_exc_value); __pyx_save_exc_value = 0;
        __Pyx_XDECREF(__pyx_save_exc_tb); __pyx_save_exc_tb = 0;
        goto __pyx_L20_try_end;
        __pyx_L13_error:;

        /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":1001
 *     except:
 *         try: runtime.store_raised_exception()
 *         except: pass             # <<<<<<<<<<<<<<
 *         return -1
 * 
 */
        /*except:*/ {
          PyErr_Restore(0,0,0);
          goto __pyx_L14_exception_handled;
        }
        __pyx_L14_exception_handled:;
        __Pyx_XGIVEREF(__pyx_save_exc_type);
        __Pyx_XGIVEREF(__pyx_save_exc_value);
        __Pyx_XGIVEREF(__pyx_save_exc_tb);
        __Pyx_ExceptionReset(__pyx_save_exc_type, __pyx_save_exc_value, __pyx_save_exc_tb);
        __pyx_L20_try_end:;
      }

      /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":1002
 *         try: runtime.store_raised_exception()
 *         except: pass
 *         return -1             # <<<<<<<<<<<<<<
 * 
 * cdef int py_object_call(lua_State* L) nogil:
 */
      __pyx_r = -1;
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      goto __pyx_L6_except_return;
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      goto __pyx_L4_exception_handled;
    }
    __pyx_L5_except_error:;
    __Pyx_XGIVEREF(__pyx_save_exc_type);
    __Pyx_XGIVEREF(__pyx_save_exc_value);
    __Pyx_XGIVEREF(__pyx_save_exc_tb);
    __Pyx_ExceptionReset(__pyx_save_exc_type, __pyx_save_exc_value, __pyx_save_exc_tb);
    goto __pyx_L1_error;
    __pyx_L6_except_return:;
    __Pyx_XGIVEREF(__pyx_save_exc_type);
    __Pyx_XGIVEREF(__pyx_save_exc_value);
    __Pyx_XGIVEREF(__pyx_save_exc_tb);
    __Pyx_ExceptionReset(__pyx_save_exc_type, __pyx_save_exc_value, __pyx_save_exc_tb);
    goto __pyx_L0;
    __pyx_L4_exception_handled:;
    __Pyx_XGIVEREF(__pyx_save_exc_type);
    __Pyx_XGIVEREF(__pyx_save_exc_value);
    __Pyx_XGIVEREF(__pyx_save_exc_tb);
    __Pyx_ExceptionReset(__pyx_save_exc_type, __pyx_save_exc_value, __pyx_save_exc_tb);
    __pyx_L10_try_end:;
  }

  __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_WriteUnraisable("lupa._lupa.py_call_with_gil");
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_runtime);
  __Pyx_RefNannyFinishContext();
  #ifdef WITH_THREAD
  PyGILState_Release(_save);
  #endif
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":1004
 *         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;

  /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":1005
 * 
 * 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);

  /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":1006
 * 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));
  if (__pyx_t_1) {

    /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":1007
 *     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_28);
    goto __pyx_L0;
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":1009
 *         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);

  /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":1010
 * 
 *     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);
  if (__pyx_t_1) {

    /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":1011
 *     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_30);
    goto __pyx_L0;
    goto __pyx_L4;
  }
  __pyx_L4:;

  /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":1012
 *     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;

  __pyx_r = 0;
  __pyx_L0:;
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":1016
 * # 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;
  PyObject *__pyx_v_s;
  int __pyx_r;
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  int __pyx_t_3;
  char *__pyx_t_4;
  Py_ssize_t __pyx_t_5;
  PyObject *__pyx_t_6 = NULL;
  int __pyx_t_7;
  #ifdef WITH_THREAD
  PyGILState_STATE _save = PyGILState_Ensure();
  #endif
  __Pyx_RefNannySetupContext("py_str_with_gil");
  __pyx_v_runtime = ((struct __pyx_obj_4lupa_5_lupa_LuaRuntime *)Py_None); __Pyx_INCREF(Py_None);
  __pyx_v_s = Py_None; __Pyx_INCREF(Py_None);

  /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":1018
 * 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)
 */
  {
    PyObject *__pyx_save_exc_type, *__pyx_save_exc_value, *__pyx_save_exc_tb;
    __Pyx_ExceptionSave(&__pyx_save_exc_type, &__pyx_save_exc_value, &__pyx_save_exc_tb);
    __Pyx_XGOTREF(__pyx_save_exc_type);
    __Pyx_XGOTREF(__pyx_save_exc_value);
    __Pyx_XGOTREF(__pyx_save_exc_tb);
    /*try:*/ {

      /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":1019
 *     cdef LuaRuntime runtime
 *     try:
 *         runtime = <LuaRuntime?>py_obj.runtime             # <<<<<<<<<<<<<<
 *         s = str(<object>py_obj.obj)
 *         if isinstance(s, unicode):
 */
      __Pyx_INCREF(((PyObject *)((struct __pyx_obj_4lupa_5_lupa_LuaRuntime *)__pyx_v_py_obj->runtime)));
      __Pyx_DECREF(((PyObject *)__pyx_v_runtime));
      __pyx_v_runtime = ((struct __pyx_obj_4lupa_5_lupa_LuaRuntime *)__pyx_v_py_obj->runtime);

      /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":1020
 *     try:
 *         runtime = <LuaRuntime?>py_obj.runtime
 *         s = str(<object>py_obj.obj)             # <<<<<<<<<<<<<<
 *         if isinstance(s, unicode):
 *             s = (<unicode>s).encode(runtime._encoding)
 */
      __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1020; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_INCREF(((PyObject *)__pyx_v_py_obj->obj));
      PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)__pyx_v_py_obj->obj));
      __Pyx_GIVEREF(((PyObject *)__pyx_v_py_obj->obj));
      __pyx_t_2 = PyObject_Call(((PyObject *)((PyObject*)&PyString_Type)), __pyx_t_1, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1020; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __Pyx_DECREF(__pyx_v_s);
      __pyx_v_s = __pyx_t_2;
      __pyx_t_2 = 0;

      /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":1021
 *         runtime = <LuaRuntime?>py_obj.runtime
 *         s = str(<object>py_obj.obj)
 *         if isinstance(s, unicode):             # <<<<<<<<<<<<<<
 *             s = (<unicode>s).encode(runtime._encoding)
 *         else:
 */
      __pyx_t_3 = PyUnicode_Check(__pyx_v_s); 
      if (__pyx_t_3) {

        /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":1022
 *         s = str(<object>py_obj.obj)
 *         if isinstance(s, unicode):
 *             s = (<unicode>s).encode(runtime._encoding)             # <<<<<<<<<<<<<<
 *         else:
 *             assert isinstance(s, bytes)
 */
        if (unlikely(((PyObject *)__pyx_v_s) == Py_None)) {
          PyErr_SetString(PyExc_AttributeError, "'NoneType' object has no attribute 'encode'"); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1022; __pyx_clineno = __LINE__; goto __pyx_L3_error;} 
        }
        __pyx_t_4 = PyBytes_AsString(((PyObject *)__pyx_v_runtime->_encoding)); if (unlikely((!__pyx_t_4) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1022; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        __pyx_t_2 = ((PyObject *)PyUnicode_AsEncodedString(((PyObject *)__pyx_v_s), __pyx_t_4, NULL)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1022; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        __Pyx_GOTREF(((PyObject *)__pyx_t_2));
        __Pyx_DECREF(__pyx_v_s);
        __pyx_v_s = ((PyObject *)__pyx_t_2);
        __pyx_t_2 = 0;
        goto __pyx_L11;
      }
      /*else*/ {

        /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":1024
 *             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 PYREX_WITHOUT_ASSERTIONS
        __pyx_t_3 = PyBytes_Check(__pyx_v_s); 
        if (unlikely(!__pyx_t_3)) {
          PyErr_SetNone(PyExc_AssertionError);
          {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1024; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        }
        #endif
      }
      __pyx_L11:;

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

      /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":1026
 *             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_save_exc_type); __pyx_save_exc_type = 0;
    __Pyx_XDECREF(__pyx_save_exc_value); __pyx_save_exc_value = 0;
    __Pyx_XDECREF(__pyx_save_exc_tb); __pyx_save_exc_tb = 0;
    goto __pyx_L10_try_end;
    __pyx_L7_try_return:;
    __Pyx_XGIVEREF(__pyx_save_exc_type);
    __Pyx_XGIVEREF(__pyx_save_exc_value);
    __Pyx_XGIVEREF(__pyx_save_exc_tb);
    __Pyx_ExceptionReset(__pyx_save_exc_type, __pyx_save_exc_value, __pyx_save_exc_tb);
    goto __pyx_L0;
    __pyx_L3_error:;
    __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;

    /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":1027
 *         lua.lua_pushlstring(L, <bytes>s, len(<bytes>s))
 *         return 1 # returning 1 value
 *     except:             # <<<<<<<<<<<<<<
 *         try: runtime.store_raised_exception()
 *         except: pass
 */
    /*except:*/ {
      __Pyx_AddTraceback("lupa._lupa.py_str_with_gil");
      if (__Pyx_GetException(&__pyx_t_2, &__pyx_t_1, &__pyx_t_6) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1027; __pyx_clineno = __LINE__; goto __pyx_L5_except_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_GOTREF(__pyx_t_6);

      /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":1028
 *         return 1 # returning 1 value
 *     except:
 *         try: runtime.store_raised_exception()             # <<<<<<<<<<<<<<
 *         except: pass
 *         return -1
 */
      {
        PyObject *__pyx_save_exc_type, *__pyx_save_exc_value, *__pyx_save_exc_tb;
        __Pyx_ExceptionSave(&__pyx_save_exc_type, &__pyx_save_exc_value, &__pyx_save_exc_tb);
        __Pyx_XGOTREF(__pyx_save_exc_type);
        __Pyx_XGOTREF(__pyx_save_exc_value);
        __Pyx_XGOTREF(__pyx_save_exc_tb);
        /*try:*/ {
          __pyx_t_7 = ((struct __pyx_vtabstruct_4lupa_5_lupa_LuaRuntime *)__pyx_v_runtime->__pyx_vtab)->store_raised_exception(__pyx_v_runtime); if (unlikely(__pyx_t_7 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1028; __pyx_clineno = __LINE__; goto __pyx_L14_error;}
        }
        __Pyx_XDECREF(__pyx_save_exc_type); __pyx_save_exc_type = 0;
        __Pyx_XDECREF(__pyx_save_exc_value); __pyx_save_exc_value = 0;
        __Pyx_XDECREF(__pyx_save_exc_tb); __pyx_save_exc_tb = 0;
        goto __pyx_L21_try_end;
        __pyx_L14_error:;

        /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":1029
 *     except:
 *         try: runtime.store_raised_exception()
 *         except: pass             # <<<<<<<<<<<<<<
 *         return -1
 * 
 */
        /*except:*/ {
          PyErr_Restore(0,0,0);
          goto __pyx_L15_exception_handled;
        }
        __pyx_L15_exception_handled:;
        __Pyx_XGIVEREF(__pyx_save_exc_type);
        __Pyx_XGIVEREF(__pyx_save_exc_value);
        __Pyx_XGIVEREF(__pyx_save_exc_tb);
        __Pyx_ExceptionReset(__pyx_save_exc_type, __pyx_save_exc_value, __pyx_save_exc_tb);
        __pyx_L21_try_end:;
      }

      /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":1030
 *         try: runtime.store_raised_exception()
 *         except: pass
 *         return -1             # <<<<<<<<<<<<<<
 * 
 * cdef int py_object_str(lua_State* L) nogil:
 */
      __pyx_r = -1;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      goto __pyx_L6_except_return;
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      goto __pyx_L4_exception_handled;
    }
    __pyx_L5_except_error:;
    __Pyx_XGIVEREF(__pyx_save_exc_type);
    __Pyx_XGIVEREF(__pyx_save_exc_value);
    __Pyx_XGIVEREF(__pyx_save_exc_tb);
    __Pyx_ExceptionReset(__pyx_save_exc_type, __pyx_save_exc_value, __pyx_save_exc_tb);
    goto __pyx_L1_error;
    __pyx_L6_except_return:;
    __Pyx_XGIVEREF(__pyx_save_exc_type);
    __Pyx_XGIVEREF(__pyx_save_exc_value);
    __Pyx_XGIVEREF(__pyx_save_exc_tb);
    __Pyx_ExceptionReset(__pyx_save_exc_type, __pyx_save_exc_value, __pyx_save_exc_tb);
    goto __pyx_L0;
    __pyx_L4_exception_handled:;
    __Pyx_XGIVEREF(__pyx_save_exc_type);
    __Pyx_XGIVEREF(__pyx_save_exc_value);
    __Pyx_XGIVEREF(__pyx_save_exc_tb);
    __Pyx_ExceptionReset(__pyx_save_exc_type, __pyx_save_exc_value, __pyx_save_exc_tb);
    __pyx_L10_try_end:;
  }

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_WriteUnraisable("lupa._lupa.py_str_with_gil");
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_DECREF((PyObject *)__pyx_v_runtime);
  __Pyx_DECREF(__pyx_v_s);
  __Pyx_RefNannyFinishContext();
  #ifdef WITH_THREAD
  PyGILState_Release(_save);
  #endif
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":1032
 *         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;

  /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":1033
 * 
 * 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);

  /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":1034
 * 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));
  if (__pyx_t_1) {

    /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":1035
 *     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_28);
    goto __pyx_L0;
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":1036
 *     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);

  /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":1037
 *         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);
  if (__pyx_t_1) {

    /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":1038
 *     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_31);
    goto __pyx_L0;
    goto __pyx_L4;
  }
  __pyx_L4:;

  /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":1039
 *     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;

  __pyx_r = 0;
  __pyx_L0:;
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":1043
 * # item access for Python objects
 * 
 * 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) ], 1)
 */

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;
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  int __pyx_t_3;
  __Pyx_RefNannySetupContext("getitem_for_lua");

  /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":1045
 * 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) ], 1)             # <<<<<<<<<<<<<<
 * 
 * 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 = 1045; __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 (!__pyx_t_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1045; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_3 = __pyx_f_4lupa_5_lupa_py_to_lua(__pyx_v_runtime, __pyx_v_L, __pyx_t_2, 1); if (unlikely(__pyx_t_3 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1044; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_r = __pyx_t_3;
  goto __pyx_L0;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_AddTraceback("lupa._lupa.getitem_for_lua");
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":1047
 *                      (<object>py_obj.obj)[ py_from_lua(runtime, L, key_n) ], 1)
 * 
 * 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;
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  __Pyx_RefNannySetupContext("setitem_for_lua");

  /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":1048
 * 
 * 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 = 1048; __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 = 1048; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  if (PyObject_SetItem(((PyObject *)__pyx_v_py_obj->obj), __pyx_t_2, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1048; __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;

  /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":1049
 * 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;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_AddTraceback("lupa._lupa.setitem_for_lua");
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":1051
 *     return 0
 * 
 * cdef int getattr_for_lua(LuaRuntime runtime, lua_State* L, py_object* py_obj, int key_n) except -1:             # <<<<<<<<<<<<<<
 *     return py_to_lua(runtime, L,
 *                      getattr(<object>py_obj.obj, py_from_lua(runtime, L, key_n)), 1)
 */

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) {
  int __pyx_r;
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  int __pyx_t_3;
  __Pyx_RefNannySetupContext("getattr_for_lua");

  /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":1053
 * cdef int getattr_for_lua(LuaRuntime runtime, lua_State* L, py_object* py_obj, int key_n) except -1:
 *     return py_to_lua(runtime, L,
 *                      getattr(<object>py_obj.obj, py_from_lua(runtime, L, key_n)), 1)             # <<<<<<<<<<<<<<
 * 
 * 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_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 = 1053; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyObject_GetAttr(((PyObject *)__pyx_v_py_obj->obj), __pyx_t_1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1053; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_3 = __pyx_f_4lupa_5_lupa_py_to_lua(__pyx_v_runtime, __pyx_v_L, __pyx_t_2, 1); if (unlikely(__pyx_t_3 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1052; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_r = __pyx_t_3;
  goto __pyx_L0;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_AddTraceback("lupa._lupa.getattr_for_lua");
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":1055
 *                      getattr(<object>py_obj.obj, py_from_lua(runtime, L, key_n)), 1)
 * 
 * cdef int setattr_for_lua(LuaRuntime runtime, lua_State* L, py_object* py_obj, int key_n, int value_n) except -1:             # <<<<<<<<<<<<<<
 *     setattr(<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_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) {
  int __pyx_r;
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  int __pyx_t_3;
  __Pyx_RefNannySetupContext("setattr_for_lua");

  /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":1056
 * 
 * cdef int setattr_for_lua(LuaRuntime runtime, lua_State* L, py_object* py_obj, int key_n, int value_n) except -1:
 *     setattr(<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_key_n); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1056; __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_value_n); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1056; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = PyObject_SetAttr(((PyObject *)__pyx_v_py_obj->obj), __pyx_t_1, __pyx_t_2); if (unlikely(__pyx_t_3 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1056; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":1057
 * cdef int setattr_for_lua(LuaRuntime runtime, lua_State* L, py_object* py_obj, int key_n, int value_n) except -1:
 *     setattr(<object>py_obj.obj, py_from_lua(runtime, L, key_n), py_from_lua(runtime, L, value_n))
 *     return 0             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_r = 0;
  goto __pyx_L0;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_AddTraceback("lupa._lupa.setattr_for_lua");
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":1060
 * 
 * 
 * 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;
  int __pyx_r;
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  #ifdef WITH_THREAD
  PyGILState_STATE _save = PyGILState_Ensure();
  #endif
  __Pyx_RefNannySetupContext("py_object_getindex_with_gil");
  __pyx_v_runtime = ((struct __pyx_obj_4lupa_5_lupa_LuaRuntime *)Py_None); __Pyx_INCREF(Py_None);

  /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":1062
 * 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:
 */
  {
    PyObject *__pyx_save_exc_type, *__pyx_save_exc_value, *__pyx_save_exc_tb;
    __Pyx_ExceptionSave(&__pyx_save_exc_type, &__pyx_save_exc_value, &__pyx_save_exc_tb);
    __Pyx_XGOTREF(__pyx_save_exc_type);
    __Pyx_XGOTREF(__pyx_save_exc_value);
    __Pyx_XGOTREF(__pyx_save_exc_tb);
    /*try:*/ {

      /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":1063
 *     cdef LuaRuntime runtime
 *     try:
 *         runtime = <LuaRuntime?>py_obj.runtime             # <<<<<<<<<<<<<<
 *         if py_obj.type_flags & OBJ_AS_INDEX:
 *             return getitem_for_lua(runtime, L, py_obj, 2)
 */
      __Pyx_INCREF(((PyObject *)((struct __pyx_obj_4lupa_5_lupa_LuaRuntime *)__pyx_v_py_obj->runtime)));
      __Pyx_DECREF(((PyObject *)__pyx_v_runtime));
      __pyx_v_runtime = ((struct __pyx_obj_4lupa_5_lupa_LuaRuntime *)__pyx_v_py_obj->runtime);

      /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":1064
 *     try:
 *         runtime = <LuaRuntime?>py_obj.runtime
 *         if py_obj.type_flags & OBJ_AS_INDEX:             # <<<<<<<<<<<<<<
 *             return getitem_for_lua(runtime, L, py_obj, 2)
 *         else:
 */
      __pyx_t_1 = (__pyx_v_py_obj->type_flags & __pyx_e_4lupa_5_lupa_OBJ_AS_INDEX);
      if (__pyx_t_1) {

        /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":1065
 *         runtime = <LuaRuntime?>py_obj.runtime
 *         if py_obj.type_flags & OBJ_AS_INDEX:
 *             return getitem_for_lua(runtime, L, py_obj, 2)             # <<<<<<<<<<<<<<
 *         else:
 *             return getattr_for_lua(runtime, L, py_obj, 2)
 */
        __pyx_t_1 = __pyx_f_4lupa_5_lupa_getitem_for_lua(__pyx_v_runtime, __pyx_v_L, __pyx_v_py_obj, 2); if (unlikely(__pyx_t_1 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1065; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        __pyx_r = __pyx_t_1;
        goto __pyx_L7_try_return;
        goto __pyx_L11;
      }
      /*else*/ {

        /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":1067
 *             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_1 = __pyx_f_4lupa_5_lupa_getattr_for_lua(__pyx_v_runtime, __pyx_v_L, __pyx_v_py_obj, 2); if (unlikely(__pyx_t_1 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1067; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        __pyx_r = __pyx_t_1;
        goto __pyx_L7_try_return;
      }
      __pyx_L11:;
    }
    __Pyx_XDECREF(__pyx_save_exc_type); __pyx_save_exc_type = 0;
    __Pyx_XDECREF(__pyx_save_exc_value); __pyx_save_exc_value = 0;
    __Pyx_XDECREF(__pyx_save_exc_tb); __pyx_save_exc_tb = 0;
    goto __pyx_L10_try_end;
    __pyx_L7_try_return:;
    __Pyx_XGIVEREF(__pyx_save_exc_type);
    __Pyx_XGIVEREF(__pyx_save_exc_value);
    __Pyx_XGIVEREF(__pyx_save_exc_tb);
    __Pyx_ExceptionReset(__pyx_save_exc_type, __pyx_save_exc_value, __pyx_save_exc_tb);
    goto __pyx_L0;
    __pyx_L3_error:;

    /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":1068
 *         else:
 *             return getattr_for_lua(runtime, L, py_obj, 2)
 *     except:             # <<<<<<<<<<<<<<
 *         try: runtime.store_raised_exception()
 *         except: pass
 */
    /*except:*/ {
      __Pyx_AddTraceback("lupa._lupa.py_object_getindex_with_gil");
      if (__Pyx_GetException(&__pyx_t_2, &__pyx_t_3, &__pyx_t_4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1068; __pyx_clineno = __LINE__; goto __pyx_L5_except_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_GOTREF(__pyx_t_4);

      /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":1069
 *             return getattr_for_lua(runtime, L, py_obj, 2)
 *     except:
 *         try: runtime.store_raised_exception()             # <<<<<<<<<<<<<<
 *         except: pass
 *         return -1
 */
      {
        PyObject *__pyx_save_exc_type, *__pyx_save_exc_value, *__pyx_save_exc_tb;
        __Pyx_ExceptionSave(&__pyx_save_exc_type, &__pyx_save_exc_value, &__pyx_save_exc_tb);
        __Pyx_XGOTREF(__pyx_save_exc_type);
        __Pyx_XGOTREF(__pyx_save_exc_value);
        __Pyx_XGOTREF(__pyx_save_exc_tb);
        /*try:*/ {
          __pyx_t_1 = ((struct __pyx_vtabstruct_4lupa_5_lupa_LuaRuntime *)__pyx_v_runtime->__pyx_vtab)->store_raised_exception(__pyx_v_runtime); if (unlikely(__pyx_t_1 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1069; __pyx_clineno = __LINE__; goto __pyx_L14_error;}
        }
        __Pyx_XDECREF(__pyx_save_exc_type); __pyx_save_exc_type = 0;
        __Pyx_XDECREF(__pyx_save_exc_value); __pyx_save_exc_value = 0;
        __Pyx_XDECREF(__pyx_save_exc_tb); __pyx_save_exc_tb = 0;
        goto __pyx_L21_try_end;
        __pyx_L14_error:;

        /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":1070
 *     except:
 *         try: runtime.store_raised_exception()
 *         except: pass             # <<<<<<<<<<<<<<
 *         return -1
 * 
 */
        /*except:*/ {
          PyErr_Restore(0,0,0);
          goto __pyx_L15_exception_handled;
        }
        __pyx_L15_exception_handled:;
        __Pyx_XGIVEREF(__pyx_save_exc_type);
        __Pyx_XGIVEREF(__pyx_save_exc_value);
        __Pyx_XGIVEREF(__pyx_save_exc_tb);
        __Pyx_ExceptionReset(__pyx_save_exc_type, __pyx_save_exc_value, __pyx_save_exc_tb);
        __pyx_L21_try_end:;
      }

      /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":1071
 *         try: runtime.store_raised_exception()
 *         except: pass
 *         return -1             # <<<<<<<<<<<<<<
 * 
 * cdef int py_object_getindex(lua_State* L) nogil:
 */
      __pyx_r = -1;
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      goto __pyx_L6_except_return;
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      goto __pyx_L4_exception_handled;
    }
    __pyx_L5_except_error:;
    __Pyx_XGIVEREF(__pyx_save_exc_type);
    __Pyx_XGIVEREF(__pyx_save_exc_value);
    __Pyx_XGIVEREF(__pyx_save_exc_tb);
    __Pyx_ExceptionReset(__pyx_save_exc_type, __pyx_save_exc_value, __pyx_save_exc_tb);
    goto __pyx_L1_error;
    __pyx_L6_except_return:;
    __Pyx_XGIVEREF(__pyx_save_exc_type);
    __Pyx_XGIVEREF(__pyx_save_exc_value);
    __Pyx_XGIVEREF(__pyx_save_exc_tb);
    __Pyx_ExceptionReset(__pyx_save_exc_type, __pyx_save_exc_value, __pyx_save_exc_tb);
    goto __pyx_L0;
    __pyx_L4_exception_handled:;
    __Pyx_XGIVEREF(__pyx_save_exc_type);
    __Pyx_XGIVEREF(__pyx_save_exc_value);
    __Pyx_XGIVEREF(__pyx_save_exc_tb);
    __Pyx_ExceptionReset(__pyx_save_exc_type, __pyx_save_exc_value, __pyx_save_exc_tb);
    __pyx_L10_try_end:;
  }

  __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_WriteUnraisable("lupa._lupa.py_object_getindex_with_gil");
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_DECREF((PyObject *)__pyx_v_runtime);
  __Pyx_RefNannyFinishContext();
  #ifdef WITH_THREAD
  PyGILState_Release(_save);
  #endif
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":1073
 *         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;

  /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":1074
 * 
 * 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);

  /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":1075
 * 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));
  if (__pyx_t_1) {

    /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":1076
 *     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_28);
    goto __pyx_L0;
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":1077
 *     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 during Python str() call')  # never returns!
 */
  __pyx_v_result = __pyx_f_4lupa_5_lupa_py_object_getindex_with_gil(__pyx_v_L, __pyx_v_py_obj);

  /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":1078
 *         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 during Python str() call')  # never returns!
 *     return result
 */
  __pyx_t_1 = (__pyx_v_result < 0);
  if (__pyx_t_1) {

    /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":1079
 *     result = py_object_getindex_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_31);
    goto __pyx_L0;
    goto __pyx_L4;
  }
  __pyx_L4:;

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

  __pyx_r = 0;
  __pyx_L0:;
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":1083
 * 
 * 
 * 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;
  int __pyx_r;
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  #ifdef WITH_THREAD
  PyGILState_STATE _save = PyGILState_Ensure();
  #endif
  __Pyx_RefNannySetupContext("py_object_setindex_with_gil");
  __pyx_v_runtime = ((struct __pyx_obj_4lupa_5_lupa_LuaRuntime *)Py_None); __Pyx_INCREF(Py_None);

  /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":1085
 * 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:
 */
  {
    PyObject *__pyx_save_exc_type, *__pyx_save_exc_value, *__pyx_save_exc_tb;
    __Pyx_ExceptionSave(&__pyx_save_exc_type, &__pyx_save_exc_value, &__pyx_save_exc_tb);
    __Pyx_XGOTREF(__pyx_save_exc_type);
    __Pyx_XGOTREF(__pyx_save_exc_value);
    __Pyx_XGOTREF(__pyx_save_exc_tb);
    /*try:*/ {

      /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":1086
 *     cdef LuaRuntime runtime
 *     try:
 *         runtime = <LuaRuntime?>py_obj.runtime             # <<<<<<<<<<<<<<
 *         if py_obj.type_flags & OBJ_AS_INDEX:
 *             return setitem_for_lua(runtime, L, py_obj, 2, 3)
 */
      __Pyx_INCREF(((PyObject *)((struct __pyx_obj_4lupa_5_lupa_LuaRuntime *)__pyx_v_py_obj->runtime)));
      __Pyx_DECREF(((PyObject *)__pyx_v_runtime));
      __pyx_v_runtime = ((struct __pyx_obj_4lupa_5_lupa_LuaRuntime *)__pyx_v_py_obj->runtime);

      /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":1087
 *     try:
 *         runtime = <LuaRuntime?>py_obj.runtime
 *         if py_obj.type_flags & OBJ_AS_INDEX:             # <<<<<<<<<<<<<<
 *             return setitem_for_lua(runtime, L, py_obj, 2, 3)
 *         else:
 */
      __pyx_t_1 = (__pyx_v_py_obj->type_flags & __pyx_e_4lupa_5_lupa_OBJ_AS_INDEX);
      if (__pyx_t_1) {

        /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":1088
 *         runtime = <LuaRuntime?>py_obj.runtime
 *         if py_obj.type_flags & OBJ_AS_INDEX:
 *             return setitem_for_lua(runtime, L, py_obj, 2, 3)             # <<<<<<<<<<<<<<
 *         else:
 *             return setattr_for_lua(runtime, L, py_obj, 2, 3)
 */
        __pyx_t_1 = __pyx_f_4lupa_5_lupa_setitem_for_lua(__pyx_v_runtime, __pyx_v_L, __pyx_v_py_obj, 2, 3); if (unlikely(__pyx_t_1 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1088; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        __pyx_r = __pyx_t_1;
        goto __pyx_L7_try_return;
        goto __pyx_L11;
      }
      /*else*/ {

        /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":1090
 *             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_1 = __pyx_f_4lupa_5_lupa_setattr_for_lua(__pyx_v_runtime, __pyx_v_L, __pyx_v_py_obj, 2, 3); if (unlikely(__pyx_t_1 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1090; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        __pyx_r = __pyx_t_1;
        goto __pyx_L7_try_return;
      }
      __pyx_L11:;
    }
    __Pyx_XDECREF(__pyx_save_exc_type); __pyx_save_exc_type = 0;
    __Pyx_XDECREF(__pyx_save_exc_value); __pyx_save_exc_value = 0;
    __Pyx_XDECREF(__pyx_save_exc_tb); __pyx_save_exc_tb = 0;
    goto __pyx_L10_try_end;
    __pyx_L7_try_return:;
    __Pyx_XGIVEREF(__pyx_save_exc_type);
    __Pyx_XGIVEREF(__pyx_save_exc_value);
    __Pyx_XGIVEREF(__pyx_save_exc_tb);
    __Pyx_ExceptionReset(__pyx_save_exc_type, __pyx_save_exc_value, __pyx_save_exc_tb);
    goto __pyx_L0;
    __pyx_L3_error:;

    /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":1091
 *         else:
 *             return setattr_for_lua(runtime, L, py_obj, 2, 3)
 *     except:             # <<<<<<<<<<<<<<
 *         try: runtime.store_raised_exception()
 *         except: pass
 */
    /*except:*/ {
      __Pyx_AddTraceback("lupa._lupa.py_object_setindex_with_gil");
      if (__Pyx_GetException(&__pyx_t_2, &__pyx_t_3, &__pyx_t_4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1091; __pyx_clineno = __LINE__; goto __pyx_L5_except_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_GOTREF(__pyx_t_4);

      /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":1092
 *             return setattr_for_lua(runtime, L, py_obj, 2, 3)
 *     except:
 *         try: runtime.store_raised_exception()             # <<<<<<<<<<<<<<
 *         except: pass
 *         return -1
 */
      {
        PyObject *__pyx_save_exc_type, *__pyx_save_exc_value, *__pyx_save_exc_tb;
        __Pyx_ExceptionSave(&__pyx_save_exc_type, &__pyx_save_exc_value, &__pyx_save_exc_tb);
        __Pyx_XGOTREF(__pyx_save_exc_type);
        __Pyx_XGOTREF(__pyx_save_exc_value);
        __Pyx_XGOTREF(__pyx_save_exc_tb);
        /*try:*/ {
          __pyx_t_1 = ((struct __pyx_vtabstruct_4lupa_5_lupa_LuaRuntime *)__pyx_v_runtime->__pyx_vtab)->store_raised_exception(__pyx_v_runtime); if (unlikely(__pyx_t_1 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1092; __pyx_clineno = __LINE__; goto __pyx_L14_error;}
        }
        __Pyx_XDECREF(__pyx_save_exc_type); __pyx_save_exc_type = 0;
        __Pyx_XDECREF(__pyx_save_exc_value); __pyx_save_exc_value = 0;
        __Pyx_XDECREF(__pyx_save_exc_tb); __pyx_save_exc_tb = 0;
        goto __pyx_L21_try_end;
        __pyx_L14_error:;

        /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":1093
 *     except:
 *         try: runtime.store_raised_exception()
 *         except: pass             # <<<<<<<<<<<<<<
 *         return -1
 * 
 */
        /*except:*/ {
          PyErr_Restore(0,0,0);
          goto __pyx_L15_exception_handled;
        }
        __pyx_L15_exception_handled:;
        __Pyx_XGIVEREF(__pyx_save_exc_type);
        __Pyx_XGIVEREF(__pyx_save_exc_value);
        __Pyx_XGIVEREF(__pyx_save_exc_tb);
        __Pyx_ExceptionReset(__pyx_save_exc_type, __pyx_save_exc_value, __pyx_save_exc_tb);
        __pyx_L21_try_end:;
      }

      /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":1094
 *         try: runtime.store_raised_exception()
 *         except: pass
 *         return -1             # <<<<<<<<<<<<<<
 * 
 * cdef int py_object_setindex(lua_State* L) nogil:
 */
      __pyx_r = -1;
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      goto __pyx_L6_except_return;
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      goto __pyx_L4_exception_handled;
    }
    __pyx_L5_except_error:;
    __Pyx_XGIVEREF(__pyx_save_exc_type);
    __Pyx_XGIVEREF(__pyx_save_exc_value);
    __Pyx_XGIVEREF(__pyx_save_exc_tb);
    __Pyx_ExceptionReset(__pyx_save_exc_type, __pyx_save_exc_value, __pyx_save_exc_tb);
    goto __pyx_L1_error;
    __pyx_L6_except_return:;
    __Pyx_XGIVEREF(__pyx_save_exc_type);
    __Pyx_XGIVEREF(__pyx_save_exc_value);
    __Pyx_XGIVEREF(__pyx_save_exc_tb);
    __Pyx_ExceptionReset(__pyx_save_exc_type, __pyx_save_exc_value, __pyx_save_exc_tb);
    goto __pyx_L0;
    __pyx_L4_exception_handled:;
    __Pyx_XGIVEREF(__pyx_save_exc_type);
    __Pyx_XGIVEREF(__pyx_save_exc_value);
    __Pyx_XGIVEREF(__pyx_save_exc_tb);
    __Pyx_ExceptionReset(__pyx_save_exc_type, __pyx_save_exc_value, __pyx_save_exc_tb);
    __pyx_L10_try_end:;
  }

  __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_WriteUnraisable("lupa._lupa.py_object_setindex_with_gil");
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_DECREF((PyObject *)__pyx_v_runtime);
  __Pyx_RefNannyFinishContext();
  #ifdef WITH_THREAD
  PyGILState_Release(_save);
  #endif
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":1096
 *         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;

  /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":1097
 * 
 * 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);

  /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":1098
 * 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));
  if (__pyx_t_1) {

    /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":1099
 *     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_28);
    goto __pyx_L0;
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":1100
 *     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 during Python str() call')  # never returns!
 */
  __pyx_v_result = __pyx_f_4lupa_5_lupa_py_object_setindex_with_gil(__pyx_v_L, __pyx_v_py_obj);

  /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":1101
 *         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 during Python str() call')  # never returns!
 *     return result
 */
  __pyx_t_1 = (__pyx_v_result < 0);
  if (__pyx_t_1) {

    /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":1102
 *     result = py_object_setindex_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_31);
    goto __pyx_L0;
    goto __pyx_L4;
  }
  __pyx_L4:;

  /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":1103
 *     if result < 0:
 *         return lua.luaL_error(L, 'error during Python str() call')  # never returns!
 *     return result             # <<<<<<<<<<<<<<
 * 
 * # special methods for Lua wrapped Python objects
 */
  __pyx_r = __pyx_v_result;
  goto __pyx_L0;

  __pyx_r = 0;
  __pyx_L0:;
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":1117
 * ## # 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;

  /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":1118
 * 
 * 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);
  if (__pyx_t_1) {

    /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":1119
 * 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_32);
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":1120
 *     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);

  /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":1121
 *         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));
  if (__pyx_t_1) {

    /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":1122
 *     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_28);
    goto __pyx_L4;
  }
  __pyx_L4:;

  /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":1123
 *     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;

  __pyx_r = 0;
  __pyx_L0:;
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":1125
 *     return py_obj
 * 
 * cdef py_object* unwrap_lua_object(lua_State* L, int n) nogil:             # <<<<<<<<<<<<<<
 *     if lua.lua_isuserdata(L, n):
 *         return <py_object*> lua.luaL_checkudata(L, n, POBJECT) # doesn't return on error!
 */

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;

  /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":1126
 * 
 * cdef py_object* unwrap_lua_object(lua_State* L, int n) nogil:
 *     if lua.lua_isuserdata(L, n):             # <<<<<<<<<<<<<<
 *         return <py_object*> lua.luaL_checkudata(L, n, POBJECT) # doesn't return on error!
 *     else:
 */
  __pyx_t_1 = lua_isuserdata(__pyx_v_L, __pyx_v_n);
  if (__pyx_t_1) {

    /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":1127
 * cdef py_object* unwrap_lua_object(lua_State* L, int n) nogil:
 *     if lua.lua_isuserdata(L, n):
 *         return <py_object*> lua.luaL_checkudata(L, n, POBJECT) # doesn't return on error!             # <<<<<<<<<<<<<<
 *     else:
 *         return unpack_wrapped_pyfunction(L, n)
 */
    __pyx_r = ((struct __pyx_t_4lupa_5_lupa_py_object *)luaL_checkudata(__pyx_v_L, __pyx_v_n, __pyx_k__POBJECT));
    goto __pyx_L0;
    goto __pyx_L3;
  }
  /*else*/ {

    /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":1129
 *         return <py_object*> lua.luaL_checkudata(L, n, POBJECT) # doesn't return on error!
 *     else:
 *         return unpack_wrapped_pyfunction(L, n)             # <<<<<<<<<<<<<<
 * 
 * cdef py_object* unwrap_lua_object_from_cclosure(lua_State* L, int n) nogil:
 */
    __pyx_r = __pyx_f_4lupa_5_lupa_unpack_wrapped_pyfunction(__pyx_v_L, __pyx_v_n);
    goto __pyx_L0;
  }
  __pyx_L3:;

  __pyx_r = 0;
  __pyx_L0:;
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":1131
 *         return unpack_wrapped_pyfunction(L, n)
 * 
 * cdef py_object* unwrap_lua_object_from_cclosure(lua_State* L, int n) nogil:             # <<<<<<<<<<<<<<
 *     cdef py_object* userdata = <py_object*> lua.lua_touserdata(L, lua.lua_upvalueindex(n))
 *     if userdata:
 */

static  struct __pyx_t_4lupa_5_lupa_py_object *__pyx_f_4lupa_5_lupa_unwrap_lua_object_from_cclosure(lua_State *__pyx_v_L, int __pyx_v_n) {
  struct __pyx_t_4lupa_5_lupa_py_object *__pyx_v_userdata;
  struct __pyx_t_4lupa_5_lupa_py_object *__pyx_r;
  int __pyx_t_1;

  /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":1132
 * 
 * cdef py_object* unwrap_lua_object_from_cclosure(lua_State* L, int n) nogil:
 *     cdef py_object* userdata = <py_object*> lua.lua_touserdata(L, lua.lua_upvalueindex(n))             # <<<<<<<<<<<<<<
 *     if userdata:
 *         return userdata
 */
  __pyx_v_userdata = ((struct __pyx_t_4lupa_5_lupa_py_object *)lua_touserdata(__pyx_v_L, lua_upvalueindex(__pyx_v_n)));

  /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":1133
 * cdef py_object* unwrap_lua_object_from_cclosure(lua_State* L, int n) nogil:
 *     cdef py_object* userdata = <py_object*> lua.lua_touserdata(L, lua.lua_upvalueindex(n))
 *     if userdata:             # <<<<<<<<<<<<<<
 *         return userdata
 *     else:
 */
  __pyx_t_1 = (__pyx_v_userdata != 0);
  if (__pyx_t_1) {

    /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":1134
 *     cdef py_object* userdata = <py_object*> lua.lua_touserdata(L, lua.lua_upvalueindex(n))
 *     if userdata:
 *         return userdata             # <<<<<<<<<<<<<<
 *     else:
 *         return unpack_wrapped_pyfunction(L, lua.lua_upvalueindex(n))
 */
    __pyx_r = __pyx_v_userdata;
    goto __pyx_L0;
    goto __pyx_L3;
  }
  /*else*/ {

    /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":1136
 *         return userdata
 *     else:
 *         return unpack_wrapped_pyfunction(L, lua.lua_upvalueindex(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, lua_upvalueindex(__pyx_v_n));
    goto __pyx_L0;
  }
  __pyx_L3:;

  __pyx_r = 0;
  __pyx_L0:;
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":1138
 *         return unpack_wrapped_pyfunction(L, lua.lua_upvalueindex(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;
  int __pyx_r;
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  int __pyx_t_4;
  #ifdef WITH_THREAD
  PyGILState_STATE _save = PyGILState_Ensure();
  #endif
  __Pyx_RefNannySetupContext("py_wrap_object_protocol_with_gil");
  __pyx_v_runtime = ((struct __pyx_obj_4lupa_5_lupa_LuaRuntime *)Py_None); __Pyx_INCREF(Py_None);

  /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":1140
 * 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)
 */
  {
    PyObject *__pyx_save_exc_type, *__pyx_save_exc_value, *__pyx_save_exc_tb;
    __Pyx_ExceptionSave(&__pyx_save_exc_type, &__pyx_save_exc_value, &__pyx_save_exc_tb);
    __Pyx_XGOTREF(__pyx_save_exc_type);
    __Pyx_XGOTREF(__pyx_save_exc_value);
    __Pyx_XGOTREF(__pyx_save_exc_tb);
    /*try:*/ {

      /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":1141
 *     cdef LuaRuntime runtime
 *     try:
 *         runtime = <LuaRuntime?>py_obj.runtime             # <<<<<<<<<<<<<<
 *         return py_to_lua_custom(runtime, L, <object>py_obj.obj, type_flags)
 *     except:
 */
      __Pyx_INCREF(((PyObject *)((struct __pyx_obj_4lupa_5_lupa_LuaRuntime *)__pyx_v_py_obj->runtime)));
      __Pyx_DECREF(((PyObject *)__pyx_v_runtime));
      __pyx_v_runtime = ((struct __pyx_obj_4lupa_5_lupa_LuaRuntime *)__pyx_v_py_obj->runtime);

      /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":1142
 *     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_r = __pyx_f_4lupa_5_lupa_py_to_lua_custom(__pyx_v_runtime, __pyx_v_L, ((PyObject *)__pyx_v_py_obj->obj), __pyx_v_type_flags);
      goto __pyx_L7_try_return;
    }
    __Pyx_XDECREF(__pyx_save_exc_type); __pyx_save_exc_type = 0;
    __Pyx_XDECREF(__pyx_save_exc_value); __pyx_save_exc_value = 0;
    __Pyx_XDECREF(__pyx_save_exc_tb); __pyx_save_exc_tb = 0;
    goto __pyx_L10_try_end;
    __pyx_L7_try_return:;
    __Pyx_XGIVEREF(__pyx_save_exc_type);
    __Pyx_XGIVEREF(__pyx_save_exc_value);
    __Pyx_XGIVEREF(__pyx_save_exc_tb);
    __Pyx_ExceptionReset(__pyx_save_exc_type, __pyx_save_exc_value, __pyx_save_exc_tb);
    goto __pyx_L0;

    /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":1143
 *         runtime = <LuaRuntime?>py_obj.runtime
 *         return py_to_lua_custom(runtime, L, <object>py_obj.obj, type_flags)
 *     except:             # <<<<<<<<<<<<<<
 *         try: runtime.store_raised_exception()
 *         except: pass
 */
    /*except:*/ {
      __Pyx_AddTraceback("lupa._lupa.py_wrap_object_protocol_with_gil");
      if (__Pyx_GetException(&__pyx_t_1, &__pyx_t_2, &__pyx_t_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1143; __pyx_clineno = __LINE__; goto __pyx_L5_except_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_GOTREF(__pyx_t_3);

      /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":1144
 *         return py_to_lua_custom(runtime, L, <object>py_obj.obj, type_flags)
 *     except:
 *         try: runtime.store_raised_exception()             # <<<<<<<<<<<<<<
 *         except: pass
 *         return -1
 */
      {
        PyObject *__pyx_save_exc_type, *__pyx_save_exc_value, *__pyx_save_exc_tb;
        __Pyx_ExceptionSave(&__pyx_save_exc_type, &__pyx_save_exc_value, &__pyx_save_exc_tb);
        __Pyx_XGOTREF(__pyx_save_exc_type);
        __Pyx_XGOTREF(__pyx_save_exc_value);
        __Pyx_XGOTREF(__pyx_save_exc_tb);
        /*try:*/ {
          __pyx_t_4 = ((struct __pyx_vtabstruct_4lupa_5_lupa_LuaRuntime *)__pyx_v_runtime->__pyx_vtab)->store_raised_exception(__pyx_v_runtime); if (unlikely(__pyx_t_4 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1144; __pyx_clineno = __LINE__; goto __pyx_L13_error;}
        }
        __Pyx_XDECREF(__pyx_save_exc_type); __pyx_save_exc_type = 0;
        __Pyx_XDECREF(__pyx_save_exc_value); __pyx_save_exc_value = 0;
        __Pyx_XDECREF(__pyx_save_exc_tb); __pyx_save_exc_tb = 0;
        goto __pyx_L20_try_end;
        __pyx_L13_error:;

        /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":1145
 *     except:
 *         try: runtime.store_raised_exception()
 *         except: pass             # <<<<<<<<<<<<<<
 *         return -1
 * 
 */
        /*except:*/ {
          PyErr_Restore(0,0,0);
          goto __pyx_L14_exception_handled;
        }
        __pyx_L14_exception_handled:;
        __Pyx_XGIVEREF(__pyx_save_exc_type);
        __Pyx_XGIVEREF(__pyx_save_exc_value);
        __Pyx_XGIVEREF(__pyx_save_exc_tb);
        __Pyx_ExceptionReset(__pyx_save_exc_type, __pyx_save_exc_value, __pyx_save_exc_tb);
        __pyx_L20_try_end:;
      }

      /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":1146
 *         try: runtime.store_raised_exception()
 *         except: pass
 *         return -1             # <<<<<<<<<<<<<<
 * 
 * cdef int py_wrap_object_protocol(lua_State* L, int type_flags) nogil:
 */
      __pyx_r = -1;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      goto __pyx_L6_except_return;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      goto __pyx_L4_exception_handled;
    }
    __pyx_L5_except_error:;
    __Pyx_XGIVEREF(__pyx_save_exc_type);
    __Pyx_XGIVEREF(__pyx_save_exc_value);
    __Pyx_XGIVEREF(__pyx_save_exc_tb);
    __Pyx_ExceptionReset(__pyx_save_exc_type, __pyx_save_exc_value, __pyx_save_exc_tb);
    goto __pyx_L1_error;
    __pyx_L6_except_return:;
    __Pyx_XGIVEREF(__pyx_save_exc_type);
    __Pyx_XGIVEREF(__pyx_save_exc_value);
    __Pyx_XGIVEREF(__pyx_save_exc_tb);
    __Pyx_ExceptionReset(__pyx_save_exc_type, __pyx_save_exc_value, __pyx_save_exc_tb);
    goto __pyx_L0;
    __pyx_L4_exception_handled:;
    __Pyx_XGIVEREF(__pyx_save_exc_type);
    __Pyx_XGIVEREF(__pyx_save_exc_value);
    __Pyx_XGIVEREF(__pyx_save_exc_tb);
    __Pyx_ExceptionReset(__pyx_save_exc_type, __pyx_save_exc_value, __pyx_save_exc_tb);
    __pyx_L10_try_end:;
  }

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_WriteUnraisable("lupa._lupa.py_wrap_object_protocol_with_gil");
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_DECREF((PyObject *)__pyx_v_runtime);
  __Pyx_RefNannyFinishContext();
  #ifdef WITH_THREAD
  PyGILState_Release(_save);
  #endif
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":1148
 *         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;

  /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":1149
 * 
 * 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);

  /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":1150
 * 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);

  /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":1151
 *     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);
  if (__pyx_t_1) {

    /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":1152
 *     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_33);
    goto __pyx_L0;
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":1153
 *     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;

  __pyx_r = 0;
  __pyx_L0:;
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":1155
 *     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;

  /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":1156
 * 
 * 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;

  __pyx_r = 0;
  __pyx_L0:;
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":1158
 *     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;

  /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":1159
 * 
 * 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;

  __pyx_r = 0;
  __pyx_L0:;
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":1161
 *     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) {
  struct __pyx_t_4lupa_5_lupa_py_object *__pyx_v_py_obj;
  int __pyx_r;

  /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":1162
 * 
 * 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);

  /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":1163
 * 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);

  /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":1164
 *     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;

  __pyx_r = 0;
  __pyx_L0:;
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":1168
 * # 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;

  /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":1169
 * 
 * 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);

  /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":1170
 * 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);

  /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":1171
 *     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);
  if (__pyx_t_1) {

    /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":1172
 *     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_34);
    goto __pyx_L0;
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":1173
 *     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;

  __pyx_r = 0;
  __pyx_L0:;
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":1175
 *     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;

  /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":1176
 * 
 * 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);

  /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":1177
 * 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);

  /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":1178
 *     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);
  if (__pyx_t_1) {

    /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":1179
 *     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_34);
    goto __pyx_L0;
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":1180
 *     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;

  __pyx_r = 0;
  __pyx_L0:;
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":1182
 *     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;

  /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":1183
 * 
 * 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);
  if (__pyx_t_1) {

    /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":1184
 * 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_32);
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":1185
 *     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);

  /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":1186
 *         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));
  if (__pyx_t_1) {

    /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":1187
 *     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_28);
    goto __pyx_L4;
  }
  __pyx_L4:;

  /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":1188
 *     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)) {
    __pyx_t_2 = lua_tonumber(__pyx_v_L, -1);
  } else {
    __pyx_t_2 = 0.0;
  }
  __pyx_v_start = __pyx_t_2;

  /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":1189
 *         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);

  /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":1190
 *     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);
  if (__pyx_t_1) {

    /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":1191
 *     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_35);
    goto __pyx_L0;
    goto __pyx_L5;
  }
  __pyx_L5:;

  /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":1192
 *     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;

  __pyx_r = 0;
  __pyx_L0:;
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":1195
 * 
 * 
 * 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;
  PyObject *__pyx_v_obj;
  int __pyx_r;
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  int __pyx_t_4;
  #ifdef WITH_THREAD
  PyGILState_STATE _save = PyGILState_Ensure();
  #endif
  __Pyx_RefNannySetupContext("py_enumerate_with_gil");
  __pyx_v_runtime = ((struct __pyx_obj_4lupa_5_lupa_LuaRuntime *)Py_None); __Pyx_INCREF(Py_None);
  __pyx_v_obj = Py_None; __Pyx_INCREF(Py_None);

  /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":1197
 * 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)
 */
  {
    PyObject *__pyx_save_exc_type, *__pyx_save_exc_value, *__pyx_save_exc_tb;
    __Pyx_ExceptionSave(&__pyx_save_exc_type, &__pyx_save_exc_value, &__pyx_save_exc_tb);
    __Pyx_XGOTREF(__pyx_save_exc_type);
    __Pyx_XGOTREF(__pyx_save_exc_value);
    __Pyx_XGOTREF(__pyx_save_exc_tb);
    /*try:*/ {

      /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":1198
 *     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_INCREF(((PyObject *)((struct __pyx_obj_4lupa_5_lupa_LuaRuntime *)__pyx_v_py_obj->runtime)));
      __Pyx_DECREF(((PyObject *)__pyx_v_runtime));
      __pyx_v_runtime = ((struct __pyx_obj_4lupa_5_lupa_LuaRuntime *)__pyx_v_py_obj->runtime);

      /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":1199
 *     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_1 = PyObject_GetIter(((PyObject *)__pyx_v_py_obj->obj)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1199; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_v_obj);
      __pyx_v_obj = __pyx_t_1;
      __pyx_t_1 = 0;

      /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":1200
 *         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_save_exc_type); __pyx_save_exc_type = 0;
    __Pyx_XDECREF(__pyx_save_exc_value); __pyx_save_exc_value = 0;
    __Pyx_XDECREF(__pyx_save_exc_tb); __pyx_save_exc_tb = 0;
    goto __pyx_L10_try_end;
    __pyx_L7_try_return:;
    __Pyx_XGIVEREF(__pyx_save_exc_type);
    __Pyx_XGIVEREF(__pyx_save_exc_value);
    __Pyx_XGIVEREF(__pyx_save_exc_tb);
    __Pyx_ExceptionReset(__pyx_save_exc_type, __pyx_save_exc_value, __pyx_save_exc_tb);
    goto __pyx_L0;
    __pyx_L3_error:;
    __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;

    /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":1201
 *         obj = iter(<object>py_obj.obj)
 *         return py_push_iterator(runtime, L, obj, OBJ_ENUMERATOR, start - 1.0)
 *     except:             # <<<<<<<<<<<<<<
 *         try: runtime.store_raised_exception()
 *         except: pass
 */
    /*except:*/ {
      __Pyx_AddTraceback("lupa._lupa.py_enumerate_with_gil");
      if (__Pyx_GetException(&__pyx_t_1, &__pyx_t_2, &__pyx_t_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1201; __pyx_clineno = __LINE__; goto __pyx_L5_except_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_GOTREF(__pyx_t_3);

      /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":1202
 *         return py_push_iterator(runtime, L, obj, OBJ_ENUMERATOR, start - 1.0)
 *     except:
 *         try: runtime.store_raised_exception()             # <<<<<<<<<<<<<<
 *         except: pass
 *         return -1
 */
      {
        PyObject *__pyx_save_exc_type, *__pyx_save_exc_value, *__pyx_save_exc_tb;
        __Pyx_ExceptionSave(&__pyx_save_exc_type, &__pyx_save_exc_value, &__pyx_save_exc_tb);
        __Pyx_XGOTREF(__pyx_save_exc_type);
        __Pyx_XGOTREF(__pyx_save_exc_value);
        __Pyx_XGOTREF(__pyx_save_exc_tb);
        /*try:*/ {
          __pyx_t_4 = ((struct __pyx_vtabstruct_4lupa_5_lupa_LuaRuntime *)__pyx_v_runtime->__pyx_vtab)->store_raised_exception(__pyx_v_runtime); if (unlikely(__pyx_t_4 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1202; __pyx_clineno = __LINE__; goto __pyx_L13_error;}
        }
        __Pyx_XDECREF(__pyx_save_exc_type); __pyx_save_exc_type = 0;
        __Pyx_XDECREF(__pyx_save_exc_value); __pyx_save_exc_value = 0;
        __Pyx_XDECREF(__pyx_save_exc_tb); __pyx_save_exc_tb = 0;
        goto __pyx_L20_try_end;
        __pyx_L13_error:;

        /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":1203
 *     except:
 *         try: runtime.store_raised_exception()
 *         except: pass             # <<<<<<<<<<<<<<
 *         return -1
 * 
 */
        /*except:*/ {
          PyErr_Restore(0,0,0);
          goto __pyx_L14_exception_handled;
        }
        __pyx_L14_exception_handled:;
        __Pyx_XGIVEREF(__pyx_save_exc_type);
        __Pyx_XGIVEREF(__pyx_save_exc_value);
        __Pyx_XGIVEREF(__pyx_save_exc_tb);
        __Pyx_ExceptionReset(__pyx_save_exc_type, __pyx_save_exc_value, __pyx_save_exc_tb);
        __pyx_L20_try_end:;
      }

      /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":1204
 *         try: runtime.store_raised_exception()
 *         except: pass
 *         return -1             # <<<<<<<<<<<<<<
 * 
 * cdef int py_iter_with_gil(lua_State* L, py_object* py_obj, int type_flags) with gil:
 */
      __pyx_r = -1;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      goto __pyx_L6_except_return;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      goto __pyx_L4_exception_handled;
    }
    __pyx_L5_except_error:;
    __Pyx_XGIVEREF(__pyx_save_exc_type);
    __Pyx_XGIVEREF(__pyx_save_exc_value);
    __Pyx_XGIVEREF(__pyx_save_exc_tb);
    __Pyx_ExceptionReset(__pyx_save_exc_type, __pyx_save_exc_value, __pyx_save_exc_tb);
    goto __pyx_L1_error;
    __pyx_L6_except_return:;
    __Pyx_XGIVEREF(__pyx_save_exc_type);
    __Pyx_XGIVEREF(__pyx_save_exc_value);
    __Pyx_XGIVEREF(__pyx_save_exc_tb);
    __Pyx_ExceptionReset(__pyx_save_exc_type, __pyx_save_exc_value, __pyx_save_exc_tb);
    goto __pyx_L0;
    __pyx_L4_exception_handled:;
    __Pyx_XGIVEREF(__pyx_save_exc_type);
    __Pyx_XGIVEREF(__pyx_save_exc_value);
    __Pyx_XGIVEREF(__pyx_save_exc_tb);
    __Pyx_ExceptionReset(__pyx_save_exc_type, __pyx_save_exc_value, __pyx_save_exc_tb);
    __pyx_L10_try_end:;
  }

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_WriteUnraisable("lupa._lupa.py_enumerate_with_gil");
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_DECREF((PyObject *)__pyx_v_runtime);
  __Pyx_DECREF(__pyx_v_obj);
  __Pyx_RefNannyFinishContext();
  #ifdef WITH_THREAD
  PyGILState_Release(_save);
  #endif
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":1206
 *         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;
  PyObject *__pyx_v_obj;
  int __pyx_r;
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  int __pyx_t_4;
  #ifdef WITH_THREAD
  PyGILState_STATE _save = PyGILState_Ensure();
  #endif
  __Pyx_RefNannySetupContext("py_iter_with_gil");
  __pyx_v_runtime = ((struct __pyx_obj_4lupa_5_lupa_LuaRuntime *)Py_None); __Pyx_INCREF(Py_None);
  __pyx_v_obj = Py_None; __Pyx_INCREF(Py_None);

  /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":1208
 * 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)
 */
  {
    PyObject *__pyx_save_exc_type, *__pyx_save_exc_value, *__pyx_save_exc_tb;
    __Pyx_ExceptionSave(&__pyx_save_exc_type, &__pyx_save_exc_value, &__pyx_save_exc_tb);
    __Pyx_XGOTREF(__pyx_save_exc_type);
    __Pyx_XGOTREF(__pyx_save_exc_value);
    __Pyx_XGOTREF(__pyx_save_exc_tb);
    /*try:*/ {

      /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":1209
 *     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_INCREF(((PyObject *)((struct __pyx_obj_4lupa_5_lupa_LuaRuntime *)__pyx_v_py_obj->runtime)));
      __Pyx_DECREF(((PyObject *)__pyx_v_runtime));
      __pyx_v_runtime = ((struct __pyx_obj_4lupa_5_lupa_LuaRuntime *)__pyx_v_py_obj->runtime);

      /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":1210
 *     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_1 = PyObject_GetIter(((PyObject *)__pyx_v_py_obj->obj)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1210; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_v_obj);
      __pyx_v_obj = __pyx_t_1;
      __pyx_t_1 = 0;

      /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":1211
 *         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_save_exc_type); __pyx_save_exc_type = 0;
    __Pyx_XDECREF(__pyx_save_exc_value); __pyx_save_exc_value = 0;
    __Pyx_XDECREF(__pyx_save_exc_tb); __pyx_save_exc_tb = 0;
    goto __pyx_L10_try_end;
    __pyx_L7_try_return:;
    __Pyx_XGIVEREF(__pyx_save_exc_type);
    __Pyx_XGIVEREF(__pyx_save_exc_value);
    __Pyx_XGIVEREF(__pyx_save_exc_tb);
    __Pyx_ExceptionReset(__pyx_save_exc_type, __pyx_save_exc_value, __pyx_save_exc_tb);
    goto __pyx_L0;
    __pyx_L3_error:;
    __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;

    /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":1212
 *         obj = iter(<object>py_obj.obj)
 *         return py_push_iterator(runtime, L, obj, type_flags, 0.0)
 *     except:             # <<<<<<<<<<<<<<
 *         try: runtime.store_raised_exception()
 *         except: pass
 */
    /*except:*/ {
      __Pyx_AddTraceback("lupa._lupa.py_iter_with_gil");
      if (__Pyx_GetException(&__pyx_t_1, &__pyx_t_2, &__pyx_t_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1212; __pyx_clineno = __LINE__; goto __pyx_L5_except_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_GOTREF(__pyx_t_3);

      /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":1213
 *         return py_push_iterator(runtime, L, obj, type_flags, 0.0)
 *     except:
 *         try: runtime.store_raised_exception()             # <<<<<<<<<<<<<<
 *         except: pass
 *         return -1
 */
      {
        PyObject *__pyx_save_exc_type, *__pyx_save_exc_value, *__pyx_save_exc_tb;
        __Pyx_ExceptionSave(&__pyx_save_exc_type, &__pyx_save_exc_value, &__pyx_save_exc_tb);
        __Pyx_XGOTREF(__pyx_save_exc_type);
        __Pyx_XGOTREF(__pyx_save_exc_value);
        __Pyx_XGOTREF(__pyx_save_exc_tb);
        /*try:*/ {
          __pyx_t_4 = ((struct __pyx_vtabstruct_4lupa_5_lupa_LuaRuntime *)__pyx_v_runtime->__pyx_vtab)->store_raised_exception(__pyx_v_runtime); if (unlikely(__pyx_t_4 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1213; __pyx_clineno = __LINE__; goto __pyx_L13_error;}
        }
        __Pyx_XDECREF(__pyx_save_exc_type); __pyx_save_exc_type = 0;
        __Pyx_XDECREF(__pyx_save_exc_value); __pyx_save_exc_value = 0;
        __Pyx_XDECREF(__pyx_save_exc_tb); __pyx_save_exc_tb = 0;
        goto __pyx_L20_try_end;
        __pyx_L13_error:;

        /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":1214
 *     except:
 *         try: runtime.store_raised_exception()
 *         except: pass             # <<<<<<<<<<<<<<
 *         return -1
 * 
 */
        /*except:*/ {
          PyErr_Restore(0,0,0);
          goto __pyx_L14_exception_handled;
        }
        __pyx_L14_exception_handled:;
        __Pyx_XGIVEREF(__pyx_save_exc_type);
        __Pyx_XGIVEREF(__pyx_save_exc_value);
        __Pyx_XGIVEREF(__pyx_save_exc_tb);
        __Pyx_ExceptionReset(__pyx_save_exc_type, __pyx_save_exc_value, __pyx_save_exc_tb);
        __pyx_L20_try_end:;
      }

      /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":1215
 *         try: runtime.store_raised_exception()
 *         except: pass
 *         return -1             # <<<<<<<<<<<<<<
 * 
 * cdef int py_push_iterator(LuaRuntime runtime, lua_State* L, iterator, int type_flags, double initial_value):
 */
      __pyx_r = -1;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      goto __pyx_L6_except_return;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      goto __pyx_L4_exception_handled;
    }
    __pyx_L5_except_error:;
    __Pyx_XGIVEREF(__pyx_save_exc_type);
    __Pyx_XGIVEREF(__pyx_save_exc_value);
    __Pyx_XGIVEREF(__pyx_save_exc_tb);
    __Pyx_ExceptionReset(__pyx_save_exc_type, __pyx_save_exc_value, __pyx_save_exc_tb);
    goto __pyx_L1_error;
    __pyx_L6_except_return:;
    __Pyx_XGIVEREF(__pyx_save_exc_type);
    __Pyx_XGIVEREF(__pyx_save_exc_value);
    __Pyx_XGIVEREF(__pyx_save_exc_tb);
    __Pyx_ExceptionReset(__pyx_save_exc_type, __pyx_save_exc_value, __pyx_save_exc_tb);
    goto __pyx_L0;
    __pyx_L4_exception_handled:;
    __Pyx_XGIVEREF(__pyx_save_exc_type);
    __Pyx_XGIVEREF(__pyx_save_exc_value);
    __Pyx_XGIVEREF(__pyx_save_exc_tb);
    __Pyx_ExceptionReset(__pyx_save_exc_type, __pyx_save_exc_value, __pyx_save_exc_tb);
    __pyx_L10_try_end:;
  }

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_WriteUnraisable("lupa._lupa.py_iter_with_gil");
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_DECREF((PyObject *)__pyx_v_runtime);
  __Pyx_DECREF(__pyx_v_obj);
  __Pyx_RefNannyFinishContext();
  #ifdef WITH_THREAD
  PyGILState_Release(_save);
  #endif
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":1217
 *         return -1
 * 
 * cdef int py_push_iterator(LuaRuntime runtime, lua_State* L, iterator, int type_flags, double initial_value):             # <<<<<<<<<<<<<<
 *     # push the wrapped iterator object into the C closure
 *     if py_to_lua_custom(runtime, L, iterator, type_flags) < 1:
 */

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, double __pyx_v_initial_value) {
  int __pyx_r;
  int __pyx_t_1;
  int __pyx_t_2;
  __Pyx_RefNannySetupContext("py_push_iterator");

  /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":1219
 * cdef int py_push_iterator(LuaRuntime runtime, lua_State* L, iterator, int type_flags, double initial_value):
 *     # push the wrapped iterator object into the C closure
 *     if py_to_lua_custom(runtime, L, iterator, type_flags) < 1:             # <<<<<<<<<<<<<<
 *         return -1
 *     lua.lua_pushcclosure(L, <lua.lua_CFunction>py_iter_next, 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);
  if (__pyx_t_1) {

    /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":1220
 *     # push the wrapped iterator object into the C closure
 *     if py_to_lua_custom(runtime, L, iterator, type_flags) < 1:
 *         return -1             # <<<<<<<<<<<<<<
 *     lua.lua_pushcclosure(L, <lua.lua_CFunction>py_iter_next, 1)
 *     # Lua needs three values: iterator C function + state + last iter value
 */
    __pyx_r = -1;
    goto __pyx_L0;
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":1221
 *     if py_to_lua_custom(runtime, L, iterator, type_flags) < 1:
 *         return -1
 *     lua.lua_pushcclosure(L, <lua.lua_CFunction>py_iter_next, 1)             # <<<<<<<<<<<<<<
 *     # Lua needs three values: iterator C function + state + last iter value
 *     lua.lua_pushnil(L)
 */
  lua_pushcclosure(__pyx_v_L, ((lua_CFunction)__pyx_f_4lupa_5_lupa_py_iter_next), 1);

  /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":1223
 *     lua.lua_pushcclosure(L, <lua.lua_CFunction>py_iter_next, 1)
 *     # Lua needs three values: iterator C function + state + last iter value
 *     lua.lua_pushnil(L)             # <<<<<<<<<<<<<<
 *     if (type_flags & OBJ_ENUMERATOR):
 *         lua.lua_pushnumber(L, initial_value)
 */
  lua_pushnil(__pyx_v_L);

  /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":1224
 *     # Lua needs three values: iterator C function + state + last iter value
 *     lua.lua_pushnil(L)
 *     if (type_flags & OBJ_ENUMERATOR):             # <<<<<<<<<<<<<<
 *         lua.lua_pushnumber(L, initial_value)
 *     else:
 */
  __pyx_t_2 = (__pyx_v_type_flags & __pyx_e_4lupa_5_lupa_OBJ_ENUMERATOR);
  if (__pyx_t_2) {

    /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":1225
 *     lua.lua_pushnil(L)
 *     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_L4;
  }
  /*else*/ {

    /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":1227
 *         lua.lua_pushnumber(L, initial_value)
 *     else:
 *         lua.lua_pushnil(L)             # <<<<<<<<<<<<<<
 *     return 3
 * 
 */
    lua_pushnil(__pyx_v_L);
  }
  __pyx_L4:;

  /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":1228
 *     else:
 *         lua.lua_pushnil(L)
 *     return 3             # <<<<<<<<<<<<<<
 * 
 * cdef int py_iter_next(lua_State* L) nogil:
 */
  __pyx_r = 3;
  goto __pyx_L0;

  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":1230
 *     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_from_cclosure(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;

  /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":1232
 * 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_from_cclosure(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_from_cclosure(__pyx_v_L, 1);

  /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":1233
 *     # first value in the C closure: the Python iterator object
 *     cdef py_object* py_obj = unwrap_lua_object_from_cclosure(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));
  if (__pyx_t_1) {

    /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":1234
 *     cdef py_object* py_obj = unwrap_lua_object_from_cclosure(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_28);
    goto __pyx_L0;
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":1235
 *     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);

  /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":1236
 *         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);
  if (__pyx_t_1) {

    /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":1237
 *     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_36);
    goto __pyx_L0;
    goto __pyx_L4;
  }
  __pyx_L4:;

  /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":1238
 *     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;

  __pyx_r = 0;
  __pyx_L0:;
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":1240
 *     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;
  PyObject *__pyx_v_obj;
  PyObject *__pyx_v_result;
  int __pyx_r;
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  int __pyx_t_4;
  int __pyx_t_5;
  Py_ssize_t __pyx_t_6;
  PyObject *__pyx_t_7 = NULL;
  #ifdef WITH_THREAD
  PyGILState_STATE _save = PyGILState_Ensure();
  #endif
  __Pyx_RefNannySetupContext("py_iter_next_with_gil");
  __pyx_v_runtime = ((struct __pyx_obj_4lupa_5_lupa_LuaRuntime *)Py_None); __Pyx_INCREF(Py_None);
  __pyx_v_obj = Py_None; __Pyx_INCREF(Py_None);
  __pyx_v_result = Py_None; __Pyx_INCREF(Py_None);

  /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":1242
 * 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
 *         if PY_VERSION_HEX >= 0x02060000:
 */
  {
    PyObject *__pyx_save_exc_type, *__pyx_save_exc_value, *__pyx_save_exc_tb;
    __Pyx_ExceptionSave(&__pyx_save_exc_type, &__pyx_save_exc_value, &__pyx_save_exc_tb);
    __Pyx_XGOTREF(__pyx_save_exc_type);
    __Pyx_XGOTREF(__pyx_save_exc_value);
    __Pyx_XGOTREF(__pyx_save_exc_tb);
    /*try:*/ {

      /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":1243
 *     cdef LuaRuntime runtime
 *     try:
 *         runtime = <LuaRuntime?>py_iter.runtime             # <<<<<<<<<<<<<<
 *         if PY_VERSION_HEX >= 0x02060000:
 *             obj = next(<object>py_iter.obj)
 */
      __Pyx_INCREF(((PyObject *)((struct __pyx_obj_4lupa_5_lupa_LuaRuntime *)__pyx_v_py_iter->runtime)));
      __Pyx_DECREF(((PyObject *)__pyx_v_runtime));
      __pyx_v_runtime = ((struct __pyx_obj_4lupa_5_lupa_LuaRuntime *)__pyx_v_py_iter->runtime);

      /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":1244
 *     try:
 *         runtime = <LuaRuntime?>py_iter.runtime
 *         if PY_VERSION_HEX >= 0x02060000:             # <<<<<<<<<<<<<<
 *             obj = next(<object>py_iter.obj)
 *         else:
 */
      __pyx_t_1 = (PY_VERSION_HEX >= 0x02060000);
      if (__pyx_t_1) {

        /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":1245
 *         runtime = <LuaRuntime?>py_iter.runtime
 *         if PY_VERSION_HEX >= 0x02060000:
 *             obj = next(<object>py_iter.obj)             # <<<<<<<<<<<<<<
 *         else:
 *             obj = (<object>py_iter.obj).next()
 */
        __pyx_t_2 = __Pyx_PyIter_Next(((PyObject *)__pyx_v_py_iter->obj)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1245; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        __Pyx_GOTREF(__pyx_t_2);
        __Pyx_DECREF(__pyx_v_obj);
        __pyx_v_obj = __pyx_t_2;
        __pyx_t_2 = 0;
        goto __pyx_L11;
      }
      /*else*/ {

        /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":1247
 *             obj = next(<object>py_iter.obj)
 *         else:
 *             obj = (<object>py_iter.obj).next()             # <<<<<<<<<<<<<<
 *         if (py_iter.type_flags & OBJ_UNPACK_TUPLE) and isinstance(obj, tuple):
 *             # special case: when the iterable returns a tuple, unpack it
 */
        __pyx_t_2 = PyObject_GetAttr(((PyObject *)__pyx_v_py_iter->obj), __pyx_n_s__next); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1247; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        __Pyx_GOTREF(__pyx_t_2);
        __pyx_t_3 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1247; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        __Pyx_GOTREF(__pyx_t_3);
        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
        __Pyx_DECREF(__pyx_v_obj);
        __pyx_v_obj = __pyx_t_3;
        __pyx_t_3 = 0;
      }
      __pyx_L11:;

      /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":1248
 *         else:
 *             obj = (<object>py_iter.obj).next()
 *         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, 1)
 */
      if ((__pyx_v_py_iter->type_flags & __pyx_e_4lupa_5_lupa_OBJ_UNPACK_TUPLE)) {
        __pyx_t_1 = PyTuple_Check(__pyx_v_obj); 
        __pyx_t_4 = __pyx_t_1;
      } else {
        __pyx_t_4 = (__pyx_v_py_iter->type_flags & __pyx_e_4lupa_5_lupa_OBJ_UNPACK_TUPLE);
      }
      if (__pyx_t_4) {

        /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":1250
 *         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, 1)             # <<<<<<<<<<<<<<
 *             return len(<tuple>obj)
 *         elif (py_iter.type_flags & OBJ_ENUMERATOR):
 */
        __pyx_t_5 = __pyx_f_4lupa_5_lupa_push_lua_arguments(__pyx_v_runtime, __pyx_v_L, ((PyObject *)__pyx_v_obj), 1); if (unlikely(__pyx_t_5 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1250; __pyx_clineno = __LINE__; goto __pyx_L3_error;}

        /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":1251
 *             # special case: when the iterable returns a tuple, unpack it
 *             push_lua_arguments(runtime, L, <tuple>obj, 1)
 *             return len(<tuple>obj)             # <<<<<<<<<<<<<<
 *         elif (py_iter.type_flags & OBJ_ENUMERATOR):
 *             lua.lua_pushnumber(L, lua.lua_tonumber(L, -1) + 1.0)
 */
        if (unlikely(((PyObject *)__pyx_v_obj) == Py_None)) {
          PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()"); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1251; __pyx_clineno = __LINE__; goto __pyx_L3_error;} 
        }
        __pyx_t_6 = PyTuple_GET_SIZE(((PyObject *)((PyObject *)__pyx_v_obj))); 
        __pyx_r = __pyx_t_6;
        goto __pyx_L7_try_return;
        goto __pyx_L12;
      }

      /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":1252
 *             push_lua_arguments(runtime, L, <tuple>obj, 1)
 *             return len(<tuple>obj)
 *         elif (py_iter.type_flags & OBJ_ENUMERATOR):             # <<<<<<<<<<<<<<
 *             lua.lua_pushnumber(L, lua.lua_tonumber(L, -1) + 1.0)
 *         result = py_to_lua(runtime, L, obj, 1)
 */
      __pyx_t_5 = (__pyx_v_py_iter->type_flags & __pyx_e_4lupa_5_lupa_OBJ_ENUMERATOR);
      if (__pyx_t_5) {

        /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":1253
 *             return len(<tuple>obj)
 *         elif (py_iter.type_flags & OBJ_ENUMERATOR):
 *             lua.lua_pushnumber(L, lua.lua_tonumber(L, -1) + 1.0)             # <<<<<<<<<<<<<<
 *         result = py_to_lua(runtime, L, obj, 1)
 *         if result < 1:
 */
        lua_pushnumber(__pyx_v_L, (lua_tonumber(__pyx_v_L, -1) + 1.0));
        goto __pyx_L12;
      }
      __pyx_L12:;

      /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":1254
 *         elif (py_iter.type_flags & OBJ_ENUMERATOR):
 *             lua.lua_pushnumber(L, lua.lua_tonumber(L, -1) + 1.0)
 *         result = py_to_lua(runtime, L, obj, 1)             # <<<<<<<<<<<<<<
 *         if result < 1:
 *             return -1
 */
      __pyx_t_5 = __pyx_f_4lupa_5_lupa_py_to_lua(__pyx_v_runtime, __pyx_v_L, __pyx_v_obj, 1); if (unlikely(__pyx_t_5 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1254; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      __pyx_t_3 = PyInt_FromLong(__pyx_t_5); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1254; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_v_result);
      __pyx_v_result = __pyx_t_3;
      __pyx_t_3 = 0;

      /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":1255
 *             lua.lua_pushnumber(L, lua.lua_tonumber(L, -1) + 1.0)
 *         result = py_to_lua(runtime, L, obj, 1)
 *         if result < 1:             # <<<<<<<<<<<<<<
 *             return -1
 *         if (py_iter.type_flags & OBJ_ENUMERATOR):
 */
      __pyx_t_3 = PyObject_RichCompare(__pyx_v_result, __pyx_int_1, Py_LT); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1255; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_4 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1255; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      if (__pyx_t_4) {

        /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":1256
 *         result = py_to_lua(runtime, L, obj, 1)
 *         if result < 1:
 *             return -1             # <<<<<<<<<<<<<<
 *         if (py_iter.type_flags & OBJ_ENUMERATOR):
 *             result += 1
 */
        __pyx_r = -1;
        goto __pyx_L7_try_return;
        goto __pyx_L13;
      }
      __pyx_L13:;

      /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":1257
 *         if result < 1:
 *             return -1
 *         if (py_iter.type_flags & OBJ_ENUMERATOR):             # <<<<<<<<<<<<<<
 *             result += 1
 *         return result
 */
      __pyx_t_5 = (__pyx_v_py_iter->type_flags & __pyx_e_4lupa_5_lupa_OBJ_ENUMERATOR);
      if (__pyx_t_5) {

        /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":1258
 *             return -1
 *         if (py_iter.type_flags & OBJ_ENUMERATOR):
 *             result += 1             # <<<<<<<<<<<<<<
 *         return result
 *     except StopIteration:
 */
        __pyx_t_3 = PyNumber_InPlaceAdd(__pyx_v_result, __pyx_int_1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1258; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        __Pyx_GOTREF(__pyx_t_3);
        __Pyx_DECREF(__pyx_v_result);
        __pyx_v_result = __pyx_t_3;
        __pyx_t_3 = 0;
        goto __pyx_L14;
      }
      __pyx_L14:;

      /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":1259
 *         if (py_iter.type_flags & OBJ_ENUMERATOR):
 *             result += 1
 *         return result             # <<<<<<<<<<<<<<
 *     except StopIteration:
 *         lua.lua_pushnil(L)
 */
      __pyx_t_5 = __Pyx_PyInt_AsInt(__pyx_v_result); if (unlikely((__pyx_t_5 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1259; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      __pyx_r = __pyx_t_5;
      goto __pyx_L7_try_return;
    }
    __Pyx_XDECREF(__pyx_save_exc_type); __pyx_save_exc_type = 0;
    __Pyx_XDECREF(__pyx_save_exc_value); __pyx_save_exc_value = 0;
    __Pyx_XDECREF(__pyx_save_exc_tb); __pyx_save_exc_tb = 0;
    goto __pyx_L10_try_end;
    __pyx_L7_try_return:;
    __Pyx_XGIVEREF(__pyx_save_exc_type);
    __Pyx_XGIVEREF(__pyx_save_exc_value);
    __Pyx_XGIVEREF(__pyx_save_exc_tb);
    __Pyx_ExceptionReset(__pyx_save_exc_type, __pyx_save_exc_value, __pyx_save_exc_tb);
    goto __pyx_L0;
    __pyx_L3_error:;
    __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;

    /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":1260
 *             result += 1
 *         return result
 *     except StopIteration:             # <<<<<<<<<<<<<<
 *         lua.lua_pushnil(L)
 *         return 1
 */
    __pyx_t_5 = PyErr_ExceptionMatches(__pyx_builtin_StopIteration);
    if (__pyx_t_5) {
      __Pyx_AddTraceback("lupa._lupa.py_iter_next_with_gil");
      if (__Pyx_GetException(&__pyx_t_3, &__pyx_t_2, &__pyx_t_7) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1260; __pyx_clineno = __LINE__; goto __pyx_L5_except_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_GOTREF(__pyx_t_7);

      /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":1261
 *         return result
 *     except StopIteration:
 *         lua.lua_pushnil(L)             # <<<<<<<<<<<<<<
 *         return 1
 *     except:
 */
      lua_pushnil(__pyx_v_L);

      /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":1262
 *     except StopIteration:
 *         lua.lua_pushnil(L)
 *         return 1             # <<<<<<<<<<<<<<
 *     except:
 *         try: runtime.store_raised_exception()
 */
      __pyx_r = 1;
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      goto __pyx_L6_except_return;
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      goto __pyx_L4_exception_handled;
    }

    /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":1263
 *         lua.lua_pushnil(L)
 *         return 1
 *     except:             # <<<<<<<<<<<<<<
 *         try: runtime.store_raised_exception()
 *         except: pass
 */
    /*except:*/ {
      __Pyx_AddTraceback("lupa._lupa.py_iter_next_with_gil");
      if (__Pyx_GetException(&__pyx_t_7, &__pyx_t_2, &__pyx_t_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1263; __pyx_clineno = __LINE__; goto __pyx_L5_except_error;}
      __Pyx_GOTREF(__pyx_t_7);
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_GOTREF(__pyx_t_3);

      /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":1264
 *         return 1
 *     except:
 *         try: runtime.store_raised_exception()             # <<<<<<<<<<<<<<
 *         except: pass
 *         return -1
 */
      {
        PyObject *__pyx_save_exc_type, *__pyx_save_exc_value, *__pyx_save_exc_tb;
        __Pyx_ExceptionSave(&__pyx_save_exc_type, &__pyx_save_exc_value, &__pyx_save_exc_tb);
        __Pyx_XGOTREF(__pyx_save_exc_type);
        __Pyx_XGOTREF(__pyx_save_exc_value);
        __Pyx_XGOTREF(__pyx_save_exc_tb);
        /*try:*/ {
          __pyx_t_5 = ((struct __pyx_vtabstruct_4lupa_5_lupa_LuaRuntime *)__pyx_v_runtime->__pyx_vtab)->store_raised_exception(__pyx_v_runtime); if (unlikely(__pyx_t_5 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1264; __pyx_clineno = __LINE__; goto __pyx_L19_error;}
        }
        __Pyx_XDECREF(__pyx_save_exc_type); __pyx_save_exc_type = 0;
        __Pyx_XDECREF(__pyx_save_exc_value); __pyx_save_exc_value = 0;
        __Pyx_XDECREF(__pyx_save_exc_tb); __pyx_save_exc_tb = 0;
        goto __pyx_L26_try_end;
        __pyx_L19_error:;

        /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":1265
 *     except:
 *         try: runtime.store_raised_exception()
 *         except: pass             # <<<<<<<<<<<<<<
 *         return -1
 * 
 */
        /*except:*/ {
          PyErr_Restore(0,0,0);
          goto __pyx_L20_exception_handled;
        }
        __pyx_L20_exception_handled:;
        __Pyx_XGIVEREF(__pyx_save_exc_type);
        __Pyx_XGIVEREF(__pyx_save_exc_value);
        __Pyx_XGIVEREF(__pyx_save_exc_tb);
        __Pyx_ExceptionReset(__pyx_save_exc_type, __pyx_save_exc_value, __pyx_save_exc_tb);
        __pyx_L26_try_end:;
      }

      /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":1266
 *         try: runtime.store_raised_exception()
 *         except: pass
 *         return -1             # <<<<<<<<<<<<<<
 * 
 * # 'python' module functions in Lua
 */
      __pyx_r = -1;
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      goto __pyx_L6_except_return;
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      goto __pyx_L4_exception_handled;
    }
    __pyx_L5_except_error:;
    __Pyx_XGIVEREF(__pyx_save_exc_type);
    __Pyx_XGIVEREF(__pyx_save_exc_value);
    __Pyx_XGIVEREF(__pyx_save_exc_tb);
    __Pyx_ExceptionReset(__pyx_save_exc_type, __pyx_save_exc_value, __pyx_save_exc_tb);
    goto __pyx_L1_error;
    __pyx_L6_except_return:;
    __Pyx_XGIVEREF(__pyx_save_exc_type);
    __Pyx_XGIVEREF(__pyx_save_exc_value);
    __Pyx_XGIVEREF(__pyx_save_exc_tb);
    __Pyx_ExceptionReset(__pyx_save_exc_type, __pyx_save_exc_value, __pyx_save_exc_tb);
    goto __pyx_L0;
    __pyx_L4_exception_handled:;
    __Pyx_XGIVEREF(__pyx_save_exc_type);
    __Pyx_XGIVEREF(__pyx_save_exc_value);
    __Pyx_XGIVEREF(__pyx_save_exc_tb);
    __Pyx_ExceptionReset(__pyx_save_exc_type, __pyx_save_exc_value, __pyx_save_exc_tb);
    __pyx_L10_try_end:;
  }

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_WriteUnraisable("lupa._lupa.py_iter_next_with_gil");
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_DECREF((PyObject *)__pyx_v_runtime);
  __Pyx_DECREF(__pyx_v_obj);
  __Pyx_DECREF(__pyx_v_result);
  __Pyx_RefNannyFinishContext();
  #ifdef WITH_THREAD
  PyGILState_Release(_save);
  #endif
  return __pyx_r;
}
static struct __pyx_vtabstruct_4lupa_5_lupa__LuaObject __pyx_vtable_4lupa_5_lupa__LuaObject;

static PyObject *__pyx_tp_new_4lupa_5_lupa__LuaObject(PyTypeObject *t, PyObject *a, PyObject *k) {
  struct __pyx_obj_4lupa_5_lupa__LuaObject *p;
  PyObject *o = (*t->tp_alloc)(t, 0);
  if (!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;
  {
    PyObject *etype, *eval, *etb;
    PyErr_Fetch(&etype, &eval, &etb);
    ++Py_REFCNT(o);
    __pyx_pf_4lupa_5_lupa_10_LuaObject___dealloc__(o);
    if (PyErr_Occurred()) PyErr_WriteUnraisable(o);
    --Py_REFCNT(o);
    PyErr_Restore(etype, eval, etb);
  }
  Py_XDECREF(((PyObject *)p->_runtime));
  (*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 int __pyx_tp_clear_4lupa_5_lupa__LuaObject(PyObject *o) {
  struct __pyx_obj_4lupa_5_lupa__LuaObject *p = (struct __pyx_obj_4lupa_5_lupa__LuaObject *)o;
  PyObject* tmp;
  tmp = ((PyObject*)p->_runtime);
  p->_runtime = ((struct __pyx_obj_4lupa_5_lupa_LuaRuntime *)Py_None); Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  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 int __pyx_mp_ass_subscript_4lupa_5_lupa__LuaObject(PyObject *o, PyObject *i, PyObject *v) {
  if (v) {
    return __pyx_pf_4lupa_5_lupa_10_LuaObject___setitem__(o, i, v);
  }
  else {
    PyErr_Format(PyExc_NotImplementedError,
      "Subscript deletion not supported by %s", Py_TYPE(o)->tp_name);
    return -1;
  }
}

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_pf_4lupa_5_lupa_10_LuaObject___getattr__(o, n);
  }
  return v;
}

static int __pyx_tp_setattro_4lupa_5_lupa__LuaObject(PyObject *o, PyObject *n, PyObject *v) {
  if (v) {
    return __pyx_pf_4lupa_5_lupa_10_LuaObject___setattr__(o, n, v);
  }
  else {
    return PyObject_GenericSetAttr(o, n, 0);
  }
}

static PyMethodDef __pyx_methods_4lupa_5_lupa__LuaObject[] = {
  {__Pyx_NAMESTR("__getattr__"), (PyCFunction)__pyx_pf_4lupa_5_lupa_10_LuaObject___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_pf_4lupa_5_lupa_10_LuaObject___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_pf_4lupa_5_lupa_10_LuaObject___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_pf_4lupa_5_lupa_10_LuaObject___len__, /*mp_length*/
  __pyx_pf_4lupa_5_lupa_10_LuaObject___getitem__, /*mp_subscript*/
  __pyx_mp_ass_subscript_4lupa_5_lupa__LuaObject, /*mp_ass_subscript*/
};

static PyBufferProcs __pyx_tp_as_buffer__LuaObject = {
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getreadbuffer*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getwritebuffer*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getsegcount*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getcharbuffer*/
  #endif
  #if PY_VERSION_HEX >= 0x02060000
  0, /*bf_getbuffer*/
  #endif
  #if PY_VERSION_HEX >= 0x02060000
  0, /*bf_releasebuffer*/
  #endif
};

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_pf_4lupa_5_lupa_10_LuaObject___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_pf_4lupa_5_lupa_10_LuaObject___call__, /*tp_call*/
  __pyx_pf_4lupa_5_lupa_10_LuaObject___str__, /*tp_str*/
  __pyx_tp_getattro_4lupa_5_lupa__LuaObject, /*tp_getattro*/
  __pyx_tp_setattro_4lupa_5_lupa__LuaObject, /*tp_setattro*/
  &__pyx_tp_as_buffer__LuaObject, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|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 of function.\n    "), /*tp_doc*/
  __pyx_tp_traverse_4lupa_5_lupa__LuaObject, /*tp_traverse*/
  __pyx_tp_clear_4lupa_5_lupa__LuaObject, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  __pyx_pf_4lupa_5_lupa_10_LuaObject___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_pf_4lupa_5_lupa_10_LuaObject___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
};

static PyObject *__pyx_tp_new_4lupa_5_lupa_FastRLock(PyTypeObject *t, PyObject *a, PyObject *k) {
  PyObject *o = (*t->tp_alloc)(t, 0);
  if (!o) return 0;
  if (__pyx_pf_4lupa_5_lupa_9FastRLock___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) {
  {
    PyObject *etype, *eval, *etb;
    PyErr_Fetch(&etype, &eval, &etb);
    ++Py_REFCNT(o);
    __pyx_pf_4lupa_5_lupa_9FastRLock___dealloc__(o);
    if (PyErr_Occurred()) PyErr_WriteUnraisable(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_pf_4lupa_5_lupa_9FastRLock_acquire, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(__pyx_doc_4lupa_5_lupa_9FastRLock_acquire)},
  {__Pyx_NAMESTR("release"), (PyCFunction)__pyx_pf_4lupa_5_lupa_9FastRLock_release, METH_NOARGS, __Pyx_DOCSTR(__pyx_doc_4lupa_5_lupa_9FastRLock_release)},
  {__Pyx_NAMESTR("__enter__"), (PyCFunction)__pyx_pf_4lupa_5_lupa_9FastRLock___enter__, METH_NOARGS, __Pyx_DOCSTR(__pyx_doc_4lupa_5_lupa_9FastRLock___enter__)},
  {__Pyx_NAMESTR("__exit__"), (PyCFunction)__pyx_pf_4lupa_5_lupa_9FastRLock___exit__, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(__pyx_doc_4lupa_5_lupa_9FastRLock___exit__)},
  {__Pyx_NAMESTR("_is_owned"), (PyCFunction)__pyx_pf_4lupa_5_lupa_9FastRLock__is_owned, METH_NOARGS, __Pyx_DOCSTR(__pyx_doc_4lupa_5_lupa_9FastRLock__is_owned)},
  {0, 0, 0, 0}
};

static PyNumberMethods __pyx_tp_as_number_FastRLock = {
  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*/
  0, /*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_FastRLock = {
  0, /*sq_length*/
  0, /*sq_concat*/
  0, /*sq_repeat*/
  0, /*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_FastRLock = {
  0, /*mp_length*/
  0, /*mp_subscript*/
  0, /*mp_ass_subscript*/
};

static PyBufferProcs __pyx_tp_as_buffer_FastRLock = {
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getreadbuffer*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getwritebuffer*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getsegcount*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getcharbuffer*/
  #endif
  #if PY_VERSION_HEX >= 0x02060000
  0, /*bf_getbuffer*/
  #endif
  #if PY_VERSION_HEX >= 0x02060000
  0, /*bf_releasebuffer*/
  #endif
};

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*/
  &__pyx_tp_as_number_FastRLock, /*tp_as_number*/
  &__pyx_tp_as_sequence_FastRLock, /*tp_as_sequence*/
  &__pyx_tp_as_mapping_FastRLock, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  &__pyx_tp_as_buffer_FastRLock, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|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
};
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 = (*t->tp_alloc)(t, 0);
  if (!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->_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);
  if (__pyx_pf_4lupa_5_lupa_10LuaRuntime___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;
  {
    PyObject *etype, *eval, *etb;
    PyErr_Fetch(&etype, &eval, &etb);
    ++Py_REFCNT(o);
    __pyx_pf_4lupa_5_lupa_10LuaRuntime___dealloc__(o);
    if (PyErr_Occurred()) PyErr_WriteUnraisable(o);
    --Py_REFCNT(o);
    PyErr_Restore(etype, eval, etb);
  }
  Py_XDECREF(((PyObject *)p->_lock));
  Py_XDECREF(((PyObject *)p->_raised_exception));
  Py_XDECREF(((PyObject *)p->_encoding));
  Py_XDECREF(((PyObject *)p->_source_encoding));
  (*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->_raised_exception) {
    e = (*v)(p->_raised_exception, a); if (e) return e;
  }
  if (p->_encoding) {
    e = (*v)(p->_encoding, a); if (e) return e;
  }
  if (p->_source_encoding) {
    e = (*v)(p->_source_encoding, a); if (e) return e;
  }
  return 0;
}

static int __pyx_tp_clear_4lupa_5_lupa_LuaRuntime(PyObject *o) {
  struct __pyx_obj_4lupa_5_lupa_LuaRuntime *p = (struct __pyx_obj_4lupa_5_lupa_LuaRuntime *)o;
  PyObject* tmp;
  tmp = ((PyObject*)p->_lock);
  p->_lock = ((struct __pyx_obj_4lupa_5_lupa_FastRLock *)Py_None); Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->_raised_exception);
  p->_raised_exception = ((PyObject *)Py_None); Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->_encoding);
  p->_encoding = ((PyObject *)Py_None); Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->_source_encoding);
  p->_source_encoding = ((PyObject *)Py_None); Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  return 0;
}

static PyMethodDef __pyx_methods_4lupa_5_lupa_LuaRuntime[] = {
  {__Pyx_NAMESTR("eval"), (PyCFunction)__pyx_pf_4lupa_5_lupa_10LuaRuntime_eval, METH_O, __Pyx_DOCSTR(__pyx_doc_4lupa_5_lupa_10LuaRuntime_eval)},
  {__Pyx_NAMESTR("execute"), (PyCFunction)__pyx_pf_4lupa_5_lupa_10LuaRuntime_execute, METH_O, __Pyx_DOCSTR(__pyx_doc_4lupa_5_lupa_10LuaRuntime_execute)},
  {__Pyx_NAMESTR("require"), (PyCFunction)__pyx_pf_4lupa_5_lupa_10LuaRuntime_require, METH_O, __Pyx_DOCSTR(__pyx_doc_4lupa_5_lupa_10LuaRuntime_require)},
  {__Pyx_NAMESTR("globals"), (PyCFunction)__pyx_pf_4lupa_5_lupa_10LuaRuntime_globals, METH_NOARGS, __Pyx_DOCSTR(__pyx_doc_4lupa_5_lupa_10LuaRuntime_globals)},
  {__Pyx_NAMESTR("table"), (PyCFunction)__pyx_pf_4lupa_5_lupa_10LuaRuntime_table, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(__pyx_doc_4lupa_5_lupa_10LuaRuntime_table)},
  {0, 0, 0, 0}
};

static PyNumberMethods __pyx_tp_as_number_LuaRuntime = {
  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*/
  0, /*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_LuaRuntime = {
  0, /*sq_length*/
  0, /*sq_concat*/
  0, /*sq_repeat*/
  0, /*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_LuaRuntime = {
  0, /*mp_length*/
  0, /*mp_subscript*/
  0, /*mp_ass_subscript*/
};

static PyBufferProcs __pyx_tp_as_buffer_LuaRuntime = {
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getreadbuffer*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getwritebuffer*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getsegcount*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getcharbuffer*/
  #endif
  #if PY_VERSION_HEX >= 0x02060000
  0, /*bf_getbuffer*/
  #endif
  #if PY_VERSION_HEX >= 0x02060000
  0, /*bf_releasebuffer*/
  #endif
};

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*/
  &__pyx_tp_as_number_LuaRuntime, /*tp_as_number*/
  &__pyx_tp_as_sequence_LuaRuntime, /*tp_as_sequence*/
  &__pyx_tp_as_mapping_LuaRuntime, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  &__pyx_tp_as_buffer_LuaRuntime, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|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    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*/
  __pyx_tp_clear_4lupa_5_lupa_LuaRuntime, /*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
};
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 (!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 PyMethodDef __pyx_methods_4lupa_5_lupa__LuaTable[] = {
  {__Pyx_NAMESTR("keys"), (PyCFunction)__pyx_pf_4lupa_5_lupa_9_LuaTable_keys, METH_NOARGS, __Pyx_DOCSTR(__pyx_doc_4lupa_5_lupa_9_LuaTable_keys)},
  {__Pyx_NAMESTR("values"), (PyCFunction)__pyx_pf_4lupa_5_lupa_9_LuaTable_values, METH_NOARGS, __Pyx_DOCSTR(__pyx_doc_4lupa_5_lupa_9_LuaTable_values)},
  {__Pyx_NAMESTR("items"), (PyCFunction)__pyx_pf_4lupa_5_lupa_9_LuaTable_items, METH_NOARGS, __Pyx_DOCSTR(__pyx_doc_4lupa_5_lupa_9_LuaTable_items)},
  {0, 0, 0, 0}
};

static PyNumberMethods __pyx_tp_as_number__LuaTable = {
  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*/
  0, /*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__LuaTable = {
  0, /*sq_length*/
  0, /*sq_concat*/
  0, /*sq_repeat*/
  0, /*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__LuaTable = {
  0, /*mp_length*/
  0, /*mp_subscript*/
  0, /*mp_ass_subscript*/
};

static PyBufferProcs __pyx_tp_as_buffer__LuaTable = {
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getreadbuffer*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getwritebuffer*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getsegcount*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getcharbuffer*/
  #endif
  #if PY_VERSION_HEX >= 0x02060000
  0, /*bf_getbuffer*/
  #endif
  #if PY_VERSION_HEX >= 0x02060000
  0, /*bf_releasebuffer*/
  #endif
};

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
  0, /*tp_repr*/
  &__pyx_tp_as_number__LuaTable, /*tp_as_number*/
  &__pyx_tp_as_sequence__LuaTable, /*tp_as_sequence*/
  &__pyx_tp_as_mapping__LuaTable, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  &__pyx_tp_as_buffer__LuaTable, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  0, /*tp_doc*/
  __pyx_tp_traverse_4lupa_5_lupa__LuaObject, /*tp_traverse*/
  __pyx_tp_clear_4lupa_5_lupa__LuaObject, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  __pyx_pf_4lupa_5_lupa_9_LuaTable___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*/
  0, /*tp_init*/
  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
};
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 (!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_pf_4lupa_5_lupa_12_LuaFunction_coroutine, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(__pyx_doc_4lupa_5_lupa_12_LuaFunction_coroutine)},
  {0, 0, 0, 0}
};

static PyNumberMethods __pyx_tp_as_number__LuaFunction = {
  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*/
  0, /*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__LuaFunction = {
  0, /*sq_length*/
  0, /*sq_concat*/
  0, /*sq_repeat*/
  0, /*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__LuaFunction = {
  0, /*mp_length*/
  0, /*mp_subscript*/
  0, /*mp_ass_subscript*/
};

static PyBufferProcs __pyx_tp_as_buffer__LuaFunction = {
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getreadbuffer*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getwritebuffer*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getsegcount*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getcharbuffer*/
  #endif
  #if PY_VERSION_HEX >= 0x02060000
  0, /*bf_getbuffer*/
  #endif
  #if PY_VERSION_HEX >= 0x02060000
  0, /*bf_releasebuffer*/
  #endif
};

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
  0, /*tp_repr*/
  &__pyx_tp_as_number__LuaFunction, /*tp_as_number*/
  &__pyx_tp_as_sequence__LuaFunction, /*tp_as_sequence*/
  &__pyx_tp_as_mapping__LuaFunction, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  &__pyx_tp_as_buffer__LuaFunction, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|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*/
  __pyx_tp_clear_4lupa_5_lupa__LuaObject, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  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*/
  0, /*tp_init*/
  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
};
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__LuaObject(t, a, k);
  if (!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 PyNumberMethods __pyx_tp_as_number__LuaCoroutineFunction = {
  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*/
  0, /*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__LuaCoroutineFunction = {
  0, /*sq_length*/
  0, /*sq_concat*/
  0, /*sq_repeat*/
  0, /*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__LuaCoroutineFunction = {
  0, /*mp_length*/
  0, /*mp_subscript*/
  0, /*mp_ass_subscript*/
};

static PyBufferProcs __pyx_tp_as_buffer__LuaCoroutineFunction = {
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getreadbuffer*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getwritebuffer*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getsegcount*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getcharbuffer*/
  #endif
  #if PY_VERSION_HEX >= 0x02060000
  0, /*bf_getbuffer*/
  #endif
  #if PY_VERSION_HEX >= 0x02060000
  0, /*bf_releasebuffer*/
  #endif
};

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
  0, /*tp_repr*/
  &__pyx_tp_as_number__LuaCoroutineFunction, /*tp_as_number*/
  &__pyx_tp_as_sequence__LuaCoroutineFunction, /*tp_as_sequence*/
  &__pyx_tp_as_mapping__LuaCoroutineFunction, /*tp_as_mapping*/
  0, /*tp_hash*/
  __pyx_pf_4lupa_5_lupa_21_LuaCoroutineFunction___call__, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  &__pyx_tp_as_buffer__LuaCoroutineFunction, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE|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*/
  __pyx_tp_clear_4lupa_5_lupa__LuaObject, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  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*/
  0, /*tp_init*/
  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
};
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 (!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;
  Py_XDECREF(((PyObject *)p->_arguments));
  __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 int __pyx_tp_clear_4lupa_5_lupa__LuaThread(PyObject *o) {
  struct __pyx_obj_4lupa_5_lupa__LuaThread *p = (struct __pyx_obj_4lupa_5_lupa__LuaThread *)o;
  PyObject* tmp;
  __pyx_tp_clear_4lupa_5_lupa__LuaObject(o);
  tmp = ((PyObject*)p->_arguments);
  p->_arguments = ((PyObject *)Py_None); Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  return 0;
}

static PyMethodDef __pyx_methods_4lupa_5_lupa__LuaThread[] = {
  {__Pyx_NAMESTR("__next__"), (PyCFunction)__pyx_pf_4lupa_5_lupa_10_LuaThread___next__, METH_NOARGS|METH_COEXIST, __Pyx_DOCSTR(0)},
  {__Pyx_NAMESTR("send"), (PyCFunction)__pyx_pf_4lupa_5_lupa_10_LuaThread_send, METH_O, __Pyx_DOCSTR(__pyx_doc_4lupa_5_lupa_10_LuaThread_send)},
  {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_pf_4lupa_5_lupa_10_LuaThread___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 PySequenceMethods __pyx_tp_as_sequence__LuaThread = {
  0, /*sq_length*/
  0, /*sq_concat*/
  0, /*sq_repeat*/
  0, /*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__LuaThread = {
  0, /*mp_length*/
  0, /*mp_subscript*/
  0, /*mp_ass_subscript*/
};

static PyBufferProcs __pyx_tp_as_buffer__LuaThread = {
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getreadbuffer*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getwritebuffer*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getsegcount*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getcharbuffer*/
  #endif
  #if PY_VERSION_HEX >= 0x02060000
  0, /*bf_getbuffer*/
  #endif
  #if PY_VERSION_HEX >= 0x02060000
  0, /*bf_releasebuffer*/
  #endif
};

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
  0, /*tp_repr*/
  &__pyx_tp_as_number__LuaThread, /*tp_as_number*/
  &__pyx_tp_as_sequence__LuaThread, /*tp_as_sequence*/
  &__pyx_tp_as_mapping__LuaThread, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  &__pyx_tp_as_buffer__LuaThread, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  __Pyx_DOCSTR("A Lua thread (coroutine).\n    "), /*tp_doc*/
  __pyx_tp_traverse_4lupa_5_lupa__LuaThread, /*tp_traverse*/
  __pyx_tp_clear_4lupa_5_lupa__LuaThread, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  __pyx_pf_4lupa_5_lupa_10_LuaThread___iter__, /*tp_iter*/
  __pyx_pf_4lupa_5_lupa_10_LuaThread___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*/
  0, /*tp_init*/
  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
};

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 = (*t->tp_alloc)(t, 0);
  if (!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 (__pyx_pf_4lupa_5_lupa_8_LuaIter___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 *etype, *eval, *etb;
    PyErr_Fetch(&etype, &eval, &etb);
    ++Py_REFCNT(o);
    __pyx_pf_4lupa_5_lupa_8_LuaIter___dealloc__(o);
    if (PyErr_Occurred()) PyErr_WriteUnraisable(o);
    --Py_REFCNT(o);
    PyErr_Restore(etype, eval, etb);
  }
  Py_XDECREF(((PyObject *)p->_runtime));
  Py_XDECREF(((PyObject *)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 int __pyx_tp_clear_4lupa_5_lupa__LuaIter(PyObject *o) {
  struct __pyx_obj_4lupa_5_lupa__LuaIter *p = (struct __pyx_obj_4lupa_5_lupa__LuaIter *)o;
  PyObject* tmp;
  tmp = ((PyObject*)p->_runtime);
  p->_runtime = ((struct __pyx_obj_4lupa_5_lupa_LuaRuntime *)Py_None); Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->_obj);
  p->_obj = ((struct __pyx_obj_4lupa_5_lupa__LuaObject *)Py_None); Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  return 0;
}

static PyMethodDef __pyx_methods_4lupa_5_lupa__LuaIter[] = {
  {__Pyx_NAMESTR("__next__"), (PyCFunction)__pyx_pf_4lupa_5_lupa_8_LuaIter___next__, METH_NOARGS|METH_COEXIST, __Pyx_DOCSTR(0)},
  {0, 0, 0, 0}
};

static PyNumberMethods __pyx_tp_as_number__LuaIter = {
  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*/
  0, /*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__LuaIter = {
  0, /*sq_length*/
  0, /*sq_concat*/
  0, /*sq_repeat*/
  0, /*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__LuaIter = {
  0, /*mp_length*/
  0, /*mp_subscript*/
  0, /*mp_ass_subscript*/
};

static PyBufferProcs __pyx_tp_as_buffer__LuaIter = {
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getreadbuffer*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getwritebuffer*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getsegcount*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getcharbuffer*/
  #endif
  #if PY_VERSION_HEX >= 0x02060000
  0, /*bf_getbuffer*/
  #endif
  #if PY_VERSION_HEX >= 0x02060000
  0, /*bf_releasebuffer*/
  #endif
};

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_pf_4lupa_5_lupa_8_LuaIter___repr__, /*tp_repr*/
  &__pyx_tp_as_number__LuaIter, /*tp_as_number*/
  &__pyx_tp_as_sequence__LuaIter, /*tp_as_sequence*/
  &__pyx_tp_as_mapping__LuaIter, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  &__pyx_tp_as_buffer__LuaIter, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  0, /*tp_doc*/
  __pyx_tp_traverse_4lupa_5_lupa__LuaIter, /*tp_traverse*/
  __pyx_tp_clear_4lupa_5_lupa__LuaIter, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  __pyx_pf_4lupa_5_lupa_8_LuaIter___iter__, /*tp_iter*/
  __pyx_pf_4lupa_5_lupa_8_LuaIter___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
};

static PyObject *__pyx_tp_new_4lupa_5_lupa__PyProtocolWrapper(PyTypeObject *t, PyObject *a, PyObject *k) {
  struct __pyx_obj_4lupa_5_lupa__PyProtocolWrapper *p;
  PyObject *o = (*t->tp_alloc)(t, 0);
  if (!o) return 0;
  p = ((struct __pyx_obj_4lupa_5_lupa__PyProtocolWrapper *)o);
  p->_obj = Py_None; Py_INCREF(Py_None);
  if (__pyx_pf_4lupa_5_lupa_18_PyProtocolWrapper___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;
  Py_XDECREF(p->_obj);
  (*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) {
  struct __pyx_obj_4lupa_5_lupa__PyProtocolWrapper *p = (struct __pyx_obj_4lupa_5_lupa__PyProtocolWrapper *)o;
  PyObject* tmp;
  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 PyNumberMethods __pyx_tp_as_number__PyProtocolWrapper = {
  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*/
  0, /*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__PyProtocolWrapper = {
  0, /*sq_length*/
  0, /*sq_concat*/
  0, /*sq_repeat*/
  0, /*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__PyProtocolWrapper = {
  0, /*mp_length*/
  0, /*mp_subscript*/
  0, /*mp_ass_subscript*/
};

static PyBufferProcs __pyx_tp_as_buffer__PyProtocolWrapper = {
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getreadbuffer*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getwritebuffer*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getsegcount*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getcharbuffer*/
  #endif
  #if PY_VERSION_HEX >= 0x02060000
  0, /*bf_getbuffer*/
  #endif
  #if PY_VERSION_HEX >= 0x02060000
  0, /*bf_releasebuffer*/
  #endif
};

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*/
  &__pyx_tp_as_number__PyProtocolWrapper, /*tp_as_number*/
  &__pyx_tp_as_sequence__PyProtocolWrapper, /*tp_as_sequence*/
  &__pyx_tp_as_mapping__PyProtocolWrapper, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  &__pyx_tp_as_buffer__PyProtocolWrapper, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE|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_pf_4lupa_5_lupa_18_PyProtocolWrapper___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
};

static PyMethodDef __pyx_methods[] = {
  {__Pyx_NAMESTR("as_attrgetter"), (PyCFunction)__pyx_pf_4lupa_5_lupa_as_attrgetter, METH_O, __Pyx_DOCSTR(__pyx_doc_4lupa_5_lupa_as_attrgetter)},
  {__Pyx_NAMESTR("as_itemgetter"), (PyCFunction)__pyx_pf_4lupa_5_lupa_as_itemgetter, METH_O, __Pyx_DOCSTR(__pyx_doc_4lupa_5_lupa_as_itemgetter)},
  {0, 0, 0, 0}
};

#if PY_MAJOR_VERSION >= 3
static struct PyModuleDef __pyx_moduledef = {
    PyModuleDef_HEAD_INIT,
    __Pyx_NAMESTR("_lupa"),
    __Pyx_DOCSTR(__pyx_k_37), /* 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_kp_s_1, __pyx_k_1, sizeof(__pyx_k_1), 0, 0, 1, 0},
  {&__pyx_kp_s_10, __pyx_k_10, sizeof(__pyx_k_10), 0, 0, 1, 0},
  {&__pyx_kp_s_11, __pyx_k_11, sizeof(__pyx_k_11), 0, 0, 1, 0},
  {&__pyx_kp_s_12, __pyx_k_12, sizeof(__pyx_k_12), 0, 0, 1, 0},
  {&__pyx_kp_s_13, __pyx_k_13, sizeof(__pyx_k_13), 0, 0, 1, 0},
  {&__pyx_kp_s_14, __pyx_k_14, sizeof(__pyx_k_14), 0, 0, 1, 0},
  {&__pyx_kp_s_17, __pyx_k_17, sizeof(__pyx_k_17), 0, 0, 1, 0},
  {&__pyx_kp_s_18, __pyx_k_18, sizeof(__pyx_k_18), 0, 0, 1, 0},
  {&__pyx_kp_s_19, __pyx_k_19, sizeof(__pyx_k_19), 0, 0, 1, 0},
  {&__pyx_kp_b_2, __pyx_k_2, sizeof(__pyx_k_2), 0, 0, 0, 0},
  {&__pyx_kp_s_2, __pyx_k_2, sizeof(__pyx_k_2), 0, 0, 1, 0},
  {&__pyx_kp_u_20, __pyx_k_20, sizeof(__pyx_k_20), 0, 1, 0, 0},
  {&__pyx_kp_s_22, __pyx_k_22, sizeof(__pyx_k_22), 0, 0, 1, 0},
  {&__pyx_kp_s_23, __pyx_k_23, sizeof(__pyx_k_23), 0, 0, 1, 0},
  {&__pyx_kp_u_25, __pyx_k_25, sizeof(__pyx_k_25), 0, 1, 0, 0},
  {&__pyx_n_s_26, __pyx_k_26, sizeof(__pyx_k_26), 0, 0, 1, 1},
  {&__pyx_kp_s_27, __pyx_k_27, sizeof(__pyx_k_27), 0, 0, 1, 0},
  {&__pyx_kp_s_28, __pyx_k_28, sizeof(__pyx_k_28), 0, 0, 1, 0},
  {&__pyx_n_s_29, __pyx_k_29, sizeof(__pyx_k_29), 0, 0, 1, 1},
  {&__pyx_kp_s_3, __pyx_k_3, sizeof(__pyx_k_3), 0, 0, 1, 0},
  {&__pyx_kp_s_38, __pyx_k_38, sizeof(__pyx_k_38), 0, 0, 1, 0},
  {&__pyx_n_s_39, __pyx_k_39, sizeof(__pyx_k_39), 0, 0, 1, 1},
  {&__pyx_kp_b_4, __pyx_k_4, sizeof(__pyx_k_4), 0, 0, 0, 0},
  {&__pyx_kp_s_40, __pyx_k_40, sizeof(__pyx_k_40), 0, 0, 1, 0},
  {&__pyx_kp_s_5, __pyx_k_5, sizeof(__pyx_k_5), 0, 0, 1, 0},
  {&__pyx_kp_s_6, __pyx_k_6, sizeof(__pyx_k_6), 0, 0, 1, 0},
  {&__pyx_kp_s_7, __pyx_k_7, sizeof(__pyx_k_7), 0, 0, 1, 0},
  {&__pyx_kp_s_8, __pyx_k_8, sizeof(__pyx_k_8), 0, 0, 1, 0},
  {&__pyx_kp_s_9, __pyx_k_9, sizeof(__pyx_k_9), 0, 0, 1, 0},
  {&__pyx_n_s__ASCII, __pyx_k__ASCII, sizeof(__pyx_k__ASCII), 0, 0, 1, 1},
  {&__pyx_n_s__Exception, __pyx_k__Exception, sizeof(__pyx_k__Exception), 0, 0, 1, 1},
  {&__pyx_n_s__ImportError, __pyx_k__ImportError, sizeof(__pyx_k__ImportError), 0, 0, 1, 1},
  {&__pyx_n_s__LuaError, __pyx_k__LuaError, sizeof(__pyx_k__LuaError), 0, 0, 1, 1},
  {&__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_n_s__PyErr_NoMemory, __pyx_k__PyErr_NoMemory, sizeof(__pyx_k__PyErr_NoMemory), 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_n_s__TypeError, __pyx_k__TypeError, sizeof(__pyx_k__TypeError), 0, 0, 1, 1},
  {&__pyx_n_s__UnicodeDecodeError, __pyx_k__UnicodeDecodeError, sizeof(__pyx_k__UnicodeDecodeError), 0, 0, 1, 1},
  {&__pyx_n_b____, __pyx_k____, sizeof(__pyx_k____), 0, 0, 0, 1},
  {&__pyx_n_u____, __pyx_k____, sizeof(__pyx_k____), 0, 1, 0, 1},
  {&__pyx_n_s____all__, __pyx_k____all__, sizeof(__pyx_k____all__), 0, 0, 1, 1},
  {&__pyx_n_s____builtin__, __pyx_k____builtin__, sizeof(__pyx_k____builtin__), 0, 0, 1, 1},
  {&__pyx_n_s____getattr__, __pyx_k____getattr__, sizeof(__pyx_k____getattr__), 0, 0, 1, 1},
  {&__pyx_n_s____getitem__, __pyx_k____getitem__, sizeof(__pyx_k____getitem__), 0, 0, 1, 1},
  {&__pyx_n_s____main__, __pyx_k____main__, sizeof(__pyx_k____main__), 0, 0, 1, 1},
  {&__pyx_n_s____setattr__, __pyx_k____setattr__, sizeof(__pyx_k____setattr__), 0, 0, 1, 1},
  {&__pyx_n_s____test__, __pyx_k____test__, sizeof(__pyx_k____test__), 0, 0, 1, 1},
  {&__pyx_n_s___arguments, __pyx_k___arguments, sizeof(__pyx_k___arguments), 0, 0, 1, 1},
  {&__pyx_n_s___co_state, __pyx_k___co_state, sizeof(__pyx_k___co_state), 0, 0, 1, 1},
  {&__pyx_n_s___count, __pyx_k___count, sizeof(__pyx_k___count), 0, 0, 1, 1},
  {&__pyx_n_s___encoding, __pyx_k___encoding, sizeof(__pyx_k___encoding), 0, 0, 1, 1},
  {&__pyx_n_s___is_locked, __pyx_k___is_locked, sizeof(__pyx_k___is_locked), 0, 0, 1, 1},
  {&__pyx_n_s___lock, __pyx_k___lock, sizeof(__pyx_k___lock), 0, 0, 1, 1},
  {&__pyx_n_s___obj, __pyx_k___obj, sizeof(__pyx_k___obj), 0, 0, 1, 1},
  {&__pyx_n_s___owner, __pyx_k___owner, sizeof(__pyx_k___owner), 0, 0, 1, 1},
  {&__pyx_n_s___pending_requests, __pyx_k___pending_requests, sizeof(__pyx_k___pending_requests), 0, 0, 1, 1},
  {&__pyx_n_s___raised_exception, __pyx_k___raised_exception, sizeof(__pyx_k___raised_exception), 0, 0, 1, 1},
  {&__pyx_n_s___real_lock, __pyx_k___real_lock, sizeof(__pyx_k___real_lock), 0, 0, 1, 1},
  {&__pyx_n_s___ref, __pyx_k___ref, sizeof(__pyx_k___ref), 0, 0, 1, 1},
  {&__pyx_n_s___refiter, __pyx_k___refiter, sizeof(__pyx_k___refiter), 0, 0, 1, 1},
  {&__pyx_n_s___runtime, __pyx_k___runtime, sizeof(__pyx_k___runtime), 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___state, __pyx_k___state, sizeof(__pyx_k___state), 0, 0, 1, 1},
  {&__pyx_n_s___type_flags, __pyx_k___type_flags, sizeof(__pyx_k___type_flags), 0, 0, 1, 1},
  {&__pyx_n_s___what, __pyx_k___what, sizeof(__pyx_k___what), 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__blocking, __pyx_k__blocking, sizeof(__pyx_k__blocking), 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_n_s__coroutine, __pyx_k__coroutine, sizeof(__pyx_k__coroutine), 0, 0, 1, 1},
  {&__pyx_n_s__cpython, __pyx_k__cpython, sizeof(__pyx_k__cpython), 0, 0, 1, 1},
  {&__pyx_n_s__decode, __pyx_k__decode, sizeof(__pyx_k__decode), 0, 0, 1, 1},
  {&__pyx_n_s__encode, __pyx_k__encode, sizeof(__pyx_k__encode), 0, 0, 1, 1},
  {&__pyx_n_s__encoding, __pyx_k__encoding, sizeof(__pyx_k__encoding), 0, 0, 1, 1},
  {&__pyx_n_s__endswith, __pyx_k__endswith, sizeof(__pyx_k__endswith), 0, 0, 1, 1},
  {&__pyx_n_s__enumerate, __pyx_k__enumerate, sizeof(__pyx_k__enumerate), 0, 0, 1, 1},
  {&__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, __pyx_k__exc, sizeof(__pyx_k__exc), 0, 0, 1, 1},
  {&__pyx_n_s__exc_info, __pyx_k__exc_info, sizeof(__pyx_k__exc_info), 0, 0, 1, 1},
  {&__pyx_n_s__func, __pyx_k__func, sizeof(__pyx_k__func), 0, 0, 1, 1},
  {&__pyx_n_s__init_python_lib, __pyx_k__init_python_lib, sizeof(__pyx_k__init_python_lib), 0, 0, 1, 1},
  {&__pyx_n_s__name, __pyx_k__name, sizeof(__pyx_k__name), 0, 0, 1, 1},
  {&__pyx_n_s__next, __pyx_k__next, sizeof(__pyx_k__next), 0, 0, 1, 1},
  {&__pyx_n_b__none, __pyx_k__none, sizeof(__pyx_k__none), 0, 0, 0, 1},
  {&__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__push_lua_object, __pyx_k__push_lua_object, sizeof(__pyx_k__push_lua_object), 0, 0, 1, 1},
  {&__pyx_n_s__range, __pyx_k__range, sizeof(__pyx_k__range), 0, 0, 1, 1},
  {&__pyx_n_s__register_py_object, __pyx_k__register_py_object, sizeof(__pyx_k__register_py_object), 0, 0, 1, 1},
  {&__pyx_n_s__runtime, __pyx_k__runtime, sizeof(__pyx_k__runtime), 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__startswith, __pyx_k__startswith, sizeof(__pyx_k__startswith), 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__tb, __pyx_k__tb, sizeof(__pyx_k__tb), 0, 0, 1, 1},
  {&__pyx_n_s__type_flags, __pyx_k__type_flags, sizeof(__pyx_k__type_flags), 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},
  {0, 0, 0, 0, 0, 0, 0}
};
static int __Pyx_InitCachedBuiltins(void) {
  __pyx_builtin_ImportError = __Pyx_GetName(__pyx_b, __pyx_n_s__ImportError); if (!__pyx_builtin_ImportError) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 30; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_builtin_Exception = __Pyx_GetName(__pyx_b, __pyx_n_s__Exception); if (!__pyx_builtin_Exception) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 50; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_builtin_RuntimeError = __Pyx_GetName(__pyx_b, __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_TypeError = __Pyx_GetName(__pyx_b, __pyx_n_s__TypeError); if (!__pyx_builtin_TypeError) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 148; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_builtin_enumerate = __Pyx_GetName(__pyx_b, __pyx_n_s__enumerate); if (!__pyx_builtin_enumerate) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 192; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_builtin_eval = __Pyx_GetName(__pyx_b, __pyx_n_s__eval); if (!__pyx_builtin_eval) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 227; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_builtin_UnicodeDecodeError = __Pyx_GetName(__pyx_b, __pyx_n_s__UnicodeDecodeError); if (!__pyx_builtin_UnicodeDecodeError) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 339; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_builtin_object = __Pyx_GetName(__pyx_b, __pyx_n_s__object); if (!__pyx_builtin_object) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 355; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_builtin_StopIteration = __Pyx_GetName(__pyx_b, __pyx_n_s__StopIteration); if (!__pyx_builtin_StopIteration) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 589; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_builtin_range = __Pyx_GetName(__pyx_b, __pyx_n_s__range); if (!__pyx_builtin_range) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 935; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  return 0;
  __pyx_L1_error:;
  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;
  int __pyx_t_3;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  luaL_Reg __pyx_t_6;
  #if CYTHON_REFNANNY
  void* __pyx_refnanny = NULL;
  __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");
  }
  __pyx_refnanny = __Pyx_RefNanny->SetupContext("PyMODINIT_FUNC PyInit__lupa(void)", __LINE__, __FILE__);
  #endif
  __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_binding_PyCFunctionType_USED
  if (__pyx_binding_PyCFunctionType_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_37), 0, PYTHON_API_VERSION);
  #else
  __pyx_m = PyModule_Create(&__pyx_moduledef);
  #endif
  if (!__pyx_m) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
  #if PY_MAJOR_VERSION < 3
  Py_INCREF(__pyx_m);
  #endif
  __pyx_b = PyImport_AddModule(__Pyx_NAMESTR(__Pyx_BUILTIN_MODULE_NAME));
  if (!__pyx_b) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
  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 (__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;};
  }
  /*--- Builtin init code ---*/
  if (unlikely(__Pyx_InitCachedBuiltins() < 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_builtins = Py_None; Py_INCREF(Py_None);
  /*--- Function export code ---*/
  /*--- Type init code ---*/
  __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;
  if (PyType_Ready(&__pyx_type_4lupa_5_lupa__LuaObject) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 248; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  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 = 248; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__Pyx_SetAttrString(__pyx_m, "_LuaObject", (PyObject *)&__pyx_type_4lupa_5_lupa__LuaObject) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 248; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_ptype_4lupa_5_lupa__LuaObject = &__pyx_type_4lupa_5_lupa__LuaObject;
  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;}
  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 *))__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 = 60; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  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 = 60; __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 = 60; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_ptype_4lupa_5_lupa_LuaRuntime = &__pyx_type_4lupa_5_lupa_LuaRuntime;
  __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_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 = 438; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  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 = 438; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__Pyx_SetAttrString(__pyx_m, "_LuaTable", (PyObject *)&__pyx_type_4lupa_5_lupa__LuaTable) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 438; __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 = 466; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  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 = 466; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__Pyx_SetAttrString(__pyx_m, "_LuaFunction", (PyObject *)&__pyx_type_4lupa_5_lupa__LuaFunction) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 466; __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 = 501; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  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 = 501; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__Pyx_SetAttrString(__pyx_m, "_LuaCoroutineFunction", (PyObject *)&__pyx_type_4lupa_5_lupa__LuaCoroutineFunction) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 501; __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 = 513; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  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 = 513; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__Pyx_SetAttrString(__pyx_m, "_LuaThread", (PyObject *)&__pyx_type_4lupa_5_lupa__LuaThread) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 513; __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 = 614; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__Pyx_SetAttrString(__pyx_m, "_LuaIter", (PyObject *)&__pyx_type_4lupa_5_lupa__LuaIter) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 614; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_ptype_4lupa_5_lupa__LuaIter = &__pyx_type_4lupa_5_lupa__LuaIter;
  if (PyType_Ready(&__pyx_type_4lupa_5_lupa__PyProtocolWrapper) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 725; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__Pyx_SetAttrString(__pyx_m, "_PyProtocolWrapper", (PyObject *)&__pyx_type_4lupa_5_lupa__PyProtocolWrapper) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 725; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_ptype_4lupa_5_lupa__PyProtocolWrapper = &__pyx_type_4lupa_5_lupa__PyProtocolWrapper;
  /*--- Type import code ---*/
  __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[2]; __pyx_lineno = 8; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  /*--- Function import code ---*/
  /*--- Execution code ---*/

  /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":23
 * 
 * cdef object exc_info
 * from sys import exc_info             # <<<<<<<<<<<<<<
 * 
 * __all__ = ['LuaRuntime', 'LuaError', 'as_itemgetter', 'as_attrgetter']
 */
  __pyx_t_1 = PyList_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 23; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_1));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__exc_info));
  PyList_SET_ITEM(__pyx_t_1, 0, ((PyObject *)__pyx_n_s__exc_info));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__exc_info));
  __pyx_t_2 = __Pyx_Import(((PyObject *)__pyx_n_s__sys), ((PyObject *)__pyx_t_1)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 23; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
  __pyx_t_1 = PyObject_GetAttr(__pyx_t_2, __pyx_n_s__exc_info); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 23; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_INCREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v_4lupa_5_lupa_exc_info);
  __Pyx_DECREF(__pyx_v_4lupa_5_lupa_exc_info);
  __Pyx_GIVEREF(__pyx_t_1);
  __pyx_v_4lupa_5_lupa_exc_info = __pyx_t_1;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":25
 * from sys import exc_info
 * 
 * __all__ = ['LuaRuntime', 'LuaError', 'as_itemgetter', 'as_attrgetter']             # <<<<<<<<<<<<<<
 * 
 * cdef object builtins
 */
  __pyx_t_2 = PyList_New(4); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 25; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_2));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__LuaRuntime));
  PyList_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_n_s__LuaRuntime));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__LuaRuntime));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__LuaError));
  PyList_SET_ITEM(__pyx_t_2, 1, ((PyObject *)__pyx_n_s__LuaError));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__LuaError));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__as_itemgetter));
  PyList_SET_ITEM(__pyx_t_2, 2, ((PyObject *)__pyx_n_s__as_itemgetter));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__as_itemgetter));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__as_attrgetter));
  PyList_SET_ITEM(__pyx_t_2, 3, ((PyObject *)__pyx_n_s__as_attrgetter));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__as_attrgetter));
  if (PyObject_SetAttr(__pyx_m, __pyx_n_s____all__, ((PyObject *)__pyx_t_2)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 25; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;

  /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":28
 * 
 * cdef object builtins
 * try:             # <<<<<<<<<<<<<<
 *     import __builtin__ as builtins
 * except ImportError:
 */
  {
    PyObject *__pyx_save_exc_type, *__pyx_save_exc_value, *__pyx_save_exc_tb;
    __Pyx_ExceptionSave(&__pyx_save_exc_type, &__pyx_save_exc_value, &__pyx_save_exc_tb);
    __Pyx_XGOTREF(__pyx_save_exc_type);
    __Pyx_XGOTREF(__pyx_save_exc_value);
    __Pyx_XGOTREF(__pyx_save_exc_tb);
    /*try:*/ {

      /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":29
 * cdef object builtins
 * try:
 *     import __builtin__ as builtins             # <<<<<<<<<<<<<<
 * except ImportError:
 *     import builtins
 */
      __pyx_t_2 = __Pyx_Import(((PyObject *)__pyx_n_s____builtin__), 0); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 29; __pyx_clineno = __LINE__; goto __pyx_L2_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_GOTREF(__pyx_v_4lupa_5_lupa_builtins);
      __Pyx_DECREF(__pyx_v_4lupa_5_lupa_builtins);
      __Pyx_GIVEREF(__pyx_t_2);
      __pyx_v_4lupa_5_lupa_builtins = __pyx_t_2;
      __pyx_t_2 = 0;
    }
    __Pyx_XDECREF(__pyx_save_exc_type); __pyx_save_exc_type = 0;
    __Pyx_XDECREF(__pyx_save_exc_value); __pyx_save_exc_value = 0;
    __Pyx_XDECREF(__pyx_save_exc_tb); __pyx_save_exc_tb = 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;

    /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":30
 * try:
 *     import __builtin__ as builtins
 * except ImportError:             # <<<<<<<<<<<<<<
 *     import builtins
 * 
 */
    __pyx_t_3 = PyErr_ExceptionMatches(__pyx_builtin_ImportError);
    if (__pyx_t_3) {
      __Pyx_AddTraceback("lupa._lupa");
      if (__Pyx_GetException(&__pyx_t_2, &__pyx_t_1, &__pyx_t_4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 30; __pyx_clineno = __LINE__; goto __pyx_L4_except_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_GOTREF(__pyx_t_4);

      /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":31
 *     import __builtin__ as builtins
 * except ImportError:
 *     import builtins             # <<<<<<<<<<<<<<
 * 
 * DEF POBJECT = "POBJECT" # as used by LunaticPython
 */
      __pyx_t_5 = __Pyx_Import(((PyObject *)__pyx_n_s__builtins), 0); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 31; __pyx_clineno = __LINE__; goto __pyx_L4_except_error;}
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_GOTREF(__pyx_v_4lupa_5_lupa_builtins);
      __Pyx_DECREF(__pyx_v_4lupa_5_lupa_builtins);
      __Pyx_GIVEREF(__pyx_t_5);
      __pyx_v_4lupa_5_lupa_builtins = __pyx_t_5;
      __pyx_t_5 = 0;
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      goto __pyx_L3_exception_handled;
    }
    __pyx_L4_except_error:;
    __Pyx_XGIVEREF(__pyx_save_exc_type);
    __Pyx_XGIVEREF(__pyx_save_exc_value);
    __Pyx_XGIVEREF(__pyx_save_exc_tb);
    __Pyx_ExceptionReset(__pyx_save_exc_type, __pyx_save_exc_value, __pyx_save_exc_tb);
    goto __pyx_L1_error;
    __pyx_L3_exception_handled:;
    __Pyx_XGIVEREF(__pyx_save_exc_type);
    __Pyx_XGIVEREF(__pyx_save_exc_value);
    __Pyx_XGIVEREF(__pyx_save_exc_tb);
    __Pyx_ExceptionReset(__pyx_save_exc_type, __pyx_save_exc_value, __pyx_save_exc_tb);
    __pyx_L9_try_end:;
  }

  /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":50
 * include "lock.pxi"
 * 
 * class LuaError(Exception):             # <<<<<<<<<<<<<<
 *     """Base class for errors in the Lua runtime.
 *     """
 */
  __pyx_t_4 = PyDict_New(); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 50; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_4));
  __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 50; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_INCREF(__pyx_builtin_Exception);
  PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_builtin_Exception);
  __Pyx_GIVEREF(__pyx_builtin_Exception);
  if (PyDict_SetItemString(((PyObject *)__pyx_t_4), "__doc__", ((PyObject *)__pyx_kp_s_38)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 50; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_2 = __Pyx_CreateClass(__pyx_t_1, ((PyObject *)__pyx_t_4), __pyx_n_s__LuaError, __pyx_n_s_39); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 50; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (PyObject_SetAttr(__pyx_m, __pyx_n_s__LuaError, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 50; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(((PyObject *)__pyx_t_4)); __pyx_t_4 = 0;

  /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":55
 *     pass
 * 
 * class LuaSyntaxError(LuaError):             # <<<<<<<<<<<<<<
 *     """Syntax error in Lua code.
 *     """
 */
  __pyx_t_4 = PyDict_New(); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 55; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_4));
  __pyx_t_2 = __Pyx_GetName(__pyx_m, __pyx_n_s__LuaError); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 55; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 55; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_2);
  __Pyx_GIVEREF(__pyx_t_2);
  __pyx_t_2 = 0;
  if (PyDict_SetItemString(((PyObject *)__pyx_t_4), "__doc__", ((PyObject *)__pyx_kp_s_40)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 55; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_2 = __Pyx_CreateClass(__pyx_t_1, ((PyObject *)__pyx_t_4), __pyx_n_s__LuaSyntaxError, __pyx_n_s_39); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 55; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (PyObject_SetAttr(__pyx_m, __pyx_n_s__LuaSyntaxError, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 55; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(((PyObject *)__pyx_t_4)); __pyx_t_4 = 0;

  /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":1108
 * 
 * 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_6.name = __pyx_k____call;
  __pyx_t_6.func = ((lua_CFunction)__pyx_f_4lupa_5_lupa_py_object_call);
  (__pyx_v_4lupa_5_lupa_py_object_lib[0]) = __pyx_t_6;

  /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":1109
 * 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_6.name = __pyx_k____index;
  __pyx_t_6.func = ((lua_CFunction)__pyx_f_4lupa_5_lupa_py_object_getindex);
  (__pyx_v_4lupa_5_lupa_py_object_lib[1]) = __pyx_t_6;

  /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":1110
 * 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_6.name = __pyx_k____newindex;
  __pyx_t_6.func = ((lua_CFunction)__pyx_f_4lupa_5_lupa_py_object_setindex);
  (__pyx_v_4lupa_5_lupa_py_object_lib[2]) = __pyx_t_6;

  /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":1111
 * 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_6.name = __pyx_k____tostring;
  __pyx_t_6.func = ((lua_CFunction)__pyx_f_4lupa_5_lupa_py_object_str);
  (__pyx_v_4lupa_5_lupa_py_object_lib[3]) = __pyx_t_6;

  /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":1112
 * 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_6.name = __pyx_k____gc;
  __pyx_t_6.func = ((lua_CFunction)__pyx_f_4lupa_5_lupa_py_object_gc);
  (__pyx_v_4lupa_5_lupa_py_object_lib[4]) = __pyx_t_6;

  /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":1113
 * 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_6.name = NULL;
  __pyx_t_6.func = NULL;
  (__pyx_v_4lupa_5_lupa_py_object_lib[5]) = __pyx_t_6;

  /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":1271
 * 
 * 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_6.name = __pyx_k__as_attrgetter;
  __pyx_t_6.func = ((lua_CFunction)__pyx_f_4lupa_5_lupa_py_as_attrgetter);
  (__pyx_v_4lupa_5_lupa_py_lib[0]) = __pyx_t_6;

  /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":1272
 * 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_6.name = __pyx_k__as_itemgetter;
  __pyx_t_6.func = ((lua_CFunction)__pyx_f_4lupa_5_lupa_py_as_itemgetter);
  (__pyx_v_4lupa_5_lupa_py_lib[1]) = __pyx_t_6;

  /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":1273
 * 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_6.name = __pyx_k__as_function;
  __pyx_t_6.func = ((lua_CFunction)__pyx_f_4lupa_5_lupa_py_as_function);
  (__pyx_v_4lupa_5_lupa_py_lib[2]) = __pyx_t_6;

  /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":1274
 * 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_6.name = __pyx_k__iter;
  __pyx_t_6.func = ((lua_CFunction)__pyx_f_4lupa_5_lupa_py_iter);
  (__pyx_v_4lupa_5_lupa_py_lib[3]) = __pyx_t_6;

  /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":1275
 * 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_6.name = __pyx_k__iterex;
  __pyx_t_6.func = ((lua_CFunction)__pyx_f_4lupa_5_lupa_py_iterex);
  (__pyx_v_4lupa_5_lupa_py_lib[4]) = __pyx_t_6;

  /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":1276
 * 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_6.name = __pyx_k__enumerate;
  __pyx_t_6.func = ((lua_CFunction)__pyx_f_4lupa_5_lupa_py_enumerate);
  (__pyx_v_4lupa_5_lupa_py_lib[5]) = __pyx_t_6;

  /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":1277
 * 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_6.name = NULL;
  __pyx_t_6.func = NULL;
  (__pyx_v_4lupa_5_lupa_py_lib[6]) = __pyx_t_6;

  /* "/home/sbehnel/source/Python/lua/lupa/lupa/_lupa.pyx":1
 * # cython: embedsignature=True             # <<<<<<<<<<<<<<
 * 
 * """
 */
  __pyx_t_4 = PyDict_New(); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_4));
  if (PyObject_SetAttr(__pyx_m, __pyx_n_s____test__, ((PyObject *)__pyx_t_4)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(((PyObject *)__pyx_t_4)); __pyx_t_4 = 0;

  /* "/home/sbehnel/source/Python/cython/cython-work/Cython/Includes/cpython/type.pxd":2
 * 
 * cdef extern from "Python.h":             # <<<<<<<<<<<<<<
 *     # The C structure of the objects used to describe built-in types.
 * 
 */
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  if (__pyx_m) {
    __Pyx_AddTraceback("init lupa._lupa");
    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 */

static PyObject *__Pyx_GetName(PyObject *dict, PyObject *name) {
    PyObject *result;
    result = PyObject_GetAttr(dict, name);
    if (!result)
        PyErr_SetObject(PyExc_NameError, name);
    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 *number, *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";
    }
    number = (num_expected == 1) ? "" : "s";
    PyErr_Format(PyExc_TypeError,
        #if PY_VERSION_HEX < 0x02050000
            "%s() takes %s %d positional argument%s (%d given)",
        #else
            "%s() takes %s %zd positional argument%s (%zd given)",
        #endif
        func_name, more_or_less, num_expected, number, 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;
    while (PyDict_Next(kwdict, &pos, &key, 0)) {
        #if PY_MAJOR_VERSION < 3
        if (unlikely(!PyString_CheckExact(key)) && unlikely(!PyString_Check(key)))
        #else
        if (unlikely(!PyUnicode_CheckExact(key)) && unlikely(!PyUnicode_Check(key)))
        #endif
            goto invalid_keyword_type;
    }
    if ((!kw_allowed) && unlikely(key))
        goto invalid_keyword;
    return 1;
invalid_keyword_type:
    PyErr_Format(PyExc_TypeError,
        "%s() keywords must be strings", function_name);
    return 0;
invalid_keyword:
    PyErr_Format(PyExc_TypeError,
    #if PY_MAJOR_VERSION < 3
        "%s() got an unexpected keyword argument '%s'",
        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_AS_STRING(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;
        } else {
            #if PY_MAJOR_VERSION < 3
            if (unlikely(!PyString_CheckExact(key)) && unlikely(!PyString_Check(key))) {
            #else
            if (unlikely(!PyUnicode_CheckExact(key)) && unlikely(!PyUnicode_Check(key))) {
            #endif
                goto invalid_keyword_type;
            } else {
                for (name = first_kw_arg; *name; name++) {
                    #if PY_MAJOR_VERSION >= 3
                    if (PyUnicode_GET_SIZE(**name) == PyUnicode_GET_SIZE(key) &&
                        PyUnicode_Compare(**name, key) == 0) break;
                    #else
                    if (PyString_GET_SIZE(**name) == PyString_GET_SIZE(key) &&
                        _PyString_Eq(**name, key)) break;
                    #endif
                }
                if (*name) {
                    values[name-argnames] = value;
                } else {
                    /* unexpected keyword found */
                    for (name=argnames; name != first_kw_arg; name++) {
                        if (**name == key) goto arg_passed_twice;
                        #if PY_MAJOR_VERSION >= 3
                        if (PyUnicode_GET_SIZE(**name) == PyUnicode_GET_SIZE(key) &&
                            PyUnicode_Compare(**name, key) == 0) goto arg_passed_twice;
                        #else
                        if (PyString_GET_SIZE(**name) == PyString_GET_SIZE(key) &&
                            _PyString_Eq(**name, key)) goto arg_passed_twice;
                        #endif
                    }
                    if (kwds2) {
                        if (unlikely(PyDict_SetItem(kwds2, key, value))) goto bad;
                    } else {
                        goto invalid_keyword;
                    }
                }
            }
        }
    }
    return 0;
arg_passed_twice:
    __Pyx_RaiseDoubleKeywordsError(function_name, **name);
    goto bad;
invalid_keyword_type:
    PyErr_Format(PyExc_TypeError,
        "%s() keywords must be strings", function_name);
    goto bad;
invalid_keyword:
    PyErr_Format(PyExc_TypeError,
    #if PY_MAJOR_VERSION < 3
        "%s() got an unexpected keyword argument '%s'",
        function_name, PyString_AsString(key));
    #else
        "%s() got an unexpected keyword argument '%U'",
        function_name, key);
    #endif
bad:
    return -1;
}


static CYTHON_INLINE void __Pyx_ErrRestore(PyObject *type, PyObject *value, PyObject *tb) {
    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);
}

static CYTHON_INLINE void __Pyx_ErrFetch(PyObject **type, PyObject **value, PyObject **tb) {
    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;
}


static int __Pyx_GetException(PyObject **type, PyObject **value, PyObject **tb) {
    PyObject *local_type, *local_value, *local_tb;
    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;
    PyErr_NormalizeException(&local_type, &local_value, &local_tb);
    if (unlikely(tstate->curexc_type))
        goto bad;
    #if PY_MAJOR_VERSION >= 3
    if (unlikely(PyException_SetTraceback(local_value, local_tb) < 0))
        goto bad;
    #endif
    *type = local_type;
    *value = local_value;
    *tb = local_tb;
    Py_INCREF(local_type);
    Py_INCREF(local_value);
    Py_INCREF(local_tb);
    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;
    /* Make sure tstate is in a consistent state when we XDECREF
       these objects (XDECREF may run arbitrary code). */
    Py_XDECREF(tmp_type);
    Py_XDECREF(tmp_value);
    Py_XDECREF(tmp_tb);
    return 0;
bad:
    *type = 0;
    *value = 0;
    *tb = 0;
    Py_XDECREF(local_type);
    Py_XDECREF(local_value);
    Py_XDECREF(local_tb);
    return -1;
}


static int __Pyx_PyUnicode_Tailmatch(PyObject* s, PyObject* substr,
                                     Py_ssize_t start, Py_ssize_t end, int direction) {
    if (unlikely(PyTuple_Check(substr))) {
        int result;
        Py_ssize_t i;
        for (i = 0; i < PyTuple_GET_SIZE(substr); i++) {
            result = PyUnicode_Tailmatch(s, PyTuple_GET_ITEM(substr, i),
                                         start, end, direction);
            if (result) {
                return result;
            }
        }
        return 0;
    }
    return PyUnicode_Tailmatch(s, substr, start, end, direction);
}

static CYTHON_INLINE int __Pyx_TypeTest(PyObject *obj, PyTypeObject *type) {
    if (unlikely(!type)) {
        PyErr_Format(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 int __Pyx_ArgTypeTest(PyObject *obj, PyTypeObject *type, int none_allowed,
    const char *name, int exact)
{
    if (!type) {
        PyErr_Format(PyExc_SystemError, "Missing type object");
        return 0;
    }
    if (none_allowed && obj == Py_None) return 1;
    else if (exact) {
        if (Py_TYPE(obj) == type) return 1;
    }
    else {
        if (PyObject_TypeCheck(obj, type)) return 1;
    }
    PyErr_Format(PyExc_TypeError,
        "Argument '%s' has incorrect type (expected %s, got %s)",
        name, type->tp_name, Py_TYPE(obj)->tp_name);
    return 0;
}

static CYTHON_INLINE void __Pyx_ExceptionSave(PyObject **type, PyObject **value, PyObject **tb) {
    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);
}

static void __Pyx_ExceptionReset(PyObject *type, PyObject *value, PyObject *tb) {
    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);
}

static PyObject *__Pyx_Import(PyObject *name, PyObject *from_list) {
    PyObject *py_import = 0;
    PyObject *empty_list = 0;
    PyObject *module = 0;
    PyObject *global_dict = 0;
    PyObject *empty_dict = 0;
    PyObject *list;
    py_import = __Pyx_GetAttrString(__pyx_b, "__import__");
    if (!py_import)
        goto bad;
    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;
    module = PyObject_CallFunctionObjArgs(py_import,
        name, global_dict, empty_dict, list, NULL);
bad:
    Py_XDECREF(empty_list);
    Py_XDECREF(py_import);
    Py_XDECREF(empty_dict);
    return module;
}

static PyObject *__Pyx_CreateClass(
    PyObject *bases, PyObject *methods, PyObject *name, PyObject *modname)
{
    PyObject *result = 0;
#if PY_MAJOR_VERSION < 3
    PyObject *metaclass = 0, *base;
#endif

    if (PyDict_SetItemString(methods, "__module__", modname) < 0)
        goto bad;
    #if PY_MAJOR_VERSION < 3
    metaclass = PyDict_GetItemString(methods, "__metaclass__");

    if (metaclass != NULL)
        Py_INCREF(metaclass);
    else if (PyTuple_Check(bases) && PyTuple_GET_SIZE(bases) > 0) {
        base = PyTuple_GET_ITEM(bases, 0);
        metaclass = PyObject_GetAttrString(base, "__class__");
        if (metaclass == NULL) {
            PyErr_Clear();
            metaclass = (PyObject *)base->ob_type;
            Py_INCREF(metaclass);
        }
    }
    else {
        metaclass = (PyObject *) &PyClass_Type;
        Py_INCREF(metaclass);
    }

    result = PyObject_CallFunctionObjArgs(metaclass, name, bases, methods, NULL);
    Py_DECREF(metaclass);
    #else
    /* it seems that python3+ handle __metaclass__ itself */
    result = PyObject_CallFunctionObjArgs((PyObject *)&PyType_Type, name, bases, methods, NULL);
    #endif
bad:
    return result;
}

#if PY_MAJOR_VERSION < 3
static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb) {
    Py_XINCREF(type);
    Py_XINCREF(value);
    Py_XINCREF(tb);
    /* First, check the traceback argument, replacing None with NULL. */
    if (tb == Py_None) {
        Py_DECREF(tb);
        tb = 0;
    }
    else if (tb != NULL && !PyTraceBack_Check(tb)) {
        PyErr_SetString(PyExc_TypeError,
            "raise: arg 3 must be a traceback or None");
        goto raise_error;
    }
    /* Next, replace a missing value with None */
    if (value == NULL) {
        value = Py_None;
        Py_INCREF(value);
    }
    #if PY_VERSION_HEX < 0x02050000
    if (!PyClass_Check(type))
    #else
    if (!PyType_Check(type))
    #endif
    {
        /* Raising an instance.  The value should be a dummy. */
        if (value != Py_None) {
            PyErr_SetString(PyExc_TypeError,
                "instance exception may not have a separate value");
            goto raise_error;
        }
        /* Normalize to raise <class>, <instance> */
        Py_DECREF(value);
        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) {
    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)) {
        PyErr_SetString(PyExc_TypeError,
            "raise: exception class must be a subclass of BaseException");
        goto bad;
    }

    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:
    return;
}
#endif

static PyObject *__Pyx_GetAttr3(PyObject *o, PyObject *n, PyObject *d) {
    PyObject *r = PyObject_GetAttr(o, n);
    if (!r) {
        if (!PyErr_ExceptionMatches(PyExc_AttributeError))
            goto bad;
        PyErr_Clear();
        r = d;
        Py_INCREF(d);
    }
    return r;
bad:
    return 0;
}

static CYTHON_INLINE PyObject *__Pyx_PyIter_Next2(PyObject* iterator, PyObject* defval) {
    PyObject* next;
    if (unlikely(!PyIter_Check(iterator))) {
        PyErr_Format(PyExc_TypeError,
            "%.200s object is not an iterator", iterator->ob_type->tp_name);
        return NULL;
    }
    next = (*iterator->ob_type->tp_iternext)(iterator);
    if (likely(next)) {
        return next;
    } else if (defval) {
        if (PyErr_Occurred()) {
            if(!PyErr_ExceptionMatches(PyExc_StopIteration))
                return NULL;
            PyErr_Clear();
        }
        Py_INCREF(defval);
        return defval;
    } else if (PyErr_Occurred()) {
        return NULL;
    } else {
        PyErr_SetNone(PyExc_StopIteration);
        return NULL;
    }
}

static CYTHON_INLINE unsigned char __Pyx_PyInt_AsUnsignedChar(PyObject* x) {
    const unsigned char neg_one = (unsigned char)-1, const_zero = 0;
    const int is_unsigned = neg_one > const_zero;
    if (sizeof(unsigned char) < sizeof(long)) {
        long val = __Pyx_PyInt_AsLong(x);
        if (unlikely(val != (long)(unsigned char)val)) {
            if (!unlikely(val == -1 && PyErr_Occurred())) {
                PyErr_SetString(PyExc_OverflowError,
                    (is_unsigned && unlikely(val < 0)) ?
                    "can't convert negative value to unsigned char" :
                    "value too large to convert to unsigned char");
            }
            return (unsigned char)-1;
        }
        return (unsigned char)val;
    }
    return (unsigned char)__Pyx_PyInt_AsUnsignedLong(x);
}

static CYTHON_INLINE unsigned short __Pyx_PyInt_AsUnsignedShort(PyObject* x) {
    const unsigned short neg_one = (unsigned short)-1, const_zero = 0;
    const int is_unsigned = neg_one > const_zero;
    if (sizeof(unsigned short) < sizeof(long)) {
        long val = __Pyx_PyInt_AsLong(x);
        if (unlikely(val != (long)(unsigned short)val)) {
            if (!unlikely(val == -1 && PyErr_Occurred())) {
                PyErr_SetString(PyExc_OverflowError,
                    (is_unsigned && unlikely(val < 0)) ?
                    "can't convert negative value to unsigned short" :
                    "value too large to convert to unsigned short");
            }
            return (unsigned short)-1;
        }
        return (unsigned short)val;
    }
    return (unsigned short)__Pyx_PyInt_AsUnsignedLong(x);
}

static CYTHON_INLINE unsigned int __Pyx_PyInt_AsUnsignedInt(PyObject* x) {
    const unsigned int neg_one = (unsigned int)-1, const_zero = 0;
    const int is_unsigned = neg_one > const_zero;
    if (sizeof(unsigned int) < sizeof(long)) {
        long val = __Pyx_PyInt_AsLong(x);
        if (unlikely(val != (long)(unsigned int)val)) {
            if (!unlikely(val == -1 && PyErr_Occurred())) {
                PyErr_SetString(PyExc_OverflowError,
                    (is_unsigned && unlikely(val < 0)) ?
                    "can't convert negative value to unsigned int" :
                    "value too large to convert to unsigned int");
            }
            return (unsigned int)-1;
        }
        return (unsigned int)val;
    }
    return (unsigned int)__Pyx_PyInt_AsUnsignedLong(x);
}

static CYTHON_INLINE char __Pyx_PyInt_AsChar(PyObject* x) {
    const char neg_one = (char)-1, const_zero = 0;
    const int is_unsigned = neg_one > const_zero;
    if (sizeof(char) < sizeof(long)) {
        long val = __Pyx_PyInt_AsLong(x);
        if (unlikely(val != (long)(char)val)) {
            if (!unlikely(val == -1 && PyErr_Occurred())) {
                PyErr_SetString(PyExc_OverflowError,
                    (is_unsigned && unlikely(val < 0)) ?
                    "can't convert negative value to char" :
                    "value too large to convert to char");
            }
            return (char)-1;
        }
        return (char)val;
    }
    return (char)__Pyx_PyInt_AsLong(x);
}

static CYTHON_INLINE short __Pyx_PyInt_AsShort(PyObject* x) {
    const short neg_one = (short)-1, const_zero = 0;
    const int is_unsigned = neg_one > const_zero;
    if (sizeof(short) < sizeof(long)) {
        long val = __Pyx_PyInt_AsLong(x);
        if (unlikely(val != (long)(short)val)) {
            if (!unlikely(val == -1 && PyErr_Occurred())) {
                PyErr_SetString(PyExc_OverflowError,
                    (is_unsigned && unlikely(val < 0)) ?
                    "can't convert negative value to short" :
                    "value too large to convert to short");
            }
            return (short)-1;
        }
        return (short)val;
    }
    return (short)__Pyx_PyInt_AsLong(x);
}

static CYTHON_INLINE int __Pyx_PyInt_AsInt(PyObject* x) {
    const int neg_one = (int)-1, const_zero = 0;
    const int is_unsigned = neg_one > const_zero;
    if (sizeof(int) < sizeof(long)) {
        long val = __Pyx_PyInt_AsLong(x);
        if (unlikely(val != (long)(int)val)) {
            if (!unlikely(val == -1 && PyErr_Occurred())) {
                PyErr_SetString(PyExc_OverflowError,
                    (is_unsigned && unlikely(val < 0)) ?
                    "can't convert negative value to int" :
                    "value too large to convert to int");
            }
            return (int)-1;
        }
        return (int)val;
    }
    return (int)__Pyx_PyInt_AsLong(x);
}

static CYTHON_INLINE signed char __Pyx_PyInt_AsSignedChar(PyObject* x) {
    const signed char neg_one = (signed char)-1, const_zero = 0;
    const int is_unsigned = neg_one > const_zero;
    if (sizeof(signed char) < sizeof(long)) {
        long val = __Pyx_PyInt_AsLong(x);
        if (unlikely(val != (long)(signed char)val)) {
            if (!unlikely(val == -1 && PyErr_Occurred())) {
                PyErr_SetString(PyExc_OverflowError,
                    (is_unsigned && unlikely(val < 0)) ?
                    "can't convert negative value to signed char" :
                    "value too large to convert to signed char");
            }
            return (signed char)-1;
        }
        return (signed char)val;
    }
    return (signed char)__Pyx_PyInt_AsSignedLong(x);
}

static CYTHON_INLINE signed short __Pyx_PyInt_AsSignedShort(PyObject* x) {
    const signed short neg_one = (signed short)-1, const_zero = 0;
    const int is_unsigned = neg_one > const_zero;
    if (sizeof(signed short) < sizeof(long)) {
        long val = __Pyx_PyInt_AsLong(x);
        if (unlikely(val != (long)(signed short)val)) {
            if (!unlikely(val == -1 && PyErr_Occurred())) {
                PyErr_SetString(PyExc_OverflowError,
                    (is_unsigned && unlikely(val < 0)) ?
                    "can't convert negative value to signed short" :
                    "value too large to convert to signed short");
            }
            return (signed short)-1;
        }
        return (signed short)val;
    }
    return (signed short)__Pyx_PyInt_AsSignedLong(x);
}

static CYTHON_INLINE signed int __Pyx_PyInt_AsSignedInt(PyObject* x) {
    const signed int neg_one = (signed int)-1, const_zero = 0;
    const int is_unsigned = neg_one > const_zero;
    if (sizeof(signed int) < sizeof(long)) {
        long val = __Pyx_PyInt_AsLong(x);
        if (unlikely(val != (long)(signed int)val)) {
            if (!unlikely(val == -1 && PyErr_Occurred())) {
                PyErr_SetString(PyExc_OverflowError,
                    (is_unsigned && unlikely(val < 0)) ?
                    "can't convert negative value to signed int" :
                    "value too large to convert to signed int");
            }
            return (signed int)-1;
        }
        return (signed int)val;
    }
    return (signed int)__Pyx_PyInt_AsSignedLong(x);
}

static CYTHON_INLINE int __Pyx_PyInt_AsLongDouble(PyObject* x) {
    const int neg_one = (int)-1, const_zero = 0;
    const int is_unsigned = neg_one > const_zero;
    if (sizeof(int) < sizeof(long)) {
        long val = __Pyx_PyInt_AsLong(x);
        if (unlikely(val != (long)(int)val)) {
            if (!unlikely(val == -1 && PyErr_Occurred())) {
                PyErr_SetString(PyExc_OverflowError,
                    (is_unsigned && unlikely(val < 0)) ?
                    "can't convert negative value to int" :
                    "value too large to convert to int");
            }
            return (int)-1;
        }
        return (int)val;
    }
    return (int)__Pyx_PyInt_AsLong(x);
}

static CYTHON_INLINE unsigned long __Pyx_PyInt_AsUnsignedLong(PyObject* x) {
    const unsigned long neg_one = (unsigned long)-1, const_zero = 0;
    const int is_unsigned = neg_one > const_zero;
#if PY_VERSION_HEX < 0x03000000
    if (likely(PyInt_Check(x))) {
        long val = PyInt_AS_LONG(x);
        if (is_unsigned && unlikely(val < 0)) {
            PyErr_SetString(PyExc_OverflowError,
                            "can't convert negative value to unsigned long");
            return (unsigned long)-1;
        }
        return (unsigned long)val;
    } else
#endif
    if (likely(PyLong_Check(x))) {
        if (is_unsigned) {
            if (unlikely(Py_SIZE(x) < 0)) {
                PyErr_SetString(PyExc_OverflowError,
                                "can't convert negative value to unsigned long");
                return (unsigned long)-1;
            }
            return PyLong_AsUnsignedLong(x);
        } else {
            return PyLong_AsLong(x);
        }
    } else {
        unsigned long val;
        PyObject *tmp = __Pyx_PyNumber_Int(x);
        if (!tmp) return (unsigned long)-1;
        val = __Pyx_PyInt_AsUnsignedLong(tmp);
        Py_DECREF(tmp);
        return val;
    }
}

static CYTHON_INLINE unsigned PY_LONG_LONG __Pyx_PyInt_AsUnsignedLongLong(PyObject* x) {
    const unsigned PY_LONG_LONG neg_one = (unsigned PY_LONG_LONG)-1, const_zero = 0;
    const int is_unsigned = neg_one > const_zero;
#if PY_VERSION_HEX < 0x03000000
    if (likely(PyInt_Check(x))) {
        long val = PyInt_AS_LONG(x);
        if (is_unsigned && unlikely(val < 0)) {
            PyErr_SetString(PyExc_OverflowError,
                            "can't convert negative value to unsigned PY_LONG_LONG");
            return (unsigned PY_LONG_LONG)-1;
        }
        return (unsigned PY_LONG_LONG)val;
    } else
#endif
    if (likely(PyLong_Check(x))) {
        if (is_unsigned) {
            if (unlikely(Py_SIZE(x) < 0)) {
                PyErr_SetString(PyExc_OverflowError,
                                "can't convert negative value to unsigned PY_LONG_LONG");
                return (unsigned PY_LONG_LONG)-1;
            }
            return PyLong_AsUnsignedLongLong(x);
        } else {
            return PyLong_AsLongLong(x);
        }
    } else {
        unsigned PY_LONG_LONG val;
        PyObject *tmp = __Pyx_PyNumber_Int(x);
        if (!tmp) return (unsigned PY_LONG_LONG)-1;
        val = __Pyx_PyInt_AsUnsignedLongLong(tmp);
        Py_DECREF(tmp);
        return val;
    }
}

static CYTHON_INLINE long __Pyx_PyInt_AsLong(PyObject* x) {
    const long neg_one = (long)-1, const_zero = 0;
    const int is_unsigned = neg_one > const_zero;
#if PY_VERSION_HEX < 0x03000000
    if (likely(PyInt_Check(x))) {
        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 (unlikely(Py_SIZE(x) < 0)) {
                PyErr_SetString(PyExc_OverflowError,
                                "can't convert negative value to long");
                return (long)-1;
            }
            return PyLong_AsUnsignedLong(x);
        } else {
            return PyLong_AsLong(x);
        }
    } else {
        long val;
        PyObject *tmp = __Pyx_PyNumber_Int(x);
        if (!tmp) return (long)-1;
        val = __Pyx_PyInt_AsLong(tmp);
        Py_DECREF(tmp);
        return val;
    }
}

static CYTHON_INLINE PY_LONG_LONG __Pyx_PyInt_AsLongLong(PyObject* x) {
    const PY_LONG_LONG neg_one = (PY_LONG_LONG)-1, const_zero = 0;
    const int is_unsigned = neg_one > const_zero;
#if PY_VERSION_HEX < 0x03000000
    if (likely(PyInt_Check(x))) {
        long val = PyInt_AS_LONG(x);
        if (is_unsigned && unlikely(val < 0)) {
            PyErr_SetString(PyExc_OverflowError,
                            "can't convert negative value to PY_LONG_LONG");
            return (PY_LONG_LONG)-1;
        }
        return (PY_LONG_LONG)val;
    } else
#endif
    if (likely(PyLong_Check(x))) {
        if (is_unsigned) {
            if (unlikely(Py_SIZE(x) < 0)) {
                PyErr_SetString(PyExc_OverflowError,
                                "can't convert negative value to PY_LONG_LONG");
                return (PY_LONG_LONG)-1;
            }
            return PyLong_AsUnsignedLongLong(x);
        } else {
            return PyLong_AsLongLong(x);
        }
    } else {
        PY_LONG_LONG val;
        PyObject *tmp = __Pyx_PyNumber_Int(x);
        if (!tmp) return (PY_LONG_LONG)-1;
        val = __Pyx_PyInt_AsLongLong(tmp);
        Py_DECREF(tmp);
        return val;
    }
}

static CYTHON_INLINE signed long __Pyx_PyInt_AsSignedLong(PyObject* x) {
    const signed long neg_one = (signed long)-1, const_zero = 0;
    const int is_unsigned = neg_one > const_zero;
#if PY_VERSION_HEX < 0x03000000
    if (likely(PyInt_Check(x))) {
        long val = PyInt_AS_LONG(x);
        if (is_unsigned && unlikely(val < 0)) {
            PyErr_SetString(PyExc_OverflowError,
                            "can't convert negative value to signed long");
            return (signed long)-1;
        }
        return (signed long)val;
    } else
#endif
    if (likely(PyLong_Check(x))) {
        if (is_unsigned) {
            if (unlikely(Py_SIZE(x) < 0)) {
                PyErr_SetString(PyExc_OverflowError,
                                "can't convert negative value to signed long");
                return (signed long)-1;
            }
            return PyLong_AsUnsignedLong(x);
        } else {
            return PyLong_AsLong(x);
        }
    } else {
        signed long val;
        PyObject *tmp = __Pyx_PyNumber_Int(x);
        if (!tmp) return (signed long)-1;
        val = __Pyx_PyInt_AsSignedLong(tmp);
        Py_DECREF(tmp);
        return val;
    }
}

static CYTHON_INLINE signed PY_LONG_LONG __Pyx_PyInt_AsSignedLongLong(PyObject* x) {
    const signed PY_LONG_LONG neg_one = (signed PY_LONG_LONG)-1, const_zero = 0;
    const int is_unsigned = neg_one > const_zero;
#if PY_VERSION_HEX < 0x03000000
    if (likely(PyInt_Check(x))) {
        long val = PyInt_AS_LONG(x);
        if (is_unsigned && unlikely(val < 0)) {
            PyErr_SetString(PyExc_OverflowError,
                            "can't convert negative value to signed PY_LONG_LONG");
            return (signed PY_LONG_LONG)-1;
        }
        return (signed PY_LONG_LONG)val;
    } else
#endif
    if (likely(PyLong_Check(x))) {
        if (is_unsigned) {
            if (unlikely(Py_SIZE(x) < 0)) {
                PyErr_SetString(PyExc_OverflowError,
                                "can't convert negative value to signed PY_LONG_LONG");
                return (signed PY_LONG_LONG)-1;
            }
            return PyLong_AsUnsignedLongLong(x);
        } else {
            return PyLong_AsLongLong(x);
        }
    } else {
        signed PY_LONG_LONG val;
        PyObject *tmp = __Pyx_PyNumber_Int(x);
        if (!tmp) return (signed PY_LONG_LONG)-1;
        val = __Pyx_PyInt_AsSignedLongLong(tmp);
        Py_DECREF(tmp);
        return val;
    }
}

static void __Pyx_WriteUnraisable(const char *name) {
    PyObject *old_exc, *old_val, *old_tb;
    PyObject *ctx;
    __Pyx_ErrFetch(&old_exc, &old_val, &old_tb);
    #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 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_SetItemString(dict, "__pyx_vtable__", ob) < 0)
        goto bad;
    Py_DECREF(ob);
    return 0;
bad:
    Py_XDECREF(ob);
    return -1;
}

#ifndef __PYX_HAVE_RT_ImportType
#define __PYX_HAVE_RT_ImportType
static PyTypeObject *__Pyx_ImportType(const char *module_name, const char *class_name,
    long size, int strict)
{
    PyObject *py_module = 0;
    PyObject *result = 0;
    PyObject *py_name = 0;
    char warning[200];

    py_module = __Pyx_ImportModule(module_name);
    if (!py_module)
        goto bad;
    #if PY_MAJOR_VERSION < 3
    py_name = PyString_FromString(class_name);
    #else
    py_name = PyUnicode_FromString(class_name);
    #endif
    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, 
            "%s.%s is not a type object",
            module_name, class_name);
        goto bad;
    }
    if (!strict && ((PyTypeObject *)result)->tp_basicsize > size) {
        PyOS_snprintf(warning, sizeof(warning), 
            "%s.%s size changed, may indicate binary incompatibility",
            module_name, class_name);
        #if PY_VERSION_HEX < 0x02050000
        PyErr_Warn(NULL, warning);
        #else
        PyErr_WarnEx(NULL, warning, 0);
        #endif
    }
    else if (((PyTypeObject *)result)->tp_basicsize != size) {
        PyErr_Format(PyExc_ValueError, 
            "%s.%s has the wrong size, try recompiling",
            module_name, class_name);
        goto bad;
    }
    return (PyTypeObject *)result;
bad:
    Py_XDECREF(py_module);
    Py_XDECREF(result);
    return 0;
}
#endif

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

    #if PY_MAJOR_VERSION < 3
    py_name = PyString_FromString(name);
    #else
    py_name = PyUnicode_FromString(name);
    #endif
    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

#include "compile.h"
#include "frameobject.h"
#include "traceback.h"

static void __Pyx_AddTraceback(const char *funcname) {
    PyObject *py_srcfile = 0;
    PyObject *py_funcname = 0;
    PyObject *py_globals = 0;
    PyCodeObject *py_code = 0;
    PyFrameObject *py_frame = 0;

    #if PY_MAJOR_VERSION < 3
    py_srcfile = PyString_FromString(__pyx_filename);
    #else
    py_srcfile = PyUnicode_FromString(__pyx_filename);
    #endif
    if (!py_srcfile) goto bad;
    if (__pyx_clineno) {
        #if PY_MAJOR_VERSION < 3
        py_funcname = PyString_FromFormat( "%s (%s:%d)", funcname, __pyx_cfilenm, __pyx_clineno);
        #else
        py_funcname = PyUnicode_FromFormat( "%s (%s:%d)", funcname, __pyx_cfilenm, __pyx_clineno);
        #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_globals = PyModule_GetDict(__pyx_m);
    if (!py_globals) goto bad;
    py_code = PyCode_New(
        0,            /*int argcount,*/
        #if PY_MAJOR_VERSION >= 3
        0,            /*int kwonlyargcount,*/
        #endif
        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,*/
        __pyx_lineno,   /*int firstlineno,*/
        __pyx_empty_bytes  /*PyObject *lnotab*/
    );
    if (!py_code) 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 = __pyx_lineno;
    PyTraceBack_Here(py_frame);
bad:
    Py_XDECREF(py_srcfile);
    Py_XDECREF(py_funcname);
    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;
}

/* Type Conversion Functions */

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_VERSION_HEX < 0x03000000
  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_VERSION_HEX < 0x03000000
  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_VERSION_HEX < 0x03000000
    if (!PyInt_Check(res) && !PyLong_Check(res)) {
#else
    if (!PyLong_Check(res)) {
#endif
      PyErr_Format(PyExc_TypeError,
                   "__%s__ returned non-%s (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;
}

static CYTHON_INLINE Py_ssize_t __Pyx_PyIndex_AsSsize_t(PyObject* b) {
  Py_ssize_t ival;
  PyObject* 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
}

static CYTHON_INLINE size_t __Pyx_PyInt_AsSize_t(PyObject* x) {
   unsigned PY_LONG_LONG val = __Pyx_PyInt_AsUnsignedLongLong(x);
   if (unlikely(val == (unsigned PY_LONG_LONG)-1 && PyErr_Occurred())) {
       return (size_t)-1;
   } else if (unlikely(val != (unsigned PY_LONG_LONG)(size_t)val)) {
       PyErr_SetString(PyExc_OverflowError,
                       "value too large to convert to size_t");
       return (size_t)-1;
   }
   return (size_t)val;
}


#endif /* Py_PYTHON_H */
