lupa-1.6/0000775000175000017500000000000013215037350013104 5ustar stefanstefan00000000000000lupa-1.6/setup.py0000664000175000017500000002432013215036356014624 0ustar stefanstefan00000000000000from __future__ import absolute_import import sys import shutil import os import os.path from glob import iglob try: # use setuptools if available from setuptools import setup, Extension except ImportError: from distutils.core import setup, Extension VERSION = '1.6' extra_setup_args = {} # support 'test' target if setuptools/distribute is available if 'setuptools' in sys.modules: extra_setup_args['test_suite'] = 'lupa.tests.suite' extra_setup_args["zip_safe"] = False class PkgConfigError(RuntimeError): pass def try_int(s): try: return int(s) except ValueError: return s def cmd_output(command): """ Returns the exit code and output of the program, as a triplet of the form (exit_code, stdout, stderr). """ env = os.environ.copy() env['LANG'] = '' import subprocess proc = subprocess.Popen(command, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE, env=env) stdout, stderr = proc.communicate() exit_code = proc.wait() if exit_code != 0: raise PkgConfigError(stderr.decode('ISO8859-1')) return stdout def decode_path_output(s): if sys.version_info[0] < 3: return s # no need to decode, and safer not to do it # we don't really know in which encoding pkgconfig # outputs its results, so we try to guess for encoding in (sys.getfilesystemencoding(), sys.getdefaultencoding(), 'utf8'): try: return s.decode(encoding) except UnicodeDecodeError: pass return s.decode('iso8859-1') # try to find LuaJIT installation using pkgconfig def check_lua_installed(package='luajit', min_version='2'): try: cmd_output('pkg-config %s --exists' % package) except RuntimeError: # pkg-config gives no stdout when it is given --exists and it cannot # find the package, so we'll give it some better output error = sys.exc_info()[1] if not error.args[0]: raise RuntimeError("pkg-config cannot find an installed %s" % package) raise lua_version = cmd_output('pkg-config %s --modversion' % package).decode('iso8859-1') try: if tuple(map(try_int, lua_version.split('.'))) < tuple(map(try_int, min_version.split('.'))): raise PkgConfigError("Expected version %s+ of %s, but found %s" % (min_version, package, lua_version)) except (ValueError, TypeError): print("failed to parse version '%s' of installed %s package, minimum is %s" % ( lua_version, package, min_version)) else: print("pkg-config found %s version %s" % (package, lua_version)) def lua_include(package='luajit'): cflag_out = cmd_output('pkg-config %s --cflags-only-I' % package) cflag_out = decode_path_output(cflag_out) def trim_i(s): if s.startswith('-I'): return s[2:] return s return list(map(trim_i, cflag_out.split())) def lua_libs(package='luajit'): libs_out = cmd_output('pkg-config %s --libs' % package) libs_out = decode_path_output(libs_out) return libs_out.split() basedir = os.path.abspath(os.path.dirname(__file__)) def find_lua_build(no_luajit=False): # try to find local LuaJIT2 build os_path = os.path for filename in os.listdir(basedir): if not filename.lower().startswith('luajit'): continue filepath = os_path.join(basedir, filename, 'src') if not os_path.isdir(filepath): continue libfile = os_path.join(filepath, 'libluajit.a') if os_path.isfile(libfile): print("found LuaJIT build in %s" % filepath) print("building statically") return dict(extra_objects=[libfile], include_dirs=[filepath]) # also check for lua51.lib, the Windows equivalent of libluajit.a for libfile in iglob(os_path.join(filepath, 'lua5?.lib')): if os_path.isfile(libfile): print("found LuaJIT build in %s (%s)" % ( filepath, os.path.basename(libfile))) print("building statically") # And return the dll file name too, as we need to # include it in the install directory return dict(extra_objects=[libfile], include_dirs=[filepath], libfile=libfile) print("No local build of LuaJIT2 found in lupa directory") # try to find installed LuaJIT2 or Lua if no_luajit: packages = [] else: packages = [('luajit', '2')] packages += [ (name, lua_version) for lua_version in ('5.2', '5.1') for name in ('lua%s' % lua_version, 'lua-%s' % lua_version, 'lua') ] for package_name, min_version in packages: print("Checking for installed %s library using pkg-config" % package_name) try: check_lua_installed(package_name, min_version) return dict(extra_objects=lua_libs(package_name), include_dirs=lua_include(package_name)) except RuntimeError: print("Did not find %s using pkg-config: %s" % ( package_name, sys.exc_info()[1])) return {} def no_lua_error(): error = ("Neither LuaJIT2 nor Lua 5.1/5.2 were found. Please install " "Lua and its development packages, " "or put a local build into the lupa main directory.") print(error) return {} def use_bundled_lua(path, lua_sources, macros): print('Using bundled Lua') ext_libraries = [ ['lua', { 'sources': [path + src for src in lua_sources], 'include_dirs': [path], 'macros': macros, }] ] return { 'include_dirs': [path], 'ext_libraries': ext_libraries, } def has_option(name): if name in sys.argv[1:]: sys.argv.remove(name) return True envvar_name = 'LUPA_' + name.lstrip('-').upper().replace('-', '_') return os.environ.get(envvar_name) == 'true' c_defines = [ ] if has_option('--without-assert'): c_defines.append(('CYTHON_WITHOUT_ASSERTIONS', None)) if has_option('--with-lua-checks'): c_defines.append(('LUA_USE_APICHECK', None)) # bundled lua lua_bundle_path = 'third-party/lua/' lua_sources = [ 'lapi.c', 'lcode.c', 'lctype.c', 'ldebug.c', 'ldo.c', 'ldump.c', 'lfunc.c', 'lgc.c', 'llex.c', 'lmem.c', 'lobject.c', 'lopcodes.c', 'lparser.c', 'lstate.c', 'lstring.c', 'ltable.c', 'ltm.c', 'lundump.c', 'lvm.c', 'lzio.c', 'ltests.c', 'lauxlib.c', 'lbaselib.c', 'ldblib.c', 'liolib.c', 'lmathlib.c', 'loslib.c', 'ltablib.c', 'lstrlib.c', 'lutf8lib.c', 'lbitlib.c', 'loadlib.c', 'lcorolib.c', 'linit.c', ] config = None if not has_option('--use-bundle'): config = find_lua_build(no_luajit=has_option('--no-luajit')) if not config and not has_option('--no-bundle'): config = use_bundled_lua(lua_bundle_path, lua_sources, c_defines) if not config: config = no_lua_error() ext_args = { 'extra_objects': config.get('extra_objects'), 'include_dirs': config.get('include_dirs'), 'define_macros': c_defines, } # check if Cython is installed, and use it if requested or necessary use_cython = has_option('--with-cython') if not use_cython: if not os.path.exists(os.path.join(os.path.dirname(__file__), 'lupa', '_lupa.c')): print("generated sources not available, need Cython to build") use_cython = True cythonize = None source_extension = ".c" if use_cython: try: import Cython.Compiler.Version from Cython.Build import cythonize print("building with Cython " + Cython.Compiler.Version.version) source_extension = ".pyx" except ImportError: print("WARNING: trying to build with Cython, but it is not installed") else: print("building without Cython") ext_modules = [ Extension( 'lupa._lupa', sources = ['lupa/_lupa'+source_extension], **ext_args )] if cythonize is not None: ext_modules = cythonize(ext_modules) def read_file(filename): with open(os.path.join(basedir, filename)) as f: return f.read() def write_file(filename, content): with open(os.path.join(basedir, filename), 'w') as f: f.write(content) long_description = '\n\n'.join([ read_file(text_file) for text_file in ['README.rst', 'INSTALL.rst', 'CHANGES.rst', "LICENSE.txt"]]) write_file(os.path.join('lupa', 'version.py'), "__version__ = '%s'\n" % VERSION) if config.get('libfile'): # include lua51.dll in the lib folder if we are on windows dllfile = os.path.splitext(config['libfile'])[0] + ".dll" shutil.copy(dllfile, os.path.join(basedir, 'lupa')) extra_setup_args['package_data'] = {'lupa': [os.path.basename(dllfile)]} # call distutils setup( name="lupa", version=VERSION, author="Stefan Behnel", author_email="stefan_ml@behnel.de", maintainer="Lupa-dev mailing list", maintainer_email="lupa-dev@freelists.org", url="https://github.com/scoder/lupa", description="Python wrapper around Lua and LuaJIT", long_description=long_description, license='MIT style', classifiers=[ 'Development Status :: 5 - Production/Stable', 'Intended Audience :: Developers', 'Intended Audience :: Information Technology', 'License :: OSI Approved :: MIT License', 'Programming Language :: Cython', 'Programming Language :: Python :: 2', 'Programming Language :: Python :: 2.6', 'Programming Language :: Python :: 2.7', 'Programming Language :: Python :: 3', 'Programming Language :: Python :: 3.3', 'Programming Language :: Python :: 3.4', 'Programming Language :: Python :: 3.5', 'Programming Language :: Python :: 3.6', 'Programming Language :: Other Scripting Engines', 'Operating System :: OS Independent', 'Topic :: Software Development', ], packages=['lupa'], ext_modules=ext_modules, libraries=config.get('ext_libraries'), **extra_setup_args ) lupa-1.6/PKG-INFO0000664000175000017500000016551413215037350014215 0ustar stefanstefan00000000000000Metadata-Version: 1.1 Name: lupa Version: 1.6 Summary: Python wrapper around Lua and LuaJIT Home-page: https://github.com/scoder/lupa Author: Lupa-dev mailing list Author-email: lupa-dev@freelists.org License: MIT style Description: Lupa ==== Lupa integrates the runtimes of Lua_ or LuaJIT2_ into CPython. It is a partial rewrite of LunaticPython_ in Cython_ with some additional features such as proper coroutine support. .. _Lua: http://lua.org/ .. _LuaJIT2: http://luajit.org/ .. _LunaticPython: http://labix.org/lunatic-python .. _Cython: http://cython.org For questions not answered here, please contact the `Lupa mailing list`_. .. _`Lupa mailing list`: http://www.freelists.org/list/lupa-dev .. contents:: :local: Major features -------------- * separate Lua runtime states through a ``LuaRuntime`` class * Python coroutine wrapper for Lua coroutines * iteration support for Python objects in Lua and Lua objects in Python * proper encoding and decoding of strings (configurable per runtime, UTF-8 by default) * frees the GIL and supports threading in separate runtimes when calling into Lua * tested with Python 2.6/3.2 and later * written for LuaJIT2 (tested with LuaJIT 2.0.2), but also works with the normal Lua interpreter (5.1 and 5.2) * easy to hack on and extend as it is written in Cython, not C Why the name? ------------- In Latin, "lupa" is a female wolf, as elegant and wild as it sounds. If you don't like this kind of straight forward allegory to an endangered species, you may also happily assume it's just an amalgamation of the phonetic sounds that start the words "Lua" and "Python", two from each to keep the balance. Why use it? ----------- It complements Python very well. Lua is a language as dynamic as Python, but LuaJIT compiles it to very fast machine code, sometimes faster than many statically compiled languages for computational code. The language runtime is very small and carefully designed for embedding. The complete binary module of Lupa, including a statically linked LuaJIT2 runtime, only weighs some 700KB on a 64 bit machine. With standard Lua 5.1, it's less than 400KB. However, the Lua ecosystem lacks many of the batteries that Python readily includes, either directly in its standard library or as third party packages. This makes real-world Lua applications harder to write than equivalent Python applications. Lua is therefore not commonly used as primary language for large applications, but it makes for a fast, high-level and resource-friendly backup language inside of Python when raw speed is required and the edit-compile-run cycle of binary extension modules is too heavy and too static for agile development or hot-deployment. Lupa is a very fast and thin wrapper around Lua or LuaJIT. It makes it easy to write dynamic Lua code that accompanies dynamic Python code by switching between the two languages at runtime, based on the tradeoff between simplicity and speed. Examples -------- .. ## doctest helpers: >>> try: _ = sorted ... except NameError: ... def sorted(seq): ... l = list(seq) ... l.sort() ... return l .. code:: python >>> import lupa >>> from lupa import LuaRuntime >>> lua = LuaRuntime(unpack_returned_tuples=True) >>> lua.eval('1+1') 2 >>> lua_func = lua.eval('function(f, n) return f(n) end') >>> def py_add1(n): return n+1 >>> lua_func(py_add1, 2) 3 >>> lua.eval('python.eval(" 2 ** 2 ")') == 4 True >>> lua.eval('python.builtins.str(4)') == '4' True The function ``lua_type(obj)`` can be used to find out the type of a wrapped Lua object in Python code, as provided by Lua's ``type()`` function: .. code:: python >>> lupa.lua_type(lua_func) 'function' >>> lupa.lua_type(lua.eval('{}')) 'table' To help in distinguishing between wrapped Lua objects and normal Python objects, it returns ``None`` for the latter: .. code:: python >>> lupa.lua_type(123) is None True >>> lupa.lua_type('abc') is None True >>> lupa.lua_type({}) is None True Note the flag ``unpack_returned_tuples=True`` that is passed to create the Lua runtime. It is new in Lupa 0.21 and changes the behaviour of tuples that get returned by Python functions. With this flag, they explode into separate Lua values: .. code:: python >>> lua.execute('a,b,c = python.eval("(1,2)")') >>> g = lua.globals() >>> g.a 1 >>> g.b 2 >>> g.c is None True When set to False, functions that return a tuple pass it through to the Lua code: .. code:: python >>> non_explode_lua = lupa.LuaRuntime(unpack_returned_tuples=False) >>> non_explode_lua.execute('a,b,c = python.eval("(1,2)")') >>> g = non_explode_lua.globals() >>> g.a (1, 2) >>> g.b is None True >>> g.c is None True Since the default behaviour (to not explode tuples) might change in a later version of Lupa, it is best to always pass this flag explicitly. Python objects in Lua --------------------- Python objects are either converted when passed into Lua (e.g. numbers and strings) or passed as wrapped object references. .. code:: python >>> wrapped_type = lua.globals().type # Lua's own type() function >>> wrapped_type(1) == 'number' True >>> wrapped_type('abc') == 'string' True Wrapped Lua objects get unwrapped when they are passed back into Lua, and arbitrary Python objects get wrapped in different ways: .. code:: python >>> wrapped_type(wrapped_type) == 'function' # unwrapped Lua function True >>> wrapped_type(len) == 'userdata' # wrapped Python function True >>> wrapped_type([]) == 'userdata' # wrapped Python object True Lua supports two main protocols on objects: calling and indexing. It does not distinguish between attribute access and item access like Python does, so the Lua operations ``obj[x]`` and ``obj.x`` both map to indexing. To decide which Python protocol to use for Lua wrapped objects, Lupa employs a simple heuristic. Pratically all Python objects allow attribute access, so if the object also has a ``__getitem__`` method, it is preferred when turning it into an indexable Lua object. Otherwise, it becomes a simple object that uses attribute access for indexing from inside Lua. Obviously, this heuristic will fail to provide the required behaviour in many cases, e.g. when attribute access is required to an object that happens to support item access. To be explicit about the protocol that should be used, Lupa provides the helper functions ``as_attrgetter()`` and ``as_itemgetter()`` that restrict the view on an object to a certain protocol, both from Python and from inside Lua: .. code:: python >>> lua_func = lua.eval('function(obj) return obj["get"] end') >>> d = {'get' : 'value'} >>> value = lua_func(d) >>> value == d['get'] == 'value' True >>> value = lua_func( lupa.as_itemgetter(d) ) >>> value == d['get'] == 'value' True >>> dict_get = lua_func( lupa.as_attrgetter(d) ) >>> dict_get == d.get True >>> dict_get('get') == d.get('get') == 'value' True >>> lua_func = lua.eval( ... 'function(obj) return python.as_attrgetter(obj)["get"] end') >>> dict_get = lua_func(d) >>> dict_get('get') == d.get('get') == 'value' True Note that unlike Lua function objects, callable Python objects support indexing in Lua: .. code:: python >>> def py_func(): pass >>> py_func.ATTR = 2 >>> lua_func = lua.eval('function(obj) return obj.ATTR end') >>> lua_func(py_func) 2 >>> lua_func = lua.eval( ... 'function(obj) return python.as_attrgetter(obj).ATTR end') >>> lua_func(py_func) 2 >>> lua_func = lua.eval( ... 'function(obj) return python.as_attrgetter(obj)["ATTR"] end') >>> lua_func(py_func) 2 Iteration in Lua ---------------- Iteration over Python objects from Lua's for-loop is fully supported. However, Python iterables need to be converted using one of the utility functions which are described here. This is similar to the functions like ``pairs()`` in Lua. To iterate over a plain Python iterable, use the ``python.iter()`` function. For example, you can manually copy a Python list into a Lua table like this: .. code:: python >>> lua_copy = lua.eval(''' ... function(L) ... local t, i = {}, 1 ... for item in python.iter(L) do ... t[i] = item ... i = i + 1 ... end ... return t ... end ... ''') >>> table = lua_copy([1,2,3,4]) >>> len(table) 4 >>> table[1] # Lua indexing 1 Python's ``enumerate()`` function is also supported, so the above could be simplified to: .. code:: python >>> lua_copy = lua.eval(''' ... function(L) ... local t = {} ... for index, item in python.enumerate(L) do ... t[ index+1 ] = item ... end ... return t ... end ... ''') >>> table = lua_copy([1,2,3,4]) >>> len(table) 4 >>> table[1] # Lua indexing 1 For iterators that return tuples, such as ``dict.iteritems()``, it is convenient to use the special ``python.iterex()`` function that automatically explodes the tuple items into separate Lua arguments: .. code:: python >>> lua_copy = lua.eval(''' ... function(d) ... local t = {} ... for key, value in python.iterex(d.items()) do ... t[key] = value ... end ... return t ... end ... ''') >>> d = dict(a=1, b=2, c=3) >>> table = lua_copy( lupa.as_attrgetter(d) ) >>> table['b'] 2 Note that accessing the ``d.items`` method from Lua requires passing the dict as ``attrgetter``. Otherwise, attribute access in Lua would use the ``getitem`` protocol of Python dicts and look up ``d['items']`` instead. None vs. nil ------------ While ``None`` in Python and ``nil`` in Lua differ in their semantics, they usually just mean the same thing: no value. Lupa therefore tries to map one directly to the other whenever possible: .. code:: python >>> lua.eval('nil') is None True >>> is_nil = lua.eval('function(x) return x == nil end') >>> is_nil(None) True The only place where this cannot work is during iteration, because Lua considers a ``nil`` value the termination marker of iterators. Therefore, Lupa special cases ``None`` values here and replaces them by a constant ``python.none`` instead of returning ``nil``: .. code:: python >>> _ = lua.require("table") >>> func = lua.eval(''' ... function(items) ... local t = {} ... for value in python.iter(items) do ... table.insert(t, value == python.none) ... end ... return t ... end ... ''') >>> items = [1, None ,2] >>> list(func(items).values()) [False, True, False] Lupa avoids this value escaping whenever it's obviously not necessary. Thus, when unpacking tuples during iteration, only the first value will be subject to ``python.none`` replacement, as Lua does not look at the other items for loop termination anymore. And on ``enumerate()`` iteration, the first value is known to be always a number and never None, so no replacement is needed. .. code:: python >>> func = lua.eval(''' ... function(items) ... for a, b, c, d in python.iterex(items) do ... return {a == python.none, a == nil, --> a == python.none ... b == python.none, b == nil, --> b == nil ... c == python.none, c == nil, --> c == nil ... d == python.none, d == nil} --> d == nil ... ... end ... end ... ''') >>> items = [(None, None, None, None)] >>> list(func(items).values()) [True, False, False, True, False, True, False, True] >>> items = [(None, None)] # note: no values for c/d => nil in Lua >>> list(func(items).values()) [True, False, False, True, False, True, False, True] Note that this behaviour changed in Lupa 1.0. Previously, the ``python.none`` replacement was done in more places, which made it not always very predictable. Lua Tables ---------- Lua tables mimic Python's mapping protocol. For the special case of array tables, Lua automatically inserts integer indices as keys into the table. Therefore, indexing starts from 1 as in Lua instead of 0 as in Python. For the same reason, negative indexing does not work. It is best to think of Lua tables as mappings rather than arrays, even for plain array tables. .. code:: python >>> table = lua.eval('{10,20,30,40}') >>> table[1] 10 >>> table[4] 40 >>> list(table) [1, 2, 3, 4] >>> list(table.values()) [10, 20, 30, 40] >>> len(table) 4 >>> mapping = lua.eval('{ [1] = -1 }') >>> list(mapping) [1] >>> mapping = lua.eval('{ [20] = -20; [3] = -3 }') >>> mapping[20] -20 >>> mapping[3] -3 >>> sorted(mapping.values()) [-20, -3] >>> sorted(mapping.items()) [(3, -3), (20, -20)] >>> mapping[-3] = 3 # -3 used as key, not index! >>> mapping[-3] 3 >>> sorted(mapping) [-3, 3, 20] >>> sorted(mapping.items()) [(-3, 3), (3, -3), (20, -20)] To simplify the table creation from Python, the ``LuaRuntime`` comes with a helper method that creates a Lua table from Python arguments: .. code:: python >>> t = lua.table(1, 2, 3, 4) >>> lupa.lua_type(t) 'table' >>> list(t) [1, 2, 3, 4] >>> t = lua.table(1, 2, 3, 4, a=1, b=2) >>> t[3] 3 >>> t['b'] 2 A second helper method, ``.table_from()``, is new in Lupa 1.1 and accepts any number of mappings and sequences/iterables as arguments. It collects all values and key-value pairs and builds a single Lua table from them. Any keys that appear in multiple mappings get overwritten with their last value (going from left to right). .. code:: python >>> t = lua.table_from([1, 2, 3], {'a': 1, 'b': 2}, (4, 5), {'b': 42}) >>> t['b'] 42 >>> t[5] 5 A lookup of non-existing keys or indices returns None (actually ``nil`` inside of Lua). A lookup is therefore more similar to the ``.get()`` method of Python dicts than to a mapping lookup in Python. .. code:: python >>> table[1000000] is None True >>> table['no such key'] is None True >>> mapping['no such key'] is None True Note that ``len()`` does the right thing for array tables but does not work on mappings: .. code:: python >>> len(table) 4 >>> len(mapping) 0 This is because ``len()`` is based on the ``#`` (length) operator in Lua and because of the way Lua defines the length of a table. Remember that unset table indices always return ``nil``, including indices outside of the table size. Thus, Lua basically looks for an index that returns ``nil`` and returns the index before that. This works well for array tables that do not contain ``nil`` values, gives barely predictable results for tables with 'holes' and does not work at all for mapping tables. For tables with both sequential and mapping content, this ignores the mapping part completely. Note that it is best not to rely on the behaviour of len() for mappings. It might change in a later version of Lupa. Similar to the table interface provided by Lua, Lupa also supports attribute access to table members: .. code:: python >>> table = lua.eval('{ a=1, b=2 }') >>> table.a, table.b (1, 2) >>> table.a == table['a'] True This enables access to Lua 'methods' that are associated with a table, as used by the standard library modules: .. code:: python >>> string = lua.eval('string') # get the 'string' library table >>> print( string.lower('A') ) a Python Callables ---------------- As discussed earlier, Lupa allows Lua scripts to call Python functions and methods: .. code:: python >>> def add_one(num): ... return num + 1 >>> lua_func = lua.eval('function(num, py_func) return py_func(num) end') >>> lua_func(48, add_one) 49 >>> class MyClass(): ... def my_method(self): ... return 345 >>> obj = MyClass() >>> lua_func = lua.eval('function(py_obj) return py_obj:my_method() end') >>> lua_func(obj) 345 Lua doesn't have a dedicated syntax for named arguments, so by default Python callables can only be called using positional arguments. A common pattern for implementing named arguments in Lua is passing them in a table as the first and only function argument. See http://lua-users.org/wiki/NamedParameters for more details. Lupa supports this pattern by providing two decorators: ``lupa.unpacks_lua_table`` for Python functions and ``lupa.unpacks_lua_table_method`` for methods of Python objects. Python functions/methods wrapped in these decorators can be called from Lua code as ``func(foo, bar)``, ``func{foo=foo, bar=bar}`` or ``func{foo, bar=bar}``. Example: .. code:: python >>> @lupa.unpacks_lua_table ... def add(a, b): ... return a + b >>> lua_func = lua.eval('function(a, b, py_func) return py_func{a=a, b=b} end') >>> lua_func(5, 6, add) 11 >>> lua_func = lua.eval('function(a, b, py_func) return py_func{a, b=b} end') >>> lua_func(5, 6, add) 11 If you do not control the function implementation, you can also just manually wrap a callable object when passing it into Lupa: .. code:: python >>> import operator >>> wrapped_py_add = lupa.unpacks_lua_table(operator.add) >>> lua_func = lua.eval('function(a, b, py_func) return py_func{a, b} end') >>> lua_func(5, 6, wrapped_py_add) 11 There are some limitations: 1. Avoid using ``lupa.unpacks_lua_table`` and ``lupa.unpacks_lua_table_method`` for functions where the first argument can be a Lua table. In this case ``py_func{foo=bar}`` (which is the same as ``py_func({foo=bar})`` in Lua) becomes ambiguous: it could mean either "call ``py_func`` with a named ``foo`` argument" or "call ``py_func`` with a positional ``{foo=bar}`` argument". 2. One should be careful with passing ``nil`` values to callables wrapped in ``lupa.unpacks_lua_table`` or ``lupa.unpacks_lua_table_method`` decorators. Depending on the context, passing ``nil`` as a parameter can mean either "omit a parameter" or "pass None". This even depends on the Lua version. It is possible to use ``python.none`` instead of ``nil`` to pass None values robustly. Arguments with ``nil`` values are also fine when standard braces ``func(a, b, c)`` syntax is used. Because of these limitations lupa doesn't enable named arguments for all Python callables automatically. Decorators allow to enable named arguments on a per-callable basis. Lua Coroutines -------------- The next is an example of Lua coroutines. A wrapped Lua coroutine behaves exactly like a Python coroutine. It needs to get created at the beginning, either by using the ``.coroutine()`` method of a function or by creating it in Lua code. Then, values can be sent into it using the ``.send()`` method or it can be iterated over. Note that the ``.throw()`` method is not supported, though. .. code:: python >>> lua_code = '''\ ... function(N) ... for i=0,N do ... coroutine.yield( i%2 ) ... end ... end ... ''' >>> lua = LuaRuntime() >>> f = lua.eval(lua_code) >>> gen = f.coroutine(4) >>> list(enumerate(gen)) [(0, 0), (1, 1), (2, 0), (3, 1), (4, 0)] An example where values are passed into the coroutine using its ``.send()`` method: .. code:: python >>> lua_code = '''\ ... function() ... local t,i = {},0 ... local value = coroutine.yield() ... while value do ... t[i] = value ... i = i + 1 ... value = coroutine.yield() ... end ... return t ... end ... ''' >>> f = lua.eval(lua_code) >>> co = f.coroutine() # create coroutine >>> co.send(None) # start coroutine (stops at first yield) >>> for i in range(3): ... co.send(i*2) >>> mapping = co.send(None) # loop termination signal >>> sorted(mapping.items()) [(0, 0), (1, 2), (2, 4)] It also works to create coroutines in Lua and to pass them back into Python space: .. code:: python >>> lua_code = '''\ ... function f(N) ... for i=0,N do ... coroutine.yield( i%2 ) ... end ... end ; ... co1 = coroutine.create(f) ; ... co2 = coroutine.create(f) ; ... ... status, first_result = coroutine.resume(co2, 2) ; -- starting! ... ... return f, co1, co2, status, first_result ... ''' >>> lua = LuaRuntime() >>> f, co, lua_gen, status, first_result = lua.execute(lua_code) >>> # a running coroutine: >>> status True >>> first_result 0 >>> list(lua_gen) [1, 0] >>> list(lua_gen) [] >>> # an uninitialised coroutine: >>> gen = co(4) >>> list(enumerate(gen)) [(0, 0), (1, 1), (2, 0), (3, 1), (4, 0)] >>> gen = co(2) >>> list(enumerate(gen)) [(0, 0), (1, 1), (2, 0)] >>> # a plain function: >>> gen = f.coroutine(4) >>> list(enumerate(gen)) [(0, 0), (1, 1), (2, 0), (3, 1), (4, 0)] Threading --------- The following example calculates a mandelbrot image in parallel threads and displays the result in PIL. It is based on a `benchmark implementation`_ for the `Computer Language Benchmarks Game`_. .. _`Computer Language Benchmarks Game`: http://shootout.alioth.debian.org/u64/benchmark.php?test=all&lang=luajit&lang2=python3 .. _`benchmark implementation`: http://shootout.alioth.debian.org/u64/program.php?test=mandelbrot&lang=luajit&id=1 .. code:: python lua_code = '''\ function(N, i, total) local char, unpack = string.char, unpack local result = "" local M, ba, bb, buf = 2/N, 2^(N%8+1)-1, 2^(8-N%8), {} local start_line, end_line = N/total * (i-1), N/total * i - 1 for y=start_line,end_line do local Ci, b, p = y*M-1, 1, 0 for x=0,N-1 do local Cr = x*M-1.5 local Zr, Zi, Zrq, Ziq = Cr, Ci, Cr*Cr, Ci*Ci b = b + b for i=1,49 do Zi = Zr*Zi*2 + Ci Zr = Zrq-Ziq + Cr Ziq = Zi*Zi Zrq = Zr*Zr if Zrq+Ziq > 4.0 then b = b + 1; break; end end if b >= 256 then p = p + 1; buf[p] = 511 - b; b = 1; end end if b ~= 1 then p = p + 1; buf[p] = (ba-b)*bb; end result = result .. char(unpack(buf, 1, p)) end return result end ''' image_size = 1280 # == 1280 x 1280 thread_count = 8 from lupa import LuaRuntime lua_funcs = [ LuaRuntime(encoding=None).eval(lua_code) for _ in range(thread_count) ] results = [None] * thread_count def mandelbrot(i, lua_func): results[i] = lua_func(image_size, i+1, thread_count) import threading threads = [ threading.Thread(target=mandelbrot, args=(i,lua_func)) for i, lua_func in enumerate(lua_funcs) ] for thread in threads: thread.start() for thread in threads: thread.join() result_buffer = b''.join(results) # use PIL to display the image import Image image = Image.fromstring('1', (image_size, image_size), result_buffer) image.show() Note how the example creates a separate ``LuaRuntime`` for each thread to enable parallel execution. Each ``LuaRuntime`` is protected by a global lock that prevents concurrent access to it. The low memory footprint of Lua makes it reasonable to use multiple runtimes, but this setup also means that values cannot easily be exchanged between threads inside of Lua. They must either get copied through Python space (passing table references will not work, either) or use some Lua mechanism for explicit communication, such as a pipe or some kind of shared memory setup. Restricting Lua access to Python objects ---------------------------------------- .. >>> try: unicode = unicode ... except NameError: unicode = str Lupa provides a simple mechanism to control access to Python objects. Each attribute access can be passed through a filter function as follows: .. code:: python >>> def filter_attribute_access(obj, attr_name, is_setting): ... if isinstance(attr_name, unicode): ... if not attr_name.startswith('_'): ... return attr_name ... raise AttributeError('access denied') >>> lua = lupa.LuaRuntime( ... register_eval=False, ... attribute_filter=filter_attribute_access) >>> func = lua.eval('function(x) return x.__class__ end') >>> func(lua) Traceback (most recent call last): ... AttributeError: access denied The ``is_setting`` flag indicates whether the attribute is being read or set. Note that the attributes of Python functions provide access to the current ``globals()`` and therefore to the builtins etc. If you want to safely restrict access to a known set of Python objects, it is best to work with a whitelist of safe attribute names. One way to do that could be to use a well selected list of dedicated API objects that you provide to Lua code, and to only allow Python attribute access to the set of public attribute/method names of these objects. Since Lupa 1.0, you can alternatively provide dedicated getter and setter function implementations for a ``LuaRuntime``: .. code:: python >>> def getter(obj, attr_name): ... if attr_name == 'yes': ... return getattr(obj, attr_name) ... raise AttributeError( ... 'not allowed to read attribute "%s"' % attr_name) >>> def setter(obj, attr_name, value): ... if attr_name == 'put': ... setattr(obj, attr_name, value) ... return ... raise AttributeError( ... 'not allowed to write attribute "%s"' % attr_name) >>> class X(object): ... yes = 123 ... put = 'abc' ... noway = 2.1 >>> x = X() >>> lua = lupa.LuaRuntime(attribute_handlers=(getter, setter)) >>> func = lua.eval('function(x) return x.yes end') >>> func(x) # getting 'yes' 123 >>> func = lua.eval('function(x) x.put = "ABC"; end') >>> func(x) # setting 'put' >>> print(x.put) ABC >>> func = lua.eval('function(x) x.noway = 42; end') >>> func(x) # setting 'noway' Traceback (most recent call last): ... AttributeError: not allowed to write attribute "noway" Importing Lua binary modules ---------------------------- **This will usually work as is**, but here are the details, in case anything goes wrong for you. To use binary modules in Lua, you need to compile them against the header files of the LuaJIT sources that you used to build Lupa, but do not link them against the LuaJIT library. Furthermore, CPython needs to enable global symbol visibility for shared libraries before loading the Lupa module. This can be done by calling ``sys.setdlopenflags(flag_values)``. Importing the ``lupa`` module will automatically try to set up the correct ``dlopen`` flags if it can find the platform specific ``DLFCN`` Python module that defines the necessary flag constants. In that case, using binary modules in Lua should work out of the box. If this setup fails, however, you have to set the flags manually. When using the above configuration call, the argument ``flag_values`` must represent the sum of your system's values for ``RTLD_NEW`` and ``RTLD_GLOBAL``. If ``RTLD_NEW`` is 2 and ``RTLD_GLOBAL`` is 256, you need to call ``sys.setdlopenflags(258)``. Assuming that the Lua luaposix_ (``posix``) module is available, the following should work on a Linux system: .. code:: python >>> import sys >>> orig_dlflags = sys.getdlopenflags() >>> sys.setdlopenflags(258) >>> import lupa >>> sys.setdlopenflags(orig_dlflags) >>> lua = lupa.LuaRuntime() >>> posix_module = lua.require('posix') # doctest: +SKIP .. _luaposix: http://git.alpinelinux.org/cgit/luaposix Installing lupa =============== Building with LuaJIT2 --------------------- #) Download and unpack lupa http://pypi.python.org/pypi/lupa #) Download LuaJIT2 http://luajit.org/download.html #) Unpack the archive into the lupa base directory, e.g.:: .../lupa-0.1/LuaJIT-2.0.2 #) Build LuaJIT:: cd LuaJIT-2.0.2 make cd .. If you need specific C compiler flags, pass them to ``make`` as follows:: make CFLAGS="..." For trickier target platforms like Windows and MacOS-X, please see the official `installation instructions for LuaJIT`_. NOTE: When building on Windows, make sure that lua51.lib is made in addition to lua51.dll. The MSVC build produces this file, MinGW does NOT. #) Build lupa:: python setup.py install Or any other distutils target of your choice, such as ``build`` or one of the ``bdist`` targets. See the `distutils documentation`_ for help, also the `hints on building extension modules`_. Note that on 64bit MacOS-X installations, the following additional compiler flags are reportedly required due to the embedded LuaJIT:: -pagezero_size 10000 -image_base 100000000 You can find additional installation hints for MacOS-X in this `somewhat unclear blog post`_, which may or may not tell you at which point in the installation process to provide these flags. Also, on 64bit MacOS-X, you will typically have to set the environment variable ``ARCHFLAGS`` to make sure it only builds for your system instead of trying to generate a fat binary with both 32bit and 64bit support:: export ARCHFLAGS="-arch x86_64" Note that this applies to both LuaJIT and Lupa, so make sure you try a clean build of everything if you forgot to set it initially. .. _`installation instructions for LuaJIT`: http://luajit.org/install.html .. _`somewhat unclear blog post`: http://t-p-j.blogspot.com/2010/11/lupa-on-os-x-with-macports-python-26.html .. _`distutils documentation`: http://docs.python.org/install/index.html#install-index .. _`hints on building extension modules`: http://docs.python.org/install/index.html#building-extensions-tips-and-tricks Building with Lua 5.1 --------------------- Reportedly, it also works to use Lupa with the standard (non-JIT) Lua runtime. To that end, install Lua 5.1 instead of LuaJIT2, including any development packages (header files etc.). On systems that use the "pkg-config" configuration mechanism, Lupa's setup.py will pick up either LuaJIT2 or Lua automatically, with a preference for LuaJIT2 if it is found. Pass the ``--no-luajit`` option to the setup.py script if you have both installed but do not want to use LuaJIT2. On other systems, you may have to supply the build parameters externally, e.g. using environment variables or by changing the setup.py script manually. Pass the ``--no-luajit`` option to the setup.py script in order to ignore the failure you get when neither LuaJIT2 nor Lua are found automatically. For further information, read this mailing list post: http://article.gmane.org/gmane.comp.python.lupa.devel/31 Installing lupa from packages ============================= Debian/Ubuntu + Lua 5.2 ----------------------- #) Install Lua 5.2 development package:: $ apt-get install liblua5.2-dev #) Install lupa:: $ pip install lupa Debian/Ubuntu + LuaJIT2 ----------------------- #) Install LuaJIT2 development package:: $ apt-get install libluajit-5.1-dev #) Install lupa:: $ pip install lupa Depending on OS version, you might get an older LuaJIT2 version. OS X + Lua 5.2 + Homebrew ------------------------- #) Install Lua:: $ brew install lua #) Install pkg-config:: $ brew install pkg-config #) Install lupa:: $ pip install lupa Lupa change log =============== 1.6 (2017-12-15) ---------------- * GH#95: Improved compatibility with Lua 5.3. (patch by TitanSnow) 1.5 (2017-09-16) ---------------- * GH#93: New method ``LuaRuntime.compile()`` to compile Lua code without executing it. (patch by TitanSnow) * GH#91: Lua 5.3 is bundled in the source distribution to simplify one-shot installs. (patch by TitanSnow) * GH#87: Lua stack trace is included in output in debug mode. (patch by aaiyer) * GH#78: Allow Lua code to intercept Python exceptions. (patch by Sergey Dobrov) * Built with Cython 0.26.1. 1.4 (2016-12-10) ---------------- * GH#82: Lua coroutines were using the wrong runtime state (patch by Sergey Dobrov) * GH#81: copy locally provided Lua DLL into installed package on Windows (patch by Gareth Coles) * built with Cython 0.25.2 1.3 (2016-04-12) ---------------- * GH#70: ``eval()`` and ``execute()`` accept optional positional arguments (patch by John Vandenberg) * GH#65: calling ``str()`` on a Python object from Lua could fail if the ``LuaRuntime`` is set up without auto-encoding (patch by Mikhail Korobov) * GH#63: attribute/keyword names were not properly encoded if the ``LuaRuntime`` is set up without auto-encoding (patch by Mikhail Korobov) * built with Cython 0.24 1.2 (2015-10-10) ---------------- * callbacks returned from Lua coroutines were incorrectly mixing coroutine state with global Lua state (patch by Mikhail Korobov) * availability of ``python.builtins`` in Lua can be disabled via ``LuaRuntime`` option. * built with Cython 0.23.4 1.1 (2014-11-21) ---------------- * new module function ``lupa.lua_type()`` that returns the Lua type of a wrapped object as string, or ``None`` for normal Python objects * new helper method ``LuaRuntime.table_from(...)`` that creates a Lua table from one or more Python mappings and/or sequences * new ``lupa.unpacks_lua_table`` and ``lupa.unpacks_lua_table_method`` decorators to allow calling Python functions from Lua using named arguments * fix a hang on shutdown where the LuaRuntime failed to deallocate due to reference cycles * Lupa now plays more nicely with other Lua extensions that create userdata objects 1.0.1 (2014-10-11) ------------------ * fix a crash when requesting attributes of wrapped Lua coroutine objects * looking up attributes on Lua objects that do not support it now always raises an AttributeError instead of sometimes raising a TypeError depending on the attribute name 1.0 (2014-09-28) ---------------- * NOTE: this release includes the major backwards incompatible changes listed below. It is believed that they simplify the interaction between Python code and Lua code by more strongly following idiomatic Lua on the Lua side. * Instead of passing a wrapped ``python.none`` object into Lua, ``None`` return values are now mapped to ``nil``, making them more straight forward to handle in Lua code. This makes the behaviour more consistent, as it was previously somewhat arbitrary where ``none`` could appear and where a ``nil`` value was used. The only remaining exception is during iteration, where the first returned value must not be ``nil`` in Lua, or otherwise the loop terminates prematurely. To prevent this, any ``None`` value that the iterator returns, or any first item in exploded tuples that is ``None``, is still mapped to ``python.none``. Any further values returned in the same iteration will be mapped to ``nil`` if they are ``None``, not to ``none``. This means that only the first argument needs to be manually checked for this special case. For the ``enumerate()`` iterator, the counter is never ``None`` and thus the following unpacked items will never be mapped to ``python.none``. * When ``unpack_returned_tuples=True``, iteration now also unpacks tuple values, including ``enumerate()`` iteration, which yields a flat sequence of counter and unpacked values. * When calling bound Python methods from Lua as "obj:meth()", Lupa now prevents Python from prepending the self argument a second time, so that the Python method is now called as "obj.meth()". Previously, it was called as "obj.meth(obj)". Note that this can be undesired when the object itself is explicitly passed as first argument from Lua, e.g. when calling "func(obj)" where "func" is "obj.meth", but these constellations should be rare. As a work-around for this case, user code can wrap the bound method in another function so that the final call comes from Python. * garbage collection works for reference cycles that span both runtimes, Python and Lua * calling from Python into Lua and back into Python did not clean up the Lua call arguments before the innermost call, so that they could leak into the nested Python call or its return arguments * support for Lua 5.2 (in addition to Lua 5.1 and LuaJIT 2.0) * Lua tables support Python's "del" statement for item deletion (patch by Jason Fried) * Attribute lookup can use a more fine-grained control mechanism by implementing explicit getter and setter functions for a LuaRuntime (``attribute_handlers`` argument). Patch by Brian Moe. * item assignments/lookups on Lua objects from Python no longer special case double underscore names (as opposed to attribute lookups) 0.21 (2014-02-12) ----------------- * some garbage collection issues were cleaned up using new Cython features * new ``LuaRuntime`` option ``unpack_returned_tuples`` which automatically unpacks tuples returned from Python functions into separate Lua objects (instead of returning a single Python tuple object) * some internal wrapper classes were removed from the module API * Windows build fixes * Py3.x build fixes * support for building with Lua 5.1 instead of LuaJIT (setup.py --no-luajit) * no longer uses Cython by default when building from released sources (pass ``--with-cython`` to explicitly request a rebuild) * requires Cython 0.20+ when building from unreleased sources * built with Cython 0.20.1 0.20 (2011-05-22) ----------------- * fix "deallocating None" crash while iterating over Lua tables in Python code * support for filtering attribute access to Python objects for Lua code * fix: setting source encoding for Lua code was broken 0.19 (2011-03-06) ----------------- * fix serious resource leak when creating multiple LuaRuntime instances * portability fix for binary module importing 0.18 (2010-11-06) ----------------- * fix iteration by returning ``Py_None`` object for ``None`` instead of ``nil``, which would terminate the iteration * when converting Python values to Lua, represent ``None`` as a ``Py_None`` object in places where ``nil`` has a special meaning, but leave it as ``nil`` where it doesn't hurt * support for counter start value in ``python.enumerate()`` * native implementation for ``python.enumerate()`` that is several times faster * much faster Lua iteration over Python objects 0.17 (2010-11-05) ----------------- * new helper function ``python.enumerate()`` in Lua that returns a Lua iterator for a Python object and adds the 0-based index to each item. * new helper function ``python.iterex()`` in Lua that returns a Lua iterator for a Python object and unpacks any tuples that the iterator yields. * new helper function ``python.iter()`` in Lua that returns a Lua iterator for a Python object. * reestablished the ``python.as_function()`` helper function for Lua code as it can be needed in cases where Lua cannot determine how to run a Python function. 0.16 (2010-09-03) ----------------- * dropped ``python.as_function()`` helper function for Lua as all Python objects are callable from Lua now (potentially raising a ``TypeError`` at call time if they are not callable) * fix regression in 0.13 and later where ordinary Lua functions failed to print due to an accidentally used meta table * fix crash when calling ``str()`` on wrapped Lua objects without metatable 0.15 (2010-09-02) ----------------- * support for loading binary Lua modules on systems that support it 0.14 (2010-08-31) ----------------- * relicensed to the MIT license used by LuaJIT2 to simplify licensing considerations 0.13.1 (2010-08-30) ------------------- * fix Cython generated C file using Cython 0.13 0.13 (2010-08-29) ----------------- * fixed undefined behaviour on ``str(lua_object)`` when the object's ``__tostring()`` meta method fails * removed redundant "error:" prefix from ``LuaError`` messages * access to Python's ``python.builtins`` from Lua code * more generic wrapping rules for Python objects based on supported protocols (callable, getitem, getattr) * new helper functions ``as_attrgetter()`` and ``as_itemgetter()`` to specify the Python object protocol used by Lua indexing when wrapping Python objects in Python code * new helper functions ``python.as_attrgetter()``, ``python.as_itemgetter()`` and ``python.as_function()`` to specify the Python object protocol used by Lua indexing of Python objects in Lua code * item and attribute access for Python objects from Lua code 0.12 (2010-08-16) ----------------- * fix Lua stack leak during table iteration * fix lost Lua object reference after iteration 0.11 (2010-08-07) ----------------- * error reporting on Lua syntax errors failed to clean up the stack so that errors could leak into the next Lua run * Lua error messages were not properly decoded 0.10 (2010-07-27) ----------------- * much faster locking of the LuaRuntime, especially in the single threaded case (see http://code.activestate.com/recipes/577336-fast-re-entrant-optimistic-lock-implemented-in-cyt/) * fixed several error handling problems when executing Python code inside of Lua 0.9 (2010-07-23) ---------------- * fixed Python special double-underscore method access on LuaObject instances * Lua coroutine support through dedicated wrapper classes, including Python iteration support. In Python space, Lua coroutines behave exactly like Python generators. 0.8 (2010-07-21) ---------------- * support for returning multiple values from Lua evaluation * ``repr()`` support for Lua objects * ``LuaRuntime.table()`` method for creating Lua tables from Python space * encoding fix for ``str(LuaObject)`` 0.7 (2010-07-18) ---------------- * ``LuaRuntime.require()`` and ``LuaRuntime.globals()`` methods * renamed ``LuaRuntime.run()`` to ``LuaRuntime.execute()`` * support for ``len()``, ``setattr()`` and subscripting of Lua objects * provide all built-in Lua libraries in ``LuaRuntime``, including support for library loading * fixed a thread locking issue * fix passing Lua objects back into the runtime from Python space 0.6 (2010-07-18) ---------------- * Python iteration support for Lua objects (e.g. tables) * threading fixes * fix compile warnings 0.5 (2010-07-14) ---------------- * explicit encoding options per LuaRuntime instance to decode/encode strings and Lua code 0.4 (2010-07-14) ---------------- * attribute read access on Lua objects, e.g. to read Lua table values from Python * str() on Lua objects * include .hg repository in source downloads * added missing files to source distribution 0.3 (2010-07-13) ---------------- * fix several threading issues * safely free the GIL when calling into Lua 0.2 (2010-07-13) ---------------- * propagate Python exceptions through Lua calls 0.1 (2010-07-12) ---------------- * first public release License ======= Lupa ---- Copyright (c) 2010-2017 Stefan Behnel. All rights reserved. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. Lua --- (See https://www.lua.org/license.html) Copyright © 1994–2017 Lua.org, PUC-Rio. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. Platform: UNKNOWN Classifier: Development Status :: 5 - Production/Stable Classifier: Intended Audience :: Developers Classifier: Intended Audience :: Information Technology Classifier: License :: OSI Approved :: MIT License Classifier: Programming Language :: Cython Classifier: Programming Language :: Python :: 2 Classifier: Programming Language :: Python :: 2.6 Classifier: Programming Language :: Python :: 2.7 Classifier: Programming Language :: Python :: 3 Classifier: Programming Language :: Python :: 3.3 Classifier: Programming Language :: Python :: 3.4 Classifier: Programming Language :: Python :: 3.5 Classifier: Programming Language :: Python :: 3.6 Classifier: Programming Language :: Other Scripting Engines Classifier: Operating System :: OS Independent Classifier: Topic :: Software Development lupa-1.6/lupa/0000775000175000017500000000000013215037350014045 5ustar stefanstefan00000000000000lupa-1.6/lupa/lua.pxd0000664000175000017500000003745213204632560015360 0ustar stefanstefan00000000000000 cdef extern from *: ctypedef struct va_list cdef extern from *: # "luaconf.h" # Various tunables. enum: LUAI_MAXSTACK # 65500 /* Max. # of stack slots for a thread (<64K). */ LUAI_MAXCSTACK # 8000 /* Max. # of stack slots for a C func (<10K). */ LUAI_GCPAUSE # 200 /* Pause GC until memory is at 200%. */ LUAI_GCMUL # 200 /* Run GC at 200% of allocation speed. */ LUA_MAXCAPTURES # 32 /* Max. pattern captures. */ LUA_IDSIZE # 60 /* Size of lua_Debug.short_src. */ LUAL_BUFFERSIZE # BUFSIZ /* Size of lauxlib and io.* buffers. */ ################################################################################ # lua.h ################################################################################ cdef extern from "lua.h" nogil: char* LUA_VERSION char* LUA_RELEASE int LUA_VERSION_NUM char* LUA_COPYRIGHT char* LUA_AUTHORS char* LUA_SIGNATURE int LUA_MULTRET int LUA_REGISTRYINDEX int LUA_ENVIRONINDEX int LUA_GLOBALSINDEX int lua_upvalueindex(int i) enum: # thread status; 0 is OK LUA_YIELD # 1 LUA_ERRRUN # 2 LUA_ERRSYNTAX # 3 LUA_ERRMEM # 4 LUA_ERRERR # 5 ctypedef struct lua_State ctypedef int (*lua_CFunction) (lua_State *L) ctypedef char * (*lua_Reader) (lua_State *L, void *ud, size_t *sz) ctypedef int (*lua_Writer) (lua_State *L, void* p, size_t sz, void* ud) ctypedef void * (*lua_Alloc) (void *ud, void *ptr, size_t osize, size_t nsize) enum: LUA_TNONE # -1 LUA_TNIL # 0 LUA_TBOOLEAN # 1 LUA_TLIGHTUSERDATA # 2 LUA_TNUMBER # 3 LUA_TSTRING # 4 LUA_TTABLE # 5 LUA_TFUNCTION # 6 LUA_TUSERDATA # 7 LUA_TTHREAD # 8 int LUA_MINSTACK # minimum Lua stack available to a C function ctypedef float lua_Number # type of numbers in Lua ctypedef int lua_Integer # type for integer functions lua_State *lua_newstate (lua_Alloc f, void *ud) void lua_close (lua_State *L) lua_State *lua_newthread (lua_State *L) lua_CFunction lua_atpanic (lua_State *L, lua_CFunction panicf) # basic stack manipulation int lua_gettop (lua_State *L) void lua_settop (lua_State *L, int idx) void lua_pushvalue (lua_State *L, int idx) void lua_remove (lua_State *L, int idx) void lua_insert (lua_State *L, int idx) void lua_replace (lua_State *L, int idx) int lua_checkstack (lua_State *L, int sz) void lua_xmove (lua_State *_from, lua_State *to, int n) # access functions (stack -> C) int lua_isnumber (lua_State *L, int idx) int lua_isstring (lua_State *L, int idx) int lua_iscfunction (lua_State *L, int idx) int lua_isuserdata (lua_State *L, int idx) int lua_type (lua_State *L, int idx) char *lua_typename (lua_State *L, int tp) int lua_equal (lua_State *L, int idx1, int idx2) int lua_rawequal (lua_State *L, int idx1, int idx2) int lua_lessthan (lua_State *L, int idx1, int idx2) lua_Number lua_tonumber (lua_State *L, int idx) lua_Integer lua_tointeger (lua_State *L, int idx) bint lua_toboolean (lua_State *L, int idx) char *lua_tolstring (lua_State *L, int idx, size_t *len) size_t lua_objlen (lua_State *L, int idx) lua_CFunction lua_tocfunction (lua_State *L, int idx) void *lua_touserdata (lua_State *L, int idx) lua_State *lua_tothread (lua_State *L, int idx) void *lua_topointer (lua_State *L, int idx) # push functions (C -> stack) void lua_pushnil (lua_State *L) void lua_pushnumber (lua_State *L, lua_Number n) void lua_pushinteger (lua_State *L, lua_Integer n) void lua_pushlstring (lua_State *L, char *s, size_t l) void lua_pushstring (lua_State *L, char *s) char *lua_pushvfstring (lua_State *L, char *fmt, va_list argp) char *lua_pushfstring (lua_State *L, char *fmt, ...) void lua_pushcclosure (lua_State *L, lua_CFunction fn, int n) void lua_pushboolean (lua_State *L, bint b) void lua_pushlightuserdata (lua_State *L, void *p) int lua_pushthread (lua_State *L) # get functions (Lua -> stack) void lua_gettable (lua_State *L, int idx) void lua_getfield (lua_State *L, int idx, char *k) void lua_rawget (lua_State *L, int idx) void lua_rawgeti (lua_State *L, int idx, int n) void lua_createtable (lua_State *L, int narr, int nrec) void *lua_newuserdata (lua_State *L, size_t sz) int lua_getmetatable (lua_State *L, int objindex) void lua_getfenv (lua_State *L, int idx) # set functions (stack -> Lua) void lua_settable (lua_State *L, int idx) void lua_setfield (lua_State *L, int idx, char *k) void lua_rawset (lua_State *L, int idx) void lua_rawseti (lua_State *L, int idx, int n) int lua_setmetatable (lua_State *L, int objindex) int lua_setfenv (lua_State *L, int idx) # `load' and `call' functions (load and run Lua code) void lua_call (lua_State *L, int nargs, int nresults) int lua_pcall (lua_State *L, int nargs, int nresults, int errfunc) int lua_cpcall (lua_State *L, lua_CFunction func, void *ud) int lua_load (lua_State *L, lua_Reader reader, void *dt, char *chunkname) int lua_dump (lua_State *L, lua_Writer writer, void *data) # coroutine functions int lua_yield (lua_State *L, int nresults) int lua_resume "__lupa_lua_resume" (lua_State *L, lua_State *from_, int narg) int lua_status (lua_State *L) # garbage-collection function and options enum: LUA_GCSTOP # 0 LUA_GCRESTART # 1 LUA_GCCOLLECT # 2 LUA_GCCOUNT # 3 LUA_GCCOUNTB # 4 LUA_GCSTEP # 5 LUA_GCSETPAUSE # 6 LUA_GCSETSTEPMUL # 7 int lua_gc (lua_State *L, int what, int data) # miscellaneous functions int lua_error (lua_State *L) int lua_next (lua_State *L, int idx) void lua_concat (lua_State *L, int n) lua_Alloc lua_getallocf (lua_State *L, void **ud) void lua_setallocf (lua_State *L, lua_Alloc f, void *ud) # =============================================================== # some useful macros # =============================================================== void lua_pop(lua_State *L, int n) # lua_settop(L, -(n)-1) void lua_newtable(lua_State *L) # lua_createtable(L, 0, 0) void lua_register(lua_State *L, char* n, lua_CFunction f) # (lua_pushcfunction(L, (f)), lua_setglobal(L, (n))) void lua_pushcfunction(lua_State *L, lua_CFunction fn) # lua_pushcclosure(L, (f), 0) size_t lua_strlen(lua_State *L, int i) # lua_objlen(L, (i)) bint lua_isfunction(lua_State *L, int n) # (lua_type(L, (n)) == LUA_TFUNCTION) bint lua_istable(lua_State *L, int n) # (lua_type(L, (n)) == LUA_TTABLE) bint lua_islightuserdata(lua_State *L, int n) # (lua_type(L, (n)) == LUA_TLIGHTUSERDATA) bint lua_isnil(lua_State *L, int n) # (lua_type(L, (n)) == LUA_TNIL) bint lua_isboolean(lua_State *L, int n) # (lua_type(L, (n)) == LUA_TBOOLEAN) bint lua_isthread(lua_State *L, int n) # (lua_type(L, (n)) == LUA_TTHREAD) bint lua_isnone(lua_State *L,int n) # (lua_type(L, (n)) == LUA_TNONE) bint lua_isnoneornil(lua_State *L, int n) # (lua_type(L, (n)) <= 0) void lua_pushliteral(lua_State *L, char* s) # lua_pushlstring(L, "" s, (sizeof(s)/sizeof(char))-1) void lua_setglobal(lua_State *L, char* s) # lua_setfield(L, LUA_GLOBALSINDEX, (s)) void lua_getglobal(lua_State *L, char* s) # lua_getfield(L, LUA_GLOBALSINDEX, (s)) char* lua_tostring(lua_State *L, int i) # lua_tolstring(L, (i), NULL) # compatibility macros and functions lua_State* luaL_newstate() void lua_getregistry(lua_State *L) # lua_pushvalue(L, LUA_REGISTRYINDEX) int lua_getgccount(lua_State *L) # define lua_Chunkreader lua_Reader # define lua_Chunkwriter lua_Writer # hack void lua_setlevel(lua_State *_from, lua_State *to) # ======================================================================= # Debug API # ======================================================================= # Event codes enum: LUA_HOOKCALL # 0 LUA_HOOKRET # 1 LUA_HOOKLINE # 2 LUA_HOOKCOUNT # 3 LUA_HOOKTAILRET # 4 # Event masks enum: LUA_MASKCALL # (1 << LUA_HOOKCALL) LUA_MASKRET # (1 << LUA_HOOKRET) LUA_MASKLINE # (1 << LUA_HOOKLINE) LUA_MASKCOUNT # (1 << LUA_HOOKCOUNT) ctypedef struct lua_Debug # activation record # Functions to be called by the debuger in specific events ctypedef void (*lua_Hook) (lua_State *L, lua_Debug *ar) int lua_getstack (lua_State *L, int level, lua_Debug *ar) int lua_getinfo (lua_State *L, char *what, lua_Debug *ar) char *lua_getlocal (lua_State *L, lua_Debug *ar, int n) char *lua_setlocal (lua_State *L, lua_Debug *ar, int n) char *lua_getupvalue (lua_State *L, int funcindex, int n) char *lua_setupvalue (lua_State *L, int funcindex, int n) int lua_sethook (lua_State *L, lua_Hook func, int mask, int count) lua_Hook lua_gethook (lua_State *L) int lua_gethookmask (lua_State *L) int lua_gethookcount (lua_State *L) ctypedef struct lua_Debug: int event char *name # (n) */ char *namewhat # (n) `global', `local', `field', `method' */ char *what # (S) `Lua', `C', `main', `tail' */ char *source # (S) */ int currentline # (l) */ int nups # (u) number of upvalues */ int linedefined # (S) */ int lastlinedefined # (S) */ char short_src[LUA_IDSIZE] # (S) */ # private part int i_ci # active function */ ################################################################################ # lauxlib.h ################################################################################ cdef extern from "lauxlib.h" nogil: size_t luaL_getn(lua_State *L, int i) # ((int)lua_objlen(L, i)) #void luaL_setn(lua_State *L, int i, int j) # ((void)0) /* no op! */ # extra error code for `luaL_load' enum: LUA_ERRFILE # (LUA_ERRERR+1) ctypedef struct luaL_Reg: char *name lua_CFunction func void luaL_register (lua_State *L, char *libname, luaL_Reg *l) void luaL_setfuncs (lua_State *L, luaL_Reg *l, int nup) # 5.2+ int luaL_getmetafield (lua_State *L, int obj, char *e) int luaL_callmeta (lua_State *L, int obj, char *e) int luaL_typerror (lua_State *L, int narg, char *tname) int luaL_argerror (lua_State *L, int numarg, char *extramsg) char *luaL_checklstring (lua_State *L, int numArg, size_t *l) char *luaL_optlstring (lua_State *L, int numArg, char *default, size_t *l) lua_Number luaL_checknumber (lua_State *L, int numArg) lua_Number luaL_optnumber (lua_State *L, int nArg, lua_Number default) lua_Integer luaL_checkinteger (lua_State *L, int numArg) lua_Integer luaL_optinteger (lua_State *L, int nArg, lua_Integer default) void luaL_checkstack (lua_State *L, int sz, char *msg) void luaL_checktype (lua_State *L, int narg, int t) void luaL_checkany (lua_State *L, int narg) int luaL_newmetatable (lua_State *L, char *tname) void *luaL_checkudata (lua_State *L, int ud, char *tname) void luaL_where (lua_State *L, int lvl) int luaL_error (lua_State *L, char *fmt, ...) int luaL_checkoption (lua_State *L, int narg, char *default, char *lst[]) int luaL_ref (lua_State *L, int t) void luaL_unref (lua_State *L, int t, int ref) int luaL_loadfile (lua_State *L, char *filename) int luaL_loadbuffer (lua_State *L, char *buff, size_t sz, char *name) int luaL_loadstring (lua_State *L, char *s) lua_State *luaL_newstate () char *luaL_gsub (lua_State *L, char *s, char *p, char *r) # =============================================================== # some useful macros # =============================================================== int luaL_argcheck(lua_State *L, bint cond, int numarg, char *extramsg) # ((void)((cond) || luaL_argerror(L, (numarg), (extramsg)))) char* luaL_checkstring(lua_State *L, int n) # (luaL_checklstring(L, (n), NULL)) char* luaL_optstring(lua_State *L, int n, char* d) # (luaL_optlstring(L, (n), (d), NULL)) int luaL_checkint(lua_State *L, int n) # ((int)luaL_checkinteger(L, (n))) int luaL_optint(lua_State *L, int n, lua_Integer d) # ((int)luaL_optinteger(L, (n), (d))) long luaL_checklong(lua_State *L, int n) # ((long)luaL_checkinteger(L, (n))) long luaL_optlong(lua_State *L, int n, lua_Integer d) # ((long)luaL_optinteger(L, (n), (d))) char* luaL_typename (lua_State *L, int i) # lua_typename(L, lua_type(L,(i))) int luaL_dofile(lua_State *L, char* fn) # (luaL_loadfile(L, fn) || lua_pcall(L, 0, LUA_MULTRET, 0)) int luaL_dostring(lua_State *L, char* s) # (luaL_loadstring(L, s) || lua_pcall(L, 0, LUA_MULTRET, 0)) void luaL_getmetatable(lua_State *L, char* n) # (lua_getfield(L, LUA_REGISTRYINDEX, (n))) #define luaL_opt(L,f,n,d) (lua_isnoneornil(L,(n)) ? (d) : f(L,(n))) # ======================================================= # Generic Buffer manipulation # ======================================================= ''' typedef struct luaL_Buffer { char *p; /* current position in buffer */ int lvl; /* number of strings in the stack (level) */ lua_State *L; char buffer[LUAL_BUFFERSIZE]; } luaL_Buffer; #define luaL_addchar(B,c) \ ((void)((B)->p < ((B)->buffer+LUAL_BUFFERSIZE) || luaL_prepbuffer(B)), \ (*(B)->p++ = (char)(c))) /* compatibility only */ #define luaL_putchar(B,c) luaL_addchar(B,c) #define luaL_addsize(B,n) ((B)->p += (n)) void (luaL_buffinit) (lua_State *L, luaL_Buffer *B); char *(luaL_prepbuffer) (luaL_Buffer *B); void (luaL_addlstring) (luaL_Buffer *B, const char *s, size_t l); void (luaL_addstring) (luaL_Buffer *B, const char *s); void (luaL_addvalue) (luaL_Buffer *B); void (luaL_pushresult) (luaL_Buffer *B); /* }====================================================== */ /* compatibility with ref system */ /* pre-defined references */ #define LUA_NOREF (-2) #define LUA_REFNIL (-1) #define lua_ref(L,lock) ((lock) ? luaL_ref(L, LUA_REGISTRYINDEX) : \ (lua_pushstring(L, "unlocked references are obsolete"), lua_error(L), 0)) #define lua_unref(L,ref) luaL_unref(L, LUA_REGISTRYINDEX, (ref)) #define lua_getref(L,ref) lua_rawgeti(L, LUA_REGISTRYINDEX, (ref)) #define luaL_reg luaL_Reg #endif ''' cdef extern from "lualib.h": char* LUA_COLIBNAME # "coroutine" char* LUA_MATHLIBNAME # "math" char* LUA_STRLIBNAME # "string" char* LUA_TABLIBNAME # "table" char* LUA_IOLIBNAME # "io" char* LUA_OSLIBNAME # "os" char* LUA_LOADLIBNAME # "package" char* LUA_DBLIBNAME # "debug" char* LUA_BITLIBNAME # "bit" char* LUA_JITLIBNAME # "jit" int luaopen_base(lua_State *L) int luaopen_math(lua_State *L) int luaopen_string(lua_State *L) int luaopen_table(lua_State *L) int luaopen_io(lua_State *L) int luaopen_os(lua_State *L) int luaopen_package(lua_State *L) int luaopen_debug(lua_State *L) int luaopen_bit(lua_State *L) int luaopen_jit(lua_State *L) void luaL_openlibs(lua_State *L) cdef extern from "lupa_defs.h": pass lupa-1.6/lupa/tests/0000775000175000017500000000000013215037350015207 5ustar stefanstefan00000000000000lupa-1.6/lupa/tests/__init__.py0000644000175000017500000000116612426225524017327 0ustar stefanstefan00000000000000from __future__ import absolute_import import unittest import doctest import os import lupa def suite(): test_dir = os.path.abspath(os.path.dirname(__file__)) tests = [] for filename in os.listdir(test_dir): if filename.endswith('.py') and not filename.startswith('_'): tests.append('lupa.tests.' + filename[:-3]) suite = unittest.defaultTestLoader.loadTestsFromNames(tests) suite.addTest(doctest.DocTestSuite(lupa._lupa)) suite.addTest(doctest.DocFileSuite('../../README.rst')) return suite if __name__ == '__main__': unittest.TextTestRunner(verbosity=2).run(suite()) lupa-1.6/lupa/tests/test.py0000664000175000017500000025464513204632560016562 0ustar stefanstefan00000000000000# -*- coding: utf-8 -*- from __future__ import absolute_import import threading import operator import unittest import time import sys import gc import lupa IS_PYTHON3 = sys.version_info[0] >= 3 try: _next = next except NameError: def _next(o): return o.next() unicode_type = type(IS_PYTHON3 and 'abc' or 'abc'.decode('ASCII')) class SetupLuaRuntimeMixin(object): lua_runtime_kwargs = {} def setUp(self): self.lua = lupa.LuaRuntime(**self.lua_runtime_kwargs) def tearDown(self): self.lua = None gc.collect() class TestLuaRuntimeRefcounting(unittest.TestCase): def _run_gc_test(self, run_test): gc.collect() old_count = len(gc.get_objects()) i = None for i in range(100): run_test() del i gc.collect() new_count = len(gc.get_objects()) self.assertEqual(old_count, new_count) def test_runtime_cleanup(self): def run_test(): lua = lupa.LuaRuntime() lua_table = lua.eval('{1,2,3,4}') del lua self.assertEqual(1, lua_table[1]) self._run_gc_test(run_test) def test_pyfunc_refcycle(self): def make_refcycle(): def use_runtime(): return lua.eval('1+1') lua = lupa.LuaRuntime() lua.globals()['use_runtime'] = use_runtime self.assertEqual(2, lua.eval('use_runtime()')) self._run_gc_test(make_refcycle) def test_attrgetter_refcycle(self): def make_refcycle(): def get_attr(obj, name): lua.eval('1+1') # create ref-cycle with runtime return 23 lua = lupa.LuaRuntime(attribute_handlers=(get_attr, None)) assert lua.eval('python.eval.huhu') == 23 self._run_gc_test(make_refcycle) class TestLuaRuntime(SetupLuaRuntimeMixin, unittest.TestCase): def test_eval(self): self.assertEqual(2, self.lua.eval('1+1')) def test_eval_multi(self): self.assertEqual((1,2,3), self.lua.eval('1,2,3')) def test_eval_args(self): self.assertEqual(2, self.lua.eval('...', 2)) def test_eval_args_multi(self): self.assertEqual((1, 2, 3), self.lua.eval('...', 1, 2, 3)) def test_eval_error(self): self.assertRaises(lupa.LuaError, self.lua.eval, '') def test_eval_error_cleanup(self): self.assertEqual(2, self.lua.eval('1+1')) self.assertRaises(lupa.LuaError, self.lua.eval, '') self.assertEqual(2, self.lua.eval('1+1')) self.assertRaises(lupa.LuaError, self.lua.eval, '') self.assertEqual(2, self.lua.eval('1+1')) self.assertEqual(2, self.lua.eval('1+1')) def test_eval_error_message_decoding(self): try: self.lua.eval('require "UNKNOWNöMODULEäNAME"') except lupa.LuaError: error = (IS_PYTHON3 and '%s' or '%s'.decode('ASCII')) % sys.exc_info()[1] else: self.fail('expected error not raised') expected_message = 'module \'UNKNOWNöMODULEäNAME\' not found' if not IS_PYTHON3: expected_message = expected_message.decode('UTF-8') self.assertTrue(expected_message in error, '"%s" not found in "%s"' % (expected_message, error)) def test_execute(self): self.assertEqual(2, self.lua.execute('return 1+1')) def test_execute_function(self): self.assertEqual(3, self.lua.execute('f = function(i) return i+1 end; return f(2)')) def test_execute_tostring_function(self): self.assertEqual('function', self.lua.execute('f = function(i) return i+1 end; return tostring(f)')[:8]) def test_execute_args(self): self.assertEqual(2, self.lua.execute('return ...', 2)) def test_execute_args_multi(self): self.assertEqual((1, 2, 3), self.lua.execute('return ...', 1, 2, 3)) def test_function(self): function = self.lua.eval('function() return 1+1 end') self.assertNotEqual(None, function) self.assertEqual(2, function()) def test_multiple_functions(self): function1 = self.lua.eval('function() return 0+1 end') function2 = self.lua.eval('function() return 1+1 end') self.assertEqual(1, function1()) self.assertEqual(2, function2()) function3 = self.lua.eval('function() return 1+2 end') self.assertEqual(3, function3()) self.assertEqual(2, function2()) self.assertEqual(1, function1()) def test_recursive_function(self): fac = self.lua.execute('''\ function fac(i) if i <= 1 then return 1 else return i * fac(i-1) end end return fac ''') self.assertNotEqual(None, fac) self.assertEqual(6, fac(3)) self.assertEqual(3628800, fac(10)) def test_double_recursive_function(self): func_code = '''\ function calc(i) if i > 2 then return calc(i-1) + calc(i-2) + 1 else return 1 end end return calc ''' calc = self.lua.execute(func_code) self.assertNotEqual(None, calc) self.assertEqual(3, calc(3)) self.assertEqual(109, calc(10)) self.assertEqual(13529, calc(20)) def test_double_recursive_function_pycallback(self): func_code = '''\ function calc(pyfunc, i) if i > 2 then return pyfunc(i) + calc(pyfunc, i-1) + calc(pyfunc, i-2) + 1 else return 1 end end return calc ''' def pycallback(i): return i**2 calc = self.lua.execute(func_code) self.assertNotEqual(None, calc) self.assertEqual(12, calc(pycallback, 3)) self.assertEqual(1342, calc(pycallback, 10)) self.assertEqual(185925, calc(pycallback, 20)) def test_none(self): function = self.lua.eval('function() return python.none end') self.assertEqual(None, function()) def test_pybuiltins(self): function = self.lua.eval('function() return python.builtins end') try: import __builtin__ as builtins except ImportError: import builtins self.assertEqual(builtins, function()) def test_pybuiltins_disabled(self): lua = lupa.LuaRuntime(register_builtins=False) self.assertEqual(True, lua.eval('python.builtins == nil')) def test_call_none(self): self.assertRaises(TypeError, self.lua.eval, 'python.none()') def test_call_non_callable(self): func = self.lua.eval('function(x) CALLED = 99; return x() end') self.assertRaises(TypeError, func, object()) self.assertEqual(99, self.lua.eval('CALLED')) def test_call_str(self): self.assertEqual("test-None", self.lua.eval('"test-" .. tostring(python.none)')) def test_call_str_py(self): function = self.lua.eval('function(x) return "test-" .. tostring(x) end') self.assertEqual("test-nil", function(None)) self.assertEqual("test-1.5", function(1.5)) def test_call_str_class(self): called = [False] class test(object): def __str__(self): called[0] = True return 'STR!!' function = self.lua.eval('function(x) return "test-" .. tostring(x) end') self.assertEqual("test-STR!!", function(test())) self.assertEqual(True, called[0]) def test_python_eval(self): eval = self.lua.eval('function() return python.eval end')() self.assertEqual(2, eval('1+1')) self.assertEqual(2, self.lua.eval('python.eval("1+1")')) def test_python_eval_disabled(self): lua = lupa.LuaRuntime(register_eval=False) self.assertEqual(True, lua.eval('python.eval == nil')) def test_len_table_array(self): table = self.lua.eval('{1,2,3,4,5}') self.assertEqual(5, len(table)) def test_len_table_dict(self): table = self.lua.eval('{a=1, b=2, c=3}') self.assertEqual(0, len(table)) # as returned by Lua's "#" operator def test_table_delattr(self): table = self.lua.eval('{a=1, b=2, c=3}') self.assertTrue('a' in table) del table.a self.assertFalse('a' in table) def test_table_delitem(self): table = self.lua.eval('{a=1, b=2, c=3}') self.assertTrue('c' in table) del table['c'] self.assertFalse('c' in table) def test_table_delitem_special(self): table = self.lua.eval('{a=1, b=2, c=3, __attr__=4}') self.assertTrue('__attr__' in table) del table['__attr__'] self.assertFalse('__attr__' in table) def test_len_table(self): table = self.lua.eval('{1,2,3,4, a=1, b=2, c=3}') self.assertEqual(4, len(table)) # as returned by Lua's "#" operator def test_iter_table(self): table = self.lua.eval('{2,3,4,5,6}') self.assertEqual([1,2,3,4,5], list(table)) def test_iter_table_list_repeat(self): table = self.lua.eval('{2,3,4,5,6}') self.assertEqual([1,2,3,4,5], list(table)) # 1 self.assertEqual([1,2,3,4,5], list(table)) # 2 self.assertEqual([1,2,3,4,5], list(table)) # 3 def test_iter_array_table_values(self): table = self.lua.eval('{2,3,4,5,6}') self.assertEqual([2,3,4,5,6], list(table.values())) def test_iter_array_table_repeat(self): table = self.lua.eval('{2,3,4,5,6}') self.assertEqual([2,3,4,5,6], list(table.values())) # 1 self.assertEqual([2,3,4,5,6], list(table.values())) # 2 self.assertEqual([2,3,4,5,6], list(table.values())) # 3 def test_iter_multiple_tables(self): count = 10 table_values = [self.lua.eval('{%s}' % ','.join(map(str, range(2, count+2)))).values() for _ in range(4)] # round robin l = [[] for _ in range(count)] for sublist in l: for table in table_values: sublist.append(_next(table)) self.assertEqual([[i]*len(table_values) for i in range(2, count+2)], l) def test_iter_table_repeat(self): count = 10 table_values = [self.lua.eval('{%s}' % ','.join(map(str, range(2, count+2)))).values() for _ in range(4)] # one table after the other l = [[] for _ in range(count)] for table in table_values: for sublist in l: sublist.append(_next(table)) self.assertEqual([[i]*len(table_values) for i in range(2,count+2)], l) def test_iter_table_refcounting(self): lua_func = self.lua.eval(''' function () local t = {} t.foo = 'bar' t.hello = 'world' return t end ''') table = lua_func() for _ in range(10000): list(table.items()) def test_iter_table_mapping(self): keys = list('abcdefg') table = self.lua.eval('{%s}' % ','.join('%s=%d' % (c, i) for i, c in enumerate(keys))) l = list(table) l.sort() self.assertEqual(keys, l) def test_iter_table_mapping_int_keys(self): table = self.lua.eval('{%s}' % ','.join('[%d]=%d' % (i, -i) for i in range(10))) l = list(table) l.sort() self.assertEqual(list(range(10)), l) def test_iter_table_keys(self): keys = list('abcdefg') table = self.lua.eval('{%s}' % ','.join('%s=%d' % (c, i) for i, c in enumerate(keys))) l = list(table.keys()) l.sort() self.assertEqual(keys, l) def test_iter_table_keys_int_keys(self): table = self.lua.eval('{%s}' % ','.join('[%d]=%d' % (i, -i) for i in range(10))) l = list(table.keys()) l.sort() self.assertEqual(list(range(10)), l) def test_iter_table_values(self): keys = list('abcdefg') table = self.lua.eval('{%s}' % ','.join('%s=%d' % (c, i) for i, c in enumerate(keys))) l = list(table.values()) l.sort() self.assertEqual(list(range(len(keys))), l) def test_iter_table_values_int_keys(self): table = self.lua.eval('{%s}' % ','.join('[%d]=%d' % (i, -i) for i in range(10))) l = list(table.values()) l.sort() self.assertEqual(list(range(-9,1)), l) def test_iter_table_items(self): keys = list('abcdefg') table = self.lua.eval('{%s}' % ','.join('%s=%d' % (c, i) for i, c in enumerate(keys))) l = list(table.items()) l.sort() self.assertEqual(list(zip(keys,range(len(keys)))), l) def test_iter_table_items_int_keys(self): table = self.lua.eval('{%s}' % ','.join('[%d]=%d' % (i, -i) for i in range(10))) l = list(table.items()) l.sort() self.assertEqual(list(zip(range(10), range(0,-10,-1))), l) def test_iter_table_values_mixed(self): keys = list('abcdefg') table = self.lua.eval('{98, 99; %s}' % ','.join('%s=%d' % (c, i) for i, c in enumerate(keys))) l = list(table.values()) l.sort() self.assertEqual(list(range(len(keys))) + [98, 99], l) def test_error_iter_number(self): func = self.lua.eval('1') self.assertRaises(TypeError, list, func) def test_error_iter_function(self): func = self.lua.eval('function() return 1 end') self.assertRaises(TypeError, list, func) def test_string_values(self): function = self.lua.eval('function(s) return s .. "abc" end') self.assertEqual('ABCabc', function('ABC')) def test_int_values(self): function = self.lua.eval('function(i) return i + 5 end') self.assertEqual(3+5, function(3)) def test_long_values(self): try: _long = long except NameError: _long = int function = self.lua.eval('function(i) return i + 5 end') self.assertEqual(3+5, function(_long(3))) def test_float_values(self): function = self.lua.eval('function(i) return i + 5 end') self.assertEqual(float(3)+5, function(float(3))) def test_str_function(self): func = self.lua.eval('function() return 1 end') self.assertEqual(' 4.0 then b = b + 1; break; end end if b >= 256 then p = p + 1; buf[p] = 511 - b; b = 1; end end if b ~= 1 then p = p + 1; buf[p] = (ba-b)*bb; end result = result .. char(unpack(buf, 1, p)) end return result end ''' lua = lupa.LuaRuntime(encoding=None) lua_mandelbrot = lua.eval(code) image_size = 128 result_bytes = lua_mandelbrot(image_size) self.assertEqual(type(result_bytes), type(''.encode('ASCII'))) self.assertEqual(image_size*image_size//8, len(result_bytes)) # if we have PIL, check that it can read the image ## try: ## import Image ## except ImportError: ## pass ## else: ## image = Image.fromstring('1', (image_size, image_size), result_bytes) ## image.show() class TestLuaRuntimeEncoding(unittest.TestCase): def tearDown(self): gc.collect() test_string = '"abcüöä"' if not IS_PYTHON3: test_string = test_string.decode('UTF-8') def _encoding_test(self, encoding, expected_length): lua = lupa.LuaRuntime(encoding) self.assertEqual(unicode_type, type(lua.eval(self.test_string))) self.assertEqual(self.test_string[1:-1], lua.eval(self.test_string)) self.assertEqual(expected_length, lua.eval('string.len(%s)' % self.test_string)) def test_utf8(self): self._encoding_test('UTF-8', 9) def test_latin9(self): self._encoding_test('ISO-8859-15', 6) def test_stringlib_utf8(self): lua = lupa.LuaRuntime('UTF-8') stringlib = lua.eval('string') self.assertEqual('abc', stringlib.lower('ABC')) def test_stringlib_no_encoding(self): lua = lupa.LuaRuntime(encoding=None) stringlib = lua.eval('string') self.assertEqual('abc'.encode('ASCII'), stringlib.lower('ABC'.encode('ASCII'))) class TestMultipleLuaRuntimes(unittest.TestCase): def tearDown(self): gc.collect() def test_multiple_runtimes(self): lua1 = lupa.LuaRuntime() function1 = lua1.eval('function() return 1 end') self.assertNotEqual(None, function1) self.assertEqual(1, function1()) lua2 = lupa.LuaRuntime() function2 = lua2.eval('function() return 1+1 end') self.assertNotEqual(None, function2) self.assertEqual(1, function1()) self.assertEqual(2, function2()) lua3 = lupa.LuaRuntime() self.assertEqual(1, function1()) self.assertEqual(2, function2()) function3 = lua3.eval('function() return 1+1+1 end') self.assertNotEqual(None, function3) del lua1, lua2, lua3 self.assertEqual(1, function1()) self.assertEqual(2, function2()) self.assertEqual(3, function3()) class TestThreading(unittest.TestCase): def tearDown(self): gc.collect() def _run_threads(self, threads, starter=None): for thread in threads: thread.start() if starter is not None: time.sleep(0.1) # give some time to start up starter.set() for thread in threads: thread.join() def test_sequential_threading(self): func_code = '''\ function calc(i) if i > 2 then return calc(i-1) + calc(i-2) + 1 else return 1 end end return calc ''' lua = lupa.LuaRuntime() functions = [ lua.execute(func_code) for _ in range(10) ] results = [None] * len(functions) starter = threading.Event() def test(i, func, *args): starter.wait() results[i] = func(*args) threads = [ threading.Thread(target=test, args=(i, func, 25)) for i, func in enumerate(functions) ] self._run_threads(threads, starter) self.assertEqual(1, len(set(results))) self.assertEqual(150049, results[0]) def test_threading(self): func_code = '''\ function calc(i) if i > 2 then return calc(i-1) + calc(i-2) + 1 else return 1 end end return calc ''' runtimes = [ lupa.LuaRuntime() for _ in range(10) ] functions = [ lua.execute(func_code) for lua in runtimes ] results = [None] * len(runtimes) def test(i, func, *args): results[i] = func(*args) threads = [ threading.Thread(target=test, args=(i, func, 20)) for i, func in enumerate(functions) ] self._run_threads(threads) self.assertEqual(1, len(set(results))) self.assertEqual(13529, results[0]) def test_threading_pycallback(self): func_code = '''\ function calc(pyfunc, i) if i > 2 then return pyfunc(i) + calc(pyfunc, i-1) + calc(pyfunc, i-2) + 1 else return 1 end end return calc ''' runtimes = [ lupa.LuaRuntime() for _ in range(10) ] functions = [ lua.execute(func_code) for lua in runtimes ] results = [None] * len(runtimes) def pycallback(i): return i**2 def test(i, func, *args): results[i] = func(*args) threads = [ threading.Thread(target=test, args=(i, luafunc, pycallback, 20)) for i, luafunc in enumerate(functions) ] self._run_threads(threads) self.assertEqual(1, len(set(results))) self.assertEqual(185925, results[0]) def test_threading_iter(self): values = list(range(1,100)) lua = lupa.LuaRuntime() table = lua.eval('{%s}' % ','.join(map(str, values))) self.assertEqual(values, list(table)) lua_iter = iter(table) state_lock = threading.Lock() running = [] iterations_done = {} def sync(i): state_lock.acquire() try: status = iterations_done[i] except KeyError: status = iterations_done[i] = [0, threading.Event()] status[0] += 1 state_lock.release() event = status[1] while status[0] < len(running): event.wait(0.1) event.set() l = [] start_event = threading.Event() def extract(n, append = l.append): running.append(n) if len(running) < len(threads): start_event.wait() else: start_event.set() # all running, let's go for i, item in enumerate(lua_iter): append(item) sync(i) running.remove(n) threads = [ threading.Thread(target=extract, args=(i,)) for i in range(6) ] self._run_threads(threads) orig = l[:] l.sort() self.assertEqual(values, l) def test_threading_mandelbrot(self): # copied from Computer Language Benchmarks Game code = '''\ function(N, i, total) local char, unpack = string.char, unpack if unpack == nil then unpack = table.unpack end local result = "" local M, ba, bb, buf = 2/N, 2^(N%8+1)-1, 2^(8-N%8), {} local start_line, end_line = N/total * (i-1), N/total * i - 1 for y=start_line,end_line do local Ci, b, p = y*M-1, 1, 0 for x=0,N-1 do local Cr = x*M-1.5 local Zr, Zi, Zrq, Ziq = Cr, Ci, Cr*Cr, Ci*Ci b = b + b for i=1,49 do Zi = Zr*Zi*2 + Ci Zr = Zrq-Ziq + Cr Ziq = Zi*Zi Zrq = Zr*Zr if Zrq+Ziq > 4.0 then b = b + 1; break; end end if b >= 256 then p = p + 1; buf[p] = 511 - b; b = 1; end end if b ~= 1 then p = p + 1; buf[p] = (ba-b)*bb; end result = result .. char(unpack(buf, 1, p)) end return result end ''' empty_bytes_string = ''.encode('ASCII') image_size = 128 thread_count = 4 lua_funcs = [ lupa.LuaRuntime(encoding=None).eval(code) for _ in range(thread_count) ] results = [None] * thread_count def mandelbrot(i, lua_func): results[i] = lua_func(image_size, i+1, thread_count) threads = [ threading.Thread(target=mandelbrot, args=(i, lua_func)) for i, lua_func in enumerate(lua_funcs) ] self._run_threads(threads) result_bytes = empty_bytes_string.join(results) self.assertEqual(type(result_bytes), type(empty_bytes_string)) self.assertEqual(image_size*image_size//8, len(result_bytes)) # plausability checks - make sure it's not all white or all black self.assertEqual('\0'.encode('ASCII')*(image_size//8//2), result_bytes[:image_size//8//2]) if IS_PYTHON3: self.assertTrue('\xFF'.encode('ISO-8859-1') in result_bytes) else: self.assertTrue('\xFF' in result_bytes) # if we have PIL, check that it can read the image ## try: ## import Image ## except ImportError: ## pass ## else: ## image = Image.fromstring('1', (image_size, image_size), result_bytes) ## image.show() class TestDontUnpackTuples(unittest.TestCase): def setUp(self): self.lua = lupa.LuaRuntime() # default is unpack_returned_tuples=False # Define a Python function which returns a tuple # and is accessible from Lua as fun(). def tuple_fun(): return "one", "two", "three", "four" self.lua.globals()['fun'] = tuple_fun def tearDown(self): self.lua = None gc.collect() def test_python_function_tuple(self): self.lua.execute("a, b, c = fun()") self.assertEqual(("one", "two", "three", "four"), self.lua.eval("a")) self.assertEqual(None, self.lua.eval("b")) self.assertEqual(None, self.lua.eval("c")) def test_python_function_tuple_exact(self): self.lua.execute("a = fun()") self.assertEqual(("one", "two", "three", "four"), self.lua.eval("a")) class TestUnpackTuples(unittest.TestCase): def setUp(self): self.lua = lupa.LuaRuntime(unpack_returned_tuples=True) # Define a Python function which returns a tuple # and is accessible from Lua as fun(). def tuple_fun(): return "one", "two", "three", "four" self.lua.globals()['fun'] = tuple_fun def tearDown(self): self.lua = None gc.collect() def test_python_function_tuple_expansion_exact(self): self.lua.execute("a, b, c, d = fun()") self.assertEqual("one", self.lua.eval("a")) self.assertEqual("two", self.lua.eval("b")) self.assertEqual("three", self.lua.eval("c")) self.assertEqual("four", self.lua.eval("d")) def test_python_function_tuple_expansion_extra_args(self): self.lua.execute("a, b, c, d, e, f = fun()") self.assertTrue(self.lua.eval("a == 'one'")) self.assertTrue(self.lua.eval("b == 'two'")) self.assertTrue(self.lua.eval("c == 'three'")) self.assertTrue(self.lua.eval("d == 'four'")) self.assertTrue(self.lua.eval("e == nil")) self.assertTrue(self.lua.eval("f == nil")) self.assertEqual("one", self.lua.eval("a")) self.assertEqual("two", self.lua.eval("b")) self.assertEqual("three", self.lua.eval("c")) self.assertEqual("four", self.lua.eval("d")) self.assertEqual(None, self.lua.eval("e")) self.assertEqual(None, self.lua.eval("f")) def test_python_function_tuple_expansion_missing_args(self): self.lua.execute("a, b = fun()") self.assertEqual("one", self.lua.eval("a")) self.assertEqual("two", self.lua.eval("b")) def test_translate_None(self): """Lua does not understand None. Should (almost) never see it.""" self.lua.globals()['f'] = lambda: (None, None) self.lua.execute("x, y = f()") self.assertEqual(None, self.lua.eval("x")) self.assertEqual(self.lua.eval("x"), self.lua.eval("y")) self.assertEqual(self.lua.eval("x"), self.lua.eval("z")) self.assertTrue(self.lua.eval("x == y")) self.assertTrue(self.lua.eval("x == z")) self.assertTrue(self.lua.eval("x == nil")) self.assertTrue(self.lua.eval("nil == z")) def test_python_enumerate_list_unpacked(self): values = self.lua.eval(''' function(L) local t = {} for index, a, b in python.enumerate(L) do assert(a + 30 == b) t[ index+1 ] = a + b end return t end ''') self.assertEqual([50, 70, 90], list(values(zip([10, 20, 30], [40, 50, 60])).values())) def test_python_enumerate_list_unpacked_None(self): values = self.lua.eval(''' function(L) local t = {} for index, a, b in python.enumerate(L) do assert(a == nil) t[ index+1 ] = b end return t end ''') self.assertEqual([3, 5], list(values(zip([None, None, None], [3, None, 5])).values())) def test_python_enumerate_list_start(self): values = self.lua.eval(''' function(L) local t = {5,6,7} for index, a, b, c in python.enumerate(L, 3) do assert(c == nil) assert(a + 10 == b) t[ index ] = a + b end return t end ''') self.assertEqual([5, 6, 30, 50, 70], list(values(zip([10, 20, 30], [20, 30, 40])).values())) class TestMethodCall(unittest.TestCase): def setUp(self): self.lua = lupa.LuaRuntime(unpack_returned_tuples=True) class C(object): def __init__(self, x): self.x = int(x) def getx(self): return self.x def getx1(self, n): return int(n) + self.x def setx(self, v): self.x = int(v) @classmethod def classmeth(cls, v): return v @staticmethod def staticmeth(v): return v class D(C): pass def f(): return 100 def g(n): return int(n) + 100 x = C(1) self.lua.globals()['C'] = C self.lua.globals()['D'] = D self.lua.globals()['x'] = x self.lua.globals()['f'] = f self.lua.globals()['g'] = g self.lua.globals()['d'] = { 'F': f, "G": g } self.lua.globals()['bound0'] = x.getx self.lua.globals()['bound1'] = x.getx1 def tearDown(self): self.lua = None gc.collect() def test_method_call_as_method(self): self.assertEqual(self.lua.eval("x:getx()"), 1) self.assertEqual(self.lua.eval("x:getx1(2)"), 3) self.lua.execute("x:setx(4)") self.assertEqual(self.lua.eval("x:getx()"), 4) self.assertEqual(self.lua.eval("x:getx1(2)"), 6) def test_method_call_as_attribute(self): self.assertEqual(self.lua.eval("x.getx()"), 1) self.assertEqual(self.lua.eval("x.getx1(2)"), 3) self.lua.execute("x.setx(4)") self.assertEqual(self.lua.eval("x.getx()"), 4) self.assertEqual(self.lua.eval("x.getx1(2)"), 6) def test_method_call_mixed(self): self.assertEqual(self.lua.eval("x.getx()"), 1) self.assertEqual(self.lua.eval("x:getx1(2)"), 3) self.assertEqual(self.lua.eval("x:getx()"), 1) self.assertEqual(self.lua.eval("x.getx1(2)"), 3) self.lua.execute("x:setx(4)") self.assertEqual(self.lua.eval("x:getx()"), 4) self.assertEqual(self.lua.eval("x.getx1(2)"), 6) self.assertEqual(self.lua.eval("x.getx()"), 4) self.assertEqual(self.lua.eval("x:getx1(2)"), 6) self.lua.execute("x.setx(6)") self.assertEqual(self.lua.eval("x.getx()"), 6) self.assertEqual(self.lua.eval("x:getx()"), 6) self.assertEqual(self.lua.eval("x.getx()"), 6) self.assertEqual(self.lua.eval("x.getx1(2)"), 8) self.assertEqual(self.lua.eval("x:getx1(2)"), 8) def test_method_call_function_lookup(self): self.assertEqual(self.lua.eval("f()"), 100) self.assertEqual(self.lua.eval("g(10)"), 110) self.assertEqual(self.lua.eval("d.F()"), 100) self.assertEqual(self.lua.eval("d.G(9)"), 109) def test_method_call_class_hierarchy(self): self.assertEqual(self.lua.eval("C(5).getx()"), 5) self.assertEqual(self.lua.eval("D(5).getx()"), 5) self.assertEqual(self.lua.eval("C(5):getx()"), 5) self.assertEqual(self.lua.eval("D(5):getx()"), 5) def test_method_call_class_methods(self): # unbound methods self.assertEqual(self.lua.eval("C.getx(C(5))"), 5) self.assertEqual(self.lua.eval("C.getx(D(5))"), 5) # class/static methods self.assertEqual(self.lua.eval("C:classmeth(5)"), 5) self.assertEqual(self.lua.eval("C.classmeth(5)"), 5) self.assertEqual(self.lua.eval("C.staticmeth(5)"), 5) def test_method_call_bound(self): self.assertEqual(self.lua.eval("bound0()"), 1) self.assertEqual(self.lua.eval("bound1(3)"), 4) self.assertEqual(self.lua.eval("python.eval('1 .__add__')(1)"), 2) self.assertEqual(self.lua.eval("python.eval('1 .__add__')(2)"), 3) # the following is an unfortunate side effect of the "self" removal # on bound method calls: self.assertRaises(TypeError, self.lua.eval, "bound1(x)") ################################################################################ # tests for the lupa.unpacks_lua_table and lupa.unpacks_lua_table_method # decorators @lupa.unpacks_lua_table def func_1(x): return ("x=%s" % (x, )) @lupa.unpacks_lua_table def func_2(x, y): return ("x=%s, y=%s" % (x, y)) @lupa.unpacks_lua_table def func_3(x, y, z='default'): return ("x=%s, y=%s, z=%s" % (x, y, z)) class MyCls_1(object): @lupa.unpacks_lua_table_method def meth(self, x): return ("x=%s" % (x,)) class MyCls_2(object): @lupa.unpacks_lua_table_method def meth(self, x, y): return ("x=%s, y=%s" % (x, y)) class MyCls_3(object): @lupa.unpacks_lua_table_method def meth(self, x, y, z='default'): return ("x=%s, y=%s, z=%s" % (x, y, z)) class KwargsDecoratorTest(SetupLuaRuntimeMixin, unittest.TestCase): def __init__(self, *args, **kwargs): super(KwargsDecoratorTest, self).__init__(*args, **kwargs) self.arg1 = func_1 self.arg2 = func_2 self.arg3 = func_3 def assertResult(self, f, call_txt, res_txt): lua_func = self.lua.eval("function (f) return f%s end" % call_txt) self.assertEqual(lua_func(f), res_txt) def assertIncorrect(self, f, call_txt): lua_func = self.lua.eval("function (f) return f%s end" % call_txt) self.assertRaises(TypeError, lua_func, f) def test_many_args(self): self.assertResult(self.arg2, "{x=1, y=2}", "x=1, y=2") self.assertResult(self.arg2, "{x=2, y=1}", "x=2, y=1") self.assertResult(self.arg2, "{y=1, x=2}", "x=2, y=1") self.assertResult(self.arg2, "(1, 2)", "x=1, y=2") def test_single_arg(self): self.assertResult(self.arg1, "{x=1}", "x=1") self.assertResult(self.arg1, "(1)", "x=1") self.assertResult(self.arg1, "(nil)", "x=None") def test_defaults(self): self.assertResult(self.arg3, "{x=1, y=2}", "x=1, y=2, z=default") self.assertResult(self.arg3, "{x=1, y=2, z=3}", "x=1, y=2, z=3") def test_defaults_incorrect(self): self.assertIncorrect(self.arg3, "{x=1, z=3}") def test_kwargs_unknown(self): self.assertIncorrect(self.arg2, "{x=1, y=2, z=3}") self.assertIncorrect(self.arg2, "{y=2, z=3}") self.assertIncorrect(self.arg1, "{x=1, y=2}") def test_posargs_bad(self): self.assertIncorrect(self.arg1, "(1,2)") self.assertIncorrect(self.arg1, "()") def test_posargs_kwargs(self): self.assertResult(self.arg2, "{5, y=6}", "x=5, y=6") self.assertResult(self.arg2, "{y=6, 5}", "x=5, y=6") self.assertResult(self.arg2, "{5, [2]=6}", "x=5, y=6") self.assertResult(self.arg2, "{[1]=5, [2]=6}", "x=5, y=6") self.assertResult(self.arg2, "{[1]=5, y=6}", "x=5, y=6") self.assertResult(self.arg3, "{x=5, y=6, z=8}", "x=5, y=6, z=8") self.assertResult(self.arg3, "{5, y=6, z=8}", "x=5, y=6, z=8") self.assertResult(self.arg3, "{5, y=6}", "x=5, y=6, z=default") self.assertResult(self.arg3, "{5, 6}", "x=5, y=6, z=default") self.assertResult(self.arg3, "{5, 6, 7}", "x=5, y=6, z=7") self.assertResult(self.arg3, "{z=7, 5, 6}", "x=5, y=6, z=7") def test_posargs_kwargs_bad(self): self.assertIncorrect(self.arg2, "{5, y=6, z=7}") self.assertIncorrect(self.arg2, "{5, [3]=6}") self.assertIncorrect(self.arg2, "{x=5, [2]=6}") # I guess it's ok to reject this self.assertIncorrect(self.arg3, "{5, z=7}") self.assertIncorrect(self.arg3, "{5}") def test_posargs_nil(self): self.assertResult(self.arg3, "(5, nil, 6)", "x=5, y=None, z=6") def test_posargs_nil_first(self): self.assertResult(self.arg3, "(nil, nil, 6)", "x=None, y=None, z=6") def test_posargs_nil_last(self): self.assertResult(self.arg3, "(5, nil, nil)", "x=5, y=None, z=None") def test_posargs_kwargs_python_none_last(self): self.assertResult(self.arg3, "{5, python.none, python.none}", "x=5, y=None, z=None") def test_posargs_python_none_last(self): self.assertResult(self.arg3, "(5, python.none, python.none)", "x=5, y=None, z=None") def test_posargs_kwargs_python_none_some(self): self.assertResult(self.arg3, "{python.none, y=python.none, z=6}", "x=None, y=None, z=6") def test_posargs_kwargs_python_none_all(self): self.assertResult(self.arg3, "{x=python.none, y=python.none}", "x=None, y=None, z=default") # ------------------------------------------------------------------------- # The following examples don't work as a Python programmer would expect # them to: # def test_posargs_kwargs_nil_last(self): # self.assertResult(self.arg3, "{5, nil, nil}", "x=5, y=None, z=None") # # def test_posargs_kwargs_nil_some(self): # self.assertResult(self.arg3, "{nil, y=nil, z=6}", "x=None, y=None, z=6") # # def test_posargs_kwargs_nil_all(self): # self.assertResult(self.arg3, "{x=nil, y=nil}", "x=None, y=None, z=default") # ------------------------------------------------------------------------- # These tests pass in Lua 5.2 but fail in LuaJIT: # def test_posargs_kwargs_nil(self): # self.assertResult(self.arg3, "{5, nil, 6}", "x=5, y=None, z=6") # # def test_posargs_kwargs_nil_first(self): # self.assertResult(self.arg3, "{nil, nil, 6}", "x=None, y=None, z=6") class MethodKwargsDecoratorTest(KwargsDecoratorTest): def __init__(self, *args, **kwargs): super(MethodKwargsDecoratorTest, self).__init__(*args, **kwargs) self.arg1 = MyCls_1() self.arg2 = MyCls_2() self.arg3 = MyCls_3() def assertResult(self, f, call_txt, res_txt): lua_func = self.lua.eval("function (obj) return obj:meth%s end" % call_txt) self.assertEqual(lua_func(f), res_txt) def assertIncorrect(self, f, call_txt): lua_func = self.lua.eval("function (obj) return obj:meth%s end" % call_txt) self.assertRaises(TypeError, lua_func, f) class NoEncodingKwargsDecoratorTest(KwargsDecoratorTest): lua_runtime_kwargs = {'encoding': None} class NoEncodingMethodKwargsDecoratorTest(MethodKwargsDecoratorTest): lua_runtime_kwargs = {'encoding': None} ################################################################################ # tests for the FastRLock implementation try: from thread import start_new_thread, get_ident except ImportError: # Python 3? from _thread import start_new_thread, get_ident def _wait(): # A crude wait/yield function not relying on synchronization primitives. time.sleep(0.01) class TestFastRLock(unittest.TestCase): """Copied from CPython's test.lock_tests module """ def setUp(self): from lupa._lupa import FastRLock self.locktype = FastRLock def tearDown(self): gc.collect() class Bunch(object): """ A bunch of threads. """ def __init__(self, f, n, wait_before_exit=False): """ Construct a bunch of `n` threads running the same function `f`. If `wait_before_exit` is True, the threads won't terminate until do_finish() is called. """ self.f = f self.n = n self.started = [] self.finished = [] self._can_exit = not wait_before_exit def task(): tid = get_ident() self.started.append(tid) try: f() finally: self.finished.append(tid) while not self._can_exit: _wait() for i in range(n): start_new_thread(task, ()) def wait_for_started(self): while len(self.started) < self.n: _wait() def wait_for_finished(self): while len(self.finished) < self.n: _wait() def do_finish(self): self._can_exit = True # the locking tests """ Tests for both recursive and non-recursive locks. """ def test_constructor(self): lock = self.locktype() del lock def test_acquire_destroy(self): lock = self.locktype() lock.acquire() del lock def test_acquire_release(self): lock = self.locktype() lock.acquire() lock.release() del lock def test_try_acquire(self): lock = self.locktype() self.assertTrue(lock.acquire(False)) lock.release() def test_try_acquire_contended(self): lock = self.locktype() lock.acquire() result = [] def f(): result.append(lock.acquire(False)) self.Bunch(f, 1).wait_for_finished() self.assertFalse(result[0]) lock.release() def test_acquire_contended(self): lock = self.locktype() lock.acquire() N = 5 def f(): lock.acquire() lock.release() b = self.Bunch(f, N) b.wait_for_started() _wait() self.assertEqual(len(b.finished), 0) lock.release() b.wait_for_finished() self.assertEqual(len(b.finished), N) ## def test_with(self): ## lock = self.locktype() ## def f(): ## lock.acquire() ## lock.release() ## def _with(err=None): ## with lock: ## if err is not None: ## raise err ## _with() ## # Check the lock is unacquired ## self.Bunch(f, 1).wait_for_finished() ## self.assertRaises(TypeError, _with, TypeError) ## # Check the lock is unacquired ## self.Bunch(f, 1).wait_for_finished() def test_thread_leak(self): # The lock shouldn't leak a Thread instance when used from a foreign # (non-threading) thread. lock = self.locktype() def f(): lock.acquire() lock.release() n = len(threading.enumerate()) # We run many threads in the hope that existing threads ids won't # be recycled. self.Bunch(f, 15).wait_for_finished() self.assertEqual(n, len(threading.enumerate())) """ Tests for non-recursive, weak locks (which can be acquired and released from different threads). """ def DISABLED_test_reacquire_non_recursive(self): # Lock needs to be released before re-acquiring. lock = self.locktype() phase = [] def f(): lock.acquire() phase.append(None) lock.acquire() phase.append(None) start_new_thread(f, ()) while len(phase) == 0: _wait() _wait() self.assertEqual(len(phase), 1) lock.release() while len(phase) == 1: _wait() self.assertEqual(len(phase), 2) def DISABLED_test_different_thread_release_succeeds(self): # Lock can be released from a different thread. lock = self.locktype() lock.acquire() def f(): lock.release() b = self.Bunch(f, 1) b.wait_for_finished() lock.acquire() lock.release() """ Tests for recursive locks. """ def test_reacquire(self): lock = self.locktype() lock.acquire() lock.acquire() lock.release() lock.acquire() lock.release() lock.release() def test_release_unacquired(self): # Cannot release an unacquired lock lock = self.locktype() self.assertRaises(RuntimeError, lock.release) lock.acquire() lock.acquire() lock.release() lock.acquire() lock.release() lock.release() self.assertRaises(RuntimeError, lock.release) def test_different_thread_release_fails(self): # Cannot release from a different thread lock = self.locktype() def f(): lock.acquire() b = self.Bunch(f, 1, True) try: self.assertRaises(RuntimeError, lock.release) finally: b.do_finish() def test__is_owned(self): lock = self.locktype() self.assertFalse(lock._is_owned()) lock.acquire() self.assertTrue(lock._is_owned()) lock.acquire() self.assertTrue(lock._is_owned()) result = [] def f(): result.append(lock._is_owned()) self.Bunch(f, 1).wait_for_finished() self.assertFalse(result[0]) lock.release() self.assertTrue(lock._is_owned()) lock.release() self.assertFalse(lock._is_owned()) ################################################################################ # tests for error stacktrace class TestErrorStackTrace(unittest.TestCase): if not hasattr(unittest.TestCase, 'assertIn'): def assertIn(self, member, container, msg=None): self.assertTrue(member in container, msg) if not hasattr(unittest.TestCase, 'assertNotIn'): def assertNotIn(self, member, container, msg=None): self.assertFalse(member in container, msg) def test_stacktrace(self): lua = lupa.LuaRuntime() try: lua.execute("error('abc')") raise RuntimeError("LuaError was not raised") except lupa.LuaError as e: self.assertIn("stack traceback:", e.args[0]) def test_nil_debug(self): lua = lupa.LuaRuntime() try: lua.execute("debug = nil") lua.execute("error('abc')") raise RuntimeError("LuaError was not raised") except lupa.LuaError as e: self.assertNotIn("stack traceback:", e.args[0]) def test_nil_debug_traceback(self): lua = lupa.LuaRuntime() try: lua.execute("debug = nil") lua.execute("error('abc')") raise RuntimeError("LuaError was not raised") except lupa.LuaError as e: self.assertNotIn("stack traceback:", e.args[0]) if __name__ == '__main__': unittest.main() lupa-1.6/lupa/lupa_defs.h0000664000175000017500000000060012703236255016162 0ustar stefanstefan00000000000000/* * Compatibility definitions for Lupa. */ #if LUA_VERSION_NUM >= 502 #define __lupa_lua_resume(L, from_, nargs) lua_resume(L, from_, nargs) #define lua_objlen(L, i) lua_rawlen(L, (i)) #else #if LUA_VERSION_NUM >= 501 #define __lupa_lua_resume(L, from_, nargs) lua_resume(L, nargs) #else #error Lupa requires at least Lua 5.1 or LuaJIT 2.x #endif #endif lupa-1.6/lupa/__init__.py0000664000175000017500000000150512123314212016147 0ustar stefanstefan00000000000000 # We need to enable global symbol visibility for lupa in order to # support binary module loading in Lua. If we can enable it here, we # do it temporarily. def _try_import_with_global_library_symbols(): try: import DLFCN dlopen_flags = DLFCN.RTLD_NOW | DLFCN.RTLD_GLOBAL except ImportError: import ctypes dlopen_flags = ctypes.RTLD_GLOBAL import sys old_flags = sys.getdlopenflags() try: sys.setdlopenflags(dlopen_flags) import lupa._lupa finally: sys.setdlopenflags(old_flags) try: _try_import_with_global_library_symbols() except: pass del _try_import_with_global_library_symbols # the following is all that should stay in the namespace: from lupa._lupa import * try: from lupa.version import __version__ except ImportError: pass lupa-1.6/lupa/_lupa.pyx0000664000175000017500000020237713204635326015727 0ustar stefanstefan00000000000000# cython: embedsignature=True, binding=True """ A fast Python wrapper around Lua and LuaJIT2. """ from __future__ import absolute_import cimport cython from libc.string cimport strlen, strchr from lupa cimport lua from .lua cimport lua_State cimport cpython.ref cimport cpython.tuple cimport cpython.float cimport cpython.long from cpython.ref cimport PyObject from cpython.method cimport ( PyMethod_Check, PyMethod_GET_SELF, PyMethod_GET_FUNCTION) from cpython.version cimport PY_MAJOR_VERSION from cpython.bytes cimport PyBytes_FromFormat from libc.stdint cimport uintptr_t cdef object exc_info from sys import exc_info cdef object Mapping from collections import Mapping cdef object wraps from functools import wraps __all__ = ['LuaRuntime', 'LuaError', 'LuaSyntaxError', 'as_itemgetter', 'as_attrgetter', 'lua_type', 'unpacks_lua_table', 'unpacks_lua_table_method'] cdef object builtins try: import __builtin__ as builtins except ImportError: import builtins DEF POBJECT = b"POBJECT" # as used by LunaticPython cdef int IS_PY2 = PY_MAJOR_VERSION == 2 cdef enum WrappedObjectFlags: # flags that determine the behaviour of a wrapped object: OBJ_AS_INDEX = 1 # prefers the getitem protocol (over getattr) OBJ_UNPACK_TUPLE = 2 # unpacks into separate values if it is a tuple OBJ_ENUMERATOR = 4 # iteration uses native enumerate() implementation cdef struct py_object: PyObject* obj PyObject* runtime int type_flags # or-ed set of WrappedObjectFlags include "lock.pxi" class LuaError(Exception): """Base class for errors in the Lua runtime. """ class LuaSyntaxError(LuaError): """Syntax error in Lua code. """ def lua_type(obj): """ Return the Lua type name of a wrapped object as string, as provided by Lua's type() function. For non-wrapper objects (i.e. normal Python objects), returns None. """ if not isinstance(obj, _LuaObject): return None lua_object = <_LuaObject>obj assert lua_object._runtime is not None lock_runtime(lua_object._runtime) L = lua_object._state old_top = lua.lua_gettop(L) cdef const char* lua_type_name try: lua.lua_rawgeti(L, lua.LUA_REGISTRYINDEX, lua_object._ref) ltype = lua.lua_type(L, -1) if ltype == lua.LUA_TTABLE: return 'table' elif ltype == lua.LUA_TFUNCTION: return 'function' elif ltype == lua.LUA_TTHREAD: return 'thread' elif ltype in (lua.LUA_TUSERDATA, lua.LUA_TLIGHTUSERDATA): return 'userdata' else: lua_type_name = lua.lua_typename(L, ltype) return lua_type_name if IS_PY2 else lua_type_name.decode('ascii') finally: lua.lua_settop(L, old_top) unlock_runtime(lua_object._runtime) @cython.no_gc_clear cdef class LuaRuntime: """The main entry point to the Lua runtime. Available options: * ``encoding``: the string encoding, defaulting to UTF-8. If set to ``None``, all string values will be returned as byte strings. Otherwise, they will be decoded to unicode strings on the way from Lua to Python and unicode strings will be encoded on the way to Lua. Note that ``str()`` calls on Lua objects will always return a unicode object. * ``source_encoding``: the encoding used for Lua code, defaulting to the string encoding or UTF-8 if the string encoding is ``None``. * ``attribute_filter``: filter function for attribute access (get/set). Must have the signature ``func(obj, attr_name, is_setting)``, where ``is_setting`` is True when the attribute is being set. If provided, the function will be called for all Python object attributes that are being accessed from Lua code. Normally, it should return an attribute name that will then be used for the lookup. If it wants to prevent access, it should raise an ``AttributeError``. Note that Lua does not guarantee that the names will be strings. (New in Lupa 0.20) * ``attribute_handlers``: like ``attribute_filter`` above, but handles the getting/setting itself rather than giving hints to the LuaRuntime. This must be a 2-tuple, ``(getter, setter)`` where ``getter`` has the signature ``func(obj, attr_name)`` and either returns the value for ``obj.attr_name`` or raises an ``AttributeError`` The function ``setter`` has the signature ``func(obj, attr_name, value)`` and may raise an ``AttributeError``. The return value of the setter is unused. (New in Lupa 1.0) * ``register_eval``: should Python's ``eval()`` function be available to Lua code as ``python.eval()``? Note that this does not remove it from the builtins. Use an ``attribute_filter`` function for that. (default: True) * ``register_builtins``: should Python's builtins be available to Lua code as ``python.builtins.*``? Note that this does not prevent access to the globals available as special Python function attributes, for example. Use an ``attribute_filter`` function for that. (default: True, new in Lupa 1.2) * ``unpack_returned_tuples``: should Python tuples be unpacked in Lua? If ``py_fun()`` returns ``(1, 2, 3)``, then does ``a, b, c = py_fun()`` give ``a == 1 and b == 2 and c == 3`` or does it give ``a == (1,2,3), b == nil, c == nil``? ``unpack_returned_tuples=True`` gives the former. (default: False, new in Lupa 0.21) Example usage:: >>> from lupa import LuaRuntime >>> lua = LuaRuntime() >>> lua.eval('1+1') 2 >>> lua_func = lua.eval('function(f, n) return f(n) end') >>> def py_add1(n): return n+1 >>> lua_func(py_add1, 2) 3 """ cdef lua_State *_state cdef FastRLock _lock cdef dict _pyrefs_in_lua cdef tuple _raised_exception cdef bytes _encoding cdef bytes _source_encoding cdef object _attribute_filter cdef object _attribute_getter cdef object _attribute_setter cdef bint _unpack_returned_tuples def __cinit__(self, encoding='UTF-8', source_encoding=None, attribute_filter=None, attribute_handlers=None, bint register_eval=True, bint unpack_returned_tuples=False, bint register_builtins=True): cdef lua_State* L = lua.luaL_newstate() if L is NULL: raise LuaError("Failed to initialise Lua runtime") self._state = L self._lock = FastRLock() self._pyrefs_in_lua = {} self._encoding = _asciiOrNone(encoding) self._source_encoding = _asciiOrNone(source_encoding) or self._encoding or b'UTF-8' if attribute_filter is not None and not callable(attribute_filter): raise ValueError("attribute_filter must be callable") self._attribute_filter = attribute_filter self._unpack_returned_tuples = unpack_returned_tuples if attribute_handlers: raise_error = False try: getter, setter = attribute_handlers except (ValueError, TypeError): raise_error = True else: if (getter is not None and not callable(getter) or setter is not None and not callable(setter)): raise_error = True if raise_error: raise ValueError("attribute_handlers must be a sequence of two callables") if attribute_filter and (getter is not None or setter is not None): raise ValueError("attribute_filter and attribute_handlers are mutually exclusive") self._attribute_getter, self._attribute_setter = getter, setter lua.luaL_openlibs(L) self.init_python_lib(register_eval, register_builtins) lua.lua_settop(L, 0) lua.lua_atpanic(L, 1) def __dealloc__(self): if self._state is not NULL: lua.lua_close(self._state) self._state = NULL @cython.final cdef int reraise_on_exception(self) except -1: if self._raised_exception is not None: exception = self._raised_exception self._raised_exception = None raise exception[0], exception[1], exception[2] return 0 @cython.final cdef int store_raised_exception(self, lua_State* L, bytes lua_error_msg) except -1: try: self._raised_exception = exc_info() py_to_lua(self, L, self._raised_exception[1]) except: lua.lua_pushlstring(L, lua_error_msg, len(lua_error_msg)) raise return 0 def eval(self, lua_code, *args): """Evaluate a Lua expression passed in a string. """ assert self._state is not NULL if isinstance(lua_code, unicode): lua_code = (lua_code).encode(self._source_encoding) return run_lua(self, b'return ' + lua_code, args) def execute(self, lua_code, *args): """Execute a Lua program passed in a string. """ assert self._state is not NULL if isinstance(lua_code, unicode): lua_code = (lua_code).encode(self._source_encoding) return run_lua(self, lua_code, args) def compile(self, lua_code): """Compile a Lua program into a callable Lua function. """ cdef const char *err if isinstance(lua_code, unicode): lua_code = (lua_code).encode(self._source_encoding) L = self._state lock_runtime(self) oldtop = lua.lua_gettop(L) cdef size_t size try: status = lua.luaL_loadbuffer(L, lua_code, len(lua_code), b'') if status == 0: return py_from_lua(self, L, -1) else: err = lua.lua_tolstring(L, -1, &size) error = err[:size] if self._encoding is None else err[:size].decode(self._encoding) raise LuaSyntaxError(error) finally: lua.lua_settop(L, oldtop) unlock_runtime(self) def require(self, modulename): """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)): raise TypeError("modulename must be a string") lock_runtime(self) old_top = lua.lua_gettop(L) try: lua.lua_getglobal(L, 'require') if lua.lua_isnil(L, -1): raise LuaError("require is not defined") return call_lua(self, L, (modulename,)) finally: lua.lua_settop(L, old_top) unlock_runtime(self) def globals(self): """Return the globals defined in this Lua runtime as a Lua table. """ assert self._state is not NULL cdef lua_State *L = self._state lock_runtime(self) old_top = lua.lua_gettop(L) try: lua.lua_getglobal(L, '_G') if lua.lua_isnil(L, -1): raise LuaError("globals not defined") return py_from_lua(self, L, -1) finally: lua.lua_settop(L, old_top) unlock_runtime(self) def table(self, *items, **kwargs): """Create a new table with the provided items. Positional arguments are placed in the table in order, keyword arguments are set as key-value pairs. """ return self.table_from(items, kwargs) def table_from(self, *args): """Create a new table from Python mapping or iterable. table_from() accepts either a dict/mapping or an iterable with items. Items from dicts are set as key-value pairs; items from iterables are placed in the table in order. Nested mappings / iterables are passed to Lua as userdata (wrapped Python objects); they are not converted to Lua tables. """ assert self._state is not NULL cdef lua_State *L = self._state cdef int i = 1 lock_runtime(self) old_top = lua.lua_gettop(L) try: lua.lua_newtable(L) # FIXME: how to check for failure? for obj in args: if isinstance(obj, dict): for key, value in obj.iteritems(): py_to_lua(self, L, key) py_to_lua(self, L, value) lua.lua_rawset(L, -3) elif isinstance(obj, _LuaTable): # Stack: # tbl (<_LuaObject>obj).push_lua_object() # tbl, obj lua.lua_pushnil(L) # tbl, obj, nil // iterate over obj (-2) while lua.lua_next(L, -2): # tbl, obj, k, v lua.lua_pushvalue(L, -2) # tbl, obj, k, v, k // copy key (because lua.lua_insert(L, -2) # tbl, obj, k, k, v // lua_next needs a key for iteration) lua.lua_settable(L, -5) # tbl, obj, k // tbl[k] = v lua.lua_pop(L, 1) # tbl // remove obj from stack elif isinstance(obj, Mapping): for key in obj: value = obj[key] py_to_lua(self, L, key) py_to_lua(self, L, value) lua.lua_rawset(L, -3) else: for arg in obj: py_to_lua(self, L, arg) lua.lua_rawseti(L, -2, i) i += 1 return py_from_lua(self, L, -1) finally: lua.lua_settop(L, old_top) unlock_runtime(self) @cython.final cdef int register_py_object(self, bytes cname, bytes pyname, object obj) except -1: cdef lua_State *L = self._state lua.lua_pushlstring(L, cname, len(cname)) if not py_to_lua_custom(self, L, obj, 0): 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) lua.lua_rawset(L, lua.LUA_REGISTRYINDEX) return 0 @cython.final cdef int init_python_lib(self, bint register_eval, bint register_builtins) except -1: cdef lua_State *L = self._state # create 'python' lib and register our own object metatable luaL_openlib(L, "python", py_lib, 0) lua.luaL_newmetatable(L, POBJECT) luaL_openlib(L, NULL, py_object_lib, 0) lua.lua_pop(L, 1) # register global names in the module self.register_py_object(b'Py_None', b'none', None) if register_eval: self.register_py_object(b'eval', b'eval', eval) if register_builtins: self.register_py_object(b'builtins', b'builtins', builtins) return 0 # nothing left to return on the stack ################################################################################ # decorators for calling Python functions with keyword (named) arguments # from Lua scripts def unpacks_lua_table(func): """ A decorator to make the decorated function receive kwargs when it is called from Lua with a single Lua table argument. Python functions wrapped in this decorator can be called from Lua code as ``func(foo, bar)``, ``func{foo=foo, bar=bar}`` and ``func{foo, bar=bar}``. See also: http://lua-users.org/wiki/NamedParameters WARNING: avoid using this decorator for functions where the first argument can be a Lua table. WARNING: be careful with ``nil`` values. Depending on the context, passing ``nil`` as a parameter can mean either "omit a parameter" or "pass None". This even depends on the Lua version. It is possible to use ``python.none`` instead of ``nil`` to pass None values robustly. """ @wraps(func) def wrapper(*args): args, kwargs = _fix_args_kwargs(args) return func(*args, **kwargs) return wrapper def unpacks_lua_table_method(meth): """ This is :func:`unpacks_lua_table` for methods (i.e. it knows about the 'self' argument). """ @wraps(meth) def wrapper(self, *args): args, kwargs = _fix_args_kwargs(args) return meth(self, *args, **kwargs) return wrapper cdef tuple _fix_args_kwargs(tuple args): """ Extract named arguments from args passed to a Python function by Lua script. Arguments are processed only if a single argument is passed and it is a table. """ if len(args) != 1: return args, {} arg = args[0] if not isinstance(arg, _LuaTable): return args, {} table = <_LuaTable>arg encoding = table._runtime._source_encoding # arguments with keys from 1 to #tbl are passed as positional new_args = [ table._getitem(key, is_attr_access=False) for key in range(1, table._len() + 1) ] # arguments with non-integer keys are passed as named new_kwargs = { (key).decode(encoding) if not IS_PY2 and isinstance(key, bytes) else key: value for key, value in _LuaIter(table, ITEMS) if not isinstance(key, (int, long)) } return new_args, new_kwargs ################################################################################ # 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") return 0 cdef inline void unlock_runtime(LuaRuntime runtime) nogil: unlock_lock(runtime._lock) ################################################################################ # Lua object wrappers @cython.internal @cython.no_gc_clear @cython.freelist(16) cdef class _LuaObject: """A wrapper around a Lua object such as a table or function. """ cdef LuaRuntime _runtime cdef lua_State* _state cdef int _ref def __init__(self): raise TypeError("Type cannot be instantiated manually") def __dealloc__(self): if self._runtime is None: return cdef lua_State* L = self._state try: lock_runtime(self._runtime) locked = True except: locked = False lua.luaL_unref(L, lua.LUA_REGISTRYINDEX, self._ref) if locked: unlock_runtime(self._runtime) @cython.final cdef inline int push_lua_object(self) except -1: cdef lua_State* L = self._state lua.lua_rawgeti(L, lua.LUA_REGISTRYINDEX, self._ref) if lua.lua_isnil(L, -1): lua.lua_pop(L, 1) raise LuaError("lost reference") def __call__(self, *args): assert self._runtime is not None cdef lua_State* L = self._state lock_runtime(self._runtime) try: lua.lua_settop(L, 0) self.push_lua_object() return call_lua(self._runtime, L, args) finally: lua.lua_settop(L, 0) unlock_runtime(self._runtime) def __len__(self): return self._len() @cython.final cdef size_t _len(self): assert self._runtime is not None cdef lua_State* L = self._state lock_runtime(self._runtime) size = 0 try: self.push_lua_object() size = lua.lua_objlen(L, -1) lua.lua_pop(L, 1) finally: unlock_runtime(self._runtime) return size def __nonzero__(self): return True def __iter__(self): # if not provided, iteration will try item access and call into Lua raise TypeError("iteration is only supported for tables") def __repr__(self): assert self._runtime is not None cdef lua_State* L = self._state cdef bytes encoding = self._runtime._encoding or b'UTF-8' lock_runtime(self._runtime) try: self.push_lua_object() return lua_object_repr(L, encoding) finally: lua.lua_pop(L, 1) unlock_runtime(self._runtime) def __str__(self): assert self._runtime is not None cdef lua_State* L = self._state cdef unicode py_string = None cdef const char *s cdef size_t size = 0 cdef bytes encoding = self._runtime._encoding or b'UTF-8' lock_runtime(self._runtime) old_top = lua.lua_gettop(L) try: self.push_lua_object() # 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: s = lua.lua_tolstring(L, -1, &size) if s: try: py_string = s[:size].decode(encoding) except UnicodeDecodeError: # safe 'decode' py_string = s[:size].decode('ISO-8859-1') if py_string is None: lua.lua_settop(L, old_top + 1) py_string = lua_object_repr(L, encoding) finally: lua.lua_settop(L, old_top) unlock_runtime(self._runtime) return py_string def __getattr__(self, name): assert self._runtime is not None if isinstance(name, unicode): if (name).startswith(u'__') and (name).endswith(u'__'): return object.__getattr__(self, name) name = (name).encode(self._runtime._source_encoding) elif isinstance(name, bytes): if (name).startswith(b'__') and (name).endswith(b'__'): return object.__getattr__(self, name) return self._getitem(name, is_attr_access=True) def __getitem__(self, index_or_name): return self._getitem(index_or_name, is_attr_access=False) @cython.final cdef _getitem(self, name, bint is_attr_access): cdef lua_State* L = self._state lock_runtime(self._runtime) old_top = lua.lua_gettop(L) try: self.push_lua_object() lua_type = lua.lua_type(L, -1) if lua_type == lua.LUA_TFUNCTION or lua_type == lua.LUA_TTHREAD: lua.lua_pop(L, 1) raise (AttributeError if is_attr_access else TypeError)( "item/attribute access not supported on functions") # table[nil] fails, so map None -> python.none for Lua tables py_to_lua(self._runtime, L, name, wrap_none=lua_type == lua.LUA_TTABLE) lua.lua_gettable(L, -2) return py_from_lua(self._runtime, L, -1) finally: lua.lua_settop(L, old_top) unlock_runtime(self._runtime) 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 cdef void init_lua_object(_LuaObject obj, LuaRuntime runtime, lua_State* L, int n): obj._runtime = runtime obj._state = L lua.lua_pushvalue(L, n) obj._ref = lua.luaL_ref(L, lua.LUA_REGISTRYINDEX) cdef object lua_object_repr(lua_State* L, bytes encoding): cdef bytes py_bytes lua_type = lua.lua_type(L, -1) if lua_type in (lua.LUA_TTABLE, lua.LUA_TFUNCTION): ptr = lua.lua_topointer(L, -1) elif lua_type in (lua.LUA_TUSERDATA, lua.LUA_TLIGHTUSERDATA): ptr = lua.lua_touserdata(L, -1) elif lua_type == lua.LUA_TTHREAD: ptr = lua.lua_tothread(L, -1) else: ptr = NULL if ptr: py_bytes = PyBytes_FromFormat( "", lua.lua_typename(L, lua_type), ptr) else: py_bytes = PyBytes_FromFormat( "", lua.lua_typename(L, lua_type)) try: return py_bytes.decode(encoding) except UnicodeDecodeError: # safe 'decode' return py_bytes.decode('ISO-8859-1') @cython.final @cython.internal @cython.no_gc_clear cdef class _LuaTable(_LuaObject): def __iter__(self): return _LuaIter(self, KEYS) def keys(self): """Returns an iterator over the keys of a table that this object represents. Same as iter(obj). """ return _LuaIter(self, KEYS) def values(self): """Returns an iterator over the values of a table that this object represents. """ return _LuaIter(self, VALUES) def items(self): """Returns an iterator over the key-value pairs of a table that this object represents. """ return _LuaIter(self, ITEMS) def __setattr__(self, name, value): assert self._runtime is not None if isinstance(name, unicode): if (name).startswith(u'__') and (name).endswith(u'__'): object.__setattr__(self, name, value) return name = (name).encode(self._runtime._source_encoding) elif isinstance(name, bytes) and (name).startswith(b'__') and (name).endswith(b'__'): object.__setattr__(self, name, value) return self._setitem(name, value) def __setitem__(self, index_or_name, value): self._setitem(index_or_name, value) @cython.final cdef int _setitem(self, name, value) except -1: cdef lua_State* L = self._state lock_runtime(self._runtime) old_top = lua.lua_gettop(L) try: self.push_lua_object() # table[nil] fails, so map None -> python.none for Lua tables py_to_lua(self._runtime, L, name, wrap_none=True) py_to_lua(self._runtime, L, value) lua.lua_settable(L, -3) finally: lua.lua_settop(L, old_top) unlock_runtime(self._runtime) return 0 def __delattr__(self, item): assert self._runtime is not None if isinstance(item, unicode): if (item).startswith(u'__') and (item).endswith(u'__'): object.__delattr__(self, item) return item = (item).encode(self._runtime._source_encoding) elif isinstance(item, bytes) and (item).startswith(b'__') and (item).endswith(b'__'): object.__delattr__(self, item) return self._delitem(item) def __delitem__(self, key): self._delitem(key) @cython.final cdef _delitem(self, name): cdef lua_State* L = self._state lock_runtime(self._runtime) old_top = lua.lua_gettop(L) try: self.push_lua_object() py_to_lua(self._runtime, L, name, wrap_none=True) lua.lua_pushnil(L) lua.lua_settable(L, -3) finally: lua.lua_settop(L, old_top) unlock_runtime(self._runtime) 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 @cython.internal @cython.no_gc_clear cdef class _LuaFunction(_LuaObject): """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. """ assert self._runtime is not None cdef lua_State* L = self._state cdef lua_State* co cdef _LuaThread thread lock_runtime(self._runtime) old_top = lua.lua_gettop(L) try: self.push_lua_object() if not lua.lua_isfunction(L, -1) or lua.lua_iscfunction(L, -1): 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) # 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 finally: lua.lua_settop(L, old_top) 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) return obj @cython.final @cython.internal @cython.no_gc_clear cdef class _LuaCoroutineFunction(_LuaFunction): """A function that returns a new coroutine when called. """ def __call__(self, *args): 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) return obj @cython.final @cython.internal @cython.no_gc_clear # FIXME: get rid if this cdef class _LuaThread(_LuaObject): """A Lua thread (coroutine). """ cdef lua_State* _co_state cdef tuple _arguments def __iter__(self): return self def __next__(self): 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) def send(self, value): """Send a value into the coroutine. If the value is a tuple, 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") if not isinstance(value, tuple): value = (value,) elif self._arguments is not None: value = self._arguments self._arguments = None return resume_lua_thread(self, value) 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: return True 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: return True # not started yet 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) obj._co_state = lua.lua_tothread(L, n) return obj 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 # 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 lua.lua_pushvalue(co, 1) lua.lua_xmove(co, L, 1) try: return new_lua_coroutine_function(runtime, L, -1) finally: lua.lua_pop(L, 1) else: # already started => wrap the thread return new_lua_thread(runtime, L, n) cdef object resume_lua_thread(_LuaThread thread, tuple args): cdef lua_State* co = thread._co_state cdef lua_State* L = thread._state cdef int status, i, nargs = 0, nres = 0 lock_runtime(thread._runtime) old_top = lua.lua_gettop(L) try: if lua.lua_status(co) == 0 and lua.lua_gettop(co) == 0: # already terminated raise StopIteration if args: nargs = len(args) push_lua_arguments(thread._runtime, co, args) with nogil: status = lua.lua_resume(co, L, nargs) nres = lua.lua_gettop(co) if status != lua.LUA_YIELD: if status == 0: # terminated if nres == 0: # no values left to return raise StopIteration else: raise_lua_error(thread._runtime, co, status) # Move yielded values to the main state before unpacking. # This is what Lua's internal auxresume function is doing; # it affects wrapped Lua functions returned to Python. lua.lua_xmove(co, L, nres) return unpack_lua_results(thread._runtime, L) finally: # FIXME: check that coroutine state is OK in case of errors? lua.lua_settop(L, old_top) unlock_runtime(thread._runtime) cdef enum: KEYS = 1 VALUES = 2 ITEMS = 3 @cython.final @cython.internal @cython.no_gc_clear cdef class _LuaIter: cdef LuaRuntime _runtime cdef _LuaObject _obj cdef lua_State* _state cdef int _refiter cdef char _what def __cinit__(self, _LuaObject obj not None, int what): self._state = NULL assert obj._runtime is not None self._runtime = obj._runtime self._obj = obj self._state = obj._state self._refiter = 0 self._what = what def __dealloc__(self): if self._runtime is None: return cdef lua_State* L = self._state if L is not NULL and self._refiter: locked = False try: lock_runtime(self._runtime) locked = True except: pass lua.luaL_unref(L, lua.LUA_REGISTRYINDEX, self._refiter) if locked: unlock_runtime(self._runtime) def __repr__(self): return u"LuaIter(%r)" % (self._obj) def __iter__(self): return self def __next__(self): if self._obj is None: raise StopIteration cdef lua_State* L = self._obj._state lock_runtime(self._runtime) old_top = lua.lua_gettop(L) try: if self._obj is None: 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.lua_pop(L, 1) raise LuaError("lost reference") raise TypeError("cannot iterate over non-table (found %r)" % self._obj) if not self._refiter: # initial key lua.lua_pushnil(L) else: # last key 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) 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)) finally: # pop value lua.lua_pop(L, 1) # 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) return retval # iteration done, clean up if self._refiter: lua.luaL_unref(L, lua.LUA_REGISTRYINDEX, self._refiter) self._refiter = 0 self._obj = None finally: lua.lua_settop(L, old_top) unlock_runtime(self._runtime) raise StopIteration # 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) == 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.lua_insert(L, 1) 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 py_asfunc_call: lua.lua_pushvalue(L, n) lua.lua_pushlightuserdata(L, unpack_wrapped_pyfunction) if lua.lua_pcall(L, 1, 1, 0) == 0: return unpack_userdata(L, -1) return NULL @cython.final @cython.internal @cython.freelist(8) cdef class _PyProtocolWrapper: cdef object _obj cdef int _type_flags def __cinit__(self): self._type_flags = 0 def __init__(self): raise TypeError("Type cannot be instantiated from Python") def as_attrgetter(obj): cdef _PyProtocolWrapper wrap = _PyProtocolWrapper.__new__(_PyProtocolWrapper) wrap._obj = obj wrap._type_flags = 0 return wrap def as_itemgetter(obj): cdef _PyProtocolWrapper wrap = _PyProtocolWrapper.__new__(_PyProtocolWrapper) wrap._obj = obj wrap._type_flags = OBJ_AS_INDEX return wrap cdef object py_from_lua(LuaRuntime runtime, lua_State *L, int n): """ Convert a Lua object to a Python object by either mapping, wrapping or unwrapping it. """ cdef size_t size = 0 cdef const char *s 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: return None elif lua_type == lua.LUA_TNUMBER: number = lua.lua_tonumber(L, n) if number != number: return number else: return 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) else: return s[:size] elif lua_type == lua.LUA_TBOOLEAN: return lua.lua_toboolean(L, n) elif lua_type == lua.LUA_TUSERDATA: py_obj = unpack_userdata(L, n) if py_obj: return 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) elif lua_type == lua.LUA_TFUNCTION: py_obj = unpack_wrapped_pyfunction(L, n) if py_obj: return py_obj.obj return new_lua_function(runtime, L, n) return new_lua_object(runtime, L, n) cdef py_object* unpack_userdata(lua_State *L, int n) nogil: """ Like luaL_checkudata(), unpacks a userdata object and validates that it's a wrapped Python object. Returns NULL on failure. """ p = lua.lua_touserdata(L, n) if p and lua.lua_getmetatable(L, n): # found userdata with metatable - the one we expect? lua.luaL_getmetatable(L, POBJECT) if lua.lua_rawequal(L, -1, -2): lua.lua_pop(L, 2) return p lua.lua_pop(L, 2) return NULL cdef int py_function_result_to_lua(LuaRuntime runtime, lua_State *L, object o) except -1: if runtime._unpack_returned_tuples and isinstance(o, tuple): push_lua_arguments(runtime, L, o) return len(o) return py_to_lua(runtime, L, o) cdef int py_to_lua(LuaRuntime runtime, lua_State *L, object o, bint wrap_none=False) except -1: cdef int pushed_values_count = 0 cdef int type_flags = 0 if o is None: if wrap_none: lua.lua_pushlstring(L, "Py_None", 7) lua.lua_rawget(L, lua.LUA_REGISTRYINDEX) if lua.lua_isnil(L, -1): lua.lua_pop(L, 1) return 0 pushed_values_count = 1 else: # Not really needed, but this way we may check for errors # with pushed_values_count == 0. lua.lua_pushnil(L) pushed_values_count = 1 elif o is True or o is False: lua.lua_pushboolean(L, o) pushed_values_count = 1 elif type(o) is float: lua.lua_pushnumber(L, cpython.float.PyFloat_AS_DOUBLE(o)) pushed_values_count = 1 elif isinstance(o, long): lua.lua_pushnumber(L, cpython.long.PyLong_AsDouble(o)) pushed_values_count = 1 elif IS_PY2 and isinstance(o, int): lua.lua_pushnumber(L, o) pushed_values_count = 1 elif isinstance(o, bytes): lua.lua_pushlstring(L, (o), len(o)) pushed_values_count = 1 elif isinstance(o, unicode) and runtime._encoding is not None: pushed_values_count = push_encoded_unicode_string(runtime, L, 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) pushed_values_count = 1 elif isinstance(o, float): lua.lua_pushnumber(L, o) pushed_values_count = 1 else: if isinstance(o, _PyProtocolWrapper): type_flags = (<_PyProtocolWrapper>o)._type_flags o = (<_PyProtocolWrapper>o)._obj 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 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, bytes_string, len(bytes_string)) return 1 cdef bint py_to_lua_custom(LuaRuntime runtime, lua_State *L, object o, int type_flags): cdef py_object *py_obj = lua.lua_newuserdata(L, sizeof(py_object)) if not py_obj: return 0 # values pushed # originally, we just used: #cpython.ref.Py_INCREF(o) # now, we store an owned reference in "runtime._pyrefs_in_lua" to keep it visible to Python # and a borrowed reference in "py_obj.obj" for access from Lua obj_id = (o) if obj_id in runtime._pyrefs_in_lua: runtime._pyrefs_in_lua[obj_id].append(o) else: runtime._pyrefs_in_lua[obj_id] = [o] py_obj.obj = o py_obj.runtime = runtime py_obj.type_flags = type_flags lua.luaL_getmetatable(L, POBJECT) lua.lua_setmetatable(L, -2) return 1 # values pushed cdef inline int _isascii(unsigned char* s): cdef unsigned char c = 0 while s[0]: c |= s[0] s += 1 return c & 0x80 == 0 cdef bytes _asciiOrNone(s): if s is None: return s elif isinstance(s, unicode): return (s).encode('ascii') elif isinstance(s, bytearray): s = bytes(s) elif not isinstance(s, bytes): raise ValueError("expected string, got %s" % type(s)) if not _isascii(s): raise ValueError("byte string input has unknown encoding, only ASCII is allowed") return s # error handling cdef int raise_lua_error(LuaRuntime runtime, lua_State* L, int result) except -1: if result == 0: return 0 elif result == lua.LUA_ERRMEM: raise MemoryError() 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): cdef size_t size = 0 cdef const char *s = lua.lua_tolstring(L, n, &size) if runtime._encoding is not None: try: py_ustring = s[:size].decode(runtime._encoding) except UnicodeDecodeError: py_ustring = s[:size].decode('ISO-8859-1') # safe 'fake' decoding else: py_ustring = s[:size].decode('ISO-8859-1') if err_message is None: return py_ustring else: return err_message % py_ustring # calling into Lua cdef run_lua(LuaRuntime runtime, bytes lua_code, tuple args): # locks the runtime cdef lua_State* L = runtime._state cdef bint result lock_runtime(runtime) old_top = lua.lua_gettop(L) try: if lua.luaL_loadbuffer(L, lua_code, len(lua_code), ''): raise LuaSyntaxError(build_lua_error_message( runtime, L, u"error loading code: %s", -1)) return call_lua(runtime, L, args) finally: lua.lua_settop(L, old_top) unlock_runtime(runtime) cdef call_lua(LuaRuntime runtime, lua_State *L, tuple args): # does not lock the runtime! # does not clean up the stack! push_lua_arguments(runtime, L, args) return execute_lua_call(runtime, L, len(args)) cdef object execute_lua_call(LuaRuntime runtime, lua_State *L, Py_ssize_t nargs): cdef int result_status cdef object result # call into Lua cdef int errfunc = 0 with nogil: lua.lua_getglobal(L, "debug") if not lua.lua_istable(L, -1): lua.lua_pop(L, 1) else: lua.lua_getfield(L, -1, "traceback") if not lua.lua_isfunction(L, -1): lua.lua_pop(L, 2) else: lua.lua_replace(L, -2) lua.lua_insert(L, 1) errfunc = 1 result_status = lua.lua_pcall(L, nargs, lua.LUA_MULTRET, errfunc) if errfunc: lua.lua_remove(L, 1) results = unpack_lua_results(runtime, L) if result_status: if isinstance(results, BaseException): runtime.reraise_on_exception() raise_lua_error(runtime, L, result_status) return results cdef int push_lua_arguments(LuaRuntime runtime, lua_State *L, tuple args, bint first_may_be_nil=True) except -1: cdef int i if args: old_top = lua.lua_gettop(L) for i, arg in enumerate(args): if not py_to_lua(runtime, L, arg, wrap_none=not first_may_be_nil): lua.lua_settop(L, old_top) raise TypeError("failed to convert argument at index %d" % i) first_may_be_nil = True return 0 cdef inline object unpack_lua_results(LuaRuntime runtime, lua_State *L): cdef int nargs = lua.lua_gettop(L) if nargs == 1: return py_from_lua(runtime, L, 1) 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): 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) cpython.tuple.PyTuple_SET_ITEM(args, i, arg) return args ################################################################################ # Python support in Lua ## The rules: ## ## Each of the following blocks of functions represents the view on a ## specific Python feature from Lua code. As they are called from ## Lua, the entry points are 'nogil' functions that do not hold the ## GIL. They do the basic error checking and argument unpacking and ## then hand over to a 'with gil' function that acquires the GIL on ## entry and holds it during its lifetime. This function does the ## actual mapping of the Python feature or object to Lua. ## ## Lua's C level error handling is different from that of Python. It ## uses long jumps instead of returning from an error function. The ## places where this can happen are marked with a comment. Note that ## this only never happen inside of a 'nogil' function, as a long jump ## out of a function that handles Python objects would kill their ## reference counting. # ref-counting support for Python objects cdef int decref_with_gil(py_object *py_obj, lua_State* L) with gil: # originally, we just used: #cpython.ref.Py_XDECREF(py_obj.obj) # now, we keep Python object references in Lua visible to Python in a dict of lists: runtime = py_obj.runtime try: obj_id = py_obj.obj try: refs = runtime._pyrefs_in_lua[obj_id] except (TypeError, KeyError): return 0 # runtime was already cleared during GC, nothing left to do if len(refs) == 1: del runtime._pyrefs_in_lua[obj_id] else: refs.pop() # any, really return 0 except: try: runtime.store_raised_exception(L, b'error while cleaning up a Python object') finally: return -1 cdef int py_object_gc(lua_State* L) nogil: if not lua.lua_isuserdata(L, 1): return 0 py_obj = unpack_userdata(L, 1) if py_obj is not NULL and py_obj.obj is not NULL: if decref_with_gil(py_obj, L): return lua.lua_error(L) # never returns! return 0 # calling Python objects cdef bint call_python(LuaRuntime runtime, lua_State *L, py_object* py_obj) except -1: cdef int i, nargs = lua.lua_gettop(L) - 1 cdef tuple args if not py_obj: raise TypeError("not a python object") f = py_obj.obj if not nargs: lua.lua_settop(L, 0) # FIXME result = f() else: arg = py_from_lua(runtime, L, 2) if PyMethod_Check(f) and (arg) is PyMethod_GET_SELF(f): # Calling a bound method and self is already the first argument. # Lua x:m(a, b) => Python as x.m(x, a, b) but should be x.m(a, b) # # Lua syntax is sensitive to method calls vs function lookups, while # Python's syntax is not. In a way, we are leaking Python semantics # into Lua by duplicating the first argument from method calls. # # The method wrapper would only prepend self to the tuple again, # so we just call the underlying function directly instead. f = PyMethod_GET_FUNCTION(f) args = cpython.tuple.PyTuple_New(nargs) cpython.ref.Py_INCREF(arg) cpython.tuple.PyTuple_SET_ITEM(args, 0, arg) for i in range(1, nargs): arg = py_from_lua(runtime, L, i+2) cpython.ref.Py_INCREF(arg) cpython.tuple.PyTuple_SET_ITEM(args, i, arg) lua.lua_settop(L, 0) # FIXME result = f(*args) return py_function_result_to_lua(runtime, L, result) cdef int py_call_with_gil(lua_State* L, py_object *py_obj) with gil: cdef LuaRuntime runtime = None cdef lua_State* stored_state = NULL try: runtime = py_obj.runtime if runtime._state is not L: stored_state = runtime._state runtime._state = L return call_python(runtime, L, py_obj) except: runtime.store_raised_exception(L, b'error during Python call') return -1 finally: if stored_state is not NULL: runtime._state = stored_state cdef int py_object_call(lua_State* L) nogil: cdef py_object* py_obj = unwrap_lua_object(L, 1) # may not return on error! if not py_obj: return lua.luaL_argerror(L, 1, "not a python object") # never returns! result = py_call_with_gil(L, py_obj) if result < 0: return lua.lua_error(L) # never returns! return result # str() support for Python objects cdef int py_str_with_gil(lua_State* L, py_object* py_obj) with gil: cdef LuaRuntime runtime try: runtime = py_obj.runtime s = str(py_obj.obj) if isinstance(s, unicode): if runtime._encoding is None: s = (s).encode('UTF-8') else: s = (s).encode(runtime._encoding) else: assert isinstance(s, bytes) lua.lua_pushlstring(L, s, len(s)) return 1 # returning 1 value except: try: runtime.store_raised_exception(L, b'error during Python str() call') finally: return -1 cdef int py_object_str(lua_State* L) nogil: 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: return lua.lua_error(L) # never returns! return result # item access for Python objects # # Behavior is: # # If setting attribute_handlers flag has been set in LuaRuntime object # use those handlers. # # Else if wrapped by python.as_attrgetter() or python.as_itemgetter() # from the Lua side, user getitem or getattr respsectively. # # Else If object has __getitem__, use that # # Else use getattr() # # Note that when getattr() is used, attribute_filter from LuaRuntime # may mediate access. attribute_filter does not come into play when # using the getitem method of access. cdef int getitem_for_lua(LuaRuntime runtime, lua_State* L, py_object* py_obj, int key_n) except -1: return py_to_lua(runtime, L, (py_obj.obj)[ py_from_lua(runtime, L, key_n) ]) cdef int setitem_for_lua(LuaRuntime runtime, lua_State* L, py_object* py_obj, int key_n, int value_n) except -1: (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: obj = py_obj.obj attr_name = py_from_lua(runtime, L, key_n) if runtime._attribute_getter is not None: value = runtime._attribute_getter(obj, attr_name) return py_to_lua(runtime, L, value) if runtime._attribute_filter is not None: attr_name = runtime._attribute_filter(obj, attr_name, False) if isinstance(attr_name, bytes): attr_name = (attr_name).decode(runtime._source_encoding) return py_to_lua(runtime, L, getattr(obj, attr_name)) cdef int setattr_for_lua(LuaRuntime runtime, lua_State* L, py_object* py_obj, int key_n, int value_n) except -1: obj = py_obj.obj attr_name = py_from_lua(runtime, L, key_n) attr_value = py_from_lua(runtime, L, value_n) if runtime._attribute_setter is not None: runtime._attribute_setter(obj, attr_name, attr_value) else: if runtime._attribute_filter is not None: attr_name = runtime._attribute_filter(obj, attr_name, True) if isinstance(attr_name, bytes): attr_name = (attr_name).decode(runtime._source_encoding) setattr(obj, attr_name, attr_value) return 0 cdef int py_object_getindex_with_gil(lua_State* L, py_object* py_obj) with gil: cdef LuaRuntime runtime try: runtime = py_obj.runtime if (py_obj.type_flags & OBJ_AS_INDEX) and not runtime._attribute_getter: return getitem_for_lua(runtime, L, py_obj, 2) else: return getattr_for_lua(runtime, L, py_obj, 2) except: runtime.store_raised_exception(L, b'error reading Python attribute/item') 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: return lua.luaL_argerror(L, 1, "not a python object") # never returns! result = py_object_getindex_with_gil(L, py_obj) if result < 0: return lua.lua_error(L) # never returns! return result cdef int py_object_setindex_with_gil(lua_State* L, py_object* py_obj) with gil: cdef LuaRuntime runtime try: runtime = py_obj.runtime if (py_obj.type_flags & OBJ_AS_INDEX) and not runtime._attribute_setter: return setitem_for_lua(runtime, L, py_obj, 2, 3) else: return setattr_for_lua(runtime, L, py_obj, 2, 3) except: runtime.store_raised_exception(L, b'error writing Python attribute/item') 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: return lua.luaL_argerror(L, 1, "not a python object") # never returns! result = py_object_setindex_with_gil(L, py_obj) if result < 0: return lua.lua_error(L) # never returns! return result # special methods for Lua wrapped Python objects cdef lua.luaL_Reg *py_object_lib = [ lua.luaL_Reg(name = "__call", func = py_object_call), lua.luaL_Reg(name = "__index", func = py_object_getindex), lua.luaL_Reg(name = "__newindex", func = py_object_setindex), lua.luaL_Reg(name = "__tostring", func = py_object_str), lua.luaL_Reg(name = "__gc", func = py_object_gc), lua.luaL_Reg(name = NULL, func = NULL), ] ## # 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! 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 cdef py_object* unwrap_lua_object(lua_State* L, int n) nogil: if lua.lua_isuserdata(L, n): return unpack_userdata(L, n) else: return unpack_wrapped_pyfunction(L, n) 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 = py_obj.runtime return py_to_lua_custom(runtime, L, py_obj.obj, type_flags) except: try: runtime.store_raised_exception(L, b'error during type adaptation') finally: return -1 cdef int py_wrap_object_protocol(lua_State* L, int type_flags) nogil: cdef py_object* py_obj = unpack_single_python_argument_or_jump(L) # never returns on error! result = py_wrap_object_protocol_with_gil(L, py_obj, type_flags) if result < 0: return lua.lua_error(L) # never returns! return result 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: 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, py_asfunc_call, 1) return 1 # 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) if result < 0: return lua.lua_error(L) # never returns! 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) if result < 0: return lua.lua_error(L) # never returns! 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! 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) if result < 0: return lua.lua_error(L) # never returns! return result cdef int py_enumerate_with_gil(lua_State* L, py_object* py_obj, double start) with gil: cdef LuaRuntime runtime try: runtime = py_obj.runtime obj = iter(py_obj.obj) return py_push_iterator(runtime, L, obj, OBJ_ENUMERATOR, start - 1.0) except: try: runtime.store_raised_exception(L, b'error creating an iterator with enumerate()') finally: return -1 cdef int py_iter_with_gil(lua_State* L, py_object* py_obj, int type_flags) with gil: cdef LuaRuntime runtime try: runtime = py_obj.runtime obj = iter(py_obj.obj) return py_push_iterator(runtime, L, obj, type_flags, 0.0) except: try: runtime.store_raised_exception(L, b'error creating an iterator') finally: return -1 cdef int py_push_iterator(LuaRuntime runtime, lua_State* L, iterator, int type_flags, lua.lua_Number initial_value): # Lua needs three values: iterator C function + state + control variable (last iter) value old_top = lua.lua_gettop(L) lua.lua_pushcfunction(L, py_iter_next) # push the wrapped iterator object as for-loop state object if runtime._unpack_returned_tuples: type_flags |= OBJ_UNPACK_TUPLE if py_to_lua_custom(runtime, L, iterator, type_flags) < 1: lua.lua_settop(L, old_top) return -1 # push either enumerator index or nil as control variable value if type_flags & OBJ_ENUMERATOR: lua.lua_pushnumber(L, initial_value) else: lua.lua_pushnil(L) return 3 cdef int py_iter_next(lua_State* L) nogil: # first value in the C closure: the Python iterator object cdef py_object* py_obj = unwrap_lua_object(L, 1) if not py_obj: return lua.luaL_argerror(L, 1, "not a python object") # never returns! result = py_iter_next_with_gil(L, py_obj) if result < 0: return lua.lua_error(L) # never returns! return result cdef int py_iter_next_with_gil(lua_State* L, py_object* py_iter) with gil: cdef LuaRuntime runtime try: runtime = py_iter.runtime try: obj = next(py_iter.obj) except StopIteration: lua.lua_pushnil(L) return 1 # NOTE: cannot return nil for None as first item # as Lua interprets it as end of the iterator allow_nil = False if py_iter.type_flags & OBJ_ENUMERATOR: lua.lua_pushnumber(L, lua.lua_tonumber(L, -1) + 1.0) allow_nil = True if (py_iter.type_flags & OBJ_UNPACK_TUPLE) and isinstance(obj, tuple): # special case: when the iterable returns a tuple, unpack it push_lua_arguments(runtime, L, obj, first_may_be_nil=allow_nil) result = len(obj) else: result = py_to_lua(runtime, L, obj, wrap_none=not allow_nil) if result < 1: return -1 if py_iter.type_flags & OBJ_ENUMERATOR: result += 1 return result except: try: runtime.store_raised_exception(L, b'error while calling next(iterator)') finally: return -1 # 'python' module functions in Lua cdef lua.luaL_Reg *py_lib = [ lua.luaL_Reg(name = "as_attrgetter", func = py_as_attrgetter), lua.luaL_Reg(name = "as_itemgetter", func = py_as_itemgetter), lua.luaL_Reg(name = "as_function", func = py_as_function), lua.luaL_Reg(name = "iter", func = py_iter), lua.luaL_Reg(name = "iterex", func = py_iterex), lua.luaL_Reg(name = "enumerate", func = py_enumerate), lua.luaL_Reg(name = NULL, func = NULL), ] # Setup helpers for library tables (removed from C-API in Lua 5.3). cdef void luaL_setfuncs(lua_State *L, const lua.luaL_Reg *l, int nup): cdef int i lua.luaL_checkstack(L, nup, "too many upvalues") while l.name != NULL: for i in range(nup): lua.lua_pushvalue(L, -nup) lua.lua_pushcclosure(L, l.func, nup) lua.lua_setfield(L, -(nup + 2), l.name) l += 1 lua.lua_pop(L, nup) cdef int libsize(const lua.luaL_Reg *l): cdef int size = 0 while l and l.name: l += 1 size += 1 return size cdef const char *luaL_findtable(lua_State *L, int idx, const char *fname, int size_hint): cdef const char *end if idx: lua.lua_pushvalue(L, idx) while True: end = strchr(fname, '.') if end == NULL: end = fname + strlen(fname) lua.lua_pushlstring(L, fname, end - fname) lua.lua_rawget(L, -2) if lua.lua_type(L, -1) == lua.LUA_TNIL: lua.lua_pop(L, 1) lua.lua_createtable(L, 0, (1 if end[0] == '.' else size_hint)) lua.lua_pushlstring(L, fname, end - fname) lua.lua_pushvalue(L, -2) lua.lua_settable(L, -4) elif not lua.lua_istable(L, -1): lua.lua_pop(L, 2) return fname lua.lua_remove(L, -2) fname = end + 1 if end[0] != '.': break return NULL cdef void luaL_pushmodule(lua_State *L, const char *modname, int size_hint): # XXX: "_LOADED" is the value of LUA_LOADED_TABLE, # but it's absent in lua51 luaL_findtable(L, lua.LUA_REGISTRYINDEX, "_LOADED", 1) lua.lua_getfield(L, -1, modname) if lua.lua_type(L, -1) != lua.LUA_TTABLE: lua.lua_pop(L, 1) lua.lua_getglobal(L, '_G') if luaL_findtable(L, 0, modname, size_hint) != NULL: lua.luaL_error(L, "name conflict for module '%s'", modname) lua.lua_pushvalue(L, -1) lua.lua_setfield(L, -3, modname) lua.lua_remove(L, -2) cdef void luaL_openlib(lua_State *L, const char *libname, const lua.luaL_Reg *l, int nup): if libname: luaL_pushmodule(L, libname, libsize(l)) lua.lua_insert(L, -(nup + 1)) if l: luaL_setfuncs(L, l, nup) else: lua.lua_pop(L, nup) lupa-1.6/lupa/version.py0000644000175000017500000000002413215037347016104 0ustar stefanstefan00000000000000__version__ = '1.6' lupa-1.6/lupa/lock.pxi0000644000175000017500000001036611423633236015527 0ustar stefanstefan00000000000000 from cpython cimport pythread from cpython.exc cimport PyErr_NoMemory cdef class FastRLock: """Fast, re-entrant locking. Under uncongested conditions, the lock is never acquired but only counted. Only when a second thread comes in and notices that the lock is needed, it acquires the lock and notifies the first thread to release it when it's done. This is all made possible by the wonderful GIL. """ cdef pythread.PyThread_type_lock _real_lock cdef long _owner # ID of thread owning the lock cdef int _count # re-entry count cdef int _pending_requests # number of pending requests for real lock cdef bint _is_locked # whether the real lock is acquired def __cinit__(self): self._owner = -1 self._count = 0 self._is_locked = False self._pending_requests = 0 self._real_lock = pythread.PyThread_allocate_lock() if self._real_lock is NULL: PyErr_NoMemory() def __dealloc__(self): if self._real_lock is not NULL: pythread.PyThread_free_lock(self._real_lock) self._real_lock = NULL def acquire(self, bint blocking=True): 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") unlock_lock(self) # compatibility with RLock def __enter__(self): # self.acquire() 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(): raise RuntimeError("cannot release un-acquired lock") unlock_lock(self) def _is_owned(self): return self._owner == pythread.PyThread_get_thread_ident() 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 # code execution slips in that might free the GIL if lock._count: # locked! - by myself? if current_thread == lock._owner: lock._count += 1 return 1 elif not lock._pending_requests: # not locked, not requested - go! lock._owner = current_thread lock._count = 1 return 1 # need to get the real lock 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: # Note that this function *must* hold the GIL when being called. # We just use 'nogil' in the signature to make sure that no Python # 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 # 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 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) lock._pending_requests -= 1 #assert not lock._is_locked #assert lock._count == 0 if not locked: return 0 lock._is_locked = True lock._owner = current_thread lock._count = 1 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 # code execution slips in that might free the GIL #assert lock._owner == pythread.PyThread_get_thread_ident() #assert lock._count > 0 lock._count -= 1 if lock._count == 0: lock._owner = -1 if lock._is_locked: pythread.PyThread_release_lock(lock._real_lock) lock._is_locked = False lupa-1.6/lupa/_lupa.c0000664000175000017500000523433113215036755015334 0ustar stefanstefan00000000000000/* Generated by Cython 0.27.3 */ /* BEGIN: Cython Metadata { "distutils": { "depends": [ "/usr/include/luajit-2.0/lauxlib.h", "/usr/include/luajit-2.0/lua.h", "/usr/include/luajit-2.0/lualib.h", "lupa/lupa_defs.h" ], "extra_objects": [ "-lluajit-5.1" ], "include_dirs": [ "./lupa", "/usr/include/luajit-2.0" ], "name": "lupa._lupa", "sources": [ "lupa/_lupa.pyx" ] }, "module_name": "lupa._lupa" } END: Cython Metadata */ #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. #elif PY_VERSION_HEX < 0x02060000 || (0x03000000 <= PY_VERSION_HEX && PY_VERSION_HEX < 0x03030000) #error Cython requires Python 2.6+ or Python 3.3+. #else #define CYTHON_ABI "0_27_3" #define CYTHON_FUTURE_DIVISION 0 #include #ifndef offsetof #define offsetof(type, member) ( (size_t) & ((type*)0) -> member ) #endif #if !defined(WIN32) && !defined(MS_WINDOWS) #ifndef __stdcall #define __stdcall #endif #ifndef __cdecl #define __cdecl #endif #ifndef __fastcall #define __fastcall #endif #endif #ifndef DL_IMPORT #define DL_IMPORT(t) t #endif #ifndef DL_EXPORT #define DL_EXPORT(t) t #endif #define __PYX_COMMA , #ifndef HAVE_LONG_LONG #if PY_VERSION_HEX >= 0x02070000 #define HAVE_LONG_LONG #endif #endif #ifndef PY_LONG_LONG #define PY_LONG_LONG LONG_LONG #endif #ifndef Py_HUGE_VAL #define Py_HUGE_VAL HUGE_VAL #endif #ifdef PYPY_VERSION #define CYTHON_COMPILING_IN_PYPY 1 #define CYTHON_COMPILING_IN_PYSTON 0 #define CYTHON_COMPILING_IN_CPYTHON 0 #undef CYTHON_USE_TYPE_SLOTS #define CYTHON_USE_TYPE_SLOTS 0 #undef CYTHON_USE_PYTYPE_LOOKUP #define CYTHON_USE_PYTYPE_LOOKUP 0 #if PY_VERSION_HEX < 0x03050000 #undef CYTHON_USE_ASYNC_SLOTS #define CYTHON_USE_ASYNC_SLOTS 0 #elif !defined(CYTHON_USE_ASYNC_SLOTS) #define CYTHON_USE_ASYNC_SLOTS 1 #endif #undef CYTHON_USE_PYLIST_INTERNALS #define CYTHON_USE_PYLIST_INTERNALS 0 #undef CYTHON_USE_UNICODE_INTERNALS #define CYTHON_USE_UNICODE_INTERNALS 0 #undef CYTHON_USE_UNICODE_WRITER #define CYTHON_USE_UNICODE_WRITER 0 #undef CYTHON_USE_PYLONG_INTERNALS #define CYTHON_USE_PYLONG_INTERNALS 0 #undef CYTHON_AVOID_BORROWED_REFS #define CYTHON_AVOID_BORROWED_REFS 1 #undef CYTHON_ASSUME_SAFE_MACROS #define CYTHON_ASSUME_SAFE_MACROS 0 #undef CYTHON_UNPACK_METHODS #define CYTHON_UNPACK_METHODS 0 #undef CYTHON_FAST_THREAD_STATE #define CYTHON_FAST_THREAD_STATE 0 #undef CYTHON_FAST_PYCALL #define CYTHON_FAST_PYCALL 0 #undef CYTHON_PEP489_MULTI_PHASE_INIT #define CYTHON_PEP489_MULTI_PHASE_INIT 0 #undef CYTHON_USE_TP_FINALIZE #define CYTHON_USE_TP_FINALIZE 0 #elif defined(PYSTON_VERSION) #define CYTHON_COMPILING_IN_PYPY 0 #define CYTHON_COMPILING_IN_PYSTON 1 #define CYTHON_COMPILING_IN_CPYTHON 0 #ifndef CYTHON_USE_TYPE_SLOTS #define CYTHON_USE_TYPE_SLOTS 1 #endif #undef CYTHON_USE_PYTYPE_LOOKUP #define CYTHON_USE_PYTYPE_LOOKUP 0 #undef CYTHON_USE_ASYNC_SLOTS #define CYTHON_USE_ASYNC_SLOTS 0 #undef CYTHON_USE_PYLIST_INTERNALS #define CYTHON_USE_PYLIST_INTERNALS 0 #ifndef CYTHON_USE_UNICODE_INTERNALS #define CYTHON_USE_UNICODE_INTERNALS 1 #endif #undef CYTHON_USE_UNICODE_WRITER #define CYTHON_USE_UNICODE_WRITER 0 #undef CYTHON_USE_PYLONG_INTERNALS #define CYTHON_USE_PYLONG_INTERNALS 0 #ifndef CYTHON_AVOID_BORROWED_REFS #define CYTHON_AVOID_BORROWED_REFS 0 #endif #ifndef CYTHON_ASSUME_SAFE_MACROS #define CYTHON_ASSUME_SAFE_MACROS 1 #endif #ifndef CYTHON_UNPACK_METHODS #define CYTHON_UNPACK_METHODS 1 #endif #undef CYTHON_FAST_THREAD_STATE #define CYTHON_FAST_THREAD_STATE 0 #undef CYTHON_FAST_PYCALL #define CYTHON_FAST_PYCALL 0 #undef CYTHON_PEP489_MULTI_PHASE_INIT #define CYTHON_PEP489_MULTI_PHASE_INIT 0 #undef CYTHON_USE_TP_FINALIZE #define CYTHON_USE_TP_FINALIZE 0 #else #define CYTHON_COMPILING_IN_PYPY 0 #define CYTHON_COMPILING_IN_PYSTON 0 #define CYTHON_COMPILING_IN_CPYTHON 1 #ifndef CYTHON_USE_TYPE_SLOTS #define CYTHON_USE_TYPE_SLOTS 1 #endif #if PY_VERSION_HEX < 0x02070000 #undef CYTHON_USE_PYTYPE_LOOKUP #define CYTHON_USE_PYTYPE_LOOKUP 0 #elif !defined(CYTHON_USE_PYTYPE_LOOKUP) #define CYTHON_USE_PYTYPE_LOOKUP 1 #endif #if PY_MAJOR_VERSION < 3 #undef CYTHON_USE_ASYNC_SLOTS #define CYTHON_USE_ASYNC_SLOTS 0 #elif !defined(CYTHON_USE_ASYNC_SLOTS) #define CYTHON_USE_ASYNC_SLOTS 1 #endif #if PY_VERSION_HEX < 0x02070000 #undef CYTHON_USE_PYLONG_INTERNALS #define CYTHON_USE_PYLONG_INTERNALS 0 #elif !defined(CYTHON_USE_PYLONG_INTERNALS) #define CYTHON_USE_PYLONG_INTERNALS 1 #endif #ifndef CYTHON_USE_PYLIST_INTERNALS #define CYTHON_USE_PYLIST_INTERNALS 1 #endif #ifndef CYTHON_USE_UNICODE_INTERNALS #define CYTHON_USE_UNICODE_INTERNALS 1 #endif #if PY_VERSION_HEX < 0x030300F0 #undef CYTHON_USE_UNICODE_WRITER #define CYTHON_USE_UNICODE_WRITER 0 #elif !defined(CYTHON_USE_UNICODE_WRITER) #define CYTHON_USE_UNICODE_WRITER 1 #endif #ifndef CYTHON_AVOID_BORROWED_REFS #define CYTHON_AVOID_BORROWED_REFS 0 #endif #ifndef CYTHON_ASSUME_SAFE_MACROS #define CYTHON_ASSUME_SAFE_MACROS 1 #endif #ifndef CYTHON_UNPACK_METHODS #define CYTHON_UNPACK_METHODS 1 #endif #ifndef CYTHON_FAST_THREAD_STATE #define CYTHON_FAST_THREAD_STATE 1 #endif #ifndef CYTHON_FAST_PYCALL #define CYTHON_FAST_PYCALL 1 #endif #ifndef CYTHON_PEP489_MULTI_PHASE_INIT #define CYTHON_PEP489_MULTI_PHASE_INIT (0 && PY_VERSION_HEX >= 0x03050000) #endif #ifndef CYTHON_USE_TP_FINALIZE #define CYTHON_USE_TP_FINALIZE (PY_VERSION_HEX >= 0x030400a1) #endif #endif #if !defined(CYTHON_FAST_PYCCALL) #define CYTHON_FAST_PYCCALL (CYTHON_FAST_PYCALL && PY_VERSION_HEX >= 0x030600B1) #endif #if CYTHON_USE_PYLONG_INTERNALS #include "longintrepr.h" #undef SHIFT #undef BASE #undef MASK #endif #if CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX < 0x02070600 && !defined(Py_OptimizeFlag) #define Py_OptimizeFlag 0 #endif #define __PYX_BUILD_PY_SSIZE_T "n" #define CYTHON_FORMAT_SSIZE_T "z" #if PY_MAJOR_VERSION < 3 #define __Pyx_BUILTIN_MODULE_NAME "__builtin__" #define __Pyx_PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)\ PyCode_New(a+k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos) #define __Pyx_DefaultClassType PyClass_Type #else #define __Pyx_BUILTIN_MODULE_NAME "builtins" #define __Pyx_PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)\ PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos) #define __Pyx_DefaultClassType PyType_Type #endif #ifndef Py_TPFLAGS_CHECKTYPES #define Py_TPFLAGS_CHECKTYPES 0 #endif #ifndef Py_TPFLAGS_HAVE_INDEX #define Py_TPFLAGS_HAVE_INDEX 0 #endif #ifndef Py_TPFLAGS_HAVE_NEWBUFFER #define Py_TPFLAGS_HAVE_NEWBUFFER 0 #endif #ifndef Py_TPFLAGS_HAVE_FINALIZE #define Py_TPFLAGS_HAVE_FINALIZE 0 #endif #if PY_VERSION_HEX < 0x030700A0 || !defined(METH_FASTCALL) #ifndef METH_FASTCALL #define METH_FASTCALL 0x80 #endif typedef PyObject *(*__Pyx_PyCFunctionFast) (PyObject *self, PyObject **args, Py_ssize_t nargs); typedef PyObject *(*__Pyx_PyCFunctionFastWithKeywords) (PyObject *self, PyObject **args, Py_ssize_t nargs, PyObject *kwnames); #else #define __Pyx_PyCFunctionFast _PyCFunctionFast #define __Pyx_PyCFunctionFastWithKeywords _PyCFunctionFastWithKeywords #endif #if CYTHON_FAST_PYCCALL #define __Pyx_PyFastCFunction_Check(func)\ ((PyCFunction_Check(func) && (METH_FASTCALL == (PyCFunction_GET_FLAGS(func) & ~(METH_CLASS | METH_STATIC | METH_COEXIST | METH_KEYWORDS))))) #else #define __Pyx_PyFastCFunction_Check(func) 0 #endif #if !CYTHON_FAST_THREAD_STATE || PY_VERSION_HEX < 0x02070000 #define __Pyx_PyThreadState_Current PyThreadState_GET() #elif PY_VERSION_HEX >= 0x03060000 #define __Pyx_PyThreadState_Current _PyThreadState_UncheckedGet() #elif PY_VERSION_HEX >= 0x03000000 #define __Pyx_PyThreadState_Current PyThreadState_GET() #else #define __Pyx_PyThreadState_Current _PyThreadState_Current #endif #if CYTHON_COMPILING_IN_CPYTHON || defined(_PyDict_NewPresized) #define __Pyx_PyDict_NewPresized(n) ((n <= 8) ? PyDict_New() : _PyDict_NewPresized(n)) #else #define __Pyx_PyDict_NewPresized(n) PyDict_New() #endif #if PY_MAJOR_VERSION >= 3 || CYTHON_FUTURE_DIVISION #define __Pyx_PyNumber_Divide(x,y) PyNumber_TrueDivide(x,y) #define __Pyx_PyNumber_InPlaceDivide(x,y) PyNumber_InPlaceTrueDivide(x,y) #else #define __Pyx_PyNumber_Divide(x,y) PyNumber_Divide(x,y) #define __Pyx_PyNumber_InPlaceDivide(x,y) PyNumber_InPlaceDivide(x,y) #endif #if PY_VERSION_HEX > 0x03030000 && defined(PyUnicode_KIND) #define CYTHON_PEP393_ENABLED 1 #define __Pyx_PyUnicode_READY(op) (likely(PyUnicode_IS_READY(op)) ?\ 0 : _PyUnicode_Ready((PyObject *)(op))) #define __Pyx_PyUnicode_GET_LENGTH(u) PyUnicode_GET_LENGTH(u) #define __Pyx_PyUnicode_READ_CHAR(u, i) PyUnicode_READ_CHAR(u, i) #define __Pyx_PyUnicode_MAX_CHAR_VALUE(u) PyUnicode_MAX_CHAR_VALUE(u) #define __Pyx_PyUnicode_KIND(u) PyUnicode_KIND(u) #define __Pyx_PyUnicode_DATA(u) PyUnicode_DATA(u) #define __Pyx_PyUnicode_READ(k, d, i) PyUnicode_READ(k, d, i) #define __Pyx_PyUnicode_WRITE(k, d, i, ch) PyUnicode_WRITE(k, d, i, ch) #define __Pyx_PyUnicode_IS_TRUE(u) (0 != (likely(PyUnicode_IS_READY(u)) ? PyUnicode_GET_LENGTH(u) : PyUnicode_GET_SIZE(u))) #else #define CYTHON_PEP393_ENABLED 0 #define PyUnicode_1BYTE_KIND 1 #define PyUnicode_2BYTE_KIND 2 #define PyUnicode_4BYTE_KIND 4 #define __Pyx_PyUnicode_READY(op) (0) #define __Pyx_PyUnicode_GET_LENGTH(u) PyUnicode_GET_SIZE(u) #define __Pyx_PyUnicode_READ_CHAR(u, i) ((Py_UCS4)(PyUnicode_AS_UNICODE(u)[i])) #define __Pyx_PyUnicode_MAX_CHAR_VALUE(u) ((sizeof(Py_UNICODE) == 2) ? 65535 : 1114111) #define __Pyx_PyUnicode_KIND(u) (sizeof(Py_UNICODE)) #define __Pyx_PyUnicode_DATA(u) ((void*)PyUnicode_AS_UNICODE(u)) #define __Pyx_PyUnicode_READ(k, d, i) ((void)(k), (Py_UCS4)(((Py_UNICODE*)d)[i])) #define __Pyx_PyUnicode_WRITE(k, d, i, ch) (((void)(k)), ((Py_UNICODE*)d)[i] = ch) #define __Pyx_PyUnicode_IS_TRUE(u) (0 != PyUnicode_GET_SIZE(u)) #endif #if CYTHON_COMPILING_IN_PYPY #define __Pyx_PyUnicode_Concat(a, b) PyNumber_Add(a, b) #define __Pyx_PyUnicode_ConcatSafe(a, b) PyNumber_Add(a, b) #else #define __Pyx_PyUnicode_Concat(a, b) PyUnicode_Concat(a, b) #define __Pyx_PyUnicode_ConcatSafe(a, b) ((unlikely((a) == Py_None) || unlikely((b) == Py_None)) ?\ PyNumber_Add(a, b) : __Pyx_PyUnicode_Concat(a, b)) #endif #if CYTHON_COMPILING_IN_PYPY && !defined(PyUnicode_Contains) #define PyUnicode_Contains(u, s) PySequence_Contains(u, s) #endif #if CYTHON_COMPILING_IN_PYPY && !defined(PyByteArray_Check) #define PyByteArray_Check(obj) PyObject_TypeCheck(obj, &PyByteArray_Type) #endif #if CYTHON_COMPILING_IN_PYPY && !defined(PyObject_Format) #define PyObject_Format(obj, fmt) PyObject_CallMethod(obj, "__format__", "O", fmt) #endif #if CYTHON_COMPILING_IN_PYPY && !defined(PyObject_Malloc) #define PyObject_Malloc(s) PyMem_Malloc(s) #define PyObject_Free(p) PyMem_Free(p) #define PyObject_Realloc(p) PyMem_Realloc(p) #endif #if CYTHON_COMPILING_IN_PYSTON #define __Pyx_PyCode_HasFreeVars(co) PyCode_HasFreeVars(co) #define __Pyx_PyFrame_SetLineNumber(frame, lineno) PyFrame_SetLineNumber(frame, lineno) #else #define __Pyx_PyCode_HasFreeVars(co) (PyCode_GetNumFree(co) > 0) #define __Pyx_PyFrame_SetLineNumber(frame, lineno) (frame)->f_lineno = (lineno) #endif #define __Pyx_PyString_FormatSafe(a, b) ((unlikely((a) == Py_None)) ? PyNumber_Remainder(a, b) : __Pyx_PyString_Format(a, b)) #define __Pyx_PyUnicode_FormatSafe(a, b) ((unlikely((a) == Py_None)) ? PyNumber_Remainder(a, b) : PyUnicode_Format(a, b)) #if PY_MAJOR_VERSION >= 3 #define __Pyx_PyString_Format(a, b) PyUnicode_Format(a, b) #else #define __Pyx_PyString_Format(a, b) PyString_Format(a, b) #endif #if PY_MAJOR_VERSION < 3 && !defined(PyObject_ASCII) #define PyObject_ASCII(o) PyObject_Repr(o) #endif #if PY_MAJOR_VERSION >= 3 #define PyBaseString_Type PyUnicode_Type #define PyStringObject PyUnicodeObject #define PyString_Type PyUnicode_Type #define PyString_Check PyUnicode_Check #define PyString_CheckExact PyUnicode_CheckExact #endif #if PY_MAJOR_VERSION >= 3 #define __Pyx_PyBaseString_Check(obj) PyUnicode_Check(obj) #define __Pyx_PyBaseString_CheckExact(obj) PyUnicode_CheckExact(obj) #else #define __Pyx_PyBaseString_Check(obj) (PyString_Check(obj) || PyUnicode_Check(obj)) #define __Pyx_PyBaseString_CheckExact(obj) (PyString_CheckExact(obj) || PyUnicode_CheckExact(obj)) #endif #ifndef PySet_CheckExact #define PySet_CheckExact(obj) (Py_TYPE(obj) == &PySet_Type) #endif #define __Pyx_PyException_Check(obj) __Pyx_TypeCheck(obj, PyExc_Exception) #if PY_MAJOR_VERSION >= 3 #define PyIntObject PyLongObject #define PyInt_Type PyLong_Type #define PyInt_Check(op) PyLong_Check(op) #define PyInt_CheckExact(op) PyLong_CheckExact(op) #define PyInt_FromString PyLong_FromString #define PyInt_FromUnicode PyLong_FromUnicode #define PyInt_FromLong PyLong_FromLong #define PyInt_FromSize_t PyLong_FromSize_t #define PyInt_FromSsize_t PyLong_FromSsize_t #define PyInt_AsLong PyLong_AsLong #define PyInt_AS_LONG PyLong_AS_LONG #define PyInt_AsSsize_t PyLong_AsSsize_t #define PyInt_AsUnsignedLongMask PyLong_AsUnsignedLongMask #define PyInt_AsUnsignedLongLongMask PyLong_AsUnsignedLongLongMask #define PyNumber_Int PyNumber_Long #endif #if PY_MAJOR_VERSION >= 3 #define PyBoolObject PyLongObject #endif #if PY_MAJOR_VERSION >= 3 && CYTHON_COMPILING_IN_PYPY #ifndef PyUnicode_InternFromString #define PyUnicode_InternFromString(s) PyUnicode_FromString(s) #endif #endif #if PY_VERSION_HEX < 0x030200A4 typedef long Py_hash_t; #define __Pyx_PyInt_FromHash_t PyInt_FromLong #define __Pyx_PyInt_AsHash_t PyInt_AsLong #else #define __Pyx_PyInt_FromHash_t PyInt_FromSsize_t #define __Pyx_PyInt_AsHash_t PyInt_AsSsize_t #endif #if PY_MAJOR_VERSION >= 3 #define __Pyx_PyMethod_New(func, self, klass) ((self) ? PyMethod_New(func, self) : PyInstanceMethod_New(func)) #else #define __Pyx_PyMethod_New(func, self, klass) PyMethod_New(func, self, klass) #endif #ifndef __has_attribute #define __has_attribute(x) 0 #endif #ifndef __has_cpp_attribute #define __has_cpp_attribute(x) 0 #endif #if CYTHON_USE_ASYNC_SLOTS #if PY_VERSION_HEX >= 0x030500B1 #define __Pyx_PyAsyncMethodsStruct PyAsyncMethods #define __Pyx_PyType_AsAsync(obj) (Py_TYPE(obj)->tp_as_async) #else #define __Pyx_PyType_AsAsync(obj) ((__Pyx_PyAsyncMethodsStruct*) (Py_TYPE(obj)->tp_reserved)) #endif #else #define __Pyx_PyType_AsAsync(obj) NULL #endif #ifndef __Pyx_PyAsyncMethodsStruct typedef struct { unaryfunc am_await; unaryfunc am_aiter; unaryfunc am_anext; } __Pyx_PyAsyncMethodsStruct; #endif #ifndef CYTHON_RESTRICT #if defined(__GNUC__) #define CYTHON_RESTRICT __restrict__ #elif defined(_MSC_VER) && _MSC_VER >= 1400 #define CYTHON_RESTRICT __restrict #elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L #define CYTHON_RESTRICT restrict #else #define CYTHON_RESTRICT #endif #endif #ifndef CYTHON_UNUSED # if defined(__GNUC__) # if !(defined(__cplusplus)) || (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4)) # define CYTHON_UNUSED __attribute__ ((__unused__)) # else # define CYTHON_UNUSED # endif # elif defined(__ICC) || (defined(__INTEL_COMPILER) && !defined(_MSC_VER)) # define CYTHON_UNUSED __attribute__ ((__unused__)) # else # define CYTHON_UNUSED # endif #endif #ifndef CYTHON_MAYBE_UNUSED_VAR # if defined(__cplusplus) template void CYTHON_MAYBE_UNUSED_VAR( const T& ) { } # else # define CYTHON_MAYBE_UNUSED_VAR(x) (void)(x) # endif #endif #ifndef CYTHON_NCP_UNUSED # if CYTHON_COMPILING_IN_CPYTHON # define CYTHON_NCP_UNUSED # else # define CYTHON_NCP_UNUSED CYTHON_UNUSED # endif #endif #define __Pyx_void_to_None(void_result) ((void)(void_result), Py_INCREF(Py_None), Py_None) #ifdef _MSC_VER #ifndef _MSC_STDINT_H_ #if _MSC_VER < 1300 typedef unsigned char uint8_t; typedef unsigned int uint32_t; #else typedef unsigned __int8 uint8_t; typedef unsigned __int32 uint32_t; #endif #endif #else #include #endif #ifndef CYTHON_FALLTHROUGH #if defined(__cplusplus) && __cplusplus >= 201103L #if __has_cpp_attribute(fallthrough) #define CYTHON_FALLTHROUGH [[fallthrough]] #elif __has_cpp_attribute(clang::fallthrough) #define CYTHON_FALLTHROUGH [[clang::fallthrough]] #elif __has_cpp_attribute(gnu::fallthrough) #define CYTHON_FALLTHROUGH [[gnu::fallthrough]] #endif #endif #ifndef CYTHON_FALLTHROUGH #if __has_attribute(fallthrough) #define CYTHON_FALLTHROUGH __attribute__((fallthrough)) #else #define CYTHON_FALLTHROUGH #endif #endif #if defined(__clang__ ) && defined(__apple_build_version__) #if __apple_build_version__ < 7000000 #undef CYTHON_FALLTHROUGH #define CYTHON_FALLTHROUGH #endif #endif #endif #ifndef CYTHON_INLINE #if defined(__clang__) #define CYTHON_INLINE __inline__ __attribute__ ((__unused__)) #elif defined(__GNUC__) #define CYTHON_INLINE __inline__ #elif defined(_MSC_VER) #define CYTHON_INLINE __inline #elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L #define CYTHON_INLINE inline #else #define CYTHON_INLINE #endif #endif #if defined(WIN32) || defined(MS_WINDOWS) #define _USE_MATH_DEFINES #endif #include #ifdef NAN #define __PYX_NAN() ((float) NAN) #else static CYTHON_INLINE float __PYX_NAN() { float value; memset(&value, 0xFF, sizeof(value)); return value; } #endif #if defined(__CYGWIN__) && defined(_LDBL_EQ_DBL) #define __Pyx_truncl trunc #else #define __Pyx_truncl truncl #endif #define __PYX_ERR(f_index, lineno, Ln_error) \ { \ __pyx_filename = __pyx_f[f_index]; __pyx_lineno = lineno; __pyx_clineno = __LINE__; goto Ln_error; \ } #ifndef __PYX_EXTERN_C #ifdef __cplusplus #define __PYX_EXTERN_C extern "C" #else #define __PYX_EXTERN_C extern #endif #endif #define __PYX_HAVE__lupa___lupa #define __PYX_HAVE_API__lupa___lupa #include #include "lua.h" #include "lauxlib.h" #include "lualib.h" #include "lupa_defs.h" #include #include #include "pythread.h" #ifdef _OPENMP #include #endif /* _OPENMP */ #if defined(PYREX_WITHOUT_ASSERTIONS) && !defined(CYTHON_WITHOUT_ASSERTIONS) #define CYTHON_WITHOUT_ASSERTIONS #endif typedef struct {PyObject **p; const char *s; const Py_ssize_t n; const char* encoding; const char is_unicode; const char is_str; const char intern; } __Pyx_StringTabEntry; #define __PYX_DEFAULT_STRING_ENCODING_IS_ASCII 0 #define __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT 0 #define __PYX_DEFAULT_STRING_ENCODING "" #define __Pyx_PyObject_FromString __Pyx_PyBytes_FromString #define __Pyx_PyObject_FromStringAndSize __Pyx_PyBytes_FromStringAndSize #define __Pyx_uchar_cast(c) ((unsigned char)c) #define __Pyx_long_cast(x) ((long)x) #define __Pyx_fits_Py_ssize_t(v, type, is_signed) (\ (sizeof(type) < sizeof(Py_ssize_t)) ||\ (sizeof(type) > sizeof(Py_ssize_t) &&\ likely(v < (type)PY_SSIZE_T_MAX ||\ v == (type)PY_SSIZE_T_MAX) &&\ (!is_signed || likely(v > (type)PY_SSIZE_T_MIN ||\ v == (type)PY_SSIZE_T_MIN))) ||\ (sizeof(type) == sizeof(Py_ssize_t) &&\ (is_signed || likely(v < (type)PY_SSIZE_T_MAX ||\ v == (type)PY_SSIZE_T_MAX))) ) #if defined (__cplusplus) && __cplusplus >= 201103L #include #define __Pyx_sst_abs(value) std::abs(value) #elif SIZEOF_INT >= SIZEOF_SIZE_T #define __Pyx_sst_abs(value) abs(value) #elif SIZEOF_LONG >= SIZEOF_SIZE_T #define __Pyx_sst_abs(value) labs(value) #elif defined (_MSC_VER) #define __Pyx_sst_abs(value) ((Py_ssize_t)_abs64(value)) #elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L #define __Pyx_sst_abs(value) llabs(value) #elif defined (__GNUC__) #define __Pyx_sst_abs(value) __builtin_llabs(value) #else #define __Pyx_sst_abs(value) ((value<0) ? -value : value) #endif static CYTHON_INLINE const char* __Pyx_PyObject_AsString(PyObject*); static CYTHON_INLINE const char* __Pyx_PyObject_AsStringAndSize(PyObject*, Py_ssize_t* length); #define __Pyx_PyByteArray_FromString(s) PyByteArray_FromStringAndSize((const char*)s, strlen((const char*)s)) #define __Pyx_PyByteArray_FromStringAndSize(s, l) PyByteArray_FromStringAndSize((const char*)s, l) #define __Pyx_PyBytes_FromString PyBytes_FromString #define __Pyx_PyBytes_FromStringAndSize PyBytes_FromStringAndSize static CYTHON_INLINE PyObject* __Pyx_PyUnicode_FromString(const char*); #if PY_MAJOR_VERSION < 3 #define __Pyx_PyStr_FromString __Pyx_PyBytes_FromString #define __Pyx_PyStr_FromStringAndSize __Pyx_PyBytes_FromStringAndSize #else #define __Pyx_PyStr_FromString __Pyx_PyUnicode_FromString #define __Pyx_PyStr_FromStringAndSize __Pyx_PyUnicode_FromStringAndSize #endif #define __Pyx_PyBytes_AsWritableString(s) ((char*) PyBytes_AS_STRING(s)) #define __Pyx_PyBytes_AsWritableSString(s) ((signed char*) PyBytes_AS_STRING(s)) #define __Pyx_PyBytes_AsWritableUString(s) ((unsigned char*) PyBytes_AS_STRING(s)) #define __Pyx_PyBytes_AsString(s) ((const char*) PyBytes_AS_STRING(s)) #define __Pyx_PyBytes_AsSString(s) ((const signed char*) PyBytes_AS_STRING(s)) #define __Pyx_PyBytes_AsUString(s) ((const unsigned char*) PyBytes_AS_STRING(s)) #define __Pyx_PyObject_AsWritableString(s) ((char*) __Pyx_PyObject_AsString(s)) #define __Pyx_PyObject_AsWritableSString(s) ((signed char*) __Pyx_PyObject_AsString(s)) #define __Pyx_PyObject_AsWritableUString(s) ((unsigned char*) __Pyx_PyObject_AsString(s)) #define __Pyx_PyObject_AsSString(s) ((const signed char*) __Pyx_PyObject_AsString(s)) #define __Pyx_PyObject_AsUString(s) ((const unsigned char*) __Pyx_PyObject_AsString(s)) #define __Pyx_PyObject_FromCString(s) __Pyx_PyObject_FromString((const char*)s) #define __Pyx_PyBytes_FromCString(s) __Pyx_PyBytes_FromString((const char*)s) #define __Pyx_PyByteArray_FromCString(s) __Pyx_PyByteArray_FromString((const char*)s) #define __Pyx_PyStr_FromCString(s) __Pyx_PyStr_FromString((const char*)s) #define __Pyx_PyUnicode_FromCString(s) __Pyx_PyUnicode_FromString((const char*)s) static CYTHON_INLINE size_t __Pyx_Py_UNICODE_strlen(const Py_UNICODE *u) { const Py_UNICODE *u_end = u; while (*u_end++) ; return (size_t)(u_end - u - 1); } #define __Pyx_PyUnicode_FromUnicode(u) PyUnicode_FromUnicode(u, __Pyx_Py_UNICODE_strlen(u)) #define __Pyx_PyUnicode_FromUnicodeAndLength PyUnicode_FromUnicode #define __Pyx_PyUnicode_AsUnicode PyUnicode_AsUnicode #define __Pyx_NewRef(obj) (Py_INCREF(obj), obj) #define __Pyx_Owned_Py_None(b) __Pyx_NewRef(Py_None) #define __Pyx_PyBool_FromLong(b) ((b) ? __Pyx_NewRef(Py_True) : __Pyx_NewRef(Py_False)) static CYTHON_INLINE int __Pyx_PyObject_IsTrue(PyObject*); static CYTHON_INLINE PyObject* __Pyx_PyNumber_IntOrLong(PyObject* x); #define __Pyx_PySequence_Tuple(obj)\ (likely(PyTuple_CheckExact(obj)) ? __Pyx_NewRef(obj) : PySequence_Tuple(obj)) static CYTHON_INLINE Py_ssize_t __Pyx_PyIndex_AsSsize_t(PyObject*); static CYTHON_INLINE PyObject * __Pyx_PyInt_FromSize_t(size_t); #if CYTHON_ASSUME_SAFE_MACROS #define __pyx_PyFloat_AsDouble(x) (PyFloat_CheckExact(x) ? PyFloat_AS_DOUBLE(x) : PyFloat_AsDouble(x)) #else #define __pyx_PyFloat_AsDouble(x) PyFloat_AsDouble(x) #endif #define __pyx_PyFloat_AsFloat(x) ((float) __pyx_PyFloat_AsDouble(x)) #if PY_MAJOR_VERSION >= 3 #define __Pyx_PyNumber_Int(x) (PyLong_CheckExact(x) ? __Pyx_NewRef(x) : PyNumber_Long(x)) #else #define __Pyx_PyNumber_Int(x) (PyInt_CheckExact(x) ? __Pyx_NewRef(x) : PyNumber_Int(x)) #endif #define __Pyx_PyNumber_Float(x) (PyFloat_CheckExact(x) ? __Pyx_NewRef(x) : PyNumber_Float(x)) #if PY_MAJOR_VERSION < 3 && __PYX_DEFAULT_STRING_ENCODING_IS_ASCII static int __Pyx_sys_getdefaultencoding_not_ascii; static int __Pyx_init_sys_getdefaultencoding_params(void) { PyObject* sys; PyObject* default_encoding = NULL; PyObject* ascii_chars_u = NULL; PyObject* ascii_chars_b = NULL; const char* default_encoding_c; sys = PyImport_ImportModule("sys"); if (!sys) goto bad; default_encoding = PyObject_CallMethod(sys, (char*) "getdefaultencoding", NULL); Py_DECREF(sys); if (!default_encoding) goto bad; default_encoding_c = PyBytes_AsString(default_encoding); if (!default_encoding_c) goto bad; if (strcmp(default_encoding_c, "ascii") == 0) { __Pyx_sys_getdefaultencoding_not_ascii = 0; } else { char ascii_chars[128]; int c; for (c = 0; c < 128; c++) { ascii_chars[c] = c; } __Pyx_sys_getdefaultencoding_not_ascii = 1; ascii_chars_u = PyUnicode_DecodeASCII(ascii_chars, 128, NULL); if (!ascii_chars_u) goto bad; ascii_chars_b = PyUnicode_AsEncodedString(ascii_chars_u, default_encoding_c, NULL); if (!ascii_chars_b || !PyBytes_Check(ascii_chars_b) || memcmp(ascii_chars, PyBytes_AS_STRING(ascii_chars_b), 128) != 0) { PyErr_Format( PyExc_ValueError, "This module compiled with c_string_encoding=ascii, but default encoding '%.200s' is not a superset of ascii.", default_encoding_c); goto bad; } Py_DECREF(ascii_chars_u); Py_DECREF(ascii_chars_b); } Py_DECREF(default_encoding); return 0; bad: Py_XDECREF(default_encoding); Py_XDECREF(ascii_chars_u); Py_XDECREF(ascii_chars_b); return -1; } #endif #if __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT && PY_MAJOR_VERSION >= 3 #define __Pyx_PyUnicode_FromStringAndSize(c_str, size) PyUnicode_DecodeUTF8(c_str, size, NULL) #else #define __Pyx_PyUnicode_FromStringAndSize(c_str, size) PyUnicode_Decode(c_str, size, __PYX_DEFAULT_STRING_ENCODING, NULL) #if __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT static char* __PYX_DEFAULT_STRING_ENCODING; static int __Pyx_init_sys_getdefaultencoding_params(void) { PyObject* sys; PyObject* default_encoding = NULL; char* default_encoding_c; sys = PyImport_ImportModule("sys"); if (!sys) goto bad; default_encoding = PyObject_CallMethod(sys, (char*) (const char*) "getdefaultencoding", NULL); Py_DECREF(sys); if (!default_encoding) goto bad; default_encoding_c = PyBytes_AsString(default_encoding); if (!default_encoding_c) goto bad; __PYX_DEFAULT_STRING_ENCODING = (char*) malloc(strlen(default_encoding_c)); if (!__PYX_DEFAULT_STRING_ENCODING) goto bad; strcpy(__PYX_DEFAULT_STRING_ENCODING, default_encoding_c); Py_DECREF(default_encoding); return 0; bad: Py_XDECREF(default_encoding); return -1; } #endif #endif /* Test for GCC > 2.95 */ #if defined(__GNUC__) && (__GNUC__ > 2 || (__GNUC__ == 2 && (__GNUC_MINOR__ > 95))) #define likely(x) __builtin_expect(!!(x), 1) #define unlikely(x) __builtin_expect(!!(x), 0) #else /* !__GNUC__ or GCC < 2.95 */ #define likely(x) (x) #define unlikely(x) (x) #endif /* __GNUC__ */ static CYTHON_INLINE void __Pyx_pretend_to_initialize(void* ptr) { (void)ptr; } static PyObject *__pyx_m = NULL; static PyObject *__pyx_d; static PyObject *__pyx_b; static PyObject *__pyx_cython_runtime; static PyObject *__pyx_empty_tuple; static PyObject *__pyx_empty_bytes; static PyObject *__pyx_empty_unicode; static int __pyx_lineno; static int __pyx_clineno = 0; static const char * __pyx_cfilenm= __FILE__; static const char *__pyx_filename; static const char *__pyx_f[] = { "lupa/_lupa.pyx", "lupa/lock.pxi", "stringsource", "type.pxd", "bool.pxd", "complex.pxd", }; /* NoFastGil.proto */ #define __Pyx_PyGILState_Ensure PyGILState_Ensure #define __Pyx_PyGILState_Release PyGILState_Release #define __Pyx_FastGIL_Remember() #define __Pyx_FastGIL_Forget() #define __Pyx_FastGilFuncInit() /* ForceInitThreads.proto */ #ifndef __PYX_FORCE_INIT_THREADS #define __PYX_FORCE_INIT_THREADS 0 #endif /*--- Type declarations ---*/ struct __pyx_obj_4lupa_5_lupa_FastRLock; struct __pyx_obj_4lupa_5_lupa_LuaRuntime; struct __pyx_obj_4lupa_5_lupa__LuaObject; struct __pyx_obj_4lupa_5_lupa__LuaTable; struct __pyx_obj_4lupa_5_lupa__LuaFunction; struct __pyx_obj_4lupa_5_lupa__LuaCoroutineFunction; struct __pyx_obj_4lupa_5_lupa__LuaThread; struct __pyx_obj_4lupa_5_lupa__LuaIter; struct __pyx_obj_4lupa_5_lupa__PyProtocolWrapper; struct __pyx_obj_4lupa_5_lupa___pyx_scope_struct__unpacks_lua_table; struct __pyx_obj_4lupa_5_lupa___pyx_scope_struct_1_unpacks_lua_table_method; struct __pyx_t_4lupa_5_lupa_py_object; struct __pyx_opt_args_4lupa_5_lupa_py_to_lua; struct __pyx_opt_args_4lupa_5_lupa_push_lua_arguments; /* "lupa/_lupa.pyx":50 * cdef int IS_PY2 = PY_MAJOR_VERSION == 2 * * cdef enum WrappedObjectFlags: # <<<<<<<<<<<<<< * # flags that determine the behaviour of a wrapped object: * OBJ_AS_INDEX = 1 # prefers the getitem protocol (over getattr) */ enum __pyx_t_4lupa_5_lupa_WrappedObjectFlags { __pyx_e_4lupa_5_lupa_OBJ_AS_INDEX = 1, __pyx_e_4lupa_5_lupa_OBJ_UNPACK_TUPLE = 2, __pyx_e_4lupa_5_lupa_OBJ_ENUMERATOR = 4 }; /* "lupa/_lupa.pyx":936 * * * cdef enum: # <<<<<<<<<<<<<< * KEYS = 1 * VALUES = 2 */ enum { __pyx_e_4lupa_5_lupa_KEYS = 1, __pyx_e_4lupa_5_lupa_VALUES = 2, __pyx_e_4lupa_5_lupa_ITEMS = 3 }; /* "lupa/_lupa.pyx":56 * OBJ_ENUMERATOR = 4 # iteration uses native enumerate() implementation * * cdef struct py_object: # <<<<<<<<<<<<<< * PyObject* obj * PyObject* runtime */ struct __pyx_t_4lupa_5_lupa_py_object { PyObject *obj; PyObject *runtime; int type_flags; }; /* "lupa/_lupa.pyx":1140 * return py_to_lua(runtime, L, o) * * cdef int py_to_lua(LuaRuntime runtime, lua_State *L, object o, bint wrap_none=False) except -1: # <<<<<<<<<<<<<< * cdef int pushed_values_count = 0 * cdef int type_flags = 0 */ struct __pyx_opt_args_4lupa_5_lupa_py_to_lua { int __pyx_n; int wrap_none; }; /* "lupa/_lupa.pyx":1317 * return results * * cdef int push_lua_arguments(LuaRuntime runtime, lua_State *L, # <<<<<<<<<<<<<< * tuple args, bint first_may_be_nil=True) except -1: * cdef int i */ struct __pyx_opt_args_4lupa_5_lupa_push_lua_arguments { int __pyx_n; int first_may_be_nil; }; /* "lupa/lock.pxi":5 * from cpython.exc cimport PyErr_NoMemory * * cdef class FastRLock: # <<<<<<<<<<<<<< * """Fast, re-entrant locking. * */ struct __pyx_obj_4lupa_5_lupa_FastRLock { PyObject_HEAD PyThread_type_lock _real_lock; long _owner; int _count; int _pending_requests; int _is_locked; }; /* "lupa/_lupa.pyx":110 * * @cython.no_gc_clear * cdef class LuaRuntime: # <<<<<<<<<<<<<< * """The main entry point to the Lua runtime. * */ struct __pyx_obj_4lupa_5_lupa_LuaRuntime { PyObject_HEAD struct __pyx_vtabstruct_4lupa_5_lupa_LuaRuntime *__pyx_vtab; lua_State *_state; struct __pyx_obj_4lupa_5_lupa_FastRLock *_lock; PyObject *_pyrefs_in_lua; PyObject *_raised_exception; PyObject *_encoding; PyObject *_source_encoding; PyObject *_attribute_filter; PyObject *_attribute_getter; PyObject *_attribute_setter; int _unpack_returned_tuples; }; /* "lupa/_lupa.pyx":503 * @cython.no_gc_clear * @cython.freelist(16) * cdef class _LuaObject: # <<<<<<<<<<<<<< * """A wrapper around a Lua object such as a table or function. * """ */ struct __pyx_obj_4lupa_5_lupa__LuaObject { PyObject_HEAD struct __pyx_vtabstruct_4lupa_5_lupa__LuaObject *__pyx_vtab; struct __pyx_obj_4lupa_5_lupa_LuaRuntime *_runtime; lua_State *_state; int _ref; }; /* "lupa/_lupa.pyx":686 * @cython.internal * @cython.no_gc_clear * cdef class _LuaTable(_LuaObject): # <<<<<<<<<<<<<< * def __iter__(self): * return _LuaIter(self, KEYS) */ struct __pyx_obj_4lupa_5_lupa__LuaTable { struct __pyx_obj_4lupa_5_lupa__LuaObject __pyx_base; }; /* "lupa/_lupa.pyx":777 * @cython.internal * @cython.no_gc_clear * cdef class _LuaFunction(_LuaObject): # <<<<<<<<<<<<<< * """A Lua function (which may become a coroutine). * """ */ struct __pyx_obj_4lupa_5_lupa__LuaFunction { struct __pyx_obj_4lupa_5_lupa__LuaObject __pyx_base; }; /* "lupa/_lupa.pyx":816 * @cython.internal * @cython.no_gc_clear * cdef class _LuaCoroutineFunction(_LuaFunction): # <<<<<<<<<<<<<< * """A function that returns a new coroutine when called. * """ */ struct __pyx_obj_4lupa_5_lupa__LuaCoroutineFunction { struct __pyx_obj_4lupa_5_lupa__LuaFunction __pyx_base; }; /* "lupa/_lupa.pyx":831 * @cython.internal * @cython.no_gc_clear # FIXME: get rid if this * cdef class _LuaThread(_LuaObject): # <<<<<<<<<<<<<< * """A Lua thread (coroutine). * """ */ struct __pyx_obj_4lupa_5_lupa__LuaThread { struct __pyx_obj_4lupa_5_lupa__LuaObject __pyx_base; lua_State *_co_state; PyObject *_arguments; }; /* "lupa/_lupa.pyx":945 * @cython.internal * @cython.no_gc_clear * cdef class _LuaIter: # <<<<<<<<<<<<<< * cdef LuaRuntime _runtime * cdef _LuaObject _obj */ struct __pyx_obj_4lupa_5_lupa__LuaIter { PyObject_HEAD struct __pyx_obj_4lupa_5_lupa_LuaRuntime *_runtime; struct __pyx_obj_4lupa_5_lupa__LuaObject *_obj; lua_State *_state; int _refiter; char _what; }; /* "lupa/_lupa.pyx":1056 * @cython.internal * @cython.freelist(8) * cdef class _PyProtocolWrapper: # <<<<<<<<<<<<<< * cdef object _obj * cdef int _type_flags */ struct __pyx_obj_4lupa_5_lupa__PyProtocolWrapper { PyObject_HEAD PyObject *_obj; int _type_flags; }; /* "lupa/_lupa.pyx":416 * # from Lua scripts * * def unpacks_lua_table(func): # <<<<<<<<<<<<<< * """ * A decorator to make the decorated function receive kwargs */ struct __pyx_obj_4lupa_5_lupa___pyx_scope_struct__unpacks_lua_table { PyObject_HEAD PyObject *__pyx_v_func; }; /* "lupa/_lupa.pyx":442 * * * def unpacks_lua_table_method(meth): # <<<<<<<<<<<<<< * """ * This is :func:`unpacks_lua_table` for methods */ struct __pyx_obj_4lupa_5_lupa___pyx_scope_struct_1_unpacks_lua_table_method { PyObject_HEAD PyObject *__pyx_v_meth; }; /* "lupa/_lupa.pyx":110 * * @cython.no_gc_clear * cdef class LuaRuntime: # <<<<<<<<<<<<<< * """The main entry point to the Lua runtime. * */ struct __pyx_vtabstruct_4lupa_5_lupa_LuaRuntime { int (*reraise_on_exception)(struct __pyx_obj_4lupa_5_lupa_LuaRuntime *); int (*store_raised_exception)(struct __pyx_obj_4lupa_5_lupa_LuaRuntime *, lua_State *, PyObject *); int (*register_py_object)(struct __pyx_obj_4lupa_5_lupa_LuaRuntime *, PyObject *, PyObject *, PyObject *); int (*init_python_lib)(struct __pyx_obj_4lupa_5_lupa_LuaRuntime *, int, int); }; static struct __pyx_vtabstruct_4lupa_5_lupa_LuaRuntime *__pyx_vtabptr_4lupa_5_lupa_LuaRuntime; static int __pyx_f_4lupa_5_lupa_10LuaRuntime_reraise_on_exception(struct __pyx_obj_4lupa_5_lupa_LuaRuntime *); static int __pyx_f_4lupa_5_lupa_10LuaRuntime_store_raised_exception(struct __pyx_obj_4lupa_5_lupa_LuaRuntime *, lua_State *, PyObject *); static int __pyx_f_4lupa_5_lupa_10LuaRuntime_register_py_object(struct __pyx_obj_4lupa_5_lupa_LuaRuntime *, PyObject *, PyObject *, PyObject *); static int __pyx_f_4lupa_5_lupa_10LuaRuntime_init_python_lib(struct __pyx_obj_4lupa_5_lupa_LuaRuntime *, int, int); /* "lupa/_lupa.pyx":503 * @cython.no_gc_clear * @cython.freelist(16) * cdef class _LuaObject: # <<<<<<<<<<<<<< * """A wrapper around a Lua object such as a table or function. * """ */ struct __pyx_vtabstruct_4lupa_5_lupa__LuaObject { int (*push_lua_object)(struct __pyx_obj_4lupa_5_lupa__LuaObject *); size_t (*_len)(struct __pyx_obj_4lupa_5_lupa__LuaObject *); PyObject *(*_getitem)(struct __pyx_obj_4lupa_5_lupa__LuaObject *, PyObject *, int); }; static struct __pyx_vtabstruct_4lupa_5_lupa__LuaObject *__pyx_vtabptr_4lupa_5_lupa__LuaObject; static CYTHON_INLINE int __pyx_f_4lupa_5_lupa_10_LuaObject_push_lua_object(struct __pyx_obj_4lupa_5_lupa__LuaObject *); static size_t __pyx_f_4lupa_5_lupa_10_LuaObject__len(struct __pyx_obj_4lupa_5_lupa__LuaObject *); static PyObject *__pyx_f_4lupa_5_lupa_10_LuaObject__getitem(struct __pyx_obj_4lupa_5_lupa__LuaObject *, PyObject *, int); /* "lupa/_lupa.pyx":686 * @cython.internal * @cython.no_gc_clear * cdef class _LuaTable(_LuaObject): # <<<<<<<<<<<<<< * def __iter__(self): * return _LuaIter(self, KEYS) */ struct __pyx_vtabstruct_4lupa_5_lupa__LuaTable { struct __pyx_vtabstruct_4lupa_5_lupa__LuaObject __pyx_base; int (*_setitem)(struct __pyx_obj_4lupa_5_lupa__LuaTable *, PyObject *, PyObject *); PyObject *(*_delitem)(struct __pyx_obj_4lupa_5_lupa__LuaTable *, PyObject *); }; static struct __pyx_vtabstruct_4lupa_5_lupa__LuaTable *__pyx_vtabptr_4lupa_5_lupa__LuaTable; static int __pyx_f_4lupa_5_lupa_9_LuaTable__setitem(struct __pyx_obj_4lupa_5_lupa__LuaTable *, PyObject *, PyObject *); static PyObject *__pyx_f_4lupa_5_lupa_9_LuaTable__delitem(struct __pyx_obj_4lupa_5_lupa__LuaTable *, PyObject *); /* "lupa/_lupa.pyx":777 * @cython.internal * @cython.no_gc_clear * cdef class _LuaFunction(_LuaObject): # <<<<<<<<<<<<<< * """A Lua function (which may become a coroutine). * """ */ struct __pyx_vtabstruct_4lupa_5_lupa__LuaFunction { struct __pyx_vtabstruct_4lupa_5_lupa__LuaObject __pyx_base; }; static struct __pyx_vtabstruct_4lupa_5_lupa__LuaFunction *__pyx_vtabptr_4lupa_5_lupa__LuaFunction; /* "lupa/_lupa.pyx":816 * @cython.internal * @cython.no_gc_clear * cdef class _LuaCoroutineFunction(_LuaFunction): # <<<<<<<<<<<<<< * """A function that returns a new coroutine when called. * """ */ struct __pyx_vtabstruct_4lupa_5_lupa__LuaCoroutineFunction { struct __pyx_vtabstruct_4lupa_5_lupa__LuaFunction __pyx_base; }; static struct __pyx_vtabstruct_4lupa_5_lupa__LuaCoroutineFunction *__pyx_vtabptr_4lupa_5_lupa__LuaCoroutineFunction; /* "lupa/_lupa.pyx":831 * @cython.internal * @cython.no_gc_clear # FIXME: get rid if this * cdef class _LuaThread(_LuaObject): # <<<<<<<<<<<<<< * """A Lua thread (coroutine). * """ */ struct __pyx_vtabstruct_4lupa_5_lupa__LuaThread { struct __pyx_vtabstruct_4lupa_5_lupa__LuaObject __pyx_base; }; static struct __pyx_vtabstruct_4lupa_5_lupa__LuaThread *__pyx_vtabptr_4lupa_5_lupa__LuaThread; /* --- Runtime support code (head) --- */ /* Refnanny.proto */ #ifndef CYTHON_REFNANNY #define CYTHON_REFNANNY 0 #endif #if CYTHON_REFNANNY typedef struct { void (*INCREF)(void*, PyObject*, int); void (*DECREF)(void*, PyObject*, int); void (*GOTREF)(void*, PyObject*, int); void (*GIVEREF)(void*, PyObject*, int); void* (*SetupContext)(const char*, int, const char*); void (*FinishContext)(void**); } __Pyx_RefNannyAPIStruct; static __Pyx_RefNannyAPIStruct *__Pyx_RefNanny = NULL; static __Pyx_RefNannyAPIStruct *__Pyx_RefNannyImportAPI(const char *modname); #define __Pyx_RefNannyDeclarations void *__pyx_refnanny = NULL; #ifdef WITH_THREAD #define __Pyx_RefNannySetupContext(name, acquire_gil)\ if (acquire_gil) {\ PyGILState_STATE __pyx_gilstate_save = PyGILState_Ensure();\ __pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE__);\ PyGILState_Release(__pyx_gilstate_save);\ } else {\ __pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE__);\ } #else #define __Pyx_RefNannySetupContext(name, acquire_gil)\ __pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE__) #endif #define __Pyx_RefNannyFinishContext()\ __Pyx_RefNanny->FinishContext(&__pyx_refnanny) #define __Pyx_INCREF(r) __Pyx_RefNanny->INCREF(__pyx_refnanny, (PyObject *)(r), __LINE__) #define __Pyx_DECREF(r) __Pyx_RefNanny->DECREF(__pyx_refnanny, (PyObject *)(r), __LINE__) #define __Pyx_GOTREF(r) __Pyx_RefNanny->GOTREF(__pyx_refnanny, (PyObject *)(r), __LINE__) #define __Pyx_GIVEREF(r) __Pyx_RefNanny->GIVEREF(__pyx_refnanny, (PyObject *)(r), __LINE__) #define __Pyx_XINCREF(r) do { if((r) != NULL) {__Pyx_INCREF(r); }} while(0) #define __Pyx_XDECREF(r) do { if((r) != NULL) {__Pyx_DECREF(r); }} while(0) #define __Pyx_XGOTREF(r) do { if((r) != NULL) {__Pyx_GOTREF(r); }} while(0) #define __Pyx_XGIVEREF(r) do { if((r) != NULL) {__Pyx_GIVEREF(r);}} while(0) #else #define __Pyx_RefNannyDeclarations #define __Pyx_RefNannySetupContext(name, acquire_gil) #define __Pyx_RefNannyFinishContext() #define __Pyx_INCREF(r) Py_INCREF(r) #define __Pyx_DECREF(r) Py_DECREF(r) #define __Pyx_GOTREF(r) #define __Pyx_GIVEREF(r) #define __Pyx_XINCREF(r) Py_XINCREF(r) #define __Pyx_XDECREF(r) Py_XDECREF(r) #define __Pyx_XGOTREF(r) #define __Pyx_XGIVEREF(r) #endif #define __Pyx_XDECREF_SET(r, v) do {\ PyObject *tmp = (PyObject *) r;\ r = v; __Pyx_XDECREF(tmp);\ } while (0) #define __Pyx_DECREF_SET(r, v) do {\ PyObject *tmp = (PyObject *) r;\ r = v; __Pyx_DECREF(tmp);\ } while (0) #define __Pyx_CLEAR(r) do { PyObject* tmp = ((PyObject*)(r)); r = NULL; __Pyx_DECREF(tmp);} while(0) #define __Pyx_XCLEAR(r) do { if((r) != NULL) {PyObject* tmp = ((PyObject*)(r)); r = NULL; __Pyx_DECREF(tmp);}} while(0) /* PyObjectGetAttrStr.proto */ #if CYTHON_USE_TYPE_SLOTS static CYTHON_INLINE PyObject* __Pyx_PyObject_GetAttrStr(PyObject* obj, PyObject* attr_name) { PyTypeObject* tp = Py_TYPE(obj); if (likely(tp->tp_getattro)) return tp->tp_getattro(obj, attr_name); #if PY_MAJOR_VERSION < 3 if (likely(tp->tp_getattr)) return tp->tp_getattr(obj, PyString_AS_STRING(attr_name)); #endif return PyObject_GetAttr(obj, attr_name); } #else #define __Pyx_PyObject_GetAttrStr(o,n) PyObject_GetAttr(o,n) #endif /* GetBuiltinName.proto */ static PyObject *__Pyx_GetBuiltinName(PyObject *name); /* RaiseArgTupleInvalid.proto */ static void __Pyx_RaiseArgtupleInvalid(const char* func_name, int exact, Py_ssize_t num_min, Py_ssize_t num_max, Py_ssize_t num_found); /* KeywordStringCheck.proto */ static int __Pyx_CheckKeywordStrings(PyObject *kwdict, const char* function_name, int kw_allowed); /* RaiseDoubleKeywords.proto */ static void __Pyx_RaiseDoubleKeywordsError(const char* func_name, PyObject* kw_name); /* ParseKeywords.proto */ static int __Pyx_ParseOptionalKeywords(PyObject *kwds, PyObject **argnames[],\ PyObject *kwds2, PyObject *values[], Py_ssize_t num_pos_args,\ const char* function_name); /* PyObjectCall.proto */ #if CYTHON_COMPILING_IN_CPYTHON static CYTHON_INLINE PyObject* __Pyx_PyObject_Call(PyObject *func, PyObject *arg, PyObject *kw); #else #define __Pyx_PyObject_Call(func, arg, kw) PyObject_Call(func, arg, kw) #endif /* PyThreadStateGet.proto */ #if CYTHON_FAST_THREAD_STATE #define __Pyx_PyThreadState_declare PyThreadState *__pyx_tstate; #define __Pyx_PyThreadState_assign __pyx_tstate = __Pyx_PyThreadState_Current; #define __Pyx_PyErr_Occurred() __pyx_tstate->curexc_type #else #define __Pyx_PyThreadState_declare #define __Pyx_PyThreadState_assign #define __Pyx_PyErr_Occurred() PyErr_Occurred() #endif /* PyErrFetchRestore.proto */ #if CYTHON_FAST_THREAD_STATE #define __Pyx_PyErr_Clear() __Pyx_ErrRestore(NULL, NULL, NULL) #define __Pyx_ErrRestoreWithState(type, value, tb) __Pyx_ErrRestoreInState(PyThreadState_GET(), type, value, tb) #define __Pyx_ErrFetchWithState(type, value, tb) __Pyx_ErrFetchInState(PyThreadState_GET(), type, value, tb) #define __Pyx_ErrRestore(type, value, tb) __Pyx_ErrRestoreInState(__pyx_tstate, type, value, tb) #define __Pyx_ErrFetch(type, value, tb) __Pyx_ErrFetchInState(__pyx_tstate, type, value, tb) static CYTHON_INLINE void __Pyx_ErrRestoreInState(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb); static CYTHON_INLINE void __Pyx_ErrFetchInState(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb); #if CYTHON_COMPILING_IN_CPYTHON #define __Pyx_PyErr_SetNone(exc) (Py_INCREF(exc), __Pyx_ErrRestore((exc), NULL, NULL)) #else #define __Pyx_PyErr_SetNone(exc) PyErr_SetNone(exc) #endif #else #define __Pyx_PyErr_Clear() PyErr_Clear() #define __Pyx_PyErr_SetNone(exc) PyErr_SetNone(exc) #define __Pyx_ErrRestoreWithState(type, value, tb) PyErr_Restore(type, value, tb) #define __Pyx_ErrFetchWithState(type, value, tb) PyErr_Fetch(type, value, tb) #define __Pyx_ErrRestoreInState(tstate, type, value, tb) PyErr_Restore(type, value, tb) #define __Pyx_ErrFetchInState(tstate, type, value, tb) PyErr_Fetch(type, value, tb) #define __Pyx_ErrRestore(type, value, tb) PyErr_Restore(type, value, tb) #define __Pyx_ErrFetch(type, value, tb) PyErr_Fetch(type, value, tb) #endif /* RaiseException.proto */ static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, PyObject *cause); /* IncludeStringH.proto */ #include /* decode_c_string_utf16.proto */ static CYTHON_INLINE PyObject *__Pyx_PyUnicode_DecodeUTF16(const char *s, Py_ssize_t size, const char *errors) { int byteorder = 0; return PyUnicode_DecodeUTF16(s, size, errors, &byteorder); } static CYTHON_INLINE PyObject *__Pyx_PyUnicode_DecodeUTF16LE(const char *s, Py_ssize_t size, const char *errors) { int byteorder = -1; return PyUnicode_DecodeUTF16(s, size, errors, &byteorder); } static CYTHON_INLINE PyObject *__Pyx_PyUnicode_DecodeUTF16BE(const char *s, Py_ssize_t size, const char *errors) { int byteorder = 1; return PyUnicode_DecodeUTF16(s, size, errors, &byteorder); } /* decode_c_string.proto */ static CYTHON_INLINE PyObject* __Pyx_decode_c_string( const char* cstring, Py_ssize_t start, Py_ssize_t stop, const char* encoding, const char* errors, PyObject* (*decode_func)(const char *s, Py_ssize_t size, const char *errors)); /* GetException.proto */ #if CYTHON_FAST_THREAD_STATE #define __Pyx_GetException(type, value, tb) __Pyx__GetException(__pyx_tstate, type, value, tb) static int __Pyx__GetException(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb); #else static int __Pyx_GetException(PyObject **type, PyObject **value, PyObject **tb); #endif /* SwapException.proto */ #if CYTHON_FAST_THREAD_STATE #define __Pyx_ExceptionSwap(type, value, tb) __Pyx__ExceptionSwap(__pyx_tstate, type, value, tb) static CYTHON_INLINE void __Pyx__ExceptionSwap(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb); #else static CYTHON_INLINE void __Pyx_ExceptionSwap(PyObject **type, PyObject **value, PyObject **tb); #endif /* SaveResetException.proto */ #if CYTHON_FAST_THREAD_STATE #define __Pyx_ExceptionSave(type, value, tb) __Pyx__ExceptionSave(__pyx_tstate, type, value, tb) static CYTHON_INLINE void __Pyx__ExceptionSave(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb); #define __Pyx_ExceptionReset(type, value, tb) __Pyx__ExceptionReset(__pyx_tstate, type, value, tb) static CYTHON_INLINE void __Pyx__ExceptionReset(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb); #else #define __Pyx_ExceptionSave(type, value, tb) PyErr_GetExcInfo(type, value, tb) #define __Pyx_ExceptionReset(type, value, tb) PyErr_SetExcInfo(type, value, tb) #endif /* GetModuleGlobalName.proto */ static CYTHON_INLINE PyObject *__Pyx_GetModuleGlobalName(PyObject *name); /* CallableCheck.proto */ #if CYTHON_USE_TYPE_SLOTS && PY_MAJOR_VERSION >= 3 #define __Pyx_PyCallable_Check(obj) ((obj)->ob_type->tp_call != NULL) #else #define __Pyx_PyCallable_Check(obj) PyCallable_Check(obj) #endif /* RaiseTooManyValuesToUnpack.proto */ static CYTHON_INLINE void __Pyx_RaiseTooManyValuesError(Py_ssize_t expected); /* RaiseNeedMoreValuesToUnpack.proto */ static CYTHON_INLINE void __Pyx_RaiseNeedMoreValuesError(Py_ssize_t index); /* IterFinish.proto */ static CYTHON_INLINE int __Pyx_IterFinish(void); /* UnpackItemEndCheck.proto */ static int __Pyx_IternextUnpackEndCheck(PyObject *retval, Py_ssize_t expected); /* PyErrExceptionMatches.proto */ #if CYTHON_FAST_THREAD_STATE #define __Pyx_PyErr_ExceptionMatches(err) __Pyx_PyErr_ExceptionMatchesInState(__pyx_tstate, err) static CYTHON_INLINE int __Pyx_PyErr_ExceptionMatchesInState(PyThreadState* tstate, PyObject* err); #else #define __Pyx_PyErr_ExceptionMatches(err) PyErr_ExceptionMatches(err) #endif /* None.proto */ static CYTHON_INLINE void __Pyx_RaiseUnboundLocalError(const char *varname); /* GetItemInt.proto */ #define __Pyx_GetItemInt(o, i, type, is_signed, to_py_func, is_list, wraparound, boundscheck)\ (__Pyx_fits_Py_ssize_t(i, type, is_signed) ?\ __Pyx_GetItemInt_Fast(o, (Py_ssize_t)i, is_list, wraparound, boundscheck) :\ (is_list ? (PyErr_SetString(PyExc_IndexError, "list index out of range"), (PyObject*)NULL) :\ __Pyx_GetItemInt_Generic(o, to_py_func(i)))) #define __Pyx_GetItemInt_List(o, i, type, is_signed, to_py_func, is_list, wraparound, boundscheck)\ (__Pyx_fits_Py_ssize_t(i, type, is_signed) ?\ __Pyx_GetItemInt_List_Fast(o, (Py_ssize_t)i, wraparound, boundscheck) :\ (PyErr_SetString(PyExc_IndexError, "list index out of range"), (PyObject*)NULL)) static CYTHON_INLINE PyObject *__Pyx_GetItemInt_List_Fast(PyObject *o, Py_ssize_t i, int wraparound, int boundscheck); #define __Pyx_GetItemInt_Tuple(o, i, type, is_signed, to_py_func, is_list, wraparound, boundscheck)\ (__Pyx_fits_Py_ssize_t(i, type, is_signed) ?\ __Pyx_GetItemInt_Tuple_Fast(o, (Py_ssize_t)i, wraparound, boundscheck) :\ (PyErr_SetString(PyExc_IndexError, "tuple index out of range"), (PyObject*)NULL)) static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Tuple_Fast(PyObject *o, Py_ssize_t i, int wraparound, int boundscheck); static PyObject *__Pyx_GetItemInt_Generic(PyObject *o, PyObject* j); static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Fast(PyObject *o, Py_ssize_t i, int is_list, int wraparound, int boundscheck); /* PyCFunctionFastCall.proto */ #if CYTHON_FAST_PYCCALL static CYTHON_INLINE PyObject *__Pyx_PyCFunction_FastCall(PyObject *func, PyObject **args, Py_ssize_t nargs); #else #define __Pyx_PyCFunction_FastCall(func, args, nargs) (assert(0), NULL) #endif /* PyFunctionFastCall.proto */ #if CYTHON_FAST_PYCALL #define __Pyx_PyFunction_FastCall(func, args, nargs)\ __Pyx_PyFunction_FastCallDict((func), (args), (nargs), NULL) #if 1 || PY_VERSION_HEX < 0x030600B1 static PyObject *__Pyx_PyFunction_FastCallDict(PyObject *func, PyObject **args, int nargs, PyObject *kwargs); #else #define __Pyx_PyFunction_FastCallDict(func, args, nargs, kwargs) _PyFunction_FastCallDict(func, args, nargs, kwargs) #endif #endif /* PyObjectCallMethO.proto */ #if CYTHON_COMPILING_IN_CPYTHON static CYTHON_INLINE PyObject* __Pyx_PyObject_CallMethO(PyObject *func, PyObject *arg); #endif /* PyObjectCallOneArg.proto */ static CYTHON_INLINE PyObject* __Pyx_PyObject_CallOneArg(PyObject *func, PyObject *arg); /* PyObjectCallNoArg.proto */ #if CYTHON_COMPILING_IN_CPYTHON static CYTHON_INLINE PyObject* __Pyx_PyObject_CallNoArg(PyObject *func); #else #define __Pyx_PyObject_CallNoArg(func) __Pyx_PyObject_Call(func, __pyx_empty_tuple, NULL) #endif /* PyObjectCallMethod0.proto */ static PyObject* __Pyx_PyObject_CallMethod0(PyObject* obj, PyObject* method_name); /* RaiseNoneIterError.proto */ static CYTHON_INLINE void __Pyx_RaiseNoneNotIterableError(void); /* UnpackTupleError.proto */ static void __Pyx_UnpackTupleError(PyObject *, Py_ssize_t index); /* UnpackTuple2.proto */ #define __Pyx_unpack_tuple2(tuple, value1, value2, is_tuple, has_known_size, decref_tuple)\ (likely(is_tuple || PyTuple_Check(tuple)) ?\ (likely(has_known_size || PyTuple_GET_SIZE(tuple) == 2) ?\ __Pyx_unpack_tuple2_exact(tuple, value1, value2, decref_tuple) :\ (__Pyx_UnpackTupleError(tuple, 2), -1)) :\ __Pyx_unpack_tuple2_generic(tuple, value1, value2, has_known_size, decref_tuple)) static CYTHON_INLINE int __Pyx_unpack_tuple2_exact( PyObject* tuple, PyObject** value1, PyObject** value2, int decref_tuple); static int __Pyx_unpack_tuple2_generic( PyObject* tuple, PyObject** value1, PyObject** value2, int has_known_size, int decref_tuple); /* dict_iter.proto */ static CYTHON_INLINE PyObject* __Pyx_dict_iterator(PyObject* dict, int is_dict, PyObject* method_name, Py_ssize_t* p_orig_length, int* p_is_dict); static CYTHON_INLINE int __Pyx_dict_iter_next(PyObject* dict_or_iter, Py_ssize_t orig_length, Py_ssize_t* ppos, PyObject** pkey, PyObject** pvalue, PyObject** pitem, int is_dict); /* None.proto */ static CYTHON_INLINE void __Pyx_RaiseClosureNameError(const char *varname); /* FetchCommonType.proto */ static PyTypeObject* __Pyx_FetchCommonType(PyTypeObject* type); /* CythonFunction.proto */ #define __Pyx_CyFunction_USED 1 #include #define __Pyx_CYFUNCTION_STATICMETHOD 0x01 #define __Pyx_CYFUNCTION_CLASSMETHOD 0x02 #define __Pyx_CYFUNCTION_CCLASS 0x04 #define __Pyx_CyFunction_GetClosure(f)\ (((__pyx_CyFunctionObject *) (f))->func_closure) #define __Pyx_CyFunction_GetClassObj(f)\ (((__pyx_CyFunctionObject *) (f))->func_classobj) #define __Pyx_CyFunction_Defaults(type, f)\ ((type *)(((__pyx_CyFunctionObject *) (f))->defaults)) #define __Pyx_CyFunction_SetDefaultsGetter(f, g)\ ((__pyx_CyFunctionObject *) (f))->defaults_getter = (g) typedef struct { PyCFunctionObject func; #if PY_VERSION_HEX < 0x030500A0 PyObject *func_weakreflist; #endif PyObject *func_dict; PyObject *func_name; PyObject *func_qualname; PyObject *func_doc; PyObject *func_globals; PyObject *func_code; PyObject *func_closure; PyObject *func_classobj; void *defaults; int defaults_pyobjects; int flags; PyObject *defaults_tuple; PyObject *defaults_kwdict; PyObject *(*defaults_getter)(PyObject *); PyObject *func_annotations; } __pyx_CyFunctionObject; static PyTypeObject *__pyx_CyFunctionType = 0; #define __Pyx_CyFunction_NewEx(ml, flags, qualname, self, module, globals, code)\ __Pyx_CyFunction_New(__pyx_CyFunctionType, ml, flags, qualname, self, module, globals, code) static PyObject *__Pyx_CyFunction_New(PyTypeObject *, PyMethodDef *ml, int flags, PyObject* qualname, PyObject *self, PyObject *module, PyObject *globals, PyObject* code); static CYTHON_INLINE void *__Pyx_CyFunction_InitDefaults(PyObject *m, size_t size, int pyobjects); static CYTHON_INLINE void __Pyx_CyFunction_SetDefaultsTuple(PyObject *m, PyObject *tuple); static CYTHON_INLINE void __Pyx_CyFunction_SetDefaultsKwDict(PyObject *m, PyObject *dict); static CYTHON_INLINE void __Pyx_CyFunction_SetAnnotationsDict(PyObject *m, PyObject *dict); static int __pyx_CyFunction_init(void); /* ListCompAppend.proto */ #if CYTHON_USE_PYLIST_INTERNALS && CYTHON_ASSUME_SAFE_MACROS static CYTHON_INLINE int __Pyx_ListComp_Append(PyObject* list, PyObject* x) { PyListObject* L = (PyListObject*) list; Py_ssize_t len = Py_SIZE(list); if (likely(L->allocated > len)) { Py_INCREF(x); PyList_SET_ITEM(list, len, x); Py_SIZE(list) = len+1; return 0; } return PyList_Append(list, x); } #else #define __Pyx_ListComp_Append(L,x) PyList_Append(L,x) #endif /* decode_c_bytes.proto */ static CYTHON_INLINE PyObject* __Pyx_decode_c_bytes( const char* cstring, Py_ssize_t length, Py_ssize_t start, Py_ssize_t stop, const char* encoding, const char* errors, PyObject* (*decode_func)(const char *s, Py_ssize_t size, const char *errors)); /* decode_bytes.proto */ static CYTHON_INLINE PyObject* __Pyx_decode_bytes( PyObject* string, Py_ssize_t start, Py_ssize_t stop, const char* encoding, const char* errors, PyObject* (*decode_func)(const char *s, Py_ssize_t size, const char *errors)) { return __Pyx_decode_c_bytes( PyBytes_AS_STRING(string), PyBytes_GET_SIZE(string), start, stop, encoding, errors, decode_func); } /* WriteUnraisableException.proto */ static void __Pyx_WriteUnraisable(const char *name, int clineno, int lineno, const char *filename, int full_traceback, int nogil); /* PyIntBinop.proto */ #if !CYTHON_COMPILING_IN_PYPY static PyObject* __Pyx_PyInt_AddObjC(PyObject *op1, PyObject *op2, long intval, int inplace); #else #define __Pyx_PyInt_AddObjC(op1, op2, intval, inplace)\ (inplace ? PyNumber_InPlaceAdd(op1, op2) : PyNumber_Add(op1, op2)) #endif /* unicode_tailmatch.proto */ static int __Pyx_PyUnicode_Tailmatch( PyObject* s, PyObject* substr, Py_ssize_t start, Py_ssize_t end, int direction); /* bytes_tailmatch.proto */ static int __Pyx_PyBytes_SingleTailmatch(PyObject* self, PyObject* arg, Py_ssize_t start, Py_ssize_t end, int direction); static int __Pyx_PyBytes_Tailmatch(PyObject* self, PyObject* substr, Py_ssize_t start, Py_ssize_t end, int direction); /* ExtTypeTest.proto */ static CYTHON_INLINE int __Pyx_TypeTest(PyObject *obj, PyTypeObject *type); /* ArgTypeTest.proto */ #define __Pyx_ArgTypeTest(obj, type, none_allowed, name, exact)\ ((likely((Py_TYPE(obj) == type) | (none_allowed && (obj == Py_None)))) ? 1 :\ __Pyx__ArgTypeTest(obj, type, name, exact)) static int __Pyx__ArgTypeTest(PyObject *obj, PyTypeObject *type, const char *name, int exact); /* GetAttr.proto */ static CYTHON_INLINE PyObject *__Pyx_GetAttr(PyObject *, PyObject *); /* HasAttr.proto */ static CYTHON_INLINE int __Pyx_HasAttr(PyObject *, PyObject *); /* PyDictContains.proto */ static CYTHON_INLINE int __Pyx_PyDict_ContainsTF(PyObject* item, PyObject* dict, int eq) { int result = PyDict_Contains(dict, item); return unlikely(result < 0) ? result : (result == (eq == Py_EQ)); } /* ListAppend.proto */ #if CYTHON_USE_PYLIST_INTERNALS && CYTHON_ASSUME_SAFE_MACROS static CYTHON_INLINE int __Pyx_PyList_Append(PyObject* list, PyObject* x) { PyListObject* L = (PyListObject*) list; Py_ssize_t len = Py_SIZE(list); if (likely(L->allocated > len) & likely(len > (L->allocated >> 1))) { Py_INCREF(x); PyList_SET_ITEM(list, len, x); Py_SIZE(list) = len+1; return 0; } return PyList_Append(list, x); } #else #define __Pyx_PyList_Append(L,x) PyList_Append(L,x) #endif /* PyObjectCallMethod1.proto */ static PyObject* __Pyx_PyObject_CallMethod1(PyObject* obj, PyObject* method_name, PyObject* arg); static PyObject* __Pyx__PyObject_CallMethod1(PyObject* method, PyObject* arg); /* append.proto */ static CYTHON_INLINE int __Pyx_PyObject_Append(PyObject* L, PyObject* x); /* DictGetItem.proto */ #if PY_MAJOR_VERSION >= 3 && !CYTHON_COMPILING_IN_PYPY static PyObject *__Pyx_PyDict_GetItem(PyObject *d, PyObject* key) { PyObject *value; value = PyDict_GetItemWithError(d, key); if (unlikely(!value)) { if (!PyErr_Occurred()) { PyObject* args = PyTuple_Pack(1, key); if (likely(args)) PyErr_SetObject(PyExc_KeyError, args); Py_XDECREF(args); } return NULL; } Py_INCREF(value); return value; } #else #define __Pyx_PyDict_GetItem(d, key) PyObject_GetItem(d, key) #endif /* pop.proto */ static CYTHON_INLINE PyObject* __Pyx__PyObject_Pop(PyObject* L); #if CYTHON_USE_PYLIST_INTERNALS && CYTHON_ASSUME_SAFE_MACROS static CYTHON_INLINE PyObject* __Pyx_PyList_Pop(PyObject* L); #define __Pyx_PyObject_Pop(L) (likely(PyList_CheckExact(L)) ?\ __Pyx_PyList_Pop(L) : __Pyx__PyObject_Pop(L)) #else #define __Pyx_PyList_Pop(L) __Pyx__PyObject_Pop(L) #define __Pyx_PyObject_Pop(L) __Pyx__PyObject_Pop(L) #endif /* UnpackUnboundCMethod.proto */ typedef struct { PyObject *type; PyObject **method_name; PyCFunction func; PyObject *method; int flag; } __Pyx_CachedCFunction; /* CallUnboundCMethod0.proto */ static PyObject* __Pyx__CallUnboundCMethod0(__Pyx_CachedCFunction* cfunc, PyObject* self); #if CYTHON_COMPILING_IN_CPYTHON #define __Pyx_CallUnboundCMethod0(cfunc, self)\ ((likely((cfunc)->func)) ?\ (likely((cfunc)->flag == METH_NOARGS) ? (*((cfunc)->func))(self, NULL) :\ (likely((cfunc)->flag == (METH_VARARGS | METH_KEYWORDS)) ? ((*(PyCFunctionWithKeywords)(cfunc)->func)(self, __pyx_empty_tuple, NULL)) :\ ((cfunc)->flag == METH_VARARGS ? (*((cfunc)->func))(self, __pyx_empty_tuple) :\ (PY_VERSION_HEX >= 0x030600B1 && (cfunc)->flag == METH_FASTCALL ?\ (PY_VERSION_HEX >= 0x030700A0 ?\ (*(__Pyx_PyCFunctionFast)(cfunc)->func)(self, &PyTuple_GET_ITEM(__pyx_empty_tuple, 0), 0) :\ (*(__Pyx_PyCFunctionFastWithKeywords)(cfunc)->func)(self, &PyTuple_GET_ITEM(__pyx_empty_tuple, 0), 0, NULL)) :\ (PY_VERSION_HEX >= 0x030700A0 && (cfunc)->flag == (METH_FASTCALL | METH_KEYWORDS) ?\ (*(__Pyx_PyCFunctionFastWithKeywords)(cfunc)->func)(self, &PyTuple_GET_ITEM(__pyx_empty_tuple, 0), 0, NULL) :\ __Pyx__CallUnboundCMethod0(cfunc, self)))))) :\ __Pyx__CallUnboundCMethod0(cfunc, self)) #else #define __Pyx_CallUnboundCMethod0(cfunc, self) __Pyx__CallUnboundCMethod0(cfunc, self) #endif /* IterNext.proto */ #define __Pyx_PyIter_Next(obj) __Pyx_PyIter_Next2(obj, NULL) static CYTHON_INLINE PyObject *__Pyx_PyIter_Next2(PyObject *, PyObject *); /* SetupReduce.proto */ static int __Pyx_setup_reduce(PyObject* type_obj); /* SetVTable.proto */ static int __Pyx_SetVtable(PyObject *dict, void *vtable); /* Import.proto */ static PyObject *__Pyx_Import(PyObject *name, PyObject *from_list, int level); /* ImportFrom.proto */ static PyObject* __Pyx_ImportFrom(PyObject* module, PyObject* name); /* CalculateMetaclass.proto */ static PyObject *__Pyx_CalculateMetaclass(PyTypeObject *metaclass, PyObject *bases); /* Py3ClassCreate.proto */ static PyObject *__Pyx_Py3MetaclassPrepare(PyObject *metaclass, PyObject *bases, PyObject *name, PyObject *qualname, PyObject *mkw, PyObject *modname, PyObject *doc); static PyObject *__Pyx_Py3ClassCreate(PyObject *metaclass, PyObject *name, PyObject *bases, PyObject *dict, PyObject *mkw, int calculate_metaclass, int allow_py2_metaclass); /* CLineInTraceback.proto */ #ifdef CYTHON_CLINE_IN_TRACEBACK #define __Pyx_CLineForTraceback(tstate, c_line) (((CYTHON_CLINE_IN_TRACEBACK)) ? c_line : 0) #else static int __Pyx_CLineForTraceback(PyThreadState *tstate, int c_line); #endif /* CodeObjectCache.proto */ typedef struct { PyCodeObject* code_object; int code_line; } __Pyx_CodeObjectCacheEntry; struct __Pyx_CodeObjectCache { int count; int max_count; __Pyx_CodeObjectCacheEntry* entries; }; static struct __Pyx_CodeObjectCache __pyx_code_cache = {0,0,NULL}; static int __pyx_bisect_code_objects(__Pyx_CodeObjectCacheEntry* entries, int count, int code_line); static PyCodeObject *__pyx_find_code_object(int code_line); static void __pyx_insert_code_object(int code_line, PyCodeObject* code_object); /* AddTraceback.proto */ static void __Pyx_AddTraceback(const char *funcname, int c_line, int py_line, const char *filename); /* CIntToPy.proto */ static CYTHON_INLINE PyObject* __Pyx_PyInt_From_long(long value); /* CIntToPy.proto */ static CYTHON_INLINE PyObject* __Pyx_PyInt_From_int(int value); /* CIntFromPy.proto */ static CYTHON_INLINE int __Pyx_PyInt_As_int(PyObject *); /* CIntFromPy.proto */ static CYTHON_INLINE size_t __Pyx_PyInt_As_size_t(PyObject *); /* CIntFromPy.proto */ static CYTHON_INLINE long __Pyx_PyInt_As_long(PyObject *); /* FastTypeChecks.proto */ #if CYTHON_COMPILING_IN_CPYTHON #define __Pyx_TypeCheck(obj, type) __Pyx_IsSubtype(Py_TYPE(obj), (PyTypeObject *)type) static CYTHON_INLINE int __Pyx_IsSubtype(PyTypeObject *a, PyTypeObject *b); static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches(PyObject *err, PyObject *type); static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches2(PyObject *err, PyObject *type1, PyObject *type2); #else #define __Pyx_TypeCheck(obj, type) PyObject_TypeCheck(obj, (PyTypeObject *)type) #define __Pyx_PyErr_GivenExceptionMatches(err, type) PyErr_GivenExceptionMatches(err, type) #define __Pyx_PyErr_GivenExceptionMatches2(err, type1, type2) (PyErr_GivenExceptionMatches(err, type1) || PyErr_GivenExceptionMatches(err, type2)) #endif /* CheckBinaryVersion.proto */ static int __Pyx_check_binary_version(void); /* PyIdentifierFromString.proto */ #if !defined(__Pyx_PyIdentifier_FromString) #if PY_MAJOR_VERSION < 3 #define __Pyx_PyIdentifier_FromString(s) PyString_FromString(s) #else #define __Pyx_PyIdentifier_FromString(s) PyUnicode_FromString(s) #endif #endif /* ModuleImport.proto */ static PyObject *__Pyx_ImportModule(const char *name); /* TypeImport.proto */ static PyTypeObject *__Pyx_ImportType(const char *module_name, const char *class_name, size_t size, int strict); /* InitStrings.proto */ static int __Pyx_InitStrings(__Pyx_StringTabEntry *t); static int __pyx_f_4lupa_5_lupa_10LuaRuntime_reraise_on_exception(struct __pyx_obj_4lupa_5_lupa_LuaRuntime *__pyx_v_self); /* proto*/ static int __pyx_f_4lupa_5_lupa_10LuaRuntime_store_raised_exception(struct __pyx_obj_4lupa_5_lupa_LuaRuntime *__pyx_v_self, lua_State *__pyx_v_L, PyObject *__pyx_v_lua_error_msg); /* proto*/ static int __pyx_f_4lupa_5_lupa_10LuaRuntime_register_py_object(struct __pyx_obj_4lupa_5_lupa_LuaRuntime *__pyx_v_self, PyObject *__pyx_v_cname, PyObject *__pyx_v_pyname, PyObject *__pyx_v_obj); /* proto*/ static int __pyx_f_4lupa_5_lupa_10LuaRuntime_init_python_lib(struct __pyx_obj_4lupa_5_lupa_LuaRuntime *__pyx_v_self, int __pyx_v_register_eval, int __pyx_v_register_builtins); /* proto*/ static CYTHON_INLINE int __pyx_f_4lupa_5_lupa_10_LuaObject_push_lua_object(struct __pyx_obj_4lupa_5_lupa__LuaObject *__pyx_v_self); /* proto*/ static size_t __pyx_f_4lupa_5_lupa_10_LuaObject__len(struct __pyx_obj_4lupa_5_lupa__LuaObject *__pyx_v_self); /* proto*/ static PyObject *__pyx_f_4lupa_5_lupa_10_LuaObject__getitem(struct __pyx_obj_4lupa_5_lupa__LuaObject *__pyx_v_self, PyObject *__pyx_v_name, int __pyx_v_is_attr_access); /* proto*/ static int __pyx_f_4lupa_5_lupa_9_LuaTable__setitem(struct __pyx_obj_4lupa_5_lupa__LuaTable *__pyx_v_self, PyObject *__pyx_v_name, PyObject *__pyx_v_value); /* proto*/ static PyObject *__pyx_f_4lupa_5_lupa_9_LuaTable__delitem(struct __pyx_obj_4lupa_5_lupa__LuaTable *__pyx_v_self, PyObject *__pyx_v_name); /* proto*/ /* Module declarations from 'cython' */ /* Module declarations from 'libc.string' */ /* Module declarations from 'lupa' */ /* Module declarations from 'lupa.lua' */ /* Module declarations from 'libc.stdio' */ /* Module declarations from '__builtin__' */ /* Module declarations from 'cpython.type' */ static PyTypeObject *__pyx_ptype_7cpython_4type_type = 0; /* Module declarations from 'cpython.tuple' */ /* Module declarations from 'cpython.float' */ /* Module declarations from 'cpython.long' */ /* Module declarations from 'cpython.version' */ /* Module declarations from 'cpython.exc' */ /* Module declarations from 'cpython.module' */ /* Module declarations from 'cpython.mem' */ /* Module declarations from 'cpython.list' */ /* Module declarations from 'cpython.sequence' */ /* Module declarations from 'cpython.mapping' */ /* Module declarations from 'cpython.iterator' */ /* Module declarations from 'cpython.number' */ /* Module declarations from 'cpython.int' */ /* Module declarations from '__builtin__' */ /* Module declarations from 'cpython.bool' */ static PyTypeObject *__pyx_ptype_7cpython_4bool_bool = 0; /* Module declarations from '__builtin__' */ /* Module declarations from 'cpython.complex' */ static PyTypeObject *__pyx_ptype_7cpython_7complex_complex = 0; /* Module declarations from 'cpython.string' */ /* Module declarations from 'cpython.unicode' */ /* Module declarations from 'cpython.dict' */ /* Module declarations from 'cpython.instance' */ /* Module declarations from 'cpython.function' */ /* Module declarations from 'cpython.method' */ /* Module declarations from 'cpython.weakref' */ /* Module declarations from 'cpython.getargs' */ /* Module declarations from 'cpython.pythread' */ /* Module declarations from 'cpython.pystate' */ /* Module declarations from 'cpython.cobject' */ /* Module declarations from 'cpython.oldbuffer' */ /* Module declarations from 'cpython.set' */ /* Module declarations from 'cpython.buffer' */ /* Module declarations from 'cpython.bytes' */ /* Module declarations from 'cpython.pycapsule' */ /* Module declarations from 'cpython' */ /* Module declarations from 'cpython.object' */ /* Module declarations from 'cpython.ref' */ /* Module declarations from 'libc.stdint' */ /* Module declarations from 'lupa._lupa' */ static PyTypeObject *__pyx_ptype_4lupa_5_lupa_FastRLock = 0; static PyTypeObject *__pyx_ptype_4lupa_5_lupa_LuaRuntime = 0; static PyTypeObject *__pyx_ptype_4lupa_5_lupa__LuaObject = 0; static PyTypeObject *__pyx_ptype_4lupa_5_lupa__LuaTable = 0; static PyTypeObject *__pyx_ptype_4lupa_5_lupa__LuaFunction = 0; static PyTypeObject *__pyx_ptype_4lupa_5_lupa__LuaCoroutineFunction = 0; static PyTypeObject *__pyx_ptype_4lupa_5_lupa__LuaThread = 0; static PyTypeObject *__pyx_ptype_4lupa_5_lupa__LuaIter = 0; static PyTypeObject *__pyx_ptype_4lupa_5_lupa__PyProtocolWrapper = 0; static PyTypeObject *__pyx_ptype_4lupa_5_lupa___pyx_scope_struct__unpacks_lua_table = 0; static PyTypeObject *__pyx_ptype_4lupa_5_lupa___pyx_scope_struct_1_unpacks_lua_table_method = 0; static PyObject *__pyx_v_4lupa_5_lupa_exc_info = 0; static PyObject *__pyx_v_4lupa_5_lupa_Mapping = 0; static PyObject *__pyx_v_4lupa_5_lupa_wraps = 0; static PyObject *__pyx_v_4lupa_5_lupa_builtins = 0; static int __pyx_v_4lupa_5_lupa_IS_PY2; static luaL_Reg *__pyx_v_4lupa_5_lupa_py_object_lib; static luaL_Reg *__pyx_v_4lupa_5_lupa_py_lib; static CYTHON_INLINE int __pyx_f_4lupa_5_lupa_lock_lock(struct __pyx_obj_4lupa_5_lupa_FastRLock *, long, int); /*proto*/ static int __pyx_f_4lupa_5_lupa__acquire_lock(struct __pyx_obj_4lupa_5_lupa_FastRLock *, long, int); /*proto*/ static CYTHON_INLINE void __pyx_f_4lupa_5_lupa_unlock_lock(struct __pyx_obj_4lupa_5_lupa_FastRLock *); /*proto*/ static PyObject *__pyx_f_4lupa_5_lupa__fix_args_kwargs(PyObject *); /*proto*/ static CYTHON_INLINE int __pyx_f_4lupa_5_lupa_lock_runtime(struct __pyx_obj_4lupa_5_lupa_LuaRuntime *); /*proto*/ static CYTHON_INLINE void __pyx_f_4lupa_5_lupa_unlock_runtime(struct __pyx_obj_4lupa_5_lupa_LuaRuntime *); /*proto*/ static struct __pyx_obj_4lupa_5_lupa__LuaObject *__pyx_f_4lupa_5_lupa_new_lua_object(struct __pyx_obj_4lupa_5_lupa_LuaRuntime *, lua_State *, int); /*proto*/ static void __pyx_f_4lupa_5_lupa_init_lua_object(struct __pyx_obj_4lupa_5_lupa__LuaObject *, struct __pyx_obj_4lupa_5_lupa_LuaRuntime *, lua_State *, int); /*proto*/ static PyObject *__pyx_f_4lupa_5_lupa_lua_object_repr(lua_State *, PyObject *); /*proto*/ static struct __pyx_obj_4lupa_5_lupa__LuaTable *__pyx_f_4lupa_5_lupa_new_lua_table(struct __pyx_obj_4lupa_5_lupa_LuaRuntime *, lua_State *, int); /*proto*/ static struct __pyx_obj_4lupa_5_lupa__LuaFunction *__pyx_f_4lupa_5_lupa_new_lua_function(struct __pyx_obj_4lupa_5_lupa_LuaRuntime *, lua_State *, int); /*proto*/ static struct __pyx_obj_4lupa_5_lupa__LuaCoroutineFunction *__pyx_f_4lupa_5_lupa_new_lua_coroutine_function(struct __pyx_obj_4lupa_5_lupa_LuaRuntime *, lua_State *, int); /*proto*/ static struct __pyx_obj_4lupa_5_lupa__LuaThread *__pyx_f_4lupa_5_lupa_new_lua_thread(struct __pyx_obj_4lupa_5_lupa_LuaRuntime *, lua_State *, int); /*proto*/ static struct __pyx_obj_4lupa_5_lupa__LuaObject *__pyx_f_4lupa_5_lupa_new_lua_thread_or_function(struct __pyx_obj_4lupa_5_lupa_LuaRuntime *, lua_State *, int); /*proto*/ static PyObject *__pyx_f_4lupa_5_lupa_resume_lua_thread(struct __pyx_obj_4lupa_5_lupa__LuaThread *, PyObject *); /*proto*/ static int __pyx_f_4lupa_5_lupa_py_asfunc_call(lua_State *); /*proto*/ static struct __pyx_t_4lupa_5_lupa_py_object *__pyx_f_4lupa_5_lupa_unpack_wrapped_pyfunction(lua_State *, int); /*proto*/ static PyObject *__pyx_f_4lupa_5_lupa_py_from_lua(struct __pyx_obj_4lupa_5_lupa_LuaRuntime *, lua_State *, int); /*proto*/ static struct __pyx_t_4lupa_5_lupa_py_object *__pyx_f_4lupa_5_lupa_unpack_userdata(lua_State *, int); /*proto*/ static int __pyx_f_4lupa_5_lupa_py_function_result_to_lua(struct __pyx_obj_4lupa_5_lupa_LuaRuntime *, lua_State *, PyObject *); /*proto*/ static int __pyx_f_4lupa_5_lupa_py_to_lua(struct __pyx_obj_4lupa_5_lupa_LuaRuntime *, lua_State *, PyObject *, struct __pyx_opt_args_4lupa_5_lupa_py_to_lua *__pyx_optional_args); /*proto*/ static int __pyx_f_4lupa_5_lupa_push_encoded_unicode_string(struct __pyx_obj_4lupa_5_lupa_LuaRuntime *, lua_State *, PyObject *); /*proto*/ static int __pyx_f_4lupa_5_lupa_py_to_lua_custom(struct __pyx_obj_4lupa_5_lupa_LuaRuntime *, lua_State *, PyObject *, int); /*proto*/ static CYTHON_INLINE int __pyx_f_4lupa_5_lupa__isascii(unsigned char *); /*proto*/ static PyObject *__pyx_f_4lupa_5_lupa__asciiOrNone(PyObject *); /*proto*/ static int __pyx_f_4lupa_5_lupa_raise_lua_error(struct __pyx_obj_4lupa_5_lupa_LuaRuntime *, lua_State *, int); /*proto*/ static PyObject *__pyx_f_4lupa_5_lupa_build_lua_error_message(struct __pyx_obj_4lupa_5_lupa_LuaRuntime *, lua_State *, PyObject *, int); /*proto*/ static PyObject *__pyx_f_4lupa_5_lupa_run_lua(struct __pyx_obj_4lupa_5_lupa_LuaRuntime *, PyObject *, PyObject *); /*proto*/ static PyObject *__pyx_f_4lupa_5_lupa_call_lua(struct __pyx_obj_4lupa_5_lupa_LuaRuntime *, lua_State *, PyObject *); /*proto*/ static PyObject *__pyx_f_4lupa_5_lupa_execute_lua_call(struct __pyx_obj_4lupa_5_lupa_LuaRuntime *, lua_State *, Py_ssize_t); /*proto*/ static int __pyx_f_4lupa_5_lupa_push_lua_arguments(struct __pyx_obj_4lupa_5_lupa_LuaRuntime *, lua_State *, PyObject *, struct __pyx_opt_args_4lupa_5_lupa_push_lua_arguments *__pyx_optional_args); /*proto*/ static CYTHON_INLINE PyObject *__pyx_f_4lupa_5_lupa_unpack_lua_results(struct __pyx_obj_4lupa_5_lupa_LuaRuntime *, lua_State *); /*proto*/ static PyObject *__pyx_f_4lupa_5_lupa_unpack_multiple_lua_results(struct __pyx_obj_4lupa_5_lupa_LuaRuntime *, lua_State *, int); /*proto*/ static int __pyx_f_4lupa_5_lupa_decref_with_gil(struct __pyx_t_4lupa_5_lupa_py_object *, lua_State *); /*proto*/ static int __pyx_f_4lupa_5_lupa_py_object_gc(lua_State *); /*proto*/ static int __pyx_f_4lupa_5_lupa_call_python(struct __pyx_obj_4lupa_5_lupa_LuaRuntime *, lua_State *, struct __pyx_t_4lupa_5_lupa_py_object *); /*proto*/ static int __pyx_f_4lupa_5_lupa_py_call_with_gil(lua_State *, struct __pyx_t_4lupa_5_lupa_py_object *); /*proto*/ static int __pyx_f_4lupa_5_lupa_py_object_call(lua_State *); /*proto*/ static int __pyx_f_4lupa_5_lupa_py_str_with_gil(lua_State *, struct __pyx_t_4lupa_5_lupa_py_object *); /*proto*/ static int __pyx_f_4lupa_5_lupa_py_object_str(lua_State *); /*proto*/ static int __pyx_f_4lupa_5_lupa_getitem_for_lua(struct __pyx_obj_4lupa_5_lupa_LuaRuntime *, lua_State *, struct __pyx_t_4lupa_5_lupa_py_object *, int); /*proto*/ static int __pyx_f_4lupa_5_lupa_setitem_for_lua(struct __pyx_obj_4lupa_5_lupa_LuaRuntime *, lua_State *, struct __pyx_t_4lupa_5_lupa_py_object *, int, int); /*proto*/ static int __pyx_f_4lupa_5_lupa_getattr_for_lua(struct __pyx_obj_4lupa_5_lupa_LuaRuntime *, lua_State *, struct __pyx_t_4lupa_5_lupa_py_object *, int); /*proto*/ static int __pyx_f_4lupa_5_lupa_setattr_for_lua(struct __pyx_obj_4lupa_5_lupa_LuaRuntime *, lua_State *, struct __pyx_t_4lupa_5_lupa_py_object *, int, int); /*proto*/ static int __pyx_f_4lupa_5_lupa_py_object_getindex_with_gil(lua_State *, struct __pyx_t_4lupa_5_lupa_py_object *); /*proto*/ static int __pyx_f_4lupa_5_lupa_py_object_getindex(lua_State *); /*proto*/ static int __pyx_f_4lupa_5_lupa_py_object_setindex_with_gil(lua_State *, struct __pyx_t_4lupa_5_lupa_py_object *); /*proto*/ static int __pyx_f_4lupa_5_lupa_py_object_setindex(lua_State *); /*proto*/ static CYTHON_INLINE struct __pyx_t_4lupa_5_lupa_py_object *__pyx_f_4lupa_5_lupa_unpack_single_python_argument_or_jump(lua_State *); /*proto*/ static struct __pyx_t_4lupa_5_lupa_py_object *__pyx_f_4lupa_5_lupa_unwrap_lua_object(lua_State *, int); /*proto*/ static int __pyx_f_4lupa_5_lupa_py_wrap_object_protocol_with_gil(lua_State *, struct __pyx_t_4lupa_5_lupa_py_object *, int); /*proto*/ static int __pyx_f_4lupa_5_lupa_py_wrap_object_protocol(lua_State *, int); /*proto*/ static int __pyx_f_4lupa_5_lupa_py_as_attrgetter(lua_State *); /*proto*/ static int __pyx_f_4lupa_5_lupa_py_as_itemgetter(lua_State *); /*proto*/ static int __pyx_f_4lupa_5_lupa_py_as_function(lua_State *); /*proto*/ static int __pyx_f_4lupa_5_lupa_py_iter(lua_State *); /*proto*/ static int __pyx_f_4lupa_5_lupa_py_iterex(lua_State *); /*proto*/ static int __pyx_f_4lupa_5_lupa_py_enumerate(lua_State *); /*proto*/ static int __pyx_f_4lupa_5_lupa_py_enumerate_with_gil(lua_State *, struct __pyx_t_4lupa_5_lupa_py_object *, double); /*proto*/ static int __pyx_f_4lupa_5_lupa_py_iter_with_gil(lua_State *, struct __pyx_t_4lupa_5_lupa_py_object *, int); /*proto*/ static int __pyx_f_4lupa_5_lupa_py_push_iterator(struct __pyx_obj_4lupa_5_lupa_LuaRuntime *, lua_State *, PyObject *, int, lua_Number); /*proto*/ static int __pyx_f_4lupa_5_lupa_py_iter_next(lua_State *); /*proto*/ static int __pyx_f_4lupa_5_lupa_py_iter_next_with_gil(lua_State *, struct __pyx_t_4lupa_5_lupa_py_object *); /*proto*/ static void __pyx_f_4lupa_5_lupa_luaL_setfuncs(lua_State *, luaL_Reg const *, int); /*proto*/ static int __pyx_f_4lupa_5_lupa_libsize(luaL_Reg const *); /*proto*/ static char const *__pyx_f_4lupa_5_lupa_luaL_findtable(lua_State *, int, char const *, int); /*proto*/ static void __pyx_f_4lupa_5_lupa_luaL_pushmodule(lua_State *, char const *, int); /*proto*/ static void __pyx_f_4lupa_5_lupa_luaL_openlib(lua_State *, char const *, luaL_Reg const *, int); /*proto*/ #define __Pyx_MODULE_NAME "lupa._lupa" extern int __pyx_module_is_main_lupa___lupa; int __pyx_module_is_main_lupa___lupa = 0; /* Implementation of 'lupa._lupa' */ static PyObject *__pyx_builtin_ImportError; static PyObject *__pyx_builtin_RuntimeError; static PyObject *__pyx_builtin_TypeError; static PyObject *__pyx_builtin_ValueError; static PyObject *__pyx_builtin_eval; static PyObject *__pyx_builtin_range; static PyObject *__pyx_builtin_UnicodeDecodeError; static PyObject *__pyx_builtin_object; static PyObject *__pyx_builtin_AttributeError; static PyObject *__pyx_builtin_StopIteration; static PyObject *__pyx_builtin_MemoryError; static PyObject *__pyx_builtin_BaseException; static PyObject *__pyx_builtin_enumerate; static PyObject *__pyx_builtin_KeyError; static const char __pyx_k_L[] = "L"; static const char __pyx_k_i[] = "i"; static const char __pyx_k_t[] = "t"; static const char __pyx_k_v[] = "v"; static const char __pyx_k_co[] = "co"; static const char __pyx_k_tb[] = "tb"; static const char __pyx_k__22[] = "__"; static const char __pyx_k_all[] = "__all__"; static const char __pyx_k_arg[] = "arg"; static const char __pyx_k_doc[] = "__doc__"; static const char __pyx_k_err[] = "err"; static const char __pyx_k_key[] = "key"; static const char __pyx_k_obj[] = "obj"; static const char __pyx_k_pop[] = "pop"; static const char __pyx_k_sys[] = "sys"; static const char __pyx_k_args[] = "args"; static const char __pyx_k_eval[] = "eval"; static const char __pyx_k_exit[] = "__exit__"; static const char __pyx_k_func[] = "func"; static const char __pyx_k_keys[] = "keys"; static const char __pyx_k_main[] = "__main__"; static const char __pyx_k_meth[] = "meth"; static const char __pyx_k_name[] = "__name__"; static const char __pyx_k_none[] = "none"; static const char __pyx_k_self[] = "self"; static const char __pyx_k_send[] = "send"; static const char __pyx_k_size[] = "size"; static const char __pyx_k_test[] = "__test__"; static const char __pyx_k_what[] = "what"; static const char __pyx_k_wrap[] = "wrap"; static const char __pyx_k_UTF_8[] = "UTF-8"; static const char __pyx_k_enter[] = "__enter__"; static const char __pyx_k_error[] = "error"; static const char __pyx_k_items[] = "items"; static const char __pyx_k_ltype[] = "ltype"; static const char __pyx_k_range[] = "range"; static const char __pyx_k_table[] = "table"; static const char __pyx_k_value[] = "value"; static const char __pyx_k_wraps[] = "wraps"; static const char __pyx_k_append[] = "append"; static const char __pyx_k_import[] = "__import__"; static const char __pyx_k_kwargs[] = "kwargs"; static const char __pyx_k_module[] = "__module__"; static const char __pyx_k_name_2[] = "name"; static const char __pyx_k_object[] = "object"; static const char __pyx_k_oldtop[] = "oldtop"; static const char __pyx_k_reduce[] = "__reduce__"; static const char __pyx_k_return[] = "return "; static const char __pyx_k_status[] = "status"; static const char __pyx_k_thread[] = "thread"; static const char __pyx_k_values[] = "values"; static const char __pyx_k_Mapping[] = "Mapping"; static const char __pyx_k_Py_None[] = "Py_None"; static const char __pyx_k_acquire[] = "acquire"; static const char __pyx_k_builtin[] = "__builtin__"; static const char __pyx_k_compile[] = "compile"; static const char __pyx_k_delattr[] = "__delattr__"; static const char __pyx_k_execute[] = "execute"; static const char __pyx_k_getattr[] = "__getattr__"; static const char __pyx_k_getitem[] = "__getitem__"; static const char __pyx_k_globals[] = "globals"; static const char __pyx_k_old_top[] = "old_top"; static const char __pyx_k_prepare[] = "__prepare__"; static const char __pyx_k_release[] = "release"; static const char __pyx_k_require[] = "require"; static const char __pyx_k_setattr[] = "__setattr__"; static const char __pyx_k_wrapper[] = "wrapper"; static const char __pyx_k_KeyError[] = "KeyError"; static const char __pyx_k_LuaError[] = "LuaError"; static const char __pyx_k_blocking[] = "blocking"; static const char __pyx_k_builtins[] = "builtins"; static const char __pyx_k_encoding[] = "encoding"; static const char __pyx_k_exc_info[] = "exc_info"; static const char __pyx_k_function[] = "function"; static const char __pyx_k_getstate[] = "__getstate__"; static const char __pyx_k_is_owned[] = "_is_owned"; static const char __pyx_k_lua_code[] = "lua_code"; static const char __pyx_k_lua_type[] = "lua_type"; static const char __pyx_k_qualname[] = "__qualname__"; static const char __pyx_k_setstate[] = "__setstate__"; static const char __pyx_k_userdata[] = "userdata"; static const char __pyx_k_LuaIter_r[] = "LuaIter(%r)"; static const char __pyx_k_TypeError[] = "TypeError"; static const char __pyx_k_coroutine[] = "coroutine"; static const char __pyx_k_enumerate[] = "enumerate"; static const char __pyx_k_functools[] = "functools"; static const char __pyx_k_iteritems[] = "iteritems"; static const char __pyx_k_metaclass[] = "__metaclass__"; static const char __pyx_k_pyx_state[] = "__pyx_state"; static const char __pyx_k_reduce_ex[] = "__reduce_ex__"; static const char __pyx_k_LuaRuntime[] = "LuaRuntime"; static const char __pyx_k_ValueError[] = "ValueError"; static const char __pyx_k_lua_object[] = "lua_object"; static const char __pyx_k_lupa__lupa[] = "lupa._lupa"; static const char __pyx_k_modulename[] = "modulename"; static const char __pyx_k_pyx_vtable[] = "__pyx_vtable__"; static const char __pyx_k_table_from[] = "table_from"; static const char __pyx_k_ImportError[] = "ImportError"; static const char __pyx_k_MemoryError[] = "MemoryError"; static const char __pyx_k_collections[] = "collections"; static const char __pyx_k_RuntimeError[] = "RuntimeError"; static const char __pyx_k_stringsource[] = "stringsource"; static const char __pyx_k_BaseException[] = "BaseException"; static const char __pyx_k_LuaTable_keys[] = "_LuaTable.keys"; static const char __pyx_k_StopIteration[] = "StopIteration"; static const char __pyx_k_as_attrgetter[] = "as_attrgetter"; static const char __pyx_k_as_itemgetter[] = "as_itemgetter"; static const char __pyx_k_lua_type_name[] = "lua_type_name"; static const char __pyx_k_lupa_lock_pxi[] = "lupa/lock.pxi"; static const char __pyx_k_reduce_cython[] = "__reduce_cython__"; static const char __pyx_k_register_eval[] = "register_eval"; static const char __pyx_k_AttributeError[] = "AttributeError"; static const char __pyx_k_LuaSyntaxError[] = "LuaSyntaxError"; static const char __pyx_k_LuaTable_items[] = "_LuaTable.items"; static const char __pyx_k_LuaThread_send[] = "_LuaThread.send"; static const char __pyx_k_lost_reference[] = "lost reference"; static const char __pyx_k_lupa__lupa_pyx[] = "lupa/_lupa.pyx"; static const char __pyx_k_LuaRuntime_eval[] = "LuaRuntime.eval"; static const char __pyx_k_LuaTable_values[] = "_LuaTable.values"; static const char __pyx_k_setstate_cython[] = "__setstate_cython__"; static const char __pyx_k_source_encoding[] = "source_encoding"; static const char __pyx_k_FastRLock___exit[] = "FastRLock.__exit__"; static const char __pyx_k_LuaRuntime_table[] = "LuaRuntime.table"; static const char __pyx_k_attribute_filter[] = "attribute_filter"; static const char __pyx_k_FastRLock___enter[] = "FastRLock.__enter__"; static const char __pyx_k_FastRLock_acquire[] = "FastRLock.acquire"; static const char __pyx_k_FastRLock_release[] = "FastRLock.release"; static const char __pyx_k_register_builtins[] = "register_builtins"; static const char __pyx_k_unpacks_lua_table[] = "unpacks_lua_table"; static const char __pyx_k_LuaRuntime_compile[] = "LuaRuntime.compile"; static const char __pyx_k_LuaRuntime_execute[] = "LuaRuntime.execute"; static const char __pyx_k_LuaRuntime_globals[] = "LuaRuntime.globals"; static const char __pyx_k_LuaRuntime_require[] = "LuaRuntime.require"; static const char __pyx_k_UnicodeDecodeError[] = "UnicodeDecodeError"; static const char __pyx_k_attribute_handlers[] = "attribute_handlers"; static const char __pyx_k_cline_in_traceback[] = "cline_in_traceback"; static const char __pyx_k_FastRLock__is_owned[] = "FastRLock._is_owned"; static const char __pyx_k_globals_not_defined[] = "globals not defined"; static const char __pyx_k_not_a_python_object[] = "not a python object"; static const char __pyx_k_error_loading_code_s[] = "error loading code: %s"; static const char __pyx_k_LuaFunction_coroutine[] = "_LuaFunction.coroutine"; static const char __pyx_k_LuaRuntime_table_from[] = "LuaRuntime.table_from"; static const char __pyx_k_expected_string_got_s[] = "expected string, got %s"; static const char __pyx_k_require_is_not_defined[] = "require is not defined"; static const char __pyx_k_unpack_returned_tuples[] = "unpack_returned_tuples"; static const char __pyx_k_LuaIter___reduce_cython[] = "_LuaIter.__reduce_cython__"; static const char __pyx_k_LuaTable___reduce_cython[] = "_LuaTable.__reduce_cython__"; static const char __pyx_k_Syntax_error_in_Lua_code[] = "Syntax error in Lua code.\n "; static const char __pyx_k_error_during_Python_call[] = "error during Python call"; static const char __pyx_k_unpacks_lua_table_method[] = "unpacks_lua_table_method"; static const char __pyx_k_FastRLock___reduce_cython[] = "FastRLock.__reduce_cython__"; static const char __pyx_k_LuaIter___setstate_cython[] = "_LuaIter.__setstate_cython__"; static const char __pyx_k_LuaObject___reduce_cython[] = "_LuaObject.__reduce_cython__"; static const char __pyx_k_LuaThread___reduce_cython[] = "_LuaThread.__reduce_cython__"; static const char __pyx_k_LuaRuntime___reduce_cython[] = "LuaRuntime.__reduce_cython__"; static const char __pyx_k_LuaTable___setstate_cython[] = "_LuaTable.__setstate_cython__"; static const char __pyx_k_error_creating_an_iterator[] = "error creating an iterator"; static const char __pyx_k_failed_to_convert_s_object[] = "failed to convert %s object"; static const char __pyx_k_FastRLock___setstate_cython[] = "FastRLock.__setstate_cython__"; static const char __pyx_k_LuaFunction___reduce_cython[] = "_LuaFunction.__reduce_cython__"; static const char __pyx_k_LuaObject___setstate_cython[] = "_LuaObject.__setstate_cython__"; static const char __pyx_k_LuaThread___setstate_cython[] = "_LuaThread.__setstate_cython__"; static const char __pyx_k_modulename_must_be_a_string[] = "modulename must be a string"; static const char __pyx_k_LuaRuntime___setstate_cython[] = "LuaRuntime.__setstate_cython__"; static const char __pyx_k_Lua_object_is_not_a_function[] = "Lua object is not a function"; static const char __pyx_k_error_during_Python_str_call[] = "error during Python str() call"; static const char __pyx_k_Failed_to_acquire_thread_lock[] = "Failed to acquire thread lock"; static const char __pyx_k_LuaFunction___setstate_cython[] = "_LuaFunction.__setstate_cython__"; static const char __pyx_k_A_fast_Python_wrapper_around_Lu[] = "\nA fast Python wrapper around Lua and LuaJIT2.\n"; static const char __pyx_k_LuaCoroutineFunction___reduce_c[] = "_LuaCoroutineFunction.__reduce_cython__"; static const char __pyx_k_LuaCoroutineFunction___setstate[] = "_LuaCoroutineFunction.__setstate_cython__"; static const char __pyx_k_PyProtocolWrapper___reduce_cyth[] = "_PyProtocolWrapper.__reduce_cython__"; static const char __pyx_k_PyProtocolWrapper___setstate_cy[] = "_PyProtocolWrapper.__setstate_cython__"; static const char __pyx_k_cannot_release_un_acquired_lock[] = "cannot release un-acquired lock"; static const char __pyx_k_error_creating_an_iterator_with[] = "error creating an iterator with enumerate()"; static const char __pyx_k_iteration_is_only_supported_for[] = "iteration is only supported for tables"; static const char __pyx_k_self__state_cannot_be_converted[] = "self._state cannot be converted to a Python object for pickling"; static const char __pyx_k_unpacks_lua_table_method_locals[] = "unpacks_lua_table_method..wrapper"; static const char __pyx_k_Base_class_for_errors_in_the_Lua[] = "Base class for errors in the Lua runtime.\n "; static const char __pyx_k_Failed_to_initialise_Lua_runtime[] = "Failed to initialise Lua runtime"; static const char __pyx_k_Type_cannot_be_instantiated_from[] = "Type cannot be instantiated from Python"; static const char __pyx_k_Type_cannot_be_instantiated_manu[] = "Type cannot be instantiated manually"; static const char __pyx_k_attribute_filter_and_attribute_h[] = "attribute_filter and attribute_handlers are mutually exclusive"; static const char __pyx_k_attribute_filter_must_be_callabl[] = "attribute_filter must be callable"; static const char __pyx_k_attribute_handlers_must_be_a_seq[] = "attribute_handlers must be a sequence of two callables"; static const char __pyx_k_byte_string_input_has_unknown_en[] = "byte string input has unknown encoding, only ASCII is allowed"; static const char __pyx_k_can_t_send_non_None_value_to_a_j[] = "can't send non-None value to a just-started generator"; static const char __pyx_k_cannot_iterate_over_non_table_fo[] = "cannot iterate over non-table (found %r)"; static const char __pyx_k_cannot_mix_objects_from_differen[] = "cannot mix objects from different Lua runtimes"; static const char __pyx_k_error_reading_Python_attribute_i[] = "error reading Python attribute/item"; static const char __pyx_k_error_while_calling_next_iterato[] = "error while calling next(iterator)"; static const char __pyx_k_error_while_cleaning_up_a_Python[] = "error while cleaning up a Python object"; static const char __pyx_k_error_writing_Python_attribute_i[] = "error writing Python attribute/item"; static const char __pyx_k_failed_to_convert_argument_at_in[] = "failed to convert argument at index %d"; static const char __pyx_k_item_attribute_access_not_suppor[] = "item/attribute access not supported on functions"; static const char __pyx_k_no_default___reduce___due_to_non[] = "no default __reduce__ due to non-trivial __cinit__"; static const char __pyx_k_self__co_state_self__state_canno[] = "self._co_state,self._state cannot be converted to a Python object for pickling"; static const char __pyx_k_unpacks_lua_table_locals_wrapper[] = "unpacks_lua_table..wrapper"; static PyObject *__pyx_n_s_AttributeError; static PyObject *__pyx_n_s_BaseException; static PyObject *__pyx_kp_s_Base_class_for_errors_in_the_Lua; static PyObject *__pyx_kp_s_Failed_to_acquire_thread_lock; static PyObject *__pyx_kp_s_Failed_to_initialise_Lua_runtime; static PyObject *__pyx_n_s_FastRLock___enter; static PyObject *__pyx_n_s_FastRLock___exit; static PyObject *__pyx_n_s_FastRLock___reduce_cython; static PyObject *__pyx_n_s_FastRLock___setstate_cython; static PyObject *__pyx_n_s_FastRLock__is_owned; static PyObject *__pyx_n_s_FastRLock_acquire; static PyObject *__pyx_n_s_FastRLock_release; static PyObject *__pyx_n_s_ImportError; static PyObject *__pyx_n_s_KeyError; static PyObject *__pyx_n_s_L; static PyObject *__pyx_n_s_LuaCoroutineFunction___reduce_c; static PyObject *__pyx_n_s_LuaCoroutineFunction___setstate; static PyObject *__pyx_n_s_LuaError; static PyObject *__pyx_n_s_LuaFunction___reduce_cython; static PyObject *__pyx_n_s_LuaFunction___setstate_cython; static PyObject *__pyx_n_s_LuaFunction_coroutine; static PyObject *__pyx_n_s_LuaIter___reduce_cython; static PyObject *__pyx_n_s_LuaIter___setstate_cython; static PyObject *__pyx_kp_u_LuaIter_r; static PyObject *__pyx_n_s_LuaObject___reduce_cython; static PyObject *__pyx_n_s_LuaObject___setstate_cython; static PyObject *__pyx_n_s_LuaRuntime; static PyObject *__pyx_n_s_LuaRuntime___reduce_cython; static PyObject *__pyx_n_s_LuaRuntime___setstate_cython; static PyObject *__pyx_n_s_LuaRuntime_compile; static PyObject *__pyx_n_s_LuaRuntime_eval; static PyObject *__pyx_n_s_LuaRuntime_execute; static PyObject *__pyx_n_s_LuaRuntime_globals; static PyObject *__pyx_n_s_LuaRuntime_require; static PyObject *__pyx_n_s_LuaRuntime_table; static PyObject *__pyx_n_s_LuaRuntime_table_from; static PyObject *__pyx_n_s_LuaSyntaxError; static PyObject *__pyx_n_s_LuaTable___reduce_cython; static PyObject *__pyx_n_s_LuaTable___setstate_cython; static PyObject *__pyx_n_s_LuaTable_items; static PyObject *__pyx_n_s_LuaTable_keys; static PyObject *__pyx_n_s_LuaTable_values; static PyObject *__pyx_n_s_LuaThread___reduce_cython; static PyObject *__pyx_n_s_LuaThread___setstate_cython; static PyObject *__pyx_n_s_LuaThread_send; static PyObject *__pyx_kp_s_Lua_object_is_not_a_function; static PyObject *__pyx_n_s_Mapping; static PyObject *__pyx_n_s_MemoryError; static PyObject *__pyx_n_s_PyProtocolWrapper___reduce_cyth; static PyObject *__pyx_n_s_PyProtocolWrapper___setstate_cy; static PyObject *__pyx_n_b_Py_None; static PyObject *__pyx_n_s_RuntimeError; static PyObject *__pyx_n_s_StopIteration; static PyObject *__pyx_kp_s_Syntax_error_in_Lua_code; static PyObject *__pyx_n_s_TypeError; static PyObject *__pyx_kp_s_Type_cannot_be_instantiated_from; static PyObject *__pyx_kp_s_Type_cannot_be_instantiated_manu; static PyObject *__pyx_kp_b_UTF_8; static PyObject *__pyx_kp_s_UTF_8; static PyObject *__pyx_n_s_UnicodeDecodeError; static PyObject *__pyx_n_s_ValueError; static PyObject *__pyx_n_b__22; static PyObject *__pyx_n_u__22; static PyObject *__pyx_n_s_acquire; static PyObject *__pyx_n_s_all; static PyObject *__pyx_n_s_append; static PyObject *__pyx_n_s_arg; static PyObject *__pyx_n_s_args; static PyObject *__pyx_n_s_as_attrgetter; static PyObject *__pyx_n_s_as_itemgetter; static PyObject *__pyx_n_s_attribute_filter; static PyObject *__pyx_kp_s_attribute_filter_and_attribute_h; static PyObject *__pyx_kp_s_attribute_filter_must_be_callabl; static PyObject *__pyx_n_s_attribute_handlers; static PyObject *__pyx_kp_s_attribute_handlers_must_be_a_seq; static PyObject *__pyx_n_s_blocking; static PyObject *__pyx_n_s_builtin; static PyObject *__pyx_n_b_builtins; static PyObject *__pyx_n_s_builtins; static PyObject *__pyx_kp_s_byte_string_input_has_unknown_en; static PyObject *__pyx_kp_s_can_t_send_non_None_value_to_a_j; static PyObject *__pyx_kp_s_cannot_iterate_over_non_table_fo; static PyObject *__pyx_kp_s_cannot_mix_objects_from_differen; static PyObject *__pyx_kp_s_cannot_release_un_acquired_lock; static PyObject *__pyx_n_s_cline_in_traceback; static PyObject *__pyx_n_s_co; static PyObject *__pyx_n_s_collections; static PyObject *__pyx_n_s_compile; static PyObject *__pyx_n_s_coroutine; static PyObject *__pyx_n_s_delattr; static PyObject *__pyx_n_s_doc; static PyObject *__pyx_n_s_encoding; static PyObject *__pyx_n_s_enter; static PyObject *__pyx_n_s_enumerate; static PyObject *__pyx_n_s_err; static PyObject *__pyx_n_s_error; static PyObject *__pyx_kp_b_error_creating_an_iterator; static PyObject *__pyx_kp_b_error_creating_an_iterator_with; static PyObject *__pyx_kp_b_error_during_Python_call; static PyObject *__pyx_kp_b_error_during_Python_str_call; static PyObject *__pyx_kp_u_error_loading_code_s; static PyObject *__pyx_kp_b_error_reading_Python_attribute_i; static PyObject *__pyx_kp_b_error_while_calling_next_iterato; static PyObject *__pyx_kp_b_error_while_cleaning_up_a_Python; static PyObject *__pyx_kp_b_error_writing_Python_attribute_i; static PyObject *__pyx_n_b_eval; static PyObject *__pyx_n_s_eval; static PyObject *__pyx_n_s_exc_info; static PyObject *__pyx_n_s_execute; static PyObject *__pyx_n_s_exit; static PyObject *__pyx_kp_s_expected_string_got_s; static PyObject *__pyx_kp_s_failed_to_convert_argument_at_in; static PyObject *__pyx_kp_s_failed_to_convert_s_object; static PyObject *__pyx_n_s_func; static PyObject *__pyx_n_s_function; static PyObject *__pyx_n_s_functools; static PyObject *__pyx_n_s_getattr; static PyObject *__pyx_n_s_getitem; static PyObject *__pyx_n_s_getstate; static PyObject *__pyx_n_s_globals; static PyObject *__pyx_kp_s_globals_not_defined; static PyObject *__pyx_n_s_i; static PyObject *__pyx_n_s_import; static PyObject *__pyx_n_s_is_owned; static PyObject *__pyx_kp_s_item_attribute_access_not_suppor; static PyObject *__pyx_n_s_items; static PyObject *__pyx_kp_s_iteration_is_only_supported_for; static PyObject *__pyx_n_s_iteritems; static PyObject *__pyx_n_s_key; static PyObject *__pyx_n_s_keys; static PyObject *__pyx_n_s_kwargs; static PyObject *__pyx_kp_s_lost_reference; static PyObject *__pyx_n_s_ltype; static PyObject *__pyx_n_s_lua_code; static PyObject *__pyx_n_s_lua_object; static PyObject *__pyx_n_s_lua_type; static PyObject *__pyx_n_s_lua_type_name; static PyObject *__pyx_n_s_lupa__lupa; static PyObject *__pyx_kp_s_lupa__lupa_pyx; static PyObject *__pyx_kp_s_lupa_lock_pxi; static PyObject *__pyx_n_s_main; static PyObject *__pyx_n_s_metaclass; static PyObject *__pyx_n_s_meth; static PyObject *__pyx_n_s_module; static PyObject *__pyx_n_s_modulename; static PyObject *__pyx_kp_s_modulename_must_be_a_string; static PyObject *__pyx_n_s_name; static PyObject *__pyx_n_s_name_2; static PyObject *__pyx_kp_s_no_default___reduce___due_to_non; static PyObject *__pyx_n_b_none; static PyObject *__pyx_kp_s_not_a_python_object; static PyObject *__pyx_n_s_obj; static PyObject *__pyx_n_s_object; static PyObject *__pyx_n_s_old_top; static PyObject *__pyx_n_s_oldtop; static PyObject *__pyx_n_s_pop; static PyObject *__pyx_n_s_prepare; static PyObject *__pyx_n_s_pyx_state; static PyObject *__pyx_n_s_pyx_vtable; static PyObject *__pyx_n_s_qualname; static PyObject *__pyx_n_s_range; static PyObject *__pyx_n_s_reduce; static PyObject *__pyx_n_s_reduce_cython; static PyObject *__pyx_n_s_reduce_ex; static PyObject *__pyx_n_s_register_builtins; static PyObject *__pyx_n_s_register_eval; static PyObject *__pyx_n_s_release; static PyObject *__pyx_n_s_require; static PyObject *__pyx_kp_s_require_is_not_defined; static PyObject *__pyx_kp_b_return; static PyObject *__pyx_n_s_self; static PyObject *__pyx_kp_s_self__co_state_self__state_canno; static PyObject *__pyx_kp_s_self__state_cannot_be_converted; static PyObject *__pyx_n_s_send; static PyObject *__pyx_n_s_setattr; static PyObject *__pyx_n_s_setstate; static PyObject *__pyx_n_s_setstate_cython; static PyObject *__pyx_n_s_size; static PyObject *__pyx_n_s_source_encoding; static PyObject *__pyx_n_s_status; static PyObject *__pyx_kp_s_stringsource; static PyObject *__pyx_n_s_sys; static PyObject *__pyx_n_s_t; static PyObject *__pyx_n_s_table; static PyObject *__pyx_n_s_table_from; static PyObject *__pyx_n_s_tb; static PyObject *__pyx_n_s_test; static PyObject *__pyx_n_s_thread; static PyObject *__pyx_n_s_unpack_returned_tuples; static PyObject *__pyx_n_s_unpacks_lua_table; static PyObject *__pyx_n_s_unpacks_lua_table_locals_wrapper; static PyObject *__pyx_n_s_unpacks_lua_table_method; static PyObject *__pyx_n_s_unpacks_lua_table_method_locals; static PyObject *__pyx_n_s_userdata; static PyObject *__pyx_n_s_v; static PyObject *__pyx_n_s_value; static PyObject *__pyx_n_s_values; static PyObject *__pyx_n_s_what; static PyObject *__pyx_n_s_wrap; static PyObject *__pyx_n_s_wrapper; static PyObject *__pyx_n_s_wraps; static int __pyx_pf_4lupa_5_lupa_9FastRLock___cinit__(struct __pyx_obj_4lupa_5_lupa_FastRLock *__pyx_v_self); /* proto */ static void __pyx_pf_4lupa_5_lupa_9FastRLock_2__dealloc__(struct __pyx_obj_4lupa_5_lupa_FastRLock *__pyx_v_self); /* proto */ static PyObject *__pyx_pf_4lupa_5_lupa_9FastRLock_4acquire(struct __pyx_obj_4lupa_5_lupa_FastRLock *__pyx_v_self, int __pyx_v_blocking); /* proto */ static PyObject *__pyx_pf_4lupa_5_lupa_9FastRLock_6release(struct __pyx_obj_4lupa_5_lupa_FastRLock *__pyx_v_self); /* proto */ static PyObject *__pyx_pf_4lupa_5_lupa_9FastRLock_8__enter__(struct __pyx_obj_4lupa_5_lupa_FastRLock *__pyx_v_self); /* proto */ static PyObject *__pyx_pf_4lupa_5_lupa_9FastRLock_10__exit__(struct __pyx_obj_4lupa_5_lupa_FastRLock *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v_t, CYTHON_UNUSED PyObject *__pyx_v_v, CYTHON_UNUSED PyObject *__pyx_v_tb); /* proto */ static PyObject *__pyx_pf_4lupa_5_lupa_9FastRLock_12_is_owned(struct __pyx_obj_4lupa_5_lupa_FastRLock *__pyx_v_self); /* proto */ static PyObject *__pyx_pf_4lupa_5_lupa_9FastRLock_14__reduce_cython__(CYTHON_UNUSED struct __pyx_obj_4lupa_5_lupa_FastRLock *__pyx_v_self); /* proto */ static PyObject *__pyx_pf_4lupa_5_lupa_9FastRLock_16__setstate_cython__(CYTHON_UNUSED struct __pyx_obj_4lupa_5_lupa_FastRLock *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v___pyx_state); /* proto */ static PyObject *__pyx_pf_4lupa_5_lupa_lua_type(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_obj); /* proto */ static int __pyx_pf_4lupa_5_lupa_10LuaRuntime___cinit__(struct __pyx_obj_4lupa_5_lupa_LuaRuntime *__pyx_v_self, PyObject *__pyx_v_encoding, PyObject *__pyx_v_source_encoding, PyObject *__pyx_v_attribute_filter, PyObject *__pyx_v_attribute_handlers, int __pyx_v_register_eval, int __pyx_v_unpack_returned_tuples, int __pyx_v_register_builtins); /* proto */ static void __pyx_pf_4lupa_5_lupa_10LuaRuntime_2__dealloc__(struct __pyx_obj_4lupa_5_lupa_LuaRuntime *__pyx_v_self); /* proto */ static PyObject *__pyx_pf_4lupa_5_lupa_10LuaRuntime_4eval(struct __pyx_obj_4lupa_5_lupa_LuaRuntime *__pyx_v_self, PyObject *__pyx_v_lua_code, PyObject *__pyx_v_args); /* proto */ static PyObject *__pyx_pf_4lupa_5_lupa_10LuaRuntime_6execute(struct __pyx_obj_4lupa_5_lupa_LuaRuntime *__pyx_v_self, PyObject *__pyx_v_lua_code, PyObject *__pyx_v_args); /* proto */ static PyObject *__pyx_pf_4lupa_5_lupa_10LuaRuntime_8compile(struct __pyx_obj_4lupa_5_lupa_LuaRuntime *__pyx_v_self, PyObject *__pyx_v_lua_code); /* proto */ static PyObject *__pyx_pf_4lupa_5_lupa_10LuaRuntime_10require(struct __pyx_obj_4lupa_5_lupa_LuaRuntime *__pyx_v_self, PyObject *__pyx_v_modulename); /* proto */ static PyObject *__pyx_pf_4lupa_5_lupa_10LuaRuntime_12globals(struct __pyx_obj_4lupa_5_lupa_LuaRuntime *__pyx_v_self); /* proto */ static PyObject *__pyx_pf_4lupa_5_lupa_10LuaRuntime_14table(struct __pyx_obj_4lupa_5_lupa_LuaRuntime *__pyx_v_self, PyObject *__pyx_v_items, PyObject *__pyx_v_kwargs); /* proto */ static PyObject *__pyx_pf_4lupa_5_lupa_10LuaRuntime_16table_from(struct __pyx_obj_4lupa_5_lupa_LuaRuntime *__pyx_v_self, PyObject *__pyx_v_args); /* proto */ static PyObject *__pyx_pf_4lupa_5_lupa_10LuaRuntime_18__reduce_cython__(CYTHON_UNUSED struct __pyx_obj_4lupa_5_lupa_LuaRuntime *__pyx_v_self); /* proto */ static PyObject *__pyx_pf_4lupa_5_lupa_10LuaRuntime_20__setstate_cython__(CYTHON_UNUSED struct __pyx_obj_4lupa_5_lupa_LuaRuntime *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v___pyx_state); /* proto */ static PyObject *__pyx_pf_4lupa_5_lupa_17unpacks_lua_table_wrapper(PyObject *__pyx_self, PyObject *__pyx_v_args); /* proto */ static PyObject *__pyx_pf_4lupa_5_lupa_2unpacks_lua_table(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_func); /* proto */ static PyObject *__pyx_pf_4lupa_5_lupa_24unpacks_lua_table_method_wrapper(PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_args); /* proto */ static PyObject *__pyx_pf_4lupa_5_lupa_4unpacks_lua_table_method(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_meth); /* proto */ static int __pyx_pf_4lupa_5_lupa_10_LuaObject___init__(CYTHON_UNUSED struct __pyx_obj_4lupa_5_lupa__LuaObject *__pyx_v_self); /* proto */ static void __pyx_pf_4lupa_5_lupa_10_LuaObject_2__dealloc__(struct __pyx_obj_4lupa_5_lupa__LuaObject *__pyx_v_self); /* proto */ static PyObject *__pyx_pf_4lupa_5_lupa_10_LuaObject_4__call__(struct __pyx_obj_4lupa_5_lupa__LuaObject *__pyx_v_self, PyObject *__pyx_v_args); /* proto */ static Py_ssize_t __pyx_pf_4lupa_5_lupa_10_LuaObject_6__len__(struct __pyx_obj_4lupa_5_lupa__LuaObject *__pyx_v_self); /* proto */ static int __pyx_pf_4lupa_5_lupa_10_LuaObject_8__nonzero__(CYTHON_UNUSED struct __pyx_obj_4lupa_5_lupa__LuaObject *__pyx_v_self); /* proto */ static PyObject *__pyx_pf_4lupa_5_lupa_10_LuaObject_10__iter__(CYTHON_UNUSED struct __pyx_obj_4lupa_5_lupa__LuaObject *__pyx_v_self); /* proto */ static PyObject *__pyx_pf_4lupa_5_lupa_10_LuaObject_12__repr__(struct __pyx_obj_4lupa_5_lupa__LuaObject *__pyx_v_self); /* proto */ static PyObject *__pyx_pf_4lupa_5_lupa_10_LuaObject_14__str__(struct __pyx_obj_4lupa_5_lupa__LuaObject *__pyx_v_self); /* proto */ static PyObject *__pyx_pf_4lupa_5_lupa_10_LuaObject_16__getattr__(struct __pyx_obj_4lupa_5_lupa__LuaObject *__pyx_v_self, PyObject *__pyx_v_name); /* proto */ static PyObject *__pyx_pf_4lupa_5_lupa_10_LuaObject_18__getitem__(struct __pyx_obj_4lupa_5_lupa__LuaObject *__pyx_v_self, PyObject *__pyx_v_index_or_name); /* proto */ static PyObject *__pyx_pf_4lupa_5_lupa_10_LuaObject_20__reduce_cython__(CYTHON_UNUSED struct __pyx_obj_4lupa_5_lupa__LuaObject *__pyx_v_self); /* proto */ static PyObject *__pyx_pf_4lupa_5_lupa_10_LuaObject_22__setstate_cython__(CYTHON_UNUSED struct __pyx_obj_4lupa_5_lupa__LuaObject *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v___pyx_state); /* proto */ static PyObject *__pyx_pf_4lupa_5_lupa_9_LuaTable___iter__(struct __pyx_obj_4lupa_5_lupa__LuaTable *__pyx_v_self); /* proto */ static PyObject *__pyx_pf_4lupa_5_lupa_9_LuaTable_2keys(struct __pyx_obj_4lupa_5_lupa__LuaTable *__pyx_v_self); /* proto */ static PyObject *__pyx_pf_4lupa_5_lupa_9_LuaTable_4values(struct __pyx_obj_4lupa_5_lupa__LuaTable *__pyx_v_self); /* proto */ static PyObject *__pyx_pf_4lupa_5_lupa_9_LuaTable_6items(struct __pyx_obj_4lupa_5_lupa__LuaTable *__pyx_v_self); /* proto */ static int __pyx_pf_4lupa_5_lupa_9_LuaTable_8__setattr__(struct __pyx_obj_4lupa_5_lupa__LuaTable *__pyx_v_self, PyObject *__pyx_v_name, PyObject *__pyx_v_value); /* proto */ static int __pyx_pf_4lupa_5_lupa_9_LuaTable_10__setitem__(struct __pyx_obj_4lupa_5_lupa__LuaTable *__pyx_v_self, PyObject *__pyx_v_index_or_name, PyObject *__pyx_v_value); /* proto */ static int __pyx_pf_4lupa_5_lupa_9_LuaTable_12__delattr__(struct __pyx_obj_4lupa_5_lupa__LuaTable *__pyx_v_self, PyObject *__pyx_v_item); /* proto */ static int __pyx_pf_4lupa_5_lupa_9_LuaTable_14__delitem__(struct __pyx_obj_4lupa_5_lupa__LuaTable *__pyx_v_self, PyObject *__pyx_v_key); /* proto */ static PyObject *__pyx_pf_4lupa_5_lupa_9_LuaTable_16__reduce_cython__(CYTHON_UNUSED struct __pyx_obj_4lupa_5_lupa__LuaTable *__pyx_v_self); /* proto */ static PyObject *__pyx_pf_4lupa_5_lupa_9_LuaTable_18__setstate_cython__(CYTHON_UNUSED struct __pyx_obj_4lupa_5_lupa__LuaTable *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v___pyx_state); /* proto */ static PyObject *__pyx_pf_4lupa_5_lupa_12_LuaFunction_coroutine(struct __pyx_obj_4lupa_5_lupa__LuaFunction *__pyx_v_self, PyObject *__pyx_v_args); /* proto */ static PyObject *__pyx_pf_4lupa_5_lupa_12_LuaFunction_2__reduce_cython__(CYTHON_UNUSED struct __pyx_obj_4lupa_5_lupa__LuaFunction *__pyx_v_self); /* proto */ static PyObject *__pyx_pf_4lupa_5_lupa_12_LuaFunction_4__setstate_cython__(CYTHON_UNUSED struct __pyx_obj_4lupa_5_lupa__LuaFunction *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v___pyx_state); /* proto */ static PyObject *__pyx_pf_4lupa_5_lupa_21_LuaCoroutineFunction___call__(struct __pyx_obj_4lupa_5_lupa__LuaCoroutineFunction *__pyx_v_self, PyObject *__pyx_v_args); /* proto */ static PyObject *__pyx_pf_4lupa_5_lupa_21_LuaCoroutineFunction_2__reduce_cython__(CYTHON_UNUSED struct __pyx_obj_4lupa_5_lupa__LuaCoroutineFunction *__pyx_v_self); /* proto */ static PyObject *__pyx_pf_4lupa_5_lupa_21_LuaCoroutineFunction_4__setstate_cython__(CYTHON_UNUSED struct __pyx_obj_4lupa_5_lupa__LuaCoroutineFunction *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v___pyx_state); /* proto */ static PyObject *__pyx_pf_4lupa_5_lupa_10_LuaThread___iter__(struct __pyx_obj_4lupa_5_lupa__LuaThread *__pyx_v_self); /* proto */ static PyObject *__pyx_pf_4lupa_5_lupa_10_LuaThread_2__next__(struct __pyx_obj_4lupa_5_lupa__LuaThread *__pyx_v_self); /* proto */ static PyObject *__pyx_pf_4lupa_5_lupa_10_LuaThread_4send(struct __pyx_obj_4lupa_5_lupa__LuaThread *__pyx_v_self, PyObject *__pyx_v_value); /* proto */ static int __pyx_pf_4lupa_5_lupa_10_LuaThread_6__bool__(struct __pyx_obj_4lupa_5_lupa__LuaThread *__pyx_v_self); /* proto */ static PyObject *__pyx_pf_4lupa_5_lupa_10_LuaThread_8__reduce_cython__(CYTHON_UNUSED struct __pyx_obj_4lupa_5_lupa__LuaThread *__pyx_v_self); /* proto */ static PyObject *__pyx_pf_4lupa_5_lupa_10_LuaThread_10__setstate_cython__(CYTHON_UNUSED struct __pyx_obj_4lupa_5_lupa__LuaThread *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v___pyx_state); /* proto */ static int __pyx_pf_4lupa_5_lupa_8_LuaIter___cinit__(struct __pyx_obj_4lupa_5_lupa__LuaIter *__pyx_v_self, struct __pyx_obj_4lupa_5_lupa__LuaObject *__pyx_v_obj, int __pyx_v_what); /* proto */ static void __pyx_pf_4lupa_5_lupa_8_LuaIter_2__dealloc__(struct __pyx_obj_4lupa_5_lupa__LuaIter *__pyx_v_self); /* proto */ static PyObject *__pyx_pf_4lupa_5_lupa_8_LuaIter_4__repr__(struct __pyx_obj_4lupa_5_lupa__LuaIter *__pyx_v_self); /* proto */ static PyObject *__pyx_pf_4lupa_5_lupa_8_LuaIter_6__iter__(struct __pyx_obj_4lupa_5_lupa__LuaIter *__pyx_v_self); /* proto */ static PyObject *__pyx_pf_4lupa_5_lupa_8_LuaIter_8__next__(struct __pyx_obj_4lupa_5_lupa__LuaIter *__pyx_v_self); /* proto */ static PyObject *__pyx_pf_4lupa_5_lupa_8_LuaIter_10__reduce_cython__(CYTHON_UNUSED struct __pyx_obj_4lupa_5_lupa__LuaIter *__pyx_v_self); /* proto */ static PyObject *__pyx_pf_4lupa_5_lupa_8_LuaIter_12__setstate_cython__(CYTHON_UNUSED struct __pyx_obj_4lupa_5_lupa__LuaIter *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v___pyx_state); /* proto */ static int __pyx_pf_4lupa_5_lupa_18_PyProtocolWrapper___cinit__(struct __pyx_obj_4lupa_5_lupa__PyProtocolWrapper *__pyx_v_self); /* proto */ static int __pyx_pf_4lupa_5_lupa_18_PyProtocolWrapper_2__init__(CYTHON_UNUSED struct __pyx_obj_4lupa_5_lupa__PyProtocolWrapper *__pyx_v_self); /* proto */ static PyObject *__pyx_pf_4lupa_5_lupa_18_PyProtocolWrapper_4__reduce_cython__(CYTHON_UNUSED struct __pyx_obj_4lupa_5_lupa__PyProtocolWrapper *__pyx_v_self); /* proto */ static PyObject *__pyx_pf_4lupa_5_lupa_18_PyProtocolWrapper_6__setstate_cython__(CYTHON_UNUSED struct __pyx_obj_4lupa_5_lupa__PyProtocolWrapper *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v___pyx_state); /* proto */ static PyObject *__pyx_pf_4lupa_5_lupa_6as_attrgetter(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_obj); /* proto */ static PyObject *__pyx_pf_4lupa_5_lupa_8as_itemgetter(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_obj); /* proto */ static PyObject *__pyx_tp_new_4lupa_5_lupa_FastRLock(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/ static PyObject *__pyx_tp_new_4lupa_5_lupa_LuaRuntime(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/ static PyObject *__pyx_tp_new_4lupa_5_lupa__LuaObject(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/ static PyObject *__pyx_tp_new_4lupa_5_lupa__LuaTable(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/ static PyObject *__pyx_tp_new_4lupa_5_lupa__LuaFunction(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/ static PyObject *__pyx_tp_new_4lupa_5_lupa__LuaCoroutineFunction(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/ static PyObject *__pyx_tp_new_4lupa_5_lupa__LuaThread(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/ static PyObject *__pyx_tp_new_4lupa_5_lupa__LuaIter(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/ static PyObject *__pyx_tp_new_4lupa_5_lupa__PyProtocolWrapper(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/ static PyObject *__pyx_tp_new_4lupa_5_lupa___pyx_scope_struct__unpacks_lua_table(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/ static PyObject *__pyx_tp_new_4lupa_5_lupa___pyx_scope_struct_1_unpacks_lua_table_method(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/ static __Pyx_CachedCFunction __pyx_umethod_PyList_Type_pop = {0, &__pyx_n_s_pop, 0, 0, 0}; static PyObject *__pyx_int_1; static PyObject *__pyx_tuple_; static PyObject *__pyx_tuple__2; static PyObject *__pyx_tuple__3; static PyObject *__pyx_tuple__4; static PyObject *__pyx_tuple__5; static PyObject *__pyx_tuple__6; static PyObject *__pyx_tuple__7; static PyObject *__pyx_tuple__8; static PyObject *__pyx_tuple__9; static PyObject *__pyx_tuple__10; static PyObject *__pyx_tuple__11; static PyObject *__pyx_tuple__12; static PyObject *__pyx_tuple__13; static PyObject *__pyx_tuple__14; static PyObject *__pyx_tuple__16; static PyObject *__pyx_tuple__18; static PyObject *__pyx_tuple__19; static PyObject *__pyx_tuple__20; static PyObject *__pyx_tuple__21; static PyObject *__pyx_tuple__23; static PyObject *__pyx_tuple__24; static PyObject *__pyx_tuple__25; static PyObject *__pyx_tuple__26; static PyObject *__pyx_tuple__27; static PyObject *__pyx_tuple__28; static PyObject *__pyx_tuple__29; static PyObject *__pyx_tuple__30; static PyObject *__pyx_tuple__31; static PyObject *__pyx_tuple__32; static PyObject *__pyx_tuple__33; static PyObject *__pyx_tuple__34; static PyObject *__pyx_tuple__35; static PyObject *__pyx_tuple__36; static PyObject *__pyx_tuple__37; static PyObject *__pyx_tuple__38; static PyObject *__pyx_tuple__39; static PyObject *__pyx_tuple__40; static PyObject *__pyx_tuple__41; static PyObject *__pyx_tuple__42; static PyObject *__pyx_tuple__43; static PyObject *__pyx_tuple__44; static PyObject *__pyx_tuple__45; static PyObject *__pyx_tuple__47; static PyObject *__pyx_tuple__49; static PyObject *__pyx_tuple__51; static PyObject *__pyx_tuple__53; static PyObject *__pyx_tuple__55; static PyObject *__pyx_tuple__57; static PyObject *__pyx_tuple__59; static PyObject *__pyx_tuple__61; static PyObject *__pyx_tuple__63; static PyObject *__pyx_tuple__65; static PyObject *__pyx_tuple__67; static PyObject *__pyx_tuple__69; static PyObject *__pyx_tuple__71; static PyObject *__pyx_tuple__73; static PyObject *__pyx_tuple__75; static PyObject *__pyx_tuple__77; static PyObject *__pyx_tuple__79; static PyObject *__pyx_tuple__81; static PyObject *__pyx_tuple__83; static PyObject *__pyx_tuple__85; static PyObject *__pyx_tuple__87; static PyObject *__pyx_tuple__89; static PyObject *__pyx_tuple__91; static PyObject *__pyx_tuple__93; static PyObject *__pyx_tuple__95; static PyObject *__pyx_tuple__97; static PyObject *__pyx_tuple__99; static PyObject *__pyx_tuple__101; static PyObject *__pyx_tuple__103; static PyObject *__pyx_tuple__105; static PyObject *__pyx_tuple__107; static PyObject *__pyx_tuple__109; static PyObject *__pyx_tuple__111; static PyObject *__pyx_tuple__113; static PyObject *__pyx_tuple__115; static PyObject *__pyx_tuple__117; static PyObject *__pyx_tuple__119; static PyObject *__pyx_tuple__121; static PyObject *__pyx_tuple__123; static PyObject *__pyx_codeobj__15; static PyObject *__pyx_codeobj__17; static PyObject *__pyx_codeobj__46; static PyObject *__pyx_codeobj__48; static PyObject *__pyx_codeobj__50; static PyObject *__pyx_codeobj__52; static PyObject *__pyx_codeobj__54; static PyObject *__pyx_codeobj__56; static PyObject *__pyx_codeobj__58; static PyObject *__pyx_codeobj__60; static PyObject *__pyx_codeobj__62; static PyObject *__pyx_codeobj__64; static PyObject *__pyx_codeobj__66; static PyObject *__pyx_codeobj__68; static PyObject *__pyx_codeobj__70; static PyObject *__pyx_codeobj__72; static PyObject *__pyx_codeobj__74; static PyObject *__pyx_codeobj__76; static PyObject *__pyx_codeobj__78; static PyObject *__pyx_codeobj__80; static PyObject *__pyx_codeobj__82; static PyObject *__pyx_codeobj__84; static PyObject *__pyx_codeobj__86; static PyObject *__pyx_codeobj__88; static PyObject *__pyx_codeobj__90; static PyObject *__pyx_codeobj__92; static PyObject *__pyx_codeobj__94; static PyObject *__pyx_codeobj__96; static PyObject *__pyx_codeobj__98; static PyObject *__pyx_codeobj__100; static PyObject *__pyx_codeobj__102; static PyObject *__pyx_codeobj__104; static PyObject *__pyx_codeobj__106; static PyObject *__pyx_codeobj__108; static PyObject *__pyx_codeobj__110; static PyObject *__pyx_codeobj__112; static PyObject *__pyx_codeobj__114; static PyObject *__pyx_codeobj__116; static PyObject *__pyx_codeobj__118; static PyObject *__pyx_codeobj__120; static PyObject *__pyx_codeobj__122; static PyObject *__pyx_codeobj__124; /* "lupa/lock.pxi":20 * cdef bint _is_locked # whether the real lock is acquired * * def __cinit__(self): # <<<<<<<<<<<<<< * self._owner = -1 * self._count = 0 */ /* Python wrapper */ static int __pyx_pw_4lupa_5_lupa_9FastRLock_1__cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ static int __pyx_pw_4lupa_5_lupa_9FastRLock_1__cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { int __pyx_r; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__cinit__ (wrapper)", 0); if (unlikely(PyTuple_GET_SIZE(__pyx_args) > 0)) { __Pyx_RaiseArgtupleInvalid("__cinit__", 1, 0, 0, PyTuple_GET_SIZE(__pyx_args)); return -1;} if (unlikely(__pyx_kwds) && unlikely(PyDict_Size(__pyx_kwds) > 0) && unlikely(!__Pyx_CheckKeywordStrings(__pyx_kwds, "__cinit__", 0))) return -1; __pyx_r = __pyx_pf_4lupa_5_lupa_9FastRLock___cinit__(((struct __pyx_obj_4lupa_5_lupa_FastRLock *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static int __pyx_pf_4lupa_5_lupa_9FastRLock___cinit__(struct __pyx_obj_4lupa_5_lupa_FastRLock *__pyx_v_self) { int __pyx_r; __Pyx_RefNannyDeclarations int __pyx_t_1; PyObject *__pyx_t_2; __Pyx_RefNannySetupContext("__cinit__", 0); /* "lupa/lock.pxi":21 * * def __cinit__(self): * self._owner = -1 # <<<<<<<<<<<<<< * self._count = 0 * self._is_locked = False */ __pyx_v_self->_owner = -1L; /* "lupa/lock.pxi":22 * def __cinit__(self): * self._owner = -1 * self._count = 0 # <<<<<<<<<<<<<< * self._is_locked = False * self._pending_requests = 0 */ __pyx_v_self->_count = 0; /* "lupa/lock.pxi":23 * self._owner = -1 * self._count = 0 * self._is_locked = False # <<<<<<<<<<<<<< * self._pending_requests = 0 * self._real_lock = pythread.PyThread_allocate_lock() */ __pyx_v_self->_is_locked = 0; /* "lupa/lock.pxi":24 * self._count = 0 * self._is_locked = False * self._pending_requests = 0 # <<<<<<<<<<<<<< * self._real_lock = pythread.PyThread_allocate_lock() * if self._real_lock is NULL: */ __pyx_v_self->_pending_requests = 0; /* "lupa/lock.pxi":25 * self._is_locked = False * self._pending_requests = 0 * self._real_lock = pythread.PyThread_allocate_lock() # <<<<<<<<<<<<<< * if self._real_lock is NULL: * PyErr_NoMemory() */ __pyx_v_self->_real_lock = PyThread_allocate_lock(); /* "lupa/lock.pxi":26 * self._pending_requests = 0 * self._real_lock = pythread.PyThread_allocate_lock() * if self._real_lock is NULL: # <<<<<<<<<<<<<< * PyErr_NoMemory() * */ __pyx_t_1 = ((__pyx_v_self->_real_lock == NULL) != 0); if (__pyx_t_1) { /* "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 == ((PyObject *)NULL))) __PYX_ERR(1, 27, __pyx_L1_error) /* "lupa/lock.pxi":26 * self._pending_requests = 0 * self._real_lock = pythread.PyThread_allocate_lock() * if self._real_lock is NULL: # <<<<<<<<<<<<<< * PyErr_NoMemory() * */ } /* "lupa/lock.pxi":20 * cdef bint _is_locked # whether the real lock is acquired * * def __cinit__(self): # <<<<<<<<<<<<<< * self._owner = -1 * self._count = 0 */ /* function exit code */ __pyx_r = 0; goto __pyx_L0; __pyx_L1_error:; __Pyx_AddTraceback("lupa._lupa.FastRLock.__cinit__", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = -1; __pyx_L0:; __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "lupa/lock.pxi":29 * PyErr_NoMemory() * * def __dealloc__(self): # <<<<<<<<<<<<<< * if self._real_lock is not NULL: * pythread.PyThread_free_lock(self._real_lock) */ /* Python wrapper */ static void __pyx_pw_4lupa_5_lupa_9FastRLock_3__dealloc__(PyObject *__pyx_v_self); /*proto*/ static void __pyx_pw_4lupa_5_lupa_9FastRLock_3__dealloc__(PyObject *__pyx_v_self) { __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__dealloc__ (wrapper)", 0); __pyx_pf_4lupa_5_lupa_9FastRLock_2__dealloc__(((struct __pyx_obj_4lupa_5_lupa_FastRLock *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); } static void __pyx_pf_4lupa_5_lupa_9FastRLock_2__dealloc__(struct __pyx_obj_4lupa_5_lupa_FastRLock *__pyx_v_self) { __Pyx_RefNannyDeclarations int __pyx_t_1; __Pyx_RefNannySetupContext("__dealloc__", 0); /* "lupa/lock.pxi":30 * * def __dealloc__(self): * if self._real_lock is not NULL: # <<<<<<<<<<<<<< * pythread.PyThread_free_lock(self._real_lock) * self._real_lock = NULL */ __pyx_t_1 = ((__pyx_v_self->_real_lock != NULL) != 0); if (__pyx_t_1) { /* "lupa/lock.pxi":31 * def __dealloc__(self): * if self._real_lock is not NULL: * pythread.PyThread_free_lock(self._real_lock) # <<<<<<<<<<<<<< * self._real_lock = NULL * */ PyThread_free_lock(__pyx_v_self->_real_lock); /* "lupa/lock.pxi":32 * if self._real_lock is not NULL: * pythread.PyThread_free_lock(self._real_lock) * self._real_lock = NULL # <<<<<<<<<<<<<< * * def acquire(self, bint blocking=True): */ __pyx_v_self->_real_lock = NULL; /* "lupa/lock.pxi":30 * * def __dealloc__(self): * if self._real_lock is not NULL: # <<<<<<<<<<<<<< * pythread.PyThread_free_lock(self._real_lock) * self._real_lock = NULL */ } /* "lupa/lock.pxi":29 * PyErr_NoMemory() * * def __dealloc__(self): # <<<<<<<<<<<<<< * if self._real_lock is not NULL: * pythread.PyThread_free_lock(self._real_lock) */ /* function exit code */ __Pyx_RefNannyFinishContext(); } /* "lupa/lock.pxi":34 * self._real_lock = NULL * * def acquire(self, bint blocking=True): # <<<<<<<<<<<<<< * return lock_lock(self, pythread.PyThread_get_thread_ident(), blocking) * */ /* Python wrapper */ static PyObject *__pyx_pw_4lupa_5_lupa_9FastRLock_5acquire(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ static char __pyx_doc_4lupa_5_lupa_9FastRLock_4acquire[] = "FastRLock.acquire(self, bool blocking=True)"; static PyMethodDef __pyx_mdef_4lupa_5_lupa_9FastRLock_5acquire = {"acquire", (PyCFunction)__pyx_pw_4lupa_5_lupa_9FastRLock_5acquire, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4lupa_5_lupa_9FastRLock_4acquire}; static PyObject *__pyx_pw_4lupa_5_lupa_9FastRLock_5acquire(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { int __pyx_v_blocking; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("acquire (wrapper)", 0); { static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_blocking,0}; PyObject* values[1] = {0}; if (unlikely(__pyx_kwds)) { Py_ssize_t kw_args; const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args); switch (pos_args) { case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); CYTHON_FALLTHROUGH; case 0: break; default: goto __pyx_L5_argtuple_error; } kw_args = PyDict_Size(__pyx_kwds); switch (pos_args) { case 0: if (kw_args > 0) { PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_blocking); if (value) { values[0] = value; kw_args--; } } } if (unlikely(kw_args > 0)) { if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "acquire") < 0)) __PYX_ERR(1, 34, __pyx_L3_error) } } else { switch (PyTuple_GET_SIZE(__pyx_args)) { case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); CYTHON_FALLTHROUGH; case 0: break; default: goto __pyx_L5_argtuple_error; } } if (values[0]) { __pyx_v_blocking = __Pyx_PyObject_IsTrue(values[0]); if (unlikely((__pyx_v_blocking == (int)-1) && PyErr_Occurred())) __PYX_ERR(1, 34, __pyx_L3_error) } else { __pyx_v_blocking = ((int)1); } } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("acquire", 0, 0, 1, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(1, 34, __pyx_L3_error) __pyx_L3_error:; __Pyx_AddTraceback("lupa._lupa.FastRLock.acquire", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; __pyx_r = __pyx_pf_4lupa_5_lupa_9FastRLock_4acquire(((struct __pyx_obj_4lupa_5_lupa_FastRLock *)__pyx_v_self), __pyx_v_blocking); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_4lupa_5_lupa_9FastRLock_4acquire(struct __pyx_obj_4lupa_5_lupa_FastRLock *__pyx_v_self, int __pyx_v_blocking) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; __Pyx_RefNannySetupContext("acquire", 0); /* "lupa/lock.pxi":35 * * def acquire(self, bint blocking=True): * return lock_lock(self, pythread.PyThread_get_thread_ident(), blocking) # <<<<<<<<<<<<<< * * def release(self): */ __Pyx_XDECREF(__pyx_r); __pyx_t_1 = __Pyx_PyBool_FromLong(__pyx_f_4lupa_5_lupa_lock_lock(__pyx_v_self, PyThread_get_thread_ident(), __pyx_v_blocking)); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 35, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0; /* "lupa/lock.pxi":34 * self._real_lock = NULL * * def acquire(self, bint blocking=True): # <<<<<<<<<<<<<< * return lock_lock(self, pythread.PyThread_get_thread_ident(), blocking) * */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_AddTraceback("lupa._lupa.FastRLock.acquire", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "lupa/lock.pxi":37 * return lock_lock(self, pythread.PyThread_get_thread_ident(), blocking) * * def release(self): # <<<<<<<<<<<<<< * if self._owner != pythread.PyThread_get_thread_ident(): * raise RuntimeError("cannot release un-acquired lock") */ /* Python wrapper */ static PyObject *__pyx_pw_4lupa_5_lupa_9FastRLock_7release(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ static char __pyx_doc_4lupa_5_lupa_9FastRLock_6release[] = "FastRLock.release(self)"; static PyMethodDef __pyx_mdef_4lupa_5_lupa_9FastRLock_7release = {"release", (PyCFunction)__pyx_pw_4lupa_5_lupa_9FastRLock_7release, METH_NOARGS, __pyx_doc_4lupa_5_lupa_9FastRLock_6release}; static PyObject *__pyx_pw_4lupa_5_lupa_9FastRLock_7release(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("release (wrapper)", 0); __pyx_r = __pyx_pf_4lupa_5_lupa_9FastRLock_6release(((struct __pyx_obj_4lupa_5_lupa_FastRLock *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_4lupa_5_lupa_9FastRLock_6release(struct __pyx_obj_4lupa_5_lupa_FastRLock *__pyx_v_self) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations int __pyx_t_1; PyObject *__pyx_t_2 = NULL; __Pyx_RefNannySetupContext("release", 0); /* "lupa/lock.pxi":38 * * def release(self): * if self._owner != pythread.PyThread_get_thread_ident(): # <<<<<<<<<<<<<< * raise RuntimeError("cannot release un-acquired lock") * unlock_lock(self) */ __pyx_t_1 = ((__pyx_v_self->_owner != PyThread_get_thread_ident()) != 0); if (__pyx_t_1) { /* "lupa/lock.pxi":39 * def release(self): * if self._owner != pythread.PyThread_get_thread_ident(): * raise RuntimeError("cannot release un-acquired lock") # <<<<<<<<<<<<<< * unlock_lock(self) * */ __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_RuntimeError, __pyx_tuple_, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 39, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_Raise(__pyx_t_2, 0, 0, 0); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __PYX_ERR(1, 39, __pyx_L1_error) /* "lupa/lock.pxi":38 * * def release(self): * if self._owner != pythread.PyThread_get_thread_ident(): # <<<<<<<<<<<<<< * raise RuntimeError("cannot release un-acquired lock") * unlock_lock(self) */ } /* "lupa/lock.pxi":40 * if self._owner != pythread.PyThread_get_thread_ident(): * raise RuntimeError("cannot release un-acquired lock") * unlock_lock(self) # <<<<<<<<<<<<<< * * # compatibility with RLock */ __pyx_f_4lupa_5_lupa_unlock_lock(__pyx_v_self); /* "lupa/lock.pxi":37 * return lock_lock(self, pythread.PyThread_get_thread_ident(), blocking) * * def release(self): # <<<<<<<<<<<<<< * if self._owner != pythread.PyThread_get_thread_ident(): * raise RuntimeError("cannot release un-acquired lock") */ /* function exit code */ __pyx_r = Py_None; __Pyx_INCREF(Py_None); goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_2); __Pyx_AddTraceback("lupa._lupa.FastRLock.release", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "lupa/lock.pxi":44 * # compatibility with RLock * * def __enter__(self): # <<<<<<<<<<<<<< * # self.acquire() * return lock_lock(self, pythread.PyThread_get_thread_ident(), True) */ /* Python wrapper */ static PyObject *__pyx_pw_4lupa_5_lupa_9FastRLock_9__enter__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ static char __pyx_doc_4lupa_5_lupa_9FastRLock_8__enter__[] = "FastRLock.__enter__(self)"; static PyMethodDef __pyx_mdef_4lupa_5_lupa_9FastRLock_9__enter__ = {"__enter__", (PyCFunction)__pyx_pw_4lupa_5_lupa_9FastRLock_9__enter__, METH_NOARGS, __pyx_doc_4lupa_5_lupa_9FastRLock_8__enter__}; static PyObject *__pyx_pw_4lupa_5_lupa_9FastRLock_9__enter__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__enter__ (wrapper)", 0); __pyx_r = __pyx_pf_4lupa_5_lupa_9FastRLock_8__enter__(((struct __pyx_obj_4lupa_5_lupa_FastRLock *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_4lupa_5_lupa_9FastRLock_8__enter__(struct __pyx_obj_4lupa_5_lupa_FastRLock *__pyx_v_self) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; __Pyx_RefNannySetupContext("__enter__", 0); /* "lupa/lock.pxi":46 * def __enter__(self): * # self.acquire() * return lock_lock(self, pythread.PyThread_get_thread_ident(), True) # <<<<<<<<<<<<<< * * def __exit__(self, t, v, tb): */ __Pyx_XDECREF(__pyx_r); __pyx_t_1 = __Pyx_PyBool_FromLong(__pyx_f_4lupa_5_lupa_lock_lock(__pyx_v_self, PyThread_get_thread_ident(), 1)); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 46, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0; /* "lupa/lock.pxi":44 * # compatibility with RLock * * def __enter__(self): # <<<<<<<<<<<<<< * # self.acquire() * return lock_lock(self, pythread.PyThread_get_thread_ident(), True) */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_AddTraceback("lupa._lupa.FastRLock.__enter__", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "lupa/lock.pxi":48 * return lock_lock(self, pythread.PyThread_get_thread_ident(), True) * * def __exit__(self, t, v, tb): # <<<<<<<<<<<<<< * # self.release() * if self._owner != pythread.PyThread_get_thread_ident(): */ /* Python wrapper */ static PyObject *__pyx_pw_4lupa_5_lupa_9FastRLock_11__exit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ static char __pyx_doc_4lupa_5_lupa_9FastRLock_10__exit__[] = "FastRLock.__exit__(self, t, v, tb)"; static PyMethodDef __pyx_mdef_4lupa_5_lupa_9FastRLock_11__exit__ = {"__exit__", (PyCFunction)__pyx_pw_4lupa_5_lupa_9FastRLock_11__exit__, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4lupa_5_lupa_9FastRLock_10__exit__}; static PyObject *__pyx_pw_4lupa_5_lupa_9FastRLock_11__exit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { CYTHON_UNUSED PyObject *__pyx_v_t = 0; CYTHON_UNUSED PyObject *__pyx_v_v = 0; CYTHON_UNUSED PyObject *__pyx_v_tb = 0; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__exit__ (wrapper)", 0); { static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_t,&__pyx_n_s_v,&__pyx_n_s_tb,0}; PyObject* values[3] = {0,0,0}; if (unlikely(__pyx_kwds)) { Py_ssize_t kw_args; const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args); switch (pos_args) { case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2); CYTHON_FALLTHROUGH; case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); CYTHON_FALLTHROUGH; case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); CYTHON_FALLTHROUGH; case 0: break; default: goto __pyx_L5_argtuple_error; } kw_args = PyDict_Size(__pyx_kwds); switch (pos_args) { case 0: if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_t)) != 0)) kw_args--; else goto __pyx_L5_argtuple_error; CYTHON_FALLTHROUGH; case 1: if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_v)) != 0)) kw_args--; else { __Pyx_RaiseArgtupleInvalid("__exit__", 1, 3, 3, 1); __PYX_ERR(1, 48, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 2: if (likely((values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_tb)) != 0)) kw_args--; else { __Pyx_RaiseArgtupleInvalid("__exit__", 1, 3, 3, 2); __PYX_ERR(1, 48, __pyx_L3_error) } } if (unlikely(kw_args > 0)) { if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__exit__") < 0)) __PYX_ERR(1, 48, __pyx_L3_error) } } else if (PyTuple_GET_SIZE(__pyx_args) != 3) { goto __pyx_L5_argtuple_error; } else { values[0] = PyTuple_GET_ITEM(__pyx_args, 0); values[1] = PyTuple_GET_ITEM(__pyx_args, 1); values[2] = PyTuple_GET_ITEM(__pyx_args, 2); } __pyx_v_t = values[0]; __pyx_v_v = values[1]; __pyx_v_tb = values[2]; } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("__exit__", 1, 3, 3, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(1, 48, __pyx_L3_error) __pyx_L3_error:; __Pyx_AddTraceback("lupa._lupa.FastRLock.__exit__", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; __pyx_r = __pyx_pf_4lupa_5_lupa_9FastRLock_10__exit__(((struct __pyx_obj_4lupa_5_lupa_FastRLock *)__pyx_v_self), __pyx_v_t, __pyx_v_v, __pyx_v_tb); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_4lupa_5_lupa_9FastRLock_10__exit__(struct __pyx_obj_4lupa_5_lupa_FastRLock *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v_t, CYTHON_UNUSED PyObject *__pyx_v_v, CYTHON_UNUSED PyObject *__pyx_v_tb) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations int __pyx_t_1; PyObject *__pyx_t_2 = NULL; __Pyx_RefNannySetupContext("__exit__", 0); /* "lupa/lock.pxi":50 * def __exit__(self, t, v, tb): * # self.release() * if self._owner != pythread.PyThread_get_thread_ident(): # <<<<<<<<<<<<<< * raise RuntimeError("cannot release un-acquired lock") * unlock_lock(self) */ __pyx_t_1 = ((__pyx_v_self->_owner != PyThread_get_thread_ident()) != 0); if (__pyx_t_1) { /* "lupa/lock.pxi":51 * # self.release() * if self._owner != pythread.PyThread_get_thread_ident(): * raise RuntimeError("cannot release un-acquired lock") # <<<<<<<<<<<<<< * unlock_lock(self) * */ __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_RuntimeError, __pyx_tuple__2, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 51, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_Raise(__pyx_t_2, 0, 0, 0); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __PYX_ERR(1, 51, __pyx_L1_error) /* "lupa/lock.pxi":50 * def __exit__(self, t, v, tb): * # self.release() * if self._owner != pythread.PyThread_get_thread_ident(): # <<<<<<<<<<<<<< * raise RuntimeError("cannot release un-acquired lock") * unlock_lock(self) */ } /* "lupa/lock.pxi":52 * if self._owner != pythread.PyThread_get_thread_ident(): * raise RuntimeError("cannot release un-acquired lock") * unlock_lock(self) # <<<<<<<<<<<<<< * * def _is_owned(self): */ __pyx_f_4lupa_5_lupa_unlock_lock(__pyx_v_self); /* "lupa/lock.pxi":48 * return lock_lock(self, pythread.PyThread_get_thread_ident(), True) * * def __exit__(self, t, v, tb): # <<<<<<<<<<<<<< * # self.release() * if self._owner != pythread.PyThread_get_thread_ident(): */ /* function exit code */ __pyx_r = Py_None; __Pyx_INCREF(Py_None); goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_2); __Pyx_AddTraceback("lupa._lupa.FastRLock.__exit__", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "lupa/lock.pxi":54 * unlock_lock(self) * * def _is_owned(self): # <<<<<<<<<<<<<< * return self._owner == pythread.PyThread_get_thread_ident() * */ /* Python wrapper */ static PyObject *__pyx_pw_4lupa_5_lupa_9FastRLock_13_is_owned(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ static char __pyx_doc_4lupa_5_lupa_9FastRLock_12_is_owned[] = "FastRLock._is_owned(self)"; static PyMethodDef __pyx_mdef_4lupa_5_lupa_9FastRLock_13_is_owned = {"_is_owned", (PyCFunction)__pyx_pw_4lupa_5_lupa_9FastRLock_13_is_owned, METH_NOARGS, __pyx_doc_4lupa_5_lupa_9FastRLock_12_is_owned}; static PyObject *__pyx_pw_4lupa_5_lupa_9FastRLock_13_is_owned(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("_is_owned (wrapper)", 0); __pyx_r = __pyx_pf_4lupa_5_lupa_9FastRLock_12_is_owned(((struct __pyx_obj_4lupa_5_lupa_FastRLock *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_4lupa_5_lupa_9FastRLock_12_is_owned(struct __pyx_obj_4lupa_5_lupa_FastRLock *__pyx_v_self) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; __Pyx_RefNannySetupContext("_is_owned", 0); /* "lupa/lock.pxi":55 * * def _is_owned(self): * return self._owner == pythread.PyThread_get_thread_ident() # <<<<<<<<<<<<<< * * */ __Pyx_XDECREF(__pyx_r); __pyx_t_1 = __Pyx_PyBool_FromLong((__pyx_v_self->_owner == PyThread_get_thread_ident())); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 55, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0; /* "lupa/lock.pxi":54 * unlock_lock(self) * * def _is_owned(self): # <<<<<<<<<<<<<< * return self._owner == pythread.PyThread_get_thread_ident() * */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_AddTraceback("lupa._lupa.FastRLock._is_owned", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "(tree fragment)":1 * def __reduce_cython__(self): # <<<<<<<<<<<<<< * raise TypeError("no default __reduce__ due to non-trivial __cinit__") * def __setstate_cython__(self, __pyx_state): */ /* Python wrapper */ static PyObject *__pyx_pw_4lupa_5_lupa_9FastRLock_15__reduce_cython__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ static char __pyx_doc_4lupa_5_lupa_9FastRLock_14__reduce_cython__[] = "FastRLock.__reduce_cython__(self)"; static PyMethodDef __pyx_mdef_4lupa_5_lupa_9FastRLock_15__reduce_cython__ = {"__reduce_cython__", (PyCFunction)__pyx_pw_4lupa_5_lupa_9FastRLock_15__reduce_cython__, METH_NOARGS, __pyx_doc_4lupa_5_lupa_9FastRLock_14__reduce_cython__}; static PyObject *__pyx_pw_4lupa_5_lupa_9FastRLock_15__reduce_cython__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__reduce_cython__ (wrapper)", 0); __pyx_r = __pyx_pf_4lupa_5_lupa_9FastRLock_14__reduce_cython__(((struct __pyx_obj_4lupa_5_lupa_FastRLock *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_4lupa_5_lupa_9FastRLock_14__reduce_cython__(CYTHON_UNUSED struct __pyx_obj_4lupa_5_lupa_FastRLock *__pyx_v_self) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; __Pyx_RefNannySetupContext("__reduce_cython__", 0); /* "(tree fragment)":2 * def __reduce_cython__(self): * raise TypeError("no default __reduce__ due to non-trivial __cinit__") # <<<<<<<<<<<<<< * def __setstate_cython__(self, __pyx_state): * raise TypeError("no default __reduce__ due to non-trivial __cinit__") */ __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__3, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 2, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_Raise(__pyx_t_1, 0, 0, 0); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __PYX_ERR(2, 2, __pyx_L1_error) /* "(tree fragment)":1 * def __reduce_cython__(self): # <<<<<<<<<<<<<< * raise TypeError("no default __reduce__ due to non-trivial __cinit__") * def __setstate_cython__(self, __pyx_state): */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_AddTraceback("lupa._lupa.FastRLock.__reduce_cython__", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "(tree fragment)":3 * def __reduce_cython__(self): * raise TypeError("no default __reduce__ due to non-trivial __cinit__") * def __setstate_cython__(self, __pyx_state): # <<<<<<<<<<<<<< * raise TypeError("no default __reduce__ due to non-trivial __cinit__") */ /* Python wrapper */ static PyObject *__pyx_pw_4lupa_5_lupa_9FastRLock_17__setstate_cython__(PyObject *__pyx_v_self, PyObject *__pyx_v___pyx_state); /*proto*/ static char __pyx_doc_4lupa_5_lupa_9FastRLock_16__setstate_cython__[] = "FastRLock.__setstate_cython__(self, __pyx_state)"; static PyMethodDef __pyx_mdef_4lupa_5_lupa_9FastRLock_17__setstate_cython__ = {"__setstate_cython__", (PyCFunction)__pyx_pw_4lupa_5_lupa_9FastRLock_17__setstate_cython__, METH_O, __pyx_doc_4lupa_5_lupa_9FastRLock_16__setstate_cython__}; static PyObject *__pyx_pw_4lupa_5_lupa_9FastRLock_17__setstate_cython__(PyObject *__pyx_v_self, PyObject *__pyx_v___pyx_state) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__setstate_cython__ (wrapper)", 0); __pyx_r = __pyx_pf_4lupa_5_lupa_9FastRLock_16__setstate_cython__(((struct __pyx_obj_4lupa_5_lupa_FastRLock *)__pyx_v_self), ((PyObject *)__pyx_v___pyx_state)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_4lupa_5_lupa_9FastRLock_16__setstate_cython__(CYTHON_UNUSED struct __pyx_obj_4lupa_5_lupa_FastRLock *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v___pyx_state) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; __Pyx_RefNannySetupContext("__setstate_cython__", 0); /* "(tree fragment)":4 * raise TypeError("no default __reduce__ due to non-trivial __cinit__") * def __setstate_cython__(self, __pyx_state): * raise TypeError("no default __reduce__ due to non-trivial __cinit__") # <<<<<<<<<<<<<< */ __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__4, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 4, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_Raise(__pyx_t_1, 0, 0, 0); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __PYX_ERR(2, 4, __pyx_L1_error) /* "(tree fragment)":3 * def __reduce_cython__(self): * raise TypeError("no default __reduce__ due to non-trivial __cinit__") * def __setstate_cython__(self, __pyx_state): # <<<<<<<<<<<<<< * raise TypeError("no default __reduce__ due to non-trivial __cinit__") */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_AddTraceback("lupa._lupa.FastRLock.__setstate_cython__", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "lupa/lock.pxi":58 * * * cdef inline bint lock_lock(FastRLock lock, long current_thread, bint blocking) nogil: # <<<<<<<<<<<<<< * # Note that this function *must* hold the GIL when being called. * # We just use 'nogil' in the signature to make sure that no Python */ static CYTHON_INLINE int __pyx_f_4lupa_5_lupa_lock_lock(struct __pyx_obj_4lupa_5_lupa_FastRLock *__pyx_v_lock, long __pyx_v_current_thread, int __pyx_v_blocking) { int __pyx_r; int __pyx_t_1; int __pyx_t_2; /* "lupa/lock.pxi":63 * # code execution slips in that might free the GIL * * if lock._count: # <<<<<<<<<<<<<< * # locked! - by myself? * if current_thread == lock._owner: */ __pyx_t_1 = (__pyx_v_lock->_count != 0); if (__pyx_t_1) { /* "lupa/lock.pxi":65 * if lock._count: * # locked! - by myself? * if current_thread == lock._owner: # <<<<<<<<<<<<<< * lock._count += 1 * return 1 */ __pyx_t_1 = ((__pyx_v_current_thread == __pyx_v_lock->_owner) != 0); if (__pyx_t_1) { /* "lupa/lock.pxi":66 * # locked! - by myself? * if current_thread == lock._owner: * lock._count += 1 # <<<<<<<<<<<<<< * return 1 * elif not lock._pending_requests: */ __pyx_v_lock->_count = (__pyx_v_lock->_count + 1); /* "lupa/lock.pxi":67 * if current_thread == lock._owner: * lock._count += 1 * return 1 # <<<<<<<<<<<<<< * elif not lock._pending_requests: * # not locked, not requested - go! */ __pyx_r = 1; goto __pyx_L0; /* "lupa/lock.pxi":65 * if lock._count: * # locked! - by myself? * if current_thread == lock._owner: # <<<<<<<<<<<<<< * lock._count += 1 * return 1 */ } /* "lupa/lock.pxi":63 * # code execution slips in that might free the GIL * * if lock._count: # <<<<<<<<<<<<<< * # locked! - by myself? * if current_thread == lock._owner: */ goto __pyx_L3; } /* "lupa/lock.pxi":68 * lock._count += 1 * return 1 * elif not lock._pending_requests: # <<<<<<<<<<<<<< * # not locked, not requested - go! * lock._owner = current_thread */ __pyx_t_1 = ((!(__pyx_v_lock->_pending_requests != 0)) != 0); if (__pyx_t_1) { /* "lupa/lock.pxi":70 * elif not lock._pending_requests: * # not locked, not requested - go! * lock._owner = current_thread # <<<<<<<<<<<<<< * lock._count = 1 * return 1 */ __pyx_v_lock->_owner = __pyx_v_current_thread; /* "lupa/lock.pxi":71 * # not locked, not requested - go! * lock._owner = current_thread * lock._count = 1 # <<<<<<<<<<<<<< * return 1 * # need to get the real lock */ __pyx_v_lock->_count = 1; /* "lupa/lock.pxi":72 * lock._owner = current_thread * lock._count = 1 * return 1 # <<<<<<<<<<<<<< * # need to get the real lock * return _acquire_lock( */ __pyx_r = 1; goto __pyx_L0; /* "lupa/lock.pxi":68 * lock._count += 1 * return 1 * elif not lock._pending_requests: # <<<<<<<<<<<<<< * # not locked, not requested - go! * lock._owner = current_thread */ } __pyx_L3:; /* "lupa/lock.pxi":76 * return _acquire_lock( * lock, current_thread, * pythread.WAIT_LOCK if blocking else pythread.NOWAIT_LOCK) # <<<<<<<<<<<<<< * * cdef bint _acquire_lock(FastRLock lock, long current_thread, int wait) nogil: */ if ((__pyx_v_blocking != 0)) { __pyx_t_2 = WAIT_LOCK; } else { __pyx_t_2 = NOWAIT_LOCK; } /* "lupa/lock.pxi":74 * return 1 * # need to get the real lock * return _acquire_lock( # <<<<<<<<<<<<<< * lock, current_thread, * pythread.WAIT_LOCK if blocking else pythread.NOWAIT_LOCK) */ __pyx_r = __pyx_f_4lupa_5_lupa__acquire_lock(__pyx_v_lock, __pyx_v_current_thread, __pyx_t_2); goto __pyx_L0; /* "lupa/lock.pxi":58 * * * cdef inline bint lock_lock(FastRLock lock, long current_thread, bint blocking) nogil: # <<<<<<<<<<<<<< * # Note that this function *must* hold the GIL when being called. * # We just use 'nogil' in the signature to make sure that no Python */ /* function exit code */ __pyx_L0:; return __pyx_r; } /* "lupa/lock.pxi":78 * pythread.WAIT_LOCK if blocking else pythread.NOWAIT_LOCK) * * cdef bint _acquire_lock(FastRLock lock, long current_thread, int wait) nogil: # <<<<<<<<<<<<<< * # Note that this function *must* hold the GIL when being called. * # We just use 'nogil' in the signature to make sure that no Python */ static int __pyx_f_4lupa_5_lupa__acquire_lock(struct __pyx_obj_4lupa_5_lupa_FastRLock *__pyx_v_lock, long __pyx_v_current_thread, int __pyx_v_wait) { int __pyx_v_locked; int __pyx_r; int __pyx_t_1; int __pyx_t_2; /* "lupa/lock.pxi":83 * # code execution slips in that might free the GIL * * if not lock._is_locked and not lock._pending_requests: # <<<<<<<<<<<<<< * # someone owns it but didn't acquire the real lock - do that * # now and tell the owner to release it when done. Note that we */ __pyx_t_2 = ((!(__pyx_v_lock->_is_locked != 0)) != 0); if (__pyx_t_2) { } else { __pyx_t_1 = __pyx_t_2; goto __pyx_L4_bool_binop_done; } __pyx_t_2 = ((!(__pyx_v_lock->_pending_requests != 0)) != 0); __pyx_t_1 = __pyx_t_2; __pyx_L4_bool_binop_done:; if (__pyx_t_1) { /* "lupa/lock.pxi":88 * # do not release the GIL here as we must absolutely be the one * # who acquires the lock now. * if not pythread.PyThread_acquire_lock(lock._real_lock, wait): # <<<<<<<<<<<<<< * return 0 * #assert not lock._is_locked */ __pyx_t_1 = ((!(PyThread_acquire_lock(__pyx_v_lock->_real_lock, __pyx_v_wait) != 0)) != 0); if (__pyx_t_1) { /* "lupa/lock.pxi":89 * # who acquires the lock now. * if not pythread.PyThread_acquire_lock(lock._real_lock, wait): * return 0 # <<<<<<<<<<<<<< * #assert not lock._is_locked * lock._is_locked = True */ __pyx_r = 0; goto __pyx_L0; /* "lupa/lock.pxi":88 * # do not release the GIL here as we must absolutely be the one * # who acquires the lock now. * if not pythread.PyThread_acquire_lock(lock._real_lock, wait): # <<<<<<<<<<<<<< * return 0 * #assert not lock._is_locked */ } /* "lupa/lock.pxi":91 * return 0 * #assert not lock._is_locked * lock._is_locked = True # <<<<<<<<<<<<<< * lock._pending_requests += 1 * with nogil: */ __pyx_v_lock->_is_locked = 1; /* "lupa/lock.pxi":83 * # code execution slips in that might free the GIL * * if not lock._is_locked and not lock._pending_requests: # <<<<<<<<<<<<<< * # someone owns it but didn't acquire the real lock - do that * # now and tell the owner to release it when done. Note that we */ } /* "lupa/lock.pxi":92 * #assert not lock._is_locked * lock._is_locked = True * lock._pending_requests += 1 # <<<<<<<<<<<<<< * with nogil: * # wait for the lock owning thread to release it */ __pyx_v_lock->_pending_requests = (__pyx_v_lock->_pending_requests + 1); /* "lupa/lock.pxi":93 * lock._is_locked = True * lock._pending_requests += 1 * with nogil: # <<<<<<<<<<<<<< * # wait for the lock owning thread to release it * locked = pythread.PyThread_acquire_lock(lock._real_lock, wait) */ { #ifdef WITH_THREAD PyThreadState *_save; Py_UNBLOCK_THREADS __Pyx_FastGIL_Remember(); #endif /*try:*/ { /* "lupa/lock.pxi":95 * with nogil: * # wait for the lock owning thread to release it * locked = pythread.PyThread_acquire_lock(lock._real_lock, wait) # <<<<<<<<<<<<<< * lock._pending_requests -= 1 * #assert not lock._is_locked */ __pyx_v_locked = PyThread_acquire_lock(__pyx_v_lock->_real_lock, __pyx_v_wait); } /* "lupa/lock.pxi":93 * lock._is_locked = True * lock._pending_requests += 1 * with nogil: # <<<<<<<<<<<<<< * # wait for the lock owning thread to release it * locked = pythread.PyThread_acquire_lock(lock._real_lock, wait) */ /*finally:*/ { /*normal exit:*/{ #ifdef WITH_THREAD __Pyx_FastGIL_Forget(); Py_BLOCK_THREADS #endif goto __pyx_L9; } __pyx_L9:; } } /* "lupa/lock.pxi":96 * # wait for the lock owning thread to release it * locked = pythread.PyThread_acquire_lock(lock._real_lock, wait) * lock._pending_requests -= 1 # <<<<<<<<<<<<<< * #assert not lock._is_locked * #assert lock._count == 0 */ __pyx_v_lock->_pending_requests = (__pyx_v_lock->_pending_requests - 1); /* "lupa/lock.pxi":99 * #assert not lock._is_locked * #assert lock._count == 0 * if not locked: # <<<<<<<<<<<<<< * return 0 * lock._is_locked = True */ __pyx_t_1 = ((!(__pyx_v_locked != 0)) != 0); if (__pyx_t_1) { /* "lupa/lock.pxi":100 * #assert lock._count == 0 * if not locked: * return 0 # <<<<<<<<<<<<<< * lock._is_locked = True * lock._owner = current_thread */ __pyx_r = 0; goto __pyx_L0; /* "lupa/lock.pxi":99 * #assert not lock._is_locked * #assert lock._count == 0 * if not locked: # <<<<<<<<<<<<<< * return 0 * lock._is_locked = True */ } /* "lupa/lock.pxi":101 * if not locked: * return 0 * lock._is_locked = True # <<<<<<<<<<<<<< * lock._owner = current_thread * lock._count = 1 */ __pyx_v_lock->_is_locked = 1; /* "lupa/lock.pxi":102 * return 0 * lock._is_locked = True * lock._owner = current_thread # <<<<<<<<<<<<<< * lock._count = 1 * return 1 */ __pyx_v_lock->_owner = __pyx_v_current_thread; /* "lupa/lock.pxi":103 * lock._is_locked = True * lock._owner = current_thread * lock._count = 1 # <<<<<<<<<<<<<< * return 1 * */ __pyx_v_lock->_count = 1; /* "lupa/lock.pxi":104 * lock._owner = current_thread * lock._count = 1 * return 1 # <<<<<<<<<<<<<< * * cdef inline void unlock_lock(FastRLock lock) nogil: */ __pyx_r = 1; goto __pyx_L0; /* "lupa/lock.pxi":78 * pythread.WAIT_LOCK if blocking else pythread.NOWAIT_LOCK) * * cdef bint _acquire_lock(FastRLock lock, long current_thread, int wait) nogil: # <<<<<<<<<<<<<< * # Note that this function *must* hold the GIL when being called. * # We just use 'nogil' in the signature to make sure that no Python */ /* function exit code */ __pyx_L0:; return __pyx_r; } /* "lupa/lock.pxi":106 * return 1 * * cdef inline void unlock_lock(FastRLock lock) nogil: # <<<<<<<<<<<<<< * # Note that this function *must* hold the GIL when being called. * # We just use 'nogil' in the signature to make sure that no Python */ static CYTHON_INLINE void __pyx_f_4lupa_5_lupa_unlock_lock(struct __pyx_obj_4lupa_5_lupa_FastRLock *__pyx_v_lock) { int __pyx_t_1; /* "lupa/lock.pxi":113 * #assert lock._owner == pythread.PyThread_get_thread_ident() * #assert lock._count > 0 * lock._count -= 1 # <<<<<<<<<<<<<< * if lock._count == 0: * lock._owner = -1 */ __pyx_v_lock->_count = (__pyx_v_lock->_count - 1); /* "lupa/lock.pxi":114 * #assert lock._count > 0 * lock._count -= 1 * if lock._count == 0: # <<<<<<<<<<<<<< * lock._owner = -1 * if lock._is_locked: */ __pyx_t_1 = ((__pyx_v_lock->_count == 0) != 0); if (__pyx_t_1) { /* "lupa/lock.pxi":115 * lock._count -= 1 * if lock._count == 0: * lock._owner = -1 # <<<<<<<<<<<<<< * if lock._is_locked: * pythread.PyThread_release_lock(lock._real_lock) */ __pyx_v_lock->_owner = -1L; /* "lupa/lock.pxi":116 * if lock._count == 0: * lock._owner = -1 * if lock._is_locked: # <<<<<<<<<<<<<< * pythread.PyThread_release_lock(lock._real_lock) * lock._is_locked = False */ __pyx_t_1 = (__pyx_v_lock->_is_locked != 0); if (__pyx_t_1) { /* "lupa/lock.pxi":117 * lock._owner = -1 * if lock._is_locked: * pythread.PyThread_release_lock(lock._real_lock) # <<<<<<<<<<<<<< * lock._is_locked = False */ PyThread_release_lock(__pyx_v_lock->_real_lock); /* "lupa/lock.pxi":118 * if lock._is_locked: * pythread.PyThread_release_lock(lock._real_lock) * lock._is_locked = False # <<<<<<<<<<<<<< */ __pyx_v_lock->_is_locked = 0; /* "lupa/lock.pxi":116 * if lock._count == 0: * lock._owner = -1 * if lock._is_locked: # <<<<<<<<<<<<<< * pythread.PyThread_release_lock(lock._real_lock) * lock._is_locked = False */ } /* "lupa/lock.pxi":114 * #assert lock._count > 0 * lock._count -= 1 * if lock._count == 0: # <<<<<<<<<<<<<< * lock._owner = -1 * if lock._is_locked: */ } /* "lupa/lock.pxi":106 * return 1 * * cdef inline void unlock_lock(FastRLock lock) nogil: # <<<<<<<<<<<<<< * # Note that this function *must* hold the GIL when being called. * # We just use 'nogil' in the signature to make sure that no Python */ /* function exit code */ } /* "lupa/_lupa.pyx":75 * * * def lua_type(obj): # <<<<<<<<<<<<<< * """ * Return the Lua type name of a wrapped object as string, as provided */ /* Python wrapper */ static PyObject *__pyx_pw_4lupa_5_lupa_1lua_type(PyObject *__pyx_self, PyObject *__pyx_v_obj); /*proto*/ static char __pyx_doc_4lupa_5_lupa_lua_type[] = "lua_type(obj)\n\n Return the Lua type name of a wrapped object as string, as provided\n by Lua's type() function.\n\n For non-wrapper objects (i.e. normal Python objects), returns None.\n "; static PyMethodDef __pyx_mdef_4lupa_5_lupa_1lua_type = {"lua_type", (PyCFunction)__pyx_pw_4lupa_5_lupa_1lua_type, METH_O, __pyx_doc_4lupa_5_lupa_lua_type}; static PyObject *__pyx_pw_4lupa_5_lupa_1lua_type(PyObject *__pyx_self, PyObject *__pyx_v_obj) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("lua_type (wrapper)", 0); __pyx_r = __pyx_pf_4lupa_5_lupa_lua_type(__pyx_self, ((PyObject *)__pyx_v_obj)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_4lupa_5_lupa_lua_type(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_obj) { struct __pyx_obj_4lupa_5_lupa__LuaObject *__pyx_v_lua_object = NULL; lua_State *__pyx_v_L; int __pyx_v_old_top; char const *__pyx_v_lua_type_name; int __pyx_v_ltype; PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations int __pyx_t_1; int __pyx_t_2; PyObject *__pyx_t_3 = NULL; int __pyx_t_4; lua_State *__pyx_t_5; PyObject *__pyx_t_6 = NULL; int __pyx_t_7; char const *__pyx_t_8; PyObject *__pyx_t_9 = NULL; PyObject *__pyx_t_10 = NULL; PyObject *__pyx_t_11 = NULL; PyObject *__pyx_t_12 = NULL; PyObject *__pyx_t_13 = NULL; PyObject *__pyx_t_14 = NULL; __Pyx_RefNannySetupContext("lua_type", 0); /* "lupa/_lupa.pyx":82 * For non-wrapper objects (i.e. normal Python objects), returns None. * """ * if not isinstance(obj, _LuaObject): # <<<<<<<<<<<<<< * return None * lua_object = <_LuaObject>obj */ __pyx_t_1 = __Pyx_TypeCheck(__pyx_v_obj, __pyx_ptype_4lupa_5_lupa__LuaObject); __pyx_t_2 = ((!(__pyx_t_1 != 0)) != 0); if (__pyx_t_2) { /* "lupa/_lupa.pyx":83 * """ * if not isinstance(obj, _LuaObject): * return None # <<<<<<<<<<<<<< * lua_object = <_LuaObject>obj * assert lua_object._runtime is not None */ __Pyx_XDECREF(__pyx_r); __Pyx_INCREF(Py_None); __pyx_r = Py_None; goto __pyx_L0; /* "lupa/_lupa.pyx":82 * For non-wrapper objects (i.e. normal Python objects), returns None. * """ * if not isinstance(obj, _LuaObject): # <<<<<<<<<<<<<< * return None * lua_object = <_LuaObject>obj */ } /* "lupa/_lupa.pyx":84 * if not isinstance(obj, _LuaObject): * return None * lua_object = <_LuaObject>obj # <<<<<<<<<<<<<< * assert lua_object._runtime is not None * lock_runtime(lua_object._runtime) */ __pyx_t_3 = __pyx_v_obj; __Pyx_INCREF(__pyx_t_3); __pyx_v_lua_object = ((struct __pyx_obj_4lupa_5_lupa__LuaObject *)__pyx_t_3); __pyx_t_3 = 0; /* "lupa/_lupa.pyx":85 * return None * lua_object = <_LuaObject>obj * assert lua_object._runtime is not None # <<<<<<<<<<<<<< * lock_runtime(lua_object._runtime) * L = lua_object._state */ #ifndef CYTHON_WITHOUT_ASSERTIONS if (unlikely(!Py_OptimizeFlag)) { __pyx_t_2 = (((PyObject *)__pyx_v_lua_object->_runtime) != Py_None); if (unlikely(!(__pyx_t_2 != 0))) { PyErr_SetNone(PyExc_AssertionError); __PYX_ERR(0, 85, __pyx_L1_error) } } #endif /* "lupa/_lupa.pyx":86 * lua_object = <_LuaObject>obj * assert lua_object._runtime is not None * lock_runtime(lua_object._runtime) # <<<<<<<<<<<<<< * L = lua_object._state * old_top = lua.lua_gettop(L) */ __pyx_t_3 = ((PyObject *)__pyx_v_lua_object->_runtime); __Pyx_INCREF(__pyx_t_3); __pyx_t_4 = __pyx_f_4lupa_5_lupa_lock_runtime(((struct __pyx_obj_4lupa_5_lupa_LuaRuntime *)__pyx_t_3)); if (unlikely(__pyx_t_4 == ((int)-1))) __PYX_ERR(0, 86, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; /* "lupa/_lupa.pyx":87 * assert lua_object._runtime is not None * lock_runtime(lua_object._runtime) * L = lua_object._state # <<<<<<<<<<<<<< * old_top = lua.lua_gettop(L) * cdef const char* lua_type_name */ __pyx_t_5 = __pyx_v_lua_object->_state; __pyx_v_L = __pyx_t_5; /* "lupa/_lupa.pyx":88 * lock_runtime(lua_object._runtime) * L = lua_object._state * old_top = lua.lua_gettop(L) # <<<<<<<<<<<<<< * cdef const char* lua_type_name * try: */ __pyx_v_old_top = lua_gettop(__pyx_v_L); /* "lupa/_lupa.pyx":90 * old_top = lua.lua_gettop(L) * cdef const char* lua_type_name * try: # <<<<<<<<<<<<<< * lua.lua_rawgeti(L, lua.LUA_REGISTRYINDEX, lua_object._ref) * ltype = lua.lua_type(L, -1) */ /*try:*/ { /* "lupa/_lupa.pyx":91 * cdef const char* lua_type_name * try: * lua.lua_rawgeti(L, lua.LUA_REGISTRYINDEX, lua_object._ref) # <<<<<<<<<<<<<< * ltype = lua.lua_type(L, -1) * if ltype == lua.LUA_TTABLE: */ lua_rawgeti(__pyx_v_L, LUA_REGISTRYINDEX, __pyx_v_lua_object->_ref); /* "lupa/_lupa.pyx":92 * try: * lua.lua_rawgeti(L, lua.LUA_REGISTRYINDEX, lua_object._ref) * ltype = lua.lua_type(L, -1) # <<<<<<<<<<<<<< * if ltype == lua.LUA_TTABLE: * return 'table' */ __pyx_v_ltype = lua_type(__pyx_v_L, -1); /* "lupa/_lupa.pyx":93 * lua.lua_rawgeti(L, lua.LUA_REGISTRYINDEX, lua_object._ref) * ltype = lua.lua_type(L, -1) * if ltype == lua.LUA_TTABLE: # <<<<<<<<<<<<<< * return 'table' * elif ltype == lua.LUA_TFUNCTION: */ switch (__pyx_v_ltype) { case LUA_TTABLE: /* "lupa/_lupa.pyx":94 * ltype = lua.lua_type(L, -1) * if ltype == lua.LUA_TTABLE: * return 'table' # <<<<<<<<<<<<<< * elif ltype == lua.LUA_TFUNCTION: * return 'function' */ __Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_n_s_table); __pyx_r = __pyx_n_s_table; goto __pyx_L4_return; /* "lupa/_lupa.pyx":93 * lua.lua_rawgeti(L, lua.LUA_REGISTRYINDEX, lua_object._ref) * ltype = lua.lua_type(L, -1) * if ltype == lua.LUA_TTABLE: # <<<<<<<<<<<<<< * return 'table' * elif ltype == lua.LUA_TFUNCTION: */ break; /* "lupa/_lupa.pyx":95 * if ltype == lua.LUA_TTABLE: * return 'table' * elif ltype == lua.LUA_TFUNCTION: # <<<<<<<<<<<<<< * return 'function' * elif ltype == lua.LUA_TTHREAD: */ case LUA_TFUNCTION: /* "lupa/_lupa.pyx":96 * return 'table' * elif ltype == lua.LUA_TFUNCTION: * return 'function' # <<<<<<<<<<<<<< * elif ltype == lua.LUA_TTHREAD: * return 'thread' */ __Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_n_s_function); __pyx_r = __pyx_n_s_function; goto __pyx_L4_return; /* "lupa/_lupa.pyx":95 * if ltype == lua.LUA_TTABLE: * return 'table' * elif ltype == lua.LUA_TFUNCTION: # <<<<<<<<<<<<<< * return 'function' * elif ltype == lua.LUA_TTHREAD: */ break; /* "lupa/_lupa.pyx":97 * elif ltype == lua.LUA_TFUNCTION: * return 'function' * elif ltype == lua.LUA_TTHREAD: # <<<<<<<<<<<<<< * return 'thread' * elif ltype in (lua.LUA_TUSERDATA, lua.LUA_TLIGHTUSERDATA): */ case LUA_TTHREAD: /* "lupa/_lupa.pyx":98 * return 'function' * elif ltype == lua.LUA_TTHREAD: * return 'thread' # <<<<<<<<<<<<<< * elif ltype in (lua.LUA_TUSERDATA, lua.LUA_TLIGHTUSERDATA): * return 'userdata' */ __Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_n_s_thread); __pyx_r = __pyx_n_s_thread; goto __pyx_L4_return; /* "lupa/_lupa.pyx":97 * elif ltype == lua.LUA_TFUNCTION: * return 'function' * elif ltype == lua.LUA_TTHREAD: # <<<<<<<<<<<<<< * return 'thread' * elif ltype in (lua.LUA_TUSERDATA, lua.LUA_TLIGHTUSERDATA): */ break; /* "lupa/_lupa.pyx":99 * elif ltype == lua.LUA_TTHREAD: * return 'thread' * elif ltype in (lua.LUA_TUSERDATA, lua.LUA_TLIGHTUSERDATA): # <<<<<<<<<<<<<< * return 'userdata' * else: */ case LUA_TUSERDATA: case LUA_TLIGHTUSERDATA: /* "lupa/_lupa.pyx":100 * return 'thread' * elif ltype in (lua.LUA_TUSERDATA, lua.LUA_TLIGHTUSERDATA): * return 'userdata' # <<<<<<<<<<<<<< * else: * lua_type_name = lua.lua_typename(L, ltype) */ __Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_n_s_userdata); __pyx_r = __pyx_n_s_userdata; goto __pyx_L4_return; /* "lupa/_lupa.pyx":99 * elif ltype == lua.LUA_TTHREAD: * return 'thread' * elif ltype in (lua.LUA_TUSERDATA, lua.LUA_TLIGHTUSERDATA): # <<<<<<<<<<<<<< * return 'userdata' * else: */ break; default: /* "lupa/_lupa.pyx":102 * return 'userdata' * else: * lua_type_name = lua.lua_typename(L, ltype) # <<<<<<<<<<<<<< * return lua_type_name if IS_PY2 else lua_type_name.decode('ascii') * finally: */ __pyx_v_lua_type_name = lua_typename(__pyx_v_L, __pyx_v_ltype); /* "lupa/_lupa.pyx":103 * else: * lua_type_name = lua.lua_typename(L, ltype) * return lua_type_name if IS_PY2 else lua_type_name.decode('ascii') # <<<<<<<<<<<<<< * finally: * lua.lua_settop(L, old_top) */ __Pyx_XDECREF(__pyx_r); if ((__pyx_v_4lupa_5_lupa_IS_PY2 != 0)) { __pyx_t_6 = __Pyx_PyBytes_FromString(__pyx_v_lua_type_name); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 103, __pyx_L5_error) __Pyx_GOTREF(__pyx_t_6); __pyx_t_3 = __pyx_t_6; __pyx_t_6 = 0; } else { __pyx_t_6 = __Pyx_decode_c_string(__pyx_v_lua_type_name, 0, strlen(__pyx_v_lua_type_name), NULL, NULL, PyUnicode_DecodeASCII); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 103, __pyx_L5_error) __Pyx_GOTREF(__pyx_t_6); __pyx_t_3 = __pyx_t_6; __pyx_t_6 = 0; } __pyx_r = __pyx_t_3; __pyx_t_3 = 0; goto __pyx_L4_return; break; } } /* "lupa/_lupa.pyx":105 * return lua_type_name if IS_PY2 else lua_type_name.decode('ascii') * finally: * lua.lua_settop(L, old_top) # <<<<<<<<<<<<<< * unlock_runtime(lua_object._runtime) * */ /*finally:*/ { __pyx_L5_error:; /*exception exit:*/{ __Pyx_PyThreadState_declare __Pyx_PyThreadState_assign __pyx_t_9 = 0; __pyx_t_10 = 0; __pyx_t_11 = 0; __pyx_t_12 = 0; __pyx_t_13 = 0; __pyx_t_14 = 0; __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; if (PY_MAJOR_VERSION >= 3) __Pyx_ExceptionSwap(&__pyx_t_12, &__pyx_t_13, &__pyx_t_14); if ((PY_MAJOR_VERSION < 3) || unlikely(__Pyx_GetException(&__pyx_t_9, &__pyx_t_10, &__pyx_t_11) < 0)) __Pyx_ErrFetch(&__pyx_t_9, &__pyx_t_10, &__pyx_t_11); __Pyx_XGOTREF(__pyx_t_9); __Pyx_XGOTREF(__pyx_t_10); __Pyx_XGOTREF(__pyx_t_11); __Pyx_XGOTREF(__pyx_t_12); __Pyx_XGOTREF(__pyx_t_13); __Pyx_XGOTREF(__pyx_t_14); __pyx_t_4 = __pyx_lineno; __pyx_t_7 = __pyx_clineno; __pyx_t_8 = __pyx_filename; { lua_settop(__pyx_v_L, __pyx_v_old_top); /* "lupa/_lupa.pyx":106 * finally: * lua.lua_settop(L, old_top) * unlock_runtime(lua_object._runtime) # <<<<<<<<<<<<<< * * */ __pyx_t_3 = ((PyObject *)__pyx_v_lua_object->_runtime); __Pyx_INCREF(__pyx_t_3); __pyx_f_4lupa_5_lupa_unlock_runtime(((struct __pyx_obj_4lupa_5_lupa_LuaRuntime *)__pyx_t_3)); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; } if (PY_MAJOR_VERSION >= 3) { __Pyx_XGIVEREF(__pyx_t_12); __Pyx_XGIVEREF(__pyx_t_13); __Pyx_XGIVEREF(__pyx_t_14); __Pyx_ExceptionReset(__pyx_t_12, __pyx_t_13, __pyx_t_14); } __Pyx_XGIVEREF(__pyx_t_9); __Pyx_XGIVEREF(__pyx_t_10); __Pyx_XGIVEREF(__pyx_t_11); __Pyx_ErrRestore(__pyx_t_9, __pyx_t_10, __pyx_t_11); __pyx_t_9 = 0; __pyx_t_10 = 0; __pyx_t_11 = 0; __pyx_t_12 = 0; __pyx_t_13 = 0; __pyx_t_14 = 0; __pyx_lineno = __pyx_t_4; __pyx_clineno = __pyx_t_7; __pyx_filename = __pyx_t_8; goto __pyx_L1_error; } __pyx_L4_return: { __pyx_t_14 = __pyx_r; __pyx_r = 0; /* "lupa/_lupa.pyx":105 * return lua_type_name if IS_PY2 else lua_type_name.decode('ascii') * finally: * lua.lua_settop(L, old_top) # <<<<<<<<<<<<<< * unlock_runtime(lua_object._runtime) * */ lua_settop(__pyx_v_L, __pyx_v_old_top); /* "lupa/_lupa.pyx":106 * finally: * lua.lua_settop(L, old_top) * unlock_runtime(lua_object._runtime) # <<<<<<<<<<<<<< * * */ __pyx_t_3 = ((PyObject *)__pyx_v_lua_object->_runtime); __Pyx_INCREF(__pyx_t_3); __pyx_f_4lupa_5_lupa_unlock_runtime(((struct __pyx_obj_4lupa_5_lupa_LuaRuntime *)__pyx_t_3)); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_r = __pyx_t_14; __pyx_t_14 = 0; goto __pyx_L0; } } /* "lupa/_lupa.pyx":75 * * * def lua_type(obj): # <<<<<<<<<<<<<< * """ * Return the Lua type name of a wrapped object as string, as provided */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_3); __Pyx_XDECREF(__pyx_t_6); __Pyx_AddTraceback("lupa._lupa.lua_type", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XDECREF((PyObject *)__pyx_v_lua_object); __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "lupa/_lupa.pyx":187 * cdef bint _unpack_returned_tuples * * def __cinit__(self, encoding='UTF-8', source_encoding=None, # <<<<<<<<<<<<<< * attribute_filter=None, attribute_handlers=None, * bint register_eval=True, bint unpack_returned_tuples=False, */ /* Python wrapper */ static int __pyx_pw_4lupa_5_lupa_10LuaRuntime_1__cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ static int __pyx_pw_4lupa_5_lupa_10LuaRuntime_1__cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { PyObject *__pyx_v_encoding = 0; PyObject *__pyx_v_source_encoding = 0; PyObject *__pyx_v_attribute_filter = 0; PyObject *__pyx_v_attribute_handlers = 0; int __pyx_v_register_eval; int __pyx_v_unpack_returned_tuples; int __pyx_v_register_builtins; int __pyx_r; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__cinit__ (wrapper)", 0); { static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_encoding,&__pyx_n_s_source_encoding,&__pyx_n_s_attribute_filter,&__pyx_n_s_attribute_handlers,&__pyx_n_s_register_eval,&__pyx_n_s_unpack_returned_tuples,&__pyx_n_s_register_builtins,0}; PyObject* values[7] = {0,0,0,0,0,0,0}; values[0] = ((PyObject *)__pyx_kp_s_UTF_8); values[1] = ((PyObject *)Py_None); /* "lupa/_lupa.pyx":188 * * def __cinit__(self, encoding='UTF-8', source_encoding=None, * attribute_filter=None, attribute_handlers=None, # <<<<<<<<<<<<<< * bint register_eval=True, bint unpack_returned_tuples=False, * bint register_builtins=True): */ values[2] = ((PyObject *)Py_None); values[3] = ((PyObject *)Py_None); if (unlikely(__pyx_kwds)) { Py_ssize_t kw_args; const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args); switch (pos_args) { case 7: values[6] = PyTuple_GET_ITEM(__pyx_args, 6); CYTHON_FALLTHROUGH; case 6: values[5] = PyTuple_GET_ITEM(__pyx_args, 5); CYTHON_FALLTHROUGH; case 5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4); CYTHON_FALLTHROUGH; case 4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3); CYTHON_FALLTHROUGH; case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2); CYTHON_FALLTHROUGH; case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); CYTHON_FALLTHROUGH; case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); CYTHON_FALLTHROUGH; case 0: break; default: goto __pyx_L5_argtuple_error; } kw_args = PyDict_Size(__pyx_kwds); switch (pos_args) { case 0: if (kw_args > 0) { PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_encoding); if (value) { values[0] = value; kw_args--; } } CYTHON_FALLTHROUGH; case 1: if (kw_args > 0) { PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_source_encoding); if (value) { values[1] = value; kw_args--; } } CYTHON_FALLTHROUGH; case 2: if (kw_args > 0) { PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_attribute_filter); if (value) { values[2] = value; kw_args--; } } CYTHON_FALLTHROUGH; case 3: if (kw_args > 0) { PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_attribute_handlers); if (value) { values[3] = value; kw_args--; } } CYTHON_FALLTHROUGH; case 4: if (kw_args > 0) { PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_register_eval); if (value) { values[4] = value; kw_args--; } } CYTHON_FALLTHROUGH; case 5: if (kw_args > 0) { PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_unpack_returned_tuples); if (value) { values[5] = value; kw_args--; } } CYTHON_FALLTHROUGH; case 6: if (kw_args > 0) { PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_register_builtins); if (value) { values[6] = value; kw_args--; } } } if (unlikely(kw_args > 0)) { if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__cinit__") < 0)) __PYX_ERR(0, 187, __pyx_L3_error) } } else { switch (PyTuple_GET_SIZE(__pyx_args)) { case 7: values[6] = PyTuple_GET_ITEM(__pyx_args, 6); CYTHON_FALLTHROUGH; case 6: values[5] = PyTuple_GET_ITEM(__pyx_args, 5); CYTHON_FALLTHROUGH; case 5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4); CYTHON_FALLTHROUGH; case 4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3); CYTHON_FALLTHROUGH; case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2); CYTHON_FALLTHROUGH; case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); CYTHON_FALLTHROUGH; case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); CYTHON_FALLTHROUGH; case 0: break; default: goto __pyx_L5_argtuple_error; } } __pyx_v_encoding = values[0]; __pyx_v_source_encoding = values[1]; __pyx_v_attribute_filter = values[2]; __pyx_v_attribute_handlers = values[3]; if (values[4]) { __pyx_v_register_eval = __Pyx_PyObject_IsTrue(values[4]); if (unlikely((__pyx_v_register_eval == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 189, __pyx_L3_error) } else { /* "lupa/_lupa.pyx":189 * def __cinit__(self, encoding='UTF-8', source_encoding=None, * attribute_filter=None, attribute_handlers=None, * bint register_eval=True, bint unpack_returned_tuples=False, # <<<<<<<<<<<<<< * bint register_builtins=True): * cdef lua_State* L = lua.luaL_newstate() */ __pyx_v_register_eval = ((int)1); } if (values[5]) { __pyx_v_unpack_returned_tuples = __Pyx_PyObject_IsTrue(values[5]); if (unlikely((__pyx_v_unpack_returned_tuples == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 189, __pyx_L3_error) } else { __pyx_v_unpack_returned_tuples = ((int)0); } if (values[6]) { __pyx_v_register_builtins = __Pyx_PyObject_IsTrue(values[6]); if (unlikely((__pyx_v_register_builtins == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 190, __pyx_L3_error) } else { /* "lupa/_lupa.pyx":190 * attribute_filter=None, attribute_handlers=None, * bint register_eval=True, bint unpack_returned_tuples=False, * bint register_builtins=True): # <<<<<<<<<<<<<< * cdef lua_State* L = lua.luaL_newstate() * if L is NULL: */ __pyx_v_register_builtins = ((int)1); } } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("__cinit__", 0, 0, 7, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 187, __pyx_L3_error) __pyx_L3_error:; __Pyx_AddTraceback("lupa._lupa.LuaRuntime.__cinit__", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return -1; __pyx_L4_argument_unpacking_done:; __pyx_r = __pyx_pf_4lupa_5_lupa_10LuaRuntime___cinit__(((struct __pyx_obj_4lupa_5_lupa_LuaRuntime *)__pyx_v_self), __pyx_v_encoding, __pyx_v_source_encoding, __pyx_v_attribute_filter, __pyx_v_attribute_handlers, __pyx_v_register_eval, __pyx_v_unpack_returned_tuples, __pyx_v_register_builtins); /* "lupa/_lupa.pyx":187 * cdef bint _unpack_returned_tuples * * def __cinit__(self, encoding='UTF-8', source_encoding=None, # <<<<<<<<<<<<<< * attribute_filter=None, attribute_handlers=None, * bint register_eval=True, bint unpack_returned_tuples=False, */ /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static int __pyx_pf_4lupa_5_lupa_10LuaRuntime___cinit__(struct __pyx_obj_4lupa_5_lupa_LuaRuntime *__pyx_v_self, PyObject *__pyx_v_encoding, PyObject *__pyx_v_source_encoding, PyObject *__pyx_v_attribute_filter, PyObject *__pyx_v_attribute_handlers, int __pyx_v_register_eval, int __pyx_v_unpack_returned_tuples, int __pyx_v_register_builtins) { lua_State *__pyx_v_L; int __pyx_v_raise_error; PyObject *__pyx_v_getter = NULL; PyObject *__pyx_v_setter = NULL; int __pyx_r; __Pyx_RefNannyDeclarations int __pyx_t_1; PyObject *__pyx_t_2 = NULL; PyObject *__pyx_t_3 = NULL; int __pyx_t_4; int __pyx_t_5; PyObject *__pyx_t_6 = NULL; PyObject *__pyx_t_7 = NULL; PyObject *__pyx_t_8 = NULL; PyObject *__pyx_t_9 = NULL; PyObject *(*__pyx_t_10)(PyObject *); int __pyx_t_11; __Pyx_RefNannySetupContext("__cinit__", 0); /* "lupa/_lupa.pyx":191 * bint register_eval=True, bint unpack_returned_tuples=False, * bint register_builtins=True): * cdef lua_State* L = lua.luaL_newstate() # <<<<<<<<<<<<<< * if L is NULL: * raise LuaError("Failed to initialise Lua runtime") */ __pyx_v_L = luaL_newstate(); /* "lupa/_lupa.pyx":192 * bint register_builtins=True): * cdef lua_State* L = lua.luaL_newstate() * if L is NULL: # <<<<<<<<<<<<<< * raise LuaError("Failed to initialise Lua runtime") * self._state = L */ __pyx_t_1 = ((__pyx_v_L == NULL) != 0); if (__pyx_t_1) { /* "lupa/_lupa.pyx":193 * cdef lua_State* L = lua.luaL_newstate() * if L is NULL: * raise LuaError("Failed to initialise Lua runtime") # <<<<<<<<<<<<<< * self._state = L * self._lock = FastRLock() */ __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_LuaError); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 193, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_tuple__5, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 193, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_Raise(__pyx_t_3, 0, 0, 0); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __PYX_ERR(0, 193, __pyx_L1_error) /* "lupa/_lupa.pyx":192 * bint register_builtins=True): * cdef lua_State* L = lua.luaL_newstate() * if L is NULL: # <<<<<<<<<<<<<< * raise LuaError("Failed to initialise Lua runtime") * self._state = L */ } /* "lupa/_lupa.pyx":194 * if L is NULL: * raise LuaError("Failed to initialise Lua runtime") * self._state = L # <<<<<<<<<<<<<< * self._lock = FastRLock() * self._pyrefs_in_lua = {} */ __pyx_v_self->_state = __pyx_v_L; /* "lupa/_lupa.pyx":195 * raise LuaError("Failed to initialise Lua runtime") * self._state = L * self._lock = FastRLock() # <<<<<<<<<<<<<< * self._pyrefs_in_lua = {} * self._encoding = _asciiOrNone(encoding) */ __pyx_t_3 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_4lupa_5_lupa_FastRLock), __pyx_empty_tuple, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 195, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_GIVEREF(__pyx_t_3); __Pyx_GOTREF(__pyx_v_self->_lock); __Pyx_DECREF(((PyObject *)__pyx_v_self->_lock)); __pyx_v_self->_lock = ((struct __pyx_obj_4lupa_5_lupa_FastRLock *)__pyx_t_3); __pyx_t_3 = 0; /* "lupa/_lupa.pyx":196 * self._state = L * self._lock = FastRLock() * self._pyrefs_in_lua = {} # <<<<<<<<<<<<<< * self._encoding = _asciiOrNone(encoding) * self._source_encoding = _asciiOrNone(source_encoding) or self._encoding or b'UTF-8' */ __pyx_t_3 = __Pyx_PyDict_NewPresized(0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 196, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_GIVEREF(__pyx_t_3); __Pyx_GOTREF(__pyx_v_self->_pyrefs_in_lua); __Pyx_DECREF(__pyx_v_self->_pyrefs_in_lua); __pyx_v_self->_pyrefs_in_lua = ((PyObject*)__pyx_t_3); __pyx_t_3 = 0; /* "lupa/_lupa.pyx":197 * self._lock = FastRLock() * self._pyrefs_in_lua = {} * self._encoding = _asciiOrNone(encoding) # <<<<<<<<<<<<<< * self._source_encoding = _asciiOrNone(source_encoding) or self._encoding or b'UTF-8' * if attribute_filter is not None and not callable(attribute_filter): */ __pyx_t_3 = __pyx_f_4lupa_5_lupa__asciiOrNone(__pyx_v_encoding); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 197, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_GIVEREF(__pyx_t_3); __Pyx_GOTREF(__pyx_v_self->_encoding); __Pyx_DECREF(__pyx_v_self->_encoding); __pyx_v_self->_encoding = ((PyObject*)__pyx_t_3); __pyx_t_3 = 0; /* "lupa/_lupa.pyx":198 * self._pyrefs_in_lua = {} * self._encoding = _asciiOrNone(encoding) * self._source_encoding = _asciiOrNone(source_encoding) or self._encoding or b'UTF-8' # <<<<<<<<<<<<<< * if attribute_filter is not None and not callable(attribute_filter): * raise ValueError("attribute_filter must be callable") */ __pyx_t_2 = __pyx_f_4lupa_5_lupa__asciiOrNone(__pyx_v_source_encoding); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 198, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_1 < 0)) __PYX_ERR(0, 198, __pyx_L1_error) if (!__pyx_t_1) { __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; } else { __Pyx_INCREF(__pyx_t_2); __pyx_t_3 = __pyx_t_2; __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; goto __pyx_L4_bool_binop_done; } __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_v_self->_encoding); if (unlikely(__pyx_t_1 < 0)) __PYX_ERR(0, 198, __pyx_L1_error) if (!__pyx_t_1) { } else { __Pyx_INCREF(__pyx_v_self->_encoding); __pyx_t_3 = __pyx_v_self->_encoding; goto __pyx_L4_bool_binop_done; } __Pyx_INCREF(__pyx_kp_b_UTF_8); __pyx_t_3 = __pyx_kp_b_UTF_8; __pyx_L4_bool_binop_done:; __Pyx_GIVEREF(__pyx_t_3); __Pyx_GOTREF(__pyx_v_self->_source_encoding); __Pyx_DECREF(__pyx_v_self->_source_encoding); __pyx_v_self->_source_encoding = ((PyObject*)__pyx_t_3); __pyx_t_3 = 0; /* "lupa/_lupa.pyx":199 * self._encoding = _asciiOrNone(encoding) * self._source_encoding = _asciiOrNone(source_encoding) or self._encoding or b'UTF-8' * if attribute_filter is not None and not callable(attribute_filter): # <<<<<<<<<<<<<< * raise ValueError("attribute_filter must be callable") * self._attribute_filter = attribute_filter */ __pyx_t_4 = (__pyx_v_attribute_filter != Py_None); __pyx_t_5 = (__pyx_t_4 != 0); if (__pyx_t_5) { } else { __pyx_t_1 = __pyx_t_5; goto __pyx_L8_bool_binop_done; } __pyx_t_5 = __Pyx_PyCallable_Check(__pyx_v_attribute_filter); if (unlikely(__pyx_t_5 == ((int)-1))) __PYX_ERR(0, 199, __pyx_L1_error) __pyx_t_4 = ((!(__pyx_t_5 != 0)) != 0); __pyx_t_1 = __pyx_t_4; __pyx_L8_bool_binop_done:; if (__pyx_t_1) { /* "lupa/_lupa.pyx":200 * self._source_encoding = _asciiOrNone(source_encoding) or self._encoding or b'UTF-8' * if attribute_filter is not None and not callable(attribute_filter): * raise ValueError("attribute_filter must be callable") # <<<<<<<<<<<<<< * self._attribute_filter = attribute_filter * self._unpack_returned_tuples = unpack_returned_tuples */ __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__6, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 200, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_Raise(__pyx_t_3, 0, 0, 0); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __PYX_ERR(0, 200, __pyx_L1_error) /* "lupa/_lupa.pyx":199 * self._encoding = _asciiOrNone(encoding) * self._source_encoding = _asciiOrNone(source_encoding) or self._encoding or b'UTF-8' * if attribute_filter is not None and not callable(attribute_filter): # <<<<<<<<<<<<<< * raise ValueError("attribute_filter must be callable") * self._attribute_filter = attribute_filter */ } /* "lupa/_lupa.pyx":201 * if attribute_filter is not None and not callable(attribute_filter): * raise ValueError("attribute_filter must be callable") * self._attribute_filter = attribute_filter # <<<<<<<<<<<<<< * self._unpack_returned_tuples = unpack_returned_tuples * */ __Pyx_INCREF(__pyx_v_attribute_filter); __Pyx_GIVEREF(__pyx_v_attribute_filter); __Pyx_GOTREF(__pyx_v_self->_attribute_filter); __Pyx_DECREF(__pyx_v_self->_attribute_filter); __pyx_v_self->_attribute_filter = __pyx_v_attribute_filter; /* "lupa/_lupa.pyx":202 * raise ValueError("attribute_filter must be callable") * self._attribute_filter = attribute_filter * self._unpack_returned_tuples = unpack_returned_tuples # <<<<<<<<<<<<<< * * if attribute_handlers: */ __pyx_v_self->_unpack_returned_tuples = __pyx_v_unpack_returned_tuples; /* "lupa/_lupa.pyx":204 * self._unpack_returned_tuples = unpack_returned_tuples * * if attribute_handlers: # <<<<<<<<<<<<<< * raise_error = False * try: */ __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_v_attribute_handlers); if (unlikely(__pyx_t_1 < 0)) __PYX_ERR(0, 204, __pyx_L1_error) if (__pyx_t_1) { /* "lupa/_lupa.pyx":205 * * if attribute_handlers: * raise_error = False # <<<<<<<<<<<<<< * try: * getter, setter = attribute_handlers */ __pyx_v_raise_error = 0; /* "lupa/_lupa.pyx":206 * if attribute_handlers: * raise_error = False * try: # <<<<<<<<<<<<<< * getter, setter = attribute_handlers * except (ValueError, TypeError): */ { __Pyx_PyThreadState_declare __Pyx_PyThreadState_assign __Pyx_ExceptionSave(&__pyx_t_6, &__pyx_t_7, &__pyx_t_8); __Pyx_XGOTREF(__pyx_t_6); __Pyx_XGOTREF(__pyx_t_7); __Pyx_XGOTREF(__pyx_t_8); /*try:*/ { /* "lupa/_lupa.pyx":207 * raise_error = False * try: * getter, setter = attribute_handlers # <<<<<<<<<<<<<< * except (ValueError, TypeError): * raise_error = True */ if ((likely(PyTuple_CheckExact(__pyx_v_attribute_handlers))) || (PyList_CheckExact(__pyx_v_attribute_handlers))) { PyObject* sequence = __pyx_v_attribute_handlers; #if !CYTHON_COMPILING_IN_PYPY Py_ssize_t size = Py_SIZE(sequence); #else Py_ssize_t size = PySequence_Size(sequence); #endif if (unlikely(size != 2)) { if (size > 2) __Pyx_RaiseTooManyValuesError(2); else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size); __PYX_ERR(0, 207, __pyx_L11_error) } #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS if (likely(PyTuple_CheckExact(sequence))) { __pyx_t_3 = PyTuple_GET_ITEM(sequence, 0); __pyx_t_2 = PyTuple_GET_ITEM(sequence, 1); } else { __pyx_t_3 = PyList_GET_ITEM(sequence, 0); __pyx_t_2 = PyList_GET_ITEM(sequence, 1); } __Pyx_INCREF(__pyx_t_3); __Pyx_INCREF(__pyx_t_2); #else __pyx_t_3 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 207, __pyx_L11_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_2 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 207, __pyx_L11_error) __Pyx_GOTREF(__pyx_t_2); #endif } else { Py_ssize_t index = -1; __pyx_t_9 = PyObject_GetIter(__pyx_v_attribute_handlers); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 207, __pyx_L11_error) __Pyx_GOTREF(__pyx_t_9); __pyx_t_10 = Py_TYPE(__pyx_t_9)->tp_iternext; index = 0; __pyx_t_3 = __pyx_t_10(__pyx_t_9); if (unlikely(!__pyx_t_3)) goto __pyx_L17_unpacking_failed; __Pyx_GOTREF(__pyx_t_3); index = 1; __pyx_t_2 = __pyx_t_10(__pyx_t_9); if (unlikely(!__pyx_t_2)) goto __pyx_L17_unpacking_failed; __Pyx_GOTREF(__pyx_t_2); if (__Pyx_IternextUnpackEndCheck(__pyx_t_10(__pyx_t_9), 2) < 0) __PYX_ERR(0, 207, __pyx_L11_error) __pyx_t_10 = NULL; __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; goto __pyx_L18_unpacking_done; __pyx_L17_unpacking_failed:; __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; __pyx_t_10 = NULL; if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index); __PYX_ERR(0, 207, __pyx_L11_error) __pyx_L18_unpacking_done:; } __pyx_v_getter = __pyx_t_3; __pyx_t_3 = 0; __pyx_v_setter = __pyx_t_2; __pyx_t_2 = 0; /* "lupa/_lupa.pyx":206 * if attribute_handlers: * raise_error = False * try: # <<<<<<<<<<<<<< * getter, setter = attribute_handlers * except (ValueError, TypeError): */ } /* "lupa/_lupa.pyx":211 * raise_error = True * else: * if (getter is not None and not callable(getter) or # <<<<<<<<<<<<<< * setter is not None and not callable(setter)): * raise_error = True */ /*else:*/ { __pyx_t_4 = (__pyx_v_getter != Py_None); __pyx_t_5 = (__pyx_t_4 != 0); if (!__pyx_t_5) { goto __pyx_L21_next_or; } else { } __pyx_t_5 = __Pyx_PyCallable_Check(__pyx_v_getter); if (unlikely(__pyx_t_5 == ((int)-1))) __PYX_ERR(0, 211, __pyx_L13_except_error) __pyx_t_4 = ((!(__pyx_t_5 != 0)) != 0); if (!__pyx_t_4) { } else { __pyx_t_1 = __pyx_t_4; goto __pyx_L20_bool_binop_done; } __pyx_L21_next_or:; /* "lupa/_lupa.pyx":212 * else: * if (getter is not None and not callable(getter) or * setter is not None and not callable(setter)): # <<<<<<<<<<<<<< * raise_error = True * if raise_error: */ __pyx_t_4 = (__pyx_v_setter != Py_None); __pyx_t_5 = (__pyx_t_4 != 0); if (__pyx_t_5) { } else { __pyx_t_1 = __pyx_t_5; goto __pyx_L20_bool_binop_done; } __pyx_t_5 = __Pyx_PyCallable_Check(__pyx_v_setter); if (unlikely(__pyx_t_5 == ((int)-1))) __PYX_ERR(0, 212, __pyx_L13_except_error) __pyx_t_4 = ((!(__pyx_t_5 != 0)) != 0); __pyx_t_1 = __pyx_t_4; __pyx_L20_bool_binop_done:; /* "lupa/_lupa.pyx":211 * raise_error = True * else: * if (getter is not None and not callable(getter) or # <<<<<<<<<<<<<< * setter is not None and not callable(setter)): * raise_error = True */ if (__pyx_t_1) { /* "lupa/_lupa.pyx":213 * if (getter is not None and not callable(getter) or * setter is not None and not callable(setter)): * raise_error = True # <<<<<<<<<<<<<< * if raise_error: * raise ValueError("attribute_handlers must be a sequence of two callables") */ __pyx_v_raise_error = 1; /* "lupa/_lupa.pyx":211 * raise_error = True * else: * if (getter is not None and not callable(getter) or # <<<<<<<<<<<<<< * setter is not None and not callable(setter)): * raise_error = True */ } } __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0; __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0; goto __pyx_L16_try_end; __pyx_L11_error:; __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0; __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; /* "lupa/_lupa.pyx":208 * try: * getter, setter = attribute_handlers * except (ValueError, TypeError): # <<<<<<<<<<<<<< * raise_error = True * else: */ __pyx_t_11 = __Pyx_PyErr_ExceptionMatches(__pyx_builtin_ValueError) || __Pyx_PyErr_ExceptionMatches(__pyx_builtin_TypeError); if (__pyx_t_11) { __Pyx_AddTraceback("lupa._lupa.LuaRuntime.__cinit__", __pyx_clineno, __pyx_lineno, __pyx_filename); if (__Pyx_GetException(&__pyx_t_2, &__pyx_t_3, &__pyx_t_9) < 0) __PYX_ERR(0, 208, __pyx_L13_except_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_GOTREF(__pyx_t_3); __Pyx_GOTREF(__pyx_t_9); /* "lupa/_lupa.pyx":209 * getter, setter = attribute_handlers * except (ValueError, TypeError): * raise_error = True # <<<<<<<<<<<<<< * else: * if (getter is not None and not callable(getter) or */ __pyx_v_raise_error = 1; __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; goto __pyx_L12_exception_handled; } goto __pyx_L13_except_error; __pyx_L13_except_error:; /* "lupa/_lupa.pyx":206 * if attribute_handlers: * raise_error = False * try: # <<<<<<<<<<<<<< * getter, setter = attribute_handlers * except (ValueError, TypeError): */ __Pyx_XGIVEREF(__pyx_t_6); __Pyx_XGIVEREF(__pyx_t_7); __Pyx_XGIVEREF(__pyx_t_8); __Pyx_ExceptionReset(__pyx_t_6, __pyx_t_7, __pyx_t_8); goto __pyx_L1_error; __pyx_L12_exception_handled:; __Pyx_XGIVEREF(__pyx_t_6); __Pyx_XGIVEREF(__pyx_t_7); __Pyx_XGIVEREF(__pyx_t_8); __Pyx_ExceptionReset(__pyx_t_6, __pyx_t_7, __pyx_t_8); __pyx_L16_try_end:; } /* "lupa/_lupa.pyx":214 * setter is not None and not callable(setter)): * raise_error = True * if raise_error: # <<<<<<<<<<<<<< * raise ValueError("attribute_handlers must be a sequence of two callables") * if attribute_filter and (getter is not None or setter is not None): */ __pyx_t_1 = (__pyx_v_raise_error != 0); if (__pyx_t_1) { /* "lupa/_lupa.pyx":215 * raise_error = True * if raise_error: * raise ValueError("attribute_handlers must be a sequence of two callables") # <<<<<<<<<<<<<< * if attribute_filter and (getter is not None or setter is not None): * raise ValueError("attribute_filter and attribute_handlers are mutually exclusive") */ __pyx_t_9 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__7, NULL); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 215, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); __Pyx_Raise(__pyx_t_9, 0, 0, 0); __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; __PYX_ERR(0, 215, __pyx_L1_error) /* "lupa/_lupa.pyx":214 * setter is not None and not callable(setter)): * raise_error = True * if raise_error: # <<<<<<<<<<<<<< * raise ValueError("attribute_handlers must be a sequence of two callables") * if attribute_filter and (getter is not None or setter is not None): */ } /* "lupa/_lupa.pyx":216 * if raise_error: * raise ValueError("attribute_handlers must be a sequence of two callables") * if attribute_filter and (getter is not None or setter is not None): # <<<<<<<<<<<<<< * raise ValueError("attribute_filter and attribute_handlers are mutually exclusive") * self._attribute_getter, self._attribute_setter = getter, setter */ __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_v_attribute_filter); if (unlikely(__pyx_t_4 < 0)) __PYX_ERR(0, 216, __pyx_L1_error) if (__pyx_t_4) { } else { __pyx_t_1 = __pyx_t_4; goto __pyx_L28_bool_binop_done; } if (unlikely(!__pyx_v_getter)) { __Pyx_RaiseUnboundLocalError("getter"); __PYX_ERR(0, 216, __pyx_L1_error) } __pyx_t_4 = (__pyx_v_getter != Py_None); __pyx_t_5 = (__pyx_t_4 != 0); if (!__pyx_t_5) { } else { __pyx_t_1 = __pyx_t_5; goto __pyx_L28_bool_binop_done; } if (unlikely(!__pyx_v_setter)) { __Pyx_RaiseUnboundLocalError("setter"); __PYX_ERR(0, 216, __pyx_L1_error) } __pyx_t_5 = (__pyx_v_setter != Py_None); __pyx_t_4 = (__pyx_t_5 != 0); __pyx_t_1 = __pyx_t_4; __pyx_L28_bool_binop_done:; if (__pyx_t_1) { /* "lupa/_lupa.pyx":217 * raise ValueError("attribute_handlers must be a sequence of two callables") * if attribute_filter and (getter is not None or setter is not None): * raise ValueError("attribute_filter and attribute_handlers are mutually exclusive") # <<<<<<<<<<<<<< * self._attribute_getter, self._attribute_setter = getter, setter * */ __pyx_t_9 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__8, NULL); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 217, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); __Pyx_Raise(__pyx_t_9, 0, 0, 0); __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; __PYX_ERR(0, 217, __pyx_L1_error) /* "lupa/_lupa.pyx":216 * if raise_error: * raise ValueError("attribute_handlers must be a sequence of two callables") * if attribute_filter and (getter is not None or setter is not None): # <<<<<<<<<<<<<< * raise ValueError("attribute_filter and attribute_handlers are mutually exclusive") * self._attribute_getter, self._attribute_setter = getter, setter */ } /* "lupa/_lupa.pyx":218 * if attribute_filter and (getter is not None or setter is not None): * raise ValueError("attribute_filter and attribute_handlers are mutually exclusive") * self._attribute_getter, self._attribute_setter = getter, setter # <<<<<<<<<<<<<< * * lua.luaL_openlibs(L) */ if (unlikely(!__pyx_v_getter)) { __Pyx_RaiseUnboundLocalError("getter"); __PYX_ERR(0, 218, __pyx_L1_error) } __pyx_t_9 = __pyx_v_getter; __Pyx_INCREF(__pyx_t_9); if (unlikely(!__pyx_v_setter)) { __Pyx_RaiseUnboundLocalError("setter"); __PYX_ERR(0, 218, __pyx_L1_error) } __pyx_t_3 = __pyx_v_setter; __Pyx_INCREF(__pyx_t_3); __Pyx_GIVEREF(__pyx_t_9); __Pyx_GOTREF(__pyx_v_self->_attribute_getter); __Pyx_DECREF(__pyx_v_self->_attribute_getter); __pyx_v_self->_attribute_getter = __pyx_t_9; __pyx_t_9 = 0; __Pyx_GIVEREF(__pyx_t_3); __Pyx_GOTREF(__pyx_v_self->_attribute_setter); __Pyx_DECREF(__pyx_v_self->_attribute_setter); __pyx_v_self->_attribute_setter = __pyx_t_3; __pyx_t_3 = 0; /* "lupa/_lupa.pyx":204 * self._unpack_returned_tuples = unpack_returned_tuples * * if attribute_handlers: # <<<<<<<<<<<<<< * raise_error = False * try: */ } /* "lupa/_lupa.pyx":220 * self._attribute_getter, self._attribute_setter = getter, setter * * lua.luaL_openlibs(L) # <<<<<<<<<<<<<< * self.init_python_lib(register_eval, register_builtins) * lua.lua_settop(L, 0) */ luaL_openlibs(__pyx_v_L); /* "lupa/_lupa.pyx":221 * * lua.luaL_openlibs(L) * self.init_python_lib(register_eval, register_builtins) # <<<<<<<<<<<<<< * lua.lua_settop(L, 0) * lua.lua_atpanic(L, 1) */ __pyx_t_11 = __pyx_f_4lupa_5_lupa_10LuaRuntime_init_python_lib(__pyx_v_self, __pyx_v_register_eval, __pyx_v_register_builtins); if (unlikely(__pyx_t_11 == ((int)-1))) __PYX_ERR(0, 221, __pyx_L1_error) /* "lupa/_lupa.pyx":222 * lua.luaL_openlibs(L) * self.init_python_lib(register_eval, register_builtins) * lua.lua_settop(L, 0) # <<<<<<<<<<<<<< * lua.lua_atpanic(L, 1) * */ lua_settop(__pyx_v_L, 0); /* "lupa/_lupa.pyx":223 * self.init_python_lib(register_eval, register_builtins) * lua.lua_settop(L, 0) * lua.lua_atpanic(L, 1) # <<<<<<<<<<<<<< * * def __dealloc__(self): */ lua_atpanic(__pyx_v_L, ((lua_CFunction)1)); /* "lupa/_lupa.pyx":187 * cdef bint _unpack_returned_tuples * * def __cinit__(self, encoding='UTF-8', source_encoding=None, # <<<<<<<<<<<<<< * attribute_filter=None, attribute_handlers=None, * bint register_eval=True, bint unpack_returned_tuples=False, */ /* function exit code */ __pyx_r = 0; goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_2); __Pyx_XDECREF(__pyx_t_3); __Pyx_XDECREF(__pyx_t_9); __Pyx_AddTraceback("lupa._lupa.LuaRuntime.__cinit__", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = -1; __pyx_L0:; __Pyx_XDECREF(__pyx_v_getter); __Pyx_XDECREF(__pyx_v_setter); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "lupa/_lupa.pyx":225 * lua.lua_atpanic(L, 1) * * def __dealloc__(self): # <<<<<<<<<<<<<< * if self._state is not NULL: * lua.lua_close(self._state) */ /* Python wrapper */ static void __pyx_pw_4lupa_5_lupa_10LuaRuntime_3__dealloc__(PyObject *__pyx_v_self); /*proto*/ static void __pyx_pw_4lupa_5_lupa_10LuaRuntime_3__dealloc__(PyObject *__pyx_v_self) { __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__dealloc__ (wrapper)", 0); __pyx_pf_4lupa_5_lupa_10LuaRuntime_2__dealloc__(((struct __pyx_obj_4lupa_5_lupa_LuaRuntime *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); } static void __pyx_pf_4lupa_5_lupa_10LuaRuntime_2__dealloc__(struct __pyx_obj_4lupa_5_lupa_LuaRuntime *__pyx_v_self) { __Pyx_RefNannyDeclarations int __pyx_t_1; __Pyx_RefNannySetupContext("__dealloc__", 0); /* "lupa/_lupa.pyx":226 * * def __dealloc__(self): * if self._state is not NULL: # <<<<<<<<<<<<<< * lua.lua_close(self._state) * self._state = NULL */ __pyx_t_1 = ((__pyx_v_self->_state != NULL) != 0); if (__pyx_t_1) { /* "lupa/_lupa.pyx":227 * def __dealloc__(self): * if self._state is not NULL: * lua.lua_close(self._state) # <<<<<<<<<<<<<< * self._state = NULL * */ lua_close(__pyx_v_self->_state); /* "lupa/_lupa.pyx":228 * if self._state is not NULL: * lua.lua_close(self._state) * self._state = NULL # <<<<<<<<<<<<<< * * @cython.final */ __pyx_v_self->_state = NULL; /* "lupa/_lupa.pyx":226 * * def __dealloc__(self): * if self._state is not NULL: # <<<<<<<<<<<<<< * lua.lua_close(self._state) * self._state = NULL */ } /* "lupa/_lupa.pyx":225 * lua.lua_atpanic(L, 1) * * def __dealloc__(self): # <<<<<<<<<<<<<< * if self._state is not NULL: * lua.lua_close(self._state) */ /* function exit code */ __Pyx_RefNannyFinishContext(); } /* "lupa/_lupa.pyx":231 * * @cython.final * cdef int reraise_on_exception(self) except -1: # <<<<<<<<<<<<<< * if self._raised_exception is not None: * exception = self._raised_exception */ static int __pyx_f_4lupa_5_lupa_10LuaRuntime_reraise_on_exception(struct __pyx_obj_4lupa_5_lupa_LuaRuntime *__pyx_v_self) { PyObject *__pyx_v_exception = NULL; int __pyx_r; __Pyx_RefNannyDeclarations int __pyx_t_1; int __pyx_t_2; PyObject *__pyx_t_3 = NULL; PyObject *__pyx_t_4 = NULL; PyObject *__pyx_t_5 = NULL; __Pyx_RefNannySetupContext("reraise_on_exception", 0); /* "lupa/_lupa.pyx":232 * @cython.final * cdef int reraise_on_exception(self) except -1: * if self._raised_exception is not None: # <<<<<<<<<<<<<< * exception = self._raised_exception * self._raised_exception = None */ __pyx_t_1 = (__pyx_v_self->_raised_exception != ((PyObject*)Py_None)); __pyx_t_2 = (__pyx_t_1 != 0); if (__pyx_t_2) { /* "lupa/_lupa.pyx":233 * cdef int reraise_on_exception(self) except -1: * if self._raised_exception is not None: * exception = self._raised_exception # <<<<<<<<<<<<<< * self._raised_exception = None * raise exception[0], exception[1], exception[2] */ __pyx_t_3 = __pyx_v_self->_raised_exception; __Pyx_INCREF(__pyx_t_3); __pyx_v_exception = ((PyObject*)__pyx_t_3); __pyx_t_3 = 0; /* "lupa/_lupa.pyx":234 * if self._raised_exception is not None: * exception = self._raised_exception * self._raised_exception = None # <<<<<<<<<<<<<< * raise exception[0], exception[1], exception[2] * return 0 */ __Pyx_INCREF(Py_None); __Pyx_GIVEREF(Py_None); __Pyx_GOTREF(__pyx_v_self->_raised_exception); __Pyx_DECREF(__pyx_v_self->_raised_exception); __pyx_v_self->_raised_exception = ((PyObject*)Py_None); /* "lupa/_lupa.pyx":235 * exception = self._raised_exception * self._raised_exception = None * raise exception[0], exception[1], exception[2] # <<<<<<<<<<<<<< * return 0 * */ if (unlikely(__pyx_v_exception == Py_None)) { PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable"); __PYX_ERR(0, 235, __pyx_L1_error) } __pyx_t_3 = __Pyx_GetItemInt_Tuple(__pyx_v_exception, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 235, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); if (unlikely(__pyx_v_exception == Py_None)) { PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable"); __PYX_ERR(0, 235, __pyx_L1_error) } __pyx_t_4 = __Pyx_GetItemInt_Tuple(__pyx_v_exception, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 235, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); if (unlikely(__pyx_v_exception == Py_None)) { PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable"); __PYX_ERR(0, 235, __pyx_L1_error) } __pyx_t_5 = __Pyx_GetItemInt_Tuple(__pyx_v_exception, 2, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 235, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_Raise(__pyx_t_3, __pyx_t_4, __pyx_t_5, 0); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __PYX_ERR(0, 235, __pyx_L1_error) /* "lupa/_lupa.pyx":232 * @cython.final * cdef int reraise_on_exception(self) except -1: * if self._raised_exception is not None: # <<<<<<<<<<<<<< * exception = self._raised_exception * self._raised_exception = None */ } /* "lupa/_lupa.pyx":236 * self._raised_exception = None * raise exception[0], exception[1], exception[2] * return 0 # <<<<<<<<<<<<<< * * @cython.final */ __pyx_r = 0; goto __pyx_L0; /* "lupa/_lupa.pyx":231 * * @cython.final * cdef int reraise_on_exception(self) except -1: # <<<<<<<<<<<<<< * if self._raised_exception is not None: * exception = self._raised_exception */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_3); __Pyx_XDECREF(__pyx_t_4); __Pyx_XDECREF(__pyx_t_5); __Pyx_AddTraceback("lupa._lupa.LuaRuntime.reraise_on_exception", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = -1; __pyx_L0:; __Pyx_XDECREF(__pyx_v_exception); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "lupa/_lupa.pyx":239 * * @cython.final * cdef int store_raised_exception(self, lua_State* L, bytes lua_error_msg) except -1: # <<<<<<<<<<<<<< * try: * self._raised_exception = exc_info() */ static int __pyx_f_4lupa_5_lupa_10LuaRuntime_store_raised_exception(struct __pyx_obj_4lupa_5_lupa_LuaRuntime *__pyx_v_self, lua_State *__pyx_v_L, PyObject *__pyx_v_lua_error_msg) { int __pyx_r; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; PyObject *__pyx_t_2 = NULL; PyObject *__pyx_t_3 = NULL; PyObject *__pyx_t_4 = NULL; PyObject *__pyx_t_5 = NULL; PyObject *__pyx_t_6 = NULL; int __pyx_t_7; char *__pyx_t_8; Py_ssize_t __pyx_t_9; __Pyx_RefNannySetupContext("store_raised_exception", 0); /* "lupa/_lupa.pyx":240 * @cython.final * cdef int store_raised_exception(self, lua_State* L, bytes lua_error_msg) except -1: * try: # <<<<<<<<<<<<<< * self._raised_exception = exc_info() * py_to_lua(self, L, self._raised_exception[1]) */ { __Pyx_PyThreadState_declare __Pyx_PyThreadState_assign __Pyx_ExceptionSave(&__pyx_t_1, &__pyx_t_2, &__pyx_t_3); __Pyx_XGOTREF(__pyx_t_1); __Pyx_XGOTREF(__pyx_t_2); __Pyx_XGOTREF(__pyx_t_3); /*try:*/ { /* "lupa/_lupa.pyx":241 * cdef int store_raised_exception(self, lua_State* L, bytes lua_error_msg) except -1: * try: * self._raised_exception = exc_info() # <<<<<<<<<<<<<< * py_to_lua(self, L, self._raised_exception[1]) * except: */ __Pyx_INCREF(__pyx_v_4lupa_5_lupa_exc_info); __pyx_t_5 = __pyx_v_4lupa_5_lupa_exc_info; __pyx_t_6 = NULL; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_5))) { __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_5); if (likely(__pyx_t_6)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5); __Pyx_INCREF(__pyx_t_6); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_5, function); } } if (__pyx_t_6) { __pyx_t_4 = __Pyx_PyObject_CallOneArg(__pyx_t_5, __pyx_t_6); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 241, __pyx_L3_error) __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; } else { __pyx_t_4 = __Pyx_PyObject_CallNoArg(__pyx_t_5); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 241, __pyx_L3_error) } __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; if (!(likely(PyTuple_CheckExact(__pyx_t_4))||((__pyx_t_4) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "tuple", Py_TYPE(__pyx_t_4)->tp_name), 0))) __PYX_ERR(0, 241, __pyx_L3_error) __Pyx_GIVEREF(__pyx_t_4); __Pyx_GOTREF(__pyx_v_self->_raised_exception); __Pyx_DECREF(__pyx_v_self->_raised_exception); __pyx_v_self->_raised_exception = ((PyObject*)__pyx_t_4); __pyx_t_4 = 0; /* "lupa/_lupa.pyx":242 * try: * self._raised_exception = exc_info() * py_to_lua(self, L, self._raised_exception[1]) # <<<<<<<<<<<<<< * except: * lua.lua_pushlstring(L, lua_error_msg, len(lua_error_msg)) */ if (unlikely(__pyx_v_self->_raised_exception == Py_None)) { PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable"); __PYX_ERR(0, 242, __pyx_L3_error) } __pyx_t_4 = __Pyx_GetItemInt_Tuple(__pyx_v_self->_raised_exception, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 242, __pyx_L3_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_7 = __pyx_f_4lupa_5_lupa_py_to_lua(__pyx_v_self, __pyx_v_L, __pyx_t_4, NULL); if (unlikely(__pyx_t_7 == ((int)-1))) __PYX_ERR(0, 242, __pyx_L3_error) __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; /* "lupa/_lupa.pyx":240 * @cython.final * cdef int store_raised_exception(self, lua_State* L, bytes lua_error_msg) except -1: * try: # <<<<<<<<<<<<<< * self._raised_exception = exc_info() * py_to_lua(self, L, self._raised_exception[1]) */ } __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; goto __pyx_L8_try_end; __pyx_L3_error:; __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; /* "lupa/_lupa.pyx":243 * self._raised_exception = exc_info() * py_to_lua(self, L, self._raised_exception[1]) * except: # <<<<<<<<<<<<<< * lua.lua_pushlstring(L, lua_error_msg, len(lua_error_msg)) * raise */ /*except:*/ { __Pyx_AddTraceback("lupa._lupa.LuaRuntime.store_raised_exception", __pyx_clineno, __pyx_lineno, __pyx_filename); if (__Pyx_GetException(&__pyx_t_4, &__pyx_t_5, &__pyx_t_6) < 0) __PYX_ERR(0, 243, __pyx_L5_except_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_GOTREF(__pyx_t_5); __Pyx_GOTREF(__pyx_t_6); /* "lupa/_lupa.pyx":244 * py_to_lua(self, L, self._raised_exception[1]) * except: * lua.lua_pushlstring(L, lua_error_msg, len(lua_error_msg)) # <<<<<<<<<<<<<< * raise * return 0 */ if (unlikely(__pyx_v_lua_error_msg == Py_None)) { PyErr_SetString(PyExc_TypeError, "expected bytes, NoneType found"); __PYX_ERR(0, 244, __pyx_L5_except_error) } __pyx_t_8 = __Pyx_PyBytes_AsWritableString(__pyx_v_lua_error_msg); if (unlikely((!__pyx_t_8) && PyErr_Occurred())) __PYX_ERR(0, 244, __pyx_L5_except_error) if (unlikely(__pyx_v_lua_error_msg == Py_None)) { PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()"); __PYX_ERR(0, 244, __pyx_L5_except_error) } __pyx_t_9 = PyBytes_GET_SIZE(__pyx_v_lua_error_msg); if (unlikely(__pyx_t_9 == ((Py_ssize_t)-1))) __PYX_ERR(0, 244, __pyx_L5_except_error) lua_pushlstring(__pyx_v_L, __pyx_t_8, __pyx_t_9); /* "lupa/_lupa.pyx":245 * except: * lua.lua_pushlstring(L, lua_error_msg, len(lua_error_msg)) * raise # <<<<<<<<<<<<<< * return 0 * */ __Pyx_GIVEREF(__pyx_t_4); __Pyx_GIVEREF(__pyx_t_5); __Pyx_XGIVEREF(__pyx_t_6); __Pyx_ErrRestoreWithState(__pyx_t_4, __pyx_t_5, __pyx_t_6); __pyx_t_4 = 0; __pyx_t_5 = 0; __pyx_t_6 = 0; __PYX_ERR(0, 245, __pyx_L5_except_error) } __pyx_L5_except_error:; /* "lupa/_lupa.pyx":240 * @cython.final * cdef int store_raised_exception(self, lua_State* L, bytes lua_error_msg) except -1: * try: # <<<<<<<<<<<<<< * self._raised_exception = exc_info() * py_to_lua(self, L, self._raised_exception[1]) */ __Pyx_XGIVEREF(__pyx_t_1); __Pyx_XGIVEREF(__pyx_t_2); __Pyx_XGIVEREF(__pyx_t_3); __Pyx_ExceptionReset(__pyx_t_1, __pyx_t_2, __pyx_t_3); goto __pyx_L1_error; __pyx_L8_try_end:; } /* "lupa/_lupa.pyx":246 * lua.lua_pushlstring(L, lua_error_msg, len(lua_error_msg)) * raise * return 0 # <<<<<<<<<<<<<< * * def eval(self, lua_code, *args): */ __pyx_r = 0; goto __pyx_L0; /* "lupa/_lupa.pyx":239 * * @cython.final * cdef int store_raised_exception(self, lua_State* L, bytes lua_error_msg) except -1: # <<<<<<<<<<<<<< * try: * self._raised_exception = exc_info() */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_4); __Pyx_XDECREF(__pyx_t_5); __Pyx_XDECREF(__pyx_t_6); __Pyx_AddTraceback("lupa._lupa.LuaRuntime.store_raised_exception", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = -1; __pyx_L0:; __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "lupa/_lupa.pyx":248 * return 0 * * def eval(self, lua_code, *args): # <<<<<<<<<<<<<< * """Evaluate a Lua expression passed in a string. * """ */ /* Python wrapper */ static PyObject *__pyx_pw_4lupa_5_lupa_10LuaRuntime_5eval(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ static char __pyx_doc_4lupa_5_lupa_10LuaRuntime_4eval[] = "LuaRuntime.eval(self, lua_code, *args)\nEvaluate a Lua expression passed in a string.\n "; static PyMethodDef __pyx_mdef_4lupa_5_lupa_10LuaRuntime_5eval = {"eval", (PyCFunction)__pyx_pw_4lupa_5_lupa_10LuaRuntime_5eval, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4lupa_5_lupa_10LuaRuntime_4eval}; static PyObject *__pyx_pw_4lupa_5_lupa_10LuaRuntime_5eval(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { PyObject *__pyx_v_lua_code = 0; PyObject *__pyx_v_args = 0; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("eval (wrapper)", 0); if (PyTuple_GET_SIZE(__pyx_args) > 1) { __pyx_v_args = PyTuple_GetSlice(__pyx_args, 1, PyTuple_GET_SIZE(__pyx_args)); if (unlikely(!__pyx_v_args)) { __Pyx_RefNannyFinishContext(); return NULL; } __Pyx_GOTREF(__pyx_v_args); } else { __pyx_v_args = __pyx_empty_tuple; __Pyx_INCREF(__pyx_empty_tuple); } { static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_lua_code,0}; PyObject* values[1] = {0}; if (unlikely(__pyx_kwds)) { Py_ssize_t kw_args; const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args); switch (pos_args) { default: case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); CYTHON_FALLTHROUGH; case 0: break; } kw_args = PyDict_Size(__pyx_kwds); switch (pos_args) { case 0: if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_lua_code)) != 0)) kw_args--; else goto __pyx_L5_argtuple_error; } if (unlikely(kw_args > 0)) { const Py_ssize_t used_pos_args = (pos_args < 1) ? pos_args : 1; if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, used_pos_args, "eval") < 0)) __PYX_ERR(0, 248, __pyx_L3_error) } } else if (PyTuple_GET_SIZE(__pyx_args) < 1) { goto __pyx_L5_argtuple_error; } else { values[0] = PyTuple_GET_ITEM(__pyx_args, 0); } __pyx_v_lua_code = values[0]; } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("eval", 0, 1, 1, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 248, __pyx_L3_error) __pyx_L3_error:; __Pyx_DECREF(__pyx_v_args); __pyx_v_args = 0; __Pyx_AddTraceback("lupa._lupa.LuaRuntime.eval", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; __pyx_r = __pyx_pf_4lupa_5_lupa_10LuaRuntime_4eval(((struct __pyx_obj_4lupa_5_lupa_LuaRuntime *)__pyx_v_self), __pyx_v_lua_code, __pyx_v_args); /* function exit code */ __Pyx_XDECREF(__pyx_v_args); __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_4lupa_5_lupa_10LuaRuntime_4eval(struct __pyx_obj_4lupa_5_lupa_LuaRuntime *__pyx_v_self, PyObject *__pyx_v_lua_code, PyObject *__pyx_v_args) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations int __pyx_t_1; int __pyx_t_2; char const *__pyx_t_3; PyObject *__pyx_t_4 = NULL; PyObject *__pyx_t_5 = NULL; __Pyx_RefNannySetupContext("eval", 0); __Pyx_INCREF(__pyx_v_lua_code); /* "lupa/_lupa.pyx":251 * """Evaluate a Lua expression passed in a string. * """ * assert self._state is not NULL # <<<<<<<<<<<<<< * if isinstance(lua_code, unicode): * lua_code = (lua_code).encode(self._source_encoding) */ #ifndef CYTHON_WITHOUT_ASSERTIONS if (unlikely(!Py_OptimizeFlag)) { if (unlikely(!((__pyx_v_self->_state != NULL) != 0))) { PyErr_SetNone(PyExc_AssertionError); __PYX_ERR(0, 251, __pyx_L1_error) } } #endif /* "lupa/_lupa.pyx":252 * """ * assert self._state is not NULL * if isinstance(lua_code, unicode): # <<<<<<<<<<<<<< * lua_code = (lua_code).encode(self._source_encoding) * return run_lua(self, b'return ' + lua_code, args) */ __pyx_t_1 = PyUnicode_Check(__pyx_v_lua_code); __pyx_t_2 = (__pyx_t_1 != 0); if (__pyx_t_2) { /* "lupa/_lupa.pyx":253 * assert self._state is not NULL * if isinstance(lua_code, unicode): * lua_code = (lua_code).encode(self._source_encoding) # <<<<<<<<<<<<<< * return run_lua(self, b'return ' + lua_code, args) * */ if (unlikely(__pyx_v_lua_code == Py_None)) { PyErr_Format(PyExc_AttributeError, "'NoneType' object has no attribute '%.30s'", "encode"); __PYX_ERR(0, 253, __pyx_L1_error) } if (unlikely(__pyx_v_self->_source_encoding == Py_None)) { PyErr_SetString(PyExc_TypeError, "expected bytes, NoneType found"); __PYX_ERR(0, 253, __pyx_L1_error) } __pyx_t_3 = __Pyx_PyBytes_AsString(__pyx_v_self->_source_encoding); if (unlikely((!__pyx_t_3) && PyErr_Occurred())) __PYX_ERR(0, 253, __pyx_L1_error) __pyx_t_4 = PyUnicode_AsEncodedString(((PyObject*)__pyx_v_lua_code), __pyx_t_3, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 253, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF_SET(__pyx_v_lua_code, __pyx_t_4); __pyx_t_4 = 0; /* "lupa/_lupa.pyx":252 * """ * assert self._state is not NULL * if isinstance(lua_code, unicode): # <<<<<<<<<<<<<< * lua_code = (lua_code).encode(self._source_encoding) * return run_lua(self, b'return ' + lua_code, args) */ } /* "lupa/_lupa.pyx":254 * if isinstance(lua_code, unicode): * lua_code = (lua_code).encode(self._source_encoding) * return run_lua(self, b'return ' + lua_code, args) # <<<<<<<<<<<<<< * * def execute(self, lua_code, *args): */ __Pyx_XDECREF(__pyx_r); __pyx_t_4 = PyNumber_Add(__pyx_kp_b_return, __pyx_v_lua_code); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 254, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); if (!(likely(PyBytes_CheckExact(__pyx_t_4))||((__pyx_t_4) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "bytes", Py_TYPE(__pyx_t_4)->tp_name), 0))) __PYX_ERR(0, 254, __pyx_L1_error) __pyx_t_5 = __pyx_f_4lupa_5_lupa_run_lua(__pyx_v_self, ((PyObject*)__pyx_t_4), __pyx_v_args); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 254, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_r = __pyx_t_5; __pyx_t_5 = 0; goto __pyx_L0; /* "lupa/_lupa.pyx":248 * return 0 * * def eval(self, lua_code, *args): # <<<<<<<<<<<<<< * """Evaluate a Lua expression passed in a string. * """ */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_4); __Pyx_XDECREF(__pyx_t_5); __Pyx_AddTraceback("lupa._lupa.LuaRuntime.eval", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XDECREF(__pyx_v_lua_code); __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "lupa/_lupa.pyx":256 * return run_lua(self, b'return ' + lua_code, args) * * def execute(self, lua_code, *args): # <<<<<<<<<<<<<< * """Execute a Lua program passed in a string. * """ */ /* Python wrapper */ static PyObject *__pyx_pw_4lupa_5_lupa_10LuaRuntime_7execute(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ static char __pyx_doc_4lupa_5_lupa_10LuaRuntime_6execute[] = "LuaRuntime.execute(self, lua_code, *args)\nExecute a Lua program passed in a string.\n "; static PyMethodDef __pyx_mdef_4lupa_5_lupa_10LuaRuntime_7execute = {"execute", (PyCFunction)__pyx_pw_4lupa_5_lupa_10LuaRuntime_7execute, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4lupa_5_lupa_10LuaRuntime_6execute}; static PyObject *__pyx_pw_4lupa_5_lupa_10LuaRuntime_7execute(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { PyObject *__pyx_v_lua_code = 0; PyObject *__pyx_v_args = 0; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("execute (wrapper)", 0); if (PyTuple_GET_SIZE(__pyx_args) > 1) { __pyx_v_args = PyTuple_GetSlice(__pyx_args, 1, PyTuple_GET_SIZE(__pyx_args)); if (unlikely(!__pyx_v_args)) { __Pyx_RefNannyFinishContext(); return NULL; } __Pyx_GOTREF(__pyx_v_args); } else { __pyx_v_args = __pyx_empty_tuple; __Pyx_INCREF(__pyx_empty_tuple); } { static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_lua_code,0}; PyObject* values[1] = {0}; if (unlikely(__pyx_kwds)) { Py_ssize_t kw_args; const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args); switch (pos_args) { default: case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); CYTHON_FALLTHROUGH; case 0: break; } kw_args = PyDict_Size(__pyx_kwds); switch (pos_args) { case 0: if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_lua_code)) != 0)) kw_args--; else goto __pyx_L5_argtuple_error; } if (unlikely(kw_args > 0)) { const Py_ssize_t used_pos_args = (pos_args < 1) ? pos_args : 1; if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, used_pos_args, "execute") < 0)) __PYX_ERR(0, 256, __pyx_L3_error) } } else if (PyTuple_GET_SIZE(__pyx_args) < 1) { goto __pyx_L5_argtuple_error; } else { values[0] = PyTuple_GET_ITEM(__pyx_args, 0); } __pyx_v_lua_code = values[0]; } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("execute", 0, 1, 1, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 256, __pyx_L3_error) __pyx_L3_error:; __Pyx_DECREF(__pyx_v_args); __pyx_v_args = 0; __Pyx_AddTraceback("lupa._lupa.LuaRuntime.execute", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; __pyx_r = __pyx_pf_4lupa_5_lupa_10LuaRuntime_6execute(((struct __pyx_obj_4lupa_5_lupa_LuaRuntime *)__pyx_v_self), __pyx_v_lua_code, __pyx_v_args); /* function exit code */ __Pyx_XDECREF(__pyx_v_args); __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_4lupa_5_lupa_10LuaRuntime_6execute(struct __pyx_obj_4lupa_5_lupa_LuaRuntime *__pyx_v_self, PyObject *__pyx_v_lua_code, PyObject *__pyx_v_args) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations int __pyx_t_1; int __pyx_t_2; char const *__pyx_t_3; PyObject *__pyx_t_4 = NULL; __Pyx_RefNannySetupContext("execute", 0); __Pyx_INCREF(__pyx_v_lua_code); /* "lupa/_lupa.pyx":259 * """Execute a Lua program passed in a string. * """ * assert self._state is not NULL # <<<<<<<<<<<<<< * if isinstance(lua_code, unicode): * lua_code = (lua_code).encode(self._source_encoding) */ #ifndef CYTHON_WITHOUT_ASSERTIONS if (unlikely(!Py_OptimizeFlag)) { if (unlikely(!((__pyx_v_self->_state != NULL) != 0))) { PyErr_SetNone(PyExc_AssertionError); __PYX_ERR(0, 259, __pyx_L1_error) } } #endif /* "lupa/_lupa.pyx":260 * """ * assert self._state is not NULL * if isinstance(lua_code, unicode): # <<<<<<<<<<<<<< * lua_code = (lua_code).encode(self._source_encoding) * return run_lua(self, lua_code, args) */ __pyx_t_1 = PyUnicode_Check(__pyx_v_lua_code); __pyx_t_2 = (__pyx_t_1 != 0); if (__pyx_t_2) { /* "lupa/_lupa.pyx":261 * assert self._state is not NULL * if isinstance(lua_code, unicode): * lua_code = (lua_code).encode(self._source_encoding) # <<<<<<<<<<<<<< * return run_lua(self, lua_code, args) * */ if (unlikely(__pyx_v_lua_code == Py_None)) { PyErr_Format(PyExc_AttributeError, "'NoneType' object has no attribute '%.30s'", "encode"); __PYX_ERR(0, 261, __pyx_L1_error) } if (unlikely(__pyx_v_self->_source_encoding == Py_None)) { PyErr_SetString(PyExc_TypeError, "expected bytes, NoneType found"); __PYX_ERR(0, 261, __pyx_L1_error) } __pyx_t_3 = __Pyx_PyBytes_AsString(__pyx_v_self->_source_encoding); if (unlikely((!__pyx_t_3) && PyErr_Occurred())) __PYX_ERR(0, 261, __pyx_L1_error) __pyx_t_4 = PyUnicode_AsEncodedString(((PyObject*)__pyx_v_lua_code), __pyx_t_3, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 261, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF_SET(__pyx_v_lua_code, __pyx_t_4); __pyx_t_4 = 0; /* "lupa/_lupa.pyx":260 * """ * assert self._state is not NULL * if isinstance(lua_code, unicode): # <<<<<<<<<<<<<< * lua_code = (lua_code).encode(self._source_encoding) * return run_lua(self, lua_code, args) */ } /* "lupa/_lupa.pyx":262 * if isinstance(lua_code, unicode): * lua_code = (lua_code).encode(self._source_encoding) * return run_lua(self, lua_code, args) # <<<<<<<<<<<<<< * * def compile(self, lua_code): */ __Pyx_XDECREF(__pyx_r); if (!(likely(PyBytes_CheckExact(__pyx_v_lua_code))||((__pyx_v_lua_code) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "bytes", Py_TYPE(__pyx_v_lua_code)->tp_name), 0))) __PYX_ERR(0, 262, __pyx_L1_error) __pyx_t_4 = __pyx_f_4lupa_5_lupa_run_lua(__pyx_v_self, ((PyObject*)__pyx_v_lua_code), __pyx_v_args); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 262, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_r = __pyx_t_4; __pyx_t_4 = 0; goto __pyx_L0; /* "lupa/_lupa.pyx":256 * return run_lua(self, b'return ' + lua_code, args) * * def execute(self, lua_code, *args): # <<<<<<<<<<<<<< * """Execute a Lua program passed in a string. * """ */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_4); __Pyx_AddTraceback("lupa._lupa.LuaRuntime.execute", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XDECREF(__pyx_v_lua_code); __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "lupa/_lupa.pyx":264 * return run_lua(self, lua_code, args) * * def compile(self, lua_code): # <<<<<<<<<<<<<< * """Compile a Lua program into a callable Lua function. * """ */ /* Python wrapper */ static PyObject *__pyx_pw_4lupa_5_lupa_10LuaRuntime_9compile(PyObject *__pyx_v_self, PyObject *__pyx_v_lua_code); /*proto*/ static char __pyx_doc_4lupa_5_lupa_10LuaRuntime_8compile[] = "LuaRuntime.compile(self, lua_code)\nCompile a Lua program into a callable Lua function.\n "; static PyMethodDef __pyx_mdef_4lupa_5_lupa_10LuaRuntime_9compile = {"compile", (PyCFunction)__pyx_pw_4lupa_5_lupa_10LuaRuntime_9compile, METH_O, __pyx_doc_4lupa_5_lupa_10LuaRuntime_8compile}; static PyObject *__pyx_pw_4lupa_5_lupa_10LuaRuntime_9compile(PyObject *__pyx_v_self, PyObject *__pyx_v_lua_code) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("compile (wrapper)", 0); __pyx_r = __pyx_pf_4lupa_5_lupa_10LuaRuntime_8compile(((struct __pyx_obj_4lupa_5_lupa_LuaRuntime *)__pyx_v_self), ((PyObject *)__pyx_v_lua_code)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_4lupa_5_lupa_10LuaRuntime_8compile(struct __pyx_obj_4lupa_5_lupa_LuaRuntime *__pyx_v_self, PyObject *__pyx_v_lua_code) { char const *__pyx_v_err; lua_State *__pyx_v_L; int __pyx_v_oldtop; size_t __pyx_v_size; int __pyx_v_status; PyObject *__pyx_v_error = NULL; PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations int __pyx_t_1; int __pyx_t_2; char const *__pyx_t_3; PyObject *__pyx_t_4 = NULL; lua_State *__pyx_t_5; int __pyx_t_6; char *__pyx_t_7; Py_ssize_t __pyx_t_8; PyObject *__pyx_t_9 = NULL; PyObject *__pyx_t_10 = NULL; PyObject *__pyx_t_11 = NULL; int __pyx_t_12; char const *__pyx_t_13; PyObject *__pyx_t_14 = NULL; PyObject *__pyx_t_15 = NULL; PyObject *__pyx_t_16 = NULL; PyObject *__pyx_t_17 = NULL; PyObject *__pyx_t_18 = NULL; PyObject *__pyx_t_19 = NULL; __Pyx_RefNannySetupContext("compile", 0); __Pyx_INCREF(__pyx_v_lua_code); /* "lupa/_lupa.pyx":268 * """ * cdef const char *err * if isinstance(lua_code, unicode): # <<<<<<<<<<<<<< * lua_code = (lua_code).encode(self._source_encoding) * L = self._state */ __pyx_t_1 = PyUnicode_Check(__pyx_v_lua_code); __pyx_t_2 = (__pyx_t_1 != 0); if (__pyx_t_2) { /* "lupa/_lupa.pyx":269 * cdef const char *err * if isinstance(lua_code, unicode): * lua_code = (lua_code).encode(self._source_encoding) # <<<<<<<<<<<<<< * L = self._state * lock_runtime(self) */ if (unlikely(__pyx_v_lua_code == Py_None)) { PyErr_Format(PyExc_AttributeError, "'NoneType' object has no attribute '%.30s'", "encode"); __PYX_ERR(0, 269, __pyx_L1_error) } if (unlikely(__pyx_v_self->_source_encoding == Py_None)) { PyErr_SetString(PyExc_TypeError, "expected bytes, NoneType found"); __PYX_ERR(0, 269, __pyx_L1_error) } __pyx_t_3 = __Pyx_PyBytes_AsString(__pyx_v_self->_source_encoding); if (unlikely((!__pyx_t_3) && PyErr_Occurred())) __PYX_ERR(0, 269, __pyx_L1_error) __pyx_t_4 = PyUnicode_AsEncodedString(((PyObject*)__pyx_v_lua_code), __pyx_t_3, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 269, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF_SET(__pyx_v_lua_code, __pyx_t_4); __pyx_t_4 = 0; /* "lupa/_lupa.pyx":268 * """ * cdef const char *err * if isinstance(lua_code, unicode): # <<<<<<<<<<<<<< * lua_code = (lua_code).encode(self._source_encoding) * L = self._state */ } /* "lupa/_lupa.pyx":270 * if isinstance(lua_code, unicode): * lua_code = (lua_code).encode(self._source_encoding) * L = self._state # <<<<<<<<<<<<<< * lock_runtime(self) * oldtop = lua.lua_gettop(L) */ __pyx_t_5 = __pyx_v_self->_state; __pyx_v_L = __pyx_t_5; /* "lupa/_lupa.pyx":271 * lua_code = (lua_code).encode(self._source_encoding) * L = self._state * lock_runtime(self) # <<<<<<<<<<<<<< * oldtop = lua.lua_gettop(L) * cdef size_t size */ __pyx_t_6 = __pyx_f_4lupa_5_lupa_lock_runtime(__pyx_v_self); if (unlikely(__pyx_t_6 == ((int)-1))) __PYX_ERR(0, 271, __pyx_L1_error) /* "lupa/_lupa.pyx":272 * L = self._state * lock_runtime(self) * oldtop = lua.lua_gettop(L) # <<<<<<<<<<<<<< * cdef size_t size * try: */ __pyx_v_oldtop = lua_gettop(__pyx_v_L); /* "lupa/_lupa.pyx":274 * oldtop = lua.lua_gettop(L) * cdef size_t size * try: # <<<<<<<<<<<<<< * status = lua.luaL_loadbuffer(L, lua_code, len(lua_code), b'') * if status == 0: */ /*try:*/ { /* "lupa/_lupa.pyx":275 * cdef size_t size * try: * status = lua.luaL_loadbuffer(L, lua_code, len(lua_code), b'') # <<<<<<<<<<<<<< * if status == 0: * return py_from_lua(self, L, -1) */ __pyx_t_7 = __Pyx_PyObject_AsWritableString(__pyx_v_lua_code); if (unlikely((!__pyx_t_7) && PyErr_Occurred())) __PYX_ERR(0, 275, __pyx_L5_error) __pyx_t_8 = PyObject_Length(__pyx_v_lua_code); if (unlikely(__pyx_t_8 == ((Py_ssize_t)-1))) __PYX_ERR(0, 275, __pyx_L5_error) __pyx_v_status = luaL_loadbuffer(__pyx_v_L, __pyx_t_7, __pyx_t_8, ((char *)"")); /* "lupa/_lupa.pyx":276 * try: * status = lua.luaL_loadbuffer(L, lua_code, len(lua_code), b'') * if status == 0: # <<<<<<<<<<<<<< * return py_from_lua(self, L, -1) * else: */ __pyx_t_2 = ((__pyx_v_status == 0) != 0); if (__pyx_t_2) { /* "lupa/_lupa.pyx":277 * status = lua.luaL_loadbuffer(L, lua_code, len(lua_code), b'') * if status == 0: * return py_from_lua(self, L, -1) # <<<<<<<<<<<<<< * else: * err = lua.lua_tolstring(L, -1, &size) */ __Pyx_XDECREF(__pyx_r); __pyx_t_4 = __pyx_f_4lupa_5_lupa_py_from_lua(__pyx_v_self, __pyx_v_L, -1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 277, __pyx_L5_error) __Pyx_GOTREF(__pyx_t_4); __pyx_r = __pyx_t_4; __pyx_t_4 = 0; goto __pyx_L4_return; /* "lupa/_lupa.pyx":276 * try: * status = lua.luaL_loadbuffer(L, lua_code, len(lua_code), b'') * if status == 0: # <<<<<<<<<<<<<< * return py_from_lua(self, L, -1) * else: */ } /* "lupa/_lupa.pyx":279 * return py_from_lua(self, L, -1) * else: * err = lua.lua_tolstring(L, -1, &size) # <<<<<<<<<<<<<< * error = err[:size] if self._encoding is None else err[:size].decode(self._encoding) * raise LuaSyntaxError(error) */ /*else*/ { __pyx_v_err = lua_tolstring(__pyx_v_L, -1, (&__pyx_v_size)); /* "lupa/_lupa.pyx":280 * else: * err = lua.lua_tolstring(L, -1, &size) * error = err[:size] if self._encoding is None else err[:size].decode(self._encoding) # <<<<<<<<<<<<<< * raise LuaSyntaxError(error) * finally: */ __pyx_t_2 = (__pyx_v_self->_encoding == ((PyObject*)Py_None)); if ((__pyx_t_2 != 0)) { __pyx_t_9 = __Pyx_PyBytes_FromStringAndSize(__pyx_v_err + 0, __pyx_v_size - 0); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 280, __pyx_L5_error) __Pyx_GOTREF(__pyx_t_9); __pyx_t_4 = __pyx_t_9; __pyx_t_9 = 0; } else { if (unlikely(__pyx_v_self->_encoding == Py_None)) { PyErr_SetString(PyExc_TypeError, "expected bytes, NoneType found"); __PYX_ERR(0, 280, __pyx_L5_error) } __pyx_t_3 = __Pyx_PyBytes_AsString(__pyx_v_self->_encoding); if (unlikely((!__pyx_t_3) && PyErr_Occurred())) __PYX_ERR(0, 280, __pyx_L5_error) __pyx_t_9 = __Pyx_decode_c_string(__pyx_v_err, 0, __pyx_v_size, __pyx_t_3, NULL, NULL); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 280, __pyx_L5_error) __Pyx_GOTREF(__pyx_t_9); __pyx_t_4 = __pyx_t_9; __pyx_t_9 = 0; } __pyx_v_error = __pyx_t_4; __pyx_t_4 = 0; /* "lupa/_lupa.pyx":281 * err = lua.lua_tolstring(L, -1, &size) * error = err[:size] if self._encoding is None else err[:size].decode(self._encoding) * raise LuaSyntaxError(error) # <<<<<<<<<<<<<< * finally: * lua.lua_settop(L, oldtop) */ __pyx_t_9 = __Pyx_GetModuleGlobalName(__pyx_n_s_LuaSyntaxError); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 281, __pyx_L5_error) __Pyx_GOTREF(__pyx_t_9); __pyx_t_10 = NULL; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_9))) { __pyx_t_10 = PyMethod_GET_SELF(__pyx_t_9); if (likely(__pyx_t_10)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_9); __Pyx_INCREF(__pyx_t_10); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_9, function); } } if (!__pyx_t_10) { __pyx_t_4 = __Pyx_PyObject_CallOneArg(__pyx_t_9, __pyx_v_error); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 281, __pyx_L5_error) __Pyx_GOTREF(__pyx_t_4); } else { #if CYTHON_FAST_PYCALL if (PyFunction_Check(__pyx_t_9)) { PyObject *__pyx_temp[2] = {__pyx_t_10, __pyx_v_error}; __pyx_t_4 = __Pyx_PyFunction_FastCall(__pyx_t_9, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 281, __pyx_L5_error) __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0; __Pyx_GOTREF(__pyx_t_4); } else #endif #if CYTHON_FAST_PYCCALL if (__Pyx_PyFastCFunction_Check(__pyx_t_9)) { PyObject *__pyx_temp[2] = {__pyx_t_10, __pyx_v_error}; __pyx_t_4 = __Pyx_PyCFunction_FastCall(__pyx_t_9, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 281, __pyx_L5_error) __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0; __Pyx_GOTREF(__pyx_t_4); } else #endif { __pyx_t_11 = PyTuple_New(1+1); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 281, __pyx_L5_error) __Pyx_GOTREF(__pyx_t_11); __Pyx_GIVEREF(__pyx_t_10); PyTuple_SET_ITEM(__pyx_t_11, 0, __pyx_t_10); __pyx_t_10 = NULL; __Pyx_INCREF(__pyx_v_error); __Pyx_GIVEREF(__pyx_v_error); PyTuple_SET_ITEM(__pyx_t_11, 0+1, __pyx_v_error); __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_9, __pyx_t_11, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 281, __pyx_L5_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; } } __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; __Pyx_Raise(__pyx_t_4, 0, 0, 0); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __PYX_ERR(0, 281, __pyx_L5_error) } } /* "lupa/_lupa.pyx":283 * raise LuaSyntaxError(error) * finally: * lua.lua_settop(L, oldtop) # <<<<<<<<<<<<<< * unlock_runtime(self) * */ /*finally:*/ { __pyx_L5_error:; /*exception exit:*/{ __Pyx_PyThreadState_declare __Pyx_PyThreadState_assign __pyx_t_14 = 0; __pyx_t_15 = 0; __pyx_t_16 = 0; __pyx_t_17 = 0; __pyx_t_18 = 0; __pyx_t_19 = 0; __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0; __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0; __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0; __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; if (PY_MAJOR_VERSION >= 3) __Pyx_ExceptionSwap(&__pyx_t_17, &__pyx_t_18, &__pyx_t_19); if ((PY_MAJOR_VERSION < 3) || unlikely(__Pyx_GetException(&__pyx_t_14, &__pyx_t_15, &__pyx_t_16) < 0)) __Pyx_ErrFetch(&__pyx_t_14, &__pyx_t_15, &__pyx_t_16); __Pyx_XGOTREF(__pyx_t_14); __Pyx_XGOTREF(__pyx_t_15); __Pyx_XGOTREF(__pyx_t_16); __Pyx_XGOTREF(__pyx_t_17); __Pyx_XGOTREF(__pyx_t_18); __Pyx_XGOTREF(__pyx_t_19); __pyx_t_6 = __pyx_lineno; __pyx_t_12 = __pyx_clineno; __pyx_t_13 = __pyx_filename; { lua_settop(__pyx_v_L, __pyx_v_oldtop); /* "lupa/_lupa.pyx":284 * finally: * lua.lua_settop(L, oldtop) * unlock_runtime(self) # <<<<<<<<<<<<<< * * def require(self, modulename): */ __pyx_f_4lupa_5_lupa_unlock_runtime(__pyx_v_self); } if (PY_MAJOR_VERSION >= 3) { __Pyx_XGIVEREF(__pyx_t_17); __Pyx_XGIVEREF(__pyx_t_18); __Pyx_XGIVEREF(__pyx_t_19); __Pyx_ExceptionReset(__pyx_t_17, __pyx_t_18, __pyx_t_19); } __Pyx_XGIVEREF(__pyx_t_14); __Pyx_XGIVEREF(__pyx_t_15); __Pyx_XGIVEREF(__pyx_t_16); __Pyx_ErrRestore(__pyx_t_14, __pyx_t_15, __pyx_t_16); __pyx_t_14 = 0; __pyx_t_15 = 0; __pyx_t_16 = 0; __pyx_t_17 = 0; __pyx_t_18 = 0; __pyx_t_19 = 0; __pyx_lineno = __pyx_t_6; __pyx_clineno = __pyx_t_12; __pyx_filename = __pyx_t_13; goto __pyx_L1_error; } __pyx_L4_return: { __pyx_t_19 = __pyx_r; __pyx_r = 0; /* "lupa/_lupa.pyx":283 * raise LuaSyntaxError(error) * finally: * lua.lua_settop(L, oldtop) # <<<<<<<<<<<<<< * unlock_runtime(self) * */ lua_settop(__pyx_v_L, __pyx_v_oldtop); /* "lupa/_lupa.pyx":284 * finally: * lua.lua_settop(L, oldtop) * unlock_runtime(self) # <<<<<<<<<<<<<< * * def require(self, modulename): */ __pyx_f_4lupa_5_lupa_unlock_runtime(__pyx_v_self); __pyx_r = __pyx_t_19; __pyx_t_19 = 0; goto __pyx_L0; } } /* "lupa/_lupa.pyx":264 * return run_lua(self, lua_code, args) * * def compile(self, lua_code): # <<<<<<<<<<<<<< * """Compile a Lua program into a callable Lua function. * """ */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_4); __Pyx_XDECREF(__pyx_t_9); __Pyx_XDECREF(__pyx_t_10); __Pyx_XDECREF(__pyx_t_11); __Pyx_AddTraceback("lupa._lupa.LuaRuntime.compile", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XDECREF(__pyx_v_error); __Pyx_XDECREF(__pyx_v_lua_code); __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "lupa/_lupa.pyx":286 * unlock_runtime(self) * * def require(self, modulename): # <<<<<<<<<<<<<< * """Load a Lua library into the runtime. * """ */ /* Python wrapper */ static PyObject *__pyx_pw_4lupa_5_lupa_10LuaRuntime_11require(PyObject *__pyx_v_self, PyObject *__pyx_v_modulename); /*proto*/ static char __pyx_doc_4lupa_5_lupa_10LuaRuntime_10require[] = "LuaRuntime.require(self, modulename)\nLoad a Lua library into the runtime.\n "; static PyMethodDef __pyx_mdef_4lupa_5_lupa_10LuaRuntime_11require = {"require", (PyCFunction)__pyx_pw_4lupa_5_lupa_10LuaRuntime_11require, METH_O, __pyx_doc_4lupa_5_lupa_10LuaRuntime_10require}; static PyObject *__pyx_pw_4lupa_5_lupa_10LuaRuntime_11require(PyObject *__pyx_v_self, PyObject *__pyx_v_modulename) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("require (wrapper)", 0); __pyx_r = __pyx_pf_4lupa_5_lupa_10LuaRuntime_10require(((struct __pyx_obj_4lupa_5_lupa_LuaRuntime *)__pyx_v_self), ((PyObject *)__pyx_v_modulename)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_4lupa_5_lupa_10LuaRuntime_10require(struct __pyx_obj_4lupa_5_lupa_LuaRuntime *__pyx_v_self, PyObject *__pyx_v_modulename) { lua_State *__pyx_v_L; int __pyx_v_old_top; PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations lua_State *__pyx_t_1; int __pyx_t_2; int __pyx_t_3; int __pyx_t_4; PyObject *__pyx_t_5 = NULL; int __pyx_t_6; PyObject *__pyx_t_7 = NULL; int __pyx_t_8; char const *__pyx_t_9; PyObject *__pyx_t_10 = NULL; PyObject *__pyx_t_11 = NULL; PyObject *__pyx_t_12 = NULL; PyObject *__pyx_t_13 = NULL; PyObject *__pyx_t_14 = NULL; PyObject *__pyx_t_15 = NULL; __Pyx_RefNannySetupContext("require", 0); /* "lupa/_lupa.pyx":289 * """Load a Lua library into the runtime. * """ * assert self._state is not NULL # <<<<<<<<<<<<<< * cdef lua_State *L = self._state * if not isinstance(modulename, (bytes, unicode)): */ #ifndef CYTHON_WITHOUT_ASSERTIONS if (unlikely(!Py_OptimizeFlag)) { if (unlikely(!((__pyx_v_self->_state != NULL) != 0))) { PyErr_SetNone(PyExc_AssertionError); __PYX_ERR(0, 289, __pyx_L1_error) } } #endif /* "lupa/_lupa.pyx":290 * """ * assert self._state is not NULL * cdef lua_State *L = self._state # <<<<<<<<<<<<<< * if not isinstance(modulename, (bytes, unicode)): * raise TypeError("modulename must be a string") */ __pyx_t_1 = __pyx_v_self->_state; __pyx_v_L = __pyx_t_1; /* "lupa/_lupa.pyx":291 * assert self._state is not NULL * cdef lua_State *L = self._state * if not isinstance(modulename, (bytes, unicode)): # <<<<<<<<<<<<<< * raise TypeError("modulename must be a string") * lock_runtime(self) */ __pyx_t_3 = PyBytes_Check(__pyx_v_modulename); __pyx_t_4 = (__pyx_t_3 != 0); if (!__pyx_t_4) { } else { __pyx_t_2 = __pyx_t_4; goto __pyx_L4_bool_binop_done; } __pyx_t_4 = PyUnicode_Check(__pyx_v_modulename); __pyx_t_3 = (__pyx_t_4 != 0); __pyx_t_2 = __pyx_t_3; __pyx_L4_bool_binop_done:; __pyx_t_3 = ((!(__pyx_t_2 != 0)) != 0); if (__pyx_t_3) { /* "lupa/_lupa.pyx":292 * cdef lua_State *L = self._state * if not isinstance(modulename, (bytes, unicode)): * raise TypeError("modulename must be a string") # <<<<<<<<<<<<<< * lock_runtime(self) * old_top = lua.lua_gettop(L) */ __pyx_t_5 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__9, NULL); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 292, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_Raise(__pyx_t_5, 0, 0, 0); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __PYX_ERR(0, 292, __pyx_L1_error) /* "lupa/_lupa.pyx":291 * assert self._state is not NULL * cdef lua_State *L = self._state * if not isinstance(modulename, (bytes, unicode)): # <<<<<<<<<<<<<< * raise TypeError("modulename must be a string") * lock_runtime(self) */ } /* "lupa/_lupa.pyx":293 * if not isinstance(modulename, (bytes, unicode)): * raise TypeError("modulename must be a string") * lock_runtime(self) # <<<<<<<<<<<<<< * old_top = lua.lua_gettop(L) * try: */ __pyx_t_6 = __pyx_f_4lupa_5_lupa_lock_runtime(__pyx_v_self); if (unlikely(__pyx_t_6 == ((int)-1))) __PYX_ERR(0, 293, __pyx_L1_error) /* "lupa/_lupa.pyx":294 * raise TypeError("modulename must be a string") * lock_runtime(self) * old_top = lua.lua_gettop(L) # <<<<<<<<<<<<<< * try: * lua.lua_getglobal(L, 'require') */ __pyx_v_old_top = lua_gettop(__pyx_v_L); /* "lupa/_lupa.pyx":295 * lock_runtime(self) * old_top = lua.lua_gettop(L) * try: # <<<<<<<<<<<<<< * lua.lua_getglobal(L, 'require') * if lua.lua_isnil(L, -1): */ /*try:*/ { /* "lupa/_lupa.pyx":296 * old_top = lua.lua_gettop(L) * try: * lua.lua_getglobal(L, 'require') # <<<<<<<<<<<<<< * if lua.lua_isnil(L, -1): * raise LuaError("require is not defined") */ lua_getglobal(__pyx_v_L, ((char *)"require")); /* "lupa/_lupa.pyx":297 * try: * lua.lua_getglobal(L, 'require') * if lua.lua_isnil(L, -1): # <<<<<<<<<<<<<< * raise LuaError("require is not defined") * return call_lua(self, L, (modulename,)) */ __pyx_t_3 = (lua_isnil(__pyx_v_L, -1) != 0); if (__pyx_t_3) { /* "lupa/_lupa.pyx":298 * lua.lua_getglobal(L, 'require') * if lua.lua_isnil(L, -1): * raise LuaError("require is not defined") # <<<<<<<<<<<<<< * return call_lua(self, L, (modulename,)) * finally: */ __pyx_t_5 = __Pyx_GetModuleGlobalName(__pyx_n_s_LuaError); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 298, __pyx_L7_error) __Pyx_GOTREF(__pyx_t_5); __pyx_t_7 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_tuple__10, NULL); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 298, __pyx_L7_error) __Pyx_GOTREF(__pyx_t_7); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_Raise(__pyx_t_7, 0, 0, 0); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; __PYX_ERR(0, 298, __pyx_L7_error) /* "lupa/_lupa.pyx":297 * try: * lua.lua_getglobal(L, 'require') * if lua.lua_isnil(L, -1): # <<<<<<<<<<<<<< * raise LuaError("require is not defined") * return call_lua(self, L, (modulename,)) */ } /* "lupa/_lupa.pyx":299 * if lua.lua_isnil(L, -1): * raise LuaError("require is not defined") * return call_lua(self, L, (modulename,)) # <<<<<<<<<<<<<< * finally: * lua.lua_settop(L, old_top) */ __Pyx_XDECREF(__pyx_r); __pyx_t_7 = PyTuple_New(1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 299, __pyx_L7_error) __Pyx_GOTREF(__pyx_t_7); __Pyx_INCREF(__pyx_v_modulename); __Pyx_GIVEREF(__pyx_v_modulename); PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_v_modulename); __pyx_t_5 = __pyx_f_4lupa_5_lupa_call_lua(__pyx_v_self, __pyx_v_L, ((PyObject*)__pyx_t_7)); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 299, __pyx_L7_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; __pyx_r = __pyx_t_5; __pyx_t_5 = 0; goto __pyx_L6_return; } /* "lupa/_lupa.pyx":301 * return call_lua(self, L, (modulename,)) * finally: * lua.lua_settop(L, old_top) # <<<<<<<<<<<<<< * unlock_runtime(self) * */ /*finally:*/ { __pyx_L7_error:; /*exception exit:*/{ __Pyx_PyThreadState_declare __Pyx_PyThreadState_assign __pyx_t_10 = 0; __pyx_t_11 = 0; __pyx_t_12 = 0; __pyx_t_13 = 0; __pyx_t_14 = 0; __pyx_t_15 = 0; __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0; __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; if (PY_MAJOR_VERSION >= 3) __Pyx_ExceptionSwap(&__pyx_t_13, &__pyx_t_14, &__pyx_t_15); if ((PY_MAJOR_VERSION < 3) || unlikely(__Pyx_GetException(&__pyx_t_10, &__pyx_t_11, &__pyx_t_12) < 0)) __Pyx_ErrFetch(&__pyx_t_10, &__pyx_t_11, &__pyx_t_12); __Pyx_XGOTREF(__pyx_t_10); __Pyx_XGOTREF(__pyx_t_11); __Pyx_XGOTREF(__pyx_t_12); __Pyx_XGOTREF(__pyx_t_13); __Pyx_XGOTREF(__pyx_t_14); __Pyx_XGOTREF(__pyx_t_15); __pyx_t_6 = __pyx_lineno; __pyx_t_8 = __pyx_clineno; __pyx_t_9 = __pyx_filename; { lua_settop(__pyx_v_L, __pyx_v_old_top); /* "lupa/_lupa.pyx":302 * finally: * lua.lua_settop(L, old_top) * unlock_runtime(self) # <<<<<<<<<<<<<< * * def globals(self): */ __pyx_f_4lupa_5_lupa_unlock_runtime(__pyx_v_self); } if (PY_MAJOR_VERSION >= 3) { __Pyx_XGIVEREF(__pyx_t_13); __Pyx_XGIVEREF(__pyx_t_14); __Pyx_XGIVEREF(__pyx_t_15); __Pyx_ExceptionReset(__pyx_t_13, __pyx_t_14, __pyx_t_15); } __Pyx_XGIVEREF(__pyx_t_10); __Pyx_XGIVEREF(__pyx_t_11); __Pyx_XGIVEREF(__pyx_t_12); __Pyx_ErrRestore(__pyx_t_10, __pyx_t_11, __pyx_t_12); __pyx_t_10 = 0; __pyx_t_11 = 0; __pyx_t_12 = 0; __pyx_t_13 = 0; __pyx_t_14 = 0; __pyx_t_15 = 0; __pyx_lineno = __pyx_t_6; __pyx_clineno = __pyx_t_8; __pyx_filename = __pyx_t_9; goto __pyx_L1_error; } __pyx_L6_return: { __pyx_t_15 = __pyx_r; __pyx_r = 0; /* "lupa/_lupa.pyx":301 * return call_lua(self, L, (modulename,)) * finally: * lua.lua_settop(L, old_top) # <<<<<<<<<<<<<< * unlock_runtime(self) * */ lua_settop(__pyx_v_L, __pyx_v_old_top); /* "lupa/_lupa.pyx":302 * finally: * lua.lua_settop(L, old_top) * unlock_runtime(self) # <<<<<<<<<<<<<< * * def globals(self): */ __pyx_f_4lupa_5_lupa_unlock_runtime(__pyx_v_self); __pyx_r = __pyx_t_15; __pyx_t_15 = 0; goto __pyx_L0; } } /* "lupa/_lupa.pyx":286 * unlock_runtime(self) * * def require(self, modulename): # <<<<<<<<<<<<<< * """Load a Lua library into the runtime. * """ */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_5); __Pyx_XDECREF(__pyx_t_7); __Pyx_AddTraceback("lupa._lupa.LuaRuntime.require", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "lupa/_lupa.pyx":304 * unlock_runtime(self) * * def globals(self): # <<<<<<<<<<<<<< * """Return the globals defined in this Lua runtime as a Lua * table. */ /* Python wrapper */ static PyObject *__pyx_pw_4lupa_5_lupa_10LuaRuntime_13globals(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ static char __pyx_doc_4lupa_5_lupa_10LuaRuntime_12globals[] = "LuaRuntime.globals(self)\nReturn the globals defined in this Lua runtime as a Lua\n table.\n "; static PyMethodDef __pyx_mdef_4lupa_5_lupa_10LuaRuntime_13globals = {"globals", (PyCFunction)__pyx_pw_4lupa_5_lupa_10LuaRuntime_13globals, METH_NOARGS, __pyx_doc_4lupa_5_lupa_10LuaRuntime_12globals}; static PyObject *__pyx_pw_4lupa_5_lupa_10LuaRuntime_13globals(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("globals (wrapper)", 0); __pyx_r = __pyx_pf_4lupa_5_lupa_10LuaRuntime_12globals(((struct __pyx_obj_4lupa_5_lupa_LuaRuntime *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_4lupa_5_lupa_10LuaRuntime_12globals(struct __pyx_obj_4lupa_5_lupa_LuaRuntime *__pyx_v_self) { lua_State *__pyx_v_L; int __pyx_v_old_top; PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations lua_State *__pyx_t_1; int __pyx_t_2; int __pyx_t_3; PyObject *__pyx_t_4 = NULL; PyObject *__pyx_t_5 = NULL; int __pyx_t_6; char const *__pyx_t_7; PyObject *__pyx_t_8 = NULL; PyObject *__pyx_t_9 = NULL; PyObject *__pyx_t_10 = NULL; PyObject *__pyx_t_11 = NULL; PyObject *__pyx_t_12 = NULL; PyObject *__pyx_t_13 = NULL; __Pyx_RefNannySetupContext("globals", 0); /* "lupa/_lupa.pyx":308 * table. * """ * assert self._state is not NULL # <<<<<<<<<<<<<< * cdef lua_State *L = self._state * lock_runtime(self) */ #ifndef CYTHON_WITHOUT_ASSERTIONS if (unlikely(!Py_OptimizeFlag)) { if (unlikely(!((__pyx_v_self->_state != NULL) != 0))) { PyErr_SetNone(PyExc_AssertionError); __PYX_ERR(0, 308, __pyx_L1_error) } } #endif /* "lupa/_lupa.pyx":309 * """ * assert self._state is not NULL * cdef lua_State *L = self._state # <<<<<<<<<<<<<< * lock_runtime(self) * old_top = lua.lua_gettop(L) */ __pyx_t_1 = __pyx_v_self->_state; __pyx_v_L = __pyx_t_1; /* "lupa/_lupa.pyx":310 * assert self._state is not NULL * cdef lua_State *L = self._state * lock_runtime(self) # <<<<<<<<<<<<<< * old_top = lua.lua_gettop(L) * try: */ __pyx_t_2 = __pyx_f_4lupa_5_lupa_lock_runtime(__pyx_v_self); if (unlikely(__pyx_t_2 == ((int)-1))) __PYX_ERR(0, 310, __pyx_L1_error) /* "lupa/_lupa.pyx":311 * cdef lua_State *L = self._state * lock_runtime(self) * old_top = lua.lua_gettop(L) # <<<<<<<<<<<<<< * try: * lua.lua_getglobal(L, '_G') */ __pyx_v_old_top = lua_gettop(__pyx_v_L); /* "lupa/_lupa.pyx":312 * lock_runtime(self) * old_top = lua.lua_gettop(L) * try: # <<<<<<<<<<<<<< * lua.lua_getglobal(L, '_G') * if lua.lua_isnil(L, -1): */ /*try:*/ { /* "lupa/_lupa.pyx":313 * old_top = lua.lua_gettop(L) * try: * lua.lua_getglobal(L, '_G') # <<<<<<<<<<<<<< * if lua.lua_isnil(L, -1): * raise LuaError("globals not defined") */ lua_getglobal(__pyx_v_L, ((char *)"_G")); /* "lupa/_lupa.pyx":314 * try: * lua.lua_getglobal(L, '_G') * if lua.lua_isnil(L, -1): # <<<<<<<<<<<<<< * raise LuaError("globals not defined") * return py_from_lua(self, L, -1) */ __pyx_t_3 = (lua_isnil(__pyx_v_L, -1) != 0); if (__pyx_t_3) { /* "lupa/_lupa.pyx":315 * lua.lua_getglobal(L, '_G') * if lua.lua_isnil(L, -1): * raise LuaError("globals not defined") # <<<<<<<<<<<<<< * return py_from_lua(self, L, -1) * finally: */ __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_LuaError); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 315, __pyx_L4_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_5 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_tuple__11, NULL); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 315, __pyx_L4_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_Raise(__pyx_t_5, 0, 0, 0); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __PYX_ERR(0, 315, __pyx_L4_error) /* "lupa/_lupa.pyx":314 * try: * lua.lua_getglobal(L, '_G') * if lua.lua_isnil(L, -1): # <<<<<<<<<<<<<< * raise LuaError("globals not defined") * return py_from_lua(self, L, -1) */ } /* "lupa/_lupa.pyx":316 * if lua.lua_isnil(L, -1): * raise LuaError("globals not defined") * return py_from_lua(self, L, -1) # <<<<<<<<<<<<<< * finally: * lua.lua_settop(L, old_top) */ __Pyx_XDECREF(__pyx_r); __pyx_t_5 = __pyx_f_4lupa_5_lupa_py_from_lua(__pyx_v_self, __pyx_v_L, -1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 316, __pyx_L4_error) __Pyx_GOTREF(__pyx_t_5); __pyx_r = __pyx_t_5; __pyx_t_5 = 0; goto __pyx_L3_return; } /* "lupa/_lupa.pyx":318 * return py_from_lua(self, L, -1) * finally: * lua.lua_settop(L, old_top) # <<<<<<<<<<<<<< * unlock_runtime(self) * */ /*finally:*/ { __pyx_L4_error:; /*exception exit:*/{ __Pyx_PyThreadState_declare __Pyx_PyThreadState_assign __pyx_t_8 = 0; __pyx_t_9 = 0; __pyx_t_10 = 0; __pyx_t_11 = 0; __pyx_t_12 = 0; __pyx_t_13 = 0; __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; if (PY_MAJOR_VERSION >= 3) __Pyx_ExceptionSwap(&__pyx_t_11, &__pyx_t_12, &__pyx_t_13); if ((PY_MAJOR_VERSION < 3) || unlikely(__Pyx_GetException(&__pyx_t_8, &__pyx_t_9, &__pyx_t_10) < 0)) __Pyx_ErrFetch(&__pyx_t_8, &__pyx_t_9, &__pyx_t_10); __Pyx_XGOTREF(__pyx_t_8); __Pyx_XGOTREF(__pyx_t_9); __Pyx_XGOTREF(__pyx_t_10); __Pyx_XGOTREF(__pyx_t_11); __Pyx_XGOTREF(__pyx_t_12); __Pyx_XGOTREF(__pyx_t_13); __pyx_t_2 = __pyx_lineno; __pyx_t_6 = __pyx_clineno; __pyx_t_7 = __pyx_filename; { lua_settop(__pyx_v_L, __pyx_v_old_top); /* "lupa/_lupa.pyx":319 * finally: * lua.lua_settop(L, old_top) * unlock_runtime(self) # <<<<<<<<<<<<<< * * def table(self, *items, **kwargs): */ __pyx_f_4lupa_5_lupa_unlock_runtime(__pyx_v_self); } if (PY_MAJOR_VERSION >= 3) { __Pyx_XGIVEREF(__pyx_t_11); __Pyx_XGIVEREF(__pyx_t_12); __Pyx_XGIVEREF(__pyx_t_13); __Pyx_ExceptionReset(__pyx_t_11, __pyx_t_12, __pyx_t_13); } __Pyx_XGIVEREF(__pyx_t_8); __Pyx_XGIVEREF(__pyx_t_9); __Pyx_XGIVEREF(__pyx_t_10); __Pyx_ErrRestore(__pyx_t_8, __pyx_t_9, __pyx_t_10); __pyx_t_8 = 0; __pyx_t_9 = 0; __pyx_t_10 = 0; __pyx_t_11 = 0; __pyx_t_12 = 0; __pyx_t_13 = 0; __pyx_lineno = __pyx_t_2; __pyx_clineno = __pyx_t_6; __pyx_filename = __pyx_t_7; goto __pyx_L1_error; } __pyx_L3_return: { __pyx_t_13 = __pyx_r; __pyx_r = 0; /* "lupa/_lupa.pyx":318 * return py_from_lua(self, L, -1) * finally: * lua.lua_settop(L, old_top) # <<<<<<<<<<<<<< * unlock_runtime(self) * */ lua_settop(__pyx_v_L, __pyx_v_old_top); /* "lupa/_lupa.pyx":319 * finally: * lua.lua_settop(L, old_top) * unlock_runtime(self) # <<<<<<<<<<<<<< * * def table(self, *items, **kwargs): */ __pyx_f_4lupa_5_lupa_unlock_runtime(__pyx_v_self); __pyx_r = __pyx_t_13; __pyx_t_13 = 0; goto __pyx_L0; } } /* "lupa/_lupa.pyx":304 * unlock_runtime(self) * * def globals(self): # <<<<<<<<<<<<<< * """Return the globals defined in this Lua runtime as a Lua * table. */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_4); __Pyx_XDECREF(__pyx_t_5); __Pyx_AddTraceback("lupa._lupa.LuaRuntime.globals", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "lupa/_lupa.pyx":321 * unlock_runtime(self) * * def table(self, *items, **kwargs): # <<<<<<<<<<<<<< * """Create a new table with the provided items. Positional * arguments are placed in the table in order, keyword arguments */ /* Python wrapper */ static PyObject *__pyx_pw_4lupa_5_lupa_10LuaRuntime_15table(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ static char __pyx_doc_4lupa_5_lupa_10LuaRuntime_14table[] = "LuaRuntime.table(self, *items, **kwargs)\nCreate a new table with the provided items. Positional\n arguments are placed in the table in order, keyword arguments\n are set as key-value pairs.\n "; static PyMethodDef __pyx_mdef_4lupa_5_lupa_10LuaRuntime_15table = {"table", (PyCFunction)__pyx_pw_4lupa_5_lupa_10LuaRuntime_15table, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4lupa_5_lupa_10LuaRuntime_14table}; static PyObject *__pyx_pw_4lupa_5_lupa_10LuaRuntime_15table(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { PyObject *__pyx_v_items = 0; PyObject *__pyx_v_kwargs = 0; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("table (wrapper)", 0); if (unlikely(__pyx_kwds) && unlikely(!__Pyx_CheckKeywordStrings(__pyx_kwds, "table", 1))) return NULL; __pyx_v_kwargs = (__pyx_kwds) ? PyDict_Copy(__pyx_kwds) : PyDict_New(); if (unlikely(!__pyx_v_kwargs)) return NULL; __Pyx_GOTREF(__pyx_v_kwargs); __Pyx_INCREF(__pyx_args); __pyx_v_items = __pyx_args; __pyx_r = __pyx_pf_4lupa_5_lupa_10LuaRuntime_14table(((struct __pyx_obj_4lupa_5_lupa_LuaRuntime *)__pyx_v_self), __pyx_v_items, __pyx_v_kwargs); /* function exit code */ __Pyx_XDECREF(__pyx_v_items); __Pyx_XDECREF(__pyx_v_kwargs); __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_4lupa_5_lupa_10LuaRuntime_14table(struct __pyx_obj_4lupa_5_lupa_LuaRuntime *__pyx_v_self, PyObject *__pyx_v_items, PyObject *__pyx_v_kwargs) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; PyObject *__pyx_t_2 = NULL; PyObject *__pyx_t_3 = NULL; int __pyx_t_4; PyObject *__pyx_t_5 = NULL; __Pyx_RefNannySetupContext("table", 0); /* "lupa/_lupa.pyx":326 * are set as key-value pairs. * """ * return self.table_from(items, kwargs) # <<<<<<<<<<<<<< * * def table_from(self, *args): */ __Pyx_XDECREF(__pyx_r); __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_table_from); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 326, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_3 = NULL; __pyx_t_4 = 0; if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) { __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2); if (likely(__pyx_t_3)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2); __Pyx_INCREF(__pyx_t_3); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_2, function); __pyx_t_4 = 1; } } #if CYTHON_FAST_PYCALL if (PyFunction_Check(__pyx_t_2)) { PyObject *__pyx_temp[3] = {__pyx_t_3, __pyx_v_items, __pyx_v_kwargs}; __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_4, 2+__pyx_t_4); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 326, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_GOTREF(__pyx_t_1); } else #endif #if CYTHON_FAST_PYCCALL if (__Pyx_PyFastCFunction_Check(__pyx_t_2)) { PyObject *__pyx_temp[3] = {__pyx_t_3, __pyx_v_items, __pyx_v_kwargs}; __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_4, 2+__pyx_t_4); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 326, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_GOTREF(__pyx_t_1); } else #endif { __pyx_t_5 = PyTuple_New(2+__pyx_t_4); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 326, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); if (__pyx_t_3) { __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_3); __pyx_t_3 = NULL; } __Pyx_INCREF(__pyx_v_items); __Pyx_GIVEREF(__pyx_v_items); PyTuple_SET_ITEM(__pyx_t_5, 0+__pyx_t_4, __pyx_v_items); __Pyx_INCREF(__pyx_v_kwargs); __Pyx_GIVEREF(__pyx_v_kwargs); PyTuple_SET_ITEM(__pyx_t_5, 1+__pyx_t_4, __pyx_v_kwargs); __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_5, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 326, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; } __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0; /* "lupa/_lupa.pyx":321 * unlock_runtime(self) * * def table(self, *items, **kwargs): # <<<<<<<<<<<<<< * """Create a new table with the provided items. Positional * arguments are placed in the table in order, keyword arguments */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_2); __Pyx_XDECREF(__pyx_t_3); __Pyx_XDECREF(__pyx_t_5); __Pyx_AddTraceback("lupa._lupa.LuaRuntime.table", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "lupa/_lupa.pyx":328 * return self.table_from(items, kwargs) * * def table_from(self, *args): # <<<<<<<<<<<<<< * """Create a new table from Python mapping or iterable. * */ /* Python wrapper */ static PyObject *__pyx_pw_4lupa_5_lupa_10LuaRuntime_17table_from(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ static char __pyx_doc_4lupa_5_lupa_10LuaRuntime_16table_from[] = "LuaRuntime.table_from(self, *args)\nCreate a new table from Python mapping or iterable.\n\n table_from() accepts either a dict/mapping or an iterable with items.\n Items from dicts are set as key-value pairs; items from iterables\n are placed in the table in order.\n\n Nested mappings / iterables are passed to Lua as userdata\n (wrapped Python objects); they are not converted to Lua tables.\n "; static PyMethodDef __pyx_mdef_4lupa_5_lupa_10LuaRuntime_17table_from = {"table_from", (PyCFunction)__pyx_pw_4lupa_5_lupa_10LuaRuntime_17table_from, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4lupa_5_lupa_10LuaRuntime_16table_from}; static PyObject *__pyx_pw_4lupa_5_lupa_10LuaRuntime_17table_from(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { PyObject *__pyx_v_args = 0; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("table_from (wrapper)", 0); if (unlikely(__pyx_kwds) && unlikely(PyDict_Size(__pyx_kwds) > 0) && unlikely(!__Pyx_CheckKeywordStrings(__pyx_kwds, "table_from", 0))) return NULL; __Pyx_INCREF(__pyx_args); __pyx_v_args = __pyx_args; __pyx_r = __pyx_pf_4lupa_5_lupa_10LuaRuntime_16table_from(((struct __pyx_obj_4lupa_5_lupa_LuaRuntime *)__pyx_v_self), __pyx_v_args); /* function exit code */ __Pyx_XDECREF(__pyx_v_args); __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_4lupa_5_lupa_10LuaRuntime_16table_from(struct __pyx_obj_4lupa_5_lupa_LuaRuntime *__pyx_v_self, PyObject *__pyx_v_args) { lua_State *__pyx_v_L; int __pyx_v_i; int __pyx_v_old_top; PyObject *__pyx_v_obj = NULL; PyObject *__pyx_v_key = NULL; PyObject *__pyx_v_value = NULL; PyObject *__pyx_v_arg = NULL; PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations lua_State *__pyx_t_1; int __pyx_t_2; PyObject *__pyx_t_3 = NULL; Py_ssize_t __pyx_t_4; PyObject *__pyx_t_5 = NULL; int __pyx_t_6; int __pyx_t_7; Py_ssize_t __pyx_t_8; Py_ssize_t __pyx_t_9; PyObject *__pyx_t_10 = NULL; PyObject *__pyx_t_11 = NULL; int __pyx_t_12; PyObject *(*__pyx_t_13)(PyObject *); char const *__pyx_t_14; PyObject *__pyx_t_15 = NULL; PyObject *__pyx_t_16 = NULL; PyObject *__pyx_t_17 = NULL; PyObject *__pyx_t_18 = NULL; PyObject *__pyx_t_19 = NULL; PyObject *__pyx_t_20 = NULL; __Pyx_RefNannySetupContext("table_from", 0); /* "lupa/_lupa.pyx":338 * (wrapped Python objects); they are not converted to Lua tables. * """ * assert self._state is not NULL # <<<<<<<<<<<<<< * cdef lua_State *L = self._state * cdef int i = 1 */ #ifndef CYTHON_WITHOUT_ASSERTIONS if (unlikely(!Py_OptimizeFlag)) { if (unlikely(!((__pyx_v_self->_state != NULL) != 0))) { PyErr_SetNone(PyExc_AssertionError); __PYX_ERR(0, 338, __pyx_L1_error) } } #endif /* "lupa/_lupa.pyx":339 * """ * assert self._state is not NULL * cdef lua_State *L = self._state # <<<<<<<<<<<<<< * cdef int i = 1 * lock_runtime(self) */ __pyx_t_1 = __pyx_v_self->_state; __pyx_v_L = __pyx_t_1; /* "lupa/_lupa.pyx":340 * assert self._state is not NULL * cdef lua_State *L = self._state * cdef int i = 1 # <<<<<<<<<<<<<< * lock_runtime(self) * old_top = lua.lua_gettop(L) */ __pyx_v_i = 1; /* "lupa/_lupa.pyx":341 * cdef lua_State *L = self._state * cdef int i = 1 * lock_runtime(self) # <<<<<<<<<<<<<< * old_top = lua.lua_gettop(L) * try: */ __pyx_t_2 = __pyx_f_4lupa_5_lupa_lock_runtime(__pyx_v_self); if (unlikely(__pyx_t_2 == ((int)-1))) __PYX_ERR(0, 341, __pyx_L1_error) /* "lupa/_lupa.pyx":342 * cdef int i = 1 * lock_runtime(self) * old_top = lua.lua_gettop(L) # <<<<<<<<<<<<<< * try: * lua.lua_newtable(L) */ __pyx_v_old_top = lua_gettop(__pyx_v_L); /* "lupa/_lupa.pyx":343 * lock_runtime(self) * old_top = lua.lua_gettop(L) * try: # <<<<<<<<<<<<<< * lua.lua_newtable(L) * # FIXME: how to check for failure? */ /*try:*/ { /* "lupa/_lupa.pyx":344 * old_top = lua.lua_gettop(L) * try: * lua.lua_newtable(L) # <<<<<<<<<<<<<< * # FIXME: how to check for failure? * for obj in args: */ lua_newtable(__pyx_v_L); /* "lupa/_lupa.pyx":346 * lua.lua_newtable(L) * # FIXME: how to check for failure? * for obj in args: # <<<<<<<<<<<<<< * if isinstance(obj, dict): * for key, value in obj.iteritems(): */ __pyx_t_3 = __pyx_v_args; __Pyx_INCREF(__pyx_t_3); __pyx_t_4 = 0; for (;;) { if (__pyx_t_4 >= PyTuple_GET_SIZE(__pyx_t_3)) break; #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS __pyx_t_5 = PyTuple_GET_ITEM(__pyx_t_3, __pyx_t_4); __Pyx_INCREF(__pyx_t_5); __pyx_t_4++; if (unlikely(0 < 0)) __PYX_ERR(0, 346, __pyx_L4_error) #else __pyx_t_5 = PySequence_ITEM(__pyx_t_3, __pyx_t_4); __pyx_t_4++; if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 346, __pyx_L4_error) __Pyx_GOTREF(__pyx_t_5); #endif __Pyx_XDECREF_SET(__pyx_v_obj, __pyx_t_5); __pyx_t_5 = 0; /* "lupa/_lupa.pyx":347 * # FIXME: how to check for failure? * for obj in args: * if isinstance(obj, dict): # <<<<<<<<<<<<<< * for key, value in obj.iteritems(): * py_to_lua(self, L, key) */ __pyx_t_6 = PyDict_Check(__pyx_v_obj); __pyx_t_7 = (__pyx_t_6 != 0); if (__pyx_t_7) { /* "lupa/_lupa.pyx":348 * for obj in args: * if isinstance(obj, dict): * for key, value in obj.iteritems(): # <<<<<<<<<<<<<< * py_to_lua(self, L, key) * py_to_lua(self, L, value) */ __pyx_t_8 = 0; if (unlikely(__pyx_v_obj == Py_None)) { PyErr_Format(PyExc_AttributeError, "'NoneType' object has no attribute '%.30s'", "iteritems"); __PYX_ERR(0, 348, __pyx_L4_error) } __pyx_t_10 = __Pyx_dict_iterator(__pyx_v_obj, 0, __pyx_n_s_iteritems, (&__pyx_t_9), (&__pyx_t_2)); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 348, __pyx_L4_error) __Pyx_GOTREF(__pyx_t_10); __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = __pyx_t_10; __pyx_t_10 = 0; while (1) { __pyx_t_12 = __Pyx_dict_iter_next(__pyx_t_5, __pyx_t_9, &__pyx_t_8, &__pyx_t_10, &__pyx_t_11, NULL, __pyx_t_2); if (unlikely(__pyx_t_12 == 0)) break; if (unlikely(__pyx_t_12 == -1)) __PYX_ERR(0, 348, __pyx_L4_error) __Pyx_GOTREF(__pyx_t_10); __Pyx_GOTREF(__pyx_t_11); __Pyx_XDECREF_SET(__pyx_v_key, __pyx_t_10); __pyx_t_10 = 0; __Pyx_XDECREF_SET(__pyx_v_value, __pyx_t_11); __pyx_t_11 = 0; /* "lupa/_lupa.pyx":349 * if isinstance(obj, dict): * for key, value in obj.iteritems(): * py_to_lua(self, L, key) # <<<<<<<<<<<<<< * py_to_lua(self, L, value) * lua.lua_rawset(L, -3) */ __pyx_t_12 = __pyx_f_4lupa_5_lupa_py_to_lua(__pyx_v_self, __pyx_v_L, __pyx_v_key, NULL); if (unlikely(__pyx_t_12 == ((int)-1))) __PYX_ERR(0, 349, __pyx_L4_error) /* "lupa/_lupa.pyx":350 * for key, value in obj.iteritems(): * py_to_lua(self, L, key) * py_to_lua(self, L, value) # <<<<<<<<<<<<<< * lua.lua_rawset(L, -3) * */ __pyx_t_12 = __pyx_f_4lupa_5_lupa_py_to_lua(__pyx_v_self, __pyx_v_L, __pyx_v_value, NULL); if (unlikely(__pyx_t_12 == ((int)-1))) __PYX_ERR(0, 350, __pyx_L4_error) /* "lupa/_lupa.pyx":351 * py_to_lua(self, L, key) * py_to_lua(self, L, value) * lua.lua_rawset(L, -3) # <<<<<<<<<<<<<< * * elif isinstance(obj, _LuaTable): */ lua_rawset(__pyx_v_L, -3); } __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; /* "lupa/_lupa.pyx":347 * # FIXME: how to check for failure? * for obj in args: * if isinstance(obj, dict): # <<<<<<<<<<<<<< * for key, value in obj.iteritems(): * py_to_lua(self, L, key) */ goto __pyx_L8; } /* "lupa/_lupa.pyx":353 * lua.lua_rawset(L, -3) * * elif isinstance(obj, _LuaTable): # <<<<<<<<<<<<<< * # Stack: # tbl * (<_LuaObject>obj).push_lua_object() # tbl, obj */ __pyx_t_7 = __Pyx_TypeCheck(__pyx_v_obj, __pyx_ptype_4lupa_5_lupa__LuaTable); __pyx_t_6 = (__pyx_t_7 != 0); if (__pyx_t_6) { /* "lupa/_lupa.pyx":355 * elif isinstance(obj, _LuaTable): * # Stack: # tbl * (<_LuaObject>obj).push_lua_object() # tbl, obj # <<<<<<<<<<<<<< * lua.lua_pushnil(L) # tbl, obj, nil // iterate over obj (-2) * while lua.lua_next(L, -2): # tbl, obj, k, v */ __pyx_t_2 = __pyx_f_4lupa_5_lupa_10_LuaObject_push_lua_object(((struct __pyx_obj_4lupa_5_lupa__LuaObject *)__pyx_v_obj)); if (unlikely(__pyx_t_2 == ((int)-1))) __PYX_ERR(0, 355, __pyx_L4_error) /* "lupa/_lupa.pyx":356 * # Stack: # tbl * (<_LuaObject>obj).push_lua_object() # tbl, obj * lua.lua_pushnil(L) # tbl, obj, nil // iterate over obj (-2) # <<<<<<<<<<<<<< * while lua.lua_next(L, -2): # tbl, obj, k, v * lua.lua_pushvalue(L, -2) # tbl, obj, k, v, k // copy key (because */ lua_pushnil(__pyx_v_L); /* "lupa/_lupa.pyx":357 * (<_LuaObject>obj).push_lua_object() # tbl, obj * lua.lua_pushnil(L) # tbl, obj, nil // iterate over obj (-2) * while lua.lua_next(L, -2): # tbl, obj, k, v # <<<<<<<<<<<<<< * lua.lua_pushvalue(L, -2) # tbl, obj, k, v, k // copy key (because * lua.lua_insert(L, -2) # tbl, obj, k, k, v // lua_next needs a key for iteration) */ while (1) { __pyx_t_6 = (lua_next(__pyx_v_L, -2) != 0); if (!__pyx_t_6) break; /* "lupa/_lupa.pyx":358 * lua.lua_pushnil(L) # tbl, obj, nil // iterate over obj (-2) * while lua.lua_next(L, -2): # tbl, obj, k, v * lua.lua_pushvalue(L, -2) # tbl, obj, k, v, k // copy key (because # <<<<<<<<<<<<<< * lua.lua_insert(L, -2) # tbl, obj, k, k, v // lua_next needs a key for iteration) * lua.lua_settable(L, -5) # tbl, obj, k // tbl[k] = v */ lua_pushvalue(__pyx_v_L, -2); /* "lupa/_lupa.pyx":359 * while lua.lua_next(L, -2): # tbl, obj, k, v * lua.lua_pushvalue(L, -2) # tbl, obj, k, v, k // copy key (because * lua.lua_insert(L, -2) # tbl, obj, k, k, v // lua_next needs a key for iteration) # <<<<<<<<<<<<<< * lua.lua_settable(L, -5) # tbl, obj, k // tbl[k] = v * lua.lua_pop(L, 1) # tbl // remove obj from stack */ lua_insert(__pyx_v_L, -2); /* "lupa/_lupa.pyx":360 * lua.lua_pushvalue(L, -2) # tbl, obj, k, v, k // copy key (because * lua.lua_insert(L, -2) # tbl, obj, k, k, v // lua_next needs a key for iteration) * lua.lua_settable(L, -5) # tbl, obj, k // tbl[k] = v # <<<<<<<<<<<<<< * lua.lua_pop(L, 1) # tbl // remove obj from stack * */ lua_settable(__pyx_v_L, -5); } /* "lupa/_lupa.pyx":361 * lua.lua_insert(L, -2) # tbl, obj, k, k, v // lua_next needs a key for iteration) * lua.lua_settable(L, -5) # tbl, obj, k // tbl[k] = v * lua.lua_pop(L, 1) # tbl // remove obj from stack # <<<<<<<<<<<<<< * * elif isinstance(obj, Mapping): */ lua_pop(__pyx_v_L, 1); /* "lupa/_lupa.pyx":353 * lua.lua_rawset(L, -3) * * elif isinstance(obj, _LuaTable): # <<<<<<<<<<<<<< * # Stack: # tbl * (<_LuaObject>obj).push_lua_object() # tbl, obj */ goto __pyx_L8; } /* "lupa/_lupa.pyx":363 * lua.lua_pop(L, 1) # tbl // remove obj from stack * * elif isinstance(obj, Mapping): # <<<<<<<<<<<<<< * for key in obj: * value = obj[key] */ __pyx_t_5 = __pyx_v_4lupa_5_lupa_Mapping; __Pyx_INCREF(__pyx_t_5); __pyx_t_6 = PyObject_IsInstance(__pyx_v_obj, __pyx_t_5); if (unlikely(__pyx_t_6 == ((int)-1))) __PYX_ERR(0, 363, __pyx_L4_error) __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __pyx_t_7 = (__pyx_t_6 != 0); if (__pyx_t_7) { /* "lupa/_lupa.pyx":364 * * elif isinstance(obj, Mapping): * for key in obj: # <<<<<<<<<<<<<< * value = obj[key] * py_to_lua(self, L, key) */ if (likely(PyList_CheckExact(__pyx_v_obj)) || PyTuple_CheckExact(__pyx_v_obj)) { __pyx_t_5 = __pyx_v_obj; __Pyx_INCREF(__pyx_t_5); __pyx_t_9 = 0; __pyx_t_13 = NULL; } else { __pyx_t_9 = -1; __pyx_t_5 = PyObject_GetIter(__pyx_v_obj); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 364, __pyx_L4_error) __Pyx_GOTREF(__pyx_t_5); __pyx_t_13 = Py_TYPE(__pyx_t_5)->tp_iternext; if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 364, __pyx_L4_error) } for (;;) { if (likely(!__pyx_t_13)) { if (likely(PyList_CheckExact(__pyx_t_5))) { if (__pyx_t_9 >= PyList_GET_SIZE(__pyx_t_5)) break; #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS __pyx_t_11 = PyList_GET_ITEM(__pyx_t_5, __pyx_t_9); __Pyx_INCREF(__pyx_t_11); __pyx_t_9++; if (unlikely(0 < 0)) __PYX_ERR(0, 364, __pyx_L4_error) #else __pyx_t_11 = PySequence_ITEM(__pyx_t_5, __pyx_t_9); __pyx_t_9++; if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 364, __pyx_L4_error) __Pyx_GOTREF(__pyx_t_11); #endif } else { if (__pyx_t_9 >= PyTuple_GET_SIZE(__pyx_t_5)) break; #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS __pyx_t_11 = PyTuple_GET_ITEM(__pyx_t_5, __pyx_t_9); __Pyx_INCREF(__pyx_t_11); __pyx_t_9++; if (unlikely(0 < 0)) __PYX_ERR(0, 364, __pyx_L4_error) #else __pyx_t_11 = PySequence_ITEM(__pyx_t_5, __pyx_t_9); __pyx_t_9++; if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 364, __pyx_L4_error) __Pyx_GOTREF(__pyx_t_11); #endif } } else { __pyx_t_11 = __pyx_t_13(__pyx_t_5); if (unlikely(!__pyx_t_11)) { PyObject* exc_type = PyErr_Occurred(); if (exc_type) { if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear(); else __PYX_ERR(0, 364, __pyx_L4_error) } break; } __Pyx_GOTREF(__pyx_t_11); } __Pyx_XDECREF_SET(__pyx_v_key, __pyx_t_11); __pyx_t_11 = 0; /* "lupa/_lupa.pyx":365 * elif isinstance(obj, Mapping): * for key in obj: * value = obj[key] # <<<<<<<<<<<<<< * py_to_lua(self, L, key) * py_to_lua(self, L, value) */ __pyx_t_11 = PyObject_GetItem(__pyx_v_obj, __pyx_v_key); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 365, __pyx_L4_error) __Pyx_GOTREF(__pyx_t_11); __Pyx_XDECREF_SET(__pyx_v_value, __pyx_t_11); __pyx_t_11 = 0; /* "lupa/_lupa.pyx":366 * for key in obj: * value = obj[key] * py_to_lua(self, L, key) # <<<<<<<<<<<<<< * py_to_lua(self, L, value) * lua.lua_rawset(L, -3) */ __pyx_t_2 = __pyx_f_4lupa_5_lupa_py_to_lua(__pyx_v_self, __pyx_v_L, __pyx_v_key, NULL); if (unlikely(__pyx_t_2 == ((int)-1))) __PYX_ERR(0, 366, __pyx_L4_error) /* "lupa/_lupa.pyx":367 * value = obj[key] * py_to_lua(self, L, key) * py_to_lua(self, L, value) # <<<<<<<<<<<<<< * lua.lua_rawset(L, -3) * else: */ __pyx_t_2 = __pyx_f_4lupa_5_lupa_py_to_lua(__pyx_v_self, __pyx_v_L, __pyx_v_value, NULL); if (unlikely(__pyx_t_2 == ((int)-1))) __PYX_ERR(0, 367, __pyx_L4_error) /* "lupa/_lupa.pyx":368 * py_to_lua(self, L, key) * py_to_lua(self, L, value) * lua.lua_rawset(L, -3) # <<<<<<<<<<<<<< * else: * for arg in obj: */ lua_rawset(__pyx_v_L, -3); /* "lupa/_lupa.pyx":364 * * elif isinstance(obj, Mapping): * for key in obj: # <<<<<<<<<<<<<< * value = obj[key] * py_to_lua(self, L, key) */ } __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; /* "lupa/_lupa.pyx":363 * lua.lua_pop(L, 1) # tbl // remove obj from stack * * elif isinstance(obj, Mapping): # <<<<<<<<<<<<<< * for key in obj: * value = obj[key] */ goto __pyx_L8; } /* "lupa/_lupa.pyx":370 * lua.lua_rawset(L, -3) * else: * for arg in obj: # <<<<<<<<<<<<<< * py_to_lua(self, L, arg) * lua.lua_rawseti(L, -2, i) */ /*else*/ { if (likely(PyList_CheckExact(__pyx_v_obj)) || PyTuple_CheckExact(__pyx_v_obj)) { __pyx_t_5 = __pyx_v_obj; __Pyx_INCREF(__pyx_t_5); __pyx_t_9 = 0; __pyx_t_13 = NULL; } else { __pyx_t_9 = -1; __pyx_t_5 = PyObject_GetIter(__pyx_v_obj); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 370, __pyx_L4_error) __Pyx_GOTREF(__pyx_t_5); __pyx_t_13 = Py_TYPE(__pyx_t_5)->tp_iternext; if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 370, __pyx_L4_error) } for (;;) { if (likely(!__pyx_t_13)) { if (likely(PyList_CheckExact(__pyx_t_5))) { if (__pyx_t_9 >= PyList_GET_SIZE(__pyx_t_5)) break; #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS __pyx_t_11 = PyList_GET_ITEM(__pyx_t_5, __pyx_t_9); __Pyx_INCREF(__pyx_t_11); __pyx_t_9++; if (unlikely(0 < 0)) __PYX_ERR(0, 370, __pyx_L4_error) #else __pyx_t_11 = PySequence_ITEM(__pyx_t_5, __pyx_t_9); __pyx_t_9++; if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 370, __pyx_L4_error) __Pyx_GOTREF(__pyx_t_11); #endif } else { if (__pyx_t_9 >= PyTuple_GET_SIZE(__pyx_t_5)) break; #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS __pyx_t_11 = PyTuple_GET_ITEM(__pyx_t_5, __pyx_t_9); __Pyx_INCREF(__pyx_t_11); __pyx_t_9++; if (unlikely(0 < 0)) __PYX_ERR(0, 370, __pyx_L4_error) #else __pyx_t_11 = PySequence_ITEM(__pyx_t_5, __pyx_t_9); __pyx_t_9++; if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 370, __pyx_L4_error) __Pyx_GOTREF(__pyx_t_11); #endif } } else { __pyx_t_11 = __pyx_t_13(__pyx_t_5); if (unlikely(!__pyx_t_11)) { PyObject* exc_type = PyErr_Occurred(); if (exc_type) { if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear(); else __PYX_ERR(0, 370, __pyx_L4_error) } break; } __Pyx_GOTREF(__pyx_t_11); } __Pyx_XDECREF_SET(__pyx_v_arg, __pyx_t_11); __pyx_t_11 = 0; /* "lupa/_lupa.pyx":371 * else: * for arg in obj: * py_to_lua(self, L, arg) # <<<<<<<<<<<<<< * lua.lua_rawseti(L, -2, i) * i += 1 */ __pyx_t_2 = __pyx_f_4lupa_5_lupa_py_to_lua(__pyx_v_self, __pyx_v_L, __pyx_v_arg, NULL); if (unlikely(__pyx_t_2 == ((int)-1))) __PYX_ERR(0, 371, __pyx_L4_error) /* "lupa/_lupa.pyx":372 * for arg in obj: * py_to_lua(self, L, arg) * lua.lua_rawseti(L, -2, i) # <<<<<<<<<<<<<< * i += 1 * return py_from_lua(self, L, -1) */ lua_rawseti(__pyx_v_L, -2, __pyx_v_i); /* "lupa/_lupa.pyx":373 * py_to_lua(self, L, arg) * lua.lua_rawseti(L, -2, i) * i += 1 # <<<<<<<<<<<<<< * return py_from_lua(self, L, -1) * finally: */ __pyx_v_i = (__pyx_v_i + 1); /* "lupa/_lupa.pyx":370 * lua.lua_rawset(L, -3) * else: * for arg in obj: # <<<<<<<<<<<<<< * py_to_lua(self, L, arg) * lua.lua_rawseti(L, -2, i) */ } __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; } __pyx_L8:; /* "lupa/_lupa.pyx":346 * lua.lua_newtable(L) * # FIXME: how to check for failure? * for obj in args: # <<<<<<<<<<<<<< * if isinstance(obj, dict): * for key, value in obj.iteritems(): */ } __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; /* "lupa/_lupa.pyx":374 * lua.lua_rawseti(L, -2, i) * i += 1 * return py_from_lua(self, L, -1) # <<<<<<<<<<<<<< * finally: * lua.lua_settop(L, old_top) */ __Pyx_XDECREF(__pyx_r); __pyx_t_3 = __pyx_f_4lupa_5_lupa_py_from_lua(__pyx_v_self, __pyx_v_L, -1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 374, __pyx_L4_error) __Pyx_GOTREF(__pyx_t_3); __pyx_r = __pyx_t_3; __pyx_t_3 = 0; goto __pyx_L3_return; } /* "lupa/_lupa.pyx":376 * return py_from_lua(self, L, -1) * finally: * lua.lua_settop(L, old_top) # <<<<<<<<<<<<<< * unlock_runtime(self) * */ /*finally:*/ { __pyx_L4_error:; /*exception exit:*/{ __Pyx_PyThreadState_declare __Pyx_PyThreadState_assign __pyx_t_15 = 0; __pyx_t_16 = 0; __pyx_t_17 = 0; __pyx_t_18 = 0; __pyx_t_19 = 0; __pyx_t_20 = 0; __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0; __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0; __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; if (PY_MAJOR_VERSION >= 3) __Pyx_ExceptionSwap(&__pyx_t_18, &__pyx_t_19, &__pyx_t_20); if ((PY_MAJOR_VERSION < 3) || unlikely(__Pyx_GetException(&__pyx_t_15, &__pyx_t_16, &__pyx_t_17) < 0)) __Pyx_ErrFetch(&__pyx_t_15, &__pyx_t_16, &__pyx_t_17); __Pyx_XGOTREF(__pyx_t_15); __Pyx_XGOTREF(__pyx_t_16); __Pyx_XGOTREF(__pyx_t_17); __Pyx_XGOTREF(__pyx_t_18); __Pyx_XGOTREF(__pyx_t_19); __Pyx_XGOTREF(__pyx_t_20); __pyx_t_2 = __pyx_lineno; __pyx_t_12 = __pyx_clineno; __pyx_t_14 = __pyx_filename; { lua_settop(__pyx_v_L, __pyx_v_old_top); /* "lupa/_lupa.pyx":377 * finally: * lua.lua_settop(L, old_top) * unlock_runtime(self) # <<<<<<<<<<<<<< * * @cython.final */ __pyx_f_4lupa_5_lupa_unlock_runtime(__pyx_v_self); } if (PY_MAJOR_VERSION >= 3) { __Pyx_XGIVEREF(__pyx_t_18); __Pyx_XGIVEREF(__pyx_t_19); __Pyx_XGIVEREF(__pyx_t_20); __Pyx_ExceptionReset(__pyx_t_18, __pyx_t_19, __pyx_t_20); } __Pyx_XGIVEREF(__pyx_t_15); __Pyx_XGIVEREF(__pyx_t_16); __Pyx_XGIVEREF(__pyx_t_17); __Pyx_ErrRestore(__pyx_t_15, __pyx_t_16, __pyx_t_17); __pyx_t_15 = 0; __pyx_t_16 = 0; __pyx_t_17 = 0; __pyx_t_18 = 0; __pyx_t_19 = 0; __pyx_t_20 = 0; __pyx_lineno = __pyx_t_2; __pyx_clineno = __pyx_t_12; __pyx_filename = __pyx_t_14; goto __pyx_L1_error; } __pyx_L3_return: { __pyx_t_20 = __pyx_r; __pyx_r = 0; /* "lupa/_lupa.pyx":376 * return py_from_lua(self, L, -1) * finally: * lua.lua_settop(L, old_top) # <<<<<<<<<<<<<< * unlock_runtime(self) * */ lua_settop(__pyx_v_L, __pyx_v_old_top); /* "lupa/_lupa.pyx":377 * finally: * lua.lua_settop(L, old_top) * unlock_runtime(self) # <<<<<<<<<<<<<< * * @cython.final */ __pyx_f_4lupa_5_lupa_unlock_runtime(__pyx_v_self); __pyx_r = __pyx_t_20; __pyx_t_20 = 0; goto __pyx_L0; } } /* "lupa/_lupa.pyx":328 * return self.table_from(items, kwargs) * * def table_from(self, *args): # <<<<<<<<<<<<<< * """Create a new table from Python mapping or iterable. * */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_3); __Pyx_XDECREF(__pyx_t_5); __Pyx_XDECREF(__pyx_t_10); __Pyx_XDECREF(__pyx_t_11); __Pyx_AddTraceback("lupa._lupa.LuaRuntime.table_from", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XDECREF(__pyx_v_obj); __Pyx_XDECREF(__pyx_v_key); __Pyx_XDECREF(__pyx_v_value); __Pyx_XDECREF(__pyx_v_arg); __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "lupa/_lupa.pyx":380 * * @cython.final * cdef int register_py_object(self, bytes cname, bytes pyname, object obj) except -1: # <<<<<<<<<<<<<< * cdef lua_State *L = self._state * lua.lua_pushlstring(L, cname, len(cname)) */ static int __pyx_f_4lupa_5_lupa_10LuaRuntime_register_py_object(struct __pyx_obj_4lupa_5_lupa_LuaRuntime *__pyx_v_self, PyObject *__pyx_v_cname, PyObject *__pyx_v_pyname, PyObject *__pyx_v_obj) { lua_State *__pyx_v_L; int __pyx_r; __Pyx_RefNannyDeclarations lua_State *__pyx_t_1; char *__pyx_t_2; Py_ssize_t __pyx_t_3; int __pyx_t_4; PyObject *__pyx_t_5 = NULL; PyObject *__pyx_t_6 = NULL; PyObject *__pyx_t_7 = NULL; PyObject *__pyx_t_8 = NULL; PyObject *__pyx_t_9 = NULL; __Pyx_RefNannySetupContext("register_py_object", 0); /* "lupa/_lupa.pyx":381 * @cython.final * cdef int register_py_object(self, bytes cname, bytes pyname, object obj) except -1: * cdef lua_State *L = self._state # <<<<<<<<<<<<<< * lua.lua_pushlstring(L, cname, len(cname)) * if not py_to_lua_custom(self, L, obj, 0): */ __pyx_t_1 = __pyx_v_self->_state; __pyx_v_L = __pyx_t_1; /* "lupa/_lupa.pyx":382 * cdef int register_py_object(self, bytes cname, bytes pyname, object obj) except -1: * cdef lua_State *L = self._state * lua.lua_pushlstring(L, cname, len(cname)) # <<<<<<<<<<<<<< * if not py_to_lua_custom(self, L, obj, 0): * lua.lua_pop(L, 1) */ if (unlikely(__pyx_v_cname == Py_None)) { PyErr_SetString(PyExc_TypeError, "expected bytes, NoneType found"); __PYX_ERR(0, 382, __pyx_L1_error) } __pyx_t_2 = __Pyx_PyBytes_AsWritableString(__pyx_v_cname); if (unlikely((!__pyx_t_2) && PyErr_Occurred())) __PYX_ERR(0, 382, __pyx_L1_error) if (unlikely(__pyx_v_cname == Py_None)) { PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()"); __PYX_ERR(0, 382, __pyx_L1_error) } __pyx_t_3 = PyBytes_GET_SIZE(__pyx_v_cname); if (unlikely(__pyx_t_3 == ((Py_ssize_t)-1))) __PYX_ERR(0, 382, __pyx_L1_error) lua_pushlstring(__pyx_v_L, __pyx_t_2, __pyx_t_3); /* "lupa/_lupa.pyx":383 * cdef lua_State *L = self._state * lua.lua_pushlstring(L, cname, len(cname)) * if not py_to_lua_custom(self, L, obj, 0): # <<<<<<<<<<<<<< * lua.lua_pop(L, 1) * raise LuaError("failed to convert %s object" % pyname) */ __pyx_t_4 = ((!(__pyx_f_4lupa_5_lupa_py_to_lua_custom(__pyx_v_self, __pyx_v_L, __pyx_v_obj, 0) != 0)) != 0); if (__pyx_t_4) { /* "lupa/_lupa.pyx":384 * lua.lua_pushlstring(L, cname, len(cname)) * if not py_to_lua_custom(self, L, obj, 0): * lua.lua_pop(L, 1) # <<<<<<<<<<<<<< * raise LuaError("failed to convert %s object" % pyname) * lua.lua_pushlstring(L, pyname, len(pyname)) */ lua_pop(__pyx_v_L, 1); /* "lupa/_lupa.pyx":385 * 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_6 = __Pyx_GetModuleGlobalName(__pyx_n_s_LuaError); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 385, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __pyx_t_7 = __Pyx_PyString_Format(__pyx_kp_s_failed_to_convert_s_object, __pyx_v_pyname); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 385, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __pyx_t_8 = NULL; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_6))) { __pyx_t_8 = PyMethod_GET_SELF(__pyx_t_6); if (likely(__pyx_t_8)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6); __Pyx_INCREF(__pyx_t_8); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_6, function); } } if (!__pyx_t_8) { __pyx_t_5 = __Pyx_PyObject_CallOneArg(__pyx_t_6, __pyx_t_7); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 385, __pyx_L1_error) __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; __Pyx_GOTREF(__pyx_t_5); } else { #if CYTHON_FAST_PYCALL if (PyFunction_Check(__pyx_t_6)) { PyObject *__pyx_temp[2] = {__pyx_t_8, __pyx_t_7}; __pyx_t_5 = __Pyx_PyFunction_FastCall(__pyx_t_6, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 385, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0; __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; } else #endif #if CYTHON_FAST_PYCCALL if (__Pyx_PyFastCFunction_Check(__pyx_t_6)) { PyObject *__pyx_temp[2] = {__pyx_t_8, __pyx_t_7}; __pyx_t_5 = __Pyx_PyCFunction_FastCall(__pyx_t_6, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 385, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0; __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; } else #endif { __pyx_t_9 = PyTuple_New(1+1); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 385, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); __Pyx_GIVEREF(__pyx_t_8); PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_t_8); __pyx_t_8 = NULL; __Pyx_GIVEREF(__pyx_t_7); PyTuple_SET_ITEM(__pyx_t_9, 0+1, __pyx_t_7); __pyx_t_7 = 0; __pyx_t_5 = __Pyx_PyObject_Call(__pyx_t_6, __pyx_t_9, NULL); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 385, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; } } __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_Raise(__pyx_t_5, 0, 0, 0); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __PYX_ERR(0, 385, __pyx_L1_error) /* "lupa/_lupa.pyx":383 * cdef lua_State *L = self._state * lua.lua_pushlstring(L, cname, len(cname)) * if not py_to_lua_custom(self, L, obj, 0): # <<<<<<<<<<<<<< * lua.lua_pop(L, 1) * raise LuaError("failed to convert %s object" % pyname) */ } /* "lupa/_lupa.pyx":386 * lua.lua_pop(L, 1) * raise LuaError("failed to convert %s object" % pyname) * lua.lua_pushlstring(L, pyname, len(pyname)) # <<<<<<<<<<<<<< * lua.lua_pushvalue(L, -2) * lua.lua_rawset(L, -5) */ if (unlikely(__pyx_v_pyname == Py_None)) { PyErr_SetString(PyExc_TypeError, "expected bytes, NoneType found"); __PYX_ERR(0, 386, __pyx_L1_error) } __pyx_t_2 = __Pyx_PyBytes_AsWritableString(__pyx_v_pyname); if (unlikely((!__pyx_t_2) && PyErr_Occurred())) __PYX_ERR(0, 386, __pyx_L1_error) if (unlikely(__pyx_v_pyname == Py_None)) { PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()"); __PYX_ERR(0, 386, __pyx_L1_error) } __pyx_t_3 = PyBytes_GET_SIZE(__pyx_v_pyname); if (unlikely(__pyx_t_3 == ((Py_ssize_t)-1))) __PYX_ERR(0, 386, __pyx_L1_error) lua_pushlstring(__pyx_v_L, __pyx_t_2, __pyx_t_3); /* "lupa/_lupa.pyx":387 * raise LuaError("failed to convert %s object" % pyname) * lua.lua_pushlstring(L, pyname, len(pyname)) * lua.lua_pushvalue(L, -2) # <<<<<<<<<<<<<< * lua.lua_rawset(L, -5) * lua.lua_rawset(L, lua.LUA_REGISTRYINDEX) */ lua_pushvalue(__pyx_v_L, -2); /* "lupa/_lupa.pyx":388 * lua.lua_pushlstring(L, pyname, len(pyname)) * lua.lua_pushvalue(L, -2) * lua.lua_rawset(L, -5) # <<<<<<<<<<<<<< * lua.lua_rawset(L, lua.LUA_REGISTRYINDEX) * return 0 */ lua_rawset(__pyx_v_L, -5); /* "lupa/_lupa.pyx":389 * lua.lua_pushvalue(L, -2) * lua.lua_rawset(L, -5) * lua.lua_rawset(L, lua.LUA_REGISTRYINDEX) # <<<<<<<<<<<<<< * return 0 * */ lua_rawset(__pyx_v_L, LUA_REGISTRYINDEX); /* "lupa/_lupa.pyx":390 * lua.lua_rawset(L, -5) * lua.lua_rawset(L, lua.LUA_REGISTRYINDEX) * return 0 # <<<<<<<<<<<<<< * * @cython.final */ __pyx_r = 0; goto __pyx_L0; /* "lupa/_lupa.pyx":380 * * @cython.final * cdef int register_py_object(self, bytes cname, bytes pyname, object obj) except -1: # <<<<<<<<<<<<<< * cdef lua_State *L = self._state * lua.lua_pushlstring(L, cname, len(cname)) */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_5); __Pyx_XDECREF(__pyx_t_6); __Pyx_XDECREF(__pyx_t_7); __Pyx_XDECREF(__pyx_t_8); __Pyx_XDECREF(__pyx_t_9); __Pyx_AddTraceback("lupa._lupa.LuaRuntime.register_py_object", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = -1; __pyx_L0:; __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "lupa/_lupa.pyx":393 * * @cython.final * cdef int init_python_lib(self, bint register_eval, bint register_builtins) except -1: # <<<<<<<<<<<<<< * cdef lua_State *L = self._state * */ static int __pyx_f_4lupa_5_lupa_10LuaRuntime_init_python_lib(struct __pyx_obj_4lupa_5_lupa_LuaRuntime *__pyx_v_self, int __pyx_v_register_eval, int __pyx_v_register_builtins) { lua_State *__pyx_v_L; int __pyx_r; __Pyx_RefNannyDeclarations lua_State *__pyx_t_1; int __pyx_t_2; int __pyx_t_3; PyObject *__pyx_t_4 = NULL; __Pyx_RefNannySetupContext("init_python_lib", 0); /* "lupa/_lupa.pyx":394 * @cython.final * cdef int init_python_lib(self, bint register_eval, bint register_builtins) except -1: * cdef lua_State *L = self._state # <<<<<<<<<<<<<< * * # create 'python' lib and register our own object metatable */ __pyx_t_1 = __pyx_v_self->_state; __pyx_v_L = __pyx_t_1; /* "lupa/_lupa.pyx":397 * * # create 'python' lib and register our own object metatable * luaL_openlib(L, "python", py_lib, 0) # <<<<<<<<<<<<<< * lua.luaL_newmetatable(L, POBJECT) * luaL_openlib(L, NULL, py_object_lib, 0) */ __pyx_f_4lupa_5_lupa_luaL_openlib(__pyx_v_L, ((char const *)"python"), __pyx_v_4lupa_5_lupa_py_lib, 0); /* "lupa/_lupa.pyx":398 * # create 'python' lib and register our own object metatable * luaL_openlib(L, "python", py_lib, 0) * lua.luaL_newmetatable(L, POBJECT) # <<<<<<<<<<<<<< * luaL_openlib(L, NULL, py_object_lib, 0) * lua.lua_pop(L, 1) */ luaL_newmetatable(__pyx_v_L, ((char *)"POBJECT")); /* "lupa/_lupa.pyx":399 * luaL_openlib(L, "python", py_lib, 0) * lua.luaL_newmetatable(L, POBJECT) * luaL_openlib(L, NULL, py_object_lib, 0) # <<<<<<<<<<<<<< * lua.lua_pop(L, 1) * */ __pyx_f_4lupa_5_lupa_luaL_openlib(__pyx_v_L, NULL, __pyx_v_4lupa_5_lupa_py_object_lib, 0); /* "lupa/_lupa.pyx":400 * lua.luaL_newmetatable(L, POBJECT) * luaL_openlib(L, NULL, py_object_lib, 0) * lua.lua_pop(L, 1) # <<<<<<<<<<<<<< * * # register global names in the module */ lua_pop(__pyx_v_L, 1); /* "lupa/_lupa.pyx":403 * * # register global names in the module * self.register_py_object(b'Py_None', b'none', None) # <<<<<<<<<<<<<< * if register_eval: * self.register_py_object(b'eval', b'eval', eval) */ __pyx_t_2 = __pyx_f_4lupa_5_lupa_10LuaRuntime_register_py_object(__pyx_v_self, __pyx_n_b_Py_None, __pyx_n_b_none, Py_None); if (unlikely(__pyx_t_2 == ((int)-1))) __PYX_ERR(0, 403, __pyx_L1_error) /* "lupa/_lupa.pyx":404 * # register global names in the module * self.register_py_object(b'Py_None', b'none', None) * if register_eval: # <<<<<<<<<<<<<< * self.register_py_object(b'eval', b'eval', eval) * if register_builtins: */ __pyx_t_3 = (__pyx_v_register_eval != 0); if (__pyx_t_3) { /* "lupa/_lupa.pyx":405 * self.register_py_object(b'Py_None', b'none', None) * if register_eval: * self.register_py_object(b'eval', b'eval', eval) # <<<<<<<<<<<<<< * if register_builtins: * self.register_py_object(b'builtins', b'builtins', builtins) */ __pyx_t_2 = __pyx_f_4lupa_5_lupa_10LuaRuntime_register_py_object(__pyx_v_self, __pyx_n_b_eval, __pyx_n_b_eval, __pyx_builtin_eval); if (unlikely(__pyx_t_2 == ((int)-1))) __PYX_ERR(0, 405, __pyx_L1_error) /* "lupa/_lupa.pyx":404 * # register global names in the module * self.register_py_object(b'Py_None', b'none', None) * if register_eval: # <<<<<<<<<<<<<< * self.register_py_object(b'eval', b'eval', eval) * if register_builtins: */ } /* "lupa/_lupa.pyx":406 * if register_eval: * self.register_py_object(b'eval', b'eval', eval) * if register_builtins: # <<<<<<<<<<<<<< * self.register_py_object(b'builtins', b'builtins', builtins) * */ __pyx_t_3 = (__pyx_v_register_builtins != 0); if (__pyx_t_3) { /* "lupa/_lupa.pyx":407 * self.register_py_object(b'eval', b'eval', eval) * if register_builtins: * self.register_py_object(b'builtins', b'builtins', builtins) # <<<<<<<<<<<<<< * * return 0 # nothing left to return on the stack */ __pyx_t_4 = __pyx_v_4lupa_5_lupa_builtins; __Pyx_INCREF(__pyx_t_4); __pyx_t_2 = __pyx_f_4lupa_5_lupa_10LuaRuntime_register_py_object(__pyx_v_self, __pyx_n_b_builtins, __pyx_n_b_builtins, __pyx_t_4); if (unlikely(__pyx_t_2 == ((int)-1))) __PYX_ERR(0, 407, __pyx_L1_error) __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; /* "lupa/_lupa.pyx":406 * if register_eval: * self.register_py_object(b'eval', b'eval', eval) * if register_builtins: # <<<<<<<<<<<<<< * self.register_py_object(b'builtins', b'builtins', builtins) * */ } /* "lupa/_lupa.pyx":409 * self.register_py_object(b'builtins', b'builtins', builtins) * * return 0 # nothing left to return on the stack # <<<<<<<<<<<<<< * * */ __pyx_r = 0; goto __pyx_L0; /* "lupa/_lupa.pyx":393 * * @cython.final * cdef int init_python_lib(self, bint register_eval, bint register_builtins) except -1: # <<<<<<<<<<<<<< * cdef lua_State *L = self._state * */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_4); __Pyx_AddTraceback("lupa._lupa.LuaRuntime.init_python_lib", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = -1; __pyx_L0:; __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "(tree fragment)":1 * def __reduce_cython__(self): # <<<<<<<<<<<<<< * raise TypeError("no default __reduce__ due to non-trivial __cinit__") * def __setstate_cython__(self, __pyx_state): */ /* Python wrapper */ static PyObject *__pyx_pw_4lupa_5_lupa_10LuaRuntime_19__reduce_cython__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ static char __pyx_doc_4lupa_5_lupa_10LuaRuntime_18__reduce_cython__[] = "LuaRuntime.__reduce_cython__(self)"; static PyMethodDef __pyx_mdef_4lupa_5_lupa_10LuaRuntime_19__reduce_cython__ = {"__reduce_cython__", (PyCFunction)__pyx_pw_4lupa_5_lupa_10LuaRuntime_19__reduce_cython__, METH_NOARGS, __pyx_doc_4lupa_5_lupa_10LuaRuntime_18__reduce_cython__}; static PyObject *__pyx_pw_4lupa_5_lupa_10LuaRuntime_19__reduce_cython__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__reduce_cython__ (wrapper)", 0); __pyx_r = __pyx_pf_4lupa_5_lupa_10LuaRuntime_18__reduce_cython__(((struct __pyx_obj_4lupa_5_lupa_LuaRuntime *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_4lupa_5_lupa_10LuaRuntime_18__reduce_cython__(CYTHON_UNUSED struct __pyx_obj_4lupa_5_lupa_LuaRuntime *__pyx_v_self) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; __Pyx_RefNannySetupContext("__reduce_cython__", 0); /* "(tree fragment)":2 * def __reduce_cython__(self): * raise TypeError("no default __reduce__ due to non-trivial __cinit__") # <<<<<<<<<<<<<< * def __setstate_cython__(self, __pyx_state): * raise TypeError("no default __reduce__ due to non-trivial __cinit__") */ __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__12, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 2, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_Raise(__pyx_t_1, 0, 0, 0); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __PYX_ERR(2, 2, __pyx_L1_error) /* "(tree fragment)":1 * def __reduce_cython__(self): # <<<<<<<<<<<<<< * raise TypeError("no default __reduce__ due to non-trivial __cinit__") * def __setstate_cython__(self, __pyx_state): */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_AddTraceback("lupa._lupa.LuaRuntime.__reduce_cython__", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "(tree fragment)":3 * def __reduce_cython__(self): * raise TypeError("no default __reduce__ due to non-trivial __cinit__") * def __setstate_cython__(self, __pyx_state): # <<<<<<<<<<<<<< * raise TypeError("no default __reduce__ due to non-trivial __cinit__") */ /* Python wrapper */ static PyObject *__pyx_pw_4lupa_5_lupa_10LuaRuntime_21__setstate_cython__(PyObject *__pyx_v_self, PyObject *__pyx_v___pyx_state); /*proto*/ static char __pyx_doc_4lupa_5_lupa_10LuaRuntime_20__setstate_cython__[] = "LuaRuntime.__setstate_cython__(self, __pyx_state)"; static PyMethodDef __pyx_mdef_4lupa_5_lupa_10LuaRuntime_21__setstate_cython__ = {"__setstate_cython__", (PyCFunction)__pyx_pw_4lupa_5_lupa_10LuaRuntime_21__setstate_cython__, METH_O, __pyx_doc_4lupa_5_lupa_10LuaRuntime_20__setstate_cython__}; static PyObject *__pyx_pw_4lupa_5_lupa_10LuaRuntime_21__setstate_cython__(PyObject *__pyx_v_self, PyObject *__pyx_v___pyx_state) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__setstate_cython__ (wrapper)", 0); __pyx_r = __pyx_pf_4lupa_5_lupa_10LuaRuntime_20__setstate_cython__(((struct __pyx_obj_4lupa_5_lupa_LuaRuntime *)__pyx_v_self), ((PyObject *)__pyx_v___pyx_state)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_4lupa_5_lupa_10LuaRuntime_20__setstate_cython__(CYTHON_UNUSED struct __pyx_obj_4lupa_5_lupa_LuaRuntime *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v___pyx_state) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; __Pyx_RefNannySetupContext("__setstate_cython__", 0); /* "(tree fragment)":4 * raise TypeError("no default __reduce__ due to non-trivial __cinit__") * def __setstate_cython__(self, __pyx_state): * raise TypeError("no default __reduce__ due to non-trivial __cinit__") # <<<<<<<<<<<<<< */ __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__13, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 4, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_Raise(__pyx_t_1, 0, 0, 0); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __PYX_ERR(2, 4, __pyx_L1_error) /* "(tree fragment)":3 * def __reduce_cython__(self): * raise TypeError("no default __reduce__ due to non-trivial __cinit__") * def __setstate_cython__(self, __pyx_state): # <<<<<<<<<<<<<< * raise TypeError("no default __reduce__ due to non-trivial __cinit__") */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_AddTraceback("lupa._lupa.LuaRuntime.__setstate_cython__", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "lupa/_lupa.pyx":416 * # from Lua scripts * * def unpacks_lua_table(func): # <<<<<<<<<<<<<< * """ * A decorator to make the decorated function receive kwargs */ /* Python wrapper */ static PyObject *__pyx_pw_4lupa_5_lupa_3unpacks_lua_table(PyObject *__pyx_self, PyObject *__pyx_v_func); /*proto*/ static char __pyx_doc_4lupa_5_lupa_2unpacks_lua_table[] = "unpacks_lua_table(func)\n\n A decorator to make the decorated function receive kwargs\n when it is called from Lua with a single Lua table argument.\n\n Python functions wrapped in this decorator can be called from Lua code\n as ``func(foo, bar)``, ``func{foo=foo, bar=bar}`` and ``func{foo, bar=bar}``.\n\n See also: http://lua-users.org/wiki/NamedParameters\n\n WARNING: avoid using this decorator for functions where the\n first argument can be a Lua table.\n\n WARNING: be careful with ``nil`` values. Depending on the context,\n passing ``nil`` as a parameter can mean either \"omit a parameter\"\n or \"pass None\". This even depends on the Lua version. It is\n possible to use ``python.none`` instead of ``nil`` to pass None values\n robustly.\n "; static PyMethodDef __pyx_mdef_4lupa_5_lupa_3unpacks_lua_table = {"unpacks_lua_table", (PyCFunction)__pyx_pw_4lupa_5_lupa_3unpacks_lua_table, METH_O, __pyx_doc_4lupa_5_lupa_2unpacks_lua_table}; static PyObject *__pyx_pw_4lupa_5_lupa_3unpacks_lua_table(PyObject *__pyx_self, PyObject *__pyx_v_func) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("unpacks_lua_table (wrapper)", 0); __pyx_r = __pyx_pf_4lupa_5_lupa_2unpacks_lua_table(__pyx_self, ((PyObject *)__pyx_v_func)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "lupa/_lupa.pyx":436 * """ * @wraps(func) * def wrapper(*args): # <<<<<<<<<<<<<< * args, kwargs = _fix_args_kwargs(args) * return func(*args, **kwargs) */ /* Python wrapper */ static PyObject *__pyx_pw_4lupa_5_lupa_17unpacks_lua_table_1wrapper(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ static PyMethodDef __pyx_mdef_4lupa_5_lupa_17unpacks_lua_table_1wrapper = {"wrapper", (PyCFunction)__pyx_pw_4lupa_5_lupa_17unpacks_lua_table_1wrapper, METH_VARARGS|METH_KEYWORDS, 0}; static PyObject *__pyx_pw_4lupa_5_lupa_17unpacks_lua_table_1wrapper(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { PyObject *__pyx_v_args = 0; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("wrapper (wrapper)", 0); if (unlikely(__pyx_kwds) && unlikely(PyDict_Size(__pyx_kwds) > 0) && unlikely(!__Pyx_CheckKeywordStrings(__pyx_kwds, "wrapper", 0))) return NULL; __Pyx_INCREF(__pyx_args); __pyx_v_args = __pyx_args; __pyx_r = __pyx_pf_4lupa_5_lupa_17unpacks_lua_table_wrapper(__pyx_self, __pyx_v_args); /* function exit code */ __Pyx_XDECREF(__pyx_v_args); __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_4lupa_5_lupa_17unpacks_lua_table_wrapper(PyObject *__pyx_self, PyObject *__pyx_v_args) { struct __pyx_obj_4lupa_5_lupa___pyx_scope_struct__unpacks_lua_table *__pyx_cur_scope; struct __pyx_obj_4lupa_5_lupa___pyx_scope_struct__unpacks_lua_table *__pyx_outer_scope; PyObject *__pyx_v_kwargs = NULL; PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; PyObject *__pyx_t_2 = NULL; PyObject *__pyx_t_3 = NULL; __Pyx_RefNannySetupContext("wrapper", 0); __pyx_outer_scope = (struct __pyx_obj_4lupa_5_lupa___pyx_scope_struct__unpacks_lua_table *) __Pyx_CyFunction_GetClosure(__pyx_self); __pyx_cur_scope = __pyx_outer_scope; __Pyx_INCREF(__pyx_v_args); /* "lupa/_lupa.pyx":437 * @wraps(func) * def wrapper(*args): * args, kwargs = _fix_args_kwargs(args) # <<<<<<<<<<<<<< * return func(*args, **kwargs) * return wrapper */ if (!(likely(PyTuple_CheckExact(__pyx_v_args))||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "tuple", Py_TYPE(__pyx_v_args)->tp_name), 0))) __PYX_ERR(0, 437, __pyx_L1_error) __pyx_t_1 = __pyx_f_4lupa_5_lupa__fix_args_kwargs(((PyObject*)__pyx_v_args)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 437, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); if (likely(__pyx_t_1 != Py_None)) { PyObject* sequence = __pyx_t_1; #if !CYTHON_COMPILING_IN_PYPY Py_ssize_t size = Py_SIZE(sequence); #else Py_ssize_t size = PySequence_Size(sequence); #endif if (unlikely(size != 2)) { if (size > 2) __Pyx_RaiseTooManyValuesError(2); else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size); __PYX_ERR(0, 437, __pyx_L1_error) } #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS __pyx_t_2 = PyTuple_GET_ITEM(sequence, 0); __pyx_t_3 = PyTuple_GET_ITEM(sequence, 1); __Pyx_INCREF(__pyx_t_2); __Pyx_INCREF(__pyx_t_3); #else __pyx_t_2 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 437, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_3 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 437, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); #endif __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; } else { __Pyx_RaiseNoneNotIterableError(); __PYX_ERR(0, 437, __pyx_L1_error) } __Pyx_DECREF_SET(__pyx_v_args, __pyx_t_2); __pyx_t_2 = 0; __pyx_v_kwargs = __pyx_t_3; __pyx_t_3 = 0; /* "lupa/_lupa.pyx":438 * def wrapper(*args): * args, kwargs = _fix_args_kwargs(args) * return func(*args, **kwargs) # <<<<<<<<<<<<<< * return wrapper * */ __Pyx_XDECREF(__pyx_r); if (unlikely(!__pyx_cur_scope->__pyx_v_func)) { __Pyx_RaiseClosureNameError("func"); __PYX_ERR(0, 438, __pyx_L1_error) } __pyx_t_1 = __Pyx_PySequence_Tuple(__pyx_v_args); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 438, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); if (unlikely(__pyx_v_kwargs == Py_None)) { PyErr_SetString(PyExc_TypeError, "argument after ** must be a mapping, not NoneType"); __PYX_ERR(0, 438, __pyx_L1_error) } if (likely(PyDict_CheckExact(__pyx_v_kwargs))) { __pyx_t_3 = PyDict_Copy(__pyx_v_kwargs); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 438, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); } else { __pyx_t_3 = PyObject_CallFunctionObjArgs((PyObject*)&PyDict_Type, __pyx_v_kwargs, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 438, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); } __pyx_t_2 = __Pyx_PyObject_Call(__pyx_cur_scope->__pyx_v_func, __pyx_t_1, __pyx_t_3); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 438, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_r = __pyx_t_2; __pyx_t_2 = 0; goto __pyx_L0; /* "lupa/_lupa.pyx":436 * """ * @wraps(func) * def wrapper(*args): # <<<<<<<<<<<<<< * args, kwargs = _fix_args_kwargs(args) * return func(*args, **kwargs) */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_2); __Pyx_XDECREF(__pyx_t_3); __Pyx_AddTraceback("lupa._lupa.unpacks_lua_table.wrapper", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XDECREF(__pyx_v_args); __Pyx_XDECREF(__pyx_v_kwargs); __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "lupa/_lupa.pyx":416 * # from Lua scripts * * def unpacks_lua_table(func): # <<<<<<<<<<<<<< * """ * A decorator to make the decorated function receive kwargs */ static PyObject *__pyx_pf_4lupa_5_lupa_2unpacks_lua_table(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_func) { struct __pyx_obj_4lupa_5_lupa___pyx_scope_struct__unpacks_lua_table *__pyx_cur_scope; PyObject *__pyx_v_wrapper = 0; PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; PyObject *__pyx_t_2 = NULL; PyObject *__pyx_t_3 = NULL; PyObject *__pyx_t_4 = NULL; PyObject *__pyx_t_5 = NULL; __Pyx_RefNannySetupContext("unpacks_lua_table", 0); __pyx_cur_scope = (struct __pyx_obj_4lupa_5_lupa___pyx_scope_struct__unpacks_lua_table *)__pyx_tp_new_4lupa_5_lupa___pyx_scope_struct__unpacks_lua_table(__pyx_ptype_4lupa_5_lupa___pyx_scope_struct__unpacks_lua_table, __pyx_empty_tuple, NULL); if (unlikely(!__pyx_cur_scope)) { __pyx_cur_scope = ((struct __pyx_obj_4lupa_5_lupa___pyx_scope_struct__unpacks_lua_table *)Py_None); __Pyx_INCREF(Py_None); __PYX_ERR(0, 416, __pyx_L1_error) } else { __Pyx_GOTREF(__pyx_cur_scope); } __pyx_cur_scope->__pyx_v_func = __pyx_v_func; __Pyx_INCREF(__pyx_cur_scope->__pyx_v_func); __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_func); /* "lupa/_lupa.pyx":435 * robustly. * """ * @wraps(func) # <<<<<<<<<<<<<< * def wrapper(*args): * args, kwargs = _fix_args_kwargs(args) */ __Pyx_INCREF(__pyx_v_4lupa_5_lupa_wraps); __pyx_t_3 = __pyx_v_4lupa_5_lupa_wraps; __pyx_t_4 = NULL; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) { __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3); if (likely(__pyx_t_4)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); __Pyx_INCREF(__pyx_t_4); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_3, function); } } if (!__pyx_t_4) { __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_cur_scope->__pyx_v_func); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 435, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); } else { #if CYTHON_FAST_PYCALL if (PyFunction_Check(__pyx_t_3)) { PyObject *__pyx_temp[2] = {__pyx_t_4, __pyx_cur_scope->__pyx_v_func}; __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 435, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_GOTREF(__pyx_t_2); } else #endif #if CYTHON_FAST_PYCCALL if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) { PyObject *__pyx_temp[2] = {__pyx_t_4, __pyx_cur_scope->__pyx_v_func}; __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 435, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_GOTREF(__pyx_t_2); } else #endif { __pyx_t_5 = PyTuple_New(1+1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 435, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_4); __pyx_t_4 = NULL; __Pyx_INCREF(__pyx_cur_scope->__pyx_v_func); __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_func); PyTuple_SET_ITEM(__pyx_t_5, 0+1, __pyx_cur_scope->__pyx_v_func); __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_5, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 435, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; } } __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; /* "lupa/_lupa.pyx":436 * """ * @wraps(func) * def wrapper(*args): # <<<<<<<<<<<<<< * args, kwargs = _fix_args_kwargs(args) * return func(*args, **kwargs) */ __pyx_t_3 = __Pyx_CyFunction_NewEx(&__pyx_mdef_4lupa_5_lupa_17unpacks_lua_table_1wrapper, 0, __pyx_n_s_unpacks_lua_table_locals_wrapper, ((PyObject*)__pyx_cur_scope), __pyx_n_s_lupa__lupa, __pyx_d, ((PyObject *)__pyx_codeobj__15)); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 436, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_5 = NULL; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_2))) { __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_2); if (likely(__pyx_t_5)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2); __Pyx_INCREF(__pyx_t_5); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_2, function); } } if (!__pyx_t_5) { __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 435, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_GOTREF(__pyx_t_1); } else { #if CYTHON_FAST_PYCALL if (PyFunction_Check(__pyx_t_2)) { PyObject *__pyx_temp[2] = {__pyx_t_5, __pyx_t_3}; __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 435, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; } else #endif #if CYTHON_FAST_PYCCALL if (__Pyx_PyFastCFunction_Check(__pyx_t_2)) { PyObject *__pyx_temp[2] = {__pyx_t_5, __pyx_t_3}; __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 435, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; } else #endif { __pyx_t_4 = PyTuple_New(1+1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 435, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_5); __pyx_t_5 = NULL; __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_4, 0+1, __pyx_t_3); __pyx_t_3 = 0; __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_4, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 435, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; } } __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_v_wrapper = __pyx_t_1; __pyx_t_1 = 0; /* "lupa/_lupa.pyx":439 * args, kwargs = _fix_args_kwargs(args) * return func(*args, **kwargs) * return wrapper # <<<<<<<<<<<<<< * * */ __Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_v_wrapper); __pyx_r = __pyx_v_wrapper; goto __pyx_L0; /* "lupa/_lupa.pyx":416 * # from Lua scripts * * def unpacks_lua_table(func): # <<<<<<<<<<<<<< * """ * A decorator to make the decorated function receive kwargs */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_2); __Pyx_XDECREF(__pyx_t_3); __Pyx_XDECREF(__pyx_t_4); __Pyx_XDECREF(__pyx_t_5); __Pyx_AddTraceback("lupa._lupa.unpacks_lua_table", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XDECREF(__pyx_v_wrapper); __Pyx_DECREF(((PyObject *)__pyx_cur_scope)); __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "lupa/_lupa.pyx":442 * * * def unpacks_lua_table_method(meth): # <<<<<<<<<<<<<< * """ * This is :func:`unpacks_lua_table` for methods */ /* Python wrapper */ static PyObject *__pyx_pw_4lupa_5_lupa_5unpacks_lua_table_method(PyObject *__pyx_self, PyObject *__pyx_v_meth); /*proto*/ static char __pyx_doc_4lupa_5_lupa_4unpacks_lua_table_method[] = "unpacks_lua_table_method(meth)\n\n This is :func:`unpacks_lua_table` for methods\n (i.e. it knows about the 'self' argument).\n "; static PyMethodDef __pyx_mdef_4lupa_5_lupa_5unpacks_lua_table_method = {"unpacks_lua_table_method", (PyCFunction)__pyx_pw_4lupa_5_lupa_5unpacks_lua_table_method, METH_O, __pyx_doc_4lupa_5_lupa_4unpacks_lua_table_method}; static PyObject *__pyx_pw_4lupa_5_lupa_5unpacks_lua_table_method(PyObject *__pyx_self, PyObject *__pyx_v_meth) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("unpacks_lua_table_method (wrapper)", 0); __pyx_r = __pyx_pf_4lupa_5_lupa_4unpacks_lua_table_method(__pyx_self, ((PyObject *)__pyx_v_meth)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "lupa/_lupa.pyx":448 * """ * @wraps(meth) * def wrapper(self, *args): # <<<<<<<<<<<<<< * args, kwargs = _fix_args_kwargs(args) * return meth(self, *args, **kwargs) */ /* Python wrapper */ static PyObject *__pyx_pw_4lupa_5_lupa_24unpacks_lua_table_method_1wrapper(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ static PyMethodDef __pyx_mdef_4lupa_5_lupa_24unpacks_lua_table_method_1wrapper = {"wrapper", (PyCFunction)__pyx_pw_4lupa_5_lupa_24unpacks_lua_table_method_1wrapper, METH_VARARGS|METH_KEYWORDS, 0}; static PyObject *__pyx_pw_4lupa_5_lupa_24unpacks_lua_table_method_1wrapper(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { PyObject *__pyx_v_self = 0; PyObject *__pyx_v_args = 0; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("wrapper (wrapper)", 0); if (PyTuple_GET_SIZE(__pyx_args) > 1) { __pyx_v_args = PyTuple_GetSlice(__pyx_args, 1, PyTuple_GET_SIZE(__pyx_args)); if (unlikely(!__pyx_v_args)) { __Pyx_RefNannyFinishContext(); return NULL; } __Pyx_GOTREF(__pyx_v_args); } else { __pyx_v_args = __pyx_empty_tuple; __Pyx_INCREF(__pyx_empty_tuple); } { static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_self,0}; PyObject* values[1] = {0}; if (unlikely(__pyx_kwds)) { Py_ssize_t kw_args; const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args); switch (pos_args) { default: case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); CYTHON_FALLTHROUGH; case 0: break; } kw_args = PyDict_Size(__pyx_kwds); switch (pos_args) { case 0: if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_self)) != 0)) kw_args--; else goto __pyx_L5_argtuple_error; } if (unlikely(kw_args > 0)) { const Py_ssize_t used_pos_args = (pos_args < 1) ? pos_args : 1; if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, used_pos_args, "wrapper") < 0)) __PYX_ERR(0, 448, __pyx_L3_error) } } else if (PyTuple_GET_SIZE(__pyx_args) < 1) { goto __pyx_L5_argtuple_error; } else { values[0] = PyTuple_GET_ITEM(__pyx_args, 0); } __pyx_v_self = values[0]; } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("wrapper", 0, 1, 1, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 448, __pyx_L3_error) __pyx_L3_error:; __Pyx_DECREF(__pyx_v_args); __pyx_v_args = 0; __Pyx_AddTraceback("lupa._lupa.unpacks_lua_table_method.wrapper", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; __pyx_r = __pyx_pf_4lupa_5_lupa_24unpacks_lua_table_method_wrapper(__pyx_self, __pyx_v_self, __pyx_v_args); /* function exit code */ __Pyx_XDECREF(__pyx_v_args); __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_4lupa_5_lupa_24unpacks_lua_table_method_wrapper(PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_args) { struct __pyx_obj_4lupa_5_lupa___pyx_scope_struct_1_unpacks_lua_table_method *__pyx_cur_scope; struct __pyx_obj_4lupa_5_lupa___pyx_scope_struct_1_unpacks_lua_table_method *__pyx_outer_scope; PyObject *__pyx_v_kwargs = NULL; PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; PyObject *__pyx_t_2 = NULL; PyObject *__pyx_t_3 = NULL; __Pyx_RefNannySetupContext("wrapper", 0); __pyx_outer_scope = (struct __pyx_obj_4lupa_5_lupa___pyx_scope_struct_1_unpacks_lua_table_method *) __Pyx_CyFunction_GetClosure(__pyx_self); __pyx_cur_scope = __pyx_outer_scope; __Pyx_INCREF(__pyx_v_args); /* "lupa/_lupa.pyx":449 * @wraps(meth) * def wrapper(self, *args): * args, kwargs = _fix_args_kwargs(args) # <<<<<<<<<<<<<< * return meth(self, *args, **kwargs) * return wrapper */ if (!(likely(PyTuple_CheckExact(__pyx_v_args))||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "tuple", Py_TYPE(__pyx_v_args)->tp_name), 0))) __PYX_ERR(0, 449, __pyx_L1_error) __pyx_t_1 = __pyx_f_4lupa_5_lupa__fix_args_kwargs(((PyObject*)__pyx_v_args)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 449, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); if (likely(__pyx_t_1 != Py_None)) { PyObject* sequence = __pyx_t_1; #if !CYTHON_COMPILING_IN_PYPY Py_ssize_t size = Py_SIZE(sequence); #else Py_ssize_t size = PySequence_Size(sequence); #endif if (unlikely(size != 2)) { if (size > 2) __Pyx_RaiseTooManyValuesError(2); else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size); __PYX_ERR(0, 449, __pyx_L1_error) } #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS __pyx_t_2 = PyTuple_GET_ITEM(sequence, 0); __pyx_t_3 = PyTuple_GET_ITEM(sequence, 1); __Pyx_INCREF(__pyx_t_2); __Pyx_INCREF(__pyx_t_3); #else __pyx_t_2 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 449, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_3 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 449, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); #endif __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; } else { __Pyx_RaiseNoneNotIterableError(); __PYX_ERR(0, 449, __pyx_L1_error) } __Pyx_DECREF_SET(__pyx_v_args, __pyx_t_2); __pyx_t_2 = 0; __pyx_v_kwargs = __pyx_t_3; __pyx_t_3 = 0; /* "lupa/_lupa.pyx":450 * def wrapper(self, *args): * args, kwargs = _fix_args_kwargs(args) * return meth(self, *args, **kwargs) # <<<<<<<<<<<<<< * return wrapper * */ __Pyx_XDECREF(__pyx_r); if (unlikely(!__pyx_cur_scope->__pyx_v_meth)) { __Pyx_RaiseClosureNameError("meth"); __PYX_ERR(0, 450, __pyx_L1_error) } __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 450, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_INCREF(__pyx_v_self); __Pyx_GIVEREF(__pyx_v_self); PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_self); __pyx_t_3 = __Pyx_PySequence_Tuple(__pyx_v_args); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 450, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_2 = PyNumber_Add(__pyx_t_1, __pyx_t_3); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 450, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; if (unlikely(__pyx_v_kwargs == Py_None)) { PyErr_SetString(PyExc_TypeError, "argument after ** must be a mapping, not NoneType"); __PYX_ERR(0, 450, __pyx_L1_error) } if (likely(PyDict_CheckExact(__pyx_v_kwargs))) { __pyx_t_3 = PyDict_Copy(__pyx_v_kwargs); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 450, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); } else { __pyx_t_3 = PyObject_CallFunctionObjArgs((PyObject*)&PyDict_Type, __pyx_v_kwargs, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 450, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); } __pyx_t_1 = __Pyx_PyObject_Call(__pyx_cur_scope->__pyx_v_meth, __pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 450, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0; /* "lupa/_lupa.pyx":448 * """ * @wraps(meth) * def wrapper(self, *args): # <<<<<<<<<<<<<< * args, kwargs = _fix_args_kwargs(args) * return meth(self, *args, **kwargs) */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_2); __Pyx_XDECREF(__pyx_t_3); __Pyx_AddTraceback("lupa._lupa.unpacks_lua_table_method.wrapper", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XDECREF(__pyx_v_args); __Pyx_XDECREF(__pyx_v_kwargs); __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "lupa/_lupa.pyx":442 * * * def unpacks_lua_table_method(meth): # <<<<<<<<<<<<<< * """ * This is :func:`unpacks_lua_table` for methods */ static PyObject *__pyx_pf_4lupa_5_lupa_4unpacks_lua_table_method(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_meth) { struct __pyx_obj_4lupa_5_lupa___pyx_scope_struct_1_unpacks_lua_table_method *__pyx_cur_scope; PyObject *__pyx_v_wrapper = 0; PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; PyObject *__pyx_t_2 = NULL; PyObject *__pyx_t_3 = NULL; PyObject *__pyx_t_4 = NULL; PyObject *__pyx_t_5 = NULL; __Pyx_RefNannySetupContext("unpacks_lua_table_method", 0); __pyx_cur_scope = (struct __pyx_obj_4lupa_5_lupa___pyx_scope_struct_1_unpacks_lua_table_method *)__pyx_tp_new_4lupa_5_lupa___pyx_scope_struct_1_unpacks_lua_table_method(__pyx_ptype_4lupa_5_lupa___pyx_scope_struct_1_unpacks_lua_table_method, __pyx_empty_tuple, NULL); if (unlikely(!__pyx_cur_scope)) { __pyx_cur_scope = ((struct __pyx_obj_4lupa_5_lupa___pyx_scope_struct_1_unpacks_lua_table_method *)Py_None); __Pyx_INCREF(Py_None); __PYX_ERR(0, 442, __pyx_L1_error) } else { __Pyx_GOTREF(__pyx_cur_scope); } __pyx_cur_scope->__pyx_v_meth = __pyx_v_meth; __Pyx_INCREF(__pyx_cur_scope->__pyx_v_meth); __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_meth); /* "lupa/_lupa.pyx":447 * (i.e. it knows about the 'self' argument). * """ * @wraps(meth) # <<<<<<<<<<<<<< * def wrapper(self, *args): * args, kwargs = _fix_args_kwargs(args) */ __Pyx_INCREF(__pyx_v_4lupa_5_lupa_wraps); __pyx_t_3 = __pyx_v_4lupa_5_lupa_wraps; __pyx_t_4 = NULL; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) { __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3); if (likely(__pyx_t_4)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); __Pyx_INCREF(__pyx_t_4); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_3, function); } } if (!__pyx_t_4) { __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_cur_scope->__pyx_v_meth); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 447, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); } else { #if CYTHON_FAST_PYCALL if (PyFunction_Check(__pyx_t_3)) { PyObject *__pyx_temp[2] = {__pyx_t_4, __pyx_cur_scope->__pyx_v_meth}; __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 447, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_GOTREF(__pyx_t_2); } else #endif #if CYTHON_FAST_PYCCALL if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) { PyObject *__pyx_temp[2] = {__pyx_t_4, __pyx_cur_scope->__pyx_v_meth}; __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 447, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_GOTREF(__pyx_t_2); } else #endif { __pyx_t_5 = PyTuple_New(1+1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 447, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_4); __pyx_t_4 = NULL; __Pyx_INCREF(__pyx_cur_scope->__pyx_v_meth); __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_meth); PyTuple_SET_ITEM(__pyx_t_5, 0+1, __pyx_cur_scope->__pyx_v_meth); __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_5, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 447, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; } } __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; /* "lupa/_lupa.pyx":448 * """ * @wraps(meth) * def wrapper(self, *args): # <<<<<<<<<<<<<< * args, kwargs = _fix_args_kwargs(args) * return meth(self, *args, **kwargs) */ __pyx_t_3 = __Pyx_CyFunction_NewEx(&__pyx_mdef_4lupa_5_lupa_24unpacks_lua_table_method_1wrapper, 0, __pyx_n_s_unpacks_lua_table_method_locals, ((PyObject*)__pyx_cur_scope), __pyx_n_s_lupa__lupa, __pyx_d, ((PyObject *)__pyx_codeobj__17)); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 448, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_5 = NULL; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_2))) { __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_2); if (likely(__pyx_t_5)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2); __Pyx_INCREF(__pyx_t_5); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_2, function); } } if (!__pyx_t_5) { __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 447, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_GOTREF(__pyx_t_1); } else { #if CYTHON_FAST_PYCALL if (PyFunction_Check(__pyx_t_2)) { PyObject *__pyx_temp[2] = {__pyx_t_5, __pyx_t_3}; __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 447, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; } else #endif #if CYTHON_FAST_PYCCALL if (__Pyx_PyFastCFunction_Check(__pyx_t_2)) { PyObject *__pyx_temp[2] = {__pyx_t_5, __pyx_t_3}; __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 447, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; } else #endif { __pyx_t_4 = PyTuple_New(1+1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 447, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_5); __pyx_t_5 = NULL; __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_4, 0+1, __pyx_t_3); __pyx_t_3 = 0; __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_4, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 447, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; } } __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_v_wrapper = __pyx_t_1; __pyx_t_1 = 0; /* "lupa/_lupa.pyx":451 * args, kwargs = _fix_args_kwargs(args) * return meth(self, *args, **kwargs) * return wrapper # <<<<<<<<<<<<<< * * */ __Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_v_wrapper); __pyx_r = __pyx_v_wrapper; goto __pyx_L0; /* "lupa/_lupa.pyx":442 * * * def unpacks_lua_table_method(meth): # <<<<<<<<<<<<<< * """ * This is :func:`unpacks_lua_table` for methods */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_2); __Pyx_XDECREF(__pyx_t_3); __Pyx_XDECREF(__pyx_t_4); __Pyx_XDECREF(__pyx_t_5); __Pyx_AddTraceback("lupa._lupa.unpacks_lua_table_method", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XDECREF(__pyx_v_wrapper); __Pyx_DECREF(((PyObject *)__pyx_cur_scope)); __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "lupa/_lupa.pyx":454 * * * cdef tuple _fix_args_kwargs(tuple args): # <<<<<<<<<<<<<< * """ * Extract named arguments from args passed to a Python function by Lua */ static PyObject *__pyx_f_4lupa_5_lupa__fix_args_kwargs(PyObject *__pyx_v_args) { PyObject *__pyx_v_arg = NULL; struct __pyx_obj_4lupa_5_lupa__LuaTable *__pyx_v_table = NULL; PyObject *__pyx_v_encoding = NULL; PyObject *__pyx_v_new_args = NULL; PyObject *__pyx_v_new_kwargs = NULL; size_t __pyx_v_key; PyObject *__pyx_7genexpr__pyx_v_key = NULL; PyObject *__pyx_7genexpr__pyx_v_value = NULL; PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations Py_ssize_t __pyx_t_1; int __pyx_t_2; PyObject *__pyx_t_3 = NULL; PyObject *__pyx_t_4 = NULL; int __pyx_t_5; size_t __pyx_t_6; size_t __pyx_t_7; PyObject *__pyx_t_8 = NULL; PyObject *(*__pyx_t_9)(PyObject *); PyObject *__pyx_t_10 = NULL; PyObject *__pyx_t_11 = NULL; PyObject *__pyx_t_12 = NULL; PyObject *(*__pyx_t_13)(PyObject *); int __pyx_t_14; char const *__pyx_t_15; __Pyx_RefNannySetupContext("_fix_args_kwargs", 0); /* "lupa/_lupa.pyx":460 * it is a table. * """ * if len(args) != 1: # <<<<<<<<<<<<<< * return args, {} * */ if (unlikely(__pyx_v_args == Py_None)) { PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()"); __PYX_ERR(0, 460, __pyx_L1_error) } __pyx_t_1 = PyTuple_GET_SIZE(__pyx_v_args); if (unlikely(__pyx_t_1 == ((Py_ssize_t)-1))) __PYX_ERR(0, 460, __pyx_L1_error) __pyx_t_2 = ((__pyx_t_1 != 1) != 0); if (__pyx_t_2) { /* "lupa/_lupa.pyx":461 * """ * if len(args) != 1: * return args, {} # <<<<<<<<<<<<<< * * arg = args[0] */ __Pyx_XDECREF(__pyx_r); __pyx_t_3 = __Pyx_PyDict_NewPresized(0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 461, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_4 = PyTuple_New(2); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 461, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_INCREF(__pyx_v_args); __Pyx_GIVEREF(__pyx_v_args); PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_v_args); __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_t_3); __pyx_t_3 = 0; __pyx_r = ((PyObject*)__pyx_t_4); __pyx_t_4 = 0; goto __pyx_L0; /* "lupa/_lupa.pyx":460 * it is a table. * """ * if len(args) != 1: # <<<<<<<<<<<<<< * return args, {} * */ } /* "lupa/_lupa.pyx":463 * return args, {} * * arg = args[0] # <<<<<<<<<<<<<< * if not isinstance(arg, _LuaTable): * return args, {} */ if (unlikely(__pyx_v_args == Py_None)) { PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable"); __PYX_ERR(0, 463, __pyx_L1_error) } __pyx_t_4 = __Pyx_GetItemInt_Tuple(__pyx_v_args, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 463, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_v_arg = __pyx_t_4; __pyx_t_4 = 0; /* "lupa/_lupa.pyx":464 * * arg = args[0] * if not isinstance(arg, _LuaTable): # <<<<<<<<<<<<<< * return args, {} * */ __pyx_t_2 = __Pyx_TypeCheck(__pyx_v_arg, __pyx_ptype_4lupa_5_lupa__LuaTable); __pyx_t_5 = ((!(__pyx_t_2 != 0)) != 0); if (__pyx_t_5) { /* "lupa/_lupa.pyx":465 * arg = args[0] * if not isinstance(arg, _LuaTable): * return args, {} # <<<<<<<<<<<<<< * * table = <_LuaTable>arg */ __Pyx_XDECREF(__pyx_r); __pyx_t_4 = __Pyx_PyDict_NewPresized(0); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 465, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 465, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_INCREF(__pyx_v_args); __Pyx_GIVEREF(__pyx_v_args); PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_v_args); __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_t_4); __pyx_t_4 = 0; __pyx_r = ((PyObject*)__pyx_t_3); __pyx_t_3 = 0; goto __pyx_L0; /* "lupa/_lupa.pyx":464 * * arg = args[0] * if not isinstance(arg, _LuaTable): # <<<<<<<<<<<<<< * return args, {} * */ } /* "lupa/_lupa.pyx":467 * return args, {} * * table = <_LuaTable>arg # <<<<<<<<<<<<<< * encoding = table._runtime._source_encoding * */ __pyx_t_3 = __pyx_v_arg; __Pyx_INCREF(__pyx_t_3); __pyx_v_table = ((struct __pyx_obj_4lupa_5_lupa__LuaTable *)__pyx_t_3); __pyx_t_3 = 0; /* "lupa/_lupa.pyx":468 * * table = <_LuaTable>arg * encoding = table._runtime._source_encoding # <<<<<<<<<<<<<< * * # arguments with keys from 1 to #tbl are passed as positional */ __pyx_t_3 = __pyx_v_table->__pyx_base._runtime->_source_encoding; __Pyx_INCREF(__pyx_t_3); __pyx_v_encoding = ((PyObject*)__pyx_t_3); __pyx_t_3 = 0; /* "lupa/_lupa.pyx":471 * * # arguments with keys from 1 to #tbl are passed as positional * new_args = [ # <<<<<<<<<<<<<< * table._getitem(key, is_attr_access=False) * for key in range(1, table._len() + 1) */ __pyx_t_3 = PyList_New(0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 471, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); /* "lupa/_lupa.pyx":473 * new_args = [ * table._getitem(key, is_attr_access=False) * for key in range(1, table._len() + 1) # <<<<<<<<<<<<<< * ] * */ __pyx_t_6 = (__pyx_f_4lupa_5_lupa_10_LuaObject__len(((struct __pyx_obj_4lupa_5_lupa__LuaObject *)__pyx_v_table)) + 1); for (__pyx_t_7 = 1; __pyx_t_7 < __pyx_t_6; __pyx_t_7+=1) { __pyx_v_key = __pyx_t_7; /* "lupa/_lupa.pyx":472 * # arguments with keys from 1 to #tbl are passed as positional * new_args = [ * table._getitem(key, is_attr_access=False) # <<<<<<<<<<<<<< * for key in range(1, table._len() + 1) * ] */ __pyx_t_4 = __Pyx_PyInt_FromSize_t(__pyx_v_key); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 472, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_8 = __pyx_f_4lupa_5_lupa_10_LuaObject__getitem(((struct __pyx_obj_4lupa_5_lupa__LuaObject *)__pyx_v_table), __pyx_t_4, 0); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 472, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; if (unlikely(__Pyx_ListComp_Append(__pyx_t_3, (PyObject*)__pyx_t_8))) __PYX_ERR(0, 471, __pyx_L1_error) __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; } __pyx_v_new_args = ((PyObject*)__pyx_t_3); __pyx_t_3 = 0; /* "lupa/_lupa.pyx":477 * * # arguments with non-integer keys are passed as named * new_kwargs = { # <<<<<<<<<<<<<< * (key).decode(encoding) if not IS_PY2 and isinstance(key, bytes) else key: value * for key, value in _LuaIter(table, ITEMS) */ { /* enter inner scope */ __pyx_t_3 = PyDict_New(); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 477, __pyx_L9_error) __Pyx_GOTREF(__pyx_t_3); /* "lupa/_lupa.pyx":479 * new_kwargs = { * (key).decode(encoding) if not IS_PY2 and isinstance(key, bytes) else key: value * for key, value in _LuaIter(table, ITEMS) # <<<<<<<<<<<<<< * if not isinstance(key, (int, long)) * } */ __pyx_t_8 = __Pyx_PyInt_From_int(__pyx_e_4lupa_5_lupa_ITEMS); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 479, __pyx_L9_error) __Pyx_GOTREF(__pyx_t_8); __pyx_t_4 = PyTuple_New(2); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 479, __pyx_L9_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_INCREF(((PyObject *)__pyx_v_table)); __Pyx_GIVEREF(((PyObject *)__pyx_v_table)); PyTuple_SET_ITEM(__pyx_t_4, 0, ((PyObject *)__pyx_v_table)); __Pyx_GIVEREF(__pyx_t_8); PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_t_8); __pyx_t_8 = 0; __pyx_t_8 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_4lupa_5_lupa__LuaIter), __pyx_t_4, NULL); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 479, __pyx_L9_error) __Pyx_GOTREF(__pyx_t_8); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; if (likely(PyList_CheckExact(__pyx_t_8)) || PyTuple_CheckExact(__pyx_t_8)) { __pyx_t_4 = __pyx_t_8; __Pyx_INCREF(__pyx_t_4); __pyx_t_1 = 0; __pyx_t_9 = NULL; } else { __pyx_t_1 = -1; __pyx_t_4 = PyObject_GetIter(__pyx_t_8); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 479, __pyx_L9_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_9 = Py_TYPE(__pyx_t_4)->tp_iternext; if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 479, __pyx_L9_error) } __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; for (;;) { if (likely(!__pyx_t_9)) { if (likely(PyList_CheckExact(__pyx_t_4))) { if (__pyx_t_1 >= PyList_GET_SIZE(__pyx_t_4)) break; #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS __pyx_t_8 = PyList_GET_ITEM(__pyx_t_4, __pyx_t_1); __Pyx_INCREF(__pyx_t_8); __pyx_t_1++; if (unlikely(0 < 0)) __PYX_ERR(0, 479, __pyx_L9_error) #else __pyx_t_8 = PySequence_ITEM(__pyx_t_4, __pyx_t_1); __pyx_t_1++; if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 479, __pyx_L9_error) __Pyx_GOTREF(__pyx_t_8); #endif } else { if (__pyx_t_1 >= PyTuple_GET_SIZE(__pyx_t_4)) break; #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS __pyx_t_8 = PyTuple_GET_ITEM(__pyx_t_4, __pyx_t_1); __Pyx_INCREF(__pyx_t_8); __pyx_t_1++; if (unlikely(0 < 0)) __PYX_ERR(0, 479, __pyx_L9_error) #else __pyx_t_8 = PySequence_ITEM(__pyx_t_4, __pyx_t_1); __pyx_t_1++; if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 479, __pyx_L9_error) __Pyx_GOTREF(__pyx_t_8); #endif } } else { __pyx_t_8 = __pyx_t_9(__pyx_t_4); if (unlikely(!__pyx_t_8)) { PyObject* exc_type = PyErr_Occurred(); if (exc_type) { if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear(); else __PYX_ERR(0, 479, __pyx_L9_error) } break; } __Pyx_GOTREF(__pyx_t_8); } if ((likely(PyTuple_CheckExact(__pyx_t_8))) || (PyList_CheckExact(__pyx_t_8))) { PyObject* sequence = __pyx_t_8; #if !CYTHON_COMPILING_IN_PYPY Py_ssize_t size = Py_SIZE(sequence); #else Py_ssize_t size = PySequence_Size(sequence); #endif if (unlikely(size != 2)) { if (size > 2) __Pyx_RaiseTooManyValuesError(2); else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size); __PYX_ERR(0, 479, __pyx_L9_error) } #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS if (likely(PyTuple_CheckExact(sequence))) { __pyx_t_10 = PyTuple_GET_ITEM(sequence, 0); __pyx_t_11 = PyTuple_GET_ITEM(sequence, 1); } else { __pyx_t_10 = PyList_GET_ITEM(sequence, 0); __pyx_t_11 = PyList_GET_ITEM(sequence, 1); } __Pyx_INCREF(__pyx_t_10); __Pyx_INCREF(__pyx_t_11); #else __pyx_t_10 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 479, __pyx_L9_error) __Pyx_GOTREF(__pyx_t_10); __pyx_t_11 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 479, __pyx_L9_error) __Pyx_GOTREF(__pyx_t_11); #endif __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; } else { Py_ssize_t index = -1; __pyx_t_12 = PyObject_GetIter(__pyx_t_8); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 479, __pyx_L9_error) __Pyx_GOTREF(__pyx_t_12); __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; __pyx_t_13 = Py_TYPE(__pyx_t_12)->tp_iternext; index = 0; __pyx_t_10 = __pyx_t_13(__pyx_t_12); if (unlikely(!__pyx_t_10)) goto __pyx_L12_unpacking_failed; __Pyx_GOTREF(__pyx_t_10); index = 1; __pyx_t_11 = __pyx_t_13(__pyx_t_12); if (unlikely(!__pyx_t_11)) goto __pyx_L12_unpacking_failed; __Pyx_GOTREF(__pyx_t_11); if (__Pyx_IternextUnpackEndCheck(__pyx_t_13(__pyx_t_12), 2) < 0) __PYX_ERR(0, 479, __pyx_L9_error) __pyx_t_13 = NULL; __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; goto __pyx_L13_unpacking_done; __pyx_L12_unpacking_failed:; __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; __pyx_t_13 = NULL; if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index); __PYX_ERR(0, 479, __pyx_L9_error) __pyx_L13_unpacking_done:; } __Pyx_XDECREF_SET(__pyx_7genexpr__pyx_v_key, __pyx_t_10); __pyx_t_10 = 0; __Pyx_XDECREF_SET(__pyx_7genexpr__pyx_v_value, __pyx_t_11); __pyx_t_11 = 0; /* "lupa/_lupa.pyx":480 * (key).decode(encoding) if not IS_PY2 and isinstance(key, bytes) else key: value * for key, value in _LuaIter(table, ITEMS) * if not isinstance(key, (int, long)) # <<<<<<<<<<<<<< * } * return new_args, new_kwargs */ __pyx_t_2 = PyInt_Check(__pyx_7genexpr__pyx_v_key); __pyx_t_14 = (__pyx_t_2 != 0); if (!__pyx_t_14) { } else { __pyx_t_5 = __pyx_t_14; goto __pyx_L15_bool_binop_done; } __pyx_t_14 = PyLong_Check(__pyx_7genexpr__pyx_v_key); __pyx_t_2 = (__pyx_t_14 != 0); __pyx_t_5 = __pyx_t_2; __pyx_L15_bool_binop_done:; __pyx_t_2 = ((!(__pyx_t_5 != 0)) != 0); if (__pyx_t_2) { /* "lupa/_lupa.pyx":478 * # arguments with non-integer keys are passed as named * new_kwargs = { * (key).decode(encoding) if not IS_PY2 and isinstance(key, bytes) else key: value # <<<<<<<<<<<<<< * for key, value in _LuaIter(table, ITEMS) * if not isinstance(key, (int, long)) */ __pyx_t_5 = ((!(__pyx_v_4lupa_5_lupa_IS_PY2 != 0)) != 0); if (__pyx_t_5) { } else { __pyx_t_2 = __pyx_t_5; goto __pyx_L17_bool_binop_done; } __pyx_t_5 = PyBytes_Check(__pyx_7genexpr__pyx_v_key); __pyx_t_14 = (__pyx_t_5 != 0); __pyx_t_2 = __pyx_t_14; __pyx_L17_bool_binop_done:; if (__pyx_t_2) { if (unlikely(__pyx_7genexpr__pyx_v_key == Py_None)) { PyErr_Format(PyExc_AttributeError, "'NoneType' object has no attribute '%.30s'", "decode"); __PYX_ERR(0, 478, __pyx_L9_error) } if (unlikely(__pyx_v_encoding == Py_None)) { PyErr_SetString(PyExc_TypeError, "expected bytes, NoneType found"); __PYX_ERR(0, 478, __pyx_L9_error) } __pyx_t_15 = __Pyx_PyBytes_AsString(__pyx_v_encoding); if (unlikely((!__pyx_t_15) && PyErr_Occurred())) __PYX_ERR(0, 478, __pyx_L9_error) __pyx_t_11 = __Pyx_decode_bytes(((PyObject*)__pyx_7genexpr__pyx_v_key), 0, PY_SSIZE_T_MAX, __pyx_t_15, NULL, NULL); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 478, __pyx_L9_error) __Pyx_GOTREF(__pyx_t_11); __pyx_t_8 = __pyx_t_11; __pyx_t_11 = 0; } else { __Pyx_INCREF(__pyx_7genexpr__pyx_v_key); __pyx_t_8 = __pyx_7genexpr__pyx_v_key; } if (unlikely(PyDict_SetItem(__pyx_t_3, (PyObject*)__pyx_t_8, (PyObject*)__pyx_7genexpr__pyx_v_value))) __PYX_ERR(0, 478, __pyx_L9_error) __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; /* "lupa/_lupa.pyx":480 * (key).decode(encoding) if not IS_PY2 and isinstance(key, bytes) else key: value * for key, value in _LuaIter(table, ITEMS) * if not isinstance(key, (int, long)) # <<<<<<<<<<<<<< * } * return new_args, new_kwargs */ } /* "lupa/_lupa.pyx":479 * new_kwargs = { * (key).decode(encoding) if not IS_PY2 and isinstance(key, bytes) else key: value * for key, value in _LuaIter(table, ITEMS) # <<<<<<<<<<<<<< * if not isinstance(key, (int, long)) * } */ } __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_XDECREF(__pyx_7genexpr__pyx_v_key); __pyx_7genexpr__pyx_v_key = 0; __Pyx_XDECREF(__pyx_7genexpr__pyx_v_value); __pyx_7genexpr__pyx_v_value = 0; goto __pyx_L19_exit_scope; __pyx_L9_error:; __Pyx_XDECREF(__pyx_7genexpr__pyx_v_key); __pyx_7genexpr__pyx_v_key = 0; __Pyx_XDECREF(__pyx_7genexpr__pyx_v_value); __pyx_7genexpr__pyx_v_value = 0; goto __pyx_L1_error; __pyx_L19_exit_scope:; } /* exit inner scope */ __pyx_v_new_kwargs = ((PyObject*)__pyx_t_3); __pyx_t_3 = 0; /* "lupa/_lupa.pyx":482 * if not isinstance(key, (int, long)) * } * return new_args, new_kwargs # <<<<<<<<<<<<<< * * */ __Pyx_XDECREF(__pyx_r); __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 482, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_INCREF(__pyx_v_new_args); __Pyx_GIVEREF(__pyx_v_new_args); PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_v_new_args); __Pyx_INCREF(__pyx_v_new_kwargs); __Pyx_GIVEREF(__pyx_v_new_kwargs); PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_v_new_kwargs); __pyx_r = ((PyObject*)__pyx_t_3); __pyx_t_3 = 0; goto __pyx_L0; /* "lupa/_lupa.pyx":454 * * * cdef tuple _fix_args_kwargs(tuple args): # <<<<<<<<<<<<<< * """ * Extract named arguments from args passed to a Python function by Lua */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_3); __Pyx_XDECREF(__pyx_t_4); __Pyx_XDECREF(__pyx_t_8); __Pyx_XDECREF(__pyx_t_10); __Pyx_XDECREF(__pyx_t_11); __Pyx_XDECREF(__pyx_t_12); __Pyx_AddTraceback("lupa._lupa._fix_args_kwargs", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = 0; __pyx_L0:; __Pyx_XDECREF(__pyx_v_arg); __Pyx_XDECREF((PyObject *)__pyx_v_table); __Pyx_XDECREF(__pyx_v_encoding); __Pyx_XDECREF(__pyx_v_new_args); __Pyx_XDECREF(__pyx_v_new_kwargs); __Pyx_XDECREF(__pyx_7genexpr__pyx_v_key); __Pyx_XDECREF(__pyx_7genexpr__pyx_v_value); __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "lupa/_lupa.pyx":488 * # fast, re-entrant runtime locking * * cdef inline int lock_runtime(LuaRuntime runtime) except -1: # <<<<<<<<<<<<<< * if not lock_lock(runtime._lock, pythread.PyThread_get_thread_ident(), True): * raise LuaError("Failed to acquire thread lock") */ static CYTHON_INLINE int __pyx_f_4lupa_5_lupa_lock_runtime(struct __pyx_obj_4lupa_5_lupa_LuaRuntime *__pyx_v_runtime) { int __pyx_r; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; int __pyx_t_2; PyObject *__pyx_t_3 = NULL; __Pyx_RefNannySetupContext("lock_runtime", 0); /* "lupa/_lupa.pyx":489 * * cdef inline int lock_runtime(LuaRuntime runtime) except -1: * if not lock_lock(runtime._lock, pythread.PyThread_get_thread_ident(), True): # <<<<<<<<<<<<<< * raise LuaError("Failed to acquire thread lock") * return 0 */ __pyx_t_1 = ((PyObject *)__pyx_v_runtime->_lock); __Pyx_INCREF(__pyx_t_1); __pyx_t_2 = ((!(__pyx_f_4lupa_5_lupa_lock_lock(((struct __pyx_obj_4lupa_5_lupa_FastRLock *)__pyx_t_1), PyThread_get_thread_ident(), 1) != 0)) != 0); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; if (__pyx_t_2) { /* "lupa/_lupa.pyx":490 * cdef inline int lock_runtime(LuaRuntime runtime) except -1: * if not lock_lock(runtime._lock, pythread.PyThread_get_thread_ident(), True): * raise LuaError("Failed to acquire thread lock") # <<<<<<<<<<<<<< * return 0 * */ __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_LuaError); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 490, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_tuple__18, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 490, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_Raise(__pyx_t_3, 0, 0, 0); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __PYX_ERR(0, 490, __pyx_L1_error) /* "lupa/_lupa.pyx":489 * * cdef inline int lock_runtime(LuaRuntime runtime) except -1: * if not lock_lock(runtime._lock, pythread.PyThread_get_thread_ident(), True): # <<<<<<<<<<<<<< * raise LuaError("Failed to acquire thread lock") * return 0 */ } /* "lupa/_lupa.pyx":491 * if not lock_lock(runtime._lock, pythread.PyThread_get_thread_ident(), True): * raise LuaError("Failed to acquire thread lock") * return 0 # <<<<<<<<<<<<<< * * cdef inline void unlock_runtime(LuaRuntime runtime) nogil: */ __pyx_r = 0; goto __pyx_L0; /* "lupa/_lupa.pyx":488 * # fast, re-entrant runtime locking * * cdef inline int lock_runtime(LuaRuntime runtime) except -1: # <<<<<<<<<<<<<< * if not lock_lock(runtime._lock, pythread.PyThread_get_thread_ident(), True): * raise LuaError("Failed to acquire thread lock") */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_3); __Pyx_AddTraceback("lupa._lupa.lock_runtime", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = -1; __pyx_L0:; __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "lupa/_lupa.pyx":493 * return 0 * * cdef inline void unlock_runtime(LuaRuntime runtime) nogil: # <<<<<<<<<<<<<< * unlock_lock(runtime._lock) * */ static CYTHON_INLINE void __pyx_f_4lupa_5_lupa_unlock_runtime(struct __pyx_obj_4lupa_5_lupa_LuaRuntime *__pyx_v_runtime) { /* "lupa/_lupa.pyx":494 * * cdef inline void unlock_runtime(LuaRuntime runtime) nogil: * unlock_lock(runtime._lock) # <<<<<<<<<<<<<< * * */ __pyx_f_4lupa_5_lupa_unlock_lock(__pyx_v_runtime->_lock); /* "lupa/_lupa.pyx":493 * return 0 * * cdef inline void unlock_runtime(LuaRuntime runtime) nogil: # <<<<<<<<<<<<<< * unlock_lock(runtime._lock) * */ /* function exit code */ } /* "lupa/_lupa.pyx":510 * cdef int _ref * * def __init__(self): # <<<<<<<<<<<<<< * raise TypeError("Type cannot be instantiated manually") * */ /* Python wrapper */ static int __pyx_pw_4lupa_5_lupa_10_LuaObject_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ static int __pyx_pw_4lupa_5_lupa_10_LuaObject_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { int __pyx_r; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__init__ (wrapper)", 0); if (unlikely(PyTuple_GET_SIZE(__pyx_args) > 0)) { __Pyx_RaiseArgtupleInvalid("__init__", 1, 0, 0, PyTuple_GET_SIZE(__pyx_args)); return -1;} if (unlikely(__pyx_kwds) && unlikely(PyDict_Size(__pyx_kwds) > 0) && unlikely(!__Pyx_CheckKeywordStrings(__pyx_kwds, "__init__", 0))) return -1; __pyx_r = __pyx_pf_4lupa_5_lupa_10_LuaObject___init__(((struct __pyx_obj_4lupa_5_lupa__LuaObject *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static int __pyx_pf_4lupa_5_lupa_10_LuaObject___init__(CYTHON_UNUSED struct __pyx_obj_4lupa_5_lupa__LuaObject *__pyx_v_self) { int __pyx_r; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; __Pyx_RefNannySetupContext("__init__", 0); /* "lupa/_lupa.pyx":511 * * def __init__(self): * raise TypeError("Type cannot be instantiated manually") # <<<<<<<<<<<<<< * * def __dealloc__(self): */ __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__19, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 511, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_Raise(__pyx_t_1, 0, 0, 0); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __PYX_ERR(0, 511, __pyx_L1_error) /* "lupa/_lupa.pyx":510 * cdef int _ref * * def __init__(self): # <<<<<<<<<<<<<< * raise TypeError("Type cannot be instantiated manually") * */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_AddTraceback("lupa._lupa._LuaObject.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = -1; __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "lupa/_lupa.pyx":513 * raise TypeError("Type cannot be instantiated manually") * * def __dealloc__(self): # <<<<<<<<<<<<<< * if self._runtime is None: * return */ /* Python wrapper */ static void __pyx_pw_4lupa_5_lupa_10_LuaObject_3__dealloc__(PyObject *__pyx_v_self); /*proto*/ static void __pyx_pw_4lupa_5_lupa_10_LuaObject_3__dealloc__(PyObject *__pyx_v_self) { __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__dealloc__ (wrapper)", 0); __pyx_pf_4lupa_5_lupa_10_LuaObject_2__dealloc__(((struct __pyx_obj_4lupa_5_lupa__LuaObject *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); } static void __pyx_pf_4lupa_5_lupa_10_LuaObject_2__dealloc__(struct __pyx_obj_4lupa_5_lupa__LuaObject *__pyx_v_self) { lua_State *__pyx_v_L; int __pyx_v_locked; __Pyx_RefNannyDeclarations int __pyx_t_1; int __pyx_t_2; lua_State *__pyx_t_3; PyObject *__pyx_t_4 = NULL; PyObject *__pyx_t_5 = NULL; PyObject *__pyx_t_6 = NULL; PyObject *__pyx_t_7 = NULL; int __pyx_t_8; PyObject *__pyx_t_9 = NULL; PyObject *__pyx_t_10 = NULL; __Pyx_RefNannySetupContext("__dealloc__", 0); /* "lupa/_lupa.pyx":514 * * def __dealloc__(self): * if self._runtime is None: # <<<<<<<<<<<<<< * return * cdef lua_State* L = self._state */ __pyx_t_1 = (((PyObject *)__pyx_v_self->_runtime) == Py_None); __pyx_t_2 = (__pyx_t_1 != 0); if (__pyx_t_2) { /* "lupa/_lupa.pyx":515 * def __dealloc__(self): * if self._runtime is None: * return # <<<<<<<<<<<<<< * cdef lua_State* L = self._state * try: */ goto __pyx_L0; /* "lupa/_lupa.pyx":514 * * def __dealloc__(self): * if self._runtime is None: # <<<<<<<<<<<<<< * return * cdef lua_State* L = self._state */ } /* "lupa/_lupa.pyx":516 * if self._runtime is None: * return * cdef lua_State* L = self._state # <<<<<<<<<<<<<< * try: * lock_runtime(self._runtime) */ __pyx_t_3 = __pyx_v_self->_state; __pyx_v_L = __pyx_t_3; /* "lupa/_lupa.pyx":517 * return * cdef lua_State* L = self._state * try: # <<<<<<<<<<<<<< * lock_runtime(self._runtime) * locked = True */ { __Pyx_PyThreadState_declare __Pyx_PyThreadState_assign __Pyx_ExceptionSave(&__pyx_t_4, &__pyx_t_5, &__pyx_t_6); __Pyx_XGOTREF(__pyx_t_4); __Pyx_XGOTREF(__pyx_t_5); __Pyx_XGOTREF(__pyx_t_6); /*try:*/ { /* "lupa/_lupa.pyx":518 * cdef lua_State* L = self._state * try: * lock_runtime(self._runtime) # <<<<<<<<<<<<<< * locked = True * except: */ __pyx_t_7 = ((PyObject *)__pyx_v_self->_runtime); __Pyx_INCREF(__pyx_t_7); __pyx_t_8 = __pyx_f_4lupa_5_lupa_lock_runtime(((struct __pyx_obj_4lupa_5_lupa_LuaRuntime *)__pyx_t_7)); if (unlikely(__pyx_t_8 == ((int)-1))) __PYX_ERR(0, 518, __pyx_L4_error) __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; /* "lupa/_lupa.pyx":519 * try: * lock_runtime(self._runtime) * locked = True # <<<<<<<<<<<<<< * except: * locked = False */ __pyx_v_locked = 1; /* "lupa/_lupa.pyx":517 * return * cdef lua_State* L = self._state * try: # <<<<<<<<<<<<<< * lock_runtime(self._runtime) * locked = True */ } __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; goto __pyx_L9_try_end; __pyx_L4_error:; __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0; /* "lupa/_lupa.pyx":520 * lock_runtime(self._runtime) * locked = True * except: # <<<<<<<<<<<<<< * locked = False * lua.luaL_unref(L, lua.LUA_REGISTRYINDEX, self._ref) */ /*except:*/ { __Pyx_AddTraceback("lupa._lupa._LuaObject.__dealloc__", __pyx_clineno, __pyx_lineno, __pyx_filename); if (__Pyx_GetException(&__pyx_t_7, &__pyx_t_9, &__pyx_t_10) < 0) __PYX_ERR(0, 520, __pyx_L6_except_error) __Pyx_GOTREF(__pyx_t_7); __Pyx_GOTREF(__pyx_t_9); __Pyx_GOTREF(__pyx_t_10); /* "lupa/_lupa.pyx":521 * locked = True * except: * locked = False # <<<<<<<<<<<<<< * lua.luaL_unref(L, lua.LUA_REGISTRYINDEX, self._ref) * if locked: */ __pyx_v_locked = 0; __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; goto __pyx_L5_exception_handled; } __pyx_L6_except_error:; /* "lupa/_lupa.pyx":517 * return * cdef lua_State* L = self._state * try: # <<<<<<<<<<<<<< * lock_runtime(self._runtime) * locked = True */ __Pyx_XGIVEREF(__pyx_t_4); __Pyx_XGIVEREF(__pyx_t_5); __Pyx_XGIVEREF(__pyx_t_6); __Pyx_ExceptionReset(__pyx_t_4, __pyx_t_5, __pyx_t_6); goto __pyx_L1_error; __pyx_L5_exception_handled:; __Pyx_XGIVEREF(__pyx_t_4); __Pyx_XGIVEREF(__pyx_t_5); __Pyx_XGIVEREF(__pyx_t_6); __Pyx_ExceptionReset(__pyx_t_4, __pyx_t_5, __pyx_t_6); __pyx_L9_try_end:; } /* "lupa/_lupa.pyx":522 * except: * locked = False * lua.luaL_unref(L, lua.LUA_REGISTRYINDEX, self._ref) # <<<<<<<<<<<<<< * if locked: * unlock_runtime(self._runtime) */ luaL_unref(__pyx_v_L, LUA_REGISTRYINDEX, __pyx_v_self->_ref); /* "lupa/_lupa.pyx":523 * locked = False * lua.luaL_unref(L, lua.LUA_REGISTRYINDEX, self._ref) * if locked: # <<<<<<<<<<<<<< * unlock_runtime(self._runtime) * */ __pyx_t_2 = (__pyx_v_locked != 0); if (__pyx_t_2) { /* "lupa/_lupa.pyx":524 * lua.luaL_unref(L, lua.LUA_REGISTRYINDEX, self._ref) * if locked: * unlock_runtime(self._runtime) # <<<<<<<<<<<<<< * * @cython.final */ __pyx_t_10 = ((PyObject *)__pyx_v_self->_runtime); __Pyx_INCREF(__pyx_t_10); __pyx_f_4lupa_5_lupa_unlock_runtime(((struct __pyx_obj_4lupa_5_lupa_LuaRuntime *)__pyx_t_10)); __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; /* "lupa/_lupa.pyx":523 * locked = False * lua.luaL_unref(L, lua.LUA_REGISTRYINDEX, self._ref) * if locked: # <<<<<<<<<<<<<< * unlock_runtime(self._runtime) * */ } /* "lupa/_lupa.pyx":513 * raise TypeError("Type cannot be instantiated manually") * * def __dealloc__(self): # <<<<<<<<<<<<<< * if self._runtime is None: * return */ /* function exit code */ goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_7); __Pyx_XDECREF(__pyx_t_9); __Pyx_XDECREF(__pyx_t_10); __Pyx_WriteUnraisable("lupa._lupa._LuaObject.__dealloc__", __pyx_clineno, __pyx_lineno, __pyx_filename, 1, 0); __pyx_L0:; __Pyx_RefNannyFinishContext(); } /* "lupa/_lupa.pyx":527 * * @cython.final * cdef inline int push_lua_object(self) except -1: # <<<<<<<<<<<<<< * cdef lua_State* L = self._state * lua.lua_rawgeti(L, lua.LUA_REGISTRYINDEX, self._ref) */ static CYTHON_INLINE int __pyx_f_4lupa_5_lupa_10_LuaObject_push_lua_object(struct __pyx_obj_4lupa_5_lupa__LuaObject *__pyx_v_self) { lua_State *__pyx_v_L; int __pyx_r; __Pyx_RefNannyDeclarations lua_State *__pyx_t_1; int __pyx_t_2; PyObject *__pyx_t_3 = NULL; PyObject *__pyx_t_4 = NULL; __Pyx_RefNannySetupContext("push_lua_object", 0); /* "lupa/_lupa.pyx":528 * @cython.final * cdef inline int push_lua_object(self) except -1: * cdef lua_State* L = self._state # <<<<<<<<<<<<<< * lua.lua_rawgeti(L, lua.LUA_REGISTRYINDEX, self._ref) * if lua.lua_isnil(L, -1): */ __pyx_t_1 = __pyx_v_self->_state; __pyx_v_L = __pyx_t_1; /* "lupa/_lupa.pyx":529 * cdef inline int push_lua_object(self) except -1: * cdef lua_State* L = self._state * lua.lua_rawgeti(L, lua.LUA_REGISTRYINDEX, self._ref) # <<<<<<<<<<<<<< * if lua.lua_isnil(L, -1): * lua.lua_pop(L, 1) */ lua_rawgeti(__pyx_v_L, LUA_REGISTRYINDEX, __pyx_v_self->_ref); /* "lupa/_lupa.pyx":530 * cdef lua_State* L = self._state * lua.lua_rawgeti(L, lua.LUA_REGISTRYINDEX, self._ref) * if lua.lua_isnil(L, -1): # <<<<<<<<<<<<<< * lua.lua_pop(L, 1) * raise LuaError("lost reference") */ __pyx_t_2 = (lua_isnil(__pyx_v_L, -1) != 0); if (__pyx_t_2) { /* "lupa/_lupa.pyx":531 * lua.lua_rawgeti(L, lua.LUA_REGISTRYINDEX, self._ref) * if lua.lua_isnil(L, -1): * lua.lua_pop(L, 1) # <<<<<<<<<<<<<< * raise LuaError("lost reference") * */ lua_pop(__pyx_v_L, 1); /* "lupa/_lupa.pyx":532 * if lua.lua_isnil(L, -1): * lua.lua_pop(L, 1) * raise LuaError("lost reference") # <<<<<<<<<<<<<< * * def __call__(self, *args): */ __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_LuaError); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 532, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_tuple__20, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 532, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_Raise(__pyx_t_4, 0, 0, 0); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __PYX_ERR(0, 532, __pyx_L1_error) /* "lupa/_lupa.pyx":530 * cdef lua_State* L = self._state * lua.lua_rawgeti(L, lua.LUA_REGISTRYINDEX, self._ref) * if lua.lua_isnil(L, -1): # <<<<<<<<<<<<<< * lua.lua_pop(L, 1) * raise LuaError("lost reference") */ } /* "lupa/_lupa.pyx":527 * * @cython.final * cdef inline int push_lua_object(self) except -1: # <<<<<<<<<<<<<< * cdef lua_State* L = self._state * lua.lua_rawgeti(L, lua.LUA_REGISTRYINDEX, self._ref) */ /* function exit code */ __pyx_r = 0; goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_3); __Pyx_XDECREF(__pyx_t_4); __Pyx_AddTraceback("lupa._lupa._LuaObject.push_lua_object", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = -1; __pyx_L0:; __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "lupa/_lupa.pyx":534 * raise LuaError("lost reference") * * def __call__(self, *args): # <<<<<<<<<<<<<< * assert self._runtime is not None * cdef lua_State* L = self._state */ /* Python wrapper */ static PyObject *__pyx_pw_4lupa_5_lupa_10_LuaObject_5__call__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ static PyObject *__pyx_pw_4lupa_5_lupa_10_LuaObject_5__call__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { PyObject *__pyx_v_args = 0; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__call__ (wrapper)", 0); if (unlikely(__pyx_kwds) && unlikely(PyDict_Size(__pyx_kwds) > 0) && unlikely(!__Pyx_CheckKeywordStrings(__pyx_kwds, "__call__", 0))) return NULL; __Pyx_INCREF(__pyx_args); __pyx_v_args = __pyx_args; __pyx_r = __pyx_pf_4lupa_5_lupa_10_LuaObject_4__call__(((struct __pyx_obj_4lupa_5_lupa__LuaObject *)__pyx_v_self), __pyx_v_args); /* function exit code */ __Pyx_XDECREF(__pyx_v_args); __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_4lupa_5_lupa_10_LuaObject_4__call__(struct __pyx_obj_4lupa_5_lupa__LuaObject *__pyx_v_self, PyObject *__pyx_v_args) { lua_State *__pyx_v_L; PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations int __pyx_t_1; lua_State *__pyx_t_2; PyObject *__pyx_t_3 = NULL; int __pyx_t_4; PyObject *__pyx_t_5 = NULL; int __pyx_t_6; char const *__pyx_t_7; PyObject *__pyx_t_8 = NULL; PyObject *__pyx_t_9 = NULL; PyObject *__pyx_t_10 = NULL; PyObject *__pyx_t_11 = NULL; PyObject *__pyx_t_12 = NULL; PyObject *__pyx_t_13 = NULL; __Pyx_RefNannySetupContext("__call__", 0); /* "lupa/_lupa.pyx":535 * * def __call__(self, *args): * assert self._runtime is not None # <<<<<<<<<<<<<< * cdef lua_State* L = self._state * lock_runtime(self._runtime) */ #ifndef CYTHON_WITHOUT_ASSERTIONS if (unlikely(!Py_OptimizeFlag)) { __pyx_t_1 = (((PyObject *)__pyx_v_self->_runtime) != Py_None); if (unlikely(!(__pyx_t_1 != 0))) { PyErr_SetNone(PyExc_AssertionError); __PYX_ERR(0, 535, __pyx_L1_error) } } #endif /* "lupa/_lupa.pyx":536 * def __call__(self, *args): * assert self._runtime is not None * cdef lua_State* L = self._state # <<<<<<<<<<<<<< * lock_runtime(self._runtime) * try: */ __pyx_t_2 = __pyx_v_self->_state; __pyx_v_L = __pyx_t_2; /* "lupa/_lupa.pyx":537 * assert self._runtime is not None * cdef lua_State* L = self._state * lock_runtime(self._runtime) # <<<<<<<<<<<<<< * try: * lua.lua_settop(L, 0) */ __pyx_t_3 = ((PyObject *)__pyx_v_self->_runtime); __Pyx_INCREF(__pyx_t_3); __pyx_t_4 = __pyx_f_4lupa_5_lupa_lock_runtime(((struct __pyx_obj_4lupa_5_lupa_LuaRuntime *)__pyx_t_3)); if (unlikely(__pyx_t_4 == ((int)-1))) __PYX_ERR(0, 537, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; /* "lupa/_lupa.pyx":538 * cdef lua_State* L = self._state * lock_runtime(self._runtime) * try: # <<<<<<<<<<<<<< * lua.lua_settop(L, 0) * self.push_lua_object() */ /*try:*/ { /* "lupa/_lupa.pyx":539 * lock_runtime(self._runtime) * try: * lua.lua_settop(L, 0) # <<<<<<<<<<<<<< * self.push_lua_object() * return call_lua(self._runtime, L, args) */ lua_settop(__pyx_v_L, 0); /* "lupa/_lupa.pyx":540 * try: * lua.lua_settop(L, 0) * self.push_lua_object() # <<<<<<<<<<<<<< * return call_lua(self._runtime, L, args) * finally: */ __pyx_t_4 = __pyx_f_4lupa_5_lupa_10_LuaObject_push_lua_object(__pyx_v_self); if (unlikely(__pyx_t_4 == ((int)-1))) __PYX_ERR(0, 540, __pyx_L4_error) /* "lupa/_lupa.pyx":541 * lua.lua_settop(L, 0) * self.push_lua_object() * return call_lua(self._runtime, L, args) # <<<<<<<<<<<<<< * finally: * lua.lua_settop(L, 0) */ __Pyx_XDECREF(__pyx_r); __pyx_t_3 = ((PyObject *)__pyx_v_self->_runtime); __Pyx_INCREF(__pyx_t_3); __pyx_t_5 = __pyx_f_4lupa_5_lupa_call_lua(((struct __pyx_obj_4lupa_5_lupa_LuaRuntime *)__pyx_t_3), __pyx_v_L, __pyx_v_args); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 541, __pyx_L4_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_r = __pyx_t_5; __pyx_t_5 = 0; goto __pyx_L3_return; } /* "lupa/_lupa.pyx":543 * return call_lua(self._runtime, L, args) * finally: * lua.lua_settop(L, 0) # <<<<<<<<<<<<<< * unlock_runtime(self._runtime) * */ /*finally:*/ { __pyx_L4_error:; /*exception exit:*/{ __Pyx_PyThreadState_declare __Pyx_PyThreadState_assign __pyx_t_8 = 0; __pyx_t_9 = 0; __pyx_t_10 = 0; __pyx_t_11 = 0; __pyx_t_12 = 0; __pyx_t_13 = 0; __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; if (PY_MAJOR_VERSION >= 3) __Pyx_ExceptionSwap(&__pyx_t_11, &__pyx_t_12, &__pyx_t_13); if ((PY_MAJOR_VERSION < 3) || unlikely(__Pyx_GetException(&__pyx_t_8, &__pyx_t_9, &__pyx_t_10) < 0)) __Pyx_ErrFetch(&__pyx_t_8, &__pyx_t_9, &__pyx_t_10); __Pyx_XGOTREF(__pyx_t_8); __Pyx_XGOTREF(__pyx_t_9); __Pyx_XGOTREF(__pyx_t_10); __Pyx_XGOTREF(__pyx_t_11); __Pyx_XGOTREF(__pyx_t_12); __Pyx_XGOTREF(__pyx_t_13); __pyx_t_4 = __pyx_lineno; __pyx_t_6 = __pyx_clineno; __pyx_t_7 = __pyx_filename; { lua_settop(__pyx_v_L, 0); /* "lupa/_lupa.pyx":544 * finally: * lua.lua_settop(L, 0) * unlock_runtime(self._runtime) # <<<<<<<<<<<<<< * * def __len__(self): */ __pyx_t_5 = ((PyObject *)__pyx_v_self->_runtime); __Pyx_INCREF(__pyx_t_5); __pyx_f_4lupa_5_lupa_unlock_runtime(((struct __pyx_obj_4lupa_5_lupa_LuaRuntime *)__pyx_t_5)); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; } if (PY_MAJOR_VERSION >= 3) { __Pyx_XGIVEREF(__pyx_t_11); __Pyx_XGIVEREF(__pyx_t_12); __Pyx_XGIVEREF(__pyx_t_13); __Pyx_ExceptionReset(__pyx_t_11, __pyx_t_12, __pyx_t_13); } __Pyx_XGIVEREF(__pyx_t_8); __Pyx_XGIVEREF(__pyx_t_9); __Pyx_XGIVEREF(__pyx_t_10); __Pyx_ErrRestore(__pyx_t_8, __pyx_t_9, __pyx_t_10); __pyx_t_8 = 0; __pyx_t_9 = 0; __pyx_t_10 = 0; __pyx_t_11 = 0; __pyx_t_12 = 0; __pyx_t_13 = 0; __pyx_lineno = __pyx_t_4; __pyx_clineno = __pyx_t_6; __pyx_filename = __pyx_t_7; goto __pyx_L1_error; } __pyx_L3_return: { __pyx_t_13 = __pyx_r; __pyx_r = 0; /* "lupa/_lupa.pyx":543 * return call_lua(self._runtime, L, args) * finally: * lua.lua_settop(L, 0) # <<<<<<<<<<<<<< * unlock_runtime(self._runtime) * */ lua_settop(__pyx_v_L, 0); /* "lupa/_lupa.pyx":544 * finally: * lua.lua_settop(L, 0) * unlock_runtime(self._runtime) # <<<<<<<<<<<<<< * * def __len__(self): */ __pyx_t_5 = ((PyObject *)__pyx_v_self->_runtime); __Pyx_INCREF(__pyx_t_5); __pyx_f_4lupa_5_lupa_unlock_runtime(((struct __pyx_obj_4lupa_5_lupa_LuaRuntime *)__pyx_t_5)); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __pyx_r = __pyx_t_13; __pyx_t_13 = 0; goto __pyx_L0; } } /* "lupa/_lupa.pyx":534 * raise LuaError("lost reference") * * def __call__(self, *args): # <<<<<<<<<<<<<< * assert self._runtime is not None * cdef lua_State* L = self._state */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_3); __Pyx_XDECREF(__pyx_t_5); __Pyx_AddTraceback("lupa._lupa._LuaObject.__call__", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "lupa/_lupa.pyx":546 * unlock_runtime(self._runtime) * * def __len__(self): # <<<<<<<<<<<<<< * return self._len() * */ /* Python wrapper */ static Py_ssize_t __pyx_pw_4lupa_5_lupa_10_LuaObject_7__len__(PyObject *__pyx_v_self); /*proto*/ static Py_ssize_t __pyx_pw_4lupa_5_lupa_10_LuaObject_7__len__(PyObject *__pyx_v_self) { Py_ssize_t __pyx_r; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__len__ (wrapper)", 0); __pyx_r = __pyx_pf_4lupa_5_lupa_10_LuaObject_6__len__(((struct __pyx_obj_4lupa_5_lupa__LuaObject *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static Py_ssize_t __pyx_pf_4lupa_5_lupa_10_LuaObject_6__len__(struct __pyx_obj_4lupa_5_lupa__LuaObject *__pyx_v_self) { Py_ssize_t __pyx_r; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__len__", 0); /* "lupa/_lupa.pyx":547 * * def __len__(self): * return self._len() # <<<<<<<<<<<<<< * * @cython.final */ __pyx_r = __pyx_f_4lupa_5_lupa_10_LuaObject__len(__pyx_v_self); goto __pyx_L0; /* "lupa/_lupa.pyx":546 * unlock_runtime(self._runtime) * * def __len__(self): # <<<<<<<<<<<<<< * return self._len() * */ /* function exit code */ __pyx_L0:; __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "lupa/_lupa.pyx":550 * * @cython.final * cdef size_t _len(self): # <<<<<<<<<<<<<< * assert self._runtime is not None * cdef lua_State* L = self._state */ static size_t __pyx_f_4lupa_5_lupa_10_LuaObject__len(struct __pyx_obj_4lupa_5_lupa__LuaObject *__pyx_v_self) { lua_State *__pyx_v_L; size_t __pyx_v_size; size_t __pyx_r; __Pyx_RefNannyDeclarations int __pyx_t_1; lua_State *__pyx_t_2; PyObject *__pyx_t_3 = NULL; int __pyx_t_4; int __pyx_t_5; char const *__pyx_t_6; PyObject *__pyx_t_7 = NULL; PyObject *__pyx_t_8 = NULL; PyObject *__pyx_t_9 = NULL; PyObject *__pyx_t_10 = NULL; PyObject *__pyx_t_11 = NULL; PyObject *__pyx_t_12 = NULL; __Pyx_RefNannySetupContext("_len", 0); /* "lupa/_lupa.pyx":551 * @cython.final * cdef size_t _len(self): * assert self._runtime is not None # <<<<<<<<<<<<<< * cdef lua_State* L = self._state * lock_runtime(self._runtime) */ #ifndef CYTHON_WITHOUT_ASSERTIONS if (unlikely(!Py_OptimizeFlag)) { __pyx_t_1 = (((PyObject *)__pyx_v_self->_runtime) != Py_None); if (unlikely(!(__pyx_t_1 != 0))) { PyErr_SetNone(PyExc_AssertionError); __PYX_ERR(0, 551, __pyx_L1_error) } } #endif /* "lupa/_lupa.pyx":552 * cdef size_t _len(self): * assert self._runtime is not None * cdef lua_State* L = self._state # <<<<<<<<<<<<<< * lock_runtime(self._runtime) * size = 0 */ __pyx_t_2 = __pyx_v_self->_state; __pyx_v_L = __pyx_t_2; /* "lupa/_lupa.pyx":553 * assert self._runtime is not None * cdef lua_State* L = self._state * lock_runtime(self._runtime) # <<<<<<<<<<<<<< * size = 0 * try: */ __pyx_t_3 = ((PyObject *)__pyx_v_self->_runtime); __Pyx_INCREF(__pyx_t_3); __pyx_t_4 = __pyx_f_4lupa_5_lupa_lock_runtime(((struct __pyx_obj_4lupa_5_lupa_LuaRuntime *)__pyx_t_3)); if (unlikely(__pyx_t_4 == ((int)-1))) __PYX_ERR(0, 553, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; /* "lupa/_lupa.pyx":554 * cdef lua_State* L = self._state * lock_runtime(self._runtime) * size = 0 # <<<<<<<<<<<<<< * try: * self.push_lua_object() */ __pyx_v_size = 0; /* "lupa/_lupa.pyx":555 * lock_runtime(self._runtime) * size = 0 * try: # <<<<<<<<<<<<<< * self.push_lua_object() * size = lua.lua_objlen(L, -1) */ /*try:*/ { /* "lupa/_lupa.pyx":556 * size = 0 * try: * self.push_lua_object() # <<<<<<<<<<<<<< * size = lua.lua_objlen(L, -1) * lua.lua_pop(L, 1) */ __pyx_t_4 = __pyx_f_4lupa_5_lupa_10_LuaObject_push_lua_object(__pyx_v_self); if (unlikely(__pyx_t_4 == ((int)-1))) __PYX_ERR(0, 556, __pyx_L4_error) /* "lupa/_lupa.pyx":557 * try: * self.push_lua_object() * size = lua.lua_objlen(L, -1) # <<<<<<<<<<<<<< * lua.lua_pop(L, 1) * finally: */ __pyx_v_size = lua_objlen(__pyx_v_L, -1); /* "lupa/_lupa.pyx":558 * self.push_lua_object() * size = lua.lua_objlen(L, -1) * lua.lua_pop(L, 1) # <<<<<<<<<<<<<< * finally: * unlock_runtime(self._runtime) */ lua_pop(__pyx_v_L, 1); } /* "lupa/_lupa.pyx":560 * lua.lua_pop(L, 1) * finally: * unlock_runtime(self._runtime) # <<<<<<<<<<<<<< * return size * */ /*finally:*/ { /*normal exit:*/{ __pyx_t_3 = ((PyObject *)__pyx_v_self->_runtime); __Pyx_INCREF(__pyx_t_3); __pyx_f_4lupa_5_lupa_unlock_runtime(((struct __pyx_obj_4lupa_5_lupa_LuaRuntime *)__pyx_t_3)); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; goto __pyx_L5; } __pyx_L4_error:; /*exception exit:*/{ __Pyx_PyThreadState_declare __Pyx_PyThreadState_assign __pyx_t_7 = 0; __pyx_t_8 = 0; __pyx_t_9 = 0; __pyx_t_10 = 0; __pyx_t_11 = 0; __pyx_t_12 = 0; __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; if (PY_MAJOR_VERSION >= 3) __Pyx_ExceptionSwap(&__pyx_t_10, &__pyx_t_11, &__pyx_t_12); if ((PY_MAJOR_VERSION < 3) || unlikely(__Pyx_GetException(&__pyx_t_7, &__pyx_t_8, &__pyx_t_9) < 0)) __Pyx_ErrFetch(&__pyx_t_7, &__pyx_t_8, &__pyx_t_9); __Pyx_XGOTREF(__pyx_t_7); __Pyx_XGOTREF(__pyx_t_8); __Pyx_XGOTREF(__pyx_t_9); __Pyx_XGOTREF(__pyx_t_10); __Pyx_XGOTREF(__pyx_t_11); __Pyx_XGOTREF(__pyx_t_12); __pyx_t_4 = __pyx_lineno; __pyx_t_5 = __pyx_clineno; __pyx_t_6 = __pyx_filename; { __pyx_t_3 = ((PyObject *)__pyx_v_self->_runtime); __Pyx_INCREF(__pyx_t_3); __pyx_f_4lupa_5_lupa_unlock_runtime(((struct __pyx_obj_4lupa_5_lupa_LuaRuntime *)__pyx_t_3)); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; } if (PY_MAJOR_VERSION >= 3) { __Pyx_XGIVEREF(__pyx_t_10); __Pyx_XGIVEREF(__pyx_t_11); __Pyx_XGIVEREF(__pyx_t_12); __Pyx_ExceptionReset(__pyx_t_10, __pyx_t_11, __pyx_t_12); } __Pyx_XGIVEREF(__pyx_t_7); __Pyx_XGIVEREF(__pyx_t_8); __Pyx_XGIVEREF(__pyx_t_9); __Pyx_ErrRestore(__pyx_t_7, __pyx_t_8, __pyx_t_9); __pyx_t_7 = 0; __pyx_t_8 = 0; __pyx_t_9 = 0; __pyx_t_10 = 0; __pyx_t_11 = 0; __pyx_t_12 = 0; __pyx_lineno = __pyx_t_4; __pyx_clineno = __pyx_t_5; __pyx_filename = __pyx_t_6; goto __pyx_L1_error; } __pyx_L5:; } /* "lupa/_lupa.pyx":561 * finally: * unlock_runtime(self._runtime) * return size # <<<<<<<<<<<<<< * * def __nonzero__(self): */ __pyx_r = __pyx_v_size; goto __pyx_L0; /* "lupa/_lupa.pyx":550 * * @cython.final * cdef size_t _len(self): # <<<<<<<<<<<<<< * assert self._runtime is not None * cdef lua_State* L = self._state */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_3); __Pyx_WriteUnraisable("lupa._lupa._LuaObject._len", __pyx_clineno, __pyx_lineno, __pyx_filename, 1, 0); __pyx_r = 0; __pyx_L0:; __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "lupa/_lupa.pyx":563 * return size * * def __nonzero__(self): # <<<<<<<<<<<<<< * return True * */ /* Python wrapper */ static int __pyx_pw_4lupa_5_lupa_10_LuaObject_9__nonzero__(PyObject *__pyx_v_self); /*proto*/ static int __pyx_pw_4lupa_5_lupa_10_LuaObject_9__nonzero__(PyObject *__pyx_v_self) { int __pyx_r; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__nonzero__ (wrapper)", 0); __pyx_r = __pyx_pf_4lupa_5_lupa_10_LuaObject_8__nonzero__(((struct __pyx_obj_4lupa_5_lupa__LuaObject *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static int __pyx_pf_4lupa_5_lupa_10_LuaObject_8__nonzero__(CYTHON_UNUSED struct __pyx_obj_4lupa_5_lupa__LuaObject *__pyx_v_self) { int __pyx_r; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__nonzero__", 0); /* "lupa/_lupa.pyx":564 * * def __nonzero__(self): * return True # <<<<<<<<<<<<<< * * def __iter__(self): */ __pyx_r = 1; goto __pyx_L0; /* "lupa/_lupa.pyx":563 * return size * * def __nonzero__(self): # <<<<<<<<<<<<<< * return True * */ /* function exit code */ __pyx_L0:; __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "lupa/_lupa.pyx":566 * return True * * def __iter__(self): # <<<<<<<<<<<<<< * # if not provided, iteration will try item access and call into Lua * raise TypeError("iteration is only supported for tables") */ /* Python wrapper */ static PyObject *__pyx_pw_4lupa_5_lupa_10_LuaObject_11__iter__(PyObject *__pyx_v_self); /*proto*/ static PyObject *__pyx_pw_4lupa_5_lupa_10_LuaObject_11__iter__(PyObject *__pyx_v_self) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__iter__ (wrapper)", 0); __pyx_r = __pyx_pf_4lupa_5_lupa_10_LuaObject_10__iter__(((struct __pyx_obj_4lupa_5_lupa__LuaObject *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_4lupa_5_lupa_10_LuaObject_10__iter__(CYTHON_UNUSED struct __pyx_obj_4lupa_5_lupa__LuaObject *__pyx_v_self) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; __Pyx_RefNannySetupContext("__iter__", 0); /* "lupa/_lupa.pyx":568 * def __iter__(self): * # if not provided, iteration will try item access and call into Lua * raise TypeError("iteration is only supported for tables") # <<<<<<<<<<<<<< * * def __repr__(self): */ __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__21, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 568, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_Raise(__pyx_t_1, 0, 0, 0); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __PYX_ERR(0, 568, __pyx_L1_error) /* "lupa/_lupa.pyx":566 * return True * * def __iter__(self): # <<<<<<<<<<<<<< * # if not provided, iteration will try item access and call into Lua * raise TypeError("iteration is only supported for tables") */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_AddTraceback("lupa._lupa._LuaObject.__iter__", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "lupa/_lupa.pyx":570 * raise TypeError("iteration is only supported for tables") * * def __repr__(self): # <<<<<<<<<<<<<< * assert self._runtime is not None * cdef lua_State* L = self._state */ /* Python wrapper */ static PyObject *__pyx_pw_4lupa_5_lupa_10_LuaObject_13__repr__(PyObject *__pyx_v_self); /*proto*/ static PyObject *__pyx_pw_4lupa_5_lupa_10_LuaObject_13__repr__(PyObject *__pyx_v_self) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__repr__ (wrapper)", 0); __pyx_r = __pyx_pf_4lupa_5_lupa_10_LuaObject_12__repr__(((struct __pyx_obj_4lupa_5_lupa__LuaObject *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_4lupa_5_lupa_10_LuaObject_12__repr__(struct __pyx_obj_4lupa_5_lupa__LuaObject *__pyx_v_self) { lua_State *__pyx_v_L; PyObject *__pyx_v_encoding = 0; PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations int __pyx_t_1; lua_State *__pyx_t_2; PyObject *__pyx_t_3 = NULL; int __pyx_t_4; int __pyx_t_5; char const *__pyx_t_6; PyObject *__pyx_t_7 = NULL; PyObject *__pyx_t_8 = NULL; PyObject *__pyx_t_9 = NULL; PyObject *__pyx_t_10 = NULL; PyObject *__pyx_t_11 = NULL; PyObject *__pyx_t_12 = NULL; __Pyx_RefNannySetupContext("__repr__", 0); /* "lupa/_lupa.pyx":571 * * def __repr__(self): * assert self._runtime is not None # <<<<<<<<<<<<<< * cdef lua_State* L = self._state * cdef bytes encoding = self._runtime._encoding or b'UTF-8' */ #ifndef CYTHON_WITHOUT_ASSERTIONS if (unlikely(!Py_OptimizeFlag)) { __pyx_t_1 = (((PyObject *)__pyx_v_self->_runtime) != Py_None); if (unlikely(!(__pyx_t_1 != 0))) { PyErr_SetNone(PyExc_AssertionError); __PYX_ERR(0, 571, __pyx_L1_error) } } #endif /* "lupa/_lupa.pyx":572 * def __repr__(self): * assert self._runtime is not None * cdef lua_State* L = self._state # <<<<<<<<<<<<<< * cdef bytes encoding = self._runtime._encoding or b'UTF-8' * lock_runtime(self._runtime) */ __pyx_t_2 = __pyx_v_self->_state; __pyx_v_L = __pyx_t_2; /* "lupa/_lupa.pyx":573 * assert self._runtime is not None * cdef lua_State* L = self._state * cdef bytes encoding = self._runtime._encoding or b'UTF-8' # <<<<<<<<<<<<<< * lock_runtime(self._runtime) * try: */ __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_v_self->_runtime->_encoding); if (unlikely(__pyx_t_1 < 0)) __PYX_ERR(0, 573, __pyx_L1_error) if (!__pyx_t_1) { } else { __Pyx_INCREF(__pyx_v_self->_runtime->_encoding); __pyx_t_3 = __pyx_v_self->_runtime->_encoding; goto __pyx_L3_bool_binop_done; } __Pyx_INCREF(__pyx_kp_b_UTF_8); __pyx_t_3 = __pyx_kp_b_UTF_8; __pyx_L3_bool_binop_done:; __pyx_v_encoding = ((PyObject*)__pyx_t_3); __pyx_t_3 = 0; /* "lupa/_lupa.pyx":574 * cdef lua_State* L = self._state * cdef bytes encoding = self._runtime._encoding or b'UTF-8' * lock_runtime(self._runtime) # <<<<<<<<<<<<<< * try: * self.push_lua_object() */ __pyx_t_3 = ((PyObject *)__pyx_v_self->_runtime); __Pyx_INCREF(__pyx_t_3); __pyx_t_4 = __pyx_f_4lupa_5_lupa_lock_runtime(((struct __pyx_obj_4lupa_5_lupa_LuaRuntime *)__pyx_t_3)); if (unlikely(__pyx_t_4 == ((int)-1))) __PYX_ERR(0, 574, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; /* "lupa/_lupa.pyx":575 * cdef bytes encoding = self._runtime._encoding or b'UTF-8' * lock_runtime(self._runtime) * try: # <<<<<<<<<<<<<< * self.push_lua_object() * return lua_object_repr(L, encoding) */ /*try:*/ { /* "lupa/_lupa.pyx":576 * lock_runtime(self._runtime) * try: * self.push_lua_object() # <<<<<<<<<<<<<< * return lua_object_repr(L, encoding) * finally: */ __pyx_t_4 = __pyx_f_4lupa_5_lupa_10_LuaObject_push_lua_object(__pyx_v_self); if (unlikely(__pyx_t_4 == ((int)-1))) __PYX_ERR(0, 576, __pyx_L6_error) /* "lupa/_lupa.pyx":577 * try: * self.push_lua_object() * return lua_object_repr(L, encoding) # <<<<<<<<<<<<<< * finally: * lua.lua_pop(L, 1) */ __Pyx_XDECREF(__pyx_r); __pyx_t_3 = __pyx_f_4lupa_5_lupa_lua_object_repr(__pyx_v_L, __pyx_v_encoding); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 577, __pyx_L6_error) __Pyx_GOTREF(__pyx_t_3); __pyx_r = __pyx_t_3; __pyx_t_3 = 0; goto __pyx_L5_return; } /* "lupa/_lupa.pyx":579 * return lua_object_repr(L, encoding) * finally: * lua.lua_pop(L, 1) # <<<<<<<<<<<<<< * unlock_runtime(self._runtime) * */ /*finally:*/ { __pyx_L6_error:; /*exception exit:*/{ __Pyx_PyThreadState_declare __Pyx_PyThreadState_assign __pyx_t_7 = 0; __pyx_t_8 = 0; __pyx_t_9 = 0; __pyx_t_10 = 0; __pyx_t_11 = 0; __pyx_t_12 = 0; __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; if (PY_MAJOR_VERSION >= 3) __Pyx_ExceptionSwap(&__pyx_t_10, &__pyx_t_11, &__pyx_t_12); if ((PY_MAJOR_VERSION < 3) || unlikely(__Pyx_GetException(&__pyx_t_7, &__pyx_t_8, &__pyx_t_9) < 0)) __Pyx_ErrFetch(&__pyx_t_7, &__pyx_t_8, &__pyx_t_9); __Pyx_XGOTREF(__pyx_t_7); __Pyx_XGOTREF(__pyx_t_8); __Pyx_XGOTREF(__pyx_t_9); __Pyx_XGOTREF(__pyx_t_10); __Pyx_XGOTREF(__pyx_t_11); __Pyx_XGOTREF(__pyx_t_12); __pyx_t_4 = __pyx_lineno; __pyx_t_5 = __pyx_clineno; __pyx_t_6 = __pyx_filename; { lua_pop(__pyx_v_L, 1); /* "lupa/_lupa.pyx":580 * finally: * lua.lua_pop(L, 1) * unlock_runtime(self._runtime) # <<<<<<<<<<<<<< * * def __str__(self): */ __pyx_t_3 = ((PyObject *)__pyx_v_self->_runtime); __Pyx_INCREF(__pyx_t_3); __pyx_f_4lupa_5_lupa_unlock_runtime(((struct __pyx_obj_4lupa_5_lupa_LuaRuntime *)__pyx_t_3)); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; } if (PY_MAJOR_VERSION >= 3) { __Pyx_XGIVEREF(__pyx_t_10); __Pyx_XGIVEREF(__pyx_t_11); __Pyx_XGIVEREF(__pyx_t_12); __Pyx_ExceptionReset(__pyx_t_10, __pyx_t_11, __pyx_t_12); } __Pyx_XGIVEREF(__pyx_t_7); __Pyx_XGIVEREF(__pyx_t_8); __Pyx_XGIVEREF(__pyx_t_9); __Pyx_ErrRestore(__pyx_t_7, __pyx_t_8, __pyx_t_9); __pyx_t_7 = 0; __pyx_t_8 = 0; __pyx_t_9 = 0; __pyx_t_10 = 0; __pyx_t_11 = 0; __pyx_t_12 = 0; __pyx_lineno = __pyx_t_4; __pyx_clineno = __pyx_t_5; __pyx_filename = __pyx_t_6; goto __pyx_L1_error; } __pyx_L5_return: { __pyx_t_12 = __pyx_r; __pyx_r = 0; /* "lupa/_lupa.pyx":579 * return lua_object_repr(L, encoding) * finally: * lua.lua_pop(L, 1) # <<<<<<<<<<<<<< * unlock_runtime(self._runtime) * */ lua_pop(__pyx_v_L, 1); /* "lupa/_lupa.pyx":580 * finally: * lua.lua_pop(L, 1) * unlock_runtime(self._runtime) # <<<<<<<<<<<<<< * * def __str__(self): */ __pyx_t_3 = ((PyObject *)__pyx_v_self->_runtime); __Pyx_INCREF(__pyx_t_3); __pyx_f_4lupa_5_lupa_unlock_runtime(((struct __pyx_obj_4lupa_5_lupa_LuaRuntime *)__pyx_t_3)); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_r = __pyx_t_12; __pyx_t_12 = 0; goto __pyx_L0; } } /* "lupa/_lupa.pyx":570 * raise TypeError("iteration is only supported for tables") * * def __repr__(self): # <<<<<<<<<<<<<< * assert self._runtime is not None * cdef lua_State* L = self._state */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_3); __Pyx_AddTraceback("lupa._lupa._LuaObject.__repr__", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XDECREF(__pyx_v_encoding); __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "lupa/_lupa.pyx":582 * unlock_runtime(self._runtime) * * def __str__(self): # <<<<<<<<<<<<<< * assert self._runtime is not None * cdef lua_State* L = self._state */ /* Python wrapper */ static PyObject *__pyx_pw_4lupa_5_lupa_10_LuaObject_15__str__(PyObject *__pyx_v_self); /*proto*/ static PyObject *__pyx_pw_4lupa_5_lupa_10_LuaObject_15__str__(PyObject *__pyx_v_self) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__str__ (wrapper)", 0); __pyx_r = __pyx_pf_4lupa_5_lupa_10_LuaObject_14__str__(((struct __pyx_obj_4lupa_5_lupa__LuaObject *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_4lupa_5_lupa_10_LuaObject_14__str__(struct __pyx_obj_4lupa_5_lupa__LuaObject *__pyx_v_self) { lua_State *__pyx_v_L; PyObject *__pyx_v_py_string = 0; char const *__pyx_v_s; size_t __pyx_v_size; PyObject *__pyx_v_encoding = 0; PyObject *__pyx_v_old_top = NULL; PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations int __pyx_t_1; lua_State *__pyx_t_2; PyObject *__pyx_t_3 = NULL; int __pyx_t_4; int __pyx_t_5; PyObject *__pyx_t_6 = NULL; PyObject *__pyx_t_7 = NULL; PyObject *__pyx_t_8 = NULL; char const *__pyx_t_9; PyObject *__pyx_t_10 = NULL; PyObject *__pyx_t_11 = NULL; PyObject *__pyx_t_12 = NULL; int __pyx_t_13; char const *__pyx_t_14; PyObject *__pyx_t_15 = NULL; PyObject *__pyx_t_16 = NULL; PyObject *__pyx_t_17 = NULL; int __pyx_t_18; __Pyx_RefNannySetupContext("__str__", 0); /* "lupa/_lupa.pyx":583 * * def __str__(self): * assert self._runtime is not None # <<<<<<<<<<<<<< * cdef lua_State* L = self._state * cdef unicode py_string = None */ #ifndef CYTHON_WITHOUT_ASSERTIONS if (unlikely(!Py_OptimizeFlag)) { __pyx_t_1 = (((PyObject *)__pyx_v_self->_runtime) != Py_None); if (unlikely(!(__pyx_t_1 != 0))) { PyErr_SetNone(PyExc_AssertionError); __PYX_ERR(0, 583, __pyx_L1_error) } } #endif /* "lupa/_lupa.pyx":584 * def __str__(self): * assert self._runtime is not None * cdef lua_State* L = self._state # <<<<<<<<<<<<<< * cdef unicode py_string = None * cdef const char *s */ __pyx_t_2 = __pyx_v_self->_state; __pyx_v_L = __pyx_t_2; /* "lupa/_lupa.pyx":585 * assert self._runtime is not None * cdef lua_State* L = self._state * cdef unicode py_string = None # <<<<<<<<<<<<<< * cdef const char *s * cdef size_t size = 0 */ __Pyx_INCREF(Py_None); __pyx_v_py_string = ((PyObject*)Py_None); /* "lupa/_lupa.pyx":587 * cdef unicode py_string = None * cdef const char *s * cdef size_t size = 0 # <<<<<<<<<<<<<< * cdef bytes encoding = self._runtime._encoding or b'UTF-8' * lock_runtime(self._runtime) */ __pyx_v_size = 0; /* "lupa/_lupa.pyx":588 * cdef const char *s * cdef size_t size = 0 * cdef bytes encoding = self._runtime._encoding or b'UTF-8' # <<<<<<<<<<<<<< * lock_runtime(self._runtime) * old_top = lua.lua_gettop(L) */ __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_v_self->_runtime->_encoding); if (unlikely(__pyx_t_1 < 0)) __PYX_ERR(0, 588, __pyx_L1_error) if (!__pyx_t_1) { } else { __Pyx_INCREF(__pyx_v_self->_runtime->_encoding); __pyx_t_3 = __pyx_v_self->_runtime->_encoding; goto __pyx_L3_bool_binop_done; } __Pyx_INCREF(__pyx_kp_b_UTF_8); __pyx_t_3 = __pyx_kp_b_UTF_8; __pyx_L3_bool_binop_done:; __pyx_v_encoding = ((PyObject*)__pyx_t_3); __pyx_t_3 = 0; /* "lupa/_lupa.pyx":589 * cdef size_t size = 0 * cdef bytes encoding = self._runtime._encoding or b'UTF-8' * lock_runtime(self._runtime) # <<<<<<<<<<<<<< * old_top = lua.lua_gettop(L) * try: */ __pyx_t_3 = ((PyObject *)__pyx_v_self->_runtime); __Pyx_INCREF(__pyx_t_3); __pyx_t_4 = __pyx_f_4lupa_5_lupa_lock_runtime(((struct __pyx_obj_4lupa_5_lupa_LuaRuntime *)__pyx_t_3)); if (unlikely(__pyx_t_4 == ((int)-1))) __PYX_ERR(0, 589, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; /* "lupa/_lupa.pyx":590 * cdef bytes encoding = self._runtime._encoding or b'UTF-8' * lock_runtime(self._runtime) * old_top = lua.lua_gettop(L) # <<<<<<<<<<<<<< * try: * self.push_lua_object() */ __pyx_t_3 = __Pyx_PyInt_From_int(lua_gettop(__pyx_v_L)); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 590, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_v_old_top = __pyx_t_3; __pyx_t_3 = 0; /* "lupa/_lupa.pyx":591 * lock_runtime(self._runtime) * old_top = lua.lua_gettop(L) * try: # <<<<<<<<<<<<<< * self.push_lua_object() * # lookup and call "__tostring" metatable method manually to catch any errors */ /*try:*/ { /* "lupa/_lupa.pyx":592 * old_top = lua.lua_gettop(L) * try: * self.push_lua_object() # <<<<<<<<<<<<<< * # lookup and call "__tostring" metatable method manually to catch any errors * if lua.lua_getmetatable(L, -1): */ __pyx_t_4 = __pyx_f_4lupa_5_lupa_10_LuaObject_push_lua_object(__pyx_v_self); if (unlikely(__pyx_t_4 == ((int)-1))) __PYX_ERR(0, 592, __pyx_L6_error) /* "lupa/_lupa.pyx":594 * self.push_lua_object() * # lookup and call "__tostring" metatable method manually to catch any errors * if lua.lua_getmetatable(L, -1): # <<<<<<<<<<<<<< * lua.lua_pushlstring(L, "__tostring", 10) * lua.lua_rawget(L, -2) */ __pyx_t_1 = (lua_getmetatable(__pyx_v_L, -1) != 0); if (__pyx_t_1) { /* "lupa/_lupa.pyx":595 * # lookup and call "__tostring" metatable method manually to catch any errors * if lua.lua_getmetatable(L, -1): * lua.lua_pushlstring(L, "__tostring", 10) # <<<<<<<<<<<<<< * lua.lua_rawget(L, -2) * if not lua.lua_isnil(L, -1) and lua.lua_pcall(L, 1, 1, 0) == 0: */ lua_pushlstring(__pyx_v_L, ((char *)"__tostring"), 10); /* "lupa/_lupa.pyx":596 * if lua.lua_getmetatable(L, -1): * lua.lua_pushlstring(L, "__tostring", 10) * lua.lua_rawget(L, -2) # <<<<<<<<<<<<<< * if not lua.lua_isnil(L, -1) and lua.lua_pcall(L, 1, 1, 0) == 0: * s = lua.lua_tolstring(L, -1, &size) */ lua_rawget(__pyx_v_L, -2); /* "lupa/_lupa.pyx":597 * lua.lua_pushlstring(L, "__tostring", 10) * lua.lua_rawget(L, -2) * if not lua.lua_isnil(L, -1) and lua.lua_pcall(L, 1, 1, 0) == 0: # <<<<<<<<<<<<<< * s = lua.lua_tolstring(L, -1, &size) * if s: */ __pyx_t_5 = ((!(lua_isnil(__pyx_v_L, -1) != 0)) != 0); if (__pyx_t_5) { } else { __pyx_t_1 = __pyx_t_5; goto __pyx_L10_bool_binop_done; } __pyx_t_5 = ((lua_pcall(__pyx_v_L, 1, 1, 0) == 0) != 0); __pyx_t_1 = __pyx_t_5; __pyx_L10_bool_binop_done:; if (__pyx_t_1) { /* "lupa/_lupa.pyx":598 * lua.lua_rawget(L, -2) * if not lua.lua_isnil(L, -1) and lua.lua_pcall(L, 1, 1, 0) == 0: * s = lua.lua_tolstring(L, -1, &size) # <<<<<<<<<<<<<< * if s: * try: */ __pyx_v_s = lua_tolstring(__pyx_v_L, -1, (&__pyx_v_size)); /* "lupa/_lupa.pyx":599 * if not lua.lua_isnil(L, -1) and lua.lua_pcall(L, 1, 1, 0) == 0: * s = lua.lua_tolstring(L, -1, &size) * if s: # <<<<<<<<<<<<<< * try: * py_string = s[:size].decode(encoding) */ __pyx_t_1 = (__pyx_v_s != 0); if (__pyx_t_1) { /* "lupa/_lupa.pyx":600 * s = lua.lua_tolstring(L, -1, &size) * if s: * try: # <<<<<<<<<<<<<< * py_string = s[:size].decode(encoding) * except UnicodeDecodeError: */ { __Pyx_PyThreadState_declare __Pyx_PyThreadState_assign __Pyx_ExceptionSave(&__pyx_t_6, &__pyx_t_7, &__pyx_t_8); __Pyx_XGOTREF(__pyx_t_6); __Pyx_XGOTREF(__pyx_t_7); __Pyx_XGOTREF(__pyx_t_8); /*try:*/ { /* "lupa/_lupa.pyx":601 * if s: * try: * py_string = s[:size].decode(encoding) # <<<<<<<<<<<<<< * except UnicodeDecodeError: * # safe 'decode' */ if (unlikely(__pyx_v_encoding == Py_None)) { PyErr_SetString(PyExc_TypeError, "expected bytes, NoneType found"); __PYX_ERR(0, 601, __pyx_L13_error) } __pyx_t_9 = __Pyx_PyBytes_AsString(__pyx_v_encoding); if (unlikely((!__pyx_t_9) && PyErr_Occurred())) __PYX_ERR(0, 601, __pyx_L13_error) __pyx_t_3 = __Pyx_decode_c_string(__pyx_v_s, 0, __pyx_v_size, __pyx_t_9, NULL, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 601, __pyx_L13_error) __Pyx_GOTREF(__pyx_t_3); if (!(likely(PyUnicode_CheckExact(__pyx_t_3))||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "unicode", Py_TYPE(__pyx_t_3)->tp_name), 0))) __PYX_ERR(0, 601, __pyx_L13_error) __Pyx_DECREF_SET(__pyx_v_py_string, ((PyObject*)__pyx_t_3)); __pyx_t_3 = 0; /* "lupa/_lupa.pyx":600 * s = lua.lua_tolstring(L, -1, &size) * if s: * try: # <<<<<<<<<<<<<< * py_string = s[:size].decode(encoding) * except UnicodeDecodeError: */ } __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0; __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0; goto __pyx_L18_try_end; __pyx_L13_error:; __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; /* "lupa/_lupa.pyx":602 * try: * py_string = s[:size].decode(encoding) * except UnicodeDecodeError: # <<<<<<<<<<<<<< * # safe 'decode' * py_string = s[:size].decode('ISO-8859-1') */ __pyx_t_4 = __Pyx_PyErr_ExceptionMatches(__pyx_builtin_UnicodeDecodeError); if (__pyx_t_4) { __Pyx_AddTraceback("lupa._lupa._LuaObject.__str__", __pyx_clineno, __pyx_lineno, __pyx_filename); if (__Pyx_GetException(&__pyx_t_3, &__pyx_t_10, &__pyx_t_11) < 0) __PYX_ERR(0, 602, __pyx_L15_except_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_GOTREF(__pyx_t_10); __Pyx_GOTREF(__pyx_t_11); /* "lupa/_lupa.pyx":604 * except UnicodeDecodeError: * # safe 'decode' * py_string = s[:size].decode('ISO-8859-1') # <<<<<<<<<<<<<< * if py_string is None: * lua.lua_settop(L, old_top + 1) */ __pyx_t_12 = __Pyx_decode_c_string(__pyx_v_s, 0, __pyx_v_size, NULL, NULL, PyUnicode_DecodeLatin1); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 604, __pyx_L15_except_error) __Pyx_GOTREF(__pyx_t_12); if (!(likely(PyUnicode_CheckExact(__pyx_t_12))||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "unicode", Py_TYPE(__pyx_t_12)->tp_name), 0))) __PYX_ERR(0, 604, __pyx_L15_except_error) __Pyx_DECREF_SET(__pyx_v_py_string, ((PyObject*)__pyx_t_12)); __pyx_t_12 = 0; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; goto __pyx_L14_exception_handled; } goto __pyx_L15_except_error; __pyx_L15_except_error:; /* "lupa/_lupa.pyx":600 * s = lua.lua_tolstring(L, -1, &size) * if s: * try: # <<<<<<<<<<<<<< * py_string = s[:size].decode(encoding) * except UnicodeDecodeError: */ __Pyx_XGIVEREF(__pyx_t_6); __Pyx_XGIVEREF(__pyx_t_7); __Pyx_XGIVEREF(__pyx_t_8); __Pyx_ExceptionReset(__pyx_t_6, __pyx_t_7, __pyx_t_8); goto __pyx_L6_error; __pyx_L14_exception_handled:; __Pyx_XGIVEREF(__pyx_t_6); __Pyx_XGIVEREF(__pyx_t_7); __Pyx_XGIVEREF(__pyx_t_8); __Pyx_ExceptionReset(__pyx_t_6, __pyx_t_7, __pyx_t_8); __pyx_L18_try_end:; } /* "lupa/_lupa.pyx":599 * if not lua.lua_isnil(L, -1) and lua.lua_pcall(L, 1, 1, 0) == 0: * s = lua.lua_tolstring(L, -1, &size) * if s: # <<<<<<<<<<<<<< * try: * py_string = s[:size].decode(encoding) */ } /* "lupa/_lupa.pyx":597 * lua.lua_pushlstring(L, "__tostring", 10) * lua.lua_rawget(L, -2) * if not lua.lua_isnil(L, -1) and lua.lua_pcall(L, 1, 1, 0) == 0: # <<<<<<<<<<<<<< * s = lua.lua_tolstring(L, -1, &size) * if s: */ } /* "lupa/_lupa.pyx":594 * self.push_lua_object() * # lookup and call "__tostring" metatable method manually to catch any errors * if lua.lua_getmetatable(L, -1): # <<<<<<<<<<<<<< * lua.lua_pushlstring(L, "__tostring", 10) * lua.lua_rawget(L, -2) */ } /* "lupa/_lupa.pyx":605 * # safe 'decode' * py_string = s[:size].decode('ISO-8859-1') * if py_string is None: # <<<<<<<<<<<<<< * lua.lua_settop(L, old_top + 1) * py_string = lua_object_repr(L, encoding) */ __pyx_t_1 = (__pyx_v_py_string == ((PyObject*)Py_None)); __pyx_t_5 = (__pyx_t_1 != 0); if (__pyx_t_5) { /* "lupa/_lupa.pyx":606 * py_string = s[:size].decode('ISO-8859-1') * if py_string is None: * lua.lua_settop(L, old_top + 1) # <<<<<<<<<<<<<< * py_string = lua_object_repr(L, encoding) * finally: */ __pyx_t_11 = __Pyx_PyInt_AddObjC(__pyx_v_old_top, __pyx_int_1, 1, 0); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 606, __pyx_L6_error) __Pyx_GOTREF(__pyx_t_11); __pyx_t_4 = __Pyx_PyInt_As_int(__pyx_t_11); if (unlikely((__pyx_t_4 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 606, __pyx_L6_error) __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; lua_settop(__pyx_v_L, __pyx_t_4); /* "lupa/_lupa.pyx":607 * if py_string is None: * lua.lua_settop(L, old_top + 1) * py_string = lua_object_repr(L, encoding) # <<<<<<<<<<<<<< * finally: * lua.lua_settop(L, old_top) */ __pyx_t_11 = __pyx_f_4lupa_5_lupa_lua_object_repr(__pyx_v_L, __pyx_v_encoding); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 607, __pyx_L6_error) __Pyx_GOTREF(__pyx_t_11); if (!(likely(PyUnicode_CheckExact(__pyx_t_11))||((__pyx_t_11) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "unicode", Py_TYPE(__pyx_t_11)->tp_name), 0))) __PYX_ERR(0, 607, __pyx_L6_error) __Pyx_DECREF_SET(__pyx_v_py_string, ((PyObject*)__pyx_t_11)); __pyx_t_11 = 0; /* "lupa/_lupa.pyx":605 * # safe 'decode' * py_string = s[:size].decode('ISO-8859-1') * if py_string is None: # <<<<<<<<<<<<<< * lua.lua_settop(L, old_top + 1) * py_string = lua_object_repr(L, encoding) */ } } /* "lupa/_lupa.pyx":609 * py_string = lua_object_repr(L, encoding) * finally: * lua.lua_settop(L, old_top) # <<<<<<<<<<<<<< * unlock_runtime(self._runtime) * return py_string */ /*finally:*/ { /*normal exit:*/{ __pyx_t_4 = __Pyx_PyInt_As_int(__pyx_v_old_top); if (unlikely((__pyx_t_4 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 609, __pyx_L1_error) lua_settop(__pyx_v_L, __pyx_t_4); /* "lupa/_lupa.pyx":610 * finally: * lua.lua_settop(L, old_top) * unlock_runtime(self._runtime) # <<<<<<<<<<<<<< * return py_string * */ __pyx_t_11 = ((PyObject *)__pyx_v_self->_runtime); __Pyx_INCREF(__pyx_t_11); __pyx_f_4lupa_5_lupa_unlock_runtime(((struct __pyx_obj_4lupa_5_lupa_LuaRuntime *)__pyx_t_11)); __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; goto __pyx_L7; } __pyx_L6_error:; /*exception exit:*/{ __Pyx_PyThreadState_declare __Pyx_PyThreadState_assign __pyx_t_8 = 0; __pyx_t_7 = 0; __pyx_t_6 = 0; __pyx_t_15 = 0; __pyx_t_16 = 0; __pyx_t_17 = 0; __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0; __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0; __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0; if (PY_MAJOR_VERSION >= 3) __Pyx_ExceptionSwap(&__pyx_t_15, &__pyx_t_16, &__pyx_t_17); if ((PY_MAJOR_VERSION < 3) || unlikely(__Pyx_GetException(&__pyx_t_8, &__pyx_t_7, &__pyx_t_6) < 0)) __Pyx_ErrFetch(&__pyx_t_8, &__pyx_t_7, &__pyx_t_6); __Pyx_XGOTREF(__pyx_t_8); __Pyx_XGOTREF(__pyx_t_7); __Pyx_XGOTREF(__pyx_t_6); __Pyx_XGOTREF(__pyx_t_15); __Pyx_XGOTREF(__pyx_t_16); __Pyx_XGOTREF(__pyx_t_17); __pyx_t_4 = __pyx_lineno; __pyx_t_13 = __pyx_clineno; __pyx_t_14 = __pyx_filename; { /* "lupa/_lupa.pyx":609 * py_string = lua_object_repr(L, encoding) * finally: * lua.lua_settop(L, old_top) # <<<<<<<<<<<<<< * unlock_runtime(self._runtime) * return py_string */ __pyx_t_18 = __Pyx_PyInt_As_int(__pyx_v_old_top); if (unlikely((__pyx_t_18 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 609, __pyx_L23_error) lua_settop(__pyx_v_L, __pyx_t_18); /* "lupa/_lupa.pyx":610 * finally: * lua.lua_settop(L, old_top) * unlock_runtime(self._runtime) # <<<<<<<<<<<<<< * return py_string * */ __pyx_t_11 = ((PyObject *)__pyx_v_self->_runtime); __Pyx_INCREF(__pyx_t_11); __pyx_f_4lupa_5_lupa_unlock_runtime(((struct __pyx_obj_4lupa_5_lupa_LuaRuntime *)__pyx_t_11)); __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; } if (PY_MAJOR_VERSION >= 3) { __Pyx_XGIVEREF(__pyx_t_15); __Pyx_XGIVEREF(__pyx_t_16); __Pyx_XGIVEREF(__pyx_t_17); __Pyx_ExceptionReset(__pyx_t_15, __pyx_t_16, __pyx_t_17); } __Pyx_XGIVEREF(__pyx_t_8); __Pyx_XGIVEREF(__pyx_t_7); __Pyx_XGIVEREF(__pyx_t_6); __Pyx_ErrRestore(__pyx_t_8, __pyx_t_7, __pyx_t_6); __pyx_t_8 = 0; __pyx_t_7 = 0; __pyx_t_6 = 0; __pyx_t_15 = 0; __pyx_t_16 = 0; __pyx_t_17 = 0; __pyx_lineno = __pyx_t_4; __pyx_clineno = __pyx_t_13; __pyx_filename = __pyx_t_14; goto __pyx_L1_error; __pyx_L23_error:; if (PY_MAJOR_VERSION >= 3) { __Pyx_XGIVEREF(__pyx_t_15); __Pyx_XGIVEREF(__pyx_t_16); __Pyx_XGIVEREF(__pyx_t_17); __Pyx_ExceptionReset(__pyx_t_15, __pyx_t_16, __pyx_t_17); } __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0; __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0; __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; __pyx_t_15 = 0; __pyx_t_16 = 0; __pyx_t_17 = 0; goto __pyx_L1_error; } __pyx_L7:; } /* "lupa/_lupa.pyx":611 * lua.lua_settop(L, old_top) * unlock_runtime(self._runtime) * return py_string # <<<<<<<<<<<<<< * * def __getattr__(self, name): */ __Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_v_py_string); __pyx_r = __pyx_v_py_string; goto __pyx_L0; /* "lupa/_lupa.pyx":582 * unlock_runtime(self._runtime) * * def __str__(self): # <<<<<<<<<<<<<< * assert self._runtime is not None * cdef lua_State* L = self._state */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_3); __Pyx_XDECREF(__pyx_t_10); __Pyx_XDECREF(__pyx_t_11); __Pyx_XDECREF(__pyx_t_12); __Pyx_AddTraceback("lupa._lupa._LuaObject.__str__", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XDECREF(__pyx_v_py_string); __Pyx_XDECREF(__pyx_v_encoding); __Pyx_XDECREF(__pyx_v_old_top); __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "lupa/_lupa.pyx":613 * return py_string * * def __getattr__(self, name): # <<<<<<<<<<<<<< * assert self._runtime is not None * if isinstance(name, unicode): */ /* Python wrapper */ static PyObject *__pyx_pw_4lupa_5_lupa_10_LuaObject_17__getattr__(PyObject *__pyx_v_self, PyObject *__pyx_v_name); /*proto*/ static PyObject *__pyx_pw_4lupa_5_lupa_10_LuaObject_17__getattr__(PyObject *__pyx_v_self, PyObject *__pyx_v_name) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__getattr__ (wrapper)", 0); __pyx_r = __pyx_pf_4lupa_5_lupa_10_LuaObject_16__getattr__(((struct __pyx_obj_4lupa_5_lupa__LuaObject *)__pyx_v_self), ((PyObject *)__pyx_v_name)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_4lupa_5_lupa_10_LuaObject_16__getattr__(struct __pyx_obj_4lupa_5_lupa__LuaObject *__pyx_v_self, PyObject *__pyx_v_name) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations int __pyx_t_1; int __pyx_t_2; PyObject *__pyx_t_3 = NULL; PyObject *__pyx_t_4 = NULL; PyObject *__pyx_t_5 = NULL; int __pyx_t_6; PyObject *__pyx_t_7 = NULL; char const *__pyx_t_8; __Pyx_RefNannySetupContext("__getattr__", 0); __Pyx_INCREF(__pyx_v_name); /* "lupa/_lupa.pyx":614 * * def __getattr__(self, name): * assert self._runtime is not None # <<<<<<<<<<<<<< * if isinstance(name, unicode): * if (name).startswith(u'__') and (name).endswith(u'__'): */ #ifndef CYTHON_WITHOUT_ASSERTIONS if (unlikely(!Py_OptimizeFlag)) { __pyx_t_1 = (((PyObject *)__pyx_v_self->_runtime) != Py_None); if (unlikely(!(__pyx_t_1 != 0))) { PyErr_SetNone(PyExc_AssertionError); __PYX_ERR(0, 614, __pyx_L1_error) } } #endif /* "lupa/_lupa.pyx":615 * def __getattr__(self, name): * assert self._runtime is not None * if isinstance(name, unicode): # <<<<<<<<<<<<<< * if (name).startswith(u'__') and (name).endswith(u'__'): * return object.__getattr__(self, name) */ __pyx_t_1 = PyUnicode_Check(__pyx_v_name); __pyx_t_2 = (__pyx_t_1 != 0); if (__pyx_t_2) { /* "lupa/_lupa.pyx":616 * assert self._runtime is not None * if isinstance(name, unicode): * if (name).startswith(u'__') and (name).endswith(u'__'): # <<<<<<<<<<<<<< * return object.__getattr__(self, name) * name = (name).encode(self._runtime._source_encoding) */ if (unlikely(__pyx_v_name == Py_None)) { PyErr_Format(PyExc_AttributeError, "'NoneType' object has no attribute '%.30s'", "startswith"); __PYX_ERR(0, 616, __pyx_L1_error) } __pyx_t_1 = __Pyx_PyUnicode_Tailmatch(((PyObject*)__pyx_v_name), __pyx_n_u__22, 0, PY_SSIZE_T_MAX, -1); if (unlikely(__pyx_t_1 == ((int)-1))) __PYX_ERR(0, 616, __pyx_L1_error) if ((__pyx_t_1 != 0)) { } else { __pyx_t_2 = (__pyx_t_1 != 0); goto __pyx_L5_bool_binop_done; } if (unlikely(__pyx_v_name == Py_None)) { PyErr_Format(PyExc_AttributeError, "'NoneType' object has no attribute '%.30s'", "endswith"); __PYX_ERR(0, 616, __pyx_L1_error) } __pyx_t_1 = __Pyx_PyUnicode_Tailmatch(((PyObject*)__pyx_v_name), __pyx_n_u__22, 0, PY_SSIZE_T_MAX, 1); if (unlikely(__pyx_t_1 == ((int)-1))) __PYX_ERR(0, 616, __pyx_L1_error) __pyx_t_2 = (__pyx_t_1 != 0); __pyx_L5_bool_binop_done:; if (__pyx_t_2) { /* "lupa/_lupa.pyx":617 * if isinstance(name, unicode): * if (name).startswith(u'__') and (name).endswith(u'__'): * return object.__getattr__(self, name) # <<<<<<<<<<<<<< * name = (name).encode(self._runtime._source_encoding) * elif isinstance(name, bytes): */ __Pyx_XDECREF(__pyx_r); __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_builtin_object, __pyx_n_s_getattr); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 617, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_5 = NULL; __pyx_t_6 = 0; if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_4))) { __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_4); if (likely(__pyx_t_5)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4); __Pyx_INCREF(__pyx_t_5); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_4, function); __pyx_t_6 = 1; } } #if CYTHON_FAST_PYCALL if (PyFunction_Check(__pyx_t_4)) { PyObject *__pyx_temp[3] = {__pyx_t_5, ((PyObject *)__pyx_v_self), __pyx_v_name}; __pyx_t_3 = __Pyx_PyFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_6, 2+__pyx_t_6); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 617, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_GOTREF(__pyx_t_3); } else #endif #if CYTHON_FAST_PYCCALL if (__Pyx_PyFastCFunction_Check(__pyx_t_4)) { PyObject *__pyx_temp[3] = {__pyx_t_5, ((PyObject *)__pyx_v_self), __pyx_v_name}; __pyx_t_3 = __Pyx_PyCFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_6, 2+__pyx_t_6); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 617, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_GOTREF(__pyx_t_3); } else #endif { __pyx_t_7 = PyTuple_New(2+__pyx_t_6); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 617, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); if (__pyx_t_5) { __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_5); __pyx_t_5 = NULL; } __Pyx_INCREF(((PyObject *)__pyx_v_self)); __Pyx_GIVEREF(((PyObject *)__pyx_v_self)); PyTuple_SET_ITEM(__pyx_t_7, 0+__pyx_t_6, ((PyObject *)__pyx_v_self)); __Pyx_INCREF(__pyx_v_name); __Pyx_GIVEREF(__pyx_v_name); PyTuple_SET_ITEM(__pyx_t_7, 1+__pyx_t_6, __pyx_v_name); __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_7, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 617, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; } __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_r = __pyx_t_3; __pyx_t_3 = 0; goto __pyx_L0; /* "lupa/_lupa.pyx":616 * assert self._runtime is not None * if isinstance(name, unicode): * if (name).startswith(u'__') and (name).endswith(u'__'): # <<<<<<<<<<<<<< * return object.__getattr__(self, name) * name = (name).encode(self._runtime._source_encoding) */ } /* "lupa/_lupa.pyx":618 * if (name).startswith(u'__') and (name).endswith(u'__'): * return object.__getattr__(self, name) * name = (name).encode(self._runtime._source_encoding) # <<<<<<<<<<<<<< * elif isinstance(name, bytes): * if (name).startswith(b'__') and (name).endswith(b'__'): */ if (unlikely(__pyx_v_name == Py_None)) { PyErr_Format(PyExc_AttributeError, "'NoneType' object has no attribute '%.30s'", "encode"); __PYX_ERR(0, 618, __pyx_L1_error) } if (unlikely(__pyx_v_self->_runtime->_source_encoding == Py_None)) { PyErr_SetString(PyExc_TypeError, "expected bytes, NoneType found"); __PYX_ERR(0, 618, __pyx_L1_error) } __pyx_t_8 = __Pyx_PyBytes_AsString(__pyx_v_self->_runtime->_source_encoding); if (unlikely((!__pyx_t_8) && PyErr_Occurred())) __PYX_ERR(0, 618, __pyx_L1_error) __pyx_t_3 = PyUnicode_AsEncodedString(((PyObject*)__pyx_v_name), __pyx_t_8, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 618, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF_SET(__pyx_v_name, __pyx_t_3); __pyx_t_3 = 0; /* "lupa/_lupa.pyx":615 * def __getattr__(self, name): * assert self._runtime is not None * if isinstance(name, unicode): # <<<<<<<<<<<<<< * if (name).startswith(u'__') and (name).endswith(u'__'): * return object.__getattr__(self, name) */ goto __pyx_L3; } /* "lupa/_lupa.pyx":619 * return object.__getattr__(self, name) * name = (name).encode(self._runtime._source_encoding) * elif isinstance(name, bytes): # <<<<<<<<<<<<<< * if (name).startswith(b'__') and (name).endswith(b'__'): * return object.__getattr__(self, name) */ __pyx_t_2 = PyBytes_Check(__pyx_v_name); __pyx_t_1 = (__pyx_t_2 != 0); if (__pyx_t_1) { /* "lupa/_lupa.pyx":620 * name = (name).encode(self._runtime._source_encoding) * elif isinstance(name, bytes): * if (name).startswith(b'__') and (name).endswith(b'__'): # <<<<<<<<<<<<<< * return object.__getattr__(self, name) * return self._getitem(name, is_attr_access=True) */ if (unlikely(__pyx_v_name == Py_None)) { PyErr_Format(PyExc_AttributeError, "'NoneType' object has no attribute '%.30s'", "startswith"); __PYX_ERR(0, 620, __pyx_L1_error) } __pyx_t_2 = __Pyx_PyBytes_Tailmatch(((PyObject*)__pyx_v_name), __pyx_n_b__22, 0, PY_SSIZE_T_MAX, -1); if (unlikely(__pyx_t_2 == ((int)-1))) __PYX_ERR(0, 620, __pyx_L1_error) if ((__pyx_t_2 != 0)) { } else { __pyx_t_1 = (__pyx_t_2 != 0); goto __pyx_L8_bool_binop_done; } if (unlikely(__pyx_v_name == Py_None)) { PyErr_Format(PyExc_AttributeError, "'NoneType' object has no attribute '%.30s'", "endswith"); __PYX_ERR(0, 620, __pyx_L1_error) } __pyx_t_2 = __Pyx_PyBytes_Tailmatch(((PyObject*)__pyx_v_name), __pyx_n_b__22, 0, PY_SSIZE_T_MAX, 1); if (unlikely(__pyx_t_2 == ((int)-1))) __PYX_ERR(0, 620, __pyx_L1_error) __pyx_t_1 = (__pyx_t_2 != 0); __pyx_L8_bool_binop_done:; if (__pyx_t_1) { /* "lupa/_lupa.pyx":621 * elif isinstance(name, bytes): * if (name).startswith(b'__') and (name).endswith(b'__'): * return object.__getattr__(self, name) # <<<<<<<<<<<<<< * return self._getitem(name, is_attr_access=True) * */ __Pyx_XDECREF(__pyx_r); __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_builtin_object, __pyx_n_s_getattr); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 621, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_7 = NULL; __pyx_t_6 = 0; if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_4))) { __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_4); if (likely(__pyx_t_7)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4); __Pyx_INCREF(__pyx_t_7); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_4, function); __pyx_t_6 = 1; } } #if CYTHON_FAST_PYCALL if (PyFunction_Check(__pyx_t_4)) { PyObject *__pyx_temp[3] = {__pyx_t_7, ((PyObject *)__pyx_v_self), __pyx_v_name}; __pyx_t_3 = __Pyx_PyFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_6, 2+__pyx_t_6); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 621, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0; __Pyx_GOTREF(__pyx_t_3); } else #endif #if CYTHON_FAST_PYCCALL if (__Pyx_PyFastCFunction_Check(__pyx_t_4)) { PyObject *__pyx_temp[3] = {__pyx_t_7, ((PyObject *)__pyx_v_self), __pyx_v_name}; __pyx_t_3 = __Pyx_PyCFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_6, 2+__pyx_t_6); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 621, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0; __Pyx_GOTREF(__pyx_t_3); } else #endif { __pyx_t_5 = PyTuple_New(2+__pyx_t_6); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 621, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); if (__pyx_t_7) { __Pyx_GIVEREF(__pyx_t_7); PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_7); __pyx_t_7 = NULL; } __Pyx_INCREF(((PyObject *)__pyx_v_self)); __Pyx_GIVEREF(((PyObject *)__pyx_v_self)); PyTuple_SET_ITEM(__pyx_t_5, 0+__pyx_t_6, ((PyObject *)__pyx_v_self)); __Pyx_INCREF(__pyx_v_name); __Pyx_GIVEREF(__pyx_v_name); PyTuple_SET_ITEM(__pyx_t_5, 1+__pyx_t_6, __pyx_v_name); __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_5, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 621, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; } __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_r = __pyx_t_3; __pyx_t_3 = 0; goto __pyx_L0; /* "lupa/_lupa.pyx":620 * name = (name).encode(self._runtime._source_encoding) * elif isinstance(name, bytes): * if (name).startswith(b'__') and (name).endswith(b'__'): # <<<<<<<<<<<<<< * return object.__getattr__(self, name) * return self._getitem(name, is_attr_access=True) */ } /* "lupa/_lupa.pyx":619 * return object.__getattr__(self, name) * name = (name).encode(self._runtime._source_encoding) * elif isinstance(name, bytes): # <<<<<<<<<<<<<< * if (name).startswith(b'__') and (name).endswith(b'__'): * return object.__getattr__(self, name) */ } __pyx_L3:; /* "lupa/_lupa.pyx":622 * if (name).startswith(b'__') and (name).endswith(b'__'): * return object.__getattr__(self, name) * return self._getitem(name, is_attr_access=True) # <<<<<<<<<<<<<< * * def __getitem__(self, index_or_name): */ __Pyx_XDECREF(__pyx_r); __pyx_t_3 = __pyx_f_4lupa_5_lupa_10_LuaObject__getitem(__pyx_v_self, __pyx_v_name, 1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 622, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_r = __pyx_t_3; __pyx_t_3 = 0; goto __pyx_L0; /* "lupa/_lupa.pyx":613 * return py_string * * def __getattr__(self, name): # <<<<<<<<<<<<<< * assert self._runtime is not None * if isinstance(name, unicode): */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_3); __Pyx_XDECREF(__pyx_t_4); __Pyx_XDECREF(__pyx_t_5); __Pyx_XDECREF(__pyx_t_7); __Pyx_AddTraceback("lupa._lupa._LuaObject.__getattr__", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XDECREF(__pyx_v_name); __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "lupa/_lupa.pyx":624 * return self._getitem(name, is_attr_access=True) * * def __getitem__(self, index_or_name): # <<<<<<<<<<<<<< * return self._getitem(index_or_name, is_attr_access=False) * */ /* Python wrapper */ static PyObject *__pyx_pw_4lupa_5_lupa_10_LuaObject_19__getitem__(PyObject *__pyx_v_self, PyObject *__pyx_v_index_or_name); /*proto*/ static PyObject *__pyx_pw_4lupa_5_lupa_10_LuaObject_19__getitem__(PyObject *__pyx_v_self, PyObject *__pyx_v_index_or_name) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__getitem__ (wrapper)", 0); __pyx_r = __pyx_pf_4lupa_5_lupa_10_LuaObject_18__getitem__(((struct __pyx_obj_4lupa_5_lupa__LuaObject *)__pyx_v_self), ((PyObject *)__pyx_v_index_or_name)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_4lupa_5_lupa_10_LuaObject_18__getitem__(struct __pyx_obj_4lupa_5_lupa__LuaObject *__pyx_v_self, PyObject *__pyx_v_index_or_name) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; __Pyx_RefNannySetupContext("__getitem__", 0); /* "lupa/_lupa.pyx":625 * * def __getitem__(self, index_or_name): * return self._getitem(index_or_name, is_attr_access=False) # <<<<<<<<<<<<<< * * @cython.final */ __Pyx_XDECREF(__pyx_r); __pyx_t_1 = __pyx_f_4lupa_5_lupa_10_LuaObject__getitem(__pyx_v_self, __pyx_v_index_or_name, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 625, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0; /* "lupa/_lupa.pyx":624 * return self._getitem(name, is_attr_access=True) * * def __getitem__(self, index_or_name): # <<<<<<<<<<<<<< * return self._getitem(index_or_name, is_attr_access=False) * */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_AddTraceback("lupa._lupa._LuaObject.__getitem__", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "lupa/_lupa.pyx":628 * * @cython.final * cdef _getitem(self, name, bint is_attr_access): # <<<<<<<<<<<<<< * cdef lua_State* L = self._state * lock_runtime(self._runtime) */ static PyObject *__pyx_f_4lupa_5_lupa_10_LuaObject__getitem(struct __pyx_obj_4lupa_5_lupa__LuaObject *__pyx_v_self, PyObject *__pyx_v_name, int __pyx_v_is_attr_access) { lua_State *__pyx_v_L; int __pyx_v_old_top; int __pyx_v_lua_type; PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations lua_State *__pyx_t_1; PyObject *__pyx_t_2 = NULL; int __pyx_t_3; PyObject *__pyx_t_4 = NULL; struct __pyx_opt_args_4lupa_5_lupa_py_to_lua __pyx_t_5; int __pyx_t_6; char const *__pyx_t_7; PyObject *__pyx_t_8 = NULL; PyObject *__pyx_t_9 = NULL; PyObject *__pyx_t_10 = NULL; PyObject *__pyx_t_11 = NULL; PyObject *__pyx_t_12 = NULL; PyObject *__pyx_t_13 = NULL; __Pyx_RefNannySetupContext("_getitem", 0); /* "lupa/_lupa.pyx":629 * @cython.final * cdef _getitem(self, name, bint is_attr_access): * cdef lua_State* L = self._state # <<<<<<<<<<<<<< * lock_runtime(self._runtime) * old_top = lua.lua_gettop(L) */ __pyx_t_1 = __pyx_v_self->_state; __pyx_v_L = __pyx_t_1; /* "lupa/_lupa.pyx":630 * cdef _getitem(self, name, bint is_attr_access): * cdef lua_State* L = self._state * lock_runtime(self._runtime) # <<<<<<<<<<<<<< * old_top = lua.lua_gettop(L) * try: */ __pyx_t_2 = ((PyObject *)__pyx_v_self->_runtime); __Pyx_INCREF(__pyx_t_2); __pyx_t_3 = __pyx_f_4lupa_5_lupa_lock_runtime(((struct __pyx_obj_4lupa_5_lupa_LuaRuntime *)__pyx_t_2)); if (unlikely(__pyx_t_3 == ((int)-1))) __PYX_ERR(0, 630, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; /* "lupa/_lupa.pyx":631 * cdef lua_State* L = self._state * lock_runtime(self._runtime) * old_top = lua.lua_gettop(L) # <<<<<<<<<<<<<< * try: * self.push_lua_object() */ __pyx_v_old_top = lua_gettop(__pyx_v_L); /* "lupa/_lupa.pyx":632 * lock_runtime(self._runtime) * old_top = lua.lua_gettop(L) * try: # <<<<<<<<<<<<<< * self.push_lua_object() * lua_type = lua.lua_type(L, -1) */ /*try:*/ { /* "lupa/_lupa.pyx":633 * old_top = lua.lua_gettop(L) * try: * self.push_lua_object() # <<<<<<<<<<<<<< * lua_type = lua.lua_type(L, -1) * if lua_type == lua.LUA_TFUNCTION or lua_type == lua.LUA_TTHREAD: */ __pyx_t_3 = __pyx_f_4lupa_5_lupa_10_LuaObject_push_lua_object(__pyx_v_self); if (unlikely(__pyx_t_3 == ((int)-1))) __PYX_ERR(0, 633, __pyx_L4_error) /* "lupa/_lupa.pyx":634 * try: * self.push_lua_object() * lua_type = lua.lua_type(L, -1) # <<<<<<<<<<<<<< * if lua_type == lua.LUA_TFUNCTION or lua_type == lua.LUA_TTHREAD: * lua.lua_pop(L, 1) */ __pyx_v_lua_type = lua_type(__pyx_v_L, -1); /* "lupa/_lupa.pyx":635 * self.push_lua_object() * lua_type = lua.lua_type(L, -1) * if lua_type == lua.LUA_TFUNCTION or lua_type == lua.LUA_TTHREAD: # <<<<<<<<<<<<<< * lua.lua_pop(L, 1) * raise (AttributeError if is_attr_access else TypeError)( */ switch (__pyx_v_lua_type) { case LUA_TFUNCTION: case LUA_TTHREAD: /* "lupa/_lupa.pyx":636 * lua_type = lua.lua_type(L, -1) * if lua_type == lua.LUA_TFUNCTION or lua_type == lua.LUA_TTHREAD: * lua.lua_pop(L, 1) # <<<<<<<<<<<<<< * raise (AttributeError if is_attr_access else TypeError)( * "item/attribute access not supported on functions") */ lua_pop(__pyx_v_L, 1); /* "lupa/_lupa.pyx":637 * if lua_type == lua.LUA_TFUNCTION or lua_type == lua.LUA_TTHREAD: * lua.lua_pop(L, 1) * raise (AttributeError if is_attr_access else TypeError)( # <<<<<<<<<<<<<< * "item/attribute access not supported on functions") * # table[nil] fails, so map None -> python.none for Lua tables */ if ((__pyx_v_is_attr_access != 0)) { __Pyx_INCREF(__pyx_builtin_AttributeError); __pyx_t_2 = __pyx_builtin_AttributeError; } else { __Pyx_INCREF(__pyx_builtin_TypeError); __pyx_t_2 = __pyx_builtin_TypeError; } __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_tuple__23, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 637, __pyx_L4_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_Raise(__pyx_t_4, 0, 0, 0); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __PYX_ERR(0, 637, __pyx_L4_error) /* "lupa/_lupa.pyx":635 * self.push_lua_object() * lua_type = lua.lua_type(L, -1) * if lua_type == lua.LUA_TFUNCTION or lua_type == lua.LUA_TTHREAD: # <<<<<<<<<<<<<< * lua.lua_pop(L, 1) * raise (AttributeError if is_attr_access else TypeError)( */ break; default: break; } /* "lupa/_lupa.pyx":640 * "item/attribute access not supported on functions") * # table[nil] fails, so map None -> python.none for Lua tables * py_to_lua(self._runtime, L, name, wrap_none=lua_type == lua.LUA_TTABLE) # <<<<<<<<<<<<<< * lua.lua_gettable(L, -2) * return py_from_lua(self._runtime, L, -1) */ __pyx_t_4 = ((PyObject *)__pyx_v_self->_runtime); __Pyx_INCREF(__pyx_t_4); __pyx_t_5.__pyx_n = 1; __pyx_t_5.wrap_none = (__pyx_v_lua_type == LUA_TTABLE); __pyx_t_3 = __pyx_f_4lupa_5_lupa_py_to_lua(((struct __pyx_obj_4lupa_5_lupa_LuaRuntime *)__pyx_t_4), __pyx_v_L, __pyx_v_name, &__pyx_t_5); if (unlikely(__pyx_t_3 == ((int)-1))) __PYX_ERR(0, 640, __pyx_L4_error) __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; /* "lupa/_lupa.pyx":641 * # table[nil] fails, so map None -> python.none for Lua tables * py_to_lua(self._runtime, L, name, wrap_none=lua_type == lua.LUA_TTABLE) * lua.lua_gettable(L, -2) # <<<<<<<<<<<<<< * return py_from_lua(self._runtime, L, -1) * finally: */ lua_gettable(__pyx_v_L, -2); /* "lupa/_lupa.pyx":642 * py_to_lua(self._runtime, L, name, wrap_none=lua_type == lua.LUA_TTABLE) * lua.lua_gettable(L, -2) * return py_from_lua(self._runtime, L, -1) # <<<<<<<<<<<<<< * finally: * lua.lua_settop(L, old_top) */ __Pyx_XDECREF(__pyx_r); __pyx_t_4 = ((PyObject *)__pyx_v_self->_runtime); __Pyx_INCREF(__pyx_t_4); __pyx_t_2 = __pyx_f_4lupa_5_lupa_py_from_lua(((struct __pyx_obj_4lupa_5_lupa_LuaRuntime *)__pyx_t_4), __pyx_v_L, -1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 642, __pyx_L4_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_r = __pyx_t_2; __pyx_t_2 = 0; goto __pyx_L3_return; } /* "lupa/_lupa.pyx":644 * return py_from_lua(self._runtime, L, -1) * finally: * lua.lua_settop(L, old_top) # <<<<<<<<<<<<<< * unlock_runtime(self._runtime) * */ /*finally:*/ { __pyx_L4_error:; /*exception exit:*/{ __Pyx_PyThreadState_declare __Pyx_PyThreadState_assign __pyx_t_8 = 0; __pyx_t_9 = 0; __pyx_t_10 = 0; __pyx_t_11 = 0; __pyx_t_12 = 0; __pyx_t_13 = 0; __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; if (PY_MAJOR_VERSION >= 3) __Pyx_ExceptionSwap(&__pyx_t_11, &__pyx_t_12, &__pyx_t_13); if ((PY_MAJOR_VERSION < 3) || unlikely(__Pyx_GetException(&__pyx_t_8, &__pyx_t_9, &__pyx_t_10) < 0)) __Pyx_ErrFetch(&__pyx_t_8, &__pyx_t_9, &__pyx_t_10); __Pyx_XGOTREF(__pyx_t_8); __Pyx_XGOTREF(__pyx_t_9); __Pyx_XGOTREF(__pyx_t_10); __Pyx_XGOTREF(__pyx_t_11); __Pyx_XGOTREF(__pyx_t_12); __Pyx_XGOTREF(__pyx_t_13); __pyx_t_3 = __pyx_lineno; __pyx_t_6 = __pyx_clineno; __pyx_t_7 = __pyx_filename; { lua_settop(__pyx_v_L, __pyx_v_old_top); /* "lupa/_lupa.pyx":645 * finally: * lua.lua_settop(L, old_top) * unlock_runtime(self._runtime) # <<<<<<<<<<<<<< * * */ __pyx_t_2 = ((PyObject *)__pyx_v_self->_runtime); __Pyx_INCREF(__pyx_t_2); __pyx_f_4lupa_5_lupa_unlock_runtime(((struct __pyx_obj_4lupa_5_lupa_LuaRuntime *)__pyx_t_2)); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; } if (PY_MAJOR_VERSION >= 3) { __Pyx_XGIVEREF(__pyx_t_11); __Pyx_XGIVEREF(__pyx_t_12); __Pyx_XGIVEREF(__pyx_t_13); __Pyx_ExceptionReset(__pyx_t_11, __pyx_t_12, __pyx_t_13); } __Pyx_XGIVEREF(__pyx_t_8); __Pyx_XGIVEREF(__pyx_t_9); __Pyx_XGIVEREF(__pyx_t_10); __Pyx_ErrRestore(__pyx_t_8, __pyx_t_9, __pyx_t_10); __pyx_t_8 = 0; __pyx_t_9 = 0; __pyx_t_10 = 0; __pyx_t_11 = 0; __pyx_t_12 = 0; __pyx_t_13 = 0; __pyx_lineno = __pyx_t_3; __pyx_clineno = __pyx_t_6; __pyx_filename = __pyx_t_7; goto __pyx_L1_error; } __pyx_L3_return: { __pyx_t_13 = __pyx_r; __pyx_r = 0; /* "lupa/_lupa.pyx":644 * return py_from_lua(self._runtime, L, -1) * finally: * lua.lua_settop(L, old_top) # <<<<<<<<<<<<<< * unlock_runtime(self._runtime) * */ lua_settop(__pyx_v_L, __pyx_v_old_top); /* "lupa/_lupa.pyx":645 * finally: * lua.lua_settop(L, old_top) * unlock_runtime(self._runtime) # <<<<<<<<<<<<<< * * */ __pyx_t_2 = ((PyObject *)__pyx_v_self->_runtime); __Pyx_INCREF(__pyx_t_2); __pyx_f_4lupa_5_lupa_unlock_runtime(((struct __pyx_obj_4lupa_5_lupa_LuaRuntime *)__pyx_t_2)); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_r = __pyx_t_13; __pyx_t_13 = 0; goto __pyx_L0; } } /* "lupa/_lupa.pyx":628 * * @cython.final * cdef _getitem(self, name, bint is_attr_access): # <<<<<<<<<<<<<< * cdef lua_State* L = self._state * lock_runtime(self._runtime) */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_2); __Pyx_XDECREF(__pyx_t_4); __Pyx_AddTraceback("lupa._lupa._LuaObject._getitem", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = 0; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "(tree fragment)":1 * def __reduce_cython__(self): # <<<<<<<<<<<<<< * raise TypeError("self._state cannot be converted to a Python object for pickling") * def __setstate_cython__(self, __pyx_state): */ /* Python wrapper */ static PyObject *__pyx_pw_4lupa_5_lupa_10_LuaObject_21__reduce_cython__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ static char __pyx_doc_4lupa_5_lupa_10_LuaObject_20__reduce_cython__[] = "_LuaObject.__reduce_cython__(self)"; static PyMethodDef __pyx_mdef_4lupa_5_lupa_10_LuaObject_21__reduce_cython__ = {"__reduce_cython__", (PyCFunction)__pyx_pw_4lupa_5_lupa_10_LuaObject_21__reduce_cython__, METH_NOARGS, __pyx_doc_4lupa_5_lupa_10_LuaObject_20__reduce_cython__}; static PyObject *__pyx_pw_4lupa_5_lupa_10_LuaObject_21__reduce_cython__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__reduce_cython__ (wrapper)", 0); __pyx_r = __pyx_pf_4lupa_5_lupa_10_LuaObject_20__reduce_cython__(((struct __pyx_obj_4lupa_5_lupa__LuaObject *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_4lupa_5_lupa_10_LuaObject_20__reduce_cython__(CYTHON_UNUSED struct __pyx_obj_4lupa_5_lupa__LuaObject *__pyx_v_self) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; __Pyx_RefNannySetupContext("__reduce_cython__", 0); /* "(tree fragment)":2 * def __reduce_cython__(self): * raise TypeError("self._state cannot be converted to a Python object for pickling") # <<<<<<<<<<<<<< * def __setstate_cython__(self, __pyx_state): * raise TypeError("self._state cannot be converted to a Python object for pickling") */ __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__24, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 2, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_Raise(__pyx_t_1, 0, 0, 0); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __PYX_ERR(2, 2, __pyx_L1_error) /* "(tree fragment)":1 * def __reduce_cython__(self): # <<<<<<<<<<<<<< * raise TypeError("self._state cannot be converted to a Python object for pickling") * def __setstate_cython__(self, __pyx_state): */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_AddTraceback("lupa._lupa._LuaObject.__reduce_cython__", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "(tree fragment)":3 * def __reduce_cython__(self): * raise TypeError("self._state cannot be converted to a Python object for pickling") * def __setstate_cython__(self, __pyx_state): # <<<<<<<<<<<<<< * raise TypeError("self._state cannot be converted to a Python object for pickling") */ /* Python wrapper */ static PyObject *__pyx_pw_4lupa_5_lupa_10_LuaObject_23__setstate_cython__(PyObject *__pyx_v_self, PyObject *__pyx_v___pyx_state); /*proto*/ static char __pyx_doc_4lupa_5_lupa_10_LuaObject_22__setstate_cython__[] = "_LuaObject.__setstate_cython__(self, __pyx_state)"; static PyMethodDef __pyx_mdef_4lupa_5_lupa_10_LuaObject_23__setstate_cython__ = {"__setstate_cython__", (PyCFunction)__pyx_pw_4lupa_5_lupa_10_LuaObject_23__setstate_cython__, METH_O, __pyx_doc_4lupa_5_lupa_10_LuaObject_22__setstate_cython__}; static PyObject *__pyx_pw_4lupa_5_lupa_10_LuaObject_23__setstate_cython__(PyObject *__pyx_v_self, PyObject *__pyx_v___pyx_state) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__setstate_cython__ (wrapper)", 0); __pyx_r = __pyx_pf_4lupa_5_lupa_10_LuaObject_22__setstate_cython__(((struct __pyx_obj_4lupa_5_lupa__LuaObject *)__pyx_v_self), ((PyObject *)__pyx_v___pyx_state)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_4lupa_5_lupa_10_LuaObject_22__setstate_cython__(CYTHON_UNUSED struct __pyx_obj_4lupa_5_lupa__LuaObject *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v___pyx_state) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; __Pyx_RefNannySetupContext("__setstate_cython__", 0); /* "(tree fragment)":4 * raise TypeError("self._state cannot be converted to a Python object for pickling") * def __setstate_cython__(self, __pyx_state): * raise TypeError("self._state cannot be converted to a Python object for pickling") # <<<<<<<<<<<<<< */ __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__25, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 4, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_Raise(__pyx_t_1, 0, 0, 0); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __PYX_ERR(2, 4, __pyx_L1_error) /* "(tree fragment)":3 * def __reduce_cython__(self): * raise TypeError("self._state cannot be converted to a Python object for pickling") * def __setstate_cython__(self, __pyx_state): # <<<<<<<<<<<<<< * raise TypeError("self._state cannot be converted to a Python object for pickling") */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_AddTraceback("lupa._lupa._LuaObject.__setstate_cython__", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "lupa/_lupa.pyx":648 * * * cdef _LuaObject new_lua_object(LuaRuntime runtime, lua_State* L, int n): # <<<<<<<<<<<<<< * cdef _LuaObject obj = _LuaObject.__new__(_LuaObject) * init_lua_object(obj, runtime, L, n) */ static struct __pyx_obj_4lupa_5_lupa__LuaObject *__pyx_f_4lupa_5_lupa_new_lua_object(struct __pyx_obj_4lupa_5_lupa_LuaRuntime *__pyx_v_runtime, lua_State *__pyx_v_L, int __pyx_v_n) { struct __pyx_obj_4lupa_5_lupa__LuaObject *__pyx_v_obj = 0; struct __pyx_obj_4lupa_5_lupa__LuaObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; __Pyx_RefNannySetupContext("new_lua_object", 0); /* "lupa/_lupa.pyx":649 * * cdef _LuaObject new_lua_object(LuaRuntime runtime, lua_State* L, int n): * cdef _LuaObject obj = _LuaObject.__new__(_LuaObject) # <<<<<<<<<<<<<< * init_lua_object(obj, runtime, L, n) * return obj */ __pyx_t_1 = __pyx_tp_new_4lupa_5_lupa__LuaObject(((PyTypeObject *)__pyx_ptype_4lupa_5_lupa__LuaObject), __pyx_empty_tuple, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 649, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); if (!(likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_4lupa_5_lupa__LuaObject)))) __PYX_ERR(0, 649, __pyx_L1_error) __pyx_v_obj = ((struct __pyx_obj_4lupa_5_lupa__LuaObject *)__pyx_t_1); __pyx_t_1 = 0; /* "lupa/_lupa.pyx":650 * cdef _LuaObject new_lua_object(LuaRuntime runtime, lua_State* L, int n): * cdef _LuaObject obj = _LuaObject.__new__(_LuaObject) * init_lua_object(obj, runtime, L, n) # <<<<<<<<<<<<<< * return obj * */ __pyx_f_4lupa_5_lupa_init_lua_object(__pyx_v_obj, __pyx_v_runtime, __pyx_v_L, __pyx_v_n); /* "lupa/_lupa.pyx":651 * cdef _LuaObject obj = _LuaObject.__new__(_LuaObject) * init_lua_object(obj, runtime, L, n) * return obj # <<<<<<<<<<<<<< * * cdef void init_lua_object(_LuaObject obj, LuaRuntime runtime, lua_State* L, int n): */ __Pyx_XDECREF(((PyObject *)__pyx_r)); __Pyx_INCREF(((PyObject *)__pyx_v_obj)); __pyx_r = __pyx_v_obj; goto __pyx_L0; /* "lupa/_lupa.pyx":648 * * * cdef _LuaObject new_lua_object(LuaRuntime runtime, lua_State* L, int n): # <<<<<<<<<<<<<< * cdef _LuaObject obj = _LuaObject.__new__(_LuaObject) * init_lua_object(obj, runtime, L, n) */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_AddTraceback("lupa._lupa.new_lua_object", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = 0; __pyx_L0:; __Pyx_XDECREF((PyObject *)__pyx_v_obj); __Pyx_XGIVEREF((PyObject *)__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "lupa/_lupa.pyx":653 * return obj * * cdef void init_lua_object(_LuaObject obj, LuaRuntime runtime, lua_State* L, int n): # <<<<<<<<<<<<<< * obj._runtime = runtime * obj._state = L */ static void __pyx_f_4lupa_5_lupa_init_lua_object(struct __pyx_obj_4lupa_5_lupa__LuaObject *__pyx_v_obj, struct __pyx_obj_4lupa_5_lupa_LuaRuntime *__pyx_v_runtime, lua_State *__pyx_v_L, int __pyx_v_n) { __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("init_lua_object", 0); /* "lupa/_lupa.pyx":654 * * cdef void init_lua_object(_LuaObject obj, LuaRuntime runtime, lua_State* L, int n): * obj._runtime = runtime # <<<<<<<<<<<<<< * obj._state = L * lua.lua_pushvalue(L, n) */ __Pyx_INCREF(((PyObject *)__pyx_v_runtime)); __Pyx_GIVEREF(((PyObject *)__pyx_v_runtime)); __Pyx_GOTREF(__pyx_v_obj->_runtime); __Pyx_DECREF(((PyObject *)__pyx_v_obj->_runtime)); __pyx_v_obj->_runtime = __pyx_v_runtime; /* "lupa/_lupa.pyx":655 * cdef void init_lua_object(_LuaObject obj, LuaRuntime runtime, lua_State* L, int n): * obj._runtime = runtime * obj._state = L # <<<<<<<<<<<<<< * lua.lua_pushvalue(L, n) * obj._ref = lua.luaL_ref(L, lua.LUA_REGISTRYINDEX) */ __pyx_v_obj->_state = __pyx_v_L; /* "lupa/_lupa.pyx":656 * obj._runtime = runtime * obj._state = L * lua.lua_pushvalue(L, n) # <<<<<<<<<<<<<< * obj._ref = lua.luaL_ref(L, lua.LUA_REGISTRYINDEX) * */ lua_pushvalue(__pyx_v_L, __pyx_v_n); /* "lupa/_lupa.pyx":657 * obj._state = L * lua.lua_pushvalue(L, n) * obj._ref = lua.luaL_ref(L, lua.LUA_REGISTRYINDEX) # <<<<<<<<<<<<<< * * cdef object lua_object_repr(lua_State* L, bytes encoding): */ __pyx_v_obj->_ref = luaL_ref(__pyx_v_L, LUA_REGISTRYINDEX); /* "lupa/_lupa.pyx":653 * return obj * * cdef void init_lua_object(_LuaObject obj, LuaRuntime runtime, lua_State* L, int n): # <<<<<<<<<<<<<< * obj._runtime = runtime * obj._state = L */ /* function exit code */ __Pyx_RefNannyFinishContext(); } /* "lupa/_lupa.pyx":659 * obj._ref = lua.luaL_ref(L, lua.LUA_REGISTRYINDEX) * * cdef object lua_object_repr(lua_State* L, bytes encoding): # <<<<<<<<<<<<<< * cdef bytes py_bytes * lua_type = lua.lua_type(L, -1) */ static PyObject *__pyx_f_4lupa_5_lupa_lua_object_repr(lua_State *__pyx_v_L, PyObject *__pyx_v_encoding) { PyObject *__pyx_v_py_bytes = 0; int __pyx_v_lua_type; void *__pyx_v_ptr; PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations int __pyx_t_1; PyObject *__pyx_t_2 = NULL; PyObject *__pyx_t_3 = NULL; PyObject *__pyx_t_4 = NULL; PyObject *__pyx_t_5 = NULL; char const *__pyx_t_6; int __pyx_t_7; PyObject *__pyx_t_8 = NULL; PyObject *__pyx_t_9 = NULL; PyObject *__pyx_t_10 = NULL; __Pyx_RefNannySetupContext("lua_object_repr", 0); /* "lupa/_lupa.pyx":661 * cdef object lua_object_repr(lua_State* L, bytes encoding): * cdef bytes py_bytes * lua_type = lua.lua_type(L, -1) # <<<<<<<<<<<<<< * if lua_type in (lua.LUA_TTABLE, lua.LUA_TFUNCTION): * ptr = lua.lua_topointer(L, -1) */ __pyx_v_lua_type = lua_type(__pyx_v_L, -1); /* "lupa/_lupa.pyx":662 * cdef bytes py_bytes * lua_type = lua.lua_type(L, -1) * if lua_type in (lua.LUA_TTABLE, lua.LUA_TFUNCTION): # <<<<<<<<<<<<<< * ptr = lua.lua_topointer(L, -1) * elif lua_type in (lua.LUA_TUSERDATA, lua.LUA_TLIGHTUSERDATA): */ switch (__pyx_v_lua_type) { case LUA_TTABLE: case LUA_TFUNCTION: /* "lupa/_lupa.pyx":663 * lua_type = lua.lua_type(L, -1) * if lua_type in (lua.LUA_TTABLE, lua.LUA_TFUNCTION): * ptr = lua.lua_topointer(L, -1) # <<<<<<<<<<<<<< * elif lua_type in (lua.LUA_TUSERDATA, lua.LUA_TLIGHTUSERDATA): * ptr = lua.lua_touserdata(L, -1) */ __pyx_v_ptr = ((void *)lua_topointer(__pyx_v_L, -1)); /* "lupa/_lupa.pyx":662 * cdef bytes py_bytes * lua_type = lua.lua_type(L, -1) * if lua_type in (lua.LUA_TTABLE, lua.LUA_TFUNCTION): # <<<<<<<<<<<<<< * ptr = lua.lua_topointer(L, -1) * elif lua_type in (lua.LUA_TUSERDATA, lua.LUA_TLIGHTUSERDATA): */ break; /* "lupa/_lupa.pyx":664 * if lua_type in (lua.LUA_TTABLE, lua.LUA_TFUNCTION): * ptr = lua.lua_topointer(L, -1) * elif lua_type in (lua.LUA_TUSERDATA, lua.LUA_TLIGHTUSERDATA): # <<<<<<<<<<<<<< * ptr = lua.lua_touserdata(L, -1) * elif lua_type == lua.LUA_TTHREAD: */ case LUA_TUSERDATA: case LUA_TLIGHTUSERDATA: /* "lupa/_lupa.pyx":665 * ptr = lua.lua_topointer(L, -1) * elif lua_type in (lua.LUA_TUSERDATA, lua.LUA_TLIGHTUSERDATA): * ptr = lua.lua_touserdata(L, -1) # <<<<<<<<<<<<<< * elif lua_type == lua.LUA_TTHREAD: * ptr = lua.lua_tothread(L, -1) */ __pyx_v_ptr = ((void *)lua_touserdata(__pyx_v_L, -1)); /* "lupa/_lupa.pyx":664 * if lua_type in (lua.LUA_TTABLE, lua.LUA_TFUNCTION): * ptr = lua.lua_topointer(L, -1) * elif lua_type in (lua.LUA_TUSERDATA, lua.LUA_TLIGHTUSERDATA): # <<<<<<<<<<<<<< * ptr = lua.lua_touserdata(L, -1) * elif lua_type == lua.LUA_TTHREAD: */ break; /* "lupa/_lupa.pyx":666 * elif lua_type in (lua.LUA_TUSERDATA, lua.LUA_TLIGHTUSERDATA): * ptr = lua.lua_touserdata(L, -1) * elif lua_type == lua.LUA_TTHREAD: # <<<<<<<<<<<<<< * ptr = lua.lua_tothread(L, -1) * else: */ case LUA_TTHREAD: /* "lupa/_lupa.pyx":667 * ptr = lua.lua_touserdata(L, -1) * elif lua_type == lua.LUA_TTHREAD: * ptr = lua.lua_tothread(L, -1) # <<<<<<<<<<<<<< * else: * ptr = NULL */ __pyx_v_ptr = ((void *)lua_tothread(__pyx_v_L, -1)); /* "lupa/_lupa.pyx":666 * elif lua_type in (lua.LUA_TUSERDATA, lua.LUA_TLIGHTUSERDATA): * ptr = lua.lua_touserdata(L, -1) * elif lua_type == lua.LUA_TTHREAD: # <<<<<<<<<<<<<< * ptr = lua.lua_tothread(L, -1) * else: */ break; default: /* "lupa/_lupa.pyx":669 * ptr = lua.lua_tothread(L, -1) * else: * ptr = NULL # <<<<<<<<<<<<<< * if ptr: * py_bytes = PyBytes_FromFormat( */ __pyx_v_ptr = NULL; break; } /* "lupa/_lupa.pyx":670 * else: * ptr = NULL * if ptr: # <<<<<<<<<<<<<< * py_bytes = PyBytes_FromFormat( * "", lua.lua_typename(L, lua_type), ptr) */ __pyx_t_1 = (__pyx_v_ptr != 0); if (__pyx_t_1) { /* "lupa/_lupa.pyx":671 * ptr = NULL * if ptr: * py_bytes = PyBytes_FromFormat( # <<<<<<<<<<<<<< * "", lua.lua_typename(L, lua_type), ptr) * else: */ __pyx_t_2 = PyBytes_FromFormat(((char *)""), lua_typename(__pyx_v_L, __pyx_v_lua_type), __pyx_v_ptr); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 671, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_v_py_bytes = ((PyObject*)__pyx_t_2); __pyx_t_2 = 0; /* "lupa/_lupa.pyx":670 * else: * ptr = NULL * if ptr: # <<<<<<<<<<<<<< * py_bytes = PyBytes_FromFormat( * "", lua.lua_typename(L, lua_type), ptr) */ goto __pyx_L3; } /* "lupa/_lupa.pyx":674 * "", lua.lua_typename(L, lua_type), ptr) * else: * py_bytes = PyBytes_FromFormat( # <<<<<<<<<<<<<< * "", lua.lua_typename(L, lua_type)) * try: */ /*else*/ { /* "lupa/_lupa.pyx":675 * else: * py_bytes = PyBytes_FromFormat( * "", lua.lua_typename(L, lua_type)) # <<<<<<<<<<<<<< * try: * return py_bytes.decode(encoding) */ __pyx_t_2 = PyBytes_FromFormat(((char *)""), lua_typename(__pyx_v_L, __pyx_v_lua_type)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 674, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_v_py_bytes = ((PyObject*)__pyx_t_2); __pyx_t_2 = 0; } __pyx_L3:; /* "lupa/_lupa.pyx":676 * py_bytes = PyBytes_FromFormat( * "", lua.lua_typename(L, lua_type)) * try: # <<<<<<<<<<<<<< * return py_bytes.decode(encoding) * except UnicodeDecodeError: */ { __Pyx_PyThreadState_declare __Pyx_PyThreadState_assign __Pyx_ExceptionSave(&__pyx_t_3, &__pyx_t_4, &__pyx_t_5); __Pyx_XGOTREF(__pyx_t_3); __Pyx_XGOTREF(__pyx_t_4); __Pyx_XGOTREF(__pyx_t_5); /*try:*/ { /* "lupa/_lupa.pyx":677 * "", lua.lua_typename(L, lua_type)) * try: * return py_bytes.decode(encoding) # <<<<<<<<<<<<<< * except UnicodeDecodeError: * # safe 'decode' */ __Pyx_XDECREF(__pyx_r); if (unlikely(__pyx_v_py_bytes == Py_None)) { PyErr_Format(PyExc_AttributeError, "'NoneType' object has no attribute '%.30s'", "decode"); __PYX_ERR(0, 677, __pyx_L4_error) } if (unlikely(__pyx_v_encoding == Py_None)) { PyErr_SetString(PyExc_TypeError, "expected bytes, NoneType found"); __PYX_ERR(0, 677, __pyx_L4_error) } __pyx_t_6 = __Pyx_PyBytes_AsString(__pyx_v_encoding); if (unlikely((!__pyx_t_6) && PyErr_Occurred())) __PYX_ERR(0, 677, __pyx_L4_error) __pyx_t_2 = __Pyx_decode_bytes(__pyx_v_py_bytes, 0, PY_SSIZE_T_MAX, __pyx_t_6, NULL, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 677, __pyx_L4_error) __Pyx_GOTREF(__pyx_t_2); __pyx_r = __pyx_t_2; __pyx_t_2 = 0; goto __pyx_L8_try_return; /* "lupa/_lupa.pyx":676 * py_bytes = PyBytes_FromFormat( * "", lua.lua_typename(L, lua_type)) * try: # <<<<<<<<<<<<<< * return py_bytes.decode(encoding) * except UnicodeDecodeError: */ } __pyx_L4_error:; __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; /* "lupa/_lupa.pyx":678 * try: * return py_bytes.decode(encoding) * except UnicodeDecodeError: # <<<<<<<<<<<<<< * # safe 'decode' * return py_bytes.decode('ISO-8859-1') */ __pyx_t_7 = __Pyx_PyErr_ExceptionMatches(__pyx_builtin_UnicodeDecodeError); if (__pyx_t_7) { __Pyx_AddTraceback("lupa._lupa.lua_object_repr", __pyx_clineno, __pyx_lineno, __pyx_filename); if (__Pyx_GetException(&__pyx_t_2, &__pyx_t_8, &__pyx_t_9) < 0) __PYX_ERR(0, 678, __pyx_L6_except_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_GOTREF(__pyx_t_8); __Pyx_GOTREF(__pyx_t_9); /* "lupa/_lupa.pyx":680 * except UnicodeDecodeError: * # safe 'decode' * return py_bytes.decode('ISO-8859-1') # <<<<<<<<<<<<<< * * */ __Pyx_XDECREF(__pyx_r); if (unlikely(__pyx_v_py_bytes == Py_None)) { PyErr_Format(PyExc_AttributeError, "'NoneType' object has no attribute '%.30s'", "decode"); __PYX_ERR(0, 680, __pyx_L6_except_error) } __pyx_t_10 = __Pyx_decode_bytes(__pyx_v_py_bytes, 0, PY_SSIZE_T_MAX, NULL, NULL, PyUnicode_DecodeLatin1); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 680, __pyx_L6_except_error) __Pyx_GOTREF(__pyx_t_10); __pyx_r = __pyx_t_10; __pyx_t_10 = 0; __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; goto __pyx_L7_except_return; } goto __pyx_L6_except_error; __pyx_L6_except_error:; /* "lupa/_lupa.pyx":676 * py_bytes = PyBytes_FromFormat( * "", lua.lua_typename(L, lua_type)) * try: # <<<<<<<<<<<<<< * return py_bytes.decode(encoding) * except UnicodeDecodeError: */ __Pyx_XGIVEREF(__pyx_t_3); __Pyx_XGIVEREF(__pyx_t_4); __Pyx_XGIVEREF(__pyx_t_5); __Pyx_ExceptionReset(__pyx_t_3, __pyx_t_4, __pyx_t_5); goto __pyx_L1_error; __pyx_L8_try_return:; __Pyx_XGIVEREF(__pyx_t_3); __Pyx_XGIVEREF(__pyx_t_4); __Pyx_XGIVEREF(__pyx_t_5); __Pyx_ExceptionReset(__pyx_t_3, __pyx_t_4, __pyx_t_5); goto __pyx_L0; __pyx_L7_except_return:; __Pyx_XGIVEREF(__pyx_t_3); __Pyx_XGIVEREF(__pyx_t_4); __Pyx_XGIVEREF(__pyx_t_5); __Pyx_ExceptionReset(__pyx_t_3, __pyx_t_4, __pyx_t_5); goto __pyx_L0; } /* "lupa/_lupa.pyx":659 * obj._ref = lua.luaL_ref(L, lua.LUA_REGISTRYINDEX) * * cdef object lua_object_repr(lua_State* L, bytes encoding): # <<<<<<<<<<<<<< * cdef bytes py_bytes * lua_type = lua.lua_type(L, -1) */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_2); __Pyx_XDECREF(__pyx_t_8); __Pyx_XDECREF(__pyx_t_9); __Pyx_XDECREF(__pyx_t_10); __Pyx_AddTraceback("lupa._lupa.lua_object_repr", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = 0; __pyx_L0:; __Pyx_XDECREF(__pyx_v_py_bytes); __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "lupa/_lupa.pyx":687 * @cython.no_gc_clear * cdef class _LuaTable(_LuaObject): * def __iter__(self): # <<<<<<<<<<<<<< * return _LuaIter(self, KEYS) * */ /* Python wrapper */ static PyObject *__pyx_pw_4lupa_5_lupa_9_LuaTable_1__iter__(PyObject *__pyx_v_self); /*proto*/ static PyObject *__pyx_pw_4lupa_5_lupa_9_LuaTable_1__iter__(PyObject *__pyx_v_self) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__iter__ (wrapper)", 0); __pyx_r = __pyx_pf_4lupa_5_lupa_9_LuaTable___iter__(((struct __pyx_obj_4lupa_5_lupa__LuaTable *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_4lupa_5_lupa_9_LuaTable___iter__(struct __pyx_obj_4lupa_5_lupa__LuaTable *__pyx_v_self) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; PyObject *__pyx_t_2 = NULL; __Pyx_RefNannySetupContext("__iter__", 0); /* "lupa/_lupa.pyx":688 * cdef class _LuaTable(_LuaObject): * def __iter__(self): * return _LuaIter(self, KEYS) # <<<<<<<<<<<<<< * * def keys(self): */ __Pyx_XDECREF(__pyx_r); __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_e_4lupa_5_lupa_KEYS); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 688, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 688, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_INCREF(((PyObject *)__pyx_v_self)); __Pyx_GIVEREF(((PyObject *)__pyx_v_self)); PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_v_self)); __Pyx_GIVEREF(__pyx_t_1); PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_t_1); __pyx_t_1 = 0; __pyx_t_1 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_4lupa_5_lupa__LuaIter), __pyx_t_2, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 688, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0; /* "lupa/_lupa.pyx":687 * @cython.no_gc_clear * cdef class _LuaTable(_LuaObject): * def __iter__(self): # <<<<<<<<<<<<<< * return _LuaIter(self, KEYS) * */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_2); __Pyx_AddTraceback("lupa._lupa._LuaTable.__iter__", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "lupa/_lupa.pyx":690 * return _LuaIter(self, KEYS) * * def keys(self): # <<<<<<<<<<<<<< * """Returns an iterator over the keys of a table that this * object represents. Same as iter(obj). */ /* Python wrapper */ static PyObject *__pyx_pw_4lupa_5_lupa_9_LuaTable_3keys(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ static char __pyx_doc_4lupa_5_lupa_9_LuaTable_2keys[] = "_LuaTable.keys(self)\nReturns an iterator over the keys of a table that this\n object represents. Same as iter(obj).\n "; static PyMethodDef __pyx_mdef_4lupa_5_lupa_9_LuaTable_3keys = {"keys", (PyCFunction)__pyx_pw_4lupa_5_lupa_9_LuaTable_3keys, METH_NOARGS, __pyx_doc_4lupa_5_lupa_9_LuaTable_2keys}; static PyObject *__pyx_pw_4lupa_5_lupa_9_LuaTable_3keys(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("keys (wrapper)", 0); __pyx_r = __pyx_pf_4lupa_5_lupa_9_LuaTable_2keys(((struct __pyx_obj_4lupa_5_lupa__LuaTable *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_4lupa_5_lupa_9_LuaTable_2keys(struct __pyx_obj_4lupa_5_lupa__LuaTable *__pyx_v_self) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; PyObject *__pyx_t_2 = NULL; __Pyx_RefNannySetupContext("keys", 0); /* "lupa/_lupa.pyx":694 * object represents. Same as iter(obj). * """ * return _LuaIter(self, KEYS) # <<<<<<<<<<<<<< * * def values(self): */ __Pyx_XDECREF(__pyx_r); __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_e_4lupa_5_lupa_KEYS); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 694, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 694, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_INCREF(((PyObject *)__pyx_v_self)); __Pyx_GIVEREF(((PyObject *)__pyx_v_self)); PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_v_self)); __Pyx_GIVEREF(__pyx_t_1); PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_t_1); __pyx_t_1 = 0; __pyx_t_1 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_4lupa_5_lupa__LuaIter), __pyx_t_2, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 694, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0; /* "lupa/_lupa.pyx":690 * return _LuaIter(self, KEYS) * * def keys(self): # <<<<<<<<<<<<<< * """Returns an iterator over the keys of a table that this * object represents. Same as iter(obj). */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_2); __Pyx_AddTraceback("lupa._lupa._LuaTable.keys", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "lupa/_lupa.pyx":696 * return _LuaIter(self, KEYS) * * def values(self): # <<<<<<<<<<<<<< * """Returns an iterator over the values of a table that this * object represents. */ /* Python wrapper */ static PyObject *__pyx_pw_4lupa_5_lupa_9_LuaTable_5values(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ static char __pyx_doc_4lupa_5_lupa_9_LuaTable_4values[] = "_LuaTable.values(self)\nReturns an iterator over the values of a table that this\n object represents.\n "; static PyMethodDef __pyx_mdef_4lupa_5_lupa_9_LuaTable_5values = {"values", (PyCFunction)__pyx_pw_4lupa_5_lupa_9_LuaTable_5values, METH_NOARGS, __pyx_doc_4lupa_5_lupa_9_LuaTable_4values}; static PyObject *__pyx_pw_4lupa_5_lupa_9_LuaTable_5values(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("values (wrapper)", 0); __pyx_r = __pyx_pf_4lupa_5_lupa_9_LuaTable_4values(((struct __pyx_obj_4lupa_5_lupa__LuaTable *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_4lupa_5_lupa_9_LuaTable_4values(struct __pyx_obj_4lupa_5_lupa__LuaTable *__pyx_v_self) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; PyObject *__pyx_t_2 = NULL; __Pyx_RefNannySetupContext("values", 0); /* "lupa/_lupa.pyx":700 * object represents. * """ * return _LuaIter(self, VALUES) # <<<<<<<<<<<<<< * * def items(self): */ __Pyx_XDECREF(__pyx_r); __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_e_4lupa_5_lupa_VALUES); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 700, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 700, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_INCREF(((PyObject *)__pyx_v_self)); __Pyx_GIVEREF(((PyObject *)__pyx_v_self)); PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_v_self)); __Pyx_GIVEREF(__pyx_t_1); PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_t_1); __pyx_t_1 = 0; __pyx_t_1 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_4lupa_5_lupa__LuaIter), __pyx_t_2, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 700, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0; /* "lupa/_lupa.pyx":696 * return _LuaIter(self, KEYS) * * def values(self): # <<<<<<<<<<<<<< * """Returns an iterator over the values of a table that this * object represents. */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_2); __Pyx_AddTraceback("lupa._lupa._LuaTable.values", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "lupa/_lupa.pyx":702 * return _LuaIter(self, VALUES) * * def items(self): # <<<<<<<<<<<<<< * """Returns an iterator over the key-value pairs of a table * that this object represents. */ /* Python wrapper */ static PyObject *__pyx_pw_4lupa_5_lupa_9_LuaTable_7items(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ static char __pyx_doc_4lupa_5_lupa_9_LuaTable_6items[] = "_LuaTable.items(self)\nReturns an iterator over the key-value pairs of a table\n that this object represents.\n "; static PyMethodDef __pyx_mdef_4lupa_5_lupa_9_LuaTable_7items = {"items", (PyCFunction)__pyx_pw_4lupa_5_lupa_9_LuaTable_7items, METH_NOARGS, __pyx_doc_4lupa_5_lupa_9_LuaTable_6items}; static PyObject *__pyx_pw_4lupa_5_lupa_9_LuaTable_7items(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("items (wrapper)", 0); __pyx_r = __pyx_pf_4lupa_5_lupa_9_LuaTable_6items(((struct __pyx_obj_4lupa_5_lupa__LuaTable *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_4lupa_5_lupa_9_LuaTable_6items(struct __pyx_obj_4lupa_5_lupa__LuaTable *__pyx_v_self) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; PyObject *__pyx_t_2 = NULL; __Pyx_RefNannySetupContext("items", 0); /* "lupa/_lupa.pyx":706 * that this object represents. * """ * return _LuaIter(self, ITEMS) # <<<<<<<<<<<<<< * * def __setattr__(self, name, value): */ __Pyx_XDECREF(__pyx_r); __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_e_4lupa_5_lupa_ITEMS); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 706, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 706, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_INCREF(((PyObject *)__pyx_v_self)); __Pyx_GIVEREF(((PyObject *)__pyx_v_self)); PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_v_self)); __Pyx_GIVEREF(__pyx_t_1); PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_t_1); __pyx_t_1 = 0; __pyx_t_1 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_4lupa_5_lupa__LuaIter), __pyx_t_2, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 706, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0; /* "lupa/_lupa.pyx":702 * return _LuaIter(self, VALUES) * * def items(self): # <<<<<<<<<<<<<< * """Returns an iterator over the key-value pairs of a table * that this object represents. */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_2); __Pyx_AddTraceback("lupa._lupa._LuaTable.items", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "lupa/_lupa.pyx":708 * return _LuaIter(self, ITEMS) * * def __setattr__(self, name, value): # <<<<<<<<<<<<<< * assert self._runtime is not None * if isinstance(name, unicode): */ /* Python wrapper */ static int __pyx_pw_4lupa_5_lupa_9_LuaTable_9__setattr__(PyObject *__pyx_v_self, PyObject *__pyx_v_name, PyObject *__pyx_v_value); /*proto*/ static int __pyx_pw_4lupa_5_lupa_9_LuaTable_9__setattr__(PyObject *__pyx_v_self, PyObject *__pyx_v_name, PyObject *__pyx_v_value) { int __pyx_r; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__setattr__ (wrapper)", 0); __pyx_r = __pyx_pf_4lupa_5_lupa_9_LuaTable_8__setattr__(((struct __pyx_obj_4lupa_5_lupa__LuaTable *)__pyx_v_self), ((PyObject *)__pyx_v_name), ((PyObject *)__pyx_v_value)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static int __pyx_pf_4lupa_5_lupa_9_LuaTable_8__setattr__(struct __pyx_obj_4lupa_5_lupa__LuaTable *__pyx_v_self, PyObject *__pyx_v_name, PyObject *__pyx_v_value) { int __pyx_r; __Pyx_RefNannyDeclarations int __pyx_t_1; int __pyx_t_2; PyObject *__pyx_t_3 = NULL; PyObject *__pyx_t_4 = NULL; PyObject *__pyx_t_5 = NULL; int __pyx_t_6; PyObject *__pyx_t_7 = NULL; char const *__pyx_t_8; int __pyx_t_9; __Pyx_RefNannySetupContext("__setattr__", 0); __Pyx_INCREF(__pyx_v_name); /* "lupa/_lupa.pyx":709 * * def __setattr__(self, name, value): * assert self._runtime is not None # <<<<<<<<<<<<<< * if isinstance(name, unicode): * if (name).startswith(u'__') and (name).endswith(u'__'): */ #ifndef CYTHON_WITHOUT_ASSERTIONS if (unlikely(!Py_OptimizeFlag)) { __pyx_t_1 = (((PyObject *)__pyx_v_self->__pyx_base._runtime) != Py_None); if (unlikely(!(__pyx_t_1 != 0))) { PyErr_SetNone(PyExc_AssertionError); __PYX_ERR(0, 709, __pyx_L1_error) } } #endif /* "lupa/_lupa.pyx":710 * def __setattr__(self, name, value): * assert self._runtime is not None * if isinstance(name, unicode): # <<<<<<<<<<<<<< * if (name).startswith(u'__') and (name).endswith(u'__'): * object.__setattr__(self, name, value) */ __pyx_t_1 = PyUnicode_Check(__pyx_v_name); __pyx_t_2 = (__pyx_t_1 != 0); if (__pyx_t_2) { /* "lupa/_lupa.pyx":711 * assert self._runtime is not None * if isinstance(name, unicode): * if (name).startswith(u'__') and (name).endswith(u'__'): # <<<<<<<<<<<<<< * object.__setattr__(self, name, value) * return */ if (unlikely(__pyx_v_name == Py_None)) { PyErr_Format(PyExc_AttributeError, "'NoneType' object has no attribute '%.30s'", "startswith"); __PYX_ERR(0, 711, __pyx_L1_error) } __pyx_t_1 = __Pyx_PyUnicode_Tailmatch(((PyObject*)__pyx_v_name), __pyx_n_u__22, 0, PY_SSIZE_T_MAX, -1); if (unlikely(__pyx_t_1 == ((int)-1))) __PYX_ERR(0, 711, __pyx_L1_error) if ((__pyx_t_1 != 0)) { } else { __pyx_t_2 = (__pyx_t_1 != 0); goto __pyx_L5_bool_binop_done; } if (unlikely(__pyx_v_name == Py_None)) { PyErr_Format(PyExc_AttributeError, "'NoneType' object has no attribute '%.30s'", "endswith"); __PYX_ERR(0, 711, __pyx_L1_error) } __pyx_t_1 = __Pyx_PyUnicode_Tailmatch(((PyObject*)__pyx_v_name), __pyx_n_u__22, 0, PY_SSIZE_T_MAX, 1); if (unlikely(__pyx_t_1 == ((int)-1))) __PYX_ERR(0, 711, __pyx_L1_error) __pyx_t_2 = (__pyx_t_1 != 0); __pyx_L5_bool_binop_done:; if (__pyx_t_2) { /* "lupa/_lupa.pyx":712 * if isinstance(name, unicode): * if (name).startswith(u'__') and (name).endswith(u'__'): * object.__setattr__(self, name, value) # <<<<<<<<<<<<<< * return * name = (name).encode(self._runtime._source_encoding) */ __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_builtin_object, __pyx_n_s_setattr); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 712, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_5 = NULL; __pyx_t_6 = 0; if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_4))) { __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_4); if (likely(__pyx_t_5)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4); __Pyx_INCREF(__pyx_t_5); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_4, function); __pyx_t_6 = 1; } } #if CYTHON_FAST_PYCALL if (PyFunction_Check(__pyx_t_4)) { PyObject *__pyx_temp[4] = {__pyx_t_5, ((PyObject *)__pyx_v_self), __pyx_v_name, __pyx_v_value}; __pyx_t_3 = __Pyx_PyFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_6, 3+__pyx_t_6); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 712, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_GOTREF(__pyx_t_3); } else #endif #if CYTHON_FAST_PYCCALL if (__Pyx_PyFastCFunction_Check(__pyx_t_4)) { PyObject *__pyx_temp[4] = {__pyx_t_5, ((PyObject *)__pyx_v_self), __pyx_v_name, __pyx_v_value}; __pyx_t_3 = __Pyx_PyCFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_6, 3+__pyx_t_6); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 712, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_GOTREF(__pyx_t_3); } else #endif { __pyx_t_7 = PyTuple_New(3+__pyx_t_6); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 712, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); if (__pyx_t_5) { __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_5); __pyx_t_5 = NULL; } __Pyx_INCREF(((PyObject *)__pyx_v_self)); __Pyx_GIVEREF(((PyObject *)__pyx_v_self)); PyTuple_SET_ITEM(__pyx_t_7, 0+__pyx_t_6, ((PyObject *)__pyx_v_self)); __Pyx_INCREF(__pyx_v_name); __Pyx_GIVEREF(__pyx_v_name); PyTuple_SET_ITEM(__pyx_t_7, 1+__pyx_t_6, __pyx_v_name); __Pyx_INCREF(__pyx_v_value); __Pyx_GIVEREF(__pyx_v_value); PyTuple_SET_ITEM(__pyx_t_7, 2+__pyx_t_6, __pyx_v_value); __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_7, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 712, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; } __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; /* "lupa/_lupa.pyx":713 * if (name).startswith(u'__') and (name).endswith(u'__'): * object.__setattr__(self, name, value) * return # <<<<<<<<<<<<<< * name = (name).encode(self._runtime._source_encoding) * elif isinstance(name, bytes) and (name).startswith(b'__') and (name).endswith(b'__'): */ __pyx_r = 0; goto __pyx_L0; /* "lupa/_lupa.pyx":711 * assert self._runtime is not None * if isinstance(name, unicode): * if (name).startswith(u'__') and (name).endswith(u'__'): # <<<<<<<<<<<<<< * object.__setattr__(self, name, value) * return */ } /* "lupa/_lupa.pyx":714 * object.__setattr__(self, name, value) * return * name = (name).encode(self._runtime._source_encoding) # <<<<<<<<<<<<<< * elif isinstance(name, bytes) and (name).startswith(b'__') and (name).endswith(b'__'): * object.__setattr__(self, name, value) */ if (unlikely(__pyx_v_name == Py_None)) { PyErr_Format(PyExc_AttributeError, "'NoneType' object has no attribute '%.30s'", "encode"); __PYX_ERR(0, 714, __pyx_L1_error) } if (unlikely(__pyx_v_self->__pyx_base._runtime->_source_encoding == Py_None)) { PyErr_SetString(PyExc_TypeError, "expected bytes, NoneType found"); __PYX_ERR(0, 714, __pyx_L1_error) } __pyx_t_8 = __Pyx_PyBytes_AsString(__pyx_v_self->__pyx_base._runtime->_source_encoding); if (unlikely((!__pyx_t_8) && PyErr_Occurred())) __PYX_ERR(0, 714, __pyx_L1_error) __pyx_t_3 = PyUnicode_AsEncodedString(((PyObject*)__pyx_v_name), __pyx_t_8, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 714, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF_SET(__pyx_v_name, __pyx_t_3); __pyx_t_3 = 0; /* "lupa/_lupa.pyx":710 * def __setattr__(self, name, value): * assert self._runtime is not None * if isinstance(name, unicode): # <<<<<<<<<<<<<< * if (name).startswith(u'__') and (name).endswith(u'__'): * object.__setattr__(self, name, value) */ goto __pyx_L3; } /* "lupa/_lupa.pyx":715 * return * name = (name).encode(self._runtime._source_encoding) * elif isinstance(name, bytes) and (name).startswith(b'__') and (name).endswith(b'__'): # <<<<<<<<<<<<<< * object.__setattr__(self, name, value) * return */ __pyx_t_1 = PyBytes_Check(__pyx_v_name); __pyx_t_9 = (__pyx_t_1 != 0); if (__pyx_t_9) { } else { __pyx_t_2 = __pyx_t_9; goto __pyx_L7_bool_binop_done; } if (unlikely(__pyx_v_name == Py_None)) { PyErr_Format(PyExc_AttributeError, "'NoneType' object has no attribute '%.30s'", "startswith"); __PYX_ERR(0, 715, __pyx_L1_error) } __pyx_t_9 = __Pyx_PyBytes_Tailmatch(((PyObject*)__pyx_v_name), __pyx_n_b__22, 0, PY_SSIZE_T_MAX, -1); if (unlikely(__pyx_t_9 == ((int)-1))) __PYX_ERR(0, 715, __pyx_L1_error) if ((__pyx_t_9 != 0)) { } else { __pyx_t_2 = (__pyx_t_9 != 0); goto __pyx_L7_bool_binop_done; } if (unlikely(__pyx_v_name == Py_None)) { PyErr_Format(PyExc_AttributeError, "'NoneType' object has no attribute '%.30s'", "endswith"); __PYX_ERR(0, 715, __pyx_L1_error) } __pyx_t_9 = __Pyx_PyBytes_Tailmatch(((PyObject*)__pyx_v_name), __pyx_n_b__22, 0, PY_SSIZE_T_MAX, 1); if (unlikely(__pyx_t_9 == ((int)-1))) __PYX_ERR(0, 715, __pyx_L1_error) __pyx_t_2 = (__pyx_t_9 != 0); __pyx_L7_bool_binop_done:; if (__pyx_t_2) { /* "lupa/_lupa.pyx":716 * name = (name).encode(self._runtime._source_encoding) * elif isinstance(name, bytes) and (name).startswith(b'__') and (name).endswith(b'__'): * object.__setattr__(self, name, value) # <<<<<<<<<<<<<< * return * self._setitem(name, value) */ __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_builtin_object, __pyx_n_s_setattr); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 716, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_7 = NULL; __pyx_t_6 = 0; if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_4))) { __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_4); if (likely(__pyx_t_7)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4); __Pyx_INCREF(__pyx_t_7); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_4, function); __pyx_t_6 = 1; } } #if CYTHON_FAST_PYCALL if (PyFunction_Check(__pyx_t_4)) { PyObject *__pyx_temp[4] = {__pyx_t_7, ((PyObject *)__pyx_v_self), __pyx_v_name, __pyx_v_value}; __pyx_t_3 = __Pyx_PyFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_6, 3+__pyx_t_6); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 716, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0; __Pyx_GOTREF(__pyx_t_3); } else #endif #if CYTHON_FAST_PYCCALL if (__Pyx_PyFastCFunction_Check(__pyx_t_4)) { PyObject *__pyx_temp[4] = {__pyx_t_7, ((PyObject *)__pyx_v_self), __pyx_v_name, __pyx_v_value}; __pyx_t_3 = __Pyx_PyCFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_6, 3+__pyx_t_6); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 716, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0; __Pyx_GOTREF(__pyx_t_3); } else #endif { __pyx_t_5 = PyTuple_New(3+__pyx_t_6); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 716, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); if (__pyx_t_7) { __Pyx_GIVEREF(__pyx_t_7); PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_7); __pyx_t_7 = NULL; } __Pyx_INCREF(((PyObject *)__pyx_v_self)); __Pyx_GIVEREF(((PyObject *)__pyx_v_self)); PyTuple_SET_ITEM(__pyx_t_5, 0+__pyx_t_6, ((PyObject *)__pyx_v_self)); __Pyx_INCREF(__pyx_v_name); __Pyx_GIVEREF(__pyx_v_name); PyTuple_SET_ITEM(__pyx_t_5, 1+__pyx_t_6, __pyx_v_name); __Pyx_INCREF(__pyx_v_value); __Pyx_GIVEREF(__pyx_v_value); PyTuple_SET_ITEM(__pyx_t_5, 2+__pyx_t_6, __pyx_v_value); __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_5, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 716, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; } __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; /* "lupa/_lupa.pyx":717 * elif isinstance(name, bytes) and (name).startswith(b'__') and (name).endswith(b'__'): * object.__setattr__(self, name, value) * return # <<<<<<<<<<<<<< * self._setitem(name, value) * */ __pyx_r = 0; goto __pyx_L0; /* "lupa/_lupa.pyx":715 * return * name = (name).encode(self._runtime._source_encoding) * elif isinstance(name, bytes) and (name).startswith(b'__') and (name).endswith(b'__'): # <<<<<<<<<<<<<< * object.__setattr__(self, name, value) * return */ } __pyx_L3:; /* "lupa/_lupa.pyx":718 * object.__setattr__(self, name, value) * return * self._setitem(name, value) # <<<<<<<<<<<<<< * * def __setitem__(self, index_or_name, value): */ __pyx_t_6 = __pyx_f_4lupa_5_lupa_9_LuaTable__setitem(__pyx_v_self, __pyx_v_name, __pyx_v_value); if (unlikely(__pyx_t_6 == ((int)-1))) __PYX_ERR(0, 718, __pyx_L1_error) /* "lupa/_lupa.pyx":708 * return _LuaIter(self, ITEMS) * * def __setattr__(self, name, value): # <<<<<<<<<<<<<< * assert self._runtime is not None * if isinstance(name, unicode): */ /* function exit code */ __pyx_r = 0; goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_3); __Pyx_XDECREF(__pyx_t_4); __Pyx_XDECREF(__pyx_t_5); __Pyx_XDECREF(__pyx_t_7); __Pyx_AddTraceback("lupa._lupa._LuaTable.__setattr__", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = -1; __pyx_L0:; __Pyx_XDECREF(__pyx_v_name); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "lupa/_lupa.pyx":720 * self._setitem(name, value) * * def __setitem__(self, index_or_name, value): # <<<<<<<<<<<<<< * self._setitem(index_or_name, value) * */ /* Python wrapper */ static int __pyx_pw_4lupa_5_lupa_9_LuaTable_11__setitem__(PyObject *__pyx_v_self, PyObject *__pyx_v_index_or_name, PyObject *__pyx_v_value); /*proto*/ static int __pyx_pw_4lupa_5_lupa_9_LuaTable_11__setitem__(PyObject *__pyx_v_self, PyObject *__pyx_v_index_or_name, PyObject *__pyx_v_value) { int __pyx_r; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__setitem__ (wrapper)", 0); __pyx_r = __pyx_pf_4lupa_5_lupa_9_LuaTable_10__setitem__(((struct __pyx_obj_4lupa_5_lupa__LuaTable *)__pyx_v_self), ((PyObject *)__pyx_v_index_or_name), ((PyObject *)__pyx_v_value)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static int __pyx_pf_4lupa_5_lupa_9_LuaTable_10__setitem__(struct __pyx_obj_4lupa_5_lupa__LuaTable *__pyx_v_self, PyObject *__pyx_v_index_or_name, PyObject *__pyx_v_value) { int __pyx_r; __Pyx_RefNannyDeclarations int __pyx_t_1; __Pyx_RefNannySetupContext("__setitem__", 0); /* "lupa/_lupa.pyx":721 * * def __setitem__(self, index_or_name, value): * self._setitem(index_or_name, value) # <<<<<<<<<<<<<< * * @cython.final */ __pyx_t_1 = __pyx_f_4lupa_5_lupa_9_LuaTable__setitem(__pyx_v_self, __pyx_v_index_or_name, __pyx_v_value); if (unlikely(__pyx_t_1 == ((int)-1))) __PYX_ERR(0, 721, __pyx_L1_error) /* "lupa/_lupa.pyx":720 * self._setitem(name, value) * * def __setitem__(self, index_or_name, value): # <<<<<<<<<<<<<< * self._setitem(index_or_name, value) * */ /* function exit code */ __pyx_r = 0; goto __pyx_L0; __pyx_L1_error:; __Pyx_AddTraceback("lupa._lupa._LuaTable.__setitem__", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = -1; __pyx_L0:; __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "lupa/_lupa.pyx":724 * * @cython.final * cdef int _setitem(self, name, value) except -1: # <<<<<<<<<<<<<< * cdef lua_State* L = self._state * lock_runtime(self._runtime) */ static int __pyx_f_4lupa_5_lupa_9_LuaTable__setitem(struct __pyx_obj_4lupa_5_lupa__LuaTable *__pyx_v_self, PyObject *__pyx_v_name, PyObject *__pyx_v_value) { lua_State *__pyx_v_L; int __pyx_v_old_top; int __pyx_r; __Pyx_RefNannyDeclarations lua_State *__pyx_t_1; PyObject *__pyx_t_2 = NULL; int __pyx_t_3; struct __pyx_opt_args_4lupa_5_lupa_py_to_lua __pyx_t_4; int __pyx_t_5; char const *__pyx_t_6; PyObject *__pyx_t_7 = NULL; PyObject *__pyx_t_8 = NULL; PyObject *__pyx_t_9 = NULL; PyObject *__pyx_t_10 = NULL; PyObject *__pyx_t_11 = NULL; PyObject *__pyx_t_12 = NULL; __Pyx_RefNannySetupContext("_setitem", 0); /* "lupa/_lupa.pyx":725 * @cython.final * cdef int _setitem(self, name, value) except -1: * cdef lua_State* L = self._state # <<<<<<<<<<<<<< * lock_runtime(self._runtime) * old_top = lua.lua_gettop(L) */ __pyx_t_1 = __pyx_v_self->__pyx_base._state; __pyx_v_L = __pyx_t_1; /* "lupa/_lupa.pyx":726 * cdef int _setitem(self, name, value) except -1: * cdef lua_State* L = self._state * lock_runtime(self._runtime) # <<<<<<<<<<<<<< * old_top = lua.lua_gettop(L) * try: */ __pyx_t_2 = ((PyObject *)__pyx_v_self->__pyx_base._runtime); __Pyx_INCREF(__pyx_t_2); __pyx_t_3 = __pyx_f_4lupa_5_lupa_lock_runtime(((struct __pyx_obj_4lupa_5_lupa_LuaRuntime *)__pyx_t_2)); if (unlikely(__pyx_t_3 == ((int)-1))) __PYX_ERR(0, 726, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; /* "lupa/_lupa.pyx":727 * cdef lua_State* L = self._state * lock_runtime(self._runtime) * old_top = lua.lua_gettop(L) # <<<<<<<<<<<<<< * try: * self.push_lua_object() */ __pyx_v_old_top = lua_gettop(__pyx_v_L); /* "lupa/_lupa.pyx":728 * lock_runtime(self._runtime) * old_top = lua.lua_gettop(L) * try: # <<<<<<<<<<<<<< * self.push_lua_object() * # table[nil] fails, so map None -> python.none for Lua tables */ /*try:*/ { /* "lupa/_lupa.pyx":729 * old_top = lua.lua_gettop(L) * try: * self.push_lua_object() # <<<<<<<<<<<<<< * # table[nil] fails, so map None -> python.none for Lua tables * py_to_lua(self._runtime, L, name, wrap_none=True) */ __pyx_t_3 = __pyx_f_4lupa_5_lupa_10_LuaObject_push_lua_object(((struct __pyx_obj_4lupa_5_lupa__LuaObject *)__pyx_v_self)); if (unlikely(__pyx_t_3 == ((int)-1))) __PYX_ERR(0, 729, __pyx_L4_error) /* "lupa/_lupa.pyx":731 * self.push_lua_object() * # table[nil] fails, so map None -> python.none for Lua tables * py_to_lua(self._runtime, L, name, wrap_none=True) # <<<<<<<<<<<<<< * py_to_lua(self._runtime, L, value) * lua.lua_settable(L, -3) */ __pyx_t_2 = ((PyObject *)__pyx_v_self->__pyx_base._runtime); __Pyx_INCREF(__pyx_t_2); __pyx_t_4.__pyx_n = 1; __pyx_t_4.wrap_none = 1; __pyx_t_3 = __pyx_f_4lupa_5_lupa_py_to_lua(((struct __pyx_obj_4lupa_5_lupa_LuaRuntime *)__pyx_t_2), __pyx_v_L, __pyx_v_name, &__pyx_t_4); if (unlikely(__pyx_t_3 == ((int)-1))) __PYX_ERR(0, 731, __pyx_L4_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; /* "lupa/_lupa.pyx":732 * # table[nil] fails, so map None -> python.none for Lua tables * py_to_lua(self._runtime, L, name, wrap_none=True) * py_to_lua(self._runtime, L, value) # <<<<<<<<<<<<<< * lua.lua_settable(L, -3) * finally: */ __pyx_t_2 = ((PyObject *)__pyx_v_self->__pyx_base._runtime); __Pyx_INCREF(__pyx_t_2); __pyx_t_3 = __pyx_f_4lupa_5_lupa_py_to_lua(((struct __pyx_obj_4lupa_5_lupa_LuaRuntime *)__pyx_t_2), __pyx_v_L, __pyx_v_value, NULL); if (unlikely(__pyx_t_3 == ((int)-1))) __PYX_ERR(0, 732, __pyx_L4_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; /* "lupa/_lupa.pyx":733 * py_to_lua(self._runtime, L, name, wrap_none=True) * py_to_lua(self._runtime, L, value) * lua.lua_settable(L, -3) # <<<<<<<<<<<<<< * finally: * lua.lua_settop(L, old_top) */ lua_settable(__pyx_v_L, -3); } /* "lupa/_lupa.pyx":735 * lua.lua_settable(L, -3) * finally: * lua.lua_settop(L, old_top) # <<<<<<<<<<<<<< * unlock_runtime(self._runtime) * return 0 */ /*finally:*/ { /*normal exit:*/{ lua_settop(__pyx_v_L, __pyx_v_old_top); /* "lupa/_lupa.pyx":736 * finally: * lua.lua_settop(L, old_top) * unlock_runtime(self._runtime) # <<<<<<<<<<<<<< * return 0 * */ __pyx_t_2 = ((PyObject *)__pyx_v_self->__pyx_base._runtime); __Pyx_INCREF(__pyx_t_2); __pyx_f_4lupa_5_lupa_unlock_runtime(((struct __pyx_obj_4lupa_5_lupa_LuaRuntime *)__pyx_t_2)); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; goto __pyx_L5; } __pyx_L4_error:; /*exception exit:*/{ __Pyx_PyThreadState_declare __Pyx_PyThreadState_assign __pyx_t_7 = 0; __pyx_t_8 = 0; __pyx_t_9 = 0; __pyx_t_10 = 0; __pyx_t_11 = 0; __pyx_t_12 = 0; __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; if (PY_MAJOR_VERSION >= 3) __Pyx_ExceptionSwap(&__pyx_t_10, &__pyx_t_11, &__pyx_t_12); if ((PY_MAJOR_VERSION < 3) || unlikely(__Pyx_GetException(&__pyx_t_7, &__pyx_t_8, &__pyx_t_9) < 0)) __Pyx_ErrFetch(&__pyx_t_7, &__pyx_t_8, &__pyx_t_9); __Pyx_XGOTREF(__pyx_t_7); __Pyx_XGOTREF(__pyx_t_8); __Pyx_XGOTREF(__pyx_t_9); __Pyx_XGOTREF(__pyx_t_10); __Pyx_XGOTREF(__pyx_t_11); __Pyx_XGOTREF(__pyx_t_12); __pyx_t_3 = __pyx_lineno; __pyx_t_5 = __pyx_clineno; __pyx_t_6 = __pyx_filename; { /* "lupa/_lupa.pyx":735 * lua.lua_settable(L, -3) * finally: * lua.lua_settop(L, old_top) # <<<<<<<<<<<<<< * unlock_runtime(self._runtime) * return 0 */ lua_settop(__pyx_v_L, __pyx_v_old_top); /* "lupa/_lupa.pyx":736 * finally: * lua.lua_settop(L, old_top) * unlock_runtime(self._runtime) # <<<<<<<<<<<<<< * return 0 * */ __pyx_t_2 = ((PyObject *)__pyx_v_self->__pyx_base._runtime); __Pyx_INCREF(__pyx_t_2); __pyx_f_4lupa_5_lupa_unlock_runtime(((struct __pyx_obj_4lupa_5_lupa_LuaRuntime *)__pyx_t_2)); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; } if (PY_MAJOR_VERSION >= 3) { __Pyx_XGIVEREF(__pyx_t_10); __Pyx_XGIVEREF(__pyx_t_11); __Pyx_XGIVEREF(__pyx_t_12); __Pyx_ExceptionReset(__pyx_t_10, __pyx_t_11, __pyx_t_12); } __Pyx_XGIVEREF(__pyx_t_7); __Pyx_XGIVEREF(__pyx_t_8); __Pyx_XGIVEREF(__pyx_t_9); __Pyx_ErrRestore(__pyx_t_7, __pyx_t_8, __pyx_t_9); __pyx_t_7 = 0; __pyx_t_8 = 0; __pyx_t_9 = 0; __pyx_t_10 = 0; __pyx_t_11 = 0; __pyx_t_12 = 0; __pyx_lineno = __pyx_t_3; __pyx_clineno = __pyx_t_5; __pyx_filename = __pyx_t_6; goto __pyx_L1_error; } __pyx_L5:; } /* "lupa/_lupa.pyx":737 * lua.lua_settop(L, old_top) * unlock_runtime(self._runtime) * return 0 # <<<<<<<<<<<<<< * * def __delattr__(self, item): */ __pyx_r = 0; goto __pyx_L0; /* "lupa/_lupa.pyx":724 * * @cython.final * cdef int _setitem(self, name, value) except -1: # <<<<<<<<<<<<<< * cdef lua_State* L = self._state * lock_runtime(self._runtime) */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_2); __Pyx_AddTraceback("lupa._lupa._LuaTable._setitem", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = -1; __pyx_L0:; __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "lupa/_lupa.pyx":739 * return 0 * * def __delattr__(self, item): # <<<<<<<<<<<<<< * assert self._runtime is not None * if isinstance(item, unicode): */ /* Python wrapper */ static int __pyx_pw_4lupa_5_lupa_9_LuaTable_13__delattr__(PyObject *__pyx_v_self, PyObject *__pyx_v_item); /*proto*/ static int __pyx_pw_4lupa_5_lupa_9_LuaTable_13__delattr__(PyObject *__pyx_v_self, PyObject *__pyx_v_item) { int __pyx_r; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__delattr__ (wrapper)", 0); __pyx_r = __pyx_pf_4lupa_5_lupa_9_LuaTable_12__delattr__(((struct __pyx_obj_4lupa_5_lupa__LuaTable *)__pyx_v_self), ((PyObject *)__pyx_v_item)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static int __pyx_pf_4lupa_5_lupa_9_LuaTable_12__delattr__(struct __pyx_obj_4lupa_5_lupa__LuaTable *__pyx_v_self, PyObject *__pyx_v_item) { int __pyx_r; __Pyx_RefNannyDeclarations int __pyx_t_1; int __pyx_t_2; PyObject *__pyx_t_3 = NULL; PyObject *__pyx_t_4 = NULL; PyObject *__pyx_t_5 = NULL; int __pyx_t_6; PyObject *__pyx_t_7 = NULL; char const *__pyx_t_8; int __pyx_t_9; __Pyx_RefNannySetupContext("__delattr__", 0); __Pyx_INCREF(__pyx_v_item); /* "lupa/_lupa.pyx":740 * * def __delattr__(self, item): * assert self._runtime is not None # <<<<<<<<<<<<<< * if isinstance(item, unicode): * if (item).startswith(u'__') and (item).endswith(u'__'): */ #ifndef CYTHON_WITHOUT_ASSERTIONS if (unlikely(!Py_OptimizeFlag)) { __pyx_t_1 = (((PyObject *)__pyx_v_self->__pyx_base._runtime) != Py_None); if (unlikely(!(__pyx_t_1 != 0))) { PyErr_SetNone(PyExc_AssertionError); __PYX_ERR(0, 740, __pyx_L1_error) } } #endif /* "lupa/_lupa.pyx":741 * def __delattr__(self, item): * assert self._runtime is not None * if isinstance(item, unicode): # <<<<<<<<<<<<<< * if (item).startswith(u'__') and (item).endswith(u'__'): * object.__delattr__(self, item) */ __pyx_t_1 = PyUnicode_Check(__pyx_v_item); __pyx_t_2 = (__pyx_t_1 != 0); if (__pyx_t_2) { /* "lupa/_lupa.pyx":742 * assert self._runtime is not None * if isinstance(item, unicode): * if (item).startswith(u'__') and (item).endswith(u'__'): # <<<<<<<<<<<<<< * object.__delattr__(self, item) * return */ if (unlikely(__pyx_v_item == Py_None)) { PyErr_Format(PyExc_AttributeError, "'NoneType' object has no attribute '%.30s'", "startswith"); __PYX_ERR(0, 742, __pyx_L1_error) } __pyx_t_1 = __Pyx_PyUnicode_Tailmatch(((PyObject*)__pyx_v_item), __pyx_n_u__22, 0, PY_SSIZE_T_MAX, -1); if (unlikely(__pyx_t_1 == ((int)-1))) __PYX_ERR(0, 742, __pyx_L1_error) if ((__pyx_t_1 != 0)) { } else { __pyx_t_2 = (__pyx_t_1 != 0); goto __pyx_L5_bool_binop_done; } if (unlikely(__pyx_v_item == Py_None)) { PyErr_Format(PyExc_AttributeError, "'NoneType' object has no attribute '%.30s'", "endswith"); __PYX_ERR(0, 742, __pyx_L1_error) } __pyx_t_1 = __Pyx_PyUnicode_Tailmatch(((PyObject*)__pyx_v_item), __pyx_n_u__22, 0, PY_SSIZE_T_MAX, 1); if (unlikely(__pyx_t_1 == ((int)-1))) __PYX_ERR(0, 742, __pyx_L1_error) __pyx_t_2 = (__pyx_t_1 != 0); __pyx_L5_bool_binop_done:; if (__pyx_t_2) { /* "lupa/_lupa.pyx":743 * if isinstance(item, unicode): * if (item).startswith(u'__') and (item).endswith(u'__'): * object.__delattr__(self, item) # <<<<<<<<<<<<<< * return * item = (item).encode(self._runtime._source_encoding) */ __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_builtin_object, __pyx_n_s_delattr); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 743, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_5 = NULL; __pyx_t_6 = 0; if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_4))) { __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_4); if (likely(__pyx_t_5)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4); __Pyx_INCREF(__pyx_t_5); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_4, function); __pyx_t_6 = 1; } } #if CYTHON_FAST_PYCALL if (PyFunction_Check(__pyx_t_4)) { PyObject *__pyx_temp[3] = {__pyx_t_5, ((PyObject *)__pyx_v_self), __pyx_v_item}; __pyx_t_3 = __Pyx_PyFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_6, 2+__pyx_t_6); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 743, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_GOTREF(__pyx_t_3); } else #endif #if CYTHON_FAST_PYCCALL if (__Pyx_PyFastCFunction_Check(__pyx_t_4)) { PyObject *__pyx_temp[3] = {__pyx_t_5, ((PyObject *)__pyx_v_self), __pyx_v_item}; __pyx_t_3 = __Pyx_PyCFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_6, 2+__pyx_t_6); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 743, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_GOTREF(__pyx_t_3); } else #endif { __pyx_t_7 = PyTuple_New(2+__pyx_t_6); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 743, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); if (__pyx_t_5) { __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_5); __pyx_t_5 = NULL; } __Pyx_INCREF(((PyObject *)__pyx_v_self)); __Pyx_GIVEREF(((PyObject *)__pyx_v_self)); PyTuple_SET_ITEM(__pyx_t_7, 0+__pyx_t_6, ((PyObject *)__pyx_v_self)); __Pyx_INCREF(__pyx_v_item); __Pyx_GIVEREF(__pyx_v_item); PyTuple_SET_ITEM(__pyx_t_7, 1+__pyx_t_6, __pyx_v_item); __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_7, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 743, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; } __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; /* "lupa/_lupa.pyx":744 * if (item).startswith(u'__') and (item).endswith(u'__'): * object.__delattr__(self, item) * return # <<<<<<<<<<<<<< * item = (item).encode(self._runtime._source_encoding) * elif isinstance(item, bytes) and (item).startswith(b'__') and (item).endswith(b'__'): */ __pyx_r = 0; goto __pyx_L0; /* "lupa/_lupa.pyx":742 * assert self._runtime is not None * if isinstance(item, unicode): * if (item).startswith(u'__') and (item).endswith(u'__'): # <<<<<<<<<<<<<< * object.__delattr__(self, item) * return */ } /* "lupa/_lupa.pyx":745 * object.__delattr__(self, item) * return * item = (item).encode(self._runtime._source_encoding) # <<<<<<<<<<<<<< * elif isinstance(item, bytes) and (item).startswith(b'__') and (item).endswith(b'__'): * object.__delattr__(self, item) */ if (unlikely(__pyx_v_item == Py_None)) { PyErr_Format(PyExc_AttributeError, "'NoneType' object has no attribute '%.30s'", "encode"); __PYX_ERR(0, 745, __pyx_L1_error) } if (unlikely(__pyx_v_self->__pyx_base._runtime->_source_encoding == Py_None)) { PyErr_SetString(PyExc_TypeError, "expected bytes, NoneType found"); __PYX_ERR(0, 745, __pyx_L1_error) } __pyx_t_8 = __Pyx_PyBytes_AsString(__pyx_v_self->__pyx_base._runtime->_source_encoding); if (unlikely((!__pyx_t_8) && PyErr_Occurred())) __PYX_ERR(0, 745, __pyx_L1_error) __pyx_t_3 = PyUnicode_AsEncodedString(((PyObject*)__pyx_v_item), __pyx_t_8, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 745, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF_SET(__pyx_v_item, __pyx_t_3); __pyx_t_3 = 0; /* "lupa/_lupa.pyx":741 * def __delattr__(self, item): * assert self._runtime is not None * if isinstance(item, unicode): # <<<<<<<<<<<<<< * if (item).startswith(u'__') and (item).endswith(u'__'): * object.__delattr__(self, item) */ goto __pyx_L3; } /* "lupa/_lupa.pyx":746 * return * item = (item).encode(self._runtime._source_encoding) * elif isinstance(item, bytes) and (item).startswith(b'__') and (item).endswith(b'__'): # <<<<<<<<<<<<<< * object.__delattr__(self, item) * return */ __pyx_t_1 = PyBytes_Check(__pyx_v_item); __pyx_t_9 = (__pyx_t_1 != 0); if (__pyx_t_9) { } else { __pyx_t_2 = __pyx_t_9; goto __pyx_L7_bool_binop_done; } if (unlikely(__pyx_v_item == Py_None)) { PyErr_Format(PyExc_AttributeError, "'NoneType' object has no attribute '%.30s'", "startswith"); __PYX_ERR(0, 746, __pyx_L1_error) } __pyx_t_9 = __Pyx_PyBytes_Tailmatch(((PyObject*)__pyx_v_item), __pyx_n_b__22, 0, PY_SSIZE_T_MAX, -1); if (unlikely(__pyx_t_9 == ((int)-1))) __PYX_ERR(0, 746, __pyx_L1_error) if ((__pyx_t_9 != 0)) { } else { __pyx_t_2 = (__pyx_t_9 != 0); goto __pyx_L7_bool_binop_done; } if (unlikely(__pyx_v_item == Py_None)) { PyErr_Format(PyExc_AttributeError, "'NoneType' object has no attribute '%.30s'", "endswith"); __PYX_ERR(0, 746, __pyx_L1_error) } __pyx_t_9 = __Pyx_PyBytes_Tailmatch(((PyObject*)__pyx_v_item), __pyx_n_b__22, 0, PY_SSIZE_T_MAX, 1); if (unlikely(__pyx_t_9 == ((int)-1))) __PYX_ERR(0, 746, __pyx_L1_error) __pyx_t_2 = (__pyx_t_9 != 0); __pyx_L7_bool_binop_done:; if (__pyx_t_2) { /* "lupa/_lupa.pyx":747 * item = (item).encode(self._runtime._source_encoding) * elif isinstance(item, bytes) and (item).startswith(b'__') and (item).endswith(b'__'): * object.__delattr__(self, item) # <<<<<<<<<<<<<< * return * self._delitem(item) */ __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_builtin_object, __pyx_n_s_delattr); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 747, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_7 = NULL; __pyx_t_6 = 0; if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_4))) { __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_4); if (likely(__pyx_t_7)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4); __Pyx_INCREF(__pyx_t_7); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_4, function); __pyx_t_6 = 1; } } #if CYTHON_FAST_PYCALL if (PyFunction_Check(__pyx_t_4)) { PyObject *__pyx_temp[3] = {__pyx_t_7, ((PyObject *)__pyx_v_self), __pyx_v_item}; __pyx_t_3 = __Pyx_PyFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_6, 2+__pyx_t_6); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 747, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0; __Pyx_GOTREF(__pyx_t_3); } else #endif #if CYTHON_FAST_PYCCALL if (__Pyx_PyFastCFunction_Check(__pyx_t_4)) { PyObject *__pyx_temp[3] = {__pyx_t_7, ((PyObject *)__pyx_v_self), __pyx_v_item}; __pyx_t_3 = __Pyx_PyCFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_6, 2+__pyx_t_6); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 747, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0; __Pyx_GOTREF(__pyx_t_3); } else #endif { __pyx_t_5 = PyTuple_New(2+__pyx_t_6); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 747, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); if (__pyx_t_7) { __Pyx_GIVEREF(__pyx_t_7); PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_7); __pyx_t_7 = NULL; } __Pyx_INCREF(((PyObject *)__pyx_v_self)); __Pyx_GIVEREF(((PyObject *)__pyx_v_self)); PyTuple_SET_ITEM(__pyx_t_5, 0+__pyx_t_6, ((PyObject *)__pyx_v_self)); __Pyx_INCREF(__pyx_v_item); __Pyx_GIVEREF(__pyx_v_item); PyTuple_SET_ITEM(__pyx_t_5, 1+__pyx_t_6, __pyx_v_item); __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_5, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 747, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; } __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; /* "lupa/_lupa.pyx":748 * elif isinstance(item, bytes) and (item).startswith(b'__') and (item).endswith(b'__'): * object.__delattr__(self, item) * return # <<<<<<<<<<<<<< * self._delitem(item) * */ __pyx_r = 0; goto __pyx_L0; /* "lupa/_lupa.pyx":746 * return * item = (item).encode(self._runtime._source_encoding) * elif isinstance(item, bytes) and (item).startswith(b'__') and (item).endswith(b'__'): # <<<<<<<<<<<<<< * object.__delattr__(self, item) * return */ } __pyx_L3:; /* "lupa/_lupa.pyx":749 * object.__delattr__(self, item) * return * self._delitem(item) # <<<<<<<<<<<<<< * * def __delitem__(self, key): */ __pyx_t_3 = __pyx_f_4lupa_5_lupa_9_LuaTable__delitem(__pyx_v_self, __pyx_v_item); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 749, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; /* "lupa/_lupa.pyx":739 * return 0 * * def __delattr__(self, item): # <<<<<<<<<<<<<< * assert self._runtime is not None * if isinstance(item, unicode): */ /* function exit code */ __pyx_r = 0; goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_3); __Pyx_XDECREF(__pyx_t_4); __Pyx_XDECREF(__pyx_t_5); __Pyx_XDECREF(__pyx_t_7); __Pyx_AddTraceback("lupa._lupa._LuaTable.__delattr__", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = -1; __pyx_L0:; __Pyx_XDECREF(__pyx_v_item); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "lupa/_lupa.pyx":751 * self._delitem(item) * * def __delitem__(self, key): # <<<<<<<<<<<<<< * self._delitem(key) * */ /* Python wrapper */ static int __pyx_pw_4lupa_5_lupa_9_LuaTable_15__delitem__(PyObject *__pyx_v_self, PyObject *__pyx_v_key); /*proto*/ static int __pyx_pw_4lupa_5_lupa_9_LuaTable_15__delitem__(PyObject *__pyx_v_self, PyObject *__pyx_v_key) { int __pyx_r; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__delitem__ (wrapper)", 0); __pyx_r = __pyx_pf_4lupa_5_lupa_9_LuaTable_14__delitem__(((struct __pyx_obj_4lupa_5_lupa__LuaTable *)__pyx_v_self), ((PyObject *)__pyx_v_key)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static int __pyx_pf_4lupa_5_lupa_9_LuaTable_14__delitem__(struct __pyx_obj_4lupa_5_lupa__LuaTable *__pyx_v_self, PyObject *__pyx_v_key) { int __pyx_r; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; __Pyx_RefNannySetupContext("__delitem__", 0); /* "lupa/_lupa.pyx":752 * * def __delitem__(self, key): * self._delitem(key) # <<<<<<<<<<<<<< * * @cython.final */ __pyx_t_1 = __pyx_f_4lupa_5_lupa_9_LuaTable__delitem(__pyx_v_self, __pyx_v_key); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 752, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; /* "lupa/_lupa.pyx":751 * self._delitem(item) * * def __delitem__(self, key): # <<<<<<<<<<<<<< * self._delitem(key) * */ /* function exit code */ __pyx_r = 0; goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_AddTraceback("lupa._lupa._LuaTable.__delitem__", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = -1; __pyx_L0:; __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "lupa/_lupa.pyx":755 * * @cython.final * cdef _delitem(self, name): # <<<<<<<<<<<<<< * cdef lua_State* L = self._state * lock_runtime(self._runtime) */ static PyObject *__pyx_f_4lupa_5_lupa_9_LuaTable__delitem(struct __pyx_obj_4lupa_5_lupa__LuaTable *__pyx_v_self, PyObject *__pyx_v_name) { lua_State *__pyx_v_L; int __pyx_v_old_top; PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations lua_State *__pyx_t_1; PyObject *__pyx_t_2 = NULL; int __pyx_t_3; struct __pyx_opt_args_4lupa_5_lupa_py_to_lua __pyx_t_4; int __pyx_t_5; char const *__pyx_t_6; PyObject *__pyx_t_7 = NULL; PyObject *__pyx_t_8 = NULL; PyObject *__pyx_t_9 = NULL; PyObject *__pyx_t_10 = NULL; PyObject *__pyx_t_11 = NULL; PyObject *__pyx_t_12 = NULL; __Pyx_RefNannySetupContext("_delitem", 0); /* "lupa/_lupa.pyx":756 * @cython.final * cdef _delitem(self, name): * cdef lua_State* L = self._state # <<<<<<<<<<<<<< * lock_runtime(self._runtime) * old_top = lua.lua_gettop(L) */ __pyx_t_1 = __pyx_v_self->__pyx_base._state; __pyx_v_L = __pyx_t_1; /* "lupa/_lupa.pyx":757 * cdef _delitem(self, name): * cdef lua_State* L = self._state * lock_runtime(self._runtime) # <<<<<<<<<<<<<< * old_top = lua.lua_gettop(L) * try: */ __pyx_t_2 = ((PyObject *)__pyx_v_self->__pyx_base._runtime); __Pyx_INCREF(__pyx_t_2); __pyx_t_3 = __pyx_f_4lupa_5_lupa_lock_runtime(((struct __pyx_obj_4lupa_5_lupa_LuaRuntime *)__pyx_t_2)); if (unlikely(__pyx_t_3 == ((int)-1))) __PYX_ERR(0, 757, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; /* "lupa/_lupa.pyx":758 * cdef lua_State* L = self._state * lock_runtime(self._runtime) * old_top = lua.lua_gettop(L) # <<<<<<<<<<<<<< * try: * self.push_lua_object() */ __pyx_v_old_top = lua_gettop(__pyx_v_L); /* "lupa/_lupa.pyx":759 * lock_runtime(self._runtime) * old_top = lua.lua_gettop(L) * try: # <<<<<<<<<<<<<< * self.push_lua_object() * py_to_lua(self._runtime, L, name, wrap_none=True) */ /*try:*/ { /* "lupa/_lupa.pyx":760 * old_top = lua.lua_gettop(L) * try: * self.push_lua_object() # <<<<<<<<<<<<<< * py_to_lua(self._runtime, L, name, wrap_none=True) * lua.lua_pushnil(L) */ __pyx_t_3 = __pyx_f_4lupa_5_lupa_10_LuaObject_push_lua_object(((struct __pyx_obj_4lupa_5_lupa__LuaObject *)__pyx_v_self)); if (unlikely(__pyx_t_3 == ((int)-1))) __PYX_ERR(0, 760, __pyx_L4_error) /* "lupa/_lupa.pyx":761 * try: * self.push_lua_object() * py_to_lua(self._runtime, L, name, wrap_none=True) # <<<<<<<<<<<<<< * lua.lua_pushnil(L) * lua.lua_settable(L, -3) */ __pyx_t_2 = ((PyObject *)__pyx_v_self->__pyx_base._runtime); __Pyx_INCREF(__pyx_t_2); __pyx_t_4.__pyx_n = 1; __pyx_t_4.wrap_none = 1; __pyx_t_3 = __pyx_f_4lupa_5_lupa_py_to_lua(((struct __pyx_obj_4lupa_5_lupa_LuaRuntime *)__pyx_t_2), __pyx_v_L, __pyx_v_name, &__pyx_t_4); if (unlikely(__pyx_t_3 == ((int)-1))) __PYX_ERR(0, 761, __pyx_L4_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; /* "lupa/_lupa.pyx":762 * self.push_lua_object() * py_to_lua(self._runtime, L, name, wrap_none=True) * lua.lua_pushnil(L) # <<<<<<<<<<<<<< * lua.lua_settable(L, -3) * finally: */ lua_pushnil(__pyx_v_L); /* "lupa/_lupa.pyx":763 * py_to_lua(self._runtime, L, name, wrap_none=True) * lua.lua_pushnil(L) * lua.lua_settable(L, -3) # <<<<<<<<<<<<<< * finally: * lua.lua_settop(L, old_top) */ lua_settable(__pyx_v_L, -3); } /* "lupa/_lupa.pyx":765 * lua.lua_settable(L, -3) * finally: * lua.lua_settop(L, old_top) # <<<<<<<<<<<<<< * unlock_runtime(self._runtime) * */ /*finally:*/ { /*normal exit:*/{ lua_settop(__pyx_v_L, __pyx_v_old_top); /* "lupa/_lupa.pyx":766 * finally: * lua.lua_settop(L, old_top) * unlock_runtime(self._runtime) # <<<<<<<<<<<<<< * * */ __pyx_t_2 = ((PyObject *)__pyx_v_self->__pyx_base._runtime); __Pyx_INCREF(__pyx_t_2); __pyx_f_4lupa_5_lupa_unlock_runtime(((struct __pyx_obj_4lupa_5_lupa_LuaRuntime *)__pyx_t_2)); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; goto __pyx_L5; } __pyx_L4_error:; /*exception exit:*/{ __Pyx_PyThreadState_declare __Pyx_PyThreadState_assign __pyx_t_7 = 0; __pyx_t_8 = 0; __pyx_t_9 = 0; __pyx_t_10 = 0; __pyx_t_11 = 0; __pyx_t_12 = 0; __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; if (PY_MAJOR_VERSION >= 3) __Pyx_ExceptionSwap(&__pyx_t_10, &__pyx_t_11, &__pyx_t_12); if ((PY_MAJOR_VERSION < 3) || unlikely(__Pyx_GetException(&__pyx_t_7, &__pyx_t_8, &__pyx_t_9) < 0)) __Pyx_ErrFetch(&__pyx_t_7, &__pyx_t_8, &__pyx_t_9); __Pyx_XGOTREF(__pyx_t_7); __Pyx_XGOTREF(__pyx_t_8); __Pyx_XGOTREF(__pyx_t_9); __Pyx_XGOTREF(__pyx_t_10); __Pyx_XGOTREF(__pyx_t_11); __Pyx_XGOTREF(__pyx_t_12); __pyx_t_3 = __pyx_lineno; __pyx_t_5 = __pyx_clineno; __pyx_t_6 = __pyx_filename; { /* "lupa/_lupa.pyx":765 * lua.lua_settable(L, -3) * finally: * lua.lua_settop(L, old_top) # <<<<<<<<<<<<<< * unlock_runtime(self._runtime) * */ lua_settop(__pyx_v_L, __pyx_v_old_top); /* "lupa/_lupa.pyx":766 * finally: * lua.lua_settop(L, old_top) * unlock_runtime(self._runtime) # <<<<<<<<<<<<<< * * */ __pyx_t_2 = ((PyObject *)__pyx_v_self->__pyx_base._runtime); __Pyx_INCREF(__pyx_t_2); __pyx_f_4lupa_5_lupa_unlock_runtime(((struct __pyx_obj_4lupa_5_lupa_LuaRuntime *)__pyx_t_2)); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; } if (PY_MAJOR_VERSION >= 3) { __Pyx_XGIVEREF(__pyx_t_10); __Pyx_XGIVEREF(__pyx_t_11); __Pyx_XGIVEREF(__pyx_t_12); __Pyx_ExceptionReset(__pyx_t_10, __pyx_t_11, __pyx_t_12); } __Pyx_XGIVEREF(__pyx_t_7); __Pyx_XGIVEREF(__pyx_t_8); __Pyx_XGIVEREF(__pyx_t_9); __Pyx_ErrRestore(__pyx_t_7, __pyx_t_8, __pyx_t_9); __pyx_t_7 = 0; __pyx_t_8 = 0; __pyx_t_9 = 0; __pyx_t_10 = 0; __pyx_t_11 = 0; __pyx_t_12 = 0; __pyx_lineno = __pyx_t_3; __pyx_clineno = __pyx_t_5; __pyx_filename = __pyx_t_6; goto __pyx_L1_error; } __pyx_L5:; } /* "lupa/_lupa.pyx":755 * * @cython.final * cdef _delitem(self, name): # <<<<<<<<<<<<<< * cdef lua_State* L = self._state * lock_runtime(self._runtime) */ /* function exit code */ __pyx_r = Py_None; __Pyx_INCREF(Py_None); goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_2); __Pyx_AddTraceback("lupa._lupa._LuaTable._delitem", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = 0; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "(tree fragment)":1 * def __reduce_cython__(self): # <<<<<<<<<<<<<< * raise TypeError("self._state cannot be converted to a Python object for pickling") * def __setstate_cython__(self, __pyx_state): */ /* Python wrapper */ static PyObject *__pyx_pw_4lupa_5_lupa_9_LuaTable_17__reduce_cython__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ static char __pyx_doc_4lupa_5_lupa_9_LuaTable_16__reduce_cython__[] = "_LuaTable.__reduce_cython__(self)"; static PyMethodDef __pyx_mdef_4lupa_5_lupa_9_LuaTable_17__reduce_cython__ = {"__reduce_cython__", (PyCFunction)__pyx_pw_4lupa_5_lupa_9_LuaTable_17__reduce_cython__, METH_NOARGS, __pyx_doc_4lupa_5_lupa_9_LuaTable_16__reduce_cython__}; static PyObject *__pyx_pw_4lupa_5_lupa_9_LuaTable_17__reduce_cython__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__reduce_cython__ (wrapper)", 0); __pyx_r = __pyx_pf_4lupa_5_lupa_9_LuaTable_16__reduce_cython__(((struct __pyx_obj_4lupa_5_lupa__LuaTable *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_4lupa_5_lupa_9_LuaTable_16__reduce_cython__(CYTHON_UNUSED struct __pyx_obj_4lupa_5_lupa__LuaTable *__pyx_v_self) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; __Pyx_RefNannySetupContext("__reduce_cython__", 0); /* "(tree fragment)":2 * def __reduce_cython__(self): * raise TypeError("self._state cannot be converted to a Python object for pickling") # <<<<<<<<<<<<<< * def __setstate_cython__(self, __pyx_state): * raise TypeError("self._state cannot be converted to a Python object for pickling") */ __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__26, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 2, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_Raise(__pyx_t_1, 0, 0, 0); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __PYX_ERR(2, 2, __pyx_L1_error) /* "(tree fragment)":1 * def __reduce_cython__(self): # <<<<<<<<<<<<<< * raise TypeError("self._state cannot be converted to a Python object for pickling") * def __setstate_cython__(self, __pyx_state): */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_AddTraceback("lupa._lupa._LuaTable.__reduce_cython__", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "(tree fragment)":3 * def __reduce_cython__(self): * raise TypeError("self._state cannot be converted to a Python object for pickling") * def __setstate_cython__(self, __pyx_state): # <<<<<<<<<<<<<< * raise TypeError("self._state cannot be converted to a Python object for pickling") */ /* Python wrapper */ static PyObject *__pyx_pw_4lupa_5_lupa_9_LuaTable_19__setstate_cython__(PyObject *__pyx_v_self, PyObject *__pyx_v___pyx_state); /*proto*/ static char __pyx_doc_4lupa_5_lupa_9_LuaTable_18__setstate_cython__[] = "_LuaTable.__setstate_cython__(self, __pyx_state)"; static PyMethodDef __pyx_mdef_4lupa_5_lupa_9_LuaTable_19__setstate_cython__ = {"__setstate_cython__", (PyCFunction)__pyx_pw_4lupa_5_lupa_9_LuaTable_19__setstate_cython__, METH_O, __pyx_doc_4lupa_5_lupa_9_LuaTable_18__setstate_cython__}; static PyObject *__pyx_pw_4lupa_5_lupa_9_LuaTable_19__setstate_cython__(PyObject *__pyx_v_self, PyObject *__pyx_v___pyx_state) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__setstate_cython__ (wrapper)", 0); __pyx_r = __pyx_pf_4lupa_5_lupa_9_LuaTable_18__setstate_cython__(((struct __pyx_obj_4lupa_5_lupa__LuaTable *)__pyx_v_self), ((PyObject *)__pyx_v___pyx_state)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_4lupa_5_lupa_9_LuaTable_18__setstate_cython__(CYTHON_UNUSED struct __pyx_obj_4lupa_5_lupa__LuaTable *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v___pyx_state) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; __Pyx_RefNannySetupContext("__setstate_cython__", 0); /* "(tree fragment)":4 * raise TypeError("self._state cannot be converted to a Python object for pickling") * def __setstate_cython__(self, __pyx_state): * raise TypeError("self._state cannot be converted to a Python object for pickling") # <<<<<<<<<<<<<< */ __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__27, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 4, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_Raise(__pyx_t_1, 0, 0, 0); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __PYX_ERR(2, 4, __pyx_L1_error) /* "(tree fragment)":3 * def __reduce_cython__(self): * raise TypeError("self._state cannot be converted to a Python object for pickling") * def __setstate_cython__(self, __pyx_state): # <<<<<<<<<<<<<< * raise TypeError("self._state cannot be converted to a Python object for pickling") */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_AddTraceback("lupa._lupa._LuaTable.__setstate_cython__", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "lupa/_lupa.pyx":769 * * * cdef _LuaTable new_lua_table(LuaRuntime runtime, lua_State* L, int n): # <<<<<<<<<<<<<< * cdef _LuaTable obj = _LuaTable.__new__(_LuaTable) * init_lua_object(obj, runtime, L, n) */ static struct __pyx_obj_4lupa_5_lupa__LuaTable *__pyx_f_4lupa_5_lupa_new_lua_table(struct __pyx_obj_4lupa_5_lupa_LuaRuntime *__pyx_v_runtime, lua_State *__pyx_v_L, int __pyx_v_n) { struct __pyx_obj_4lupa_5_lupa__LuaTable *__pyx_v_obj = 0; struct __pyx_obj_4lupa_5_lupa__LuaTable *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; __Pyx_RefNannySetupContext("new_lua_table", 0); /* "lupa/_lupa.pyx":770 * * cdef _LuaTable new_lua_table(LuaRuntime runtime, lua_State* L, int n): * cdef _LuaTable obj = _LuaTable.__new__(_LuaTable) # <<<<<<<<<<<<<< * init_lua_object(obj, runtime, L, n) * return obj */ __pyx_t_1 = __pyx_tp_new_4lupa_5_lupa__LuaTable(((PyTypeObject *)__pyx_ptype_4lupa_5_lupa__LuaTable), __pyx_empty_tuple, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 770, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); if (!(likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_4lupa_5_lupa__LuaTable)))) __PYX_ERR(0, 770, __pyx_L1_error) __pyx_v_obj = ((struct __pyx_obj_4lupa_5_lupa__LuaTable *)__pyx_t_1); __pyx_t_1 = 0; /* "lupa/_lupa.pyx":771 * cdef _LuaTable new_lua_table(LuaRuntime runtime, lua_State* L, int n): * cdef _LuaTable obj = _LuaTable.__new__(_LuaTable) * init_lua_object(obj, runtime, L, n) # <<<<<<<<<<<<<< * return obj * */ __pyx_f_4lupa_5_lupa_init_lua_object(((struct __pyx_obj_4lupa_5_lupa__LuaObject *)__pyx_v_obj), __pyx_v_runtime, __pyx_v_L, __pyx_v_n); /* "lupa/_lupa.pyx":772 * cdef _LuaTable obj = _LuaTable.__new__(_LuaTable) * init_lua_object(obj, runtime, L, n) * return obj # <<<<<<<<<<<<<< * * */ __Pyx_XDECREF(((PyObject *)__pyx_r)); __Pyx_INCREF(((PyObject *)__pyx_v_obj)); __pyx_r = __pyx_v_obj; goto __pyx_L0; /* "lupa/_lupa.pyx":769 * * * cdef _LuaTable new_lua_table(LuaRuntime runtime, lua_State* L, int n): # <<<<<<<<<<<<<< * cdef _LuaTable obj = _LuaTable.__new__(_LuaTable) * init_lua_object(obj, runtime, L, n) */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_AddTraceback("lupa._lupa.new_lua_table", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = 0; __pyx_L0:; __Pyx_XDECREF((PyObject *)__pyx_v_obj); __Pyx_XGIVEREF((PyObject *)__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "lupa/_lupa.pyx":780 * """A Lua function (which may become a coroutine). * """ * def coroutine(self, *args): # <<<<<<<<<<<<<< * """Create a Lua coroutine from a Lua function and call it with * the passed parameters to start it up. */ /* Python wrapper */ static PyObject *__pyx_pw_4lupa_5_lupa_12_LuaFunction_1coroutine(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ static char __pyx_doc_4lupa_5_lupa_12_LuaFunction_coroutine[] = "_LuaFunction.coroutine(self, *args)\nCreate a Lua coroutine from a Lua function and call it with\n the passed parameters to start it up.\n "; static PyMethodDef __pyx_mdef_4lupa_5_lupa_12_LuaFunction_1coroutine = {"coroutine", (PyCFunction)__pyx_pw_4lupa_5_lupa_12_LuaFunction_1coroutine, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4lupa_5_lupa_12_LuaFunction_coroutine}; static PyObject *__pyx_pw_4lupa_5_lupa_12_LuaFunction_1coroutine(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { PyObject *__pyx_v_args = 0; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("coroutine (wrapper)", 0); if (unlikely(__pyx_kwds) && unlikely(PyDict_Size(__pyx_kwds) > 0) && unlikely(!__Pyx_CheckKeywordStrings(__pyx_kwds, "coroutine", 0))) return NULL; __Pyx_INCREF(__pyx_args); __pyx_v_args = __pyx_args; __pyx_r = __pyx_pf_4lupa_5_lupa_12_LuaFunction_coroutine(((struct __pyx_obj_4lupa_5_lupa__LuaFunction *)__pyx_v_self), __pyx_v_args); /* function exit code */ __Pyx_XDECREF(__pyx_v_args); __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_4lupa_5_lupa_12_LuaFunction_coroutine(struct __pyx_obj_4lupa_5_lupa__LuaFunction *__pyx_v_self, PyObject *__pyx_v_args) { lua_State *__pyx_v_L; lua_State *__pyx_v_co; struct __pyx_obj_4lupa_5_lupa__LuaThread *__pyx_v_thread = 0; int __pyx_v_old_top; PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations int __pyx_t_1; lua_State *__pyx_t_2; PyObject *__pyx_t_3 = NULL; int __pyx_t_4; int __pyx_t_5; PyObject *__pyx_t_6 = NULL; int __pyx_t_7; char const *__pyx_t_8; PyObject *__pyx_t_9 = NULL; PyObject *__pyx_t_10 = NULL; PyObject *__pyx_t_11 = NULL; PyObject *__pyx_t_12 = NULL; PyObject *__pyx_t_13 = NULL; PyObject *__pyx_t_14 = NULL; __Pyx_RefNannySetupContext("coroutine", 0); /* "lupa/_lupa.pyx":784 * the passed parameters to start it up. * """ * assert self._runtime is not None # <<<<<<<<<<<<<< * cdef lua_State* L = self._state * cdef lua_State* co */ #ifndef CYTHON_WITHOUT_ASSERTIONS if (unlikely(!Py_OptimizeFlag)) { __pyx_t_1 = (((PyObject *)__pyx_v_self->__pyx_base._runtime) != Py_None); if (unlikely(!(__pyx_t_1 != 0))) { PyErr_SetNone(PyExc_AssertionError); __PYX_ERR(0, 784, __pyx_L1_error) } } #endif /* "lupa/_lupa.pyx":785 * """ * assert self._runtime is not None * cdef lua_State* L = self._state # <<<<<<<<<<<<<< * cdef lua_State* co * cdef _LuaThread thread */ __pyx_t_2 = __pyx_v_self->__pyx_base._state; __pyx_v_L = __pyx_t_2; /* "lupa/_lupa.pyx":788 * cdef lua_State* co * cdef _LuaThread thread * lock_runtime(self._runtime) # <<<<<<<<<<<<<< * old_top = lua.lua_gettop(L) * try: */ __pyx_t_3 = ((PyObject *)__pyx_v_self->__pyx_base._runtime); __Pyx_INCREF(__pyx_t_3); __pyx_t_4 = __pyx_f_4lupa_5_lupa_lock_runtime(((struct __pyx_obj_4lupa_5_lupa_LuaRuntime *)__pyx_t_3)); if (unlikely(__pyx_t_4 == ((int)-1))) __PYX_ERR(0, 788, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; /* "lupa/_lupa.pyx":789 * cdef _LuaThread thread * lock_runtime(self._runtime) * old_top = lua.lua_gettop(L) # <<<<<<<<<<<<<< * try: * self.push_lua_object() */ __pyx_v_old_top = lua_gettop(__pyx_v_L); /* "lupa/_lupa.pyx":790 * lock_runtime(self._runtime) * old_top = lua.lua_gettop(L) * try: # <<<<<<<<<<<<<< * self.push_lua_object() * if not lua.lua_isfunction(L, -1) or lua.lua_iscfunction(L, -1): */ /*try:*/ { /* "lupa/_lupa.pyx":791 * old_top = lua.lua_gettop(L) * try: * self.push_lua_object() # <<<<<<<<<<<<<< * if not lua.lua_isfunction(L, -1) or lua.lua_iscfunction(L, -1): * raise TypeError("Lua object is not a function") */ __pyx_t_4 = __pyx_f_4lupa_5_lupa_10_LuaObject_push_lua_object(((struct __pyx_obj_4lupa_5_lupa__LuaObject *)__pyx_v_self)); if (unlikely(__pyx_t_4 == ((int)-1))) __PYX_ERR(0, 791, __pyx_L4_error) /* "lupa/_lupa.pyx":792 * try: * self.push_lua_object() * if not lua.lua_isfunction(L, -1) or lua.lua_iscfunction(L, -1): # <<<<<<<<<<<<<< * raise TypeError("Lua object is not a function") * # create thread stack and push the function on it */ __pyx_t_5 = ((!(lua_isfunction(__pyx_v_L, -1) != 0)) != 0); if (!__pyx_t_5) { } else { __pyx_t_1 = __pyx_t_5; goto __pyx_L7_bool_binop_done; } __pyx_t_5 = (lua_iscfunction(__pyx_v_L, -1) != 0); __pyx_t_1 = __pyx_t_5; __pyx_L7_bool_binop_done:; if (__pyx_t_1) { /* "lupa/_lupa.pyx":793 * self.push_lua_object() * if not lua.lua_isfunction(L, -1) or lua.lua_iscfunction(L, -1): * raise TypeError("Lua object is not a function") # <<<<<<<<<<<<<< * # create thread stack and push the function on it * co = lua.lua_newthread(L) */ __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__28, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 793, __pyx_L4_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_Raise(__pyx_t_3, 0, 0, 0); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __PYX_ERR(0, 793, __pyx_L4_error) /* "lupa/_lupa.pyx":792 * try: * self.push_lua_object() * if not lua.lua_isfunction(L, -1) or lua.lua_iscfunction(L, -1): # <<<<<<<<<<<<<< * raise TypeError("Lua object is not a function") * # create thread stack and push the function on it */ } /* "lupa/_lupa.pyx":795 * raise TypeError("Lua object is not a function") * # create thread stack and push the function on it * co = lua.lua_newthread(L) # <<<<<<<<<<<<<< * lua.lua_pushvalue(L, 1) * lua.lua_xmove(L, co, 1) */ __pyx_v_co = lua_newthread(__pyx_v_L); /* "lupa/_lupa.pyx":796 * # create thread stack and push the function on it * co = lua.lua_newthread(L) * lua.lua_pushvalue(L, 1) # <<<<<<<<<<<<<< * lua.lua_xmove(L, co, 1) * # create the coroutine object and initialise it */ lua_pushvalue(__pyx_v_L, 1); /* "lupa/_lupa.pyx":797 * co = lua.lua_newthread(L) * lua.lua_pushvalue(L, 1) * lua.lua_xmove(L, co, 1) # <<<<<<<<<<<<<< * # create the coroutine object and initialise it * assert lua.lua_isthread(L, -1) */ lua_xmove(__pyx_v_L, __pyx_v_co, 1); /* "lupa/_lupa.pyx":799 * lua.lua_xmove(L, co, 1) * # create the coroutine object and initialise it * assert lua.lua_isthread(L, -1) # <<<<<<<<<<<<<< * thread = new_lua_thread(self._runtime, L, -1) * thread._arguments = args # always a tuple, not None ! */ #ifndef CYTHON_WITHOUT_ASSERTIONS if (unlikely(!Py_OptimizeFlag)) { if (unlikely(!(lua_isthread(__pyx_v_L, -1) != 0))) { PyErr_SetNone(PyExc_AssertionError); __PYX_ERR(0, 799, __pyx_L4_error) } } #endif /* "lupa/_lupa.pyx":800 * # create the coroutine object and initialise it * assert lua.lua_isthread(L, -1) * thread = new_lua_thread(self._runtime, L, -1) # <<<<<<<<<<<<<< * thread._arguments = args # always a tuple, not None ! * return thread */ __pyx_t_3 = ((PyObject *)__pyx_v_self->__pyx_base._runtime); __Pyx_INCREF(__pyx_t_3); __pyx_t_6 = ((PyObject *)__pyx_f_4lupa_5_lupa_new_lua_thread(((struct __pyx_obj_4lupa_5_lupa_LuaRuntime *)__pyx_t_3), __pyx_v_L, -1)); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 800, __pyx_L4_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_v_thread = ((struct __pyx_obj_4lupa_5_lupa__LuaThread *)__pyx_t_6); __pyx_t_6 = 0; /* "lupa/_lupa.pyx":801 * assert lua.lua_isthread(L, -1) * thread = new_lua_thread(self._runtime, L, -1) * thread._arguments = args # always a tuple, not None ! # <<<<<<<<<<<<<< * return thread * finally: */ __Pyx_INCREF(__pyx_v_args); __Pyx_GIVEREF(__pyx_v_args); __Pyx_GOTREF(__pyx_v_thread->_arguments); __Pyx_DECREF(__pyx_v_thread->_arguments); __pyx_v_thread->_arguments = __pyx_v_args; /* "lupa/_lupa.pyx":802 * thread = new_lua_thread(self._runtime, L, -1) * thread._arguments = args # always a tuple, not None ! * return thread # <<<<<<<<<<<<<< * finally: * lua.lua_settop(L, old_top) */ __Pyx_XDECREF(__pyx_r); __Pyx_INCREF(((PyObject *)__pyx_v_thread)); __pyx_r = ((PyObject *)__pyx_v_thread); goto __pyx_L3_return; } /* "lupa/_lupa.pyx":804 * return thread * finally: * lua.lua_settop(L, old_top) # <<<<<<<<<<<<<< * unlock_runtime(self._runtime) * */ /*finally:*/ { __pyx_L4_error:; /*exception exit:*/{ __Pyx_PyThreadState_declare __Pyx_PyThreadState_assign __pyx_t_9 = 0; __pyx_t_10 = 0; __pyx_t_11 = 0; __pyx_t_12 = 0; __pyx_t_13 = 0; __pyx_t_14 = 0; __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; if (PY_MAJOR_VERSION >= 3) __Pyx_ExceptionSwap(&__pyx_t_12, &__pyx_t_13, &__pyx_t_14); if ((PY_MAJOR_VERSION < 3) || unlikely(__Pyx_GetException(&__pyx_t_9, &__pyx_t_10, &__pyx_t_11) < 0)) __Pyx_ErrFetch(&__pyx_t_9, &__pyx_t_10, &__pyx_t_11); __Pyx_XGOTREF(__pyx_t_9); __Pyx_XGOTREF(__pyx_t_10); __Pyx_XGOTREF(__pyx_t_11); __Pyx_XGOTREF(__pyx_t_12); __Pyx_XGOTREF(__pyx_t_13); __Pyx_XGOTREF(__pyx_t_14); __pyx_t_4 = __pyx_lineno; __pyx_t_7 = __pyx_clineno; __pyx_t_8 = __pyx_filename; { lua_settop(__pyx_v_L, __pyx_v_old_top); /* "lupa/_lupa.pyx":805 * finally: * lua.lua_settop(L, old_top) * unlock_runtime(self._runtime) # <<<<<<<<<<<<<< * * cdef _LuaFunction new_lua_function(LuaRuntime runtime, lua_State* L, int n): */ __pyx_t_6 = ((PyObject *)__pyx_v_self->__pyx_base._runtime); __Pyx_INCREF(__pyx_t_6); __pyx_f_4lupa_5_lupa_unlock_runtime(((struct __pyx_obj_4lupa_5_lupa_LuaRuntime *)__pyx_t_6)); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; } if (PY_MAJOR_VERSION >= 3) { __Pyx_XGIVEREF(__pyx_t_12); __Pyx_XGIVEREF(__pyx_t_13); __Pyx_XGIVEREF(__pyx_t_14); __Pyx_ExceptionReset(__pyx_t_12, __pyx_t_13, __pyx_t_14); } __Pyx_XGIVEREF(__pyx_t_9); __Pyx_XGIVEREF(__pyx_t_10); __Pyx_XGIVEREF(__pyx_t_11); __Pyx_ErrRestore(__pyx_t_9, __pyx_t_10, __pyx_t_11); __pyx_t_9 = 0; __pyx_t_10 = 0; __pyx_t_11 = 0; __pyx_t_12 = 0; __pyx_t_13 = 0; __pyx_t_14 = 0; __pyx_lineno = __pyx_t_4; __pyx_clineno = __pyx_t_7; __pyx_filename = __pyx_t_8; goto __pyx_L1_error; } __pyx_L3_return: { __pyx_t_14 = __pyx_r; __pyx_r = 0; /* "lupa/_lupa.pyx":804 * return thread * finally: * lua.lua_settop(L, old_top) # <<<<<<<<<<<<<< * unlock_runtime(self._runtime) * */ lua_settop(__pyx_v_L, __pyx_v_old_top); /* "lupa/_lupa.pyx":805 * finally: * lua.lua_settop(L, old_top) * unlock_runtime(self._runtime) # <<<<<<<<<<<<<< * * cdef _LuaFunction new_lua_function(LuaRuntime runtime, lua_State* L, int n): */ __pyx_t_6 = ((PyObject *)__pyx_v_self->__pyx_base._runtime); __Pyx_INCREF(__pyx_t_6); __pyx_f_4lupa_5_lupa_unlock_runtime(((struct __pyx_obj_4lupa_5_lupa_LuaRuntime *)__pyx_t_6)); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __pyx_r = __pyx_t_14; __pyx_t_14 = 0; goto __pyx_L0; } } /* "lupa/_lupa.pyx":780 * """A Lua function (which may become a coroutine). * """ * def coroutine(self, *args): # <<<<<<<<<<<<<< * """Create a Lua coroutine from a Lua function and call it with * the passed parameters to start it up. */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_3); __Pyx_XDECREF(__pyx_t_6); __Pyx_AddTraceback("lupa._lupa._LuaFunction.coroutine", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XDECREF((PyObject *)__pyx_v_thread); __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "(tree fragment)":1 * def __reduce_cython__(self): # <<<<<<<<<<<<<< * raise TypeError("self._state cannot be converted to a Python object for pickling") * def __setstate_cython__(self, __pyx_state): */ /* Python wrapper */ static PyObject *__pyx_pw_4lupa_5_lupa_12_LuaFunction_3__reduce_cython__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ static char __pyx_doc_4lupa_5_lupa_12_LuaFunction_2__reduce_cython__[] = "_LuaFunction.__reduce_cython__(self)"; static PyMethodDef __pyx_mdef_4lupa_5_lupa_12_LuaFunction_3__reduce_cython__ = {"__reduce_cython__", (PyCFunction)__pyx_pw_4lupa_5_lupa_12_LuaFunction_3__reduce_cython__, METH_NOARGS, __pyx_doc_4lupa_5_lupa_12_LuaFunction_2__reduce_cython__}; static PyObject *__pyx_pw_4lupa_5_lupa_12_LuaFunction_3__reduce_cython__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__reduce_cython__ (wrapper)", 0); __pyx_r = __pyx_pf_4lupa_5_lupa_12_LuaFunction_2__reduce_cython__(((struct __pyx_obj_4lupa_5_lupa__LuaFunction *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_4lupa_5_lupa_12_LuaFunction_2__reduce_cython__(CYTHON_UNUSED struct __pyx_obj_4lupa_5_lupa__LuaFunction *__pyx_v_self) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; __Pyx_RefNannySetupContext("__reduce_cython__", 0); /* "(tree fragment)":2 * def __reduce_cython__(self): * raise TypeError("self._state cannot be converted to a Python object for pickling") # <<<<<<<<<<<<<< * def __setstate_cython__(self, __pyx_state): * raise TypeError("self._state cannot be converted to a Python object for pickling") */ __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__29, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 2, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_Raise(__pyx_t_1, 0, 0, 0); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __PYX_ERR(2, 2, __pyx_L1_error) /* "(tree fragment)":1 * def __reduce_cython__(self): # <<<<<<<<<<<<<< * raise TypeError("self._state cannot be converted to a Python object for pickling") * def __setstate_cython__(self, __pyx_state): */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_AddTraceback("lupa._lupa._LuaFunction.__reduce_cython__", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "(tree fragment)":3 * def __reduce_cython__(self): * raise TypeError("self._state cannot be converted to a Python object for pickling") * def __setstate_cython__(self, __pyx_state): # <<<<<<<<<<<<<< * raise TypeError("self._state cannot be converted to a Python object for pickling") */ /* Python wrapper */ static PyObject *__pyx_pw_4lupa_5_lupa_12_LuaFunction_5__setstate_cython__(PyObject *__pyx_v_self, PyObject *__pyx_v___pyx_state); /*proto*/ static char __pyx_doc_4lupa_5_lupa_12_LuaFunction_4__setstate_cython__[] = "_LuaFunction.__setstate_cython__(self, __pyx_state)"; static PyMethodDef __pyx_mdef_4lupa_5_lupa_12_LuaFunction_5__setstate_cython__ = {"__setstate_cython__", (PyCFunction)__pyx_pw_4lupa_5_lupa_12_LuaFunction_5__setstate_cython__, METH_O, __pyx_doc_4lupa_5_lupa_12_LuaFunction_4__setstate_cython__}; static PyObject *__pyx_pw_4lupa_5_lupa_12_LuaFunction_5__setstate_cython__(PyObject *__pyx_v_self, PyObject *__pyx_v___pyx_state) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__setstate_cython__ (wrapper)", 0); __pyx_r = __pyx_pf_4lupa_5_lupa_12_LuaFunction_4__setstate_cython__(((struct __pyx_obj_4lupa_5_lupa__LuaFunction *)__pyx_v_self), ((PyObject *)__pyx_v___pyx_state)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_4lupa_5_lupa_12_LuaFunction_4__setstate_cython__(CYTHON_UNUSED struct __pyx_obj_4lupa_5_lupa__LuaFunction *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v___pyx_state) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; __Pyx_RefNannySetupContext("__setstate_cython__", 0); /* "(tree fragment)":4 * raise TypeError("self._state cannot be converted to a Python object for pickling") * def __setstate_cython__(self, __pyx_state): * raise TypeError("self._state cannot be converted to a Python object for pickling") # <<<<<<<<<<<<<< */ __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__30, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 4, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_Raise(__pyx_t_1, 0, 0, 0); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __PYX_ERR(2, 4, __pyx_L1_error) /* "(tree fragment)":3 * def __reduce_cython__(self): * raise TypeError("self._state cannot be converted to a Python object for pickling") * def __setstate_cython__(self, __pyx_state): # <<<<<<<<<<<<<< * raise TypeError("self._state cannot be converted to a Python object for pickling") */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_AddTraceback("lupa._lupa._LuaFunction.__setstate_cython__", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "lupa/_lupa.pyx":807 * unlock_runtime(self._runtime) * * cdef _LuaFunction new_lua_function(LuaRuntime runtime, lua_State* L, int n): # <<<<<<<<<<<<<< * cdef _LuaFunction obj = _LuaFunction.__new__(_LuaFunction) * init_lua_object(obj, runtime, L, n) */ static struct __pyx_obj_4lupa_5_lupa__LuaFunction *__pyx_f_4lupa_5_lupa_new_lua_function(struct __pyx_obj_4lupa_5_lupa_LuaRuntime *__pyx_v_runtime, lua_State *__pyx_v_L, int __pyx_v_n) { struct __pyx_obj_4lupa_5_lupa__LuaFunction *__pyx_v_obj = 0; struct __pyx_obj_4lupa_5_lupa__LuaFunction *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; __Pyx_RefNannySetupContext("new_lua_function", 0); /* "lupa/_lupa.pyx":808 * * cdef _LuaFunction new_lua_function(LuaRuntime runtime, lua_State* L, int n): * cdef _LuaFunction obj = _LuaFunction.__new__(_LuaFunction) # <<<<<<<<<<<<<< * init_lua_object(obj, runtime, L, n) * return obj */ __pyx_t_1 = __pyx_tp_new_4lupa_5_lupa__LuaFunction(((PyTypeObject *)__pyx_ptype_4lupa_5_lupa__LuaFunction), __pyx_empty_tuple, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 808, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); if (!(likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_4lupa_5_lupa__LuaFunction)))) __PYX_ERR(0, 808, __pyx_L1_error) __pyx_v_obj = ((struct __pyx_obj_4lupa_5_lupa__LuaFunction *)__pyx_t_1); __pyx_t_1 = 0; /* "lupa/_lupa.pyx":809 * cdef _LuaFunction new_lua_function(LuaRuntime runtime, lua_State* L, int n): * cdef _LuaFunction obj = _LuaFunction.__new__(_LuaFunction) * init_lua_object(obj, runtime, L, n) # <<<<<<<<<<<<<< * return obj * */ __pyx_f_4lupa_5_lupa_init_lua_object(((struct __pyx_obj_4lupa_5_lupa__LuaObject *)__pyx_v_obj), __pyx_v_runtime, __pyx_v_L, __pyx_v_n); /* "lupa/_lupa.pyx":810 * cdef _LuaFunction obj = _LuaFunction.__new__(_LuaFunction) * init_lua_object(obj, runtime, L, n) * return obj # <<<<<<<<<<<<<< * * */ __Pyx_XDECREF(((PyObject *)__pyx_r)); __Pyx_INCREF(((PyObject *)__pyx_v_obj)); __pyx_r = __pyx_v_obj; goto __pyx_L0; /* "lupa/_lupa.pyx":807 * unlock_runtime(self._runtime) * * cdef _LuaFunction new_lua_function(LuaRuntime runtime, lua_State* L, int n): # <<<<<<<<<<<<<< * cdef _LuaFunction obj = _LuaFunction.__new__(_LuaFunction) * init_lua_object(obj, runtime, L, n) */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_AddTraceback("lupa._lupa.new_lua_function", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = 0; __pyx_L0:; __Pyx_XDECREF((PyObject *)__pyx_v_obj); __Pyx_XGIVEREF((PyObject *)__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "lupa/_lupa.pyx":819 * """A function that returns a new coroutine when called. * """ * def __call__(self, *args): # <<<<<<<<<<<<<< * return self.coroutine(*args) * */ /* Python wrapper */ static PyObject *__pyx_pw_4lupa_5_lupa_21_LuaCoroutineFunction_1__call__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ static PyObject *__pyx_pw_4lupa_5_lupa_21_LuaCoroutineFunction_1__call__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { PyObject *__pyx_v_args = 0; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__call__ (wrapper)", 0); if (unlikely(__pyx_kwds) && unlikely(PyDict_Size(__pyx_kwds) > 0) && unlikely(!__Pyx_CheckKeywordStrings(__pyx_kwds, "__call__", 0))) return NULL; __Pyx_INCREF(__pyx_args); __pyx_v_args = __pyx_args; __pyx_r = __pyx_pf_4lupa_5_lupa_21_LuaCoroutineFunction___call__(((struct __pyx_obj_4lupa_5_lupa__LuaCoroutineFunction *)__pyx_v_self), __pyx_v_args); /* function exit code */ __Pyx_XDECREF(__pyx_v_args); __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_4lupa_5_lupa_21_LuaCoroutineFunction___call__(struct __pyx_obj_4lupa_5_lupa__LuaCoroutineFunction *__pyx_v_self, PyObject *__pyx_v_args) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; PyObject *__pyx_t_2 = NULL; __Pyx_RefNannySetupContext("__call__", 0); /* "lupa/_lupa.pyx":820 * """ * def __call__(self, *args): * return self.coroutine(*args) # <<<<<<<<<<<<<< * * cdef _LuaCoroutineFunction new_lua_coroutine_function(LuaRuntime runtime, lua_State* L, int n): */ __Pyx_XDECREF(__pyx_r); __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_coroutine); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 820, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_v_args, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 820, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_r = __pyx_t_2; __pyx_t_2 = 0; goto __pyx_L0; /* "lupa/_lupa.pyx":819 * """A function that returns a new coroutine when called. * """ * def __call__(self, *args): # <<<<<<<<<<<<<< * return self.coroutine(*args) * */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_2); __Pyx_AddTraceback("lupa._lupa._LuaCoroutineFunction.__call__", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "(tree fragment)":1 * def __reduce_cython__(self): # <<<<<<<<<<<<<< * raise TypeError("self._state cannot be converted to a Python object for pickling") * def __setstate_cython__(self, __pyx_state): */ /* Python wrapper */ static PyObject *__pyx_pw_4lupa_5_lupa_21_LuaCoroutineFunction_3__reduce_cython__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ static char __pyx_doc_4lupa_5_lupa_21_LuaCoroutineFunction_2__reduce_cython__[] = "_LuaCoroutineFunction.__reduce_cython__(self)"; static PyMethodDef __pyx_mdef_4lupa_5_lupa_21_LuaCoroutineFunction_3__reduce_cython__ = {"__reduce_cython__", (PyCFunction)__pyx_pw_4lupa_5_lupa_21_LuaCoroutineFunction_3__reduce_cython__, METH_NOARGS, __pyx_doc_4lupa_5_lupa_21_LuaCoroutineFunction_2__reduce_cython__}; static PyObject *__pyx_pw_4lupa_5_lupa_21_LuaCoroutineFunction_3__reduce_cython__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__reduce_cython__ (wrapper)", 0); __pyx_r = __pyx_pf_4lupa_5_lupa_21_LuaCoroutineFunction_2__reduce_cython__(((struct __pyx_obj_4lupa_5_lupa__LuaCoroutineFunction *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_4lupa_5_lupa_21_LuaCoroutineFunction_2__reduce_cython__(CYTHON_UNUSED struct __pyx_obj_4lupa_5_lupa__LuaCoroutineFunction *__pyx_v_self) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; __Pyx_RefNannySetupContext("__reduce_cython__", 0); /* "(tree fragment)":2 * def __reduce_cython__(self): * raise TypeError("self._state cannot be converted to a Python object for pickling") # <<<<<<<<<<<<<< * def __setstate_cython__(self, __pyx_state): * raise TypeError("self._state cannot be converted to a Python object for pickling") */ __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__31, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 2, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_Raise(__pyx_t_1, 0, 0, 0); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __PYX_ERR(2, 2, __pyx_L1_error) /* "(tree fragment)":1 * def __reduce_cython__(self): # <<<<<<<<<<<<<< * raise TypeError("self._state cannot be converted to a Python object for pickling") * def __setstate_cython__(self, __pyx_state): */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_AddTraceback("lupa._lupa._LuaCoroutineFunction.__reduce_cython__", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "(tree fragment)":3 * def __reduce_cython__(self): * raise TypeError("self._state cannot be converted to a Python object for pickling") * def __setstate_cython__(self, __pyx_state): # <<<<<<<<<<<<<< * raise TypeError("self._state cannot be converted to a Python object for pickling") */ /* Python wrapper */ static PyObject *__pyx_pw_4lupa_5_lupa_21_LuaCoroutineFunction_5__setstate_cython__(PyObject *__pyx_v_self, PyObject *__pyx_v___pyx_state); /*proto*/ static char __pyx_doc_4lupa_5_lupa_21_LuaCoroutineFunction_4__setstate_cython__[] = "_LuaCoroutineFunction.__setstate_cython__(self, __pyx_state)"; static PyMethodDef __pyx_mdef_4lupa_5_lupa_21_LuaCoroutineFunction_5__setstate_cython__ = {"__setstate_cython__", (PyCFunction)__pyx_pw_4lupa_5_lupa_21_LuaCoroutineFunction_5__setstate_cython__, METH_O, __pyx_doc_4lupa_5_lupa_21_LuaCoroutineFunction_4__setstate_cython__}; static PyObject *__pyx_pw_4lupa_5_lupa_21_LuaCoroutineFunction_5__setstate_cython__(PyObject *__pyx_v_self, PyObject *__pyx_v___pyx_state) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__setstate_cython__ (wrapper)", 0); __pyx_r = __pyx_pf_4lupa_5_lupa_21_LuaCoroutineFunction_4__setstate_cython__(((struct __pyx_obj_4lupa_5_lupa__LuaCoroutineFunction *)__pyx_v_self), ((PyObject *)__pyx_v___pyx_state)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_4lupa_5_lupa_21_LuaCoroutineFunction_4__setstate_cython__(CYTHON_UNUSED struct __pyx_obj_4lupa_5_lupa__LuaCoroutineFunction *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v___pyx_state) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; __Pyx_RefNannySetupContext("__setstate_cython__", 0); /* "(tree fragment)":4 * raise TypeError("self._state cannot be converted to a Python object for pickling") * def __setstate_cython__(self, __pyx_state): * raise TypeError("self._state cannot be converted to a Python object for pickling") # <<<<<<<<<<<<<< */ __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__32, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 4, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_Raise(__pyx_t_1, 0, 0, 0); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __PYX_ERR(2, 4, __pyx_L1_error) /* "(tree fragment)":3 * def __reduce_cython__(self): * raise TypeError("self._state cannot be converted to a Python object for pickling") * def __setstate_cython__(self, __pyx_state): # <<<<<<<<<<<<<< * raise TypeError("self._state cannot be converted to a Python object for pickling") */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_AddTraceback("lupa._lupa._LuaCoroutineFunction.__setstate_cython__", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "lupa/_lupa.pyx":822 * return self.coroutine(*args) * * cdef _LuaCoroutineFunction new_lua_coroutine_function(LuaRuntime runtime, lua_State* L, int n): # <<<<<<<<<<<<<< * cdef _LuaCoroutineFunction obj = _LuaCoroutineFunction.__new__(_LuaCoroutineFunction) * init_lua_object(obj, runtime, L, n) */ static struct __pyx_obj_4lupa_5_lupa__LuaCoroutineFunction *__pyx_f_4lupa_5_lupa_new_lua_coroutine_function(struct __pyx_obj_4lupa_5_lupa_LuaRuntime *__pyx_v_runtime, lua_State *__pyx_v_L, int __pyx_v_n) { struct __pyx_obj_4lupa_5_lupa__LuaCoroutineFunction *__pyx_v_obj = 0; struct __pyx_obj_4lupa_5_lupa__LuaCoroutineFunction *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; __Pyx_RefNannySetupContext("new_lua_coroutine_function", 0); /* "lupa/_lupa.pyx":823 * * cdef _LuaCoroutineFunction new_lua_coroutine_function(LuaRuntime runtime, lua_State* L, int n): * cdef _LuaCoroutineFunction obj = _LuaCoroutineFunction.__new__(_LuaCoroutineFunction) # <<<<<<<<<<<<<< * init_lua_object(obj, runtime, L, n) * return obj */ __pyx_t_1 = __pyx_tp_new_4lupa_5_lupa__LuaCoroutineFunction(((PyTypeObject *)__pyx_ptype_4lupa_5_lupa__LuaCoroutineFunction), __pyx_empty_tuple, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 823, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); if (!(likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_4lupa_5_lupa__LuaCoroutineFunction)))) __PYX_ERR(0, 823, __pyx_L1_error) __pyx_v_obj = ((struct __pyx_obj_4lupa_5_lupa__LuaCoroutineFunction *)__pyx_t_1); __pyx_t_1 = 0; /* "lupa/_lupa.pyx":824 * cdef _LuaCoroutineFunction new_lua_coroutine_function(LuaRuntime runtime, lua_State* L, int n): * cdef _LuaCoroutineFunction obj = _LuaCoroutineFunction.__new__(_LuaCoroutineFunction) * init_lua_object(obj, runtime, L, n) # <<<<<<<<<<<<<< * return obj * */ __pyx_f_4lupa_5_lupa_init_lua_object(((struct __pyx_obj_4lupa_5_lupa__LuaObject *)__pyx_v_obj), __pyx_v_runtime, __pyx_v_L, __pyx_v_n); /* "lupa/_lupa.pyx":825 * cdef _LuaCoroutineFunction obj = _LuaCoroutineFunction.__new__(_LuaCoroutineFunction) * init_lua_object(obj, runtime, L, n) * return obj # <<<<<<<<<<<<<< * * */ __Pyx_XDECREF(((PyObject *)__pyx_r)); __Pyx_INCREF(((PyObject *)__pyx_v_obj)); __pyx_r = __pyx_v_obj; goto __pyx_L0; /* "lupa/_lupa.pyx":822 * return self.coroutine(*args) * * cdef _LuaCoroutineFunction new_lua_coroutine_function(LuaRuntime runtime, lua_State* L, int n): # <<<<<<<<<<<<<< * cdef _LuaCoroutineFunction obj = _LuaCoroutineFunction.__new__(_LuaCoroutineFunction) * init_lua_object(obj, runtime, L, n) */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_AddTraceback("lupa._lupa.new_lua_coroutine_function", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = 0; __pyx_L0:; __Pyx_XDECREF((PyObject *)__pyx_v_obj); __Pyx_XGIVEREF((PyObject *)__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "lupa/_lupa.pyx":836 * cdef lua_State* _co_state * cdef tuple _arguments * def __iter__(self): # <<<<<<<<<<<<<< * return self * */ /* Python wrapper */ static PyObject *__pyx_pw_4lupa_5_lupa_10_LuaThread_1__iter__(PyObject *__pyx_v_self); /*proto*/ static PyObject *__pyx_pw_4lupa_5_lupa_10_LuaThread_1__iter__(PyObject *__pyx_v_self) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__iter__ (wrapper)", 0); __pyx_r = __pyx_pf_4lupa_5_lupa_10_LuaThread___iter__(((struct __pyx_obj_4lupa_5_lupa__LuaThread *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_4lupa_5_lupa_10_LuaThread___iter__(struct __pyx_obj_4lupa_5_lupa__LuaThread *__pyx_v_self) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__iter__", 0); /* "lupa/_lupa.pyx":837 * cdef tuple _arguments * def __iter__(self): * return self # <<<<<<<<<<<<<< * * def __next__(self): */ __Pyx_XDECREF(__pyx_r); __Pyx_INCREF(((PyObject *)__pyx_v_self)); __pyx_r = ((PyObject *)__pyx_v_self); goto __pyx_L0; /* "lupa/_lupa.pyx":836 * cdef lua_State* _co_state * cdef tuple _arguments * def __iter__(self): # <<<<<<<<<<<<<< * return self * */ /* function exit code */ __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "lupa/_lupa.pyx":839 * return self * * def __next__(self): # <<<<<<<<<<<<<< * assert self._runtime is not None * cdef tuple args = self._arguments */ /* Python wrapper */ static PyObject *__pyx_pw_4lupa_5_lupa_10_LuaThread_3__next__(PyObject *__pyx_v_self); /*proto*/ static PyObject *__pyx_pw_4lupa_5_lupa_10_LuaThread_3__next__(PyObject *__pyx_v_self) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__next__ (wrapper)", 0); __pyx_r = __pyx_pf_4lupa_5_lupa_10_LuaThread_2__next__(((struct __pyx_obj_4lupa_5_lupa__LuaThread *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_4lupa_5_lupa_10_LuaThread_2__next__(struct __pyx_obj_4lupa_5_lupa__LuaThread *__pyx_v_self) { PyObject *__pyx_v_args = 0; PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations int __pyx_t_1; PyObject *__pyx_t_2 = NULL; int __pyx_t_3; __Pyx_RefNannySetupContext("__next__", 0); /* "lupa/_lupa.pyx":840 * * def __next__(self): * assert self._runtime is not None # <<<<<<<<<<<<<< * cdef tuple args = self._arguments * if args is not None: */ #ifndef CYTHON_WITHOUT_ASSERTIONS if (unlikely(!Py_OptimizeFlag)) { __pyx_t_1 = (((PyObject *)__pyx_v_self->__pyx_base._runtime) != Py_None); if (unlikely(!(__pyx_t_1 != 0))) { PyErr_SetNone(PyExc_AssertionError); __PYX_ERR(0, 840, __pyx_L1_error) } } #endif /* "lupa/_lupa.pyx":841 * def __next__(self): * assert self._runtime is not None * cdef tuple args = self._arguments # <<<<<<<<<<<<<< * if args is not None: * self._arguments = None */ __pyx_t_2 = __pyx_v_self->_arguments; __Pyx_INCREF(__pyx_t_2); __pyx_v_args = ((PyObject*)__pyx_t_2); __pyx_t_2 = 0; /* "lupa/_lupa.pyx":842 * assert self._runtime is not None * cdef tuple args = self._arguments * if args is not None: # <<<<<<<<<<<<<< * self._arguments = None * return resume_lua_thread(self, args) */ __pyx_t_1 = (__pyx_v_args != ((PyObject*)Py_None)); __pyx_t_3 = (__pyx_t_1 != 0); if (__pyx_t_3) { /* "lupa/_lupa.pyx":843 * cdef tuple args = self._arguments * if args is not None: * self._arguments = None # <<<<<<<<<<<<<< * return resume_lua_thread(self, args) * */ __Pyx_INCREF(Py_None); __Pyx_GIVEREF(Py_None); __Pyx_GOTREF(__pyx_v_self->_arguments); __Pyx_DECREF(__pyx_v_self->_arguments); __pyx_v_self->_arguments = ((PyObject*)Py_None); /* "lupa/_lupa.pyx":842 * assert self._runtime is not None * cdef tuple args = self._arguments * if args is not None: # <<<<<<<<<<<<<< * self._arguments = None * return resume_lua_thread(self, args) */ } /* "lupa/_lupa.pyx":844 * if args is not None: * self._arguments = None * return resume_lua_thread(self, args) # <<<<<<<<<<<<<< * * def send(self, value): */ __Pyx_XDECREF(__pyx_r); __pyx_t_2 = __pyx_f_4lupa_5_lupa_resume_lua_thread(__pyx_v_self, __pyx_v_args); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 844, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_r = __pyx_t_2; __pyx_t_2 = 0; goto __pyx_L0; /* "lupa/_lupa.pyx":839 * return self * * def __next__(self): # <<<<<<<<<<<<<< * assert self._runtime is not None * cdef tuple args = self._arguments */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_2); __Pyx_AddTraceback("lupa._lupa._LuaThread.__next__", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XDECREF(__pyx_v_args); __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "lupa/_lupa.pyx":846 * return resume_lua_thread(self, args) * * def send(self, value): # <<<<<<<<<<<<<< * """Send a value into the coroutine. If the value is a tuple, * send the unpacked elements. */ /* Python wrapper */ static PyObject *__pyx_pw_4lupa_5_lupa_10_LuaThread_5send(PyObject *__pyx_v_self, PyObject *__pyx_v_value); /*proto*/ static char __pyx_doc_4lupa_5_lupa_10_LuaThread_4send[] = "_LuaThread.send(self, value)\nSend a value into the coroutine. If the value is a tuple,\n send the unpacked elements.\n "; static PyMethodDef __pyx_mdef_4lupa_5_lupa_10_LuaThread_5send = {"send", (PyCFunction)__pyx_pw_4lupa_5_lupa_10_LuaThread_5send, METH_O, __pyx_doc_4lupa_5_lupa_10_LuaThread_4send}; static PyObject *__pyx_pw_4lupa_5_lupa_10_LuaThread_5send(PyObject *__pyx_v_self, PyObject *__pyx_v_value) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("send (wrapper)", 0); __pyx_r = __pyx_pf_4lupa_5_lupa_10_LuaThread_4send(((struct __pyx_obj_4lupa_5_lupa__LuaThread *)__pyx_v_self), ((PyObject *)__pyx_v_value)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_4lupa_5_lupa_10_LuaThread_4send(struct __pyx_obj_4lupa_5_lupa__LuaThread *__pyx_v_self, PyObject *__pyx_v_value) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations int __pyx_t_1; int __pyx_t_2; PyObject *__pyx_t_3 = NULL; __Pyx_RefNannySetupContext("send", 0); __Pyx_INCREF(__pyx_v_value); /* "lupa/_lupa.pyx":850 * send the unpacked elements. * """ * if value is not None: # <<<<<<<<<<<<<< * if self._arguments is not None: * raise TypeError("can't send non-None value to a just-started generator") */ __pyx_t_1 = (__pyx_v_value != Py_None); __pyx_t_2 = (__pyx_t_1 != 0); if (__pyx_t_2) { /* "lupa/_lupa.pyx":851 * """ * if value is not None: * if self._arguments is not None: # <<<<<<<<<<<<<< * raise TypeError("can't send non-None value to a just-started generator") * if not isinstance(value, tuple): */ __pyx_t_2 = (__pyx_v_self->_arguments != ((PyObject*)Py_None)); __pyx_t_1 = (__pyx_t_2 != 0); if (__pyx_t_1) { /* "lupa/_lupa.pyx":852 * if value is not None: * if self._arguments is not None: * raise TypeError("can't send non-None value to a just-started generator") # <<<<<<<<<<<<<< * if not isinstance(value, tuple): * value = (value,) */ __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__33, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 852, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_Raise(__pyx_t_3, 0, 0, 0); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __PYX_ERR(0, 852, __pyx_L1_error) /* "lupa/_lupa.pyx":851 * """ * if value is not None: * if self._arguments is not None: # <<<<<<<<<<<<<< * raise TypeError("can't send non-None value to a just-started generator") * if not isinstance(value, tuple): */ } /* "lupa/_lupa.pyx":853 * if self._arguments is not None: * raise TypeError("can't send non-None value to a just-started generator") * if not isinstance(value, tuple): # <<<<<<<<<<<<<< * value = (value,) * elif self._arguments is not None: */ __pyx_t_1 = PyTuple_Check(__pyx_v_value); __pyx_t_2 = ((!(__pyx_t_1 != 0)) != 0); if (__pyx_t_2) { /* "lupa/_lupa.pyx":854 * raise TypeError("can't send non-None value to a just-started generator") * if not isinstance(value, tuple): * value = (value,) # <<<<<<<<<<<<<< * elif self._arguments is not None: * value = self._arguments */ __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 854, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_INCREF(__pyx_v_value); __Pyx_GIVEREF(__pyx_v_value); PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_v_value); __Pyx_DECREF_SET(__pyx_v_value, __pyx_t_3); __pyx_t_3 = 0; /* "lupa/_lupa.pyx":853 * if self._arguments is not None: * raise TypeError("can't send non-None value to a just-started generator") * if not isinstance(value, tuple): # <<<<<<<<<<<<<< * value = (value,) * elif self._arguments is not None: */ } /* "lupa/_lupa.pyx":850 * send the unpacked elements. * """ * if value is not None: # <<<<<<<<<<<<<< * if self._arguments is not None: * raise TypeError("can't send non-None value to a just-started generator") */ goto __pyx_L3; } /* "lupa/_lupa.pyx":855 * if not isinstance(value, tuple): * value = (value,) * elif self._arguments is not None: # <<<<<<<<<<<<<< * value = self._arguments * self._arguments = None */ __pyx_t_2 = (__pyx_v_self->_arguments != ((PyObject*)Py_None)); __pyx_t_1 = (__pyx_t_2 != 0); if (__pyx_t_1) { /* "lupa/_lupa.pyx":856 * value = (value,) * elif self._arguments is not None: * value = self._arguments # <<<<<<<<<<<<<< * self._arguments = None * return resume_lua_thread(self, value) */ __pyx_t_3 = __pyx_v_self->_arguments; __Pyx_INCREF(__pyx_t_3); __Pyx_DECREF_SET(__pyx_v_value, __pyx_t_3); __pyx_t_3 = 0; /* "lupa/_lupa.pyx":857 * elif self._arguments is not None: * value = self._arguments * self._arguments = None # <<<<<<<<<<<<<< * return resume_lua_thread(self, value) * */ __Pyx_INCREF(Py_None); __Pyx_GIVEREF(Py_None); __Pyx_GOTREF(__pyx_v_self->_arguments); __Pyx_DECREF(__pyx_v_self->_arguments); __pyx_v_self->_arguments = ((PyObject*)Py_None); /* "lupa/_lupa.pyx":855 * if not isinstance(value, tuple): * value = (value,) * elif self._arguments is not None: # <<<<<<<<<<<<<< * value = self._arguments * self._arguments = None */ } __pyx_L3:; /* "lupa/_lupa.pyx":858 * value = self._arguments * self._arguments = None * return resume_lua_thread(self, value) # <<<<<<<<<<<<<< * * def __bool__(self): */ __Pyx_XDECREF(__pyx_r); __pyx_t_3 = __pyx_f_4lupa_5_lupa_resume_lua_thread(__pyx_v_self, ((PyObject*)__pyx_v_value)); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 858, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_r = __pyx_t_3; __pyx_t_3 = 0; goto __pyx_L0; /* "lupa/_lupa.pyx":846 * return resume_lua_thread(self, args) * * def send(self, value): # <<<<<<<<<<<<<< * """Send a value into the coroutine. If the value is a tuple, * send the unpacked elements. */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_3); __Pyx_AddTraceback("lupa._lupa._LuaThread.send", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XDECREF(__pyx_v_value); __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "lupa/_lupa.pyx":860 * return resume_lua_thread(self, value) * * def __bool__(self): # <<<<<<<<<<<<<< * cdef lua.lua_Debug dummy * assert self._runtime is not None */ /* Python wrapper */ static int __pyx_pw_4lupa_5_lupa_10_LuaThread_7__bool__(PyObject *__pyx_v_self); /*proto*/ static int __pyx_pw_4lupa_5_lupa_10_LuaThread_7__bool__(PyObject *__pyx_v_self) { int __pyx_r; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__bool__ (wrapper)", 0); __pyx_r = __pyx_pf_4lupa_5_lupa_10_LuaThread_6__bool__(((struct __pyx_obj_4lupa_5_lupa__LuaThread *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static int __pyx_pf_4lupa_5_lupa_10_LuaThread_6__bool__(struct __pyx_obj_4lupa_5_lupa__LuaThread *__pyx_v_self) { lua_Debug __pyx_v_dummy; int __pyx_v_status; int __pyx_r; __Pyx_RefNannyDeclarations int __pyx_t_1; __Pyx_RefNannySetupContext("__bool__", 0); /* "lupa/_lupa.pyx":862 * def __bool__(self): * cdef lua.lua_Debug dummy * assert self._runtime is not None # <<<<<<<<<<<<<< * cdef int status = lua.lua_status(self._co_state) * if status == lua.LUA_YIELD: */ #ifndef CYTHON_WITHOUT_ASSERTIONS if (unlikely(!Py_OptimizeFlag)) { __pyx_t_1 = (((PyObject *)__pyx_v_self->__pyx_base._runtime) != Py_None); if (unlikely(!(__pyx_t_1 != 0))) { PyErr_SetNone(PyExc_AssertionError); __PYX_ERR(0, 862, __pyx_L1_error) } } #endif /* "lupa/_lupa.pyx":863 * cdef lua.lua_Debug dummy * assert self._runtime is not None * cdef int status = lua.lua_status(self._co_state) # <<<<<<<<<<<<<< * if status == lua.LUA_YIELD: * return True */ __pyx_v_status = lua_status(__pyx_v_self->_co_state); /* "lupa/_lupa.pyx":864 * assert self._runtime is not None * cdef int status = lua.lua_status(self._co_state) * if status == lua.LUA_YIELD: # <<<<<<<<<<<<<< * return True * if status == 0: */ __pyx_t_1 = ((__pyx_v_status == LUA_YIELD) != 0); if (__pyx_t_1) { /* "lupa/_lupa.pyx":865 * cdef int status = lua.lua_status(self._co_state) * if status == lua.LUA_YIELD: * return True # <<<<<<<<<<<<<< * if status == 0: * # copied from Lua code: check for frames */ __pyx_r = 1; goto __pyx_L0; /* "lupa/_lupa.pyx":864 * assert self._runtime is not None * cdef int status = lua.lua_status(self._co_state) * if status == lua.LUA_YIELD: # <<<<<<<<<<<<<< * return True * if status == 0: */ } /* "lupa/_lupa.pyx":866 * if status == lua.LUA_YIELD: * return True * if status == 0: # <<<<<<<<<<<<<< * # copied from Lua code: check for frames * if lua.lua_getstack(self._co_state, 0, &dummy) > 0: */ __pyx_t_1 = ((__pyx_v_status == 0) != 0); if (__pyx_t_1) { /* "lupa/_lupa.pyx":868 * if status == 0: * # copied from Lua code: check for frames * if lua.lua_getstack(self._co_state, 0, &dummy) > 0: # <<<<<<<<<<<<<< * return True # currently running * elif lua.lua_gettop(self._co_state) > 0: */ __pyx_t_1 = ((lua_getstack(__pyx_v_self->_co_state, 0, (&__pyx_v_dummy)) > 0) != 0); if (__pyx_t_1) { /* "lupa/_lupa.pyx":869 * # copied from Lua code: check for frames * if lua.lua_getstack(self._co_state, 0, &dummy) > 0: * return True # currently running # <<<<<<<<<<<<<< * elif lua.lua_gettop(self._co_state) > 0: * return True # not started yet */ __pyx_r = 1; goto __pyx_L0; /* "lupa/_lupa.pyx":868 * if status == 0: * # copied from Lua code: check for frames * if lua.lua_getstack(self._co_state, 0, &dummy) > 0: # <<<<<<<<<<<<<< * return True # currently running * elif lua.lua_gettop(self._co_state) > 0: */ } /* "lupa/_lupa.pyx":870 * if lua.lua_getstack(self._co_state, 0, &dummy) > 0: * return True # currently running * elif lua.lua_gettop(self._co_state) > 0: # <<<<<<<<<<<<<< * return True # not started yet * return False */ __pyx_t_1 = ((lua_gettop(__pyx_v_self->_co_state) > 0) != 0); if (__pyx_t_1) { /* "lupa/_lupa.pyx":871 * return True # currently running * elif lua.lua_gettop(self._co_state) > 0: * return True # not started yet # <<<<<<<<<<<<<< * return False * */ __pyx_r = 1; goto __pyx_L0; /* "lupa/_lupa.pyx":870 * if lua.lua_getstack(self._co_state, 0, &dummy) > 0: * return True # currently running * elif lua.lua_gettop(self._co_state) > 0: # <<<<<<<<<<<<<< * return True # not started yet * return False */ } /* "lupa/_lupa.pyx":866 * if status == lua.LUA_YIELD: * return True * if status == 0: # <<<<<<<<<<<<<< * # copied from Lua code: check for frames * if lua.lua_getstack(self._co_state, 0, &dummy) > 0: */ } /* "lupa/_lupa.pyx":872 * elif lua.lua_gettop(self._co_state) > 0: * return True # not started yet * return False # <<<<<<<<<<<<<< * * cdef _LuaThread new_lua_thread(LuaRuntime runtime, lua_State* L, int n): */ __pyx_r = 0; goto __pyx_L0; /* "lupa/_lupa.pyx":860 * return resume_lua_thread(self, value) * * def __bool__(self): # <<<<<<<<<<<<<< * cdef lua.lua_Debug dummy * assert self._runtime is not None */ /* function exit code */ __pyx_L1_error:; __Pyx_AddTraceback("lupa._lupa._LuaThread.__bool__", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = -1; __pyx_L0:; __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "(tree fragment)":1 * def __reduce_cython__(self): # <<<<<<<<<<<<<< * raise TypeError("self._co_state,self._state cannot be converted to a Python object for pickling") * def __setstate_cython__(self, __pyx_state): */ /* Python wrapper */ static PyObject *__pyx_pw_4lupa_5_lupa_10_LuaThread_9__reduce_cython__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ static char __pyx_doc_4lupa_5_lupa_10_LuaThread_8__reduce_cython__[] = "_LuaThread.__reduce_cython__(self)"; static PyMethodDef __pyx_mdef_4lupa_5_lupa_10_LuaThread_9__reduce_cython__ = {"__reduce_cython__", (PyCFunction)__pyx_pw_4lupa_5_lupa_10_LuaThread_9__reduce_cython__, METH_NOARGS, __pyx_doc_4lupa_5_lupa_10_LuaThread_8__reduce_cython__}; static PyObject *__pyx_pw_4lupa_5_lupa_10_LuaThread_9__reduce_cython__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__reduce_cython__ (wrapper)", 0); __pyx_r = __pyx_pf_4lupa_5_lupa_10_LuaThread_8__reduce_cython__(((struct __pyx_obj_4lupa_5_lupa__LuaThread *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_4lupa_5_lupa_10_LuaThread_8__reduce_cython__(CYTHON_UNUSED struct __pyx_obj_4lupa_5_lupa__LuaThread *__pyx_v_self) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; __Pyx_RefNannySetupContext("__reduce_cython__", 0); /* "(tree fragment)":2 * def __reduce_cython__(self): * raise TypeError("self._co_state,self._state cannot be converted to a Python object for pickling") # <<<<<<<<<<<<<< * def __setstate_cython__(self, __pyx_state): * raise TypeError("self._co_state,self._state cannot be converted to a Python object for pickling") */ __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__34, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 2, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_Raise(__pyx_t_1, 0, 0, 0); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __PYX_ERR(2, 2, __pyx_L1_error) /* "(tree fragment)":1 * def __reduce_cython__(self): # <<<<<<<<<<<<<< * raise TypeError("self._co_state,self._state cannot be converted to a Python object for pickling") * def __setstate_cython__(self, __pyx_state): */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_AddTraceback("lupa._lupa._LuaThread.__reduce_cython__", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "(tree fragment)":3 * def __reduce_cython__(self): * raise TypeError("self._co_state,self._state cannot be converted to a Python object for pickling") * def __setstate_cython__(self, __pyx_state): # <<<<<<<<<<<<<< * raise TypeError("self._co_state,self._state cannot be converted to a Python object for pickling") */ /* Python wrapper */ static PyObject *__pyx_pw_4lupa_5_lupa_10_LuaThread_11__setstate_cython__(PyObject *__pyx_v_self, PyObject *__pyx_v___pyx_state); /*proto*/ static char __pyx_doc_4lupa_5_lupa_10_LuaThread_10__setstate_cython__[] = "_LuaThread.__setstate_cython__(self, __pyx_state)"; static PyMethodDef __pyx_mdef_4lupa_5_lupa_10_LuaThread_11__setstate_cython__ = {"__setstate_cython__", (PyCFunction)__pyx_pw_4lupa_5_lupa_10_LuaThread_11__setstate_cython__, METH_O, __pyx_doc_4lupa_5_lupa_10_LuaThread_10__setstate_cython__}; static PyObject *__pyx_pw_4lupa_5_lupa_10_LuaThread_11__setstate_cython__(PyObject *__pyx_v_self, PyObject *__pyx_v___pyx_state) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__setstate_cython__ (wrapper)", 0); __pyx_r = __pyx_pf_4lupa_5_lupa_10_LuaThread_10__setstate_cython__(((struct __pyx_obj_4lupa_5_lupa__LuaThread *)__pyx_v_self), ((PyObject *)__pyx_v___pyx_state)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_4lupa_5_lupa_10_LuaThread_10__setstate_cython__(CYTHON_UNUSED struct __pyx_obj_4lupa_5_lupa__LuaThread *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v___pyx_state) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; __Pyx_RefNannySetupContext("__setstate_cython__", 0); /* "(tree fragment)":4 * raise TypeError("self._co_state,self._state cannot be converted to a Python object for pickling") * def __setstate_cython__(self, __pyx_state): * raise TypeError("self._co_state,self._state cannot be converted to a Python object for pickling") # <<<<<<<<<<<<<< */ __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__35, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 4, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_Raise(__pyx_t_1, 0, 0, 0); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __PYX_ERR(2, 4, __pyx_L1_error) /* "(tree fragment)":3 * def __reduce_cython__(self): * raise TypeError("self._co_state,self._state cannot be converted to a Python object for pickling") * def __setstate_cython__(self, __pyx_state): # <<<<<<<<<<<<<< * raise TypeError("self._co_state,self._state cannot be converted to a Python object for pickling") */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_AddTraceback("lupa._lupa._LuaThread.__setstate_cython__", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "lupa/_lupa.pyx":874 * return False * * cdef _LuaThread new_lua_thread(LuaRuntime runtime, lua_State* L, int n): # <<<<<<<<<<<<<< * cdef _LuaThread obj = _LuaThread.__new__(_LuaThread) * init_lua_object(obj, runtime, L, n) */ static struct __pyx_obj_4lupa_5_lupa__LuaThread *__pyx_f_4lupa_5_lupa_new_lua_thread(struct __pyx_obj_4lupa_5_lupa_LuaRuntime *__pyx_v_runtime, lua_State *__pyx_v_L, int __pyx_v_n) { struct __pyx_obj_4lupa_5_lupa__LuaThread *__pyx_v_obj = 0; struct __pyx_obj_4lupa_5_lupa__LuaThread *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; __Pyx_RefNannySetupContext("new_lua_thread", 0); /* "lupa/_lupa.pyx":875 * * cdef _LuaThread new_lua_thread(LuaRuntime runtime, lua_State* L, int n): * cdef _LuaThread obj = _LuaThread.__new__(_LuaThread) # <<<<<<<<<<<<<< * init_lua_object(obj, runtime, L, n) * obj._co_state = lua.lua_tothread(L, n) */ __pyx_t_1 = __pyx_tp_new_4lupa_5_lupa__LuaThread(((PyTypeObject *)__pyx_ptype_4lupa_5_lupa__LuaThread), __pyx_empty_tuple, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 875, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); if (!(likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_4lupa_5_lupa__LuaThread)))) __PYX_ERR(0, 875, __pyx_L1_error) __pyx_v_obj = ((struct __pyx_obj_4lupa_5_lupa__LuaThread *)__pyx_t_1); __pyx_t_1 = 0; /* "lupa/_lupa.pyx":876 * cdef _LuaThread new_lua_thread(LuaRuntime runtime, lua_State* L, int n): * cdef _LuaThread obj = _LuaThread.__new__(_LuaThread) * init_lua_object(obj, runtime, L, n) # <<<<<<<<<<<<<< * obj._co_state = lua.lua_tothread(L, n) * return obj */ __pyx_f_4lupa_5_lupa_init_lua_object(((struct __pyx_obj_4lupa_5_lupa__LuaObject *)__pyx_v_obj), __pyx_v_runtime, __pyx_v_L, __pyx_v_n); /* "lupa/_lupa.pyx":877 * cdef _LuaThread obj = _LuaThread.__new__(_LuaThread) * init_lua_object(obj, runtime, L, n) * obj._co_state = lua.lua_tothread(L, n) # <<<<<<<<<<<<<< * return obj * */ __pyx_v_obj->_co_state = lua_tothread(__pyx_v_L, __pyx_v_n); /* "lupa/_lupa.pyx":878 * init_lua_object(obj, runtime, L, n) * obj._co_state = lua.lua_tothread(L, n) * return obj # <<<<<<<<<<<<<< * * */ __Pyx_XDECREF(((PyObject *)__pyx_r)); __Pyx_INCREF(((PyObject *)__pyx_v_obj)); __pyx_r = __pyx_v_obj; goto __pyx_L0; /* "lupa/_lupa.pyx":874 * return False * * cdef _LuaThread new_lua_thread(LuaRuntime runtime, lua_State* L, int n): # <<<<<<<<<<<<<< * cdef _LuaThread obj = _LuaThread.__new__(_LuaThread) * init_lua_object(obj, runtime, L, n) */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_AddTraceback("lupa._lupa.new_lua_thread", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = 0; __pyx_L0:; __Pyx_XDECREF((PyObject *)__pyx_v_obj); __Pyx_XGIVEREF((PyObject *)__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "lupa/_lupa.pyx":881 * * * cdef _LuaObject new_lua_thread_or_function(LuaRuntime runtime, lua_State* L, int n): # <<<<<<<<<<<<<< * # this is special - we replace a new (unstarted) thread by its * # underlying function to better follow Python's own generator */ static struct __pyx_obj_4lupa_5_lupa__LuaObject *__pyx_f_4lupa_5_lupa_new_lua_thread_or_function(struct __pyx_obj_4lupa_5_lupa_LuaRuntime *__pyx_v_runtime, lua_State *__pyx_v_L, int __pyx_v_n) { lua_State *__pyx_v_co; struct __pyx_obj_4lupa_5_lupa__LuaObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations int __pyx_t_1; int __pyx_t_2; PyObject *__pyx_t_3 = NULL; int __pyx_t_4; int __pyx_t_5; char const *__pyx_t_6; PyObject *__pyx_t_7 = NULL; PyObject *__pyx_t_8 = NULL; PyObject *__pyx_t_9 = NULL; PyObject *__pyx_t_10 = NULL; PyObject *__pyx_t_11 = NULL; PyObject *__pyx_t_12 = NULL; struct __pyx_obj_4lupa_5_lupa__LuaObject *__pyx_t_13 = NULL; __Pyx_RefNannySetupContext("new_lua_thread_or_function", 0); /* "lupa/_lupa.pyx":885 * # underlying function to better follow Python's own generator * # protocol * cdef lua_State* co = lua.lua_tothread(L, n) # <<<<<<<<<<<<<< * assert co is not NULL * if lua.lua_status(co) == 0 and lua.lua_gettop(co) == 1: */ __pyx_v_co = lua_tothread(__pyx_v_L, __pyx_v_n); /* "lupa/_lupa.pyx":886 * # protocol * cdef lua_State* co = lua.lua_tothread(L, n) * assert co is not NULL # <<<<<<<<<<<<<< * if lua.lua_status(co) == 0 and lua.lua_gettop(co) == 1: * # not started yet => get the function and return that */ #ifndef CYTHON_WITHOUT_ASSERTIONS if (unlikely(!Py_OptimizeFlag)) { if (unlikely(!((__pyx_v_co != NULL) != 0))) { PyErr_SetNone(PyExc_AssertionError); __PYX_ERR(0, 886, __pyx_L1_error) } } #endif /* "lupa/_lupa.pyx":887 * cdef lua_State* co = lua.lua_tothread(L, n) * assert co is not NULL * if lua.lua_status(co) == 0 and lua.lua_gettop(co) == 1: # <<<<<<<<<<<<<< * # not started yet => get the function and return that * lua.lua_pushvalue(co, 1) */ __pyx_t_2 = ((lua_status(__pyx_v_co) == 0) != 0); if (__pyx_t_2) { } else { __pyx_t_1 = __pyx_t_2; goto __pyx_L4_bool_binop_done; } __pyx_t_2 = ((lua_gettop(__pyx_v_co) == 1) != 0); __pyx_t_1 = __pyx_t_2; __pyx_L4_bool_binop_done:; if (__pyx_t_1) { /* "lupa/_lupa.pyx":889 * if lua.lua_status(co) == 0 and lua.lua_gettop(co) == 1: * # not started yet => get the function and return that * lua.lua_pushvalue(co, 1) # <<<<<<<<<<<<<< * lua.lua_xmove(co, L, 1) * try: */ lua_pushvalue(__pyx_v_co, 1); /* "lupa/_lupa.pyx":890 * # not started yet => get the function and return that * lua.lua_pushvalue(co, 1) * lua.lua_xmove(co, L, 1) # <<<<<<<<<<<<<< * try: * return new_lua_coroutine_function(runtime, L, -1) */ lua_xmove(__pyx_v_co, __pyx_v_L, 1); /* "lupa/_lupa.pyx":891 * lua.lua_pushvalue(co, 1) * lua.lua_xmove(co, L, 1) * try: # <<<<<<<<<<<<<< * return new_lua_coroutine_function(runtime, L, -1) * finally: */ /*try:*/ { /* "lupa/_lupa.pyx":892 * lua.lua_xmove(co, L, 1) * try: * return new_lua_coroutine_function(runtime, L, -1) # <<<<<<<<<<<<<< * finally: * lua.lua_pop(L, 1) */ __Pyx_XDECREF(((PyObject *)__pyx_r)); __pyx_t_3 = ((PyObject *)__pyx_f_4lupa_5_lupa_new_lua_coroutine_function(__pyx_v_runtime, __pyx_v_L, -1)); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 892, __pyx_L7_error) __Pyx_GOTREF(__pyx_t_3); __pyx_r = ((struct __pyx_obj_4lupa_5_lupa__LuaObject *)__pyx_t_3); __pyx_t_3 = 0; goto __pyx_L6_return; } /* "lupa/_lupa.pyx":894 * return new_lua_coroutine_function(runtime, L, -1) * finally: * lua.lua_pop(L, 1) # <<<<<<<<<<<<<< * else: * # already started => wrap the thread */ /*finally:*/ { __pyx_L7_error:; /*exception exit:*/{ __Pyx_PyThreadState_declare __Pyx_PyThreadState_assign __pyx_t_7 = 0; __pyx_t_8 = 0; __pyx_t_9 = 0; __pyx_t_10 = 0; __pyx_t_11 = 0; __pyx_t_12 = 0; __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; if (PY_MAJOR_VERSION >= 3) __Pyx_ExceptionSwap(&__pyx_t_10, &__pyx_t_11, &__pyx_t_12); if ((PY_MAJOR_VERSION < 3) || unlikely(__Pyx_GetException(&__pyx_t_7, &__pyx_t_8, &__pyx_t_9) < 0)) __Pyx_ErrFetch(&__pyx_t_7, &__pyx_t_8, &__pyx_t_9); __Pyx_XGOTREF(__pyx_t_7); __Pyx_XGOTREF(__pyx_t_8); __Pyx_XGOTREF(__pyx_t_9); __Pyx_XGOTREF(__pyx_t_10); __Pyx_XGOTREF(__pyx_t_11); __Pyx_XGOTREF(__pyx_t_12); __pyx_t_4 = __pyx_lineno; __pyx_t_5 = __pyx_clineno; __pyx_t_6 = __pyx_filename; { lua_pop(__pyx_v_L, 1); } if (PY_MAJOR_VERSION >= 3) { __Pyx_XGIVEREF(__pyx_t_10); __Pyx_XGIVEREF(__pyx_t_11); __Pyx_XGIVEREF(__pyx_t_12); __Pyx_ExceptionReset(__pyx_t_10, __pyx_t_11, __pyx_t_12); } __Pyx_XGIVEREF(__pyx_t_7); __Pyx_XGIVEREF(__pyx_t_8); __Pyx_XGIVEREF(__pyx_t_9); __Pyx_ErrRestore(__pyx_t_7, __pyx_t_8, __pyx_t_9); __pyx_t_7 = 0; __pyx_t_8 = 0; __pyx_t_9 = 0; __pyx_t_10 = 0; __pyx_t_11 = 0; __pyx_t_12 = 0; __pyx_lineno = __pyx_t_4; __pyx_clineno = __pyx_t_5; __pyx_filename = __pyx_t_6; goto __pyx_L1_error; } __pyx_L6_return: { __pyx_t_13 = __pyx_r; __pyx_r = 0; lua_pop(__pyx_v_L, 1); __pyx_r = __pyx_t_13; __pyx_t_13 = 0; goto __pyx_L0; } } /* "lupa/_lupa.pyx":887 * cdef lua_State* co = lua.lua_tothread(L, n) * assert co is not NULL * if lua.lua_status(co) == 0 and lua.lua_gettop(co) == 1: # <<<<<<<<<<<<<< * # not started yet => get the function and return that * lua.lua_pushvalue(co, 1) */ } /* "lupa/_lupa.pyx":897 * else: * # already started => wrap the thread * return new_lua_thread(runtime, L, n) # <<<<<<<<<<<<<< * * */ /*else*/ { __Pyx_XDECREF(((PyObject *)__pyx_r)); __pyx_t_3 = ((PyObject *)__pyx_f_4lupa_5_lupa_new_lua_thread(__pyx_v_runtime, __pyx_v_L, __pyx_v_n)); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 897, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_r = ((struct __pyx_obj_4lupa_5_lupa__LuaObject *)__pyx_t_3); __pyx_t_3 = 0; goto __pyx_L0; } /* "lupa/_lupa.pyx":881 * * * cdef _LuaObject new_lua_thread_or_function(LuaRuntime runtime, lua_State* L, int n): # <<<<<<<<<<<<<< * # this is special - we replace a new (unstarted) thread by its * # underlying function to better follow Python's own generator */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_3); __Pyx_AddTraceback("lupa._lupa.new_lua_thread_or_function", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = 0; __pyx_L0:; __Pyx_XGIVEREF((PyObject *)__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "lupa/_lupa.pyx":900 * * * cdef object resume_lua_thread(_LuaThread thread, tuple args): # <<<<<<<<<<<<<< * cdef lua_State* co = thread._co_state * cdef lua_State* L = thread._state */ static PyObject *__pyx_f_4lupa_5_lupa_resume_lua_thread(struct __pyx_obj_4lupa_5_lupa__LuaThread *__pyx_v_thread, PyObject *__pyx_v_args) { lua_State *__pyx_v_co; lua_State *__pyx_v_L; int __pyx_v_status; int __pyx_v_nargs; int __pyx_v_nres; int __pyx_v_old_top; PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations lua_State *__pyx_t_1; PyObject *__pyx_t_2 = NULL; int __pyx_t_3; int __pyx_t_4; int __pyx_t_5; Py_ssize_t __pyx_t_6; PyObject *__pyx_t_7 = NULL; int __pyx_t_8; char const *__pyx_t_9; PyObject *__pyx_t_10 = NULL; PyObject *__pyx_t_11 = NULL; PyObject *__pyx_t_12 = NULL; PyObject *__pyx_t_13 = NULL; PyObject *__pyx_t_14 = NULL; PyObject *__pyx_t_15 = NULL; __Pyx_RefNannySetupContext("resume_lua_thread", 0); /* "lupa/_lupa.pyx":901 * * cdef object resume_lua_thread(_LuaThread thread, tuple args): * cdef lua_State* co = thread._co_state # <<<<<<<<<<<<<< * cdef lua_State* L = thread._state * cdef int status, i, nargs = 0, nres = 0 */ __pyx_t_1 = __pyx_v_thread->_co_state; __pyx_v_co = __pyx_t_1; /* "lupa/_lupa.pyx":902 * cdef object resume_lua_thread(_LuaThread thread, tuple args): * cdef lua_State* co = thread._co_state * cdef lua_State* L = thread._state # <<<<<<<<<<<<<< * cdef int status, i, nargs = 0, nres = 0 * lock_runtime(thread._runtime) */ __pyx_t_1 = __pyx_v_thread->__pyx_base._state; __pyx_v_L = __pyx_t_1; /* "lupa/_lupa.pyx":903 * cdef lua_State* co = thread._co_state * cdef lua_State* L = thread._state * cdef int status, i, nargs = 0, nres = 0 # <<<<<<<<<<<<<< * lock_runtime(thread._runtime) * old_top = lua.lua_gettop(L) */ __pyx_v_nargs = 0; __pyx_v_nres = 0; /* "lupa/_lupa.pyx":904 * cdef lua_State* L = thread._state * cdef int status, i, nargs = 0, nres = 0 * lock_runtime(thread._runtime) # <<<<<<<<<<<<<< * old_top = lua.lua_gettop(L) * try: */ __pyx_t_2 = ((PyObject *)__pyx_v_thread->__pyx_base._runtime); __Pyx_INCREF(__pyx_t_2); __pyx_t_3 = __pyx_f_4lupa_5_lupa_lock_runtime(((struct __pyx_obj_4lupa_5_lupa_LuaRuntime *)__pyx_t_2)); if (unlikely(__pyx_t_3 == ((int)-1))) __PYX_ERR(0, 904, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; /* "lupa/_lupa.pyx":905 * cdef int status, i, nargs = 0, nres = 0 * lock_runtime(thread._runtime) * old_top = lua.lua_gettop(L) # <<<<<<<<<<<<<< * try: * if lua.lua_status(co) == 0 and lua.lua_gettop(co) == 0: */ __pyx_v_old_top = lua_gettop(__pyx_v_L); /* "lupa/_lupa.pyx":906 * lock_runtime(thread._runtime) * old_top = lua.lua_gettop(L) * try: # <<<<<<<<<<<<<< * if lua.lua_status(co) == 0 and lua.lua_gettop(co) == 0: * # already terminated */ /*try:*/ { /* "lupa/_lupa.pyx":907 * old_top = lua.lua_gettop(L) * try: * if lua.lua_status(co) == 0 and lua.lua_gettop(co) == 0: # <<<<<<<<<<<<<< * # already terminated * raise StopIteration */ __pyx_t_5 = ((lua_status(__pyx_v_co) == 0) != 0); if (__pyx_t_5) { } else { __pyx_t_4 = __pyx_t_5; goto __pyx_L7_bool_binop_done; } __pyx_t_5 = ((lua_gettop(__pyx_v_co) == 0) != 0); __pyx_t_4 = __pyx_t_5; __pyx_L7_bool_binop_done:; if (__pyx_t_4) { /* "lupa/_lupa.pyx":909 * if lua.lua_status(co) == 0 and lua.lua_gettop(co) == 0: * # already terminated * raise StopIteration # <<<<<<<<<<<<<< * if args: * nargs = len(args) */ __Pyx_Raise(__pyx_builtin_StopIteration, 0, 0, 0); __PYX_ERR(0, 909, __pyx_L4_error) /* "lupa/_lupa.pyx":907 * old_top = lua.lua_gettop(L) * try: * if lua.lua_status(co) == 0 and lua.lua_gettop(co) == 0: # <<<<<<<<<<<<<< * # already terminated * raise StopIteration */ } /* "lupa/_lupa.pyx":910 * # already terminated * raise StopIteration * if args: # <<<<<<<<<<<<<< * nargs = len(args) * push_lua_arguments(thread._runtime, co, args) */ __pyx_t_4 = (__pyx_v_args != Py_None) && (PyTuple_GET_SIZE(__pyx_v_args) != 0); if (__pyx_t_4) { /* "lupa/_lupa.pyx":911 * raise StopIteration * if args: * nargs = len(args) # <<<<<<<<<<<<<< * push_lua_arguments(thread._runtime, co, args) * with nogil: */ if (unlikely(__pyx_v_args == Py_None)) { PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()"); __PYX_ERR(0, 911, __pyx_L4_error) } __pyx_t_6 = PyTuple_GET_SIZE(__pyx_v_args); if (unlikely(__pyx_t_6 == ((Py_ssize_t)-1))) __PYX_ERR(0, 911, __pyx_L4_error) __pyx_v_nargs = __pyx_t_6; /* "lupa/_lupa.pyx":912 * if args: * nargs = len(args) * push_lua_arguments(thread._runtime, co, args) # <<<<<<<<<<<<<< * with nogil: * status = lua.lua_resume(co, L, nargs) */ __pyx_t_2 = ((PyObject *)__pyx_v_thread->__pyx_base._runtime); __Pyx_INCREF(__pyx_t_2); __pyx_t_3 = __pyx_f_4lupa_5_lupa_push_lua_arguments(((struct __pyx_obj_4lupa_5_lupa_LuaRuntime *)__pyx_t_2), __pyx_v_co, __pyx_v_args, NULL); if (unlikely(__pyx_t_3 == ((int)-1))) __PYX_ERR(0, 912, __pyx_L4_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; /* "lupa/_lupa.pyx":910 * # already terminated * raise StopIteration * if args: # <<<<<<<<<<<<<< * nargs = len(args) * push_lua_arguments(thread._runtime, co, args) */ } /* "lupa/_lupa.pyx":913 * nargs = len(args) * push_lua_arguments(thread._runtime, co, args) * with nogil: # <<<<<<<<<<<<<< * status = lua.lua_resume(co, L, nargs) * nres = lua.lua_gettop(co) */ { #ifdef WITH_THREAD PyThreadState *_save; Py_UNBLOCK_THREADS __Pyx_FastGIL_Remember(); #endif /*try:*/ { /* "lupa/_lupa.pyx":914 * push_lua_arguments(thread._runtime, co, args) * with nogil: * status = lua.lua_resume(co, L, nargs) # <<<<<<<<<<<<<< * nres = lua.lua_gettop(co) * if status != lua.LUA_YIELD: */ __pyx_v_status = __lupa_lua_resume(__pyx_v_co, __pyx_v_L, __pyx_v_nargs); } /* "lupa/_lupa.pyx":913 * nargs = len(args) * push_lua_arguments(thread._runtime, co, args) * with nogil: # <<<<<<<<<<<<<< * status = lua.lua_resume(co, L, nargs) * nres = lua.lua_gettop(co) */ /*finally:*/ { /*normal exit:*/{ #ifdef WITH_THREAD __Pyx_FastGIL_Forget(); Py_BLOCK_THREADS #endif goto __pyx_L12; } __pyx_L12:; } } /* "lupa/_lupa.pyx":915 * with nogil: * status = lua.lua_resume(co, L, nargs) * nres = lua.lua_gettop(co) # <<<<<<<<<<<<<< * if status != lua.LUA_YIELD: * if status == 0: */ __pyx_v_nres = lua_gettop(__pyx_v_co); /* "lupa/_lupa.pyx":916 * status = lua.lua_resume(co, L, nargs) * nres = lua.lua_gettop(co) * if status != lua.LUA_YIELD: # <<<<<<<<<<<<<< * if status == 0: * # terminated */ __pyx_t_4 = ((__pyx_v_status != LUA_YIELD) != 0); if (__pyx_t_4) { /* "lupa/_lupa.pyx":917 * nres = lua.lua_gettop(co) * if status != lua.LUA_YIELD: * if status == 0: # <<<<<<<<<<<<<< * # terminated * if nres == 0: */ __pyx_t_4 = ((__pyx_v_status == 0) != 0); if (__pyx_t_4) { /* "lupa/_lupa.pyx":919 * if status == 0: * # terminated * if nres == 0: # <<<<<<<<<<<<<< * # no values left to return * raise StopIteration */ __pyx_t_4 = ((__pyx_v_nres == 0) != 0); if (__pyx_t_4) { /* "lupa/_lupa.pyx":921 * if nres == 0: * # no values left to return * raise StopIteration # <<<<<<<<<<<<<< * else: * raise_lua_error(thread._runtime, co, status) */ __Pyx_Raise(__pyx_builtin_StopIteration, 0, 0, 0); __PYX_ERR(0, 921, __pyx_L4_error) /* "lupa/_lupa.pyx":919 * if status == 0: * # terminated * if nres == 0: # <<<<<<<<<<<<<< * # no values left to return * raise StopIteration */ } /* "lupa/_lupa.pyx":917 * nres = lua.lua_gettop(co) * if status != lua.LUA_YIELD: * if status == 0: # <<<<<<<<<<<<<< * # terminated * if nres == 0: */ goto __pyx_L14; } /* "lupa/_lupa.pyx":923 * raise StopIteration * else: * raise_lua_error(thread._runtime, co, status) # <<<<<<<<<<<<<< * * # Move yielded values to the main state before unpacking. */ /*else*/ { __pyx_t_2 = ((PyObject *)__pyx_v_thread->__pyx_base._runtime); __Pyx_INCREF(__pyx_t_2); __pyx_t_3 = __pyx_f_4lupa_5_lupa_raise_lua_error(((struct __pyx_obj_4lupa_5_lupa_LuaRuntime *)__pyx_t_2), __pyx_v_co, __pyx_v_status); if (unlikely(__pyx_t_3 == ((int)-1))) __PYX_ERR(0, 923, __pyx_L4_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; } __pyx_L14:; /* "lupa/_lupa.pyx":916 * status = lua.lua_resume(co, L, nargs) * nres = lua.lua_gettop(co) * if status != lua.LUA_YIELD: # <<<<<<<<<<<<<< * if status == 0: * # terminated */ } /* "lupa/_lupa.pyx":928 * # This is what Lua's internal auxresume function is doing; * # it affects wrapped Lua functions returned to Python. * lua.lua_xmove(co, L, nres) # <<<<<<<<<<<<<< * return unpack_lua_results(thread._runtime, L) * finally: */ lua_xmove(__pyx_v_co, __pyx_v_L, __pyx_v_nres); /* "lupa/_lupa.pyx":929 * # it affects wrapped Lua functions returned to Python. * lua.lua_xmove(co, L, nres) * return unpack_lua_results(thread._runtime, L) # <<<<<<<<<<<<<< * finally: * # FIXME: check that coroutine state is OK in case of errors? */ __Pyx_XDECREF(__pyx_r); __pyx_t_2 = ((PyObject *)__pyx_v_thread->__pyx_base._runtime); __Pyx_INCREF(__pyx_t_2); __pyx_t_7 = __pyx_f_4lupa_5_lupa_unpack_lua_results(((struct __pyx_obj_4lupa_5_lupa_LuaRuntime *)__pyx_t_2), __pyx_v_L); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 929, __pyx_L4_error) __Pyx_GOTREF(__pyx_t_7); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_r = __pyx_t_7; __pyx_t_7 = 0; goto __pyx_L3_return; } /* "lupa/_lupa.pyx":932 * finally: * # FIXME: check that coroutine state is OK in case of errors? * lua.lua_settop(L, old_top) # <<<<<<<<<<<<<< * unlock_runtime(thread._runtime) * */ /*finally:*/ { __pyx_L4_error:; /*exception exit:*/{ __Pyx_PyThreadState_declare __Pyx_PyThreadState_assign __pyx_t_10 = 0; __pyx_t_11 = 0; __pyx_t_12 = 0; __pyx_t_13 = 0; __pyx_t_14 = 0; __pyx_t_15 = 0; __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0; if (PY_MAJOR_VERSION >= 3) __Pyx_ExceptionSwap(&__pyx_t_13, &__pyx_t_14, &__pyx_t_15); if ((PY_MAJOR_VERSION < 3) || unlikely(__Pyx_GetException(&__pyx_t_10, &__pyx_t_11, &__pyx_t_12) < 0)) __Pyx_ErrFetch(&__pyx_t_10, &__pyx_t_11, &__pyx_t_12); __Pyx_XGOTREF(__pyx_t_10); __Pyx_XGOTREF(__pyx_t_11); __Pyx_XGOTREF(__pyx_t_12); __Pyx_XGOTREF(__pyx_t_13); __Pyx_XGOTREF(__pyx_t_14); __Pyx_XGOTREF(__pyx_t_15); __pyx_t_3 = __pyx_lineno; __pyx_t_8 = __pyx_clineno; __pyx_t_9 = __pyx_filename; { lua_settop(__pyx_v_L, __pyx_v_old_top); /* "lupa/_lupa.pyx":933 * # FIXME: check that coroutine state is OK in case of errors? * lua.lua_settop(L, old_top) * unlock_runtime(thread._runtime) # <<<<<<<<<<<<<< * * */ __pyx_t_7 = ((PyObject *)__pyx_v_thread->__pyx_base._runtime); __Pyx_INCREF(__pyx_t_7); __pyx_f_4lupa_5_lupa_unlock_runtime(((struct __pyx_obj_4lupa_5_lupa_LuaRuntime *)__pyx_t_7)); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; } if (PY_MAJOR_VERSION >= 3) { __Pyx_XGIVEREF(__pyx_t_13); __Pyx_XGIVEREF(__pyx_t_14); __Pyx_XGIVEREF(__pyx_t_15); __Pyx_ExceptionReset(__pyx_t_13, __pyx_t_14, __pyx_t_15); } __Pyx_XGIVEREF(__pyx_t_10); __Pyx_XGIVEREF(__pyx_t_11); __Pyx_XGIVEREF(__pyx_t_12); __Pyx_ErrRestore(__pyx_t_10, __pyx_t_11, __pyx_t_12); __pyx_t_10 = 0; __pyx_t_11 = 0; __pyx_t_12 = 0; __pyx_t_13 = 0; __pyx_t_14 = 0; __pyx_t_15 = 0; __pyx_lineno = __pyx_t_3; __pyx_clineno = __pyx_t_8; __pyx_filename = __pyx_t_9; goto __pyx_L1_error; } __pyx_L3_return: { __pyx_t_15 = __pyx_r; __pyx_r = 0; /* "lupa/_lupa.pyx":932 * finally: * # FIXME: check that coroutine state is OK in case of errors? * lua.lua_settop(L, old_top) # <<<<<<<<<<<<<< * unlock_runtime(thread._runtime) * */ lua_settop(__pyx_v_L, __pyx_v_old_top); /* "lupa/_lupa.pyx":933 * # FIXME: check that coroutine state is OK in case of errors? * lua.lua_settop(L, old_top) * unlock_runtime(thread._runtime) # <<<<<<<<<<<<<< * * */ __pyx_t_7 = ((PyObject *)__pyx_v_thread->__pyx_base._runtime); __Pyx_INCREF(__pyx_t_7); __pyx_f_4lupa_5_lupa_unlock_runtime(((struct __pyx_obj_4lupa_5_lupa_LuaRuntime *)__pyx_t_7)); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; __pyx_r = __pyx_t_15; __pyx_t_15 = 0; goto __pyx_L0; } } /* "lupa/_lupa.pyx":900 * * * cdef object resume_lua_thread(_LuaThread thread, tuple args): # <<<<<<<<<<<<<< * cdef lua_State* co = thread._co_state * cdef lua_State* L = thread._state */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_2); __Pyx_XDECREF(__pyx_t_7); __Pyx_AddTraceback("lupa._lupa.resume_lua_thread", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = 0; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "lupa/_lupa.pyx":952 * cdef char _what * * def __cinit__(self, _LuaObject obj not None, int what): # <<<<<<<<<<<<<< * self._state = NULL * assert obj._runtime is not None */ /* Python wrapper */ static int __pyx_pw_4lupa_5_lupa_8_LuaIter_1__cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ static int __pyx_pw_4lupa_5_lupa_8_LuaIter_1__cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { struct __pyx_obj_4lupa_5_lupa__LuaObject *__pyx_v_obj = 0; int __pyx_v_what; int __pyx_r; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__cinit__ (wrapper)", 0); { static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_obj,&__pyx_n_s_what,0}; PyObject* values[2] = {0,0}; if (unlikely(__pyx_kwds)) { Py_ssize_t kw_args; const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args); switch (pos_args) { case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); CYTHON_FALLTHROUGH; case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); CYTHON_FALLTHROUGH; case 0: break; default: goto __pyx_L5_argtuple_error; } kw_args = PyDict_Size(__pyx_kwds); switch (pos_args) { case 0: if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_obj)) != 0)) kw_args--; else goto __pyx_L5_argtuple_error; CYTHON_FALLTHROUGH; case 1: if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_what)) != 0)) kw_args--; else { __Pyx_RaiseArgtupleInvalid("__cinit__", 1, 2, 2, 1); __PYX_ERR(0, 952, __pyx_L3_error) } } if (unlikely(kw_args > 0)) { if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__cinit__") < 0)) __PYX_ERR(0, 952, __pyx_L3_error) } } else if (PyTuple_GET_SIZE(__pyx_args) != 2) { goto __pyx_L5_argtuple_error; } else { values[0] = PyTuple_GET_ITEM(__pyx_args, 0); values[1] = PyTuple_GET_ITEM(__pyx_args, 1); } __pyx_v_obj = ((struct __pyx_obj_4lupa_5_lupa__LuaObject *)values[0]); __pyx_v_what = __Pyx_PyInt_As_int(values[1]); if (unlikely((__pyx_v_what == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 952, __pyx_L3_error) } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("__cinit__", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 952, __pyx_L3_error) __pyx_L3_error:; __Pyx_AddTraceback("lupa._lupa._LuaIter.__cinit__", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return -1; __pyx_L4_argument_unpacking_done:; if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_obj), __pyx_ptype_4lupa_5_lupa__LuaObject, 0, "obj", 0))) __PYX_ERR(0, 952, __pyx_L1_error) __pyx_r = __pyx_pf_4lupa_5_lupa_8_LuaIter___cinit__(((struct __pyx_obj_4lupa_5_lupa__LuaIter *)__pyx_v_self), __pyx_v_obj, __pyx_v_what); /* function exit code */ goto __pyx_L0; __pyx_L1_error:; __pyx_r = -1; __pyx_L0:; __Pyx_RefNannyFinishContext(); return __pyx_r; } static int __pyx_pf_4lupa_5_lupa_8_LuaIter___cinit__(struct __pyx_obj_4lupa_5_lupa__LuaIter *__pyx_v_self, struct __pyx_obj_4lupa_5_lupa__LuaObject *__pyx_v_obj, int __pyx_v_what) { int __pyx_r; __Pyx_RefNannyDeclarations int __pyx_t_1; PyObject *__pyx_t_2 = NULL; lua_State *__pyx_t_3; __Pyx_RefNannySetupContext("__cinit__", 0); /* "lupa/_lupa.pyx":953 * * def __cinit__(self, _LuaObject obj not None, int what): * self._state = NULL # <<<<<<<<<<<<<< * assert obj._runtime is not None * self._runtime = obj._runtime */ __pyx_v_self->_state = NULL; /* "lupa/_lupa.pyx":954 * def __cinit__(self, _LuaObject obj not None, int what): * self._state = NULL * assert obj._runtime is not None # <<<<<<<<<<<<<< * self._runtime = obj._runtime * self._obj = obj */ #ifndef CYTHON_WITHOUT_ASSERTIONS if (unlikely(!Py_OptimizeFlag)) { __pyx_t_1 = (((PyObject *)__pyx_v_obj->_runtime) != Py_None); if (unlikely(!(__pyx_t_1 != 0))) { PyErr_SetNone(PyExc_AssertionError); __PYX_ERR(0, 954, __pyx_L1_error) } } #endif /* "lupa/_lupa.pyx":955 * self._state = NULL * assert obj._runtime is not None * self._runtime = obj._runtime # <<<<<<<<<<<<<< * self._obj = obj * self._state = obj._state */ __pyx_t_2 = ((PyObject *)__pyx_v_obj->_runtime); __Pyx_INCREF(__pyx_t_2); __Pyx_GIVEREF(__pyx_t_2); __Pyx_GOTREF(__pyx_v_self->_runtime); __Pyx_DECREF(((PyObject *)__pyx_v_self->_runtime)); __pyx_v_self->_runtime = ((struct __pyx_obj_4lupa_5_lupa_LuaRuntime *)__pyx_t_2); __pyx_t_2 = 0; /* "lupa/_lupa.pyx":956 * assert obj._runtime is not None * self._runtime = obj._runtime * self._obj = obj # <<<<<<<<<<<<<< * self._state = obj._state * self._refiter = 0 */ __Pyx_INCREF(((PyObject *)__pyx_v_obj)); __Pyx_GIVEREF(((PyObject *)__pyx_v_obj)); __Pyx_GOTREF(__pyx_v_self->_obj); __Pyx_DECREF(((PyObject *)__pyx_v_self->_obj)); __pyx_v_self->_obj = __pyx_v_obj; /* "lupa/_lupa.pyx":957 * self._runtime = obj._runtime * self._obj = obj * self._state = obj._state # <<<<<<<<<<<<<< * self._refiter = 0 * self._what = what */ __pyx_t_3 = __pyx_v_obj->_state; __pyx_v_self->_state = __pyx_t_3; /* "lupa/_lupa.pyx":958 * self._obj = obj * self._state = obj._state * self._refiter = 0 # <<<<<<<<<<<<<< * self._what = what * */ __pyx_v_self->_refiter = 0; /* "lupa/_lupa.pyx":959 * self._state = obj._state * self._refiter = 0 * self._what = what # <<<<<<<<<<<<<< * * def __dealloc__(self): */ __pyx_v_self->_what = __pyx_v_what; /* "lupa/_lupa.pyx":952 * cdef char _what * * def __cinit__(self, _LuaObject obj not None, int what): # <<<<<<<<<<<<<< * self._state = NULL * assert obj._runtime is not None */ /* function exit code */ __pyx_r = 0; goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_2); __Pyx_AddTraceback("lupa._lupa._LuaIter.__cinit__", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = -1; __pyx_L0:; __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "lupa/_lupa.pyx":961 * self._what = what * * def __dealloc__(self): # <<<<<<<<<<<<<< * if self._runtime is None: * return */ /* Python wrapper */ static void __pyx_pw_4lupa_5_lupa_8_LuaIter_3__dealloc__(PyObject *__pyx_v_self); /*proto*/ static void __pyx_pw_4lupa_5_lupa_8_LuaIter_3__dealloc__(PyObject *__pyx_v_self) { __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__dealloc__ (wrapper)", 0); __pyx_pf_4lupa_5_lupa_8_LuaIter_2__dealloc__(((struct __pyx_obj_4lupa_5_lupa__LuaIter *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); } static void __pyx_pf_4lupa_5_lupa_8_LuaIter_2__dealloc__(struct __pyx_obj_4lupa_5_lupa__LuaIter *__pyx_v_self) { lua_State *__pyx_v_L; int __pyx_v_locked; __Pyx_RefNannyDeclarations int __pyx_t_1; int __pyx_t_2; lua_State *__pyx_t_3; PyObject *__pyx_t_4 = NULL; PyObject *__pyx_t_5 = NULL; PyObject *__pyx_t_6 = NULL; PyObject *__pyx_t_7 = NULL; int __pyx_t_8; __Pyx_RefNannySetupContext("__dealloc__", 0); /* "lupa/_lupa.pyx":962 * * def __dealloc__(self): * if self._runtime is None: # <<<<<<<<<<<<<< * return * cdef lua_State* L = self._state */ __pyx_t_1 = (((PyObject *)__pyx_v_self->_runtime) == Py_None); __pyx_t_2 = (__pyx_t_1 != 0); if (__pyx_t_2) { /* "lupa/_lupa.pyx":963 * def __dealloc__(self): * if self._runtime is None: * return # <<<<<<<<<<<<<< * cdef lua_State* L = self._state * if L is not NULL and self._refiter: */ goto __pyx_L0; /* "lupa/_lupa.pyx":962 * * def __dealloc__(self): * if self._runtime is None: # <<<<<<<<<<<<<< * return * cdef lua_State* L = self._state */ } /* "lupa/_lupa.pyx":964 * if self._runtime is None: * return * cdef lua_State* L = self._state # <<<<<<<<<<<<<< * if L is not NULL and self._refiter: * locked = False */ __pyx_t_3 = __pyx_v_self->_state; __pyx_v_L = __pyx_t_3; /* "lupa/_lupa.pyx":965 * return * cdef lua_State* L = self._state * if L is not NULL and self._refiter: # <<<<<<<<<<<<<< * locked = False * try: */ __pyx_t_1 = ((__pyx_v_L != NULL) != 0); if (__pyx_t_1) { } else { __pyx_t_2 = __pyx_t_1; goto __pyx_L5_bool_binop_done; } __pyx_t_1 = (__pyx_v_self->_refiter != 0); __pyx_t_2 = __pyx_t_1; __pyx_L5_bool_binop_done:; if (__pyx_t_2) { /* "lupa/_lupa.pyx":966 * cdef lua_State* L = self._state * if L is not NULL and self._refiter: * locked = False # <<<<<<<<<<<<<< * try: * lock_runtime(self._runtime) */ __pyx_v_locked = 0; /* "lupa/_lupa.pyx":967 * if L is not NULL and self._refiter: * locked = False * try: # <<<<<<<<<<<<<< * lock_runtime(self._runtime) * locked = True */ { __Pyx_PyThreadState_declare __Pyx_PyThreadState_assign __Pyx_ExceptionSave(&__pyx_t_4, &__pyx_t_5, &__pyx_t_6); __Pyx_XGOTREF(__pyx_t_4); __Pyx_XGOTREF(__pyx_t_5); __Pyx_XGOTREF(__pyx_t_6); /*try:*/ { /* "lupa/_lupa.pyx":968 * locked = False * try: * lock_runtime(self._runtime) # <<<<<<<<<<<<<< * locked = True * except: */ __pyx_t_7 = ((PyObject *)__pyx_v_self->_runtime); __Pyx_INCREF(__pyx_t_7); __pyx_t_8 = __pyx_f_4lupa_5_lupa_lock_runtime(((struct __pyx_obj_4lupa_5_lupa_LuaRuntime *)__pyx_t_7)); if (unlikely(__pyx_t_8 == ((int)-1))) __PYX_ERR(0, 968, __pyx_L7_error) __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; /* "lupa/_lupa.pyx":969 * try: * lock_runtime(self._runtime) * locked = True # <<<<<<<<<<<<<< * except: * pass */ __pyx_v_locked = 1; /* "lupa/_lupa.pyx":967 * if L is not NULL and self._refiter: * locked = False * try: # <<<<<<<<<<<<<< * lock_runtime(self._runtime) * locked = True */ } __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; goto __pyx_L12_try_end; __pyx_L7_error:; __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0; /* "lupa/_lupa.pyx":970 * lock_runtime(self._runtime) * locked = True * except: # <<<<<<<<<<<<<< * pass * lua.luaL_unref(L, lua.LUA_REGISTRYINDEX, self._refiter) */ /*except:*/ { __Pyx_ErrRestore(0,0,0); goto __pyx_L8_exception_handled; } __pyx_L8_exception_handled:; __Pyx_XGIVEREF(__pyx_t_4); __Pyx_XGIVEREF(__pyx_t_5); __Pyx_XGIVEREF(__pyx_t_6); __Pyx_ExceptionReset(__pyx_t_4, __pyx_t_5, __pyx_t_6); __pyx_L12_try_end:; } /* "lupa/_lupa.pyx":972 * except: * pass * lua.luaL_unref(L, lua.LUA_REGISTRYINDEX, self._refiter) # <<<<<<<<<<<<<< * if locked: * unlock_runtime(self._runtime) */ luaL_unref(__pyx_v_L, LUA_REGISTRYINDEX, __pyx_v_self->_refiter); /* "lupa/_lupa.pyx":973 * pass * lua.luaL_unref(L, lua.LUA_REGISTRYINDEX, self._refiter) * if locked: # <<<<<<<<<<<<<< * unlock_runtime(self._runtime) * */ __pyx_t_2 = (__pyx_v_locked != 0); if (__pyx_t_2) { /* "lupa/_lupa.pyx":974 * lua.luaL_unref(L, lua.LUA_REGISTRYINDEX, self._refiter) * if locked: * unlock_runtime(self._runtime) # <<<<<<<<<<<<<< * * def __repr__(self): */ __pyx_t_7 = ((PyObject *)__pyx_v_self->_runtime); __Pyx_INCREF(__pyx_t_7); __pyx_f_4lupa_5_lupa_unlock_runtime(((struct __pyx_obj_4lupa_5_lupa_LuaRuntime *)__pyx_t_7)); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; /* "lupa/_lupa.pyx":973 * pass * lua.luaL_unref(L, lua.LUA_REGISTRYINDEX, self._refiter) * if locked: # <<<<<<<<<<<<<< * unlock_runtime(self._runtime) * */ } /* "lupa/_lupa.pyx":965 * return * cdef lua_State* L = self._state * if L is not NULL and self._refiter: # <<<<<<<<<<<<<< * locked = False * try: */ } /* "lupa/_lupa.pyx":961 * self._what = what * * def __dealloc__(self): # <<<<<<<<<<<<<< * if self._runtime is None: * return */ /* function exit code */ __pyx_L0:; __Pyx_RefNannyFinishContext(); } /* "lupa/_lupa.pyx":976 * unlock_runtime(self._runtime) * * def __repr__(self): # <<<<<<<<<<<<<< * return u"LuaIter(%r)" % (self._obj) * */ /* Python wrapper */ static PyObject *__pyx_pw_4lupa_5_lupa_8_LuaIter_5__repr__(PyObject *__pyx_v_self); /*proto*/ static PyObject *__pyx_pw_4lupa_5_lupa_8_LuaIter_5__repr__(PyObject *__pyx_v_self) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__repr__ (wrapper)", 0); __pyx_r = __pyx_pf_4lupa_5_lupa_8_LuaIter_4__repr__(((struct __pyx_obj_4lupa_5_lupa__LuaIter *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_4lupa_5_lupa_8_LuaIter_4__repr__(struct __pyx_obj_4lupa_5_lupa__LuaIter *__pyx_v_self) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; __Pyx_RefNannySetupContext("__repr__", 0); /* "lupa/_lupa.pyx":977 * * def __repr__(self): * return u"LuaIter(%r)" % (self._obj) # <<<<<<<<<<<<<< * * def __iter__(self): */ __Pyx_XDECREF(__pyx_r); __pyx_t_1 = PyUnicode_Format(__pyx_kp_u_LuaIter_r, ((PyObject *)__pyx_v_self->_obj)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 977, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0; /* "lupa/_lupa.pyx":976 * unlock_runtime(self._runtime) * * def __repr__(self): # <<<<<<<<<<<<<< * return u"LuaIter(%r)" % (self._obj) * */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_AddTraceback("lupa._lupa._LuaIter.__repr__", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "lupa/_lupa.pyx":979 * return u"LuaIter(%r)" % (self._obj) * * def __iter__(self): # <<<<<<<<<<<<<< * return self * */ /* Python wrapper */ static PyObject *__pyx_pw_4lupa_5_lupa_8_LuaIter_7__iter__(PyObject *__pyx_v_self); /*proto*/ static PyObject *__pyx_pw_4lupa_5_lupa_8_LuaIter_7__iter__(PyObject *__pyx_v_self) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__iter__ (wrapper)", 0); __pyx_r = __pyx_pf_4lupa_5_lupa_8_LuaIter_6__iter__(((struct __pyx_obj_4lupa_5_lupa__LuaIter *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_4lupa_5_lupa_8_LuaIter_6__iter__(struct __pyx_obj_4lupa_5_lupa__LuaIter *__pyx_v_self) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__iter__", 0); /* "lupa/_lupa.pyx":980 * * def __iter__(self): * return self # <<<<<<<<<<<<<< * * def __next__(self): */ __Pyx_XDECREF(__pyx_r); __Pyx_INCREF(((PyObject *)__pyx_v_self)); __pyx_r = ((PyObject *)__pyx_v_self); goto __pyx_L0; /* "lupa/_lupa.pyx":979 * return u"LuaIter(%r)" % (self._obj) * * def __iter__(self): # <<<<<<<<<<<<<< * return self * */ /* function exit code */ __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "lupa/_lupa.pyx":982 * return self * * def __next__(self): # <<<<<<<<<<<<<< * if self._obj is None: * raise StopIteration */ /* Python wrapper */ static PyObject *__pyx_pw_4lupa_5_lupa_8_LuaIter_9__next__(PyObject *__pyx_v_self); /*proto*/ static PyObject *__pyx_pw_4lupa_5_lupa_8_LuaIter_9__next__(PyObject *__pyx_v_self) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__next__ (wrapper)", 0); __pyx_r = __pyx_pf_4lupa_5_lupa_8_LuaIter_8__next__(((struct __pyx_obj_4lupa_5_lupa__LuaIter *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_4lupa_5_lupa_8_LuaIter_8__next__(struct __pyx_obj_4lupa_5_lupa__LuaIter *__pyx_v_self) { lua_State *__pyx_v_L; int __pyx_v_old_top; PyObject *__pyx_v_retval = NULL; PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations int __pyx_t_1; int __pyx_t_2; lua_State *__pyx_t_3; PyObject *__pyx_t_4 = NULL; int __pyx_t_5; PyObject *__pyx_t_6 = NULL; PyObject *__pyx_t_7 = NULL; int __pyx_t_8; char const *__pyx_t_9; PyObject *__pyx_t_10 = NULL; PyObject *__pyx_t_11 = NULL; PyObject *__pyx_t_12 = NULL; PyObject *__pyx_t_13 = NULL; PyObject *__pyx_t_14 = NULL; PyObject *__pyx_t_15 = NULL; char const *__pyx_t_16; __Pyx_RefNannySetupContext("__next__", 0); /* "lupa/_lupa.pyx":983 * * def __next__(self): * if self._obj is None: # <<<<<<<<<<<<<< * raise StopIteration * cdef lua_State* L = self._obj._state */ __pyx_t_1 = (((PyObject *)__pyx_v_self->_obj) == Py_None); __pyx_t_2 = (__pyx_t_1 != 0); if (__pyx_t_2) { /* "lupa/_lupa.pyx":984 * def __next__(self): * if self._obj is None: * raise StopIteration # <<<<<<<<<<<<<< * cdef lua_State* L = self._obj._state * lock_runtime(self._runtime) */ __Pyx_Raise(__pyx_builtin_StopIteration, 0, 0, 0); __PYX_ERR(0, 984, __pyx_L1_error) /* "lupa/_lupa.pyx":983 * * def __next__(self): * if self._obj is None: # <<<<<<<<<<<<<< * raise StopIteration * cdef lua_State* L = self._obj._state */ } /* "lupa/_lupa.pyx":985 * if self._obj is None: * raise StopIteration * cdef lua_State* L = self._obj._state # <<<<<<<<<<<<<< * lock_runtime(self._runtime) * old_top = lua.lua_gettop(L) */ __pyx_t_3 = __pyx_v_self->_obj->_state; __pyx_v_L = __pyx_t_3; /* "lupa/_lupa.pyx":986 * raise StopIteration * cdef lua_State* L = self._obj._state * lock_runtime(self._runtime) # <<<<<<<<<<<<<< * old_top = lua.lua_gettop(L) * try: */ __pyx_t_4 = ((PyObject *)__pyx_v_self->_runtime); __Pyx_INCREF(__pyx_t_4); __pyx_t_5 = __pyx_f_4lupa_5_lupa_lock_runtime(((struct __pyx_obj_4lupa_5_lupa_LuaRuntime *)__pyx_t_4)); if (unlikely(__pyx_t_5 == ((int)-1))) __PYX_ERR(0, 986, __pyx_L1_error) __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; /* "lupa/_lupa.pyx":987 * cdef lua_State* L = self._obj._state * lock_runtime(self._runtime) * old_top = lua.lua_gettop(L) # <<<<<<<<<<<<<< * try: * if self._obj is None: */ __pyx_v_old_top = lua_gettop(__pyx_v_L); /* "lupa/_lupa.pyx":988 * lock_runtime(self._runtime) * old_top = lua.lua_gettop(L) * try: # <<<<<<<<<<<<<< * if self._obj is None: * raise StopIteration */ /*try:*/ { /* "lupa/_lupa.pyx":989 * old_top = lua.lua_gettop(L) * try: * if self._obj is None: # <<<<<<<<<<<<<< * raise StopIteration * # iterable object */ __pyx_t_2 = (((PyObject *)__pyx_v_self->_obj) == Py_None); __pyx_t_1 = (__pyx_t_2 != 0); if (__pyx_t_1) { /* "lupa/_lupa.pyx":990 * try: * if self._obj is None: * raise StopIteration # <<<<<<<<<<<<<< * # iterable object * lua.lua_rawgeti(L, lua.LUA_REGISTRYINDEX, self._obj._ref) */ __Pyx_Raise(__pyx_builtin_StopIteration, 0, 0, 0); __PYX_ERR(0, 990, __pyx_L5_error) /* "lupa/_lupa.pyx":989 * old_top = lua.lua_gettop(L) * try: * if self._obj is None: # <<<<<<<<<<<<<< * raise StopIteration * # iterable object */ } /* "lupa/_lupa.pyx":992 * raise StopIteration * # iterable object * lua.lua_rawgeti(L, lua.LUA_REGISTRYINDEX, self._obj._ref) # <<<<<<<<<<<<<< * if not lua.lua_istable(L, -1): * if lua.lua_isnil(L, -1): */ lua_rawgeti(__pyx_v_L, LUA_REGISTRYINDEX, __pyx_v_self->_obj->_ref); /* "lupa/_lupa.pyx":993 * # iterable object * lua.lua_rawgeti(L, lua.LUA_REGISTRYINDEX, self._obj._ref) * if not lua.lua_istable(L, -1): # <<<<<<<<<<<<<< * if lua.lua_isnil(L, -1): * lua.lua_pop(L, 1) */ __pyx_t_1 = ((!(lua_istable(__pyx_v_L, -1) != 0)) != 0); if (__pyx_t_1) { /* "lupa/_lupa.pyx":994 * lua.lua_rawgeti(L, lua.LUA_REGISTRYINDEX, self._obj._ref) * if not lua.lua_istable(L, -1): * if lua.lua_isnil(L, -1): # <<<<<<<<<<<<<< * lua.lua_pop(L, 1) * raise LuaError("lost reference") */ __pyx_t_1 = (lua_isnil(__pyx_v_L, -1) != 0); if (__pyx_t_1) { /* "lupa/_lupa.pyx":995 * if not lua.lua_istable(L, -1): * if lua.lua_isnil(L, -1): * lua.lua_pop(L, 1) # <<<<<<<<<<<<<< * raise LuaError("lost reference") * raise TypeError("cannot iterate over non-table (found %r)" % self._obj) */ lua_pop(__pyx_v_L, 1); /* "lupa/_lupa.pyx":996 * if lua.lua_isnil(L, -1): * lua.lua_pop(L, 1) * raise LuaError("lost reference") # <<<<<<<<<<<<<< * raise TypeError("cannot iterate over non-table (found %r)" % self._obj) * if not self._refiter: */ __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_LuaError); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 996, __pyx_L5_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_6 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_tuple__36, NULL); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 996, __pyx_L5_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_Raise(__pyx_t_6, 0, 0, 0); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __PYX_ERR(0, 996, __pyx_L5_error) /* "lupa/_lupa.pyx":994 * lua.lua_rawgeti(L, lua.LUA_REGISTRYINDEX, self._obj._ref) * if not lua.lua_istable(L, -1): * if lua.lua_isnil(L, -1): # <<<<<<<<<<<<<< * lua.lua_pop(L, 1) * raise LuaError("lost reference") */ } /* "lupa/_lupa.pyx":997 * lua.lua_pop(L, 1) * raise LuaError("lost reference") * raise TypeError("cannot iterate over non-table (found %r)" % self._obj) # <<<<<<<<<<<<<< * if not self._refiter: * # initial key */ __pyx_t_6 = __Pyx_PyString_Format(__pyx_kp_s_cannot_iterate_over_non_table_fo, ((PyObject *)__pyx_v_self->_obj)); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 997, __pyx_L5_error) __Pyx_GOTREF(__pyx_t_6); __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 997, __pyx_L5_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_6); __pyx_t_6 = 0; __pyx_t_6 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_t_4, NULL); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 997, __pyx_L5_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_Raise(__pyx_t_6, 0, 0, 0); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __PYX_ERR(0, 997, __pyx_L5_error) /* "lupa/_lupa.pyx":993 * # iterable object * lua.lua_rawgeti(L, lua.LUA_REGISTRYINDEX, self._obj._ref) * if not lua.lua_istable(L, -1): # <<<<<<<<<<<<<< * if lua.lua_isnil(L, -1): * lua.lua_pop(L, 1) */ } /* "lupa/_lupa.pyx":998 * raise LuaError("lost reference") * raise TypeError("cannot iterate over non-table (found %r)" % self._obj) * if not self._refiter: # <<<<<<<<<<<<<< * # initial key * lua.lua_pushnil(L) */ __pyx_t_1 = ((!(__pyx_v_self->_refiter != 0)) != 0); if (__pyx_t_1) { /* "lupa/_lupa.pyx":1000 * if not self._refiter: * # initial key * lua.lua_pushnil(L) # <<<<<<<<<<<<<< * else: * # last key */ lua_pushnil(__pyx_v_L); /* "lupa/_lupa.pyx":998 * raise LuaError("lost reference") * raise TypeError("cannot iterate over non-table (found %r)" % self._obj) * if not self._refiter: # <<<<<<<<<<<<<< * # initial key * lua.lua_pushnil(L) */ goto __pyx_L10; } /* "lupa/_lupa.pyx":1003 * else: * # last key * lua.lua_rawgeti(L, lua.LUA_REGISTRYINDEX, self._refiter) # <<<<<<<<<<<<<< * if lua.lua_next(L, -2): * try: */ /*else*/ { lua_rawgeti(__pyx_v_L, LUA_REGISTRYINDEX, __pyx_v_self->_refiter); } __pyx_L10:; /* "lupa/_lupa.pyx":1004 * # last key * lua.lua_rawgeti(L, lua.LUA_REGISTRYINDEX, self._refiter) * if lua.lua_next(L, -2): # <<<<<<<<<<<<<< * try: * if self._what == KEYS: */ __pyx_t_1 = (lua_next(__pyx_v_L, -2) != 0); if (__pyx_t_1) { /* "lupa/_lupa.pyx":1005 * lua.lua_rawgeti(L, lua.LUA_REGISTRYINDEX, self._refiter) * if lua.lua_next(L, -2): * try: # <<<<<<<<<<<<<< * if self._what == KEYS: * retval = py_from_lua(self._runtime, L, -2) */ /*try:*/ { /* "lupa/_lupa.pyx":1006 * if lua.lua_next(L, -2): * try: * if self._what == KEYS: # <<<<<<<<<<<<<< * retval = py_from_lua(self._runtime, L, -2) * elif self._what == VALUES: */ switch (__pyx_v_self->_what) { case __pyx_e_4lupa_5_lupa_KEYS: /* "lupa/_lupa.pyx":1007 * try: * if self._what == KEYS: * retval = py_from_lua(self._runtime, L, -2) # <<<<<<<<<<<<<< * elif self._what == VALUES: * retval = py_from_lua(self._runtime, L, -1) */ __pyx_t_6 = ((PyObject *)__pyx_v_self->_runtime); __Pyx_INCREF(__pyx_t_6); __pyx_t_4 = __pyx_f_4lupa_5_lupa_py_from_lua(((struct __pyx_obj_4lupa_5_lupa_LuaRuntime *)__pyx_t_6), __pyx_v_L, -2); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1007, __pyx_L13_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __pyx_v_retval = __pyx_t_4; __pyx_t_4 = 0; /* "lupa/_lupa.pyx":1006 * if lua.lua_next(L, -2): * try: * if self._what == KEYS: # <<<<<<<<<<<<<< * retval = py_from_lua(self._runtime, L, -2) * elif self._what == VALUES: */ break; /* "lupa/_lupa.pyx":1008 * if self._what == KEYS: * retval = py_from_lua(self._runtime, L, -2) * elif self._what == VALUES: # <<<<<<<<<<<<<< * retval = py_from_lua(self._runtime, L, -1) * else: # ITEMS */ case __pyx_e_4lupa_5_lupa_VALUES: /* "lupa/_lupa.pyx":1009 * retval = py_from_lua(self._runtime, L, -2) * elif self._what == VALUES: * retval = py_from_lua(self._runtime, L, -1) # <<<<<<<<<<<<<< * else: # ITEMS * retval = (py_from_lua(self._runtime, L, -2), py_from_lua(self._runtime, L, -1)) */ __pyx_t_4 = ((PyObject *)__pyx_v_self->_runtime); __Pyx_INCREF(__pyx_t_4); __pyx_t_6 = __pyx_f_4lupa_5_lupa_py_from_lua(((struct __pyx_obj_4lupa_5_lupa_LuaRuntime *)__pyx_t_4), __pyx_v_L, -1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1009, __pyx_L13_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_v_retval = __pyx_t_6; __pyx_t_6 = 0; /* "lupa/_lupa.pyx":1008 * if self._what == KEYS: * retval = py_from_lua(self._runtime, L, -2) * elif self._what == VALUES: # <<<<<<<<<<<<<< * retval = py_from_lua(self._runtime, L, -1) * else: # ITEMS */ break; default: /* "lupa/_lupa.pyx":1011 * retval = py_from_lua(self._runtime, L, -1) * else: # ITEMS * retval = (py_from_lua(self._runtime, L, -2), py_from_lua(self._runtime, L, -1)) # <<<<<<<<<<<<<< * finally: * # pop value */ __pyx_t_6 = ((PyObject *)__pyx_v_self->_runtime); __Pyx_INCREF(__pyx_t_6); __pyx_t_4 = __pyx_f_4lupa_5_lupa_py_from_lua(((struct __pyx_obj_4lupa_5_lupa_LuaRuntime *)__pyx_t_6), __pyx_v_L, -2); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1011, __pyx_L13_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __pyx_t_6 = ((PyObject *)__pyx_v_self->_runtime); __Pyx_INCREF(__pyx_t_6); __pyx_t_7 = __pyx_f_4lupa_5_lupa_py_from_lua(((struct __pyx_obj_4lupa_5_lupa_LuaRuntime *)__pyx_t_6), __pyx_v_L, -1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1011, __pyx_L13_error) __Pyx_GOTREF(__pyx_t_7); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __pyx_t_6 = PyTuple_New(2); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1011, __pyx_L13_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_4); __Pyx_GIVEREF(__pyx_t_7); PyTuple_SET_ITEM(__pyx_t_6, 1, __pyx_t_7); __pyx_t_4 = 0; __pyx_t_7 = 0; __pyx_v_retval = __pyx_t_6; __pyx_t_6 = 0; break; } } /* "lupa/_lupa.pyx":1014 * finally: * # pop value * lua.lua_pop(L, 1) # <<<<<<<<<<<<<< * # pop and store key * if not self._refiter: */ /*finally:*/ { /*normal exit:*/{ lua_pop(__pyx_v_L, 1); /* "lupa/_lupa.pyx":1016 * lua.lua_pop(L, 1) * # pop and store key * if not self._refiter: # <<<<<<<<<<<<<< * self._refiter = lua.luaL_ref(L, lua.LUA_REGISTRYINDEX) * else: */ __pyx_t_1 = ((!(__pyx_v_self->_refiter != 0)) != 0); if (__pyx_t_1) { /* "lupa/_lupa.pyx":1017 * # pop and store key * if not self._refiter: * self._refiter = lua.luaL_ref(L, lua.LUA_REGISTRYINDEX) # <<<<<<<<<<<<<< * else: * lua.lua_rawseti(L, lua.LUA_REGISTRYINDEX, self._refiter) */ __pyx_v_self->_refiter = luaL_ref(__pyx_v_L, LUA_REGISTRYINDEX); /* "lupa/_lupa.pyx":1016 * lua.lua_pop(L, 1) * # pop and store key * if not self._refiter: # <<<<<<<<<<<<<< * self._refiter = lua.luaL_ref(L, lua.LUA_REGISTRYINDEX) * else: */ goto __pyx_L15; } /* "lupa/_lupa.pyx":1019 * self._refiter = lua.luaL_ref(L, lua.LUA_REGISTRYINDEX) * else: * lua.lua_rawseti(L, lua.LUA_REGISTRYINDEX, self._refiter) # <<<<<<<<<<<<<< * return retval * # iteration done, clean up */ /*else*/ { lua_rawseti(__pyx_v_L, LUA_REGISTRYINDEX, __pyx_v_self->_refiter); } __pyx_L15:; goto __pyx_L14; } __pyx_L13_error:; /*exception exit:*/{ __Pyx_PyThreadState_declare __Pyx_PyThreadState_assign __pyx_t_10 = 0; __pyx_t_11 = 0; __pyx_t_12 = 0; __pyx_t_13 = 0; __pyx_t_14 = 0; __pyx_t_15 = 0; __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0; __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; if (PY_MAJOR_VERSION >= 3) __Pyx_ExceptionSwap(&__pyx_t_13, &__pyx_t_14, &__pyx_t_15); if ((PY_MAJOR_VERSION < 3) || unlikely(__Pyx_GetException(&__pyx_t_10, &__pyx_t_11, &__pyx_t_12) < 0)) __Pyx_ErrFetch(&__pyx_t_10, &__pyx_t_11, &__pyx_t_12); __Pyx_XGOTREF(__pyx_t_10); __Pyx_XGOTREF(__pyx_t_11); __Pyx_XGOTREF(__pyx_t_12); __Pyx_XGOTREF(__pyx_t_13); __Pyx_XGOTREF(__pyx_t_14); __Pyx_XGOTREF(__pyx_t_15); __pyx_t_5 = __pyx_lineno; __pyx_t_8 = __pyx_clineno; __pyx_t_9 = __pyx_filename; { /* "lupa/_lupa.pyx":1014 * finally: * # pop value * lua.lua_pop(L, 1) # <<<<<<<<<<<<<< * # pop and store key * if not self._refiter: */ lua_pop(__pyx_v_L, 1); /* "lupa/_lupa.pyx":1016 * lua.lua_pop(L, 1) * # pop and store key * if not self._refiter: # <<<<<<<<<<<<<< * self._refiter = lua.luaL_ref(L, lua.LUA_REGISTRYINDEX) * else: */ __pyx_t_1 = ((!(__pyx_v_self->_refiter != 0)) != 0); if (__pyx_t_1) { /* "lupa/_lupa.pyx":1017 * # pop and store key * if not self._refiter: * self._refiter = lua.luaL_ref(L, lua.LUA_REGISTRYINDEX) # <<<<<<<<<<<<<< * else: * lua.lua_rawseti(L, lua.LUA_REGISTRYINDEX, self._refiter) */ __pyx_v_self->_refiter = luaL_ref(__pyx_v_L, LUA_REGISTRYINDEX); /* "lupa/_lupa.pyx":1016 * lua.lua_pop(L, 1) * # pop and store key * if not self._refiter: # <<<<<<<<<<<<<< * self._refiter = lua.luaL_ref(L, lua.LUA_REGISTRYINDEX) * else: */ goto __pyx_L18; } /* "lupa/_lupa.pyx":1019 * self._refiter = lua.luaL_ref(L, lua.LUA_REGISTRYINDEX) * else: * lua.lua_rawseti(L, lua.LUA_REGISTRYINDEX, self._refiter) # <<<<<<<<<<<<<< * return retval * # iteration done, clean up */ /*else*/ { lua_rawseti(__pyx_v_L, LUA_REGISTRYINDEX, __pyx_v_self->_refiter); } __pyx_L18:; } if (PY_MAJOR_VERSION >= 3) { __Pyx_XGIVEREF(__pyx_t_13); __Pyx_XGIVEREF(__pyx_t_14); __Pyx_XGIVEREF(__pyx_t_15); __Pyx_ExceptionReset(__pyx_t_13, __pyx_t_14, __pyx_t_15); } __Pyx_XGIVEREF(__pyx_t_10); __Pyx_XGIVEREF(__pyx_t_11); __Pyx_XGIVEREF(__pyx_t_12); __Pyx_ErrRestore(__pyx_t_10, __pyx_t_11, __pyx_t_12); __pyx_t_10 = 0; __pyx_t_11 = 0; __pyx_t_12 = 0; __pyx_t_13 = 0; __pyx_t_14 = 0; __pyx_t_15 = 0; __pyx_lineno = __pyx_t_5; __pyx_clineno = __pyx_t_8; __pyx_filename = __pyx_t_9; goto __pyx_L5_error; } __pyx_L14:; } /* "lupa/_lupa.pyx":1020 * else: * lua.lua_rawseti(L, lua.LUA_REGISTRYINDEX, self._refiter) * return retval # <<<<<<<<<<<<<< * # iteration done, clean up * if self._refiter: */ __Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_v_retval); __pyx_r = __pyx_v_retval; goto __pyx_L4_return; /* "lupa/_lupa.pyx":1004 * # last key * lua.lua_rawgeti(L, lua.LUA_REGISTRYINDEX, self._refiter) * if lua.lua_next(L, -2): # <<<<<<<<<<<<<< * try: * if self._what == KEYS: */ } /* "lupa/_lupa.pyx":1022 * return retval * # iteration done, clean up * if self._refiter: # <<<<<<<<<<<<<< * lua.luaL_unref(L, lua.LUA_REGISTRYINDEX, self._refiter) * self._refiter = 0 */ __pyx_t_1 = (__pyx_v_self->_refiter != 0); if (__pyx_t_1) { /* "lupa/_lupa.pyx":1023 * # iteration done, clean up * if self._refiter: * lua.luaL_unref(L, lua.LUA_REGISTRYINDEX, self._refiter) # <<<<<<<<<<<<<< * self._refiter = 0 * self._obj = None */ luaL_unref(__pyx_v_L, LUA_REGISTRYINDEX, __pyx_v_self->_refiter); /* "lupa/_lupa.pyx":1024 * if self._refiter: * lua.luaL_unref(L, lua.LUA_REGISTRYINDEX, self._refiter) * self._refiter = 0 # <<<<<<<<<<<<<< * self._obj = None * finally: */ __pyx_v_self->_refiter = 0; /* "lupa/_lupa.pyx":1022 * return retval * # iteration done, clean up * if self._refiter: # <<<<<<<<<<<<<< * lua.luaL_unref(L, lua.LUA_REGISTRYINDEX, self._refiter) * self._refiter = 0 */ } /* "lupa/_lupa.pyx":1025 * lua.luaL_unref(L, lua.LUA_REGISTRYINDEX, self._refiter) * self._refiter = 0 * self._obj = None # <<<<<<<<<<<<<< * finally: * lua.lua_settop(L, old_top) */ __Pyx_INCREF(Py_None); __Pyx_GIVEREF(Py_None); __Pyx_GOTREF(__pyx_v_self->_obj); __Pyx_DECREF(((PyObject *)__pyx_v_self->_obj)); __pyx_v_self->_obj = ((struct __pyx_obj_4lupa_5_lupa__LuaObject *)Py_None); } /* "lupa/_lupa.pyx":1027 * self._obj = None * finally: * lua.lua_settop(L, old_top) # <<<<<<<<<<<<<< * unlock_runtime(self._runtime) * raise StopIteration */ /*finally:*/ { /*normal exit:*/{ lua_settop(__pyx_v_L, __pyx_v_old_top); /* "lupa/_lupa.pyx":1028 * finally: * lua.lua_settop(L, old_top) * unlock_runtime(self._runtime) # <<<<<<<<<<<<<< * raise StopIteration * */ __pyx_t_6 = ((PyObject *)__pyx_v_self->_runtime); __Pyx_INCREF(__pyx_t_6); __pyx_f_4lupa_5_lupa_unlock_runtime(((struct __pyx_obj_4lupa_5_lupa_LuaRuntime *)__pyx_t_6)); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; goto __pyx_L6; } __pyx_L5_error:; /*exception exit:*/{ __Pyx_PyThreadState_declare __Pyx_PyThreadState_assign __pyx_t_15 = 0; __pyx_t_14 = 0; __pyx_t_13 = 0; __pyx_t_12 = 0; __pyx_t_11 = 0; __pyx_t_10 = 0; __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0; __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; if (PY_MAJOR_VERSION >= 3) __Pyx_ExceptionSwap(&__pyx_t_12, &__pyx_t_11, &__pyx_t_10); if ((PY_MAJOR_VERSION < 3) || unlikely(__Pyx_GetException(&__pyx_t_15, &__pyx_t_14, &__pyx_t_13) < 0)) __Pyx_ErrFetch(&__pyx_t_15, &__pyx_t_14, &__pyx_t_13); __Pyx_XGOTREF(__pyx_t_15); __Pyx_XGOTREF(__pyx_t_14); __Pyx_XGOTREF(__pyx_t_13); __Pyx_XGOTREF(__pyx_t_12); __Pyx_XGOTREF(__pyx_t_11); __Pyx_XGOTREF(__pyx_t_10); __pyx_t_8 = __pyx_lineno; __pyx_t_5 = __pyx_clineno; __pyx_t_16 = __pyx_filename; { /* "lupa/_lupa.pyx":1027 * self._obj = None * finally: * lua.lua_settop(L, old_top) # <<<<<<<<<<<<<< * unlock_runtime(self._runtime) * raise StopIteration */ lua_settop(__pyx_v_L, __pyx_v_old_top); /* "lupa/_lupa.pyx":1028 * finally: * lua.lua_settop(L, old_top) * unlock_runtime(self._runtime) # <<<<<<<<<<<<<< * raise StopIteration * */ __pyx_t_6 = ((PyObject *)__pyx_v_self->_runtime); __Pyx_INCREF(__pyx_t_6); __pyx_f_4lupa_5_lupa_unlock_runtime(((struct __pyx_obj_4lupa_5_lupa_LuaRuntime *)__pyx_t_6)); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; } if (PY_MAJOR_VERSION >= 3) { __Pyx_XGIVEREF(__pyx_t_12); __Pyx_XGIVEREF(__pyx_t_11); __Pyx_XGIVEREF(__pyx_t_10); __Pyx_ExceptionReset(__pyx_t_12, __pyx_t_11, __pyx_t_10); } __Pyx_XGIVEREF(__pyx_t_15); __Pyx_XGIVEREF(__pyx_t_14); __Pyx_XGIVEREF(__pyx_t_13); __Pyx_ErrRestore(__pyx_t_15, __pyx_t_14, __pyx_t_13); __pyx_t_15 = 0; __pyx_t_14 = 0; __pyx_t_13 = 0; __pyx_t_12 = 0; __pyx_t_11 = 0; __pyx_t_10 = 0; __pyx_lineno = __pyx_t_8; __pyx_clineno = __pyx_t_5; __pyx_filename = __pyx_t_16; goto __pyx_L1_error; } __pyx_L4_return: { __pyx_t_10 = __pyx_r; __pyx_r = 0; /* "lupa/_lupa.pyx":1027 * self._obj = None * finally: * lua.lua_settop(L, old_top) # <<<<<<<<<<<<<< * unlock_runtime(self._runtime) * raise StopIteration */ lua_settop(__pyx_v_L, __pyx_v_old_top); /* "lupa/_lupa.pyx":1028 * finally: * lua.lua_settop(L, old_top) * unlock_runtime(self._runtime) # <<<<<<<<<<<<<< * raise StopIteration * */ __pyx_t_6 = ((PyObject *)__pyx_v_self->_runtime); __Pyx_INCREF(__pyx_t_6); __pyx_f_4lupa_5_lupa_unlock_runtime(((struct __pyx_obj_4lupa_5_lupa_LuaRuntime *)__pyx_t_6)); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __pyx_r = __pyx_t_10; __pyx_t_10 = 0; goto __pyx_L0; } __pyx_L6:; } /* "lupa/_lupa.pyx":1029 * lua.lua_settop(L, old_top) * unlock_runtime(self._runtime) * raise StopIteration # <<<<<<<<<<<<<< * * # type conversions and protocol adaptations */ __Pyx_Raise(__pyx_builtin_StopIteration, 0, 0, 0); __PYX_ERR(0, 1029, __pyx_L1_error) /* "lupa/_lupa.pyx":982 * return self * * def __next__(self): # <<<<<<<<<<<<<< * if self._obj is None: * raise StopIteration */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_4); __Pyx_XDECREF(__pyx_t_6); __Pyx_XDECREF(__pyx_t_7); __Pyx_AddTraceback("lupa._lupa._LuaIter.__next__", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XDECREF(__pyx_v_retval); __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "(tree fragment)":1 * def __reduce_cython__(self): # <<<<<<<<<<<<<< * raise TypeError("no default __reduce__ due to non-trivial __cinit__") * def __setstate_cython__(self, __pyx_state): */ /* Python wrapper */ static PyObject *__pyx_pw_4lupa_5_lupa_8_LuaIter_11__reduce_cython__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ static char __pyx_doc_4lupa_5_lupa_8_LuaIter_10__reduce_cython__[] = "_LuaIter.__reduce_cython__(self)"; static PyMethodDef __pyx_mdef_4lupa_5_lupa_8_LuaIter_11__reduce_cython__ = {"__reduce_cython__", (PyCFunction)__pyx_pw_4lupa_5_lupa_8_LuaIter_11__reduce_cython__, METH_NOARGS, __pyx_doc_4lupa_5_lupa_8_LuaIter_10__reduce_cython__}; static PyObject *__pyx_pw_4lupa_5_lupa_8_LuaIter_11__reduce_cython__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__reduce_cython__ (wrapper)", 0); __pyx_r = __pyx_pf_4lupa_5_lupa_8_LuaIter_10__reduce_cython__(((struct __pyx_obj_4lupa_5_lupa__LuaIter *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_4lupa_5_lupa_8_LuaIter_10__reduce_cython__(CYTHON_UNUSED struct __pyx_obj_4lupa_5_lupa__LuaIter *__pyx_v_self) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; __Pyx_RefNannySetupContext("__reduce_cython__", 0); /* "(tree fragment)":2 * def __reduce_cython__(self): * raise TypeError("no default __reduce__ due to non-trivial __cinit__") # <<<<<<<<<<<<<< * def __setstate_cython__(self, __pyx_state): * raise TypeError("no default __reduce__ due to non-trivial __cinit__") */ __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__37, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 2, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_Raise(__pyx_t_1, 0, 0, 0); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __PYX_ERR(2, 2, __pyx_L1_error) /* "(tree fragment)":1 * def __reduce_cython__(self): # <<<<<<<<<<<<<< * raise TypeError("no default __reduce__ due to non-trivial __cinit__") * def __setstate_cython__(self, __pyx_state): */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_AddTraceback("lupa._lupa._LuaIter.__reduce_cython__", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "(tree fragment)":3 * def __reduce_cython__(self): * raise TypeError("no default __reduce__ due to non-trivial __cinit__") * def __setstate_cython__(self, __pyx_state): # <<<<<<<<<<<<<< * raise TypeError("no default __reduce__ due to non-trivial __cinit__") */ /* Python wrapper */ static PyObject *__pyx_pw_4lupa_5_lupa_8_LuaIter_13__setstate_cython__(PyObject *__pyx_v_self, PyObject *__pyx_v___pyx_state); /*proto*/ static char __pyx_doc_4lupa_5_lupa_8_LuaIter_12__setstate_cython__[] = "_LuaIter.__setstate_cython__(self, __pyx_state)"; static PyMethodDef __pyx_mdef_4lupa_5_lupa_8_LuaIter_13__setstate_cython__ = {"__setstate_cython__", (PyCFunction)__pyx_pw_4lupa_5_lupa_8_LuaIter_13__setstate_cython__, METH_O, __pyx_doc_4lupa_5_lupa_8_LuaIter_12__setstate_cython__}; static PyObject *__pyx_pw_4lupa_5_lupa_8_LuaIter_13__setstate_cython__(PyObject *__pyx_v_self, PyObject *__pyx_v___pyx_state) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__setstate_cython__ (wrapper)", 0); __pyx_r = __pyx_pf_4lupa_5_lupa_8_LuaIter_12__setstate_cython__(((struct __pyx_obj_4lupa_5_lupa__LuaIter *)__pyx_v_self), ((PyObject *)__pyx_v___pyx_state)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_4lupa_5_lupa_8_LuaIter_12__setstate_cython__(CYTHON_UNUSED struct __pyx_obj_4lupa_5_lupa__LuaIter *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v___pyx_state) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; __Pyx_RefNannySetupContext("__setstate_cython__", 0); /* "(tree fragment)":4 * raise TypeError("no default __reduce__ due to non-trivial __cinit__") * def __setstate_cython__(self, __pyx_state): * raise TypeError("no default __reduce__ due to non-trivial __cinit__") # <<<<<<<<<<<<<< */ __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__38, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 4, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_Raise(__pyx_t_1, 0, 0, 0); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __PYX_ERR(2, 4, __pyx_L1_error) /* "(tree fragment)":3 * def __reduce_cython__(self): * raise TypeError("no default __reduce__ due to non-trivial __cinit__") * def __setstate_cython__(self, __pyx_state): # <<<<<<<<<<<<<< * raise TypeError("no default __reduce__ due to non-trivial __cinit__") */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_AddTraceback("lupa._lupa._LuaIter.__setstate_cython__", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "lupa/_lupa.pyx":1033 * # 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) == unpack_wrapped_pyfunction): */ static int __pyx_f_4lupa_5_lupa_py_asfunc_call(lua_State *__pyx_v_L) { int __pyx_r; int __pyx_t_1; int __pyx_t_2; /* "lupa/_lupa.pyx":1034 * * 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) == unpack_wrapped_pyfunction): * # special case: unwrap_lua_object() calls this to find out the Python object */ __pyx_t_2 = ((lua_gettop(__pyx_v_L) == 1) != 0); if (__pyx_t_2) { } else { __pyx_t_1 = __pyx_t_2; goto __pyx_L4_bool_binop_done; } /* "lupa/_lupa.pyx":1035 * 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) == unpack_wrapped_pyfunction): # <<<<<<<<<<<<<< * # special case: unwrap_lua_object() calls this to find out the Python object * lua.lua_pushvalue(L, lua.lua_upvalueindex(1)) */ __pyx_t_2 = (lua_islightuserdata(__pyx_v_L, 1) != 0); if (__pyx_t_2) { } else { __pyx_t_1 = __pyx_t_2; goto __pyx_L4_bool_binop_done; } __pyx_t_2 = ((lua_topointer(__pyx_v_L, 1) == ((void *)__pyx_f_4lupa_5_lupa_unpack_wrapped_pyfunction)) != 0); __pyx_t_1 = __pyx_t_2; __pyx_L4_bool_binop_done:; /* "lupa/_lupa.pyx":1034 * * 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) == unpack_wrapped_pyfunction): * # special case: unwrap_lua_object() calls this to find out the Python object */ if (__pyx_t_1) { /* "lupa/_lupa.pyx":1037 * and lua.lua_topointer(L, 1) == unpack_wrapped_pyfunction): * # special case: unwrap_lua_object() calls this to find out the Python object * lua.lua_pushvalue(L, lua.lua_upvalueindex(1)) # <<<<<<<<<<<<<< * return 1 * lua.lua_pushvalue(L, lua.lua_upvalueindex(1)) */ lua_pushvalue(__pyx_v_L, lua_upvalueindex(1)); /* "lupa/_lupa.pyx":1038 * # special case: unwrap_lua_object() calls this to find out the Python object * lua.lua_pushvalue(L, lua.lua_upvalueindex(1)) * return 1 # <<<<<<<<<<<<<< * lua.lua_pushvalue(L, lua.lua_upvalueindex(1)) * lua.lua_insert(L, 1) */ __pyx_r = 1; goto __pyx_L0; /* "lupa/_lupa.pyx":1034 * * 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) == unpack_wrapped_pyfunction): * # special case: unwrap_lua_object() calls this to find out the Python object */ } /* "lupa/_lupa.pyx":1039 * lua.lua_pushvalue(L, lua.lua_upvalueindex(1)) * return 1 * lua.lua_pushvalue(L, lua.lua_upvalueindex(1)) # <<<<<<<<<<<<<< * lua.lua_insert(L, 1) * return py_object_call(L) */ lua_pushvalue(__pyx_v_L, lua_upvalueindex(1)); /* "lupa/_lupa.pyx":1040 * return 1 * lua.lua_pushvalue(L, lua.lua_upvalueindex(1)) * lua.lua_insert(L, 1) # <<<<<<<<<<<<<< * return py_object_call(L) * */ lua_insert(__pyx_v_L, 1); /* "lupa/_lupa.pyx":1041 * lua.lua_pushvalue(L, lua.lua_upvalueindex(1)) * lua.lua_insert(L, 1) * return py_object_call(L) # <<<<<<<<<<<<<< * * cdef py_object* unpack_wrapped_pyfunction(lua_State* L, int n) nogil: */ __pyx_r = __pyx_f_4lupa_5_lupa_py_object_call(__pyx_v_L); goto __pyx_L0; /* "lupa/_lupa.pyx":1033 * # 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) == unpack_wrapped_pyfunction): */ /* function exit code */ __pyx_L0:; return __pyx_r; } /* "lupa/_lupa.pyx":1043 * 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 py_asfunc_call: */ static struct __pyx_t_4lupa_5_lupa_py_object *__pyx_f_4lupa_5_lupa_unpack_wrapped_pyfunction(lua_State *__pyx_v_L, int __pyx_v_n) { lua_CFunction __pyx_v_cfunction; struct __pyx_t_4lupa_5_lupa_py_object *__pyx_r; int __pyx_t_1; /* "lupa/_lupa.pyx":1044 * * 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 py_asfunc_call: * lua.lua_pushvalue(L, n) */ __pyx_v_cfunction = lua_tocfunction(__pyx_v_L, __pyx_v_n); /* "lupa/_lupa.pyx":1045 * 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 py_asfunc_call: # <<<<<<<<<<<<<< * lua.lua_pushvalue(L, n) * lua.lua_pushlightuserdata(L, unpack_wrapped_pyfunction) */ __pyx_t_1 = ((__pyx_v_cfunction == ((lua_CFunction)__pyx_f_4lupa_5_lupa_py_asfunc_call)) != 0); if (__pyx_t_1) { /* "lupa/_lupa.pyx":1046 * cdef lua.lua_CFunction cfunction = lua.lua_tocfunction(L, n) * if cfunction is py_asfunc_call: * lua.lua_pushvalue(L, n) # <<<<<<<<<<<<<< * lua.lua_pushlightuserdata(L, unpack_wrapped_pyfunction) * if lua.lua_pcall(L, 1, 1, 0) == 0: */ lua_pushvalue(__pyx_v_L, __pyx_v_n); /* "lupa/_lupa.pyx":1047 * if cfunction is py_asfunc_call: * lua.lua_pushvalue(L, n) * lua.lua_pushlightuserdata(L, unpack_wrapped_pyfunction) # <<<<<<<<<<<<<< * if lua.lua_pcall(L, 1, 1, 0) == 0: * return unpack_userdata(L, -1) */ lua_pushlightuserdata(__pyx_v_L, ((void *)__pyx_f_4lupa_5_lupa_unpack_wrapped_pyfunction)); /* "lupa/_lupa.pyx":1048 * lua.lua_pushvalue(L, n) * lua.lua_pushlightuserdata(L, unpack_wrapped_pyfunction) * if lua.lua_pcall(L, 1, 1, 0) == 0: # <<<<<<<<<<<<<< * return unpack_userdata(L, -1) * return NULL */ __pyx_t_1 = ((lua_pcall(__pyx_v_L, 1, 1, 0) == 0) != 0); if (__pyx_t_1) { /* "lupa/_lupa.pyx":1049 * lua.lua_pushlightuserdata(L, unpack_wrapped_pyfunction) * if lua.lua_pcall(L, 1, 1, 0) == 0: * return unpack_userdata(L, -1) # <<<<<<<<<<<<<< * return NULL * */ __pyx_r = __pyx_f_4lupa_5_lupa_unpack_userdata(__pyx_v_L, -1); goto __pyx_L0; /* "lupa/_lupa.pyx":1048 * lua.lua_pushvalue(L, n) * lua.lua_pushlightuserdata(L, unpack_wrapped_pyfunction) * if lua.lua_pcall(L, 1, 1, 0) == 0: # <<<<<<<<<<<<<< * return unpack_userdata(L, -1) * return NULL */ } /* "lupa/_lupa.pyx":1045 * 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 py_asfunc_call: # <<<<<<<<<<<<<< * lua.lua_pushvalue(L, n) * lua.lua_pushlightuserdata(L, unpack_wrapped_pyfunction) */ } /* "lupa/_lupa.pyx":1050 * if lua.lua_pcall(L, 1, 1, 0) == 0: * return unpack_userdata(L, -1) * return NULL # <<<<<<<<<<<<<< * * */ __pyx_r = NULL; goto __pyx_L0; /* "lupa/_lupa.pyx":1043 * 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 py_asfunc_call: */ /* function exit code */ __pyx_L0:; return __pyx_r; } /* "lupa/_lupa.pyx":1059 * cdef object _obj * cdef int _type_flags * def __cinit__(self): # <<<<<<<<<<<<<< * self._type_flags = 0 * def __init__(self): */ /* Python wrapper */ static int __pyx_pw_4lupa_5_lupa_18_PyProtocolWrapper_1__cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ static int __pyx_pw_4lupa_5_lupa_18_PyProtocolWrapper_1__cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { int __pyx_r; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__cinit__ (wrapper)", 0); if (unlikely(PyTuple_GET_SIZE(__pyx_args) > 0)) { __Pyx_RaiseArgtupleInvalid("__cinit__", 1, 0, 0, PyTuple_GET_SIZE(__pyx_args)); return -1;} if (unlikely(__pyx_kwds) && unlikely(PyDict_Size(__pyx_kwds) > 0) && unlikely(!__Pyx_CheckKeywordStrings(__pyx_kwds, "__cinit__", 0))) return -1; __pyx_r = __pyx_pf_4lupa_5_lupa_18_PyProtocolWrapper___cinit__(((struct __pyx_obj_4lupa_5_lupa__PyProtocolWrapper *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static int __pyx_pf_4lupa_5_lupa_18_PyProtocolWrapper___cinit__(struct __pyx_obj_4lupa_5_lupa__PyProtocolWrapper *__pyx_v_self) { int __pyx_r; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__cinit__", 0); /* "lupa/_lupa.pyx":1060 * cdef int _type_flags * def __cinit__(self): * self._type_flags = 0 # <<<<<<<<<<<<<< * def __init__(self): * raise TypeError("Type cannot be instantiated from Python") */ __pyx_v_self->_type_flags = 0; /* "lupa/_lupa.pyx":1059 * cdef object _obj * cdef int _type_flags * def __cinit__(self): # <<<<<<<<<<<<<< * self._type_flags = 0 * def __init__(self): */ /* function exit code */ __pyx_r = 0; __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "lupa/_lupa.pyx":1061 * def __cinit__(self): * self._type_flags = 0 * def __init__(self): # <<<<<<<<<<<<<< * raise TypeError("Type cannot be instantiated from Python") * */ /* Python wrapper */ static int __pyx_pw_4lupa_5_lupa_18_PyProtocolWrapper_3__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ static int __pyx_pw_4lupa_5_lupa_18_PyProtocolWrapper_3__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { int __pyx_r; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__init__ (wrapper)", 0); if (unlikely(PyTuple_GET_SIZE(__pyx_args) > 0)) { __Pyx_RaiseArgtupleInvalid("__init__", 1, 0, 0, PyTuple_GET_SIZE(__pyx_args)); return -1;} if (unlikely(__pyx_kwds) && unlikely(PyDict_Size(__pyx_kwds) > 0) && unlikely(!__Pyx_CheckKeywordStrings(__pyx_kwds, "__init__", 0))) return -1; __pyx_r = __pyx_pf_4lupa_5_lupa_18_PyProtocolWrapper_2__init__(((struct __pyx_obj_4lupa_5_lupa__PyProtocolWrapper *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static int __pyx_pf_4lupa_5_lupa_18_PyProtocolWrapper_2__init__(CYTHON_UNUSED struct __pyx_obj_4lupa_5_lupa__PyProtocolWrapper *__pyx_v_self) { int __pyx_r; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; __Pyx_RefNannySetupContext("__init__", 0); /* "lupa/_lupa.pyx":1062 * self._type_flags = 0 * def __init__(self): * raise TypeError("Type cannot be instantiated from Python") # <<<<<<<<<<<<<< * * */ __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__39, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1062, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_Raise(__pyx_t_1, 0, 0, 0); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __PYX_ERR(0, 1062, __pyx_L1_error) /* "lupa/_lupa.pyx":1061 * def __cinit__(self): * self._type_flags = 0 * def __init__(self): # <<<<<<<<<<<<<< * raise TypeError("Type cannot be instantiated from Python") * */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_AddTraceback("lupa._lupa._PyProtocolWrapper.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = -1; __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "(tree fragment)":1 * def __reduce_cython__(self): # <<<<<<<<<<<<<< * raise TypeError("no default __reduce__ due to non-trivial __cinit__") * def __setstate_cython__(self, __pyx_state): */ /* Python wrapper */ static PyObject *__pyx_pw_4lupa_5_lupa_18_PyProtocolWrapper_5__reduce_cython__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ static char __pyx_doc_4lupa_5_lupa_18_PyProtocolWrapper_4__reduce_cython__[] = "_PyProtocolWrapper.__reduce_cython__(self)"; static PyMethodDef __pyx_mdef_4lupa_5_lupa_18_PyProtocolWrapper_5__reduce_cython__ = {"__reduce_cython__", (PyCFunction)__pyx_pw_4lupa_5_lupa_18_PyProtocolWrapper_5__reduce_cython__, METH_NOARGS, __pyx_doc_4lupa_5_lupa_18_PyProtocolWrapper_4__reduce_cython__}; static PyObject *__pyx_pw_4lupa_5_lupa_18_PyProtocolWrapper_5__reduce_cython__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__reduce_cython__ (wrapper)", 0); __pyx_r = __pyx_pf_4lupa_5_lupa_18_PyProtocolWrapper_4__reduce_cython__(((struct __pyx_obj_4lupa_5_lupa__PyProtocolWrapper *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_4lupa_5_lupa_18_PyProtocolWrapper_4__reduce_cython__(CYTHON_UNUSED struct __pyx_obj_4lupa_5_lupa__PyProtocolWrapper *__pyx_v_self) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; __Pyx_RefNannySetupContext("__reduce_cython__", 0); /* "(tree fragment)":2 * def __reduce_cython__(self): * raise TypeError("no default __reduce__ due to non-trivial __cinit__") # <<<<<<<<<<<<<< * def __setstate_cython__(self, __pyx_state): * raise TypeError("no default __reduce__ due to non-trivial __cinit__") */ __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__40, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 2, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_Raise(__pyx_t_1, 0, 0, 0); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __PYX_ERR(2, 2, __pyx_L1_error) /* "(tree fragment)":1 * def __reduce_cython__(self): # <<<<<<<<<<<<<< * raise TypeError("no default __reduce__ due to non-trivial __cinit__") * def __setstate_cython__(self, __pyx_state): */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_AddTraceback("lupa._lupa._PyProtocolWrapper.__reduce_cython__", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "(tree fragment)":3 * def __reduce_cython__(self): * raise TypeError("no default __reduce__ due to non-trivial __cinit__") * def __setstate_cython__(self, __pyx_state): # <<<<<<<<<<<<<< * raise TypeError("no default __reduce__ due to non-trivial __cinit__") */ /* Python wrapper */ static PyObject *__pyx_pw_4lupa_5_lupa_18_PyProtocolWrapper_7__setstate_cython__(PyObject *__pyx_v_self, PyObject *__pyx_v___pyx_state); /*proto*/ static char __pyx_doc_4lupa_5_lupa_18_PyProtocolWrapper_6__setstate_cython__[] = "_PyProtocolWrapper.__setstate_cython__(self, __pyx_state)"; static PyMethodDef __pyx_mdef_4lupa_5_lupa_18_PyProtocolWrapper_7__setstate_cython__ = {"__setstate_cython__", (PyCFunction)__pyx_pw_4lupa_5_lupa_18_PyProtocolWrapper_7__setstate_cython__, METH_O, __pyx_doc_4lupa_5_lupa_18_PyProtocolWrapper_6__setstate_cython__}; static PyObject *__pyx_pw_4lupa_5_lupa_18_PyProtocolWrapper_7__setstate_cython__(PyObject *__pyx_v_self, PyObject *__pyx_v___pyx_state) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__setstate_cython__ (wrapper)", 0); __pyx_r = __pyx_pf_4lupa_5_lupa_18_PyProtocolWrapper_6__setstate_cython__(((struct __pyx_obj_4lupa_5_lupa__PyProtocolWrapper *)__pyx_v_self), ((PyObject *)__pyx_v___pyx_state)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_4lupa_5_lupa_18_PyProtocolWrapper_6__setstate_cython__(CYTHON_UNUSED struct __pyx_obj_4lupa_5_lupa__PyProtocolWrapper *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v___pyx_state) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; __Pyx_RefNannySetupContext("__setstate_cython__", 0); /* "(tree fragment)":4 * raise TypeError("no default __reduce__ due to non-trivial __cinit__") * def __setstate_cython__(self, __pyx_state): * raise TypeError("no default __reduce__ due to non-trivial __cinit__") # <<<<<<<<<<<<<< */ __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__41, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 4, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_Raise(__pyx_t_1, 0, 0, 0); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __PYX_ERR(2, 4, __pyx_L1_error) /* "(tree fragment)":3 * def __reduce_cython__(self): * raise TypeError("no default __reduce__ due to non-trivial __cinit__") * def __setstate_cython__(self, __pyx_state): # <<<<<<<<<<<<<< * raise TypeError("no default __reduce__ due to non-trivial __cinit__") */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_AddTraceback("lupa._lupa._PyProtocolWrapper.__setstate_cython__", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "lupa/_lupa.pyx":1065 * * * def as_attrgetter(obj): # <<<<<<<<<<<<<< * cdef _PyProtocolWrapper wrap = _PyProtocolWrapper.__new__(_PyProtocolWrapper) * wrap._obj = obj */ /* Python wrapper */ static PyObject *__pyx_pw_4lupa_5_lupa_7as_attrgetter(PyObject *__pyx_self, PyObject *__pyx_v_obj); /*proto*/ static char __pyx_doc_4lupa_5_lupa_6as_attrgetter[] = "as_attrgetter(obj)"; static PyMethodDef __pyx_mdef_4lupa_5_lupa_7as_attrgetter = {"as_attrgetter", (PyCFunction)__pyx_pw_4lupa_5_lupa_7as_attrgetter, METH_O, __pyx_doc_4lupa_5_lupa_6as_attrgetter}; static PyObject *__pyx_pw_4lupa_5_lupa_7as_attrgetter(PyObject *__pyx_self, PyObject *__pyx_v_obj) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("as_attrgetter (wrapper)", 0); __pyx_r = __pyx_pf_4lupa_5_lupa_6as_attrgetter(__pyx_self, ((PyObject *)__pyx_v_obj)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_4lupa_5_lupa_6as_attrgetter(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_obj) { struct __pyx_obj_4lupa_5_lupa__PyProtocolWrapper *__pyx_v_wrap = 0; PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; __Pyx_RefNannySetupContext("as_attrgetter", 0); /* "lupa/_lupa.pyx":1066 * * def as_attrgetter(obj): * cdef _PyProtocolWrapper wrap = _PyProtocolWrapper.__new__(_PyProtocolWrapper) # <<<<<<<<<<<<<< * wrap._obj = obj * wrap._type_flags = 0 */ __pyx_t_1 = __pyx_tp_new_4lupa_5_lupa__PyProtocolWrapper(((PyTypeObject *)__pyx_ptype_4lupa_5_lupa__PyProtocolWrapper), __pyx_empty_tuple, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1066, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); if (!(likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_4lupa_5_lupa__PyProtocolWrapper)))) __PYX_ERR(0, 1066, __pyx_L1_error) __pyx_v_wrap = ((struct __pyx_obj_4lupa_5_lupa__PyProtocolWrapper *)__pyx_t_1); __pyx_t_1 = 0; /* "lupa/_lupa.pyx":1067 * def as_attrgetter(obj): * cdef _PyProtocolWrapper wrap = _PyProtocolWrapper.__new__(_PyProtocolWrapper) * wrap._obj = obj # <<<<<<<<<<<<<< * wrap._type_flags = 0 * return wrap */ __Pyx_INCREF(__pyx_v_obj); __Pyx_GIVEREF(__pyx_v_obj); __Pyx_GOTREF(__pyx_v_wrap->_obj); __Pyx_DECREF(__pyx_v_wrap->_obj); __pyx_v_wrap->_obj = __pyx_v_obj; /* "lupa/_lupa.pyx":1068 * cdef _PyProtocolWrapper wrap = _PyProtocolWrapper.__new__(_PyProtocolWrapper) * wrap._obj = obj * wrap._type_flags = 0 # <<<<<<<<<<<<<< * return wrap * */ __pyx_v_wrap->_type_flags = 0; /* "lupa/_lupa.pyx":1069 * wrap._obj = obj * wrap._type_flags = 0 * return wrap # <<<<<<<<<<<<<< * * def as_itemgetter(obj): */ __Pyx_XDECREF(__pyx_r); __Pyx_INCREF(((PyObject *)__pyx_v_wrap)); __pyx_r = ((PyObject *)__pyx_v_wrap); goto __pyx_L0; /* "lupa/_lupa.pyx":1065 * * * def as_attrgetter(obj): # <<<<<<<<<<<<<< * cdef _PyProtocolWrapper wrap = _PyProtocolWrapper.__new__(_PyProtocolWrapper) * wrap._obj = obj */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_AddTraceback("lupa._lupa.as_attrgetter", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XDECREF((PyObject *)__pyx_v_wrap); __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "lupa/_lupa.pyx":1071 * return wrap * * def as_itemgetter(obj): # <<<<<<<<<<<<<< * cdef _PyProtocolWrapper wrap = _PyProtocolWrapper.__new__(_PyProtocolWrapper) * wrap._obj = obj */ /* Python wrapper */ static PyObject *__pyx_pw_4lupa_5_lupa_9as_itemgetter(PyObject *__pyx_self, PyObject *__pyx_v_obj); /*proto*/ static char __pyx_doc_4lupa_5_lupa_8as_itemgetter[] = "as_itemgetter(obj)"; static PyMethodDef __pyx_mdef_4lupa_5_lupa_9as_itemgetter = {"as_itemgetter", (PyCFunction)__pyx_pw_4lupa_5_lupa_9as_itemgetter, METH_O, __pyx_doc_4lupa_5_lupa_8as_itemgetter}; static PyObject *__pyx_pw_4lupa_5_lupa_9as_itemgetter(PyObject *__pyx_self, PyObject *__pyx_v_obj) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("as_itemgetter (wrapper)", 0); __pyx_r = __pyx_pf_4lupa_5_lupa_8as_itemgetter(__pyx_self, ((PyObject *)__pyx_v_obj)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_4lupa_5_lupa_8as_itemgetter(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_obj) { struct __pyx_obj_4lupa_5_lupa__PyProtocolWrapper *__pyx_v_wrap = 0; PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; __Pyx_RefNannySetupContext("as_itemgetter", 0); /* "lupa/_lupa.pyx":1072 * * def as_itemgetter(obj): * cdef _PyProtocolWrapper wrap = _PyProtocolWrapper.__new__(_PyProtocolWrapper) # <<<<<<<<<<<<<< * wrap._obj = obj * wrap._type_flags = OBJ_AS_INDEX */ __pyx_t_1 = __pyx_tp_new_4lupa_5_lupa__PyProtocolWrapper(((PyTypeObject *)__pyx_ptype_4lupa_5_lupa__PyProtocolWrapper), __pyx_empty_tuple, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1072, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); if (!(likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_4lupa_5_lupa__PyProtocolWrapper)))) __PYX_ERR(0, 1072, __pyx_L1_error) __pyx_v_wrap = ((struct __pyx_obj_4lupa_5_lupa__PyProtocolWrapper *)__pyx_t_1); __pyx_t_1 = 0; /* "lupa/_lupa.pyx":1073 * def as_itemgetter(obj): * cdef _PyProtocolWrapper wrap = _PyProtocolWrapper.__new__(_PyProtocolWrapper) * wrap._obj = obj # <<<<<<<<<<<<<< * wrap._type_flags = OBJ_AS_INDEX * return wrap */ __Pyx_INCREF(__pyx_v_obj); __Pyx_GIVEREF(__pyx_v_obj); __Pyx_GOTREF(__pyx_v_wrap->_obj); __Pyx_DECREF(__pyx_v_wrap->_obj); __pyx_v_wrap->_obj = __pyx_v_obj; /* "lupa/_lupa.pyx":1074 * cdef _PyProtocolWrapper wrap = _PyProtocolWrapper.__new__(_PyProtocolWrapper) * wrap._obj = obj * wrap._type_flags = OBJ_AS_INDEX # <<<<<<<<<<<<<< * return wrap * */ __pyx_v_wrap->_type_flags = __pyx_e_4lupa_5_lupa_OBJ_AS_INDEX; /* "lupa/_lupa.pyx":1075 * wrap._obj = obj * wrap._type_flags = OBJ_AS_INDEX * return wrap # <<<<<<<<<<<<<< * * cdef object py_from_lua(LuaRuntime runtime, lua_State *L, int n): */ __Pyx_XDECREF(__pyx_r); __Pyx_INCREF(((PyObject *)__pyx_v_wrap)); __pyx_r = ((PyObject *)__pyx_v_wrap); goto __pyx_L0; /* "lupa/_lupa.pyx":1071 * return wrap * * def as_itemgetter(obj): # <<<<<<<<<<<<<< * cdef _PyProtocolWrapper wrap = _PyProtocolWrapper.__new__(_PyProtocolWrapper) * wrap._obj = obj */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_AddTraceback("lupa._lupa.as_itemgetter", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XDECREF((PyObject *)__pyx_v_wrap); __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "lupa/_lupa.pyx":1077 * return wrap * * cdef object py_from_lua(LuaRuntime runtime, lua_State *L, int n): # <<<<<<<<<<<<<< * """ * Convert a Lua object to a Python object by either mapping, wrapping */ static PyObject *__pyx_f_4lupa_5_lupa_py_from_lua(struct __pyx_obj_4lupa_5_lupa_LuaRuntime *__pyx_v_runtime, lua_State *__pyx_v_L, int __pyx_v_n) { size_t __pyx_v_size; char const *__pyx_v_s; lua_Number __pyx_v_number; struct __pyx_t_4lupa_5_lupa_py_object *__pyx_v_py_obj; int __pyx_v_lua_type; PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations int __pyx_t_1; PyObject *__pyx_t_2 = NULL; int __pyx_t_3; char const *__pyx_t_4; __Pyx_RefNannySetupContext("py_from_lua", 0); /* "lupa/_lupa.pyx":1082 * or unwrapping it. * """ * cdef size_t size = 0 # <<<<<<<<<<<<<< * cdef const char *s * cdef lua.lua_Number number */ __pyx_v_size = 0; /* "lupa/_lupa.pyx":1086 * cdef lua.lua_Number number * cdef py_object* py_obj * cdef int lua_type = lua.lua_type(L, n) # <<<<<<<<<<<<<< * * if lua_type == lua.LUA_TNIL: */ __pyx_v_lua_type = lua_type(__pyx_v_L, __pyx_v_n); /* "lupa/_lupa.pyx":1088 * cdef int lua_type = lua.lua_type(L, n) * * if lua_type == lua.LUA_TNIL: # <<<<<<<<<<<<<< * return None * elif lua_type == lua.LUA_TNUMBER: */ switch (__pyx_v_lua_type) { case LUA_TNIL: /* "lupa/_lupa.pyx":1089 * * 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; /* "lupa/_lupa.pyx":1088 * cdef int lua_type = lua.lua_type(L, n) * * if lua_type == lua.LUA_TNIL: # <<<<<<<<<<<<<< * return None * elif lua_type == lua.LUA_TNUMBER: */ break; /* "lupa/_lupa.pyx":1090 * if lua_type == lua.LUA_TNIL: * return None * elif lua_type == lua.LUA_TNUMBER: # <<<<<<<<<<<<<< * number = lua.lua_tonumber(L, n) * if number != number: */ case LUA_TNUMBER: /* "lupa/_lupa.pyx":1091 * return None * elif lua_type == lua.LUA_TNUMBER: * number = lua.lua_tonumber(L, n) # <<<<<<<<<<<<<< * if number != number: * return number */ __pyx_v_number = lua_tonumber(__pyx_v_L, __pyx_v_n); /* "lupa/_lupa.pyx":1092 * elif lua_type == lua.LUA_TNUMBER: * number = lua.lua_tonumber(L, n) * if number != number: # <<<<<<<<<<<<<< * return number * else: */ __pyx_t_1 = ((__pyx_v_number != ((long)__pyx_v_number)) != 0); if (__pyx_t_1) { /* "lupa/_lupa.pyx":1093 * number = lua.lua_tonumber(L, n) * if number != number: * return number # <<<<<<<<<<<<<< * else: * return number */ __Pyx_XDECREF(__pyx_r); __pyx_t_2 = PyFloat_FromDouble(((double)__pyx_v_number)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1093, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_r = __pyx_t_2; __pyx_t_2 = 0; goto __pyx_L0; /* "lupa/_lupa.pyx":1092 * elif lua_type == lua.LUA_TNUMBER: * number = lua.lua_tonumber(L, n) * if number != number: # <<<<<<<<<<<<<< * return number * else: */ } /* "lupa/_lupa.pyx":1095 * return number * else: * return number # <<<<<<<<<<<<<< * elif lua_type == lua.LUA_TSTRING: * s = lua.lua_tolstring(L, n, &size) */ /*else*/ { __Pyx_XDECREF(__pyx_r); __pyx_t_2 = __Pyx_PyInt_From_long(((long)__pyx_v_number)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1095, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_r = __pyx_t_2; __pyx_t_2 = 0; goto __pyx_L0; } /* "lupa/_lupa.pyx":1090 * if lua_type == lua.LUA_TNIL: * return None * elif lua_type == lua.LUA_TNUMBER: # <<<<<<<<<<<<<< * number = lua.lua_tonumber(L, n) * if number != number: */ break; /* "lupa/_lupa.pyx":1096 * else: * return number * elif lua_type == lua.LUA_TSTRING: # <<<<<<<<<<<<<< * s = lua.lua_tolstring(L, n, &size) * if runtime._encoding is not None: */ case LUA_TSTRING: /* "lupa/_lupa.pyx":1097 * return number * elif lua_type == lua.LUA_TSTRING: * s = lua.lua_tolstring(L, n, &size) # <<<<<<<<<<<<<< * if runtime._encoding is not None: * return s[:size].decode(runtime._encoding) */ __pyx_v_s = lua_tolstring(__pyx_v_L, __pyx_v_n, (&__pyx_v_size)); /* "lupa/_lupa.pyx":1098 * elif lua_type == lua.LUA_TSTRING: * s = lua.lua_tolstring(L, n, &size) * if runtime._encoding is not None: # <<<<<<<<<<<<<< * return s[:size].decode(runtime._encoding) * else: */ __pyx_t_1 = (__pyx_v_runtime->_encoding != ((PyObject*)Py_None)); __pyx_t_3 = (__pyx_t_1 != 0); if (__pyx_t_3) { /* "lupa/_lupa.pyx":1099 * s = lua.lua_tolstring(L, n, &size) * if runtime._encoding is not None: * return s[:size].decode(runtime._encoding) # <<<<<<<<<<<<<< * else: * return s[:size] */ __Pyx_XDECREF(__pyx_r); if (unlikely(__pyx_v_runtime->_encoding == Py_None)) { PyErr_SetString(PyExc_TypeError, "expected bytes, NoneType found"); __PYX_ERR(0, 1099, __pyx_L1_error) } __pyx_t_4 = __Pyx_PyBytes_AsString(__pyx_v_runtime->_encoding); if (unlikely((!__pyx_t_4) && PyErr_Occurred())) __PYX_ERR(0, 1099, __pyx_L1_error) __pyx_t_2 = __Pyx_decode_c_string(__pyx_v_s, 0, __pyx_v_size, __pyx_t_4, NULL, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1099, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_r = __pyx_t_2; __pyx_t_2 = 0; goto __pyx_L0; /* "lupa/_lupa.pyx":1098 * elif lua_type == lua.LUA_TSTRING: * s = lua.lua_tolstring(L, n, &size) * if runtime._encoding is not None: # <<<<<<<<<<<<<< * return s[:size].decode(runtime._encoding) * else: */ } /* "lupa/_lupa.pyx":1101 * return s[:size].decode(runtime._encoding) * else: * return s[:size] # <<<<<<<<<<<<<< * elif lua_type == lua.LUA_TBOOLEAN: * return lua.lua_toboolean(L, n) */ /*else*/ { __Pyx_XDECREF(__pyx_r); __pyx_t_2 = __Pyx_PyBytes_FromStringAndSize(__pyx_v_s + 0, __pyx_v_size - 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1101, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_r = __pyx_t_2; __pyx_t_2 = 0; goto __pyx_L0; } /* "lupa/_lupa.pyx":1096 * else: * return number * elif lua_type == lua.LUA_TSTRING: # <<<<<<<<<<<<<< * s = lua.lua_tolstring(L, n, &size) * if runtime._encoding is not None: */ break; /* "lupa/_lupa.pyx":1102 * else: * return s[:size] * elif lua_type == lua.LUA_TBOOLEAN: # <<<<<<<<<<<<<< * return lua.lua_toboolean(L, n) * elif lua_type == lua.LUA_TUSERDATA: */ case LUA_TBOOLEAN: /* "lupa/_lupa.pyx":1103 * return s[:size] * elif lua_type == lua.LUA_TBOOLEAN: * return lua.lua_toboolean(L, n) # <<<<<<<<<<<<<< * elif lua_type == lua.LUA_TUSERDATA: * py_obj = unpack_userdata(L, n) */ __Pyx_XDECREF(__pyx_r); __pyx_t_2 = __Pyx_PyBool_FromLong(lua_toboolean(__pyx_v_L, __pyx_v_n)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1103, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_r = __pyx_t_2; __pyx_t_2 = 0; goto __pyx_L0; /* "lupa/_lupa.pyx":1102 * else: * return s[:size] * elif lua_type == lua.LUA_TBOOLEAN: # <<<<<<<<<<<<<< * return lua.lua_toboolean(L, n) * elif lua_type == lua.LUA_TUSERDATA: */ break; /* "lupa/_lupa.pyx":1104 * elif lua_type == lua.LUA_TBOOLEAN: * return lua.lua_toboolean(L, n) * elif lua_type == lua.LUA_TUSERDATA: # <<<<<<<<<<<<<< * py_obj = unpack_userdata(L, n) * if py_obj: */ case LUA_TUSERDATA: /* "lupa/_lupa.pyx":1105 * return lua.lua_toboolean(L, n) * elif lua_type == lua.LUA_TUSERDATA: * py_obj = unpack_userdata(L, n) # <<<<<<<<<<<<<< * if py_obj: * return py_obj.obj */ __pyx_v_py_obj = __pyx_f_4lupa_5_lupa_unpack_userdata(__pyx_v_L, __pyx_v_n); /* "lupa/_lupa.pyx":1106 * elif lua_type == lua.LUA_TUSERDATA: * py_obj = unpack_userdata(L, n) * if py_obj: # <<<<<<<<<<<<<< * return py_obj.obj * elif lua_type == lua.LUA_TTABLE: */ __pyx_t_3 = (__pyx_v_py_obj != 0); if (__pyx_t_3) { /* "lupa/_lupa.pyx":1107 * py_obj = unpack_userdata(L, n) * if py_obj: * return py_obj.obj # <<<<<<<<<<<<<< * elif lua_type == lua.LUA_TTABLE: * return new_lua_table(runtime, L, n) */ __Pyx_XDECREF(__pyx_r); __Pyx_INCREF(((PyObject *)__pyx_v_py_obj->obj)); __pyx_r = ((PyObject *)__pyx_v_py_obj->obj); goto __pyx_L0; /* "lupa/_lupa.pyx":1106 * elif lua_type == lua.LUA_TUSERDATA: * py_obj = unpack_userdata(L, n) * if py_obj: # <<<<<<<<<<<<<< * return py_obj.obj * elif lua_type == lua.LUA_TTABLE: */ } /* "lupa/_lupa.pyx":1104 * elif lua_type == lua.LUA_TBOOLEAN: * return lua.lua_toboolean(L, n) * elif lua_type == lua.LUA_TUSERDATA: # <<<<<<<<<<<<<< * py_obj = unpack_userdata(L, n) * if py_obj: */ break; /* "lupa/_lupa.pyx":1108 * if py_obj: * return py_obj.obj * elif lua_type == lua.LUA_TTABLE: # <<<<<<<<<<<<<< * return new_lua_table(runtime, L, n) * elif lua_type == lua.LUA_TTHREAD: */ case LUA_TTABLE: /* "lupa/_lupa.pyx":1109 * return py_obj.obj * elif lua_type == lua.LUA_TTABLE: * return new_lua_table(runtime, L, n) # <<<<<<<<<<<<<< * elif lua_type == lua.LUA_TTHREAD: * return new_lua_thread_or_function(runtime, L, n) */ __Pyx_XDECREF(__pyx_r); __pyx_t_2 = ((PyObject *)__pyx_f_4lupa_5_lupa_new_lua_table(__pyx_v_runtime, __pyx_v_L, __pyx_v_n)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1109, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_r = __pyx_t_2; __pyx_t_2 = 0; goto __pyx_L0; /* "lupa/_lupa.pyx":1108 * if py_obj: * return py_obj.obj * elif lua_type == lua.LUA_TTABLE: # <<<<<<<<<<<<<< * return new_lua_table(runtime, L, n) * elif lua_type == lua.LUA_TTHREAD: */ break; /* "lupa/_lupa.pyx":1110 * elif lua_type == lua.LUA_TTABLE: * return new_lua_table(runtime, L, n) * elif lua_type == lua.LUA_TTHREAD: # <<<<<<<<<<<<<< * return new_lua_thread_or_function(runtime, L, n) * elif lua_type == lua.LUA_TFUNCTION: */ case LUA_TTHREAD: /* "lupa/_lupa.pyx":1111 * return new_lua_table(runtime, L, n) * elif lua_type == lua.LUA_TTHREAD: * return new_lua_thread_or_function(runtime, L, n) # <<<<<<<<<<<<<< * elif lua_type == lua.LUA_TFUNCTION: * py_obj = unpack_wrapped_pyfunction(L, n) */ __Pyx_XDECREF(__pyx_r); __pyx_t_2 = ((PyObject *)__pyx_f_4lupa_5_lupa_new_lua_thread_or_function(__pyx_v_runtime, __pyx_v_L, __pyx_v_n)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1111, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_r = __pyx_t_2; __pyx_t_2 = 0; goto __pyx_L0; /* "lupa/_lupa.pyx":1110 * elif lua_type == lua.LUA_TTABLE: * return new_lua_table(runtime, L, n) * elif lua_type == lua.LUA_TTHREAD: # <<<<<<<<<<<<<< * return new_lua_thread_or_function(runtime, L, n) * elif lua_type == lua.LUA_TFUNCTION: */ break; /* "lupa/_lupa.pyx":1112 * elif lua_type == lua.LUA_TTHREAD: * return new_lua_thread_or_function(runtime, L, n) * elif lua_type == lua.LUA_TFUNCTION: # <<<<<<<<<<<<<< * py_obj = unpack_wrapped_pyfunction(L, n) * if py_obj: */ case LUA_TFUNCTION: /* "lupa/_lupa.pyx":1113 * 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 py_obj.obj */ __pyx_v_py_obj = __pyx_f_4lupa_5_lupa_unpack_wrapped_pyfunction(__pyx_v_L, __pyx_v_n); /* "lupa/_lupa.pyx":1114 * elif lua_type == lua.LUA_TFUNCTION: * py_obj = unpack_wrapped_pyfunction(L, n) * if py_obj: # <<<<<<<<<<<<<< * return py_obj.obj * return new_lua_function(runtime, L, n) */ __pyx_t_3 = (__pyx_v_py_obj != 0); if (__pyx_t_3) { /* "lupa/_lupa.pyx":1115 * py_obj = unpack_wrapped_pyfunction(L, n) * if py_obj: * return py_obj.obj # <<<<<<<<<<<<<< * return new_lua_function(runtime, L, n) * return new_lua_object(runtime, L, n) */ __Pyx_XDECREF(__pyx_r); __Pyx_INCREF(((PyObject *)__pyx_v_py_obj->obj)); __pyx_r = ((PyObject *)__pyx_v_py_obj->obj); goto __pyx_L0; /* "lupa/_lupa.pyx":1114 * elif lua_type == lua.LUA_TFUNCTION: * py_obj = unpack_wrapped_pyfunction(L, n) * if py_obj: # <<<<<<<<<<<<<< * return py_obj.obj * return new_lua_function(runtime, L, n) */ } /* "lupa/_lupa.pyx":1116 * if py_obj: * return py_obj.obj * return new_lua_function(runtime, L, n) # <<<<<<<<<<<<<< * return new_lua_object(runtime, L, n) * */ __Pyx_XDECREF(__pyx_r); __pyx_t_2 = ((PyObject *)__pyx_f_4lupa_5_lupa_new_lua_function(__pyx_v_runtime, __pyx_v_L, __pyx_v_n)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1116, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_r = __pyx_t_2; __pyx_t_2 = 0; goto __pyx_L0; /* "lupa/_lupa.pyx":1112 * elif lua_type == lua.LUA_TTHREAD: * return new_lua_thread_or_function(runtime, L, n) * elif lua_type == lua.LUA_TFUNCTION: # <<<<<<<<<<<<<< * py_obj = unpack_wrapped_pyfunction(L, n) * if py_obj: */ break; default: break; } /* "lupa/_lupa.pyx":1117 * return py_obj.obj * return new_lua_function(runtime, L, n) * return new_lua_object(runtime, L, n) # <<<<<<<<<<<<<< * * cdef py_object* unpack_userdata(lua_State *L, int n) nogil: */ __Pyx_XDECREF(__pyx_r); __pyx_t_2 = ((PyObject *)__pyx_f_4lupa_5_lupa_new_lua_object(__pyx_v_runtime, __pyx_v_L, __pyx_v_n)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1117, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_r = __pyx_t_2; __pyx_t_2 = 0; goto __pyx_L0; /* "lupa/_lupa.pyx":1077 * return wrap * * cdef object py_from_lua(LuaRuntime runtime, lua_State *L, int n): # <<<<<<<<<<<<<< * """ * Convert a Lua object to a Python object by either mapping, wrapping */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_2); __Pyx_AddTraceback("lupa._lupa.py_from_lua", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = 0; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "lupa/_lupa.pyx":1119 * return new_lua_object(runtime, L, n) * * cdef py_object* unpack_userdata(lua_State *L, int n) nogil: # <<<<<<<<<<<<<< * """ * Like luaL_checkudata(), unpacks a userdata object and validates that */ static struct __pyx_t_4lupa_5_lupa_py_object *__pyx_f_4lupa_5_lupa_unpack_userdata(lua_State *__pyx_v_L, int __pyx_v_n) { void *__pyx_v_p; struct __pyx_t_4lupa_5_lupa_py_object *__pyx_r; int __pyx_t_1; int __pyx_t_2; /* "lupa/_lupa.pyx":1124 * it's a wrapped Python object. Returns NULL on failure. * """ * p = lua.lua_touserdata(L, n) # <<<<<<<<<<<<<< * if p and lua.lua_getmetatable(L, n): * # found userdata with metatable - the one we expect? */ __pyx_v_p = lua_touserdata(__pyx_v_L, __pyx_v_n); /* "lupa/_lupa.pyx":1125 * """ * p = lua.lua_touserdata(L, n) * if p and lua.lua_getmetatable(L, n): # <<<<<<<<<<<<<< * # found userdata with metatable - the one we expect? * lua.luaL_getmetatable(L, POBJECT) */ __pyx_t_2 = (__pyx_v_p != 0); if (__pyx_t_2) { } else { __pyx_t_1 = __pyx_t_2; goto __pyx_L4_bool_binop_done; } __pyx_t_2 = (lua_getmetatable(__pyx_v_L, __pyx_v_n) != 0); __pyx_t_1 = __pyx_t_2; __pyx_L4_bool_binop_done:; if (__pyx_t_1) { /* "lupa/_lupa.pyx":1127 * if p and lua.lua_getmetatable(L, n): * # found userdata with metatable - the one we expect? * lua.luaL_getmetatable(L, POBJECT) # <<<<<<<<<<<<<< * if lua.lua_rawequal(L, -1, -2): * lua.lua_pop(L, 2) */ luaL_getmetatable(__pyx_v_L, ((char *)"POBJECT")); /* "lupa/_lupa.pyx":1128 * # found userdata with metatable - the one we expect? * lua.luaL_getmetatable(L, POBJECT) * if lua.lua_rawequal(L, -1, -2): # <<<<<<<<<<<<<< * lua.lua_pop(L, 2) * return p */ __pyx_t_1 = (lua_rawequal(__pyx_v_L, -1, -2) != 0); if (__pyx_t_1) { /* "lupa/_lupa.pyx":1129 * lua.luaL_getmetatable(L, POBJECT) * if lua.lua_rawequal(L, -1, -2): * lua.lua_pop(L, 2) # <<<<<<<<<<<<<< * return p * lua.lua_pop(L, 2) */ lua_pop(__pyx_v_L, 2); /* "lupa/_lupa.pyx":1130 * if lua.lua_rawequal(L, -1, -2): * lua.lua_pop(L, 2) * return p # <<<<<<<<<<<<<< * lua.lua_pop(L, 2) * return NULL */ __pyx_r = ((struct __pyx_t_4lupa_5_lupa_py_object *)__pyx_v_p); goto __pyx_L0; /* "lupa/_lupa.pyx":1128 * # found userdata with metatable - the one we expect? * lua.luaL_getmetatable(L, POBJECT) * if lua.lua_rawequal(L, -1, -2): # <<<<<<<<<<<<<< * lua.lua_pop(L, 2) * return p */ } /* "lupa/_lupa.pyx":1131 * lua.lua_pop(L, 2) * return p * lua.lua_pop(L, 2) # <<<<<<<<<<<<<< * return NULL * */ lua_pop(__pyx_v_L, 2); /* "lupa/_lupa.pyx":1125 * """ * p = lua.lua_touserdata(L, n) * if p and lua.lua_getmetatable(L, n): # <<<<<<<<<<<<<< * # found userdata with metatable - the one we expect? * lua.luaL_getmetatable(L, POBJECT) */ } /* "lupa/_lupa.pyx":1132 * return p * lua.lua_pop(L, 2) * return NULL # <<<<<<<<<<<<<< * * cdef int py_function_result_to_lua(LuaRuntime runtime, lua_State *L, object o) except -1: */ __pyx_r = NULL; goto __pyx_L0; /* "lupa/_lupa.pyx":1119 * return new_lua_object(runtime, L, n) * * cdef py_object* unpack_userdata(lua_State *L, int n) nogil: # <<<<<<<<<<<<<< * """ * Like luaL_checkudata(), unpacks a userdata object and validates that */ /* function exit code */ __pyx_L0:; return __pyx_r; } /* "lupa/_lupa.pyx":1134 * return NULL * * cdef int py_function_result_to_lua(LuaRuntime runtime, lua_State *L, object o) except -1: # <<<<<<<<<<<<<< * if runtime._unpack_returned_tuples and isinstance(o, tuple): * push_lua_arguments(runtime, L, o) */ static int __pyx_f_4lupa_5_lupa_py_function_result_to_lua(struct __pyx_obj_4lupa_5_lupa_LuaRuntime *__pyx_v_runtime, lua_State *__pyx_v_L, PyObject *__pyx_v_o) { int __pyx_r; __Pyx_RefNannyDeclarations int __pyx_t_1; int __pyx_t_2; int __pyx_t_3; int __pyx_t_4; Py_ssize_t __pyx_t_5; __Pyx_RefNannySetupContext("py_function_result_to_lua", 0); /* "lupa/_lupa.pyx":1135 * * cdef int py_function_result_to_lua(LuaRuntime runtime, lua_State *L, object o) except -1: * if runtime._unpack_returned_tuples and isinstance(o, tuple): # <<<<<<<<<<<<<< * push_lua_arguments(runtime, L, o) * return len(o) */ __pyx_t_2 = (__pyx_v_runtime->_unpack_returned_tuples != 0); if (__pyx_t_2) { } else { __pyx_t_1 = __pyx_t_2; goto __pyx_L4_bool_binop_done; } __pyx_t_2 = PyTuple_Check(__pyx_v_o); __pyx_t_3 = (__pyx_t_2 != 0); __pyx_t_1 = __pyx_t_3; __pyx_L4_bool_binop_done:; if (__pyx_t_1) { /* "lupa/_lupa.pyx":1136 * cdef int py_function_result_to_lua(LuaRuntime runtime, lua_State *L, object o) except -1: * if runtime._unpack_returned_tuples and isinstance(o, tuple): * push_lua_arguments(runtime, L, o) # <<<<<<<<<<<<<< * return len(o) * return py_to_lua(runtime, L, o) */ __pyx_t_4 = __pyx_f_4lupa_5_lupa_push_lua_arguments(__pyx_v_runtime, __pyx_v_L, ((PyObject*)__pyx_v_o), NULL); if (unlikely(__pyx_t_4 == ((int)-1))) __PYX_ERR(0, 1136, __pyx_L1_error) /* "lupa/_lupa.pyx":1137 * if runtime._unpack_returned_tuples and isinstance(o, tuple): * push_lua_arguments(runtime, L, o) * return len(o) # <<<<<<<<<<<<<< * return py_to_lua(runtime, L, o) * */ if (unlikely(__pyx_v_o == Py_None)) { PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()"); __PYX_ERR(0, 1137, __pyx_L1_error) } __pyx_t_5 = PyTuple_GET_SIZE(((PyObject*)__pyx_v_o)); if (unlikely(__pyx_t_5 == ((Py_ssize_t)-1))) __PYX_ERR(0, 1137, __pyx_L1_error) __pyx_r = __pyx_t_5; goto __pyx_L0; /* "lupa/_lupa.pyx":1135 * * cdef int py_function_result_to_lua(LuaRuntime runtime, lua_State *L, object o) except -1: * if runtime._unpack_returned_tuples and isinstance(o, tuple): # <<<<<<<<<<<<<< * push_lua_arguments(runtime, L, o) * return len(o) */ } /* "lupa/_lupa.pyx":1138 * push_lua_arguments(runtime, L, o) * return len(o) * return py_to_lua(runtime, L, o) # <<<<<<<<<<<<<< * * cdef int py_to_lua(LuaRuntime runtime, lua_State *L, object o, bint wrap_none=False) except -1: */ __pyx_t_4 = __pyx_f_4lupa_5_lupa_py_to_lua(__pyx_v_runtime, __pyx_v_L, __pyx_v_o, NULL); if (unlikely(__pyx_t_4 == ((int)-1))) __PYX_ERR(0, 1138, __pyx_L1_error) __pyx_r = __pyx_t_4; goto __pyx_L0; /* "lupa/_lupa.pyx":1134 * return NULL * * cdef int py_function_result_to_lua(LuaRuntime runtime, lua_State *L, object o) except -1: # <<<<<<<<<<<<<< * if runtime._unpack_returned_tuples and isinstance(o, tuple): * push_lua_arguments(runtime, L, o) */ /* function exit code */ __pyx_L1_error:; __Pyx_AddTraceback("lupa._lupa.py_function_result_to_lua", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = -1; __pyx_L0:; __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "lupa/_lupa.pyx":1140 * return py_to_lua(runtime, L, o) * * cdef int py_to_lua(LuaRuntime runtime, lua_State *L, object o, bint wrap_none=False) except -1: # <<<<<<<<<<<<<< * cdef int pushed_values_count = 0 * cdef int type_flags = 0 */ static int __pyx_f_4lupa_5_lupa_py_to_lua(struct __pyx_obj_4lupa_5_lupa_LuaRuntime *__pyx_v_runtime, lua_State *__pyx_v_L, PyObject *__pyx_v_o, struct __pyx_opt_args_4lupa_5_lupa_py_to_lua *__pyx_optional_args) { int __pyx_v_wrap_none = ((int)0); int __pyx_v_pushed_values_count; int __pyx_v_type_flags; int __pyx_r; __Pyx_RefNannyDeclarations int __pyx_t_1; int __pyx_t_2; int __pyx_t_3; double __pyx_t_4; long __pyx_t_5; char *__pyx_t_6; Py_ssize_t __pyx_t_7; int __pyx_t_8; PyObject *__pyx_t_9 = NULL; PyObject *__pyx_t_10 = NULL; __Pyx_RefNannySetupContext("py_to_lua", 0); if (__pyx_optional_args) { if (__pyx_optional_args->__pyx_n > 0) { __pyx_v_wrap_none = __pyx_optional_args->wrap_none; } } __Pyx_INCREF(__pyx_v_o); /* "lupa/_lupa.pyx":1141 * * cdef int py_to_lua(LuaRuntime runtime, lua_State *L, object o, bint wrap_none=False) except -1: * cdef int pushed_values_count = 0 # <<<<<<<<<<<<<< * cdef int type_flags = 0 * */ __pyx_v_pushed_values_count = 0; /* "lupa/_lupa.pyx":1142 * cdef int py_to_lua(LuaRuntime runtime, lua_State *L, object o, bint wrap_none=False) except -1: * cdef int pushed_values_count = 0 * cdef int type_flags = 0 # <<<<<<<<<<<<<< * * if o is None: */ __pyx_v_type_flags = 0; /* "lupa/_lupa.pyx":1144 * cdef int type_flags = 0 * * if o is None: # <<<<<<<<<<<<<< * if wrap_none: * lua.lua_pushlstring(L, "Py_None", 7) */ __pyx_t_1 = (__pyx_v_o == Py_None); __pyx_t_2 = (__pyx_t_1 != 0); if (__pyx_t_2) { /* "lupa/_lupa.pyx":1145 * * if o is None: * if wrap_none: # <<<<<<<<<<<<<< * lua.lua_pushlstring(L, "Py_None", 7) * lua.lua_rawget(L, lua.LUA_REGISTRYINDEX) */ __pyx_t_2 = (__pyx_v_wrap_none != 0); if (__pyx_t_2) { /* "lupa/_lupa.pyx":1146 * if o is None: * if wrap_none: * lua.lua_pushlstring(L, "Py_None", 7) # <<<<<<<<<<<<<< * lua.lua_rawget(L, lua.LUA_REGISTRYINDEX) * if lua.lua_isnil(L, -1): */ lua_pushlstring(__pyx_v_L, ((char *)"Py_None"), 7); /* "lupa/_lupa.pyx":1147 * if wrap_none: * lua.lua_pushlstring(L, "Py_None", 7) * lua.lua_rawget(L, lua.LUA_REGISTRYINDEX) # <<<<<<<<<<<<<< * if lua.lua_isnil(L, -1): * lua.lua_pop(L, 1) */ lua_rawget(__pyx_v_L, LUA_REGISTRYINDEX); /* "lupa/_lupa.pyx":1148 * lua.lua_pushlstring(L, "Py_None", 7) * lua.lua_rawget(L, lua.LUA_REGISTRYINDEX) * if lua.lua_isnil(L, -1): # <<<<<<<<<<<<<< * lua.lua_pop(L, 1) * return 0 */ __pyx_t_2 = (lua_isnil(__pyx_v_L, -1) != 0); if (__pyx_t_2) { /* "lupa/_lupa.pyx":1149 * lua.lua_rawget(L, lua.LUA_REGISTRYINDEX) * if lua.lua_isnil(L, -1): * lua.lua_pop(L, 1) # <<<<<<<<<<<<<< * return 0 * pushed_values_count = 1 */ lua_pop(__pyx_v_L, 1); /* "lupa/_lupa.pyx":1150 * if lua.lua_isnil(L, -1): * lua.lua_pop(L, 1) * return 0 # <<<<<<<<<<<<<< * pushed_values_count = 1 * else: */ __pyx_r = 0; goto __pyx_L0; /* "lupa/_lupa.pyx":1148 * lua.lua_pushlstring(L, "Py_None", 7) * lua.lua_rawget(L, lua.LUA_REGISTRYINDEX) * if lua.lua_isnil(L, -1): # <<<<<<<<<<<<<< * lua.lua_pop(L, 1) * return 0 */ } /* "lupa/_lupa.pyx":1151 * lua.lua_pop(L, 1) * return 0 * pushed_values_count = 1 # <<<<<<<<<<<<<< * else: * # Not really needed, but this way we may check for errors */ __pyx_v_pushed_values_count = 1; /* "lupa/_lupa.pyx":1145 * * if o is None: * if wrap_none: # <<<<<<<<<<<<<< * lua.lua_pushlstring(L, "Py_None", 7) * lua.lua_rawget(L, lua.LUA_REGISTRYINDEX) */ goto __pyx_L4; } /* "lupa/_lupa.pyx":1155 * # Not really needed, but this way we may check for errors * # with pushed_values_count == 0. * lua.lua_pushnil(L) # <<<<<<<<<<<<<< * pushed_values_count = 1 * elif o is True or o is False: */ /*else*/ { lua_pushnil(__pyx_v_L); /* "lupa/_lupa.pyx":1156 * # with pushed_values_count == 0. * lua.lua_pushnil(L) * pushed_values_count = 1 # <<<<<<<<<<<<<< * elif o is True or o is False: * lua.lua_pushboolean(L, o) */ __pyx_v_pushed_values_count = 1; } __pyx_L4:; /* "lupa/_lupa.pyx":1144 * cdef int type_flags = 0 * * if o is None: # <<<<<<<<<<<<<< * if wrap_none: * lua.lua_pushlstring(L, "Py_None", 7) */ goto __pyx_L3; } /* "lupa/_lupa.pyx":1157 * lua.lua_pushnil(L) * pushed_values_count = 1 * elif o is True or o is False: # <<<<<<<<<<<<<< * lua.lua_pushboolean(L, o) * pushed_values_count = 1 */ __pyx_t_1 = (__pyx_v_o == Py_True); __pyx_t_3 = (__pyx_t_1 != 0); if (!__pyx_t_3) { } else { __pyx_t_2 = __pyx_t_3; goto __pyx_L6_bool_binop_done; } __pyx_t_3 = (__pyx_v_o == Py_False); __pyx_t_1 = (__pyx_t_3 != 0); __pyx_t_2 = __pyx_t_1; __pyx_L6_bool_binop_done:; if (__pyx_t_2) { /* "lupa/_lupa.pyx":1158 * pushed_values_count = 1 * elif o is True or o is False: * lua.lua_pushboolean(L, o) # <<<<<<<<<<<<<< * pushed_values_count = 1 * elif type(o) is float: */ __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_v_o); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(0, 1158, __pyx_L1_error) lua_pushboolean(__pyx_v_L, __pyx_t_2); /* "lupa/_lupa.pyx":1159 * elif o is True or o is False: * lua.lua_pushboolean(L, o) * pushed_values_count = 1 # <<<<<<<<<<<<<< * elif type(o) is float: * lua.lua_pushnumber(L, cpython.float.PyFloat_AS_DOUBLE(o)) */ __pyx_v_pushed_values_count = 1; /* "lupa/_lupa.pyx":1157 * lua.lua_pushnil(L) * pushed_values_count = 1 * elif o is True or o is False: # <<<<<<<<<<<<<< * lua.lua_pushboolean(L, o) * pushed_values_count = 1 */ goto __pyx_L3; } /* "lupa/_lupa.pyx":1160 * lua.lua_pushboolean(L, o) * pushed_values_count = 1 * elif type(o) is float: # <<<<<<<<<<<<<< * lua.lua_pushnumber(L, cpython.float.PyFloat_AS_DOUBLE(o)) * pushed_values_count = 1 */ __pyx_t_2 = (((PyObject *)Py_TYPE(__pyx_v_o)) == ((PyObject *)(&PyFloat_Type))); __pyx_t_1 = (__pyx_t_2 != 0); if (__pyx_t_1) { /* "lupa/_lupa.pyx":1161 * pushed_values_count = 1 * elif type(o) is float: * lua.lua_pushnumber(L, cpython.float.PyFloat_AS_DOUBLE(o)) # <<<<<<<<<<<<<< * pushed_values_count = 1 * elif isinstance(o, long): */ lua_pushnumber(__pyx_v_L, ((lua_Number)PyFloat_AS_DOUBLE(__pyx_v_o))); /* "lupa/_lupa.pyx":1162 * elif type(o) is float: * lua.lua_pushnumber(L, cpython.float.PyFloat_AS_DOUBLE(o)) * pushed_values_count = 1 # <<<<<<<<<<<<<< * elif isinstance(o, long): * lua.lua_pushnumber(L, cpython.long.PyLong_AsDouble(o)) */ __pyx_v_pushed_values_count = 1; /* "lupa/_lupa.pyx":1160 * lua.lua_pushboolean(L, o) * pushed_values_count = 1 * elif type(o) is float: # <<<<<<<<<<<<<< * lua.lua_pushnumber(L, cpython.float.PyFloat_AS_DOUBLE(o)) * pushed_values_count = 1 */ goto __pyx_L3; } /* "lupa/_lupa.pyx":1163 * lua.lua_pushnumber(L, cpython.float.PyFloat_AS_DOUBLE(o)) * pushed_values_count = 1 * elif isinstance(o, long): # <<<<<<<<<<<<<< * lua.lua_pushnumber(L, cpython.long.PyLong_AsDouble(o)) * pushed_values_count = 1 */ __pyx_t_1 = PyLong_Check(__pyx_v_o); __pyx_t_2 = (__pyx_t_1 != 0); if (__pyx_t_2) { /* "lupa/_lupa.pyx":1164 * pushed_values_count = 1 * elif isinstance(o, long): * lua.lua_pushnumber(L, cpython.long.PyLong_AsDouble(o)) # <<<<<<<<<<<<<< * pushed_values_count = 1 * elif IS_PY2 and isinstance(o, int): */ __pyx_t_4 = PyLong_AsDouble(__pyx_v_o); if (unlikely(__pyx_t_4 == ((double)(-1.0)) && PyErr_Occurred())) __PYX_ERR(0, 1164, __pyx_L1_error) lua_pushnumber(__pyx_v_L, ((lua_Number)__pyx_t_4)); /* "lupa/_lupa.pyx":1165 * elif isinstance(o, long): * lua.lua_pushnumber(L, cpython.long.PyLong_AsDouble(o)) * pushed_values_count = 1 # <<<<<<<<<<<<<< * elif IS_PY2 and isinstance(o, int): * lua.lua_pushnumber(L, o) */ __pyx_v_pushed_values_count = 1; /* "lupa/_lupa.pyx":1163 * lua.lua_pushnumber(L, cpython.float.PyFloat_AS_DOUBLE(o)) * pushed_values_count = 1 * elif isinstance(o, long): # <<<<<<<<<<<<<< * lua.lua_pushnumber(L, cpython.long.PyLong_AsDouble(o)) * pushed_values_count = 1 */ goto __pyx_L3; } /* "lupa/_lupa.pyx":1166 * lua.lua_pushnumber(L, cpython.long.PyLong_AsDouble(o)) * pushed_values_count = 1 * elif IS_PY2 and isinstance(o, int): # <<<<<<<<<<<<<< * lua.lua_pushnumber(L, o) * pushed_values_count = 1 */ __pyx_t_1 = (__pyx_v_4lupa_5_lupa_IS_PY2 != 0); if (__pyx_t_1) { } else { __pyx_t_2 = __pyx_t_1; goto __pyx_L8_bool_binop_done; } __pyx_t_1 = PyInt_Check(__pyx_v_o); __pyx_t_3 = (__pyx_t_1 != 0); __pyx_t_2 = __pyx_t_3; __pyx_L8_bool_binop_done:; if (__pyx_t_2) { /* "lupa/_lupa.pyx":1167 * pushed_values_count = 1 * elif IS_PY2 and isinstance(o, int): * lua.lua_pushnumber(L, o) # <<<<<<<<<<<<<< * pushed_values_count = 1 * elif isinstance(o, bytes): */ __pyx_t_5 = __Pyx_PyInt_As_long(__pyx_v_o); if (unlikely((__pyx_t_5 == (long)-1) && PyErr_Occurred())) __PYX_ERR(0, 1167, __pyx_L1_error) lua_pushnumber(__pyx_v_L, ((lua_Number)((long)__pyx_t_5))); /* "lupa/_lupa.pyx":1168 * elif IS_PY2 and isinstance(o, int): * lua.lua_pushnumber(L, o) * pushed_values_count = 1 # <<<<<<<<<<<<<< * elif isinstance(o, bytes): * lua.lua_pushlstring(L, (o), len(o)) */ __pyx_v_pushed_values_count = 1; /* "lupa/_lupa.pyx":1166 * lua.lua_pushnumber(L, cpython.long.PyLong_AsDouble(o)) * pushed_values_count = 1 * elif IS_PY2 and isinstance(o, int): # <<<<<<<<<<<<<< * lua.lua_pushnumber(L, o) * pushed_values_count = 1 */ goto __pyx_L3; } /* "lupa/_lupa.pyx":1169 * lua.lua_pushnumber(L, o) * pushed_values_count = 1 * elif isinstance(o, bytes): # <<<<<<<<<<<<<< * lua.lua_pushlstring(L, (o), len(o)) * pushed_values_count = 1 */ __pyx_t_2 = PyBytes_Check(__pyx_v_o); __pyx_t_3 = (__pyx_t_2 != 0); if (__pyx_t_3) { /* "lupa/_lupa.pyx":1170 * pushed_values_count = 1 * elif isinstance(o, bytes): * lua.lua_pushlstring(L, (o), len(o)) # <<<<<<<<<<<<<< * pushed_values_count = 1 * elif isinstance(o, unicode) and runtime._encoding is not None: */ if (unlikely(__pyx_v_o == Py_None)) { PyErr_SetString(PyExc_TypeError, "expected bytes, NoneType found"); __PYX_ERR(0, 1170, __pyx_L1_error) } __pyx_t_6 = __Pyx_PyBytes_AsWritableString(__pyx_v_o); if (unlikely((!__pyx_t_6) && PyErr_Occurred())) __PYX_ERR(0, 1170, __pyx_L1_error) if (unlikely(__pyx_v_o == Py_None)) { PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()"); __PYX_ERR(0, 1170, __pyx_L1_error) } __pyx_t_7 = PyBytes_GET_SIZE(((PyObject*)__pyx_v_o)); if (unlikely(__pyx_t_7 == ((Py_ssize_t)-1))) __PYX_ERR(0, 1170, __pyx_L1_error) lua_pushlstring(__pyx_v_L, ((char *)__pyx_t_6), __pyx_t_7); /* "lupa/_lupa.pyx":1171 * elif isinstance(o, bytes): * lua.lua_pushlstring(L, (o), len(o)) * pushed_values_count = 1 # <<<<<<<<<<<<<< * elif isinstance(o, unicode) and runtime._encoding is not None: * pushed_values_count = push_encoded_unicode_string(runtime, L, o) */ __pyx_v_pushed_values_count = 1; /* "lupa/_lupa.pyx":1169 * lua.lua_pushnumber(L, o) * pushed_values_count = 1 * elif isinstance(o, bytes): # <<<<<<<<<<<<<< * lua.lua_pushlstring(L, (o), len(o)) * pushed_values_count = 1 */ goto __pyx_L3; } /* "lupa/_lupa.pyx":1172 * lua.lua_pushlstring(L, (o), len(o)) * pushed_values_count = 1 * elif isinstance(o, unicode) and runtime._encoding is not None: # <<<<<<<<<<<<<< * pushed_values_count = push_encoded_unicode_string(runtime, L, o) * elif isinstance(o, _LuaObject): */ __pyx_t_2 = PyUnicode_Check(__pyx_v_o); __pyx_t_1 = (__pyx_t_2 != 0); if (__pyx_t_1) { } else { __pyx_t_3 = __pyx_t_1; goto __pyx_L10_bool_binop_done; } __pyx_t_1 = (__pyx_v_runtime->_encoding != ((PyObject*)Py_None)); __pyx_t_2 = (__pyx_t_1 != 0); __pyx_t_3 = __pyx_t_2; __pyx_L10_bool_binop_done:; if (__pyx_t_3) { /* "lupa/_lupa.pyx":1173 * pushed_values_count = 1 * elif isinstance(o, unicode) and runtime._encoding is not None: * pushed_values_count = push_encoded_unicode_string(runtime, L, o) # <<<<<<<<<<<<<< * elif isinstance(o, _LuaObject): * if (<_LuaObject>o)._runtime is not runtime: */ __pyx_t_8 = __pyx_f_4lupa_5_lupa_push_encoded_unicode_string(__pyx_v_runtime, __pyx_v_L, ((PyObject*)__pyx_v_o)); if (unlikely(__pyx_t_8 == ((int)-1))) __PYX_ERR(0, 1173, __pyx_L1_error) __pyx_v_pushed_values_count = __pyx_t_8; /* "lupa/_lupa.pyx":1172 * lua.lua_pushlstring(L, (o), len(o)) * pushed_values_count = 1 * elif isinstance(o, unicode) and runtime._encoding is not None: # <<<<<<<<<<<<<< * pushed_values_count = push_encoded_unicode_string(runtime, L, o) * elif isinstance(o, _LuaObject): */ goto __pyx_L3; } /* "lupa/_lupa.pyx":1174 * elif isinstance(o, unicode) and runtime._encoding is not None: * pushed_values_count = push_encoded_unicode_string(runtime, L, o) * elif isinstance(o, _LuaObject): # <<<<<<<<<<<<<< * if (<_LuaObject>o)._runtime is not runtime: * raise LuaError("cannot mix objects from different Lua runtimes") */ __pyx_t_3 = __Pyx_TypeCheck(__pyx_v_o, __pyx_ptype_4lupa_5_lupa__LuaObject); __pyx_t_2 = (__pyx_t_3 != 0); if (__pyx_t_2) { /* "lupa/_lupa.pyx":1175 * pushed_values_count = push_encoded_unicode_string(runtime, L, o) * elif isinstance(o, _LuaObject): * if (<_LuaObject>o)._runtime is not runtime: # <<<<<<<<<<<<<< * raise LuaError("cannot mix objects from different Lua runtimes") * lua.lua_rawgeti(L, lua.LUA_REGISTRYINDEX, (<_LuaObject>o)._ref) */ __pyx_t_2 = (((struct __pyx_obj_4lupa_5_lupa__LuaObject *)__pyx_v_o)->_runtime != __pyx_v_runtime); __pyx_t_3 = (__pyx_t_2 != 0); if (__pyx_t_3) { /* "lupa/_lupa.pyx":1176 * elif isinstance(o, _LuaObject): * if (<_LuaObject>o)._runtime is not runtime: * raise LuaError("cannot mix objects from different Lua runtimes") # <<<<<<<<<<<<<< * lua.lua_rawgeti(L, lua.LUA_REGISTRYINDEX, (<_LuaObject>o)._ref) * pushed_values_count = 1 */ __pyx_t_9 = __Pyx_GetModuleGlobalName(__pyx_n_s_LuaError); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 1176, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); __pyx_t_10 = __Pyx_PyObject_Call(__pyx_t_9, __pyx_tuple__42, NULL); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 1176, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_10); __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; __Pyx_Raise(__pyx_t_10, 0, 0, 0); __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; __PYX_ERR(0, 1176, __pyx_L1_error) /* "lupa/_lupa.pyx":1175 * pushed_values_count = push_encoded_unicode_string(runtime, L, o) * elif isinstance(o, _LuaObject): * if (<_LuaObject>o)._runtime is not runtime: # <<<<<<<<<<<<<< * raise LuaError("cannot mix objects from different Lua runtimes") * lua.lua_rawgeti(L, lua.LUA_REGISTRYINDEX, (<_LuaObject>o)._ref) */ } /* "lupa/_lupa.pyx":1177 * if (<_LuaObject>o)._runtime is not runtime: * raise LuaError("cannot mix objects from different Lua runtimes") * lua.lua_rawgeti(L, lua.LUA_REGISTRYINDEX, (<_LuaObject>o)._ref) # <<<<<<<<<<<<<< * pushed_values_count = 1 * elif isinstance(o, float): */ lua_rawgeti(__pyx_v_L, LUA_REGISTRYINDEX, ((struct __pyx_obj_4lupa_5_lupa__LuaObject *)__pyx_v_o)->_ref); /* "lupa/_lupa.pyx":1178 * 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, o) */ __pyx_v_pushed_values_count = 1; /* "lupa/_lupa.pyx":1174 * elif isinstance(o, unicode) and runtime._encoding is not None: * pushed_values_count = push_encoded_unicode_string(runtime, L, o) * elif isinstance(o, _LuaObject): # <<<<<<<<<<<<<< * if (<_LuaObject>o)._runtime is not runtime: * raise LuaError("cannot mix objects from different Lua runtimes") */ goto __pyx_L3; } /* "lupa/_lupa.pyx":1179 * lua.lua_rawgeti(L, lua.LUA_REGISTRYINDEX, (<_LuaObject>o)._ref) * pushed_values_count = 1 * elif isinstance(o, float): # <<<<<<<<<<<<<< * lua.lua_pushnumber(L, o) * pushed_values_count = 1 */ __pyx_t_3 = PyFloat_Check(__pyx_v_o); __pyx_t_2 = (__pyx_t_3 != 0); if (__pyx_t_2) { /* "lupa/_lupa.pyx":1180 * pushed_values_count = 1 * elif isinstance(o, float): * lua.lua_pushnumber(L, o) # <<<<<<<<<<<<<< * pushed_values_count = 1 * else: */ __pyx_t_4 = __pyx_PyFloat_AsDouble(__pyx_v_o); if (unlikely((__pyx_t_4 == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 1180, __pyx_L1_error) lua_pushnumber(__pyx_v_L, ((lua_Number)((double)__pyx_t_4))); /* "lupa/_lupa.pyx":1181 * elif isinstance(o, float): * lua.lua_pushnumber(L, o) * pushed_values_count = 1 # <<<<<<<<<<<<<< * else: * if isinstance(o, _PyProtocolWrapper): */ __pyx_v_pushed_values_count = 1; /* "lupa/_lupa.pyx":1179 * lua.lua_rawgeti(L, lua.LUA_REGISTRYINDEX, (<_LuaObject>o)._ref) * pushed_values_count = 1 * elif isinstance(o, float): # <<<<<<<<<<<<<< * lua.lua_pushnumber(L, o) * pushed_values_count = 1 */ goto __pyx_L3; } /* "lupa/_lupa.pyx":1183 * pushed_values_count = 1 * else: * if isinstance(o, _PyProtocolWrapper): # <<<<<<<<<<<<<< * type_flags = (<_PyProtocolWrapper>o)._type_flags * o = (<_PyProtocolWrapper>o)._obj */ /*else*/ { __pyx_t_2 = __Pyx_TypeCheck(__pyx_v_o, __pyx_ptype_4lupa_5_lupa__PyProtocolWrapper); __pyx_t_3 = (__pyx_t_2 != 0); if (__pyx_t_3) { /* "lupa/_lupa.pyx":1184 * else: * if isinstance(o, _PyProtocolWrapper): * type_flags = (<_PyProtocolWrapper>o)._type_flags # <<<<<<<<<<<<<< * o = (<_PyProtocolWrapper>o)._obj * else: */ __pyx_t_8 = ((struct __pyx_obj_4lupa_5_lupa__PyProtocolWrapper *)__pyx_v_o)->_type_flags; __pyx_v_type_flags = __pyx_t_8; /* "lupa/_lupa.pyx":1185 * if isinstance(o, _PyProtocolWrapper): * type_flags = (<_PyProtocolWrapper>o)._type_flags * o = (<_PyProtocolWrapper>o)._obj # <<<<<<<<<<<<<< * else: * # prefer __getitem__ over __getattr__ by default */ __pyx_t_10 = ((struct __pyx_obj_4lupa_5_lupa__PyProtocolWrapper *)__pyx_v_o)->_obj; __Pyx_INCREF(__pyx_t_10); __Pyx_DECREF_SET(__pyx_v_o, __pyx_t_10); __pyx_t_10 = 0; /* "lupa/_lupa.pyx":1183 * pushed_values_count = 1 * else: * if isinstance(o, _PyProtocolWrapper): # <<<<<<<<<<<<<< * type_flags = (<_PyProtocolWrapper>o)._type_flags * o = (<_PyProtocolWrapper>o)._obj */ goto __pyx_L13; } /* "lupa/_lupa.pyx":1188 * else: * # prefer __getitem__ over __getattr__ by default * type_flags = OBJ_AS_INDEX if hasattr(o, '__getitem__') else 0 # <<<<<<<<<<<<<< * pushed_values_count = py_to_lua_custom(runtime, L, o, type_flags) * return pushed_values_count */ /*else*/ { __pyx_t_3 = __Pyx_HasAttr(__pyx_v_o, __pyx_n_s_getitem); if (unlikely(__pyx_t_3 == ((int)-1))) __PYX_ERR(0, 1188, __pyx_L1_error) if ((__pyx_t_3 != 0)) { __pyx_t_8 = __pyx_e_4lupa_5_lupa_OBJ_AS_INDEX; } else { __pyx_t_8 = 0; } __pyx_v_type_flags = __pyx_t_8; } __pyx_L13:; /* "lupa/_lupa.pyx":1189 * # prefer __getitem__ over __getattr__ by default * type_flags = OBJ_AS_INDEX if hasattr(o, '__getitem__') else 0 * pushed_values_count = py_to_lua_custom(runtime, L, o, type_flags) # <<<<<<<<<<<<<< * return pushed_values_count * */ __pyx_v_pushed_values_count = __pyx_f_4lupa_5_lupa_py_to_lua_custom(__pyx_v_runtime, __pyx_v_L, __pyx_v_o, __pyx_v_type_flags); } __pyx_L3:; /* "lupa/_lupa.pyx":1190 * type_flags = OBJ_AS_INDEX if hasattr(o, '__getitem__') else 0 * pushed_values_count = py_to_lua_custom(runtime, L, o, type_flags) * return pushed_values_count # <<<<<<<<<<<<<< * * cdef int push_encoded_unicode_string(LuaRuntime runtime, lua_State *L, unicode ustring) except -1: */ __pyx_r = __pyx_v_pushed_values_count; goto __pyx_L0; /* "lupa/_lupa.pyx":1140 * return py_to_lua(runtime, L, o) * * cdef int py_to_lua(LuaRuntime runtime, lua_State *L, object o, bint wrap_none=False) except -1: # <<<<<<<<<<<<<< * cdef int pushed_values_count = 0 * cdef int type_flags = 0 */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_9); __Pyx_XDECREF(__pyx_t_10); __Pyx_AddTraceback("lupa._lupa.py_to_lua", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = -1; __pyx_L0:; __Pyx_XDECREF(__pyx_v_o); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "lupa/_lupa.pyx":1192 * 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, bytes_string, len(bytes_string)) */ static int __pyx_f_4lupa_5_lupa_push_encoded_unicode_string(struct __pyx_obj_4lupa_5_lupa_LuaRuntime *__pyx_v_runtime, lua_State *__pyx_v_L, PyObject *__pyx_v_ustring) { PyObject *__pyx_v_bytes_string = 0; int __pyx_r; __Pyx_RefNannyDeclarations char const *__pyx_t_1; PyObject *__pyx_t_2 = NULL; char *__pyx_t_3; Py_ssize_t __pyx_t_4; __Pyx_RefNannySetupContext("push_encoded_unicode_string", 0); /* "lupa/_lupa.pyx":1193 * * 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, bytes_string, len(bytes_string)) * return 1 */ if (unlikely(__pyx_v_ustring == Py_None)) { PyErr_Format(PyExc_AttributeError, "'NoneType' object has no attribute '%.30s'", "encode"); __PYX_ERR(0, 1193, __pyx_L1_error) } if (unlikely(__pyx_v_runtime->_encoding == Py_None)) { PyErr_SetString(PyExc_TypeError, "expected bytes, NoneType found"); __PYX_ERR(0, 1193, __pyx_L1_error) } __pyx_t_1 = __Pyx_PyBytes_AsString(__pyx_v_runtime->_encoding); if (unlikely((!__pyx_t_1) && PyErr_Occurred())) __PYX_ERR(0, 1193, __pyx_L1_error) __pyx_t_2 = PyUnicode_AsEncodedString(__pyx_v_ustring, __pyx_t_1, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1193, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); if (!(likely(PyBytes_CheckExact(__pyx_t_2))||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "bytes", Py_TYPE(__pyx_t_2)->tp_name), 0))) __PYX_ERR(0, 1193, __pyx_L1_error) __pyx_v_bytes_string = ((PyObject*)__pyx_t_2); __pyx_t_2 = 0; /* "lupa/_lupa.pyx":1194 * 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, bytes_string, len(bytes_string)) # <<<<<<<<<<<<<< * return 1 * */ if (unlikely(__pyx_v_bytes_string == Py_None)) { PyErr_SetString(PyExc_TypeError, "expected bytes, NoneType found"); __PYX_ERR(0, 1194, __pyx_L1_error) } __pyx_t_3 = __Pyx_PyBytes_AsWritableString(__pyx_v_bytes_string); if (unlikely((!__pyx_t_3) && PyErr_Occurred())) __PYX_ERR(0, 1194, __pyx_L1_error) if (unlikely(__pyx_v_bytes_string == Py_None)) { PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()"); __PYX_ERR(0, 1194, __pyx_L1_error) } __pyx_t_4 = PyBytes_GET_SIZE(__pyx_v_bytes_string); if (unlikely(__pyx_t_4 == ((Py_ssize_t)-1))) __PYX_ERR(0, 1194, __pyx_L1_error) lua_pushlstring(__pyx_v_L, ((char *)__pyx_t_3), __pyx_t_4); /* "lupa/_lupa.pyx":1195 * cdef bytes bytes_string = ustring.encode(runtime._encoding) * lua.lua_pushlstring(L, bytes_string, len(bytes_string)) * return 1 # <<<<<<<<<<<<<< * * cdef bint py_to_lua_custom(LuaRuntime runtime, lua_State *L, object o, int type_flags): */ __pyx_r = 1; goto __pyx_L0; /* "lupa/_lupa.pyx":1192 * 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, bytes_string, len(bytes_string)) */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_2); __Pyx_AddTraceback("lupa._lupa.push_encoded_unicode_string", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = -1; __pyx_L0:; __Pyx_XDECREF(__pyx_v_bytes_string); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "lupa/_lupa.pyx":1197 * return 1 * * cdef bint py_to_lua_custom(LuaRuntime runtime, lua_State *L, object o, int type_flags): # <<<<<<<<<<<<<< * cdef py_object *py_obj = lua.lua_newuserdata(L, sizeof(py_object)) * if not py_obj: */ static int __pyx_f_4lupa_5_lupa_py_to_lua_custom(struct __pyx_obj_4lupa_5_lupa_LuaRuntime *__pyx_v_runtime, lua_State *__pyx_v_L, PyObject *__pyx_v_o, int __pyx_v_type_flags) { struct __pyx_t_4lupa_5_lupa_py_object *__pyx_v_py_obj; PyObject *__pyx_v_obj_id = NULL; int __pyx_r; __Pyx_RefNannyDeclarations int __pyx_t_1; PyObject *__pyx_t_2 = NULL; PyObject *__pyx_t_3 = NULL; int __pyx_t_4; int __pyx_t_5; __Pyx_RefNannySetupContext("py_to_lua_custom", 0); /* "lupa/_lupa.pyx":1198 * * cdef bint py_to_lua_custom(LuaRuntime runtime, lua_State *L, object o, int type_flags): * cdef py_object *py_obj = lua.lua_newuserdata(L, sizeof(py_object)) # <<<<<<<<<<<<<< * if not py_obj: * return 0 # values pushed */ __pyx_v_py_obj = ((struct __pyx_t_4lupa_5_lupa_py_object *)lua_newuserdata(__pyx_v_L, (sizeof(struct __pyx_t_4lupa_5_lupa_py_object)))); /* "lupa/_lupa.pyx":1199 * cdef bint py_to_lua_custom(LuaRuntime runtime, lua_State *L, object o, int type_flags): * cdef py_object *py_obj = lua.lua_newuserdata(L, sizeof(py_object)) * if not py_obj: # <<<<<<<<<<<<<< * return 0 # values pushed * */ __pyx_t_1 = ((!(__pyx_v_py_obj != 0)) != 0); if (__pyx_t_1) { /* "lupa/_lupa.pyx":1200 * cdef py_object *py_obj = lua.lua_newuserdata(L, sizeof(py_object)) * if not py_obj: * return 0 # values pushed # <<<<<<<<<<<<<< * * # originally, we just used: */ __pyx_r = 0; goto __pyx_L0; /* "lupa/_lupa.pyx":1199 * cdef bint py_to_lua_custom(LuaRuntime runtime, lua_State *L, object o, int type_flags): * cdef py_object *py_obj = lua.lua_newuserdata(L, sizeof(py_object)) * if not py_obj: # <<<<<<<<<<<<<< * return 0 # values pushed * */ } /* "lupa/_lupa.pyx":1206 * # now, we store an owned reference in "runtime._pyrefs_in_lua" to keep it visible to Python * # and a borrowed reference in "py_obj.obj" for access from Lua * obj_id = (o) # <<<<<<<<<<<<<< * if obj_id in runtime._pyrefs_in_lua: * runtime._pyrefs_in_lua[obj_id].append(o) */ __pyx_t_2 = __Pyx_PyInt_FromSize_t(((uintptr_t)((PyObject *)__pyx_v_o))); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1206, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_3 = __pyx_t_2; __Pyx_INCREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_v_obj_id = __pyx_t_3; __pyx_t_3 = 0; /* "lupa/_lupa.pyx":1207 * # and a borrowed reference in "py_obj.obj" for access from Lua * obj_id = (o) * if obj_id in runtime._pyrefs_in_lua: # <<<<<<<<<<<<<< * runtime._pyrefs_in_lua[obj_id].append(o) * else: */ if (unlikely(__pyx_v_runtime->_pyrefs_in_lua == Py_None)) { PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable"); __PYX_ERR(0, 1207, __pyx_L1_error) } __pyx_t_1 = (__Pyx_PyDict_ContainsTF(__pyx_v_obj_id, __pyx_v_runtime->_pyrefs_in_lua, Py_EQ)); if (unlikely(__pyx_t_1 < 0)) __PYX_ERR(0, 1207, __pyx_L1_error) __pyx_t_4 = (__pyx_t_1 != 0); if (__pyx_t_4) { /* "lupa/_lupa.pyx":1208 * obj_id = (o) * if obj_id in runtime._pyrefs_in_lua: * runtime._pyrefs_in_lua[obj_id].append(o) # <<<<<<<<<<<<<< * else: * runtime._pyrefs_in_lua[obj_id] = [o] */ if (unlikely(__pyx_v_runtime->_pyrefs_in_lua == Py_None)) { PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable"); __PYX_ERR(0, 1208, __pyx_L1_error) } __pyx_t_3 = __Pyx_PyDict_GetItem(__pyx_v_runtime->_pyrefs_in_lua, __pyx_v_obj_id); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1208, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_5 = __Pyx_PyObject_Append(__pyx_t_3, __pyx_v_o); if (unlikely(__pyx_t_5 == ((int)-1))) __PYX_ERR(0, 1208, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; /* "lupa/_lupa.pyx":1207 * # and a borrowed reference in "py_obj.obj" for access from Lua * obj_id = (o) * if obj_id in runtime._pyrefs_in_lua: # <<<<<<<<<<<<<< * runtime._pyrefs_in_lua[obj_id].append(o) * else: */ goto __pyx_L4; } /* "lupa/_lupa.pyx":1210 * runtime._pyrefs_in_lua[obj_id].append(o) * else: * runtime._pyrefs_in_lua[obj_id] = [o] # <<<<<<<<<<<<<< * * py_obj.obj = o */ /*else*/ { __pyx_t_3 = PyList_New(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1210, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_INCREF(__pyx_v_o); __Pyx_GIVEREF(__pyx_v_o); PyList_SET_ITEM(__pyx_t_3, 0, __pyx_v_o); if (unlikely(__pyx_v_runtime->_pyrefs_in_lua == Py_None)) { PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable"); __PYX_ERR(0, 1210, __pyx_L1_error) } if (unlikely(PyDict_SetItem(__pyx_v_runtime->_pyrefs_in_lua, __pyx_v_obj_id, __pyx_t_3) < 0)) __PYX_ERR(0, 1210, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; } __pyx_L4:; /* "lupa/_lupa.pyx":1212 * runtime._pyrefs_in_lua[obj_id] = [o] * * py_obj.obj = o # <<<<<<<<<<<<<< * py_obj.runtime = runtime * py_obj.type_flags = type_flags */ __pyx_v_py_obj->obj = ((PyObject *)__pyx_v_o); /* "lupa/_lupa.pyx":1213 * * py_obj.obj = o * py_obj.runtime = runtime # <<<<<<<<<<<<<< * py_obj.type_flags = type_flags * lua.luaL_getmetatable(L, POBJECT) */ __pyx_v_py_obj->runtime = ((PyObject *)__pyx_v_runtime); /* "lupa/_lupa.pyx":1214 * py_obj.obj = o * py_obj.runtime = runtime * py_obj.type_flags = type_flags # <<<<<<<<<<<<<< * lua.luaL_getmetatable(L, POBJECT) * lua.lua_setmetatable(L, -2) */ __pyx_v_py_obj->type_flags = __pyx_v_type_flags; /* "lupa/_lupa.pyx":1215 * py_obj.runtime = runtime * py_obj.type_flags = type_flags * lua.luaL_getmetatable(L, POBJECT) # <<<<<<<<<<<<<< * lua.lua_setmetatable(L, -2) * return 1 # values pushed */ luaL_getmetatable(__pyx_v_L, ((char *)"POBJECT")); /* "lupa/_lupa.pyx":1216 * py_obj.type_flags = type_flags * lua.luaL_getmetatable(L, POBJECT) * lua.lua_setmetatable(L, -2) # <<<<<<<<<<<<<< * return 1 # values pushed * */ lua_setmetatable(__pyx_v_L, -2); /* "lupa/_lupa.pyx":1217 * lua.luaL_getmetatable(L, POBJECT) * lua.lua_setmetatable(L, -2) * return 1 # values pushed # <<<<<<<<<<<<<< * * */ __pyx_r = 1; goto __pyx_L0; /* "lupa/_lupa.pyx":1197 * return 1 * * cdef bint py_to_lua_custom(LuaRuntime runtime, lua_State *L, object o, int type_flags): # <<<<<<<<<<<<<< * cdef py_object *py_obj = lua.lua_newuserdata(L, sizeof(py_object)) * if not py_obj: */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_2); __Pyx_XDECREF(__pyx_t_3); __Pyx_WriteUnraisable("lupa._lupa.py_to_lua_custom", __pyx_clineno, __pyx_lineno, __pyx_filename, 1, 0); __pyx_r = 0; __pyx_L0:; __Pyx_XDECREF(__pyx_v_obj_id); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "lupa/_lupa.pyx":1220 * * * cdef inline int _isascii(unsigned char* s): # <<<<<<<<<<<<<< * cdef unsigned char c = 0 * while s[0]: */ static CYTHON_INLINE int __pyx_f_4lupa_5_lupa__isascii(unsigned char *__pyx_v_s) { unsigned char __pyx_v_c; int __pyx_r; __Pyx_RefNannyDeclarations int __pyx_t_1; __Pyx_RefNannySetupContext("_isascii", 0); /* "lupa/_lupa.pyx":1221 * * cdef inline int _isascii(unsigned char* s): * cdef unsigned char c = 0 # <<<<<<<<<<<<<< * while s[0]: * c |= s[0] */ __pyx_v_c = 0; /* "lupa/_lupa.pyx":1222 * cdef inline int _isascii(unsigned char* s): * cdef unsigned char c = 0 * while s[0]: # <<<<<<<<<<<<<< * c |= s[0] * s += 1 */ while (1) { __pyx_t_1 = ((__pyx_v_s[0]) != 0); if (!__pyx_t_1) break; /* "lupa/_lupa.pyx":1223 * cdef unsigned char c = 0 * while s[0]: * c |= s[0] # <<<<<<<<<<<<<< * s += 1 * return c & 0x80 == 0 */ __pyx_v_c = (__pyx_v_c | (__pyx_v_s[0])); /* "lupa/_lupa.pyx":1224 * while s[0]: * c |= s[0] * s += 1 # <<<<<<<<<<<<<< * return c & 0x80 == 0 * */ __pyx_v_s = (__pyx_v_s + 1); } /* "lupa/_lupa.pyx":1225 * c |= s[0] * s += 1 * return c & 0x80 == 0 # <<<<<<<<<<<<<< * * */ __pyx_r = ((__pyx_v_c & 0x80) == 0); goto __pyx_L0; /* "lupa/_lupa.pyx":1220 * * * cdef inline int _isascii(unsigned char* s): # <<<<<<<<<<<<<< * cdef unsigned char c = 0 * while s[0]: */ /* function exit code */ __pyx_L0:; __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "lupa/_lupa.pyx":1228 * * * cdef bytes _asciiOrNone(s): # <<<<<<<<<<<<<< * if s is None: * return s */ static PyObject *__pyx_f_4lupa_5_lupa__asciiOrNone(PyObject *__pyx_v_s) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations int __pyx_t_1; int __pyx_t_2; PyObject *__pyx_t_3 = NULL; PyObject *__pyx_t_4 = NULL; unsigned char *__pyx_t_5; __Pyx_RefNannySetupContext("_asciiOrNone", 0); __Pyx_INCREF(__pyx_v_s); /* "lupa/_lupa.pyx":1229 * * cdef bytes _asciiOrNone(s): * if s is None: # <<<<<<<<<<<<<< * return s * elif isinstance(s, unicode): */ __pyx_t_1 = (__pyx_v_s == Py_None); __pyx_t_2 = (__pyx_t_1 != 0); if (__pyx_t_2) { /* "lupa/_lupa.pyx":1230 * cdef bytes _asciiOrNone(s): * if s is None: * return s # <<<<<<<<<<<<<< * elif isinstance(s, unicode): * return (s).encode('ascii') */ __Pyx_XDECREF(__pyx_r); if (!(likely(PyBytes_CheckExact(__pyx_v_s))||((__pyx_v_s) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "bytes", Py_TYPE(__pyx_v_s)->tp_name), 0))) __PYX_ERR(0, 1230, __pyx_L1_error) __Pyx_INCREF(__pyx_v_s); __pyx_r = ((PyObject*)__pyx_v_s); goto __pyx_L0; /* "lupa/_lupa.pyx":1229 * * cdef bytes _asciiOrNone(s): * if s is None: # <<<<<<<<<<<<<< * return s * elif isinstance(s, unicode): */ } /* "lupa/_lupa.pyx":1231 * if s is None: * return s * elif isinstance(s, unicode): # <<<<<<<<<<<<<< * return (s).encode('ascii') * elif isinstance(s, bytearray): */ __pyx_t_2 = PyUnicode_Check(__pyx_v_s); __pyx_t_1 = (__pyx_t_2 != 0); if (__pyx_t_1) { /* "lupa/_lupa.pyx":1232 * return s * elif isinstance(s, unicode): * return (s).encode('ascii') # <<<<<<<<<<<<<< * elif isinstance(s, bytearray): * s = bytes(s) */ __Pyx_XDECREF(__pyx_r); if (unlikely(__pyx_v_s == Py_None)) { PyErr_Format(PyExc_AttributeError, "'NoneType' object has no attribute '%.30s'", "encode"); __PYX_ERR(0, 1232, __pyx_L1_error) } __pyx_t_3 = PyUnicode_AsASCIIString(((PyObject*)__pyx_v_s)); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1232, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); if (!(likely(PyBytes_CheckExact(__pyx_t_3))||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "bytes", Py_TYPE(__pyx_t_3)->tp_name), 0))) __PYX_ERR(0, 1232, __pyx_L1_error) __pyx_r = ((PyObject*)__pyx_t_3); __pyx_t_3 = 0; goto __pyx_L0; /* "lupa/_lupa.pyx":1231 * if s is None: * return s * elif isinstance(s, unicode): # <<<<<<<<<<<<<< * return (s).encode('ascii') * elif isinstance(s, bytearray): */ } /* "lupa/_lupa.pyx":1233 * elif isinstance(s, unicode): * return (s).encode('ascii') * elif isinstance(s, bytearray): # <<<<<<<<<<<<<< * s = bytes(s) * elif not isinstance(s, bytes): */ __pyx_t_1 = PyByteArray_Check(__pyx_v_s); __pyx_t_2 = (__pyx_t_1 != 0); if (__pyx_t_2) { /* "lupa/_lupa.pyx":1234 * return (s).encode('ascii') * elif isinstance(s, bytearray): * s = bytes(s) # <<<<<<<<<<<<<< * elif not isinstance(s, bytes): * raise ValueError("expected string, got %s" % type(s)) */ __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1234, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_INCREF(__pyx_v_s); __Pyx_GIVEREF(__pyx_v_s); PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_v_s); __pyx_t_4 = __Pyx_PyObject_Call(((PyObject *)(&PyBytes_Type)), __pyx_t_3, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1234, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_DECREF_SET(__pyx_v_s, __pyx_t_4); __pyx_t_4 = 0; /* "lupa/_lupa.pyx":1233 * elif isinstance(s, unicode): * return (s).encode('ascii') * elif isinstance(s, bytearray): # <<<<<<<<<<<<<< * s = bytes(s) * elif not isinstance(s, bytes): */ goto __pyx_L3; } /* "lupa/_lupa.pyx":1235 * elif isinstance(s, bytearray): * s = bytes(s) * elif not isinstance(s, bytes): # <<<<<<<<<<<<<< * raise ValueError("expected string, got %s" % type(s)) * if not _isascii(s): */ __pyx_t_2 = PyBytes_Check(__pyx_v_s); __pyx_t_1 = ((!(__pyx_t_2 != 0)) != 0); if (__pyx_t_1) { /* "lupa/_lupa.pyx":1236 * s = bytes(s) * elif not isinstance(s, bytes): * raise ValueError("expected string, got %s" % type(s)) # <<<<<<<<<<<<<< * if not _isascii(s): * raise ValueError("byte string input has unknown encoding, only ASCII is allowed") */ __pyx_t_4 = __Pyx_PyString_Format(__pyx_kp_s_expected_string_got_s, ((PyObject *)Py_TYPE(__pyx_v_s))); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1236, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1236, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_4); __pyx_t_4 = 0; __pyx_t_4 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_t_3, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1236, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_Raise(__pyx_t_4, 0, 0, 0); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __PYX_ERR(0, 1236, __pyx_L1_error) /* "lupa/_lupa.pyx":1235 * elif isinstance(s, bytearray): * s = bytes(s) * elif not isinstance(s, bytes): # <<<<<<<<<<<<<< * raise ValueError("expected string, got %s" % type(s)) * if not _isascii(s): */ } __pyx_L3:; /* "lupa/_lupa.pyx":1237 * elif not isinstance(s, bytes): * raise ValueError("expected string, got %s" % type(s)) * if not _isascii(s): # <<<<<<<<<<<<<< * raise ValueError("byte string input has unknown encoding, only ASCII is allowed") * return s */ if (unlikely(__pyx_v_s == Py_None)) { PyErr_SetString(PyExc_TypeError, "expected bytes, NoneType found"); __PYX_ERR(0, 1237, __pyx_L1_error) } __pyx_t_5 = __Pyx_PyBytes_AsWritableUString(__pyx_v_s); if (unlikely((!__pyx_t_5) && PyErr_Occurred())) __PYX_ERR(0, 1237, __pyx_L1_error) __pyx_t_1 = ((!(__pyx_f_4lupa_5_lupa__isascii(__pyx_t_5) != 0)) != 0); if (__pyx_t_1) { /* "lupa/_lupa.pyx":1238 * raise ValueError("expected string, got %s" % type(s)) * if not _isascii(s): * raise ValueError("byte string input has unknown encoding, only ASCII is allowed") # <<<<<<<<<<<<<< * return s * */ __pyx_t_4 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__43, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1238, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_Raise(__pyx_t_4, 0, 0, 0); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __PYX_ERR(0, 1238, __pyx_L1_error) /* "lupa/_lupa.pyx":1237 * elif not isinstance(s, bytes): * raise ValueError("expected string, got %s" % type(s)) * if not _isascii(s): # <<<<<<<<<<<<<< * raise ValueError("byte string input has unknown encoding, only ASCII is allowed") * return s */ } /* "lupa/_lupa.pyx":1239 * if not _isascii(s): * raise ValueError("byte string input has unknown encoding, only ASCII is allowed") * return s # <<<<<<<<<<<<<< * * */ __Pyx_XDECREF(__pyx_r); __Pyx_INCREF(((PyObject*)__pyx_v_s)); __pyx_r = ((PyObject*)__pyx_v_s); goto __pyx_L0; /* "lupa/_lupa.pyx":1228 * * * cdef bytes _asciiOrNone(s): # <<<<<<<<<<<<<< * if s is None: * return s */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_3); __Pyx_XDECREF(__pyx_t_4); __Pyx_AddTraceback("lupa._lupa._asciiOrNone", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = 0; __pyx_L0:; __Pyx_XDECREF(__pyx_v_s); __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "lupa/_lupa.pyx":1244 * # error handling * * cdef int raise_lua_error(LuaRuntime runtime, lua_State* L, int result) except -1: # <<<<<<<<<<<<<< * if result == 0: * return 0 */ static int __pyx_f_4lupa_5_lupa_raise_lua_error(struct __pyx_obj_4lupa_5_lupa_LuaRuntime *__pyx_v_runtime, lua_State *__pyx_v_L, int __pyx_v_result) { int __pyx_r; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; PyObject *__pyx_t_2 = NULL; PyObject *__pyx_t_3 = NULL; PyObject *__pyx_t_4 = NULL; PyObject *__pyx_t_5 = NULL; __Pyx_RefNannySetupContext("raise_lua_error", 0); /* "lupa/_lupa.pyx":1245 * * cdef int raise_lua_error(LuaRuntime runtime, lua_State* L, int result) except -1: * if result == 0: # <<<<<<<<<<<<<< * return 0 * elif result == lua.LUA_ERRMEM: */ switch (__pyx_v_result) { case 0: /* "lupa/_lupa.pyx":1246 * cdef int raise_lua_error(LuaRuntime runtime, lua_State* L, int result) except -1: * if result == 0: * return 0 # <<<<<<<<<<<<<< * elif result == lua.LUA_ERRMEM: * raise MemoryError() */ __pyx_r = 0; goto __pyx_L0; /* "lupa/_lupa.pyx":1245 * * cdef int raise_lua_error(LuaRuntime runtime, lua_State* L, int result) except -1: * if result == 0: # <<<<<<<<<<<<<< * return 0 * elif result == lua.LUA_ERRMEM: */ break; /* "lupa/_lupa.pyx":1247 * if result == 0: * return 0 * elif result == lua.LUA_ERRMEM: # <<<<<<<<<<<<<< * raise MemoryError() * else: */ case LUA_ERRMEM: /* "lupa/_lupa.pyx":1248 * return 0 * elif result == lua.LUA_ERRMEM: * raise MemoryError() # <<<<<<<<<<<<<< * else: * raise LuaError( build_lua_error_message(runtime, L, None, -1) ) */ PyErr_NoMemory(); __PYX_ERR(0, 1248, __pyx_L1_error) /* "lupa/_lupa.pyx":1247 * if result == 0: * return 0 * elif result == lua.LUA_ERRMEM: # <<<<<<<<<<<<<< * raise MemoryError() * else: */ break; default: /* "lupa/_lupa.pyx":1250 * raise MemoryError() * else: * raise LuaError( build_lua_error_message(runtime, L, None, -1) ) # <<<<<<<<<<<<<< * * cdef build_lua_error_message(LuaRuntime runtime, lua_State* L, unicode err_message, int n): */ __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_LuaError); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1250, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_3 = __pyx_f_4lupa_5_lupa_build_lua_error_message(__pyx_v_runtime, __pyx_v_L, ((PyObject*)Py_None), -1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1250, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_4 = NULL; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_2))) { __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_2); if (likely(__pyx_t_4)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2); __Pyx_INCREF(__pyx_t_4); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_2, function); } } if (!__pyx_t_4) { __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1250, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_GOTREF(__pyx_t_1); } else { #if CYTHON_FAST_PYCALL if (PyFunction_Check(__pyx_t_2)) { PyObject *__pyx_temp[2] = {__pyx_t_4, __pyx_t_3}; __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1250, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; } else #endif #if CYTHON_FAST_PYCCALL if (__Pyx_PyFastCFunction_Check(__pyx_t_2)) { PyObject *__pyx_temp[2] = {__pyx_t_4, __pyx_t_3}; __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1250, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; } else #endif { __pyx_t_5 = PyTuple_New(1+1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1250, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_4); __pyx_t_4 = NULL; __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_5, 0+1, __pyx_t_3); __pyx_t_3 = 0; __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_5, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1250, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; } } __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_Raise(__pyx_t_1, 0, 0, 0); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __PYX_ERR(0, 1250, __pyx_L1_error) break; } /* "lupa/_lupa.pyx":1244 * # error handling * * cdef int raise_lua_error(LuaRuntime runtime, lua_State* L, int result) except -1: # <<<<<<<<<<<<<< * if result == 0: * return 0 */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_2); __Pyx_XDECREF(__pyx_t_3); __Pyx_XDECREF(__pyx_t_4); __Pyx_XDECREF(__pyx_t_5); __Pyx_AddTraceback("lupa._lupa.raise_lua_error", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = -1; __pyx_L0:; __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "lupa/_lupa.pyx":1252 * raise LuaError( build_lua_error_message(runtime, L, None, -1) ) * * cdef build_lua_error_message(LuaRuntime runtime, lua_State* L, unicode err_message, int n): # <<<<<<<<<<<<<< * cdef size_t size = 0 * cdef const char *s = lua.lua_tolstring(L, n, &size) */ static PyObject *__pyx_f_4lupa_5_lupa_build_lua_error_message(struct __pyx_obj_4lupa_5_lupa_LuaRuntime *__pyx_v_runtime, lua_State *__pyx_v_L, PyObject *__pyx_v_err_message, int __pyx_v_n) { size_t __pyx_v_size; char const *__pyx_v_s; PyObject *__pyx_v_py_ustring = NULL; PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations int __pyx_t_1; int __pyx_t_2; PyObject *__pyx_t_3 = NULL; PyObject *__pyx_t_4 = NULL; PyObject *__pyx_t_5 = NULL; char const *__pyx_t_6; PyObject *__pyx_t_7 = NULL; int __pyx_t_8; PyObject *__pyx_t_9 = NULL; PyObject *__pyx_t_10 = NULL; PyObject *__pyx_t_11 = NULL; __Pyx_RefNannySetupContext("build_lua_error_message", 0); /* "lupa/_lupa.pyx":1253 * * cdef build_lua_error_message(LuaRuntime runtime, lua_State* L, unicode err_message, int n): * cdef size_t size = 0 # <<<<<<<<<<<<<< * cdef const char *s = lua.lua_tolstring(L, n, &size) * if runtime._encoding is not None: */ __pyx_v_size = 0; /* "lupa/_lupa.pyx":1254 * cdef build_lua_error_message(LuaRuntime runtime, lua_State* L, unicode err_message, int n): * cdef size_t size = 0 * cdef const char *s = lua.lua_tolstring(L, n, &size) # <<<<<<<<<<<<<< * if runtime._encoding is not None: * try: */ __pyx_v_s = lua_tolstring(__pyx_v_L, __pyx_v_n, (&__pyx_v_size)); /* "lupa/_lupa.pyx":1255 * cdef size_t size = 0 * cdef const char *s = lua.lua_tolstring(L, n, &size) * if runtime._encoding is not None: # <<<<<<<<<<<<<< * try: * py_ustring = s[:size].decode(runtime._encoding) */ __pyx_t_1 = (__pyx_v_runtime->_encoding != ((PyObject*)Py_None)); __pyx_t_2 = (__pyx_t_1 != 0); if (__pyx_t_2) { /* "lupa/_lupa.pyx":1256 * cdef const char *s = lua.lua_tolstring(L, n, &size) * if runtime._encoding is not None: * try: # <<<<<<<<<<<<<< * py_ustring = s[:size].decode(runtime._encoding) * except UnicodeDecodeError: */ { __Pyx_PyThreadState_declare __Pyx_PyThreadState_assign __Pyx_ExceptionSave(&__pyx_t_3, &__pyx_t_4, &__pyx_t_5); __Pyx_XGOTREF(__pyx_t_3); __Pyx_XGOTREF(__pyx_t_4); __Pyx_XGOTREF(__pyx_t_5); /*try:*/ { /* "lupa/_lupa.pyx":1257 * if runtime._encoding is not None: * try: * py_ustring = s[:size].decode(runtime._encoding) # <<<<<<<<<<<<<< * except UnicodeDecodeError: * py_ustring = s[:size].decode('ISO-8859-1') # safe 'fake' decoding */ if (unlikely(__pyx_v_runtime->_encoding == Py_None)) { PyErr_SetString(PyExc_TypeError, "expected bytes, NoneType found"); __PYX_ERR(0, 1257, __pyx_L4_error) } __pyx_t_6 = __Pyx_PyBytes_AsString(__pyx_v_runtime->_encoding); if (unlikely((!__pyx_t_6) && PyErr_Occurred())) __PYX_ERR(0, 1257, __pyx_L4_error) __pyx_t_7 = __Pyx_decode_c_string(__pyx_v_s, 0, __pyx_v_size, __pyx_t_6, NULL, NULL); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1257, __pyx_L4_error) __Pyx_GOTREF(__pyx_t_7); __pyx_v_py_ustring = __pyx_t_7; __pyx_t_7 = 0; /* "lupa/_lupa.pyx":1256 * cdef const char *s = lua.lua_tolstring(L, n, &size) * if runtime._encoding is not None: * try: # <<<<<<<<<<<<<< * py_ustring = s[:size].decode(runtime._encoding) * except UnicodeDecodeError: */ } __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; goto __pyx_L9_try_end; __pyx_L4_error:; __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0; /* "lupa/_lupa.pyx":1258 * try: * py_ustring = s[:size].decode(runtime._encoding) * except UnicodeDecodeError: # <<<<<<<<<<<<<< * py_ustring = s[:size].decode('ISO-8859-1') # safe 'fake' decoding * else: */ __pyx_t_8 = __Pyx_PyErr_ExceptionMatches(__pyx_builtin_UnicodeDecodeError); if (__pyx_t_8) { __Pyx_AddTraceback("lupa._lupa.build_lua_error_message", __pyx_clineno, __pyx_lineno, __pyx_filename); if (__Pyx_GetException(&__pyx_t_7, &__pyx_t_9, &__pyx_t_10) < 0) __PYX_ERR(0, 1258, __pyx_L6_except_error) __Pyx_GOTREF(__pyx_t_7); __Pyx_GOTREF(__pyx_t_9); __Pyx_GOTREF(__pyx_t_10); /* "lupa/_lupa.pyx":1259 * py_ustring = s[:size].decode(runtime._encoding) * except UnicodeDecodeError: * py_ustring = s[:size].decode('ISO-8859-1') # safe 'fake' decoding # <<<<<<<<<<<<<< * else: * py_ustring = s[:size].decode('ISO-8859-1') */ __pyx_t_11 = __Pyx_decode_c_string(__pyx_v_s, 0, __pyx_v_size, NULL, NULL, PyUnicode_DecodeLatin1); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 1259, __pyx_L6_except_error) __Pyx_GOTREF(__pyx_t_11); __Pyx_XDECREF_SET(__pyx_v_py_ustring, __pyx_t_11); __pyx_t_11 = 0; __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; goto __pyx_L5_exception_handled; } goto __pyx_L6_except_error; __pyx_L6_except_error:; /* "lupa/_lupa.pyx":1256 * cdef const char *s = lua.lua_tolstring(L, n, &size) * if runtime._encoding is not None: * try: # <<<<<<<<<<<<<< * py_ustring = s[:size].decode(runtime._encoding) * except UnicodeDecodeError: */ __Pyx_XGIVEREF(__pyx_t_3); __Pyx_XGIVEREF(__pyx_t_4); __Pyx_XGIVEREF(__pyx_t_5); __Pyx_ExceptionReset(__pyx_t_3, __pyx_t_4, __pyx_t_5); goto __pyx_L1_error; __pyx_L5_exception_handled:; __Pyx_XGIVEREF(__pyx_t_3); __Pyx_XGIVEREF(__pyx_t_4); __Pyx_XGIVEREF(__pyx_t_5); __Pyx_ExceptionReset(__pyx_t_3, __pyx_t_4, __pyx_t_5); __pyx_L9_try_end:; } /* "lupa/_lupa.pyx":1255 * cdef size_t size = 0 * cdef const char *s = lua.lua_tolstring(L, n, &size) * if runtime._encoding is not None: # <<<<<<<<<<<<<< * try: * py_ustring = s[:size].decode(runtime._encoding) */ goto __pyx_L3; } /* "lupa/_lupa.pyx":1261 * py_ustring = s[:size].decode('ISO-8859-1') # safe 'fake' decoding * else: * py_ustring = s[:size].decode('ISO-8859-1') # <<<<<<<<<<<<<< * if err_message is None: * return py_ustring */ /*else*/ { __pyx_t_10 = __Pyx_decode_c_string(__pyx_v_s, 0, __pyx_v_size, NULL, NULL, PyUnicode_DecodeLatin1); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 1261, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_10); __pyx_v_py_ustring = __pyx_t_10; __pyx_t_10 = 0; } __pyx_L3:; /* "lupa/_lupa.pyx":1262 * else: * py_ustring = s[:size].decode('ISO-8859-1') * if err_message is None: # <<<<<<<<<<<<<< * return py_ustring * else: */ __pyx_t_2 = (__pyx_v_err_message == ((PyObject*)Py_None)); __pyx_t_1 = (__pyx_t_2 != 0); if (__pyx_t_1) { /* "lupa/_lupa.pyx":1263 * py_ustring = s[:size].decode('ISO-8859-1') * if err_message is None: * return py_ustring # <<<<<<<<<<<<<< * else: * return err_message % py_ustring */ __Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_v_py_ustring); __pyx_r = __pyx_v_py_ustring; goto __pyx_L0; /* "lupa/_lupa.pyx":1262 * else: * py_ustring = s[:size].decode('ISO-8859-1') * if err_message is None: # <<<<<<<<<<<<<< * return py_ustring * else: */ } /* "lupa/_lupa.pyx":1265 * return py_ustring * else: * return err_message % py_ustring # <<<<<<<<<<<<<< * * # calling into Lua */ /*else*/ { __Pyx_XDECREF(__pyx_r); __pyx_t_10 = __Pyx_PyUnicode_FormatSafe(__pyx_v_err_message, __pyx_v_py_ustring); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 1265, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_10); __pyx_r = __pyx_t_10; __pyx_t_10 = 0; goto __pyx_L0; } /* "lupa/_lupa.pyx":1252 * raise LuaError( build_lua_error_message(runtime, L, None, -1) ) * * cdef build_lua_error_message(LuaRuntime runtime, lua_State* L, unicode err_message, int n): # <<<<<<<<<<<<<< * cdef size_t size = 0 * cdef const char *s = lua.lua_tolstring(L, n, &size) */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_7); __Pyx_XDECREF(__pyx_t_9); __Pyx_XDECREF(__pyx_t_10); __Pyx_XDECREF(__pyx_t_11); __Pyx_AddTraceback("lupa._lupa.build_lua_error_message", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = 0; __pyx_L0:; __Pyx_XDECREF(__pyx_v_py_ustring); __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "lupa/_lupa.pyx":1269 * # calling into Lua * * cdef run_lua(LuaRuntime runtime, bytes lua_code, tuple args): # <<<<<<<<<<<<<< * # locks the runtime * cdef lua_State* L = runtime._state */ static PyObject *__pyx_f_4lupa_5_lupa_run_lua(struct __pyx_obj_4lupa_5_lupa_LuaRuntime *__pyx_v_runtime, PyObject *__pyx_v_lua_code, PyObject *__pyx_v_args) { lua_State *__pyx_v_L; int __pyx_v_old_top; PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations lua_State *__pyx_t_1; int __pyx_t_2; char *__pyx_t_3; Py_ssize_t __pyx_t_4; int __pyx_t_5; PyObject *__pyx_t_6 = NULL; PyObject *__pyx_t_7 = NULL; PyObject *__pyx_t_8 = NULL; PyObject *__pyx_t_9 = NULL; PyObject *__pyx_t_10 = NULL; int __pyx_t_11; char const *__pyx_t_12; PyObject *__pyx_t_13 = NULL; PyObject *__pyx_t_14 = NULL; PyObject *__pyx_t_15 = NULL; PyObject *__pyx_t_16 = NULL; PyObject *__pyx_t_17 = NULL; PyObject *__pyx_t_18 = NULL; __Pyx_RefNannySetupContext("run_lua", 0); /* "lupa/_lupa.pyx":1271 * cdef run_lua(LuaRuntime runtime, bytes lua_code, tuple args): * # locks the runtime * cdef lua_State* L = runtime._state # <<<<<<<<<<<<<< * cdef bint result * lock_runtime(runtime) */ __pyx_t_1 = __pyx_v_runtime->_state; __pyx_v_L = __pyx_t_1; /* "lupa/_lupa.pyx":1273 * cdef lua_State* L = runtime._state * cdef bint result * lock_runtime(runtime) # <<<<<<<<<<<<<< * old_top = lua.lua_gettop(L) * try: */ __pyx_t_2 = __pyx_f_4lupa_5_lupa_lock_runtime(__pyx_v_runtime); if (unlikely(__pyx_t_2 == ((int)-1))) __PYX_ERR(0, 1273, __pyx_L1_error) /* "lupa/_lupa.pyx":1274 * cdef bint result * lock_runtime(runtime) * old_top = lua.lua_gettop(L) # <<<<<<<<<<<<<< * try: * if lua.luaL_loadbuffer(L, lua_code, len(lua_code), ''): */ __pyx_v_old_top = lua_gettop(__pyx_v_L); /* "lupa/_lupa.pyx":1275 * lock_runtime(runtime) * old_top = lua.lua_gettop(L) * try: # <<<<<<<<<<<<<< * if lua.luaL_loadbuffer(L, lua_code, len(lua_code), ''): * raise LuaSyntaxError(build_lua_error_message( */ /*try:*/ { /* "lupa/_lupa.pyx":1276 * old_top = lua.lua_gettop(L) * try: * if lua.luaL_loadbuffer(L, lua_code, len(lua_code), ''): # <<<<<<<<<<<<<< * raise LuaSyntaxError(build_lua_error_message( * runtime, L, u"error loading code: %s", -1)) */ if (unlikely(__pyx_v_lua_code == Py_None)) { PyErr_SetString(PyExc_TypeError, "expected bytes, NoneType found"); __PYX_ERR(0, 1276, __pyx_L4_error) } __pyx_t_3 = __Pyx_PyBytes_AsWritableString(__pyx_v_lua_code); if (unlikely((!__pyx_t_3) && PyErr_Occurred())) __PYX_ERR(0, 1276, __pyx_L4_error) if (unlikely(__pyx_v_lua_code == Py_None)) { PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()"); __PYX_ERR(0, 1276, __pyx_L4_error) } __pyx_t_4 = PyBytes_GET_SIZE(__pyx_v_lua_code); if (unlikely(__pyx_t_4 == ((Py_ssize_t)-1))) __PYX_ERR(0, 1276, __pyx_L4_error) __pyx_t_5 = (luaL_loadbuffer(__pyx_v_L, __pyx_t_3, __pyx_t_4, ((char *)"")) != 0); if (__pyx_t_5) { /* "lupa/_lupa.pyx":1277 * try: * if lua.luaL_loadbuffer(L, lua_code, len(lua_code), ''): * raise LuaSyntaxError(build_lua_error_message( # <<<<<<<<<<<<<< * runtime, L, u"error loading code: %s", -1)) * return call_lua(runtime, L, args) */ __pyx_t_7 = __Pyx_GetModuleGlobalName(__pyx_n_s_LuaSyntaxError); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1277, __pyx_L4_error) __Pyx_GOTREF(__pyx_t_7); /* "lupa/_lupa.pyx":1278 * if lua.luaL_loadbuffer(L, lua_code, len(lua_code), ''): * raise LuaSyntaxError(build_lua_error_message( * runtime, L, u"error loading code: %s", -1)) # <<<<<<<<<<<<<< * return call_lua(runtime, L, args) * finally: */ __pyx_t_8 = __pyx_f_4lupa_5_lupa_build_lua_error_message(__pyx_v_runtime, __pyx_v_L, __pyx_kp_u_error_loading_code_s, -1); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 1277, __pyx_L4_error) __Pyx_GOTREF(__pyx_t_8); __pyx_t_9 = NULL; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_7))) { __pyx_t_9 = PyMethod_GET_SELF(__pyx_t_7); if (likely(__pyx_t_9)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_7); __Pyx_INCREF(__pyx_t_9); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_7, function); } } if (!__pyx_t_9) { __pyx_t_6 = __Pyx_PyObject_CallOneArg(__pyx_t_7, __pyx_t_8); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1277, __pyx_L4_error) __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; __Pyx_GOTREF(__pyx_t_6); } else { #if CYTHON_FAST_PYCALL if (PyFunction_Check(__pyx_t_7)) { PyObject *__pyx_temp[2] = {__pyx_t_9, __pyx_t_8}; __pyx_t_6 = __Pyx_PyFunction_FastCall(__pyx_t_7, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1277, __pyx_L4_error) __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0; __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; } else #endif #if CYTHON_FAST_PYCCALL if (__Pyx_PyFastCFunction_Check(__pyx_t_7)) { PyObject *__pyx_temp[2] = {__pyx_t_9, __pyx_t_8}; __pyx_t_6 = __Pyx_PyCFunction_FastCall(__pyx_t_7, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1277, __pyx_L4_error) __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0; __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; } else #endif { __pyx_t_10 = PyTuple_New(1+1); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 1277, __pyx_L4_error) __Pyx_GOTREF(__pyx_t_10); __Pyx_GIVEREF(__pyx_t_9); PyTuple_SET_ITEM(__pyx_t_10, 0, __pyx_t_9); __pyx_t_9 = NULL; __Pyx_GIVEREF(__pyx_t_8); PyTuple_SET_ITEM(__pyx_t_10, 0+1, __pyx_t_8); __pyx_t_8 = 0; __pyx_t_6 = __Pyx_PyObject_Call(__pyx_t_7, __pyx_t_10, NULL); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1277, __pyx_L4_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; } } __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; __Pyx_Raise(__pyx_t_6, 0, 0, 0); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __PYX_ERR(0, 1277, __pyx_L4_error) /* "lupa/_lupa.pyx":1276 * old_top = lua.lua_gettop(L) * try: * if lua.luaL_loadbuffer(L, lua_code, len(lua_code), ''): # <<<<<<<<<<<<<< * raise LuaSyntaxError(build_lua_error_message( * runtime, L, u"error loading code: %s", -1)) */ } /* "lupa/_lupa.pyx":1279 * raise LuaSyntaxError(build_lua_error_message( * runtime, L, u"error loading code: %s", -1)) * return call_lua(runtime, L, args) # <<<<<<<<<<<<<< * finally: * lua.lua_settop(L, old_top) */ __Pyx_XDECREF(__pyx_r); __pyx_t_6 = __pyx_f_4lupa_5_lupa_call_lua(__pyx_v_runtime, __pyx_v_L, __pyx_v_args); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1279, __pyx_L4_error) __Pyx_GOTREF(__pyx_t_6); __pyx_r = __pyx_t_6; __pyx_t_6 = 0; goto __pyx_L3_return; } /* "lupa/_lupa.pyx":1281 * return call_lua(runtime, L, args) * finally: * lua.lua_settop(L, old_top) # <<<<<<<<<<<<<< * unlock_runtime(runtime) * */ /*finally:*/ { __pyx_L4_error:; /*exception exit:*/{ __Pyx_PyThreadState_declare __Pyx_PyThreadState_assign __pyx_t_13 = 0; __pyx_t_14 = 0; __pyx_t_15 = 0; __pyx_t_16 = 0; __pyx_t_17 = 0; __pyx_t_18 = 0; __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0; __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0; __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0; __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0; __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; if (PY_MAJOR_VERSION >= 3) __Pyx_ExceptionSwap(&__pyx_t_16, &__pyx_t_17, &__pyx_t_18); if ((PY_MAJOR_VERSION < 3) || unlikely(__Pyx_GetException(&__pyx_t_13, &__pyx_t_14, &__pyx_t_15) < 0)) __Pyx_ErrFetch(&__pyx_t_13, &__pyx_t_14, &__pyx_t_15); __Pyx_XGOTREF(__pyx_t_13); __Pyx_XGOTREF(__pyx_t_14); __Pyx_XGOTREF(__pyx_t_15); __Pyx_XGOTREF(__pyx_t_16); __Pyx_XGOTREF(__pyx_t_17); __Pyx_XGOTREF(__pyx_t_18); __pyx_t_2 = __pyx_lineno; __pyx_t_11 = __pyx_clineno; __pyx_t_12 = __pyx_filename; { lua_settop(__pyx_v_L, __pyx_v_old_top); /* "lupa/_lupa.pyx":1282 * finally: * lua.lua_settop(L, old_top) * unlock_runtime(runtime) # <<<<<<<<<<<<<< * * cdef call_lua(LuaRuntime runtime, lua_State *L, tuple args): */ __pyx_f_4lupa_5_lupa_unlock_runtime(__pyx_v_runtime); } if (PY_MAJOR_VERSION >= 3) { __Pyx_XGIVEREF(__pyx_t_16); __Pyx_XGIVEREF(__pyx_t_17); __Pyx_XGIVEREF(__pyx_t_18); __Pyx_ExceptionReset(__pyx_t_16, __pyx_t_17, __pyx_t_18); } __Pyx_XGIVEREF(__pyx_t_13); __Pyx_XGIVEREF(__pyx_t_14); __Pyx_XGIVEREF(__pyx_t_15); __Pyx_ErrRestore(__pyx_t_13, __pyx_t_14, __pyx_t_15); __pyx_t_13 = 0; __pyx_t_14 = 0; __pyx_t_15 = 0; __pyx_t_16 = 0; __pyx_t_17 = 0; __pyx_t_18 = 0; __pyx_lineno = __pyx_t_2; __pyx_clineno = __pyx_t_11; __pyx_filename = __pyx_t_12; goto __pyx_L1_error; } __pyx_L3_return: { __pyx_t_18 = __pyx_r; __pyx_r = 0; /* "lupa/_lupa.pyx":1281 * return call_lua(runtime, L, args) * finally: * lua.lua_settop(L, old_top) # <<<<<<<<<<<<<< * unlock_runtime(runtime) * */ lua_settop(__pyx_v_L, __pyx_v_old_top); /* "lupa/_lupa.pyx":1282 * finally: * lua.lua_settop(L, old_top) * unlock_runtime(runtime) # <<<<<<<<<<<<<< * * cdef call_lua(LuaRuntime runtime, lua_State *L, tuple args): */ __pyx_f_4lupa_5_lupa_unlock_runtime(__pyx_v_runtime); __pyx_r = __pyx_t_18; __pyx_t_18 = 0; goto __pyx_L0; } } /* "lupa/_lupa.pyx":1269 * # calling into Lua * * cdef run_lua(LuaRuntime runtime, bytes lua_code, tuple args): # <<<<<<<<<<<<<< * # locks the runtime * cdef lua_State* L = runtime._state */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_6); __Pyx_XDECREF(__pyx_t_7); __Pyx_XDECREF(__pyx_t_8); __Pyx_XDECREF(__pyx_t_9); __Pyx_XDECREF(__pyx_t_10); __Pyx_AddTraceback("lupa._lupa.run_lua", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = 0; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "lupa/_lupa.pyx":1284 * unlock_runtime(runtime) * * cdef call_lua(LuaRuntime runtime, lua_State *L, tuple args): # <<<<<<<<<<<<<< * # does not lock the runtime! * # does not clean up the stack! */ static PyObject *__pyx_f_4lupa_5_lupa_call_lua(struct __pyx_obj_4lupa_5_lupa_LuaRuntime *__pyx_v_runtime, lua_State *__pyx_v_L, PyObject *__pyx_v_args) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations int __pyx_t_1; Py_ssize_t __pyx_t_2; PyObject *__pyx_t_3 = NULL; __Pyx_RefNannySetupContext("call_lua", 0); /* "lupa/_lupa.pyx":1287 * # does not lock the runtime! * # does not clean up the stack! * push_lua_arguments(runtime, L, args) # <<<<<<<<<<<<<< * return execute_lua_call(runtime, L, len(args)) * */ __pyx_t_1 = __pyx_f_4lupa_5_lupa_push_lua_arguments(__pyx_v_runtime, __pyx_v_L, __pyx_v_args, NULL); if (unlikely(__pyx_t_1 == ((int)-1))) __PYX_ERR(0, 1287, __pyx_L1_error) /* "lupa/_lupa.pyx":1288 * # does not clean up the stack! * push_lua_arguments(runtime, L, args) * return execute_lua_call(runtime, L, len(args)) # <<<<<<<<<<<<<< * * cdef object execute_lua_call(LuaRuntime runtime, lua_State *L, Py_ssize_t nargs): */ __Pyx_XDECREF(__pyx_r); if (unlikely(__pyx_v_args == Py_None)) { PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()"); __PYX_ERR(0, 1288, __pyx_L1_error) } __pyx_t_2 = PyTuple_GET_SIZE(__pyx_v_args); if (unlikely(__pyx_t_2 == ((Py_ssize_t)-1))) __PYX_ERR(0, 1288, __pyx_L1_error) __pyx_t_3 = __pyx_f_4lupa_5_lupa_execute_lua_call(__pyx_v_runtime, __pyx_v_L, __pyx_t_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1288, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_r = __pyx_t_3; __pyx_t_3 = 0; goto __pyx_L0; /* "lupa/_lupa.pyx":1284 * unlock_runtime(runtime) * * cdef call_lua(LuaRuntime runtime, lua_State *L, tuple args): # <<<<<<<<<<<<<< * # does not lock the runtime! * # does not clean up the stack! */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_3); __Pyx_AddTraceback("lupa._lupa.call_lua", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = 0; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "lupa/_lupa.pyx":1290 * return execute_lua_call(runtime, L, len(args)) * * cdef object execute_lua_call(LuaRuntime runtime, lua_State *L, Py_ssize_t nargs): # <<<<<<<<<<<<<< * cdef int result_status * cdef object result */ static PyObject *__pyx_f_4lupa_5_lupa_execute_lua_call(struct __pyx_obj_4lupa_5_lupa_LuaRuntime *__pyx_v_runtime, lua_State *__pyx_v_L, Py_ssize_t __pyx_v_nargs) { int __pyx_v_result_status; int __pyx_v_errfunc; PyObject *__pyx_v_results = NULL; PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations int __pyx_t_1; PyObject *__pyx_t_2 = NULL; int __pyx_t_3; int __pyx_t_4; __Pyx_RefNannySetupContext("execute_lua_call", 0); /* "lupa/_lupa.pyx":1294 * cdef object result * # call into Lua * cdef int errfunc = 0 # <<<<<<<<<<<<<< * with nogil: * lua.lua_getglobal(L, "debug") */ __pyx_v_errfunc = 0; /* "lupa/_lupa.pyx":1295 * # call into Lua * cdef int errfunc = 0 * with nogil: # <<<<<<<<<<<<<< * lua.lua_getglobal(L, "debug") * if not lua.lua_istable(L, -1): */ { #ifdef WITH_THREAD PyThreadState *_save; Py_UNBLOCK_THREADS __Pyx_FastGIL_Remember(); #endif /*try:*/ { /* "lupa/_lupa.pyx":1296 * cdef int errfunc = 0 * with nogil: * lua.lua_getglobal(L, "debug") # <<<<<<<<<<<<<< * if not lua.lua_istable(L, -1): * lua.lua_pop(L, 1) */ lua_getglobal(__pyx_v_L, ((char *)"debug")); /* "lupa/_lupa.pyx":1297 * with nogil: * lua.lua_getglobal(L, "debug") * if not lua.lua_istable(L, -1): # <<<<<<<<<<<<<< * lua.lua_pop(L, 1) * else: */ __pyx_t_1 = ((!(lua_istable(__pyx_v_L, -1) != 0)) != 0); if (__pyx_t_1) { /* "lupa/_lupa.pyx":1298 * lua.lua_getglobal(L, "debug") * if not lua.lua_istable(L, -1): * lua.lua_pop(L, 1) # <<<<<<<<<<<<<< * else: * lua.lua_getfield(L, -1, "traceback") */ lua_pop(__pyx_v_L, 1); /* "lupa/_lupa.pyx":1297 * with nogil: * lua.lua_getglobal(L, "debug") * if not lua.lua_istable(L, -1): # <<<<<<<<<<<<<< * lua.lua_pop(L, 1) * else: */ goto __pyx_L6; } /* "lupa/_lupa.pyx":1300 * lua.lua_pop(L, 1) * else: * lua.lua_getfield(L, -1, "traceback") # <<<<<<<<<<<<<< * if not lua.lua_isfunction(L, -1): * lua.lua_pop(L, 2) */ /*else*/ { lua_getfield(__pyx_v_L, -1, ((char *)"traceback")); /* "lupa/_lupa.pyx":1301 * else: * lua.lua_getfield(L, -1, "traceback") * if not lua.lua_isfunction(L, -1): # <<<<<<<<<<<<<< * lua.lua_pop(L, 2) * else: */ __pyx_t_1 = ((!(lua_isfunction(__pyx_v_L, -1) != 0)) != 0); if (__pyx_t_1) { /* "lupa/_lupa.pyx":1302 * lua.lua_getfield(L, -1, "traceback") * if not lua.lua_isfunction(L, -1): * lua.lua_pop(L, 2) # <<<<<<<<<<<<<< * else: * lua.lua_replace(L, -2) */ lua_pop(__pyx_v_L, 2); /* "lupa/_lupa.pyx":1301 * else: * lua.lua_getfield(L, -1, "traceback") * if not lua.lua_isfunction(L, -1): # <<<<<<<<<<<<<< * lua.lua_pop(L, 2) * else: */ goto __pyx_L7; } /* "lupa/_lupa.pyx":1304 * lua.lua_pop(L, 2) * else: * lua.lua_replace(L, -2) # <<<<<<<<<<<<<< * lua.lua_insert(L, 1) * errfunc = 1 */ /*else*/ { lua_replace(__pyx_v_L, -2); /* "lupa/_lupa.pyx":1305 * else: * lua.lua_replace(L, -2) * lua.lua_insert(L, 1) # <<<<<<<<<<<<<< * errfunc = 1 * result_status = lua.lua_pcall(L, nargs, lua.LUA_MULTRET, errfunc) */ lua_insert(__pyx_v_L, 1); /* "lupa/_lupa.pyx":1306 * lua.lua_replace(L, -2) * lua.lua_insert(L, 1) * errfunc = 1 # <<<<<<<<<<<<<< * result_status = lua.lua_pcall(L, nargs, lua.LUA_MULTRET, errfunc) * if errfunc: */ __pyx_v_errfunc = 1; } __pyx_L7:; } __pyx_L6:; /* "lupa/_lupa.pyx":1307 * lua.lua_insert(L, 1) * errfunc = 1 * result_status = lua.lua_pcall(L, nargs, lua.LUA_MULTRET, errfunc) # <<<<<<<<<<<<<< * if errfunc: * lua.lua_remove(L, 1) */ __pyx_v_result_status = lua_pcall(__pyx_v_L, __pyx_v_nargs, LUA_MULTRET, __pyx_v_errfunc); /* "lupa/_lupa.pyx":1308 * errfunc = 1 * result_status = lua.lua_pcall(L, nargs, lua.LUA_MULTRET, errfunc) * if errfunc: # <<<<<<<<<<<<<< * lua.lua_remove(L, 1) * results = unpack_lua_results(runtime, L) */ __pyx_t_1 = (__pyx_v_errfunc != 0); if (__pyx_t_1) { /* "lupa/_lupa.pyx":1309 * result_status = lua.lua_pcall(L, nargs, lua.LUA_MULTRET, errfunc) * if errfunc: * lua.lua_remove(L, 1) # <<<<<<<<<<<<<< * results = unpack_lua_results(runtime, L) * if result_status: */ lua_remove(__pyx_v_L, 1); /* "lupa/_lupa.pyx":1308 * errfunc = 1 * result_status = lua.lua_pcall(L, nargs, lua.LUA_MULTRET, errfunc) * if errfunc: # <<<<<<<<<<<<<< * lua.lua_remove(L, 1) * results = unpack_lua_results(runtime, L) */ } } /* "lupa/_lupa.pyx":1295 * # call into Lua * cdef int errfunc = 0 * with nogil: # <<<<<<<<<<<<<< * lua.lua_getglobal(L, "debug") * if not lua.lua_istable(L, -1): */ /*finally:*/ { /*normal exit:*/{ #ifdef WITH_THREAD __Pyx_FastGIL_Forget(); Py_BLOCK_THREADS #endif goto __pyx_L5; } __pyx_L5:; } } /* "lupa/_lupa.pyx":1310 * if errfunc: * lua.lua_remove(L, 1) * results = unpack_lua_results(runtime, L) # <<<<<<<<<<<<<< * if result_status: * if isinstance(results, BaseException): */ __pyx_t_2 = __pyx_f_4lupa_5_lupa_unpack_lua_results(__pyx_v_runtime, __pyx_v_L); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1310, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_v_results = __pyx_t_2; __pyx_t_2 = 0; /* "lupa/_lupa.pyx":1311 * lua.lua_remove(L, 1) * results = unpack_lua_results(runtime, L) * if result_status: # <<<<<<<<<<<<<< * if isinstance(results, BaseException): * runtime.reraise_on_exception() */ __pyx_t_1 = (__pyx_v_result_status != 0); if (__pyx_t_1) { /* "lupa/_lupa.pyx":1312 * results = unpack_lua_results(runtime, L) * if result_status: * if isinstance(results, BaseException): # <<<<<<<<<<<<<< * runtime.reraise_on_exception() * raise_lua_error(runtime, L, result_status) */ __pyx_t_1 = PyObject_IsInstance(__pyx_v_results, __pyx_builtin_BaseException); if (unlikely(__pyx_t_1 == ((int)-1))) __PYX_ERR(0, 1312, __pyx_L1_error) __pyx_t_3 = (__pyx_t_1 != 0); if (__pyx_t_3) { /* "lupa/_lupa.pyx":1313 * if result_status: * if isinstance(results, BaseException): * runtime.reraise_on_exception() # <<<<<<<<<<<<<< * raise_lua_error(runtime, L, result_status) * return results */ __pyx_t_4 = __pyx_f_4lupa_5_lupa_10LuaRuntime_reraise_on_exception(__pyx_v_runtime); if (unlikely(__pyx_t_4 == ((int)-1))) __PYX_ERR(0, 1313, __pyx_L1_error) /* "lupa/_lupa.pyx":1312 * results = unpack_lua_results(runtime, L) * if result_status: * if isinstance(results, BaseException): # <<<<<<<<<<<<<< * runtime.reraise_on_exception() * raise_lua_error(runtime, L, result_status) */ } /* "lupa/_lupa.pyx":1314 * if isinstance(results, BaseException): * runtime.reraise_on_exception() * raise_lua_error(runtime, L, result_status) # <<<<<<<<<<<<<< * return results * */ __pyx_t_4 = __pyx_f_4lupa_5_lupa_raise_lua_error(__pyx_v_runtime, __pyx_v_L, __pyx_v_result_status); if (unlikely(__pyx_t_4 == ((int)-1))) __PYX_ERR(0, 1314, __pyx_L1_error) /* "lupa/_lupa.pyx":1311 * lua.lua_remove(L, 1) * results = unpack_lua_results(runtime, L) * if result_status: # <<<<<<<<<<<<<< * if isinstance(results, BaseException): * runtime.reraise_on_exception() */ } /* "lupa/_lupa.pyx":1315 * runtime.reraise_on_exception() * raise_lua_error(runtime, L, result_status) * return results # <<<<<<<<<<<<<< * * cdef int push_lua_arguments(LuaRuntime runtime, lua_State *L, */ __Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_v_results); __pyx_r = __pyx_v_results; goto __pyx_L0; /* "lupa/_lupa.pyx":1290 * return execute_lua_call(runtime, L, len(args)) * * cdef object execute_lua_call(LuaRuntime runtime, lua_State *L, Py_ssize_t nargs): # <<<<<<<<<<<<<< * cdef int result_status * cdef object result */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_2); __Pyx_AddTraceback("lupa._lupa.execute_lua_call", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = 0; __pyx_L0:; __Pyx_XDECREF(__pyx_v_results); __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "lupa/_lupa.pyx":1317 * return results * * cdef int push_lua_arguments(LuaRuntime runtime, lua_State *L, # <<<<<<<<<<<<<< * tuple args, bint first_may_be_nil=True) except -1: * cdef int i */ static int __pyx_f_4lupa_5_lupa_push_lua_arguments(struct __pyx_obj_4lupa_5_lupa_LuaRuntime *__pyx_v_runtime, lua_State *__pyx_v_L, PyObject *__pyx_v_args, struct __pyx_opt_args_4lupa_5_lupa_push_lua_arguments *__pyx_optional_args) { /* "lupa/_lupa.pyx":1318 * * cdef int push_lua_arguments(LuaRuntime runtime, lua_State *L, * tuple args, bint first_may_be_nil=True) except -1: # <<<<<<<<<<<<<< * cdef int i * if args: */ int __pyx_v_first_may_be_nil = ((int)1); int __pyx_v_i; int __pyx_v_old_top; PyObject *__pyx_v_arg = NULL; int __pyx_r; __Pyx_RefNannyDeclarations int __pyx_t_1; int __pyx_t_2; PyObject *__pyx_t_3 = NULL; Py_ssize_t __pyx_t_4; PyObject *__pyx_t_5 = NULL; int __pyx_t_6; struct __pyx_opt_args_4lupa_5_lupa_py_to_lua __pyx_t_7; PyObject *__pyx_t_8 = NULL; __Pyx_RefNannySetupContext("push_lua_arguments", 0); if (__pyx_optional_args) { if (__pyx_optional_args->__pyx_n > 0) { __pyx_v_first_may_be_nil = __pyx_optional_args->first_may_be_nil; } } /* "lupa/_lupa.pyx":1320 * tuple args, bint first_may_be_nil=True) except -1: * cdef int i * if args: # <<<<<<<<<<<<<< * old_top = lua.lua_gettop(L) * for i, arg in enumerate(args): */ __pyx_t_1 = (__pyx_v_args != Py_None) && (PyTuple_GET_SIZE(__pyx_v_args) != 0); if (__pyx_t_1) { /* "lupa/_lupa.pyx":1321 * cdef int i * if args: * old_top = lua.lua_gettop(L) # <<<<<<<<<<<<<< * for i, arg in enumerate(args): * if not py_to_lua(runtime, L, arg, wrap_none=not first_may_be_nil): */ __pyx_v_old_top = lua_gettop(__pyx_v_L); /* "lupa/_lupa.pyx":1322 * if args: * old_top = lua.lua_gettop(L) * for i, arg in enumerate(args): # <<<<<<<<<<<<<< * if not py_to_lua(runtime, L, arg, wrap_none=not first_may_be_nil): * lua.lua_settop(L, old_top) */ __pyx_t_2 = 0; __pyx_t_3 = __pyx_v_args; __Pyx_INCREF(__pyx_t_3); __pyx_t_4 = 0; for (;;) { if (__pyx_t_4 >= PyTuple_GET_SIZE(__pyx_t_3)) break; #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS __pyx_t_5 = PyTuple_GET_ITEM(__pyx_t_3, __pyx_t_4); __Pyx_INCREF(__pyx_t_5); __pyx_t_4++; if (unlikely(0 < 0)) __PYX_ERR(0, 1322, __pyx_L1_error) #else __pyx_t_5 = PySequence_ITEM(__pyx_t_3, __pyx_t_4); __pyx_t_4++; if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1322, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); #endif __Pyx_XDECREF_SET(__pyx_v_arg, __pyx_t_5); __pyx_t_5 = 0; __pyx_v_i = __pyx_t_2; __pyx_t_2 = (__pyx_t_2 + 1); /* "lupa/_lupa.pyx":1323 * old_top = lua.lua_gettop(L) * for i, arg in enumerate(args): * if not py_to_lua(runtime, L, arg, wrap_none=not first_may_be_nil): # <<<<<<<<<<<<<< * lua.lua_settop(L, old_top) * raise TypeError("failed to convert argument at index %d" % i) */ __pyx_t_7.__pyx_n = 1; __pyx_t_7.wrap_none = (!(__pyx_v_first_may_be_nil != 0)); __pyx_t_6 = __pyx_f_4lupa_5_lupa_py_to_lua(__pyx_v_runtime, __pyx_v_L, __pyx_v_arg, &__pyx_t_7); if (unlikely(__pyx_t_6 == ((int)-1))) __PYX_ERR(0, 1323, __pyx_L1_error) __pyx_t_1 = ((!(__pyx_t_6 != 0)) != 0); if (__pyx_t_1) { /* "lupa/_lupa.pyx":1324 * for i, arg in enumerate(args): * if not py_to_lua(runtime, L, arg, wrap_none=not first_may_be_nil): * lua.lua_settop(L, old_top) # <<<<<<<<<<<<<< * raise TypeError("failed to convert argument at index %d" % i) * first_may_be_nil = True */ lua_settop(__pyx_v_L, __pyx_v_old_top); /* "lupa/_lupa.pyx":1325 * if not py_to_lua(runtime, L, arg, wrap_none=not first_may_be_nil): * lua.lua_settop(L, old_top) * raise TypeError("failed to convert argument at index %d" % i) # <<<<<<<<<<<<<< * first_may_be_nil = True * return 0 */ __pyx_t_5 = __Pyx_PyInt_From_int(__pyx_v_i); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1325, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __pyx_t_8 = __Pyx_PyString_Format(__pyx_kp_s_failed_to_convert_argument_at_in, __pyx_t_5); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 1325, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __pyx_t_5 = PyTuple_New(1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1325, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_GIVEREF(__pyx_t_8); PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_8); __pyx_t_8 = 0; __pyx_t_8 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_t_5, NULL); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 1325, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_Raise(__pyx_t_8, 0, 0, 0); __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; __PYX_ERR(0, 1325, __pyx_L1_error) /* "lupa/_lupa.pyx":1323 * old_top = lua.lua_gettop(L) * for i, arg in enumerate(args): * if not py_to_lua(runtime, L, arg, wrap_none=not first_may_be_nil): # <<<<<<<<<<<<<< * lua.lua_settop(L, old_top) * raise TypeError("failed to convert argument at index %d" % i) */ } /* "lupa/_lupa.pyx":1326 * lua.lua_settop(L, old_top) * raise TypeError("failed to convert argument at index %d" % i) * first_may_be_nil = True # <<<<<<<<<<<<<< * return 0 * */ __pyx_v_first_may_be_nil = 1; /* "lupa/_lupa.pyx":1322 * if args: * old_top = lua.lua_gettop(L) * for i, arg in enumerate(args): # <<<<<<<<<<<<<< * if not py_to_lua(runtime, L, arg, wrap_none=not first_may_be_nil): * lua.lua_settop(L, old_top) */ } __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; /* "lupa/_lupa.pyx":1320 * tuple args, bint first_may_be_nil=True) except -1: * cdef int i * if args: # <<<<<<<<<<<<<< * old_top = lua.lua_gettop(L) * for i, arg in enumerate(args): */ } /* "lupa/_lupa.pyx":1327 * raise TypeError("failed to convert argument at index %d" % i) * first_may_be_nil = True * return 0 # <<<<<<<<<<<<<< * * cdef inline object unpack_lua_results(LuaRuntime runtime, lua_State *L): */ __pyx_r = 0; goto __pyx_L0; /* "lupa/_lupa.pyx":1317 * return results * * cdef int push_lua_arguments(LuaRuntime runtime, lua_State *L, # <<<<<<<<<<<<<< * tuple args, bint first_may_be_nil=True) except -1: * cdef int i */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_3); __Pyx_XDECREF(__pyx_t_5); __Pyx_XDECREF(__pyx_t_8); __Pyx_AddTraceback("lupa._lupa.push_lua_arguments", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = -1; __pyx_L0:; __Pyx_XDECREF(__pyx_v_arg); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "lupa/_lupa.pyx":1329 * return 0 * * cdef inline object unpack_lua_results(LuaRuntime runtime, lua_State *L): # <<<<<<<<<<<<<< * cdef int nargs = lua.lua_gettop(L) * if nargs == 1: */ static CYTHON_INLINE PyObject *__pyx_f_4lupa_5_lupa_unpack_lua_results(struct __pyx_obj_4lupa_5_lupa_LuaRuntime *__pyx_v_runtime, lua_State *__pyx_v_L) { int __pyx_v_nargs; PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations int __pyx_t_1; PyObject *__pyx_t_2 = NULL; __Pyx_RefNannySetupContext("unpack_lua_results", 0); /* "lupa/_lupa.pyx":1330 * * cdef inline object unpack_lua_results(LuaRuntime runtime, lua_State *L): * cdef int nargs = lua.lua_gettop(L) # <<<<<<<<<<<<<< * if nargs == 1: * return py_from_lua(runtime, L, 1) */ __pyx_v_nargs = lua_gettop(__pyx_v_L); /* "lupa/_lupa.pyx":1331 * cdef inline object unpack_lua_results(LuaRuntime runtime, lua_State *L): * cdef int nargs = lua.lua_gettop(L) * if nargs == 1: # <<<<<<<<<<<<<< * return py_from_lua(runtime, L, 1) * if nargs == 0: */ __pyx_t_1 = ((__pyx_v_nargs == 1) != 0); if (__pyx_t_1) { /* "lupa/_lupa.pyx":1332 * cdef int nargs = lua.lua_gettop(L) * if nargs == 1: * return py_from_lua(runtime, L, 1) # <<<<<<<<<<<<<< * if nargs == 0: * return None */ __Pyx_XDECREF(__pyx_r); __pyx_t_2 = __pyx_f_4lupa_5_lupa_py_from_lua(__pyx_v_runtime, __pyx_v_L, 1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1332, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_r = __pyx_t_2; __pyx_t_2 = 0; goto __pyx_L0; /* "lupa/_lupa.pyx":1331 * cdef inline object unpack_lua_results(LuaRuntime runtime, lua_State *L): * cdef int nargs = lua.lua_gettop(L) * if nargs == 1: # <<<<<<<<<<<<<< * return py_from_lua(runtime, L, 1) * if nargs == 0: */ } /* "lupa/_lupa.pyx":1333 * if nargs == 1: * return py_from_lua(runtime, L, 1) * if nargs == 0: # <<<<<<<<<<<<<< * return None * return unpack_multiple_lua_results(runtime, L, nargs) */ __pyx_t_1 = ((__pyx_v_nargs == 0) != 0); if (__pyx_t_1) { /* "lupa/_lupa.pyx":1334 * return py_from_lua(runtime, L, 1) * if nargs == 0: * return None # <<<<<<<<<<<<<< * return unpack_multiple_lua_results(runtime, L, nargs) * */ __Pyx_XDECREF(__pyx_r); __Pyx_INCREF(Py_None); __pyx_r = Py_None; goto __pyx_L0; /* "lupa/_lupa.pyx":1333 * if nargs == 1: * return py_from_lua(runtime, L, 1) * if nargs == 0: # <<<<<<<<<<<<<< * return None * return unpack_multiple_lua_results(runtime, L, nargs) */ } /* "lupa/_lupa.pyx":1335 * if nargs == 0: * return None * return unpack_multiple_lua_results(runtime, L, nargs) # <<<<<<<<<<<<<< * * cdef tuple unpack_multiple_lua_results(LuaRuntime runtime, lua_State *L, int nargs): */ __Pyx_XDECREF(__pyx_r); __pyx_t_2 = __pyx_f_4lupa_5_lupa_unpack_multiple_lua_results(__pyx_v_runtime, __pyx_v_L, __pyx_v_nargs); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1335, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_r = __pyx_t_2; __pyx_t_2 = 0; goto __pyx_L0; /* "lupa/_lupa.pyx":1329 * return 0 * * cdef inline object unpack_lua_results(LuaRuntime runtime, lua_State *L): # <<<<<<<<<<<<<< * cdef int nargs = lua.lua_gettop(L) * if nargs == 1: */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_2); __Pyx_AddTraceback("lupa._lupa.unpack_lua_results", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = 0; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "lupa/_lupa.pyx":1337 * return unpack_multiple_lua_results(runtime, L, nargs) * * cdef tuple unpack_multiple_lua_results(LuaRuntime runtime, lua_State *L, int nargs): # <<<<<<<<<<<<<< * cdef tuple args = cpython.tuple.PyTuple_New(nargs) * cdef int i */ static PyObject *__pyx_f_4lupa_5_lupa_unpack_multiple_lua_results(struct __pyx_obj_4lupa_5_lupa_LuaRuntime *__pyx_v_runtime, lua_State *__pyx_v_L, int __pyx_v_nargs) { PyObject *__pyx_v_args = 0; int __pyx_v_i; PyObject *__pyx_v_arg = NULL; PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; int __pyx_t_2; int __pyx_t_3; __Pyx_RefNannySetupContext("unpack_multiple_lua_results", 0); /* "lupa/_lupa.pyx":1338 * * cdef tuple unpack_multiple_lua_results(LuaRuntime runtime, lua_State *L, int nargs): * cdef tuple args = cpython.tuple.PyTuple_New(nargs) # <<<<<<<<<<<<<< * cdef int i * for i in range(nargs): */ __pyx_t_1 = PyTuple_New(__pyx_v_nargs); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1338, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_v_args = ((PyObject*)__pyx_t_1); __pyx_t_1 = 0; /* "lupa/_lupa.pyx":1340 * cdef tuple args = cpython.tuple.PyTuple_New(nargs) * cdef int i * for i in range(nargs): # <<<<<<<<<<<<<< * arg = py_from_lua(runtime, L, i+1) * cpython.ref.Py_INCREF(arg) */ __pyx_t_2 = __pyx_v_nargs; for (__pyx_t_3 = 0; __pyx_t_3 < __pyx_t_2; __pyx_t_3+=1) { __pyx_v_i = __pyx_t_3; /* "lupa/_lupa.pyx":1341 * cdef int i * for i in range(nargs): * arg = py_from_lua(runtime, L, i+1) # <<<<<<<<<<<<<< * cpython.ref.Py_INCREF(arg) * cpython.tuple.PyTuple_SET_ITEM(args, i, arg) */ __pyx_t_1 = __pyx_f_4lupa_5_lupa_py_from_lua(__pyx_v_runtime, __pyx_v_L, (__pyx_v_i + 1)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1341, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_XDECREF_SET(__pyx_v_arg, __pyx_t_1); __pyx_t_1 = 0; /* "lupa/_lupa.pyx":1342 * for i in range(nargs): * arg = py_from_lua(runtime, L, i+1) * cpython.ref.Py_INCREF(arg) # <<<<<<<<<<<<<< * cpython.tuple.PyTuple_SET_ITEM(args, i, arg) * return args */ Py_INCREF(__pyx_v_arg); /* "lupa/_lupa.pyx":1343 * arg = py_from_lua(runtime, L, i+1) * cpython.ref.Py_INCREF(arg) * cpython.tuple.PyTuple_SET_ITEM(args, i, arg) # <<<<<<<<<<<<<< * return args * */ PyTuple_SET_ITEM(__pyx_v_args, __pyx_v_i, __pyx_v_arg); } /* "lupa/_lupa.pyx":1344 * cpython.ref.Py_INCREF(arg) * cpython.tuple.PyTuple_SET_ITEM(args, i, arg) * return args # <<<<<<<<<<<<<< * * */ __Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_v_args); __pyx_r = __pyx_v_args; goto __pyx_L0; /* "lupa/_lupa.pyx":1337 * return unpack_multiple_lua_results(runtime, L, nargs) * * cdef tuple unpack_multiple_lua_results(LuaRuntime runtime, lua_State *L, int nargs): # <<<<<<<<<<<<<< * cdef tuple args = cpython.tuple.PyTuple_New(nargs) * cdef int i */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_AddTraceback("lupa._lupa.unpack_multiple_lua_results", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = 0; __pyx_L0:; __Pyx_XDECREF(__pyx_v_args); __Pyx_XDECREF(__pyx_v_arg); __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "lupa/_lupa.pyx":1370 * # ref-counting support for Python objects * * cdef int decref_with_gil(py_object *py_obj, lua_State* L) with gil: # <<<<<<<<<<<<<< * # originally, we just used: * #cpython.ref.Py_XDECREF(py_obj.obj) */ static int __pyx_f_4lupa_5_lupa_decref_with_gil(struct __pyx_t_4lupa_5_lupa_py_object *__pyx_v_py_obj, lua_State *__pyx_v_L) { struct __pyx_obj_4lupa_5_lupa_LuaRuntime *__pyx_v_runtime = NULL; PyObject *__pyx_v_obj_id = NULL; PyObject *__pyx_v_refs = NULL; int __pyx_r; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; PyObject *__pyx_t_2 = NULL; PyObject *__pyx_t_3 = NULL; PyObject *__pyx_t_4 = NULL; PyObject *__pyx_t_5 = NULL; PyObject *__pyx_t_6 = NULL; PyObject *__pyx_t_7 = NULL; PyObject *__pyx_t_8 = NULL; int __pyx_t_9; PyObject *__pyx_t_10 = NULL; Py_ssize_t __pyx_t_11; int __pyx_t_12; PyObject *__pyx_t_13 = NULL; PyObject *__pyx_t_14 = NULL; PyObject *__pyx_t_15 = NULL; #ifdef WITH_THREAD PyGILState_STATE __pyx_gilstate_save = __Pyx_PyGILState_Ensure(); #endif __Pyx_RefNannySetupContext("decref_with_gil", 0); /* "lupa/_lupa.pyx":1374 * #cpython.ref.Py_XDECREF(py_obj.obj) * # now, we keep Python object references in Lua visible to Python in a dict of lists: * runtime = py_obj.runtime # <<<<<<<<<<<<<< * try: * obj_id = py_obj.obj */ __pyx_t_1 = ((PyObject *)__pyx_v_py_obj->runtime); __Pyx_INCREF(__pyx_t_1); __pyx_v_runtime = ((struct __pyx_obj_4lupa_5_lupa_LuaRuntime *)__pyx_t_1); __pyx_t_1 = 0; /* "lupa/_lupa.pyx":1375 * # now, we keep Python object references in Lua visible to Python in a dict of lists: * runtime = py_obj.runtime * try: # <<<<<<<<<<<<<< * obj_id = py_obj.obj * try: */ { __Pyx_PyThreadState_declare __Pyx_PyThreadState_assign __Pyx_ExceptionSave(&__pyx_t_2, &__pyx_t_3, &__pyx_t_4); __Pyx_XGOTREF(__pyx_t_2); __Pyx_XGOTREF(__pyx_t_3); __Pyx_XGOTREF(__pyx_t_4); /*try:*/ { /* "lupa/_lupa.pyx":1376 * runtime = py_obj.runtime * try: * obj_id = py_obj.obj # <<<<<<<<<<<<<< * try: * refs = runtime._pyrefs_in_lua[obj_id] */ __pyx_t_1 = __Pyx_PyInt_FromSize_t(((uintptr_t)__pyx_v_py_obj->obj)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1376, __pyx_L3_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_5 = __pyx_t_1; __Pyx_INCREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_v_obj_id = __pyx_t_5; __pyx_t_5 = 0; /* "lupa/_lupa.pyx":1377 * try: * obj_id = py_obj.obj * try: # <<<<<<<<<<<<<< * refs = runtime._pyrefs_in_lua[obj_id] * except (TypeError, KeyError): */ { __Pyx_PyThreadState_declare __Pyx_PyThreadState_assign __Pyx_ExceptionSave(&__pyx_t_6, &__pyx_t_7, &__pyx_t_8); __Pyx_XGOTREF(__pyx_t_6); __Pyx_XGOTREF(__pyx_t_7); __Pyx_XGOTREF(__pyx_t_8); /*try:*/ { /* "lupa/_lupa.pyx":1378 * obj_id = py_obj.obj * try: * refs = runtime._pyrefs_in_lua[obj_id] # <<<<<<<<<<<<<< * except (TypeError, KeyError): * return 0 # runtime was already cleared during GC, nothing left to do */ if (unlikely(__pyx_v_runtime->_pyrefs_in_lua == Py_None)) { PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable"); __PYX_ERR(0, 1378, __pyx_L9_error) } __pyx_t_5 = __Pyx_PyDict_GetItem(__pyx_v_runtime->_pyrefs_in_lua, __pyx_v_obj_id); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1378, __pyx_L9_error) __Pyx_GOTREF(__pyx_t_5); __pyx_t_1 = __pyx_t_5; __Pyx_INCREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __pyx_v_refs = ((PyObject*)__pyx_t_1); __pyx_t_1 = 0; /* "lupa/_lupa.pyx":1377 * try: * obj_id = py_obj.obj * try: # <<<<<<<<<<<<<< * refs = runtime._pyrefs_in_lua[obj_id] * except (TypeError, KeyError): */ } __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0; __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0; goto __pyx_L14_try_end; __pyx_L9_error:; __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0; /* "lupa/_lupa.pyx":1379 * try: * refs = runtime._pyrefs_in_lua[obj_id] * except (TypeError, KeyError): # <<<<<<<<<<<<<< * return 0 # runtime was already cleared during GC, nothing left to do * if len(refs) == 1: */ __pyx_t_9 = __Pyx_PyErr_ExceptionMatches(__pyx_builtin_TypeError) || __Pyx_PyErr_ExceptionMatches(__pyx_builtin_KeyError); if (__pyx_t_9) { __Pyx_AddTraceback("lupa._lupa.decref_with_gil", __pyx_clineno, __pyx_lineno, __pyx_filename); if (__Pyx_GetException(&__pyx_t_1, &__pyx_t_5, &__pyx_t_10) < 0) __PYX_ERR(0, 1379, __pyx_L11_except_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_GOTREF(__pyx_t_5); __Pyx_GOTREF(__pyx_t_10); /* "lupa/_lupa.pyx":1380 * refs = runtime._pyrefs_in_lua[obj_id] * except (TypeError, KeyError): * return 0 # runtime was already cleared during GC, nothing left to do # <<<<<<<<<<<<<< * if len(refs) == 1: * del runtime._pyrefs_in_lua[obj_id] */ __pyx_r = 0; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; goto __pyx_L12_except_return; } goto __pyx_L11_except_error; __pyx_L11_except_error:; /* "lupa/_lupa.pyx":1377 * try: * obj_id = py_obj.obj * try: # <<<<<<<<<<<<<< * refs = runtime._pyrefs_in_lua[obj_id] * except (TypeError, KeyError): */ __Pyx_XGIVEREF(__pyx_t_6); __Pyx_XGIVEREF(__pyx_t_7); __Pyx_XGIVEREF(__pyx_t_8); __Pyx_ExceptionReset(__pyx_t_6, __pyx_t_7, __pyx_t_8); goto __pyx_L3_error; __pyx_L12_except_return:; __Pyx_XGIVEREF(__pyx_t_6); __Pyx_XGIVEREF(__pyx_t_7); __Pyx_XGIVEREF(__pyx_t_8); __Pyx_ExceptionReset(__pyx_t_6, __pyx_t_7, __pyx_t_8); goto __pyx_L7_try_return; __pyx_L14_try_end:; } /* "lupa/_lupa.pyx":1381 * except (TypeError, KeyError): * return 0 # runtime was already cleared during GC, nothing left to do * if len(refs) == 1: # <<<<<<<<<<<<<< * del runtime._pyrefs_in_lua[obj_id] * else: */ if (unlikely(__pyx_v_refs == Py_None)) { PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()"); __PYX_ERR(0, 1381, __pyx_L3_error) } __pyx_t_11 = PyList_GET_SIZE(__pyx_v_refs); if (unlikely(__pyx_t_11 == ((Py_ssize_t)-1))) __PYX_ERR(0, 1381, __pyx_L3_error) __pyx_t_12 = ((__pyx_t_11 == 1) != 0); if (__pyx_t_12) { /* "lupa/_lupa.pyx":1382 * return 0 # runtime was already cleared during GC, nothing left to do * if len(refs) == 1: * del runtime._pyrefs_in_lua[obj_id] # <<<<<<<<<<<<<< * else: * refs.pop() # any, really */ if (unlikely(__pyx_v_runtime->_pyrefs_in_lua == Py_None)) { PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable"); __PYX_ERR(0, 1382, __pyx_L3_error) } if (unlikely(PyDict_DelItem(__pyx_v_runtime->_pyrefs_in_lua, __pyx_v_obj_id) < 0)) __PYX_ERR(0, 1382, __pyx_L3_error) /* "lupa/_lupa.pyx":1381 * except (TypeError, KeyError): * return 0 # runtime was already cleared during GC, nothing left to do * if len(refs) == 1: # <<<<<<<<<<<<<< * del runtime._pyrefs_in_lua[obj_id] * else: */ goto __pyx_L17; } /* "lupa/_lupa.pyx":1384 * del runtime._pyrefs_in_lua[obj_id] * else: * refs.pop() # any, really # <<<<<<<<<<<<<< * return 0 * except: */ /*else*/ { if (unlikely(__pyx_v_refs == Py_None)) { PyErr_Format(PyExc_AttributeError, "'NoneType' object has no attribute '%.30s'", "pop"); __PYX_ERR(0, 1384, __pyx_L3_error) } __pyx_t_10 = __Pyx_PyList_Pop(__pyx_v_refs); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 1384, __pyx_L3_error) __Pyx_GOTREF(__pyx_t_10); __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; } __pyx_L17:; /* "lupa/_lupa.pyx":1385 * else: * refs.pop() # any, really * return 0 # <<<<<<<<<<<<<< * except: * try: runtime.store_raised_exception(L, b'error while cleaning up a Python object') */ __pyx_r = 0; goto __pyx_L7_try_return; /* "lupa/_lupa.pyx":1375 * # now, we keep Python object references in Lua visible to Python in a dict of lists: * runtime = py_obj.runtime * try: # <<<<<<<<<<<<<< * obj_id = py_obj.obj * try: */ } __pyx_L3_error:; __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0; /* "lupa/_lupa.pyx":1386 * refs.pop() # any, really * return 0 * except: # <<<<<<<<<<<<<< * try: runtime.store_raised_exception(L, b'error while cleaning up a Python object') * finally: return -1 */ /*except:*/ { __Pyx_AddTraceback("lupa._lupa.decref_with_gil", __pyx_clineno, __pyx_lineno, __pyx_filename); if (__Pyx_GetException(&__pyx_t_10, &__pyx_t_5, &__pyx_t_1) < 0) __PYX_ERR(0, 1386, __pyx_L5_except_error) __Pyx_GOTREF(__pyx_t_10); __Pyx_GOTREF(__pyx_t_5); __Pyx_GOTREF(__pyx_t_1); /* "lupa/_lupa.pyx":1387 * return 0 * except: * try: runtime.store_raised_exception(L, b'error while cleaning up a Python object') # <<<<<<<<<<<<<< * finally: return -1 * */ /*try:*/ { __pyx_t_9 = __pyx_f_4lupa_5_lupa_10LuaRuntime_store_raised_exception(__pyx_v_runtime, __pyx_v_L, __pyx_kp_b_error_while_cleaning_up_a_Python); if (unlikely(__pyx_t_9 == ((int)-1))) __PYX_ERR(0, 1387, __pyx_L23_error) } /* "lupa/_lupa.pyx":1388 * except: * try: runtime.store_raised_exception(L, b'error while cleaning up a Python object') * finally: return -1 # <<<<<<<<<<<<<< * * cdef int py_object_gc(lua_State* L) nogil: */ /*finally:*/ { /*normal exit:*/{ __pyx_r = -1; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; goto __pyx_L6_except_return; } __pyx_L23_error:; /*exception exit:*/{ __Pyx_PyThreadState_declare __Pyx_PyThreadState_assign __pyx_t_8 = 0; __pyx_t_7 = 0; __pyx_t_6 = 0; __pyx_t_13 = 0; __pyx_t_14 = 0; __pyx_t_15 = 0; if (PY_MAJOR_VERSION >= 3) __Pyx_ExceptionSwap(&__pyx_t_13, &__pyx_t_14, &__pyx_t_15); if ((PY_MAJOR_VERSION < 3) || unlikely(__Pyx_GetException(&__pyx_t_8, &__pyx_t_7, &__pyx_t_6) < 0)) __Pyx_ErrFetch(&__pyx_t_8, &__pyx_t_7, &__pyx_t_6); __Pyx_XGOTREF(__pyx_t_8); __Pyx_XGOTREF(__pyx_t_7); __Pyx_XGOTREF(__pyx_t_6); __Pyx_XGOTREF(__pyx_t_13); __Pyx_XGOTREF(__pyx_t_14); __Pyx_XGOTREF(__pyx_t_15); { __pyx_r = -1; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; goto __pyx_L27_return; } __pyx_L27_return:; if (PY_MAJOR_VERSION >= 3) { __Pyx_XGIVEREF(__pyx_t_13); __Pyx_XGIVEREF(__pyx_t_14); __Pyx_XGIVEREF(__pyx_t_15); __Pyx_ExceptionReset(__pyx_t_13, __pyx_t_14, __pyx_t_15); } __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0; __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0; __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; __pyx_t_13 = 0; __pyx_t_14 = 0; __pyx_t_15 = 0; goto __pyx_L6_except_return; } } } __pyx_L5_except_error:; /* "lupa/_lupa.pyx":1375 * # now, we keep Python object references in Lua visible to Python in a dict of lists: * runtime = py_obj.runtime * try: # <<<<<<<<<<<<<< * obj_id = py_obj.obj * try: */ __Pyx_XGIVEREF(__pyx_t_2); __Pyx_XGIVEREF(__pyx_t_3); __Pyx_XGIVEREF(__pyx_t_4); __Pyx_ExceptionReset(__pyx_t_2, __pyx_t_3, __pyx_t_4); goto __pyx_L1_error; __pyx_L7_try_return:; __Pyx_XGIVEREF(__pyx_t_2); __Pyx_XGIVEREF(__pyx_t_3); __Pyx_XGIVEREF(__pyx_t_4); __Pyx_ExceptionReset(__pyx_t_2, __pyx_t_3, __pyx_t_4); goto __pyx_L0; __pyx_L6_except_return:; __Pyx_XGIVEREF(__pyx_t_2); __Pyx_XGIVEREF(__pyx_t_3); __Pyx_XGIVEREF(__pyx_t_4); __Pyx_ExceptionReset(__pyx_t_2, __pyx_t_3, __pyx_t_4); goto __pyx_L0; } /* "lupa/_lupa.pyx":1370 * # ref-counting support for Python objects * * cdef int decref_with_gil(py_object *py_obj, lua_State* L) with gil: # <<<<<<<<<<<<<< * # originally, we just used: * #cpython.ref.Py_XDECREF(py_obj.obj) */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_5); __Pyx_XDECREF(__pyx_t_10); __Pyx_WriteUnraisable("lupa._lupa.decref_with_gil", __pyx_clineno, __pyx_lineno, __pyx_filename, 1, 0); __pyx_r = 0; __pyx_L0:; __Pyx_XDECREF((PyObject *)__pyx_v_runtime); __Pyx_XDECREF(__pyx_v_obj_id); __Pyx_XDECREF(__pyx_v_refs); __Pyx_RefNannyFinishContext(); #ifdef WITH_THREAD __Pyx_PyGILState_Release(__pyx_gilstate_save); #endif return __pyx_r; } /* "lupa/_lupa.pyx":1390 * finally: return -1 * * cdef int py_object_gc(lua_State* L) nogil: # <<<<<<<<<<<<<< * if not lua.lua_isuserdata(L, 1): * return 0 */ static int __pyx_f_4lupa_5_lupa_py_object_gc(lua_State *__pyx_v_L) { struct __pyx_t_4lupa_5_lupa_py_object *__pyx_v_py_obj; int __pyx_r; int __pyx_t_1; int __pyx_t_2; /* "lupa/_lupa.pyx":1391 * * cdef int py_object_gc(lua_State* L) nogil: * if not lua.lua_isuserdata(L, 1): # <<<<<<<<<<<<<< * return 0 * py_obj = unpack_userdata(L, 1) */ __pyx_t_1 = ((!(lua_isuserdata(__pyx_v_L, 1) != 0)) != 0); if (__pyx_t_1) { /* "lupa/_lupa.pyx":1392 * cdef int py_object_gc(lua_State* L) nogil: * if not lua.lua_isuserdata(L, 1): * return 0 # <<<<<<<<<<<<<< * py_obj = unpack_userdata(L, 1) * if py_obj is not NULL and py_obj.obj is not NULL: */ __pyx_r = 0; goto __pyx_L0; /* "lupa/_lupa.pyx":1391 * * cdef int py_object_gc(lua_State* L) nogil: * if not lua.lua_isuserdata(L, 1): # <<<<<<<<<<<<<< * return 0 * py_obj = unpack_userdata(L, 1) */ } /* "lupa/_lupa.pyx":1393 * if not lua.lua_isuserdata(L, 1): * return 0 * py_obj = unpack_userdata(L, 1) # <<<<<<<<<<<<<< * if py_obj is not NULL and py_obj.obj is not NULL: * if decref_with_gil(py_obj, L): */ __pyx_v_py_obj = __pyx_f_4lupa_5_lupa_unpack_userdata(__pyx_v_L, 1); /* "lupa/_lupa.pyx":1394 * return 0 * py_obj = unpack_userdata(L, 1) * if py_obj is not NULL and py_obj.obj is not NULL: # <<<<<<<<<<<<<< * if decref_with_gil(py_obj, L): * return lua.lua_error(L) # never returns! */ __pyx_t_2 = ((__pyx_v_py_obj != NULL) != 0); if (__pyx_t_2) { } else { __pyx_t_1 = __pyx_t_2; goto __pyx_L5_bool_binop_done; } __pyx_t_2 = ((__pyx_v_py_obj->obj != NULL) != 0); __pyx_t_1 = __pyx_t_2; __pyx_L5_bool_binop_done:; if (__pyx_t_1) { /* "lupa/_lupa.pyx":1395 * py_obj = unpack_userdata(L, 1) * if py_obj is not NULL and py_obj.obj is not NULL: * if decref_with_gil(py_obj, L): # <<<<<<<<<<<<<< * return lua.lua_error(L) # never returns! * return 0 */ __pyx_t_1 = (__pyx_f_4lupa_5_lupa_decref_with_gil(__pyx_v_py_obj, __pyx_v_L) != 0); if (__pyx_t_1) { /* "lupa/_lupa.pyx":1396 * if py_obj is not NULL and py_obj.obj is not NULL: * if decref_with_gil(py_obj, L): * return lua.lua_error(L) # never returns! # <<<<<<<<<<<<<< * return 0 * */ __pyx_r = lua_error(__pyx_v_L); goto __pyx_L0; /* "lupa/_lupa.pyx":1395 * py_obj = unpack_userdata(L, 1) * if py_obj is not NULL and py_obj.obj is not NULL: * if decref_with_gil(py_obj, L): # <<<<<<<<<<<<<< * return lua.lua_error(L) # never returns! * return 0 */ } /* "lupa/_lupa.pyx":1394 * return 0 * py_obj = unpack_userdata(L, 1) * if py_obj is not NULL and py_obj.obj is not NULL: # <<<<<<<<<<<<<< * if decref_with_gil(py_obj, L): * return lua.lua_error(L) # never returns! */ } /* "lupa/_lupa.pyx":1397 * if decref_with_gil(py_obj, L): * return lua.lua_error(L) # never returns! * return 0 # <<<<<<<<<<<<<< * * # calling Python objects */ __pyx_r = 0; goto __pyx_L0; /* "lupa/_lupa.pyx":1390 * finally: return -1 * * cdef int py_object_gc(lua_State* L) nogil: # <<<<<<<<<<<<<< * if not lua.lua_isuserdata(L, 1): * return 0 */ /* function exit code */ __pyx_L0:; return __pyx_r; } /* "lupa/_lupa.pyx":1401 * # calling Python objects * * cdef bint call_python(LuaRuntime runtime, lua_State *L, py_object* py_obj) except -1: # <<<<<<<<<<<<<< * cdef int i, nargs = lua.lua_gettop(L) - 1 * cdef tuple args */ static int __pyx_f_4lupa_5_lupa_call_python(struct __pyx_obj_4lupa_5_lupa_LuaRuntime *__pyx_v_runtime, lua_State *__pyx_v_L, struct __pyx_t_4lupa_5_lupa_py_object *__pyx_v_py_obj) { int __pyx_v_i; int __pyx_v_nargs; PyObject *__pyx_v_args = 0; PyObject *__pyx_v_f = NULL; PyObject *__pyx_v_result = NULL; PyObject *__pyx_v_arg = NULL; int __pyx_r; __Pyx_RefNannyDeclarations int __pyx_t_1; PyObject *__pyx_t_2 = NULL; PyObject *__pyx_t_3 = NULL; PyObject *__pyx_t_4 = NULL; int __pyx_t_5; PyObject *__pyx_t_6; int __pyx_t_7; int __pyx_t_8; __Pyx_RefNannySetupContext("call_python", 0); /* "lupa/_lupa.pyx":1402 * * cdef bint call_python(LuaRuntime runtime, lua_State *L, py_object* py_obj) except -1: * cdef int i, nargs = lua.lua_gettop(L) - 1 # <<<<<<<<<<<<<< * cdef tuple args * */ __pyx_v_nargs = (lua_gettop(__pyx_v_L) - 1); /* "lupa/_lupa.pyx":1405 * cdef tuple args * * if not py_obj: # <<<<<<<<<<<<<< * raise TypeError("not a python object") * */ __pyx_t_1 = ((!(__pyx_v_py_obj != 0)) != 0); if (__pyx_t_1) { /* "lupa/_lupa.pyx":1406 * * if not py_obj: * raise TypeError("not a python object") # <<<<<<<<<<<<<< * * f = py_obj.obj */ __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__44, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1406, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_Raise(__pyx_t_2, 0, 0, 0); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __PYX_ERR(0, 1406, __pyx_L1_error) /* "lupa/_lupa.pyx":1405 * cdef tuple args * * if not py_obj: # <<<<<<<<<<<<<< * raise TypeError("not a python object") * */ } /* "lupa/_lupa.pyx":1408 * raise TypeError("not a python object") * * f = py_obj.obj # <<<<<<<<<<<<<< * * if not nargs: */ __pyx_t_2 = ((PyObject *)__pyx_v_py_obj->obj); __Pyx_INCREF(__pyx_t_2); __pyx_v_f = __pyx_t_2; __pyx_t_2 = 0; /* "lupa/_lupa.pyx":1410 * f = py_obj.obj * * if not nargs: # <<<<<<<<<<<<<< * lua.lua_settop(L, 0) # FIXME * result = f() */ __pyx_t_1 = ((!(__pyx_v_nargs != 0)) != 0); if (__pyx_t_1) { /* "lupa/_lupa.pyx":1411 * * if not nargs: * lua.lua_settop(L, 0) # FIXME # <<<<<<<<<<<<<< * result = f() * else: */ lua_settop(__pyx_v_L, 0); /* "lupa/_lupa.pyx":1412 * if not nargs: * lua.lua_settop(L, 0) # FIXME * result = f() # <<<<<<<<<<<<<< * else: * arg = py_from_lua(runtime, L, 2) */ __Pyx_INCREF(__pyx_v_f); __pyx_t_3 = __pyx_v_f; __pyx_t_4 = NULL; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) { __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3); if (likely(__pyx_t_4)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); __Pyx_INCREF(__pyx_t_4); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_3, function); } } if (__pyx_t_4) { __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_4); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1412, __pyx_L1_error) __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; } else { __pyx_t_2 = __Pyx_PyObject_CallNoArg(__pyx_t_3); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1412, __pyx_L1_error) } __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_v_result = __pyx_t_2; __pyx_t_2 = 0; /* "lupa/_lupa.pyx":1410 * f = py_obj.obj * * if not nargs: # <<<<<<<<<<<<<< * lua.lua_settop(L, 0) # FIXME * result = f() */ goto __pyx_L4; } /* "lupa/_lupa.pyx":1414 * result = f() * else: * arg = py_from_lua(runtime, L, 2) # <<<<<<<<<<<<<< * * if PyMethod_Check(f) and (arg) is PyMethod_GET_SELF(f): */ /*else*/ { __pyx_t_2 = __pyx_f_4lupa_5_lupa_py_from_lua(__pyx_v_runtime, __pyx_v_L, 2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1414, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_v_arg = __pyx_t_2; __pyx_t_2 = 0; /* "lupa/_lupa.pyx":1416 * arg = py_from_lua(runtime, L, 2) * * if PyMethod_Check(f) and (arg) is PyMethod_GET_SELF(f): # <<<<<<<<<<<<<< * # Calling a bound method and self is already the first argument. * # Lua x:m(a, b) => Python as x.m(x, a, b) but should be x.m(a, b) */ __pyx_t_5 = (PyMethod_Check(__pyx_v_f) != 0); if (__pyx_t_5) { } else { __pyx_t_1 = __pyx_t_5; goto __pyx_L6_bool_binop_done; } __pyx_t_5 = ((((PyObject *)__pyx_v_arg) == PyMethod_GET_SELF(__pyx_v_f)) != 0); __pyx_t_1 = __pyx_t_5; __pyx_L6_bool_binop_done:; if (__pyx_t_1) { /* "lupa/_lupa.pyx":1426 * # The method wrapper would only prepend self to the tuple again, * # so we just call the underlying function directly instead. * f = PyMethod_GET_FUNCTION(f) # <<<<<<<<<<<<<< * * args = cpython.tuple.PyTuple_New(nargs) */ __pyx_t_6 = PyMethod_GET_FUNCTION(__pyx_v_f); __pyx_t_2 = ((PyObject *)__pyx_t_6); __Pyx_INCREF(__pyx_t_2); __Pyx_DECREF_SET(__pyx_v_f, __pyx_t_2); __pyx_t_2 = 0; /* "lupa/_lupa.pyx":1416 * arg = py_from_lua(runtime, L, 2) * * if PyMethod_Check(f) and (arg) is PyMethod_GET_SELF(f): # <<<<<<<<<<<<<< * # Calling a bound method and self is already the first argument. * # Lua x:m(a, b) => Python as x.m(x, a, b) but should be x.m(a, b) */ } /* "lupa/_lupa.pyx":1428 * f = PyMethod_GET_FUNCTION(f) * * args = cpython.tuple.PyTuple_New(nargs) # <<<<<<<<<<<<<< * cpython.ref.Py_INCREF(arg) * cpython.tuple.PyTuple_SET_ITEM(args, 0, arg) */ __pyx_t_2 = PyTuple_New(__pyx_v_nargs); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1428, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_v_args = ((PyObject*)__pyx_t_2); __pyx_t_2 = 0; /* "lupa/_lupa.pyx":1429 * * args = cpython.tuple.PyTuple_New(nargs) * cpython.ref.Py_INCREF(arg) # <<<<<<<<<<<<<< * cpython.tuple.PyTuple_SET_ITEM(args, 0, arg) * */ Py_INCREF(__pyx_v_arg); /* "lupa/_lupa.pyx":1430 * args = cpython.tuple.PyTuple_New(nargs) * cpython.ref.Py_INCREF(arg) * cpython.tuple.PyTuple_SET_ITEM(args, 0, arg) # <<<<<<<<<<<<<< * * for i in range(1, nargs): */ PyTuple_SET_ITEM(__pyx_v_args, 0, __pyx_v_arg); /* "lupa/_lupa.pyx":1432 * cpython.tuple.PyTuple_SET_ITEM(args, 0, arg) * * for i in range(1, nargs): # <<<<<<<<<<<<<< * arg = py_from_lua(runtime, L, i+2) * cpython.ref.Py_INCREF(arg) */ __pyx_t_7 = __pyx_v_nargs; for (__pyx_t_8 = 1; __pyx_t_8 < __pyx_t_7; __pyx_t_8+=1) { __pyx_v_i = __pyx_t_8; /* "lupa/_lupa.pyx":1433 * * for i in range(1, nargs): * arg = py_from_lua(runtime, L, i+2) # <<<<<<<<<<<<<< * cpython.ref.Py_INCREF(arg) * cpython.tuple.PyTuple_SET_ITEM(args, i, arg) */ __pyx_t_2 = __pyx_f_4lupa_5_lupa_py_from_lua(__pyx_v_runtime, __pyx_v_L, (__pyx_v_i + 2)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1433, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF_SET(__pyx_v_arg, __pyx_t_2); __pyx_t_2 = 0; /* "lupa/_lupa.pyx":1434 * for i in range(1, nargs): * arg = py_from_lua(runtime, L, i+2) * cpython.ref.Py_INCREF(arg) # <<<<<<<<<<<<<< * cpython.tuple.PyTuple_SET_ITEM(args, i, arg) * */ Py_INCREF(__pyx_v_arg); /* "lupa/_lupa.pyx":1435 * arg = py_from_lua(runtime, L, i+2) * cpython.ref.Py_INCREF(arg) * cpython.tuple.PyTuple_SET_ITEM(args, i, arg) # <<<<<<<<<<<<<< * * lua.lua_settop(L, 0) # FIXME */ PyTuple_SET_ITEM(__pyx_v_args, __pyx_v_i, __pyx_v_arg); } /* "lupa/_lupa.pyx":1437 * cpython.tuple.PyTuple_SET_ITEM(args, i, arg) * * lua.lua_settop(L, 0) # FIXME # <<<<<<<<<<<<<< * result = f(*args) * */ lua_settop(__pyx_v_L, 0); /* "lupa/_lupa.pyx":1438 * * lua.lua_settop(L, 0) # FIXME * result = f(*args) # <<<<<<<<<<<<<< * * return py_function_result_to_lua(runtime, L, result) */ if (unlikely(__pyx_v_args == Py_None)) { PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable"); __PYX_ERR(0, 1438, __pyx_L1_error) } __pyx_t_2 = __Pyx_PyObject_Call(__pyx_v_f, __pyx_v_args, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1438, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_v_result = __pyx_t_2; __pyx_t_2 = 0; } __pyx_L4:; /* "lupa/_lupa.pyx":1440 * result = f(*args) * * return py_function_result_to_lua(runtime, L, result) # <<<<<<<<<<<<<< * * cdef int py_call_with_gil(lua_State* L, py_object *py_obj) with gil: */ __pyx_t_7 = __pyx_f_4lupa_5_lupa_py_function_result_to_lua(__pyx_v_runtime, __pyx_v_L, __pyx_v_result); if (unlikely(__pyx_t_7 == ((int)-1))) __PYX_ERR(0, 1440, __pyx_L1_error) __pyx_r = __pyx_t_7; goto __pyx_L0; /* "lupa/_lupa.pyx":1401 * # calling Python objects * * cdef bint call_python(LuaRuntime runtime, lua_State *L, py_object* py_obj) except -1: # <<<<<<<<<<<<<< * cdef int i, nargs = lua.lua_gettop(L) - 1 * cdef tuple args */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_2); __Pyx_XDECREF(__pyx_t_3); __Pyx_XDECREF(__pyx_t_4); __Pyx_AddTraceback("lupa._lupa.call_python", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = -1; __pyx_L0:; __Pyx_XDECREF(__pyx_v_args); __Pyx_XDECREF(__pyx_v_f); __Pyx_XDECREF(__pyx_v_result); __Pyx_XDECREF(__pyx_v_arg); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "lupa/_lupa.pyx":1442 * return py_function_result_to_lua(runtime, L, result) * * cdef int py_call_with_gil(lua_State* L, py_object *py_obj) with gil: # <<<<<<<<<<<<<< * cdef LuaRuntime runtime = None * cdef lua_State* stored_state = NULL */ static int __pyx_f_4lupa_5_lupa_py_call_with_gil(lua_State *__pyx_v_L, struct __pyx_t_4lupa_5_lupa_py_object *__pyx_v_py_obj) { struct __pyx_obj_4lupa_5_lupa_LuaRuntime *__pyx_v_runtime = 0; lua_State *__pyx_v_stored_state; int __pyx_r; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; PyObject *__pyx_t_2 = NULL; PyObject *__pyx_t_3 = NULL; PyObject *__pyx_t_4 = NULL; int __pyx_t_5; lua_State *__pyx_t_6; PyObject *__pyx_t_7 = NULL; PyObject *__pyx_t_8 = NULL; int __pyx_t_9; int __pyx_t_10; char const *__pyx_t_11; PyObject *__pyx_t_12 = NULL; PyObject *__pyx_t_13 = NULL; PyObject *__pyx_t_14 = NULL; #ifdef WITH_THREAD PyGILState_STATE __pyx_gilstate_save = __Pyx_PyGILState_Ensure(); #endif __Pyx_RefNannySetupContext("py_call_with_gil", 0); /* "lupa/_lupa.pyx":1443 * * cdef int py_call_with_gil(lua_State* L, py_object *py_obj) with gil: * cdef LuaRuntime runtime = None # <<<<<<<<<<<<<< * cdef lua_State* stored_state = NULL * */ __Pyx_INCREF(Py_None); __pyx_v_runtime = ((struct __pyx_obj_4lupa_5_lupa_LuaRuntime *)Py_None); /* "lupa/_lupa.pyx":1444 * cdef int py_call_with_gil(lua_State* L, py_object *py_obj) with gil: * cdef LuaRuntime runtime = None * cdef lua_State* stored_state = NULL # <<<<<<<<<<<<<< * * try: */ __pyx_v_stored_state = NULL; /* "lupa/_lupa.pyx":1446 * cdef lua_State* stored_state = NULL * * try: # <<<<<<<<<<<<<< * runtime = py_obj.runtime * if runtime._state is not L: */ /*try:*/ { { __Pyx_PyThreadState_declare __Pyx_PyThreadState_assign __Pyx_ExceptionSave(&__pyx_t_1, &__pyx_t_2, &__pyx_t_3); __Pyx_XGOTREF(__pyx_t_1); __Pyx_XGOTREF(__pyx_t_2); __Pyx_XGOTREF(__pyx_t_3); /*try:*/ { /* "lupa/_lupa.pyx":1447 * * try: * runtime = py_obj.runtime # <<<<<<<<<<<<<< * if runtime._state is not L: * stored_state = runtime._state */ __pyx_t_4 = ((PyObject *)__pyx_v_py_obj->runtime); __Pyx_INCREF(__pyx_t_4); __Pyx_DECREF_SET(__pyx_v_runtime, ((struct __pyx_obj_4lupa_5_lupa_LuaRuntime *)__pyx_t_4)); __pyx_t_4 = 0; /* "lupa/_lupa.pyx":1448 * try: * runtime = py_obj.runtime * if runtime._state is not L: # <<<<<<<<<<<<<< * stored_state = runtime._state * runtime._state = L */ __pyx_t_5 = ((__pyx_v_runtime->_state != __pyx_v_L) != 0); if (__pyx_t_5) { /* "lupa/_lupa.pyx":1449 * runtime = py_obj.runtime * if runtime._state is not L: * stored_state = runtime._state # <<<<<<<<<<<<<< * runtime._state = L * return call_python(runtime, L, py_obj) */ __pyx_t_6 = __pyx_v_runtime->_state; __pyx_v_stored_state = __pyx_t_6; /* "lupa/_lupa.pyx":1450 * if runtime._state is not L: * stored_state = runtime._state * runtime._state = L # <<<<<<<<<<<<<< * return call_python(runtime, L, py_obj) * except: */ __pyx_v_runtime->_state = __pyx_v_L; /* "lupa/_lupa.pyx":1448 * try: * runtime = py_obj.runtime * if runtime._state is not L: # <<<<<<<<<<<<<< * stored_state = runtime._state * runtime._state = L */ } /* "lupa/_lupa.pyx":1451 * stored_state = runtime._state * runtime._state = L * return call_python(runtime, L, py_obj) # <<<<<<<<<<<<<< * except: * runtime.store_raised_exception(L, b'error during Python call') */ __pyx_t_5 = __pyx_f_4lupa_5_lupa_call_python(__pyx_v_runtime, __pyx_v_L, __pyx_v_py_obj); if (unlikely(__pyx_t_5 == ((int)-1))) __PYX_ERR(0, 1451, __pyx_L6_error) __pyx_r = __pyx_t_5; goto __pyx_L10_try_return; /* "lupa/_lupa.pyx":1446 * cdef lua_State* stored_state = NULL * * try: # <<<<<<<<<<<<<< * runtime = py_obj.runtime * if runtime._state is not L: */ } __pyx_L6_error:; __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; /* "lupa/_lupa.pyx":1452 * runtime._state = L * return call_python(runtime, L, py_obj) * except: # <<<<<<<<<<<<<< * runtime.store_raised_exception(L, b'error during Python call') * return -1 */ /*except:*/ { __Pyx_AddTraceback("lupa._lupa.py_call_with_gil", __pyx_clineno, __pyx_lineno, __pyx_filename); if (__Pyx_GetException(&__pyx_t_4, &__pyx_t_7, &__pyx_t_8) < 0) __PYX_ERR(0, 1452, __pyx_L8_except_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_GOTREF(__pyx_t_7); __Pyx_GOTREF(__pyx_t_8); /* "lupa/_lupa.pyx":1453 * return call_python(runtime, L, py_obj) * except: * runtime.store_raised_exception(L, b'error during Python call') # <<<<<<<<<<<<<< * return -1 * finally: */ __pyx_t_9 = __pyx_f_4lupa_5_lupa_10LuaRuntime_store_raised_exception(__pyx_v_runtime, __pyx_v_L, __pyx_kp_b_error_during_Python_call); if (unlikely(__pyx_t_9 == ((int)-1))) __PYX_ERR(0, 1453, __pyx_L8_except_error) /* "lupa/_lupa.pyx":1454 * except: * runtime.store_raised_exception(L, b'error during Python call') * return -1 # <<<<<<<<<<<<<< * finally: * if stored_state is not NULL: */ __pyx_r = -1; __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; goto __pyx_L9_except_return; } __pyx_L8_except_error:; /* "lupa/_lupa.pyx":1446 * cdef lua_State* stored_state = NULL * * try: # <<<<<<<<<<<<<< * runtime = py_obj.runtime * if runtime._state is not L: */ __Pyx_XGIVEREF(__pyx_t_1); __Pyx_XGIVEREF(__pyx_t_2); __Pyx_XGIVEREF(__pyx_t_3); __Pyx_ExceptionReset(__pyx_t_1, __pyx_t_2, __pyx_t_3); goto __pyx_L4_error; __pyx_L10_try_return:; __Pyx_XGIVEREF(__pyx_t_1); __Pyx_XGIVEREF(__pyx_t_2); __Pyx_XGIVEREF(__pyx_t_3); __Pyx_ExceptionReset(__pyx_t_1, __pyx_t_2, __pyx_t_3); goto __pyx_L3_return; __pyx_L9_except_return:; __Pyx_XGIVEREF(__pyx_t_1); __Pyx_XGIVEREF(__pyx_t_2); __Pyx_XGIVEREF(__pyx_t_3); __Pyx_ExceptionReset(__pyx_t_1, __pyx_t_2, __pyx_t_3); goto __pyx_L3_return; } } /* "lupa/_lupa.pyx":1456 * return -1 * finally: * if stored_state is not NULL: # <<<<<<<<<<<<<< * runtime._state = stored_state * */ /*finally:*/ { __pyx_L4_error:; /*exception exit:*/{ __Pyx_PyThreadState_declare __Pyx_PyThreadState_assign __pyx_t_3 = 0; __pyx_t_2 = 0; __pyx_t_1 = 0; __pyx_t_12 = 0; __pyx_t_13 = 0; __pyx_t_14 = 0; __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0; __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0; if (PY_MAJOR_VERSION >= 3) __Pyx_ExceptionSwap(&__pyx_t_12, &__pyx_t_13, &__pyx_t_14); if ((PY_MAJOR_VERSION < 3) || unlikely(__Pyx_GetException(&__pyx_t_3, &__pyx_t_2, &__pyx_t_1) < 0)) __Pyx_ErrFetch(&__pyx_t_3, &__pyx_t_2, &__pyx_t_1); __Pyx_XGOTREF(__pyx_t_3); __Pyx_XGOTREF(__pyx_t_2); __Pyx_XGOTREF(__pyx_t_1); __Pyx_XGOTREF(__pyx_t_12); __Pyx_XGOTREF(__pyx_t_13); __Pyx_XGOTREF(__pyx_t_14); __pyx_t_9 = __pyx_lineno; __pyx_t_10 = __pyx_clineno; __pyx_t_11 = __pyx_filename; { __pyx_t_5 = ((__pyx_v_stored_state != NULL) != 0); if (__pyx_t_5) { /* "lupa/_lupa.pyx":1457 * finally: * if stored_state is not NULL: * runtime._state = stored_state # <<<<<<<<<<<<<< * * cdef int py_object_call(lua_State* L) nogil: */ __pyx_v_runtime->_state = __pyx_v_stored_state; /* "lupa/_lupa.pyx":1456 * return -1 * finally: * if stored_state is not NULL: # <<<<<<<<<<<<<< * runtime._state = stored_state * */ } } if (PY_MAJOR_VERSION >= 3) { __Pyx_XGIVEREF(__pyx_t_12); __Pyx_XGIVEREF(__pyx_t_13); __Pyx_XGIVEREF(__pyx_t_14); __Pyx_ExceptionReset(__pyx_t_12, __pyx_t_13, __pyx_t_14); } __Pyx_XGIVEREF(__pyx_t_3); __Pyx_XGIVEREF(__pyx_t_2); __Pyx_XGIVEREF(__pyx_t_1); __Pyx_ErrRestore(__pyx_t_3, __pyx_t_2, __pyx_t_1); __pyx_t_3 = 0; __pyx_t_2 = 0; __pyx_t_1 = 0; __pyx_t_12 = 0; __pyx_t_13 = 0; __pyx_t_14 = 0; __pyx_lineno = __pyx_t_9; __pyx_clineno = __pyx_t_10; __pyx_filename = __pyx_t_11; goto __pyx_L1_error; } __pyx_L3_return: { __pyx_t_10 = __pyx_r; __pyx_t_5 = ((__pyx_v_stored_state != NULL) != 0); if (__pyx_t_5) { /* "lupa/_lupa.pyx":1457 * finally: * if stored_state is not NULL: * runtime._state = stored_state # <<<<<<<<<<<<<< * * cdef int py_object_call(lua_State* L) nogil: */ __pyx_v_runtime->_state = __pyx_v_stored_state; /* "lupa/_lupa.pyx":1456 * return -1 * finally: * if stored_state is not NULL: # <<<<<<<<<<<<<< * runtime._state = stored_state * */ } __pyx_r = __pyx_t_10; goto __pyx_L0; } } /* "lupa/_lupa.pyx":1442 * return py_function_result_to_lua(runtime, L, result) * * cdef int py_call_with_gil(lua_State* L, py_object *py_obj) with gil: # <<<<<<<<<<<<<< * cdef LuaRuntime runtime = None * cdef lua_State* stored_state = NULL */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_4); __Pyx_XDECREF(__pyx_t_7); __Pyx_XDECREF(__pyx_t_8); __Pyx_WriteUnraisable("lupa._lupa.py_call_with_gil", __pyx_clineno, __pyx_lineno, __pyx_filename, 1, 0); __pyx_r = 0; __pyx_L0:; __Pyx_XDECREF((PyObject *)__pyx_v_runtime); __Pyx_RefNannyFinishContext(); #ifdef WITH_THREAD __Pyx_PyGILState_Release(__pyx_gilstate_save); #endif return __pyx_r; } /* "lupa/_lupa.pyx":1459 * runtime._state = stored_state * * cdef int py_object_call(lua_State* L) nogil: # <<<<<<<<<<<<<< * cdef py_object* py_obj = unwrap_lua_object(L, 1) # may not return on error! * if not py_obj: */ static int __pyx_f_4lupa_5_lupa_py_object_call(lua_State *__pyx_v_L) { struct __pyx_t_4lupa_5_lupa_py_object *__pyx_v_py_obj; int __pyx_v_result; int __pyx_r; int __pyx_t_1; /* "lupa/_lupa.pyx":1460 * * cdef int py_object_call(lua_State* L) nogil: * cdef py_object* py_obj = unwrap_lua_object(L, 1) # may not return on error! # <<<<<<<<<<<<<< * if not py_obj: * return lua.luaL_argerror(L, 1, "not a python object") # never returns! */ __pyx_v_py_obj = __pyx_f_4lupa_5_lupa_unwrap_lua_object(__pyx_v_L, 1); /* "lupa/_lupa.pyx":1461 * cdef int py_object_call(lua_State* L) nogil: * cdef py_object* py_obj = unwrap_lua_object(L, 1) # may not return on error! * if not py_obj: # <<<<<<<<<<<<<< * return lua.luaL_argerror(L, 1, "not a python object") # never returns! * */ __pyx_t_1 = ((!(__pyx_v_py_obj != 0)) != 0); if (__pyx_t_1) { /* "lupa/_lupa.pyx":1462 * cdef py_object* py_obj = unwrap_lua_object(L, 1) # may not return on error! * if not py_obj: * return lua.luaL_argerror(L, 1, "not a python object") # never returns! # <<<<<<<<<<<<<< * * result = py_call_with_gil(L, py_obj) */ __pyx_r = luaL_argerror(__pyx_v_L, 1, ((char *)"not a python object")); goto __pyx_L0; /* "lupa/_lupa.pyx":1461 * cdef int py_object_call(lua_State* L) nogil: * cdef py_object* py_obj = unwrap_lua_object(L, 1) # may not return on error! * if not py_obj: # <<<<<<<<<<<<<< * return lua.luaL_argerror(L, 1, "not a python object") # never returns! * */ } /* "lupa/_lupa.pyx":1464 * return lua.luaL_argerror(L, 1, "not a python object") # never returns! * * result = py_call_with_gil(L, py_obj) # <<<<<<<<<<<<<< * if result < 0: * return lua.lua_error(L) # never returns! */ __pyx_v_result = __pyx_f_4lupa_5_lupa_py_call_with_gil(__pyx_v_L, __pyx_v_py_obj); /* "lupa/_lupa.pyx":1465 * * result = py_call_with_gil(L, py_obj) * if result < 0: # <<<<<<<<<<<<<< * return lua.lua_error(L) # never returns! * return result */ __pyx_t_1 = ((__pyx_v_result < 0) != 0); if (__pyx_t_1) { /* "lupa/_lupa.pyx":1466 * result = py_call_with_gil(L, py_obj) * if result < 0: * return lua.lua_error(L) # never returns! # <<<<<<<<<<<<<< * return result * */ __pyx_r = lua_error(__pyx_v_L); goto __pyx_L0; /* "lupa/_lupa.pyx":1465 * * result = py_call_with_gil(L, py_obj) * if result < 0: # <<<<<<<<<<<<<< * return lua.lua_error(L) # never returns! * return result */ } /* "lupa/_lupa.pyx":1467 * if result < 0: * return lua.lua_error(L) # never returns! * return result # <<<<<<<<<<<<<< * * # str() support for Python objects */ __pyx_r = __pyx_v_result; goto __pyx_L0; /* "lupa/_lupa.pyx":1459 * runtime._state = stored_state * * cdef int py_object_call(lua_State* L) nogil: # <<<<<<<<<<<<<< * cdef py_object* py_obj = unwrap_lua_object(L, 1) # may not return on error! * if not py_obj: */ /* function exit code */ __pyx_L0:; return __pyx_r; } /* "lupa/_lupa.pyx":1471 * # str() support for Python objects * * cdef int py_str_with_gil(lua_State* L, py_object* py_obj) with gil: # <<<<<<<<<<<<<< * cdef LuaRuntime runtime * try: */ static int __pyx_f_4lupa_5_lupa_py_str_with_gil(lua_State *__pyx_v_L, struct __pyx_t_4lupa_5_lupa_py_object *__pyx_v_py_obj) { struct __pyx_obj_4lupa_5_lupa_LuaRuntime *__pyx_v_runtime = 0; PyObject *__pyx_v_s = NULL; int __pyx_r; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; PyObject *__pyx_t_2 = NULL; PyObject *__pyx_t_3 = NULL; PyObject *__pyx_t_4 = NULL; PyObject *__pyx_t_5 = NULL; int __pyx_t_6; int __pyx_t_7; char const *__pyx_t_8; char *__pyx_t_9; Py_ssize_t __pyx_t_10; PyObject *__pyx_t_11 = NULL; int __pyx_t_12; PyObject *__pyx_t_13 = NULL; PyObject *__pyx_t_14 = NULL; PyObject *__pyx_t_15 = NULL; PyObject *__pyx_t_16 = NULL; PyObject *__pyx_t_17 = NULL; PyObject *__pyx_t_18 = NULL; #ifdef WITH_THREAD PyGILState_STATE __pyx_gilstate_save = __Pyx_PyGILState_Ensure(); #endif __Pyx_RefNannySetupContext("py_str_with_gil", 0); /* "lupa/_lupa.pyx":1473 * cdef int py_str_with_gil(lua_State* L, py_object* py_obj) with gil: * cdef LuaRuntime runtime * try: # <<<<<<<<<<<<<< * runtime = py_obj.runtime * s = str(py_obj.obj) */ { __Pyx_PyThreadState_declare __Pyx_PyThreadState_assign __Pyx_ExceptionSave(&__pyx_t_1, &__pyx_t_2, &__pyx_t_3); __Pyx_XGOTREF(__pyx_t_1); __Pyx_XGOTREF(__pyx_t_2); __Pyx_XGOTREF(__pyx_t_3); /*try:*/ { /* "lupa/_lupa.pyx":1474 * cdef LuaRuntime runtime * try: * runtime = py_obj.runtime # <<<<<<<<<<<<<< * s = str(py_obj.obj) * if isinstance(s, unicode): */ __pyx_t_4 = ((PyObject *)__pyx_v_py_obj->runtime); __Pyx_INCREF(__pyx_t_4); __pyx_v_runtime = ((struct __pyx_obj_4lupa_5_lupa_LuaRuntime *)__pyx_t_4); __pyx_t_4 = 0; /* "lupa/_lupa.pyx":1475 * try: * runtime = py_obj.runtime * s = str(py_obj.obj) # <<<<<<<<<<<<<< * if isinstance(s, unicode): * if runtime._encoding is None: */ __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1475, __pyx_L3_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_INCREF(((PyObject *)__pyx_v_py_obj->obj)); __Pyx_GIVEREF(((PyObject *)__pyx_v_py_obj->obj)); PyTuple_SET_ITEM(__pyx_t_4, 0, ((PyObject *)__pyx_v_py_obj->obj)); __pyx_t_5 = __Pyx_PyObject_Call(((PyObject *)(&PyString_Type)), __pyx_t_4, NULL); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1475, __pyx_L3_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_v_s = __pyx_t_5; __pyx_t_5 = 0; /* "lupa/_lupa.pyx":1476 * runtime = py_obj.runtime * s = str(py_obj.obj) * if isinstance(s, unicode): # <<<<<<<<<<<<<< * if runtime._encoding is None: * s = (s).encode('UTF-8') */ __pyx_t_6 = PyUnicode_Check(__pyx_v_s); __pyx_t_7 = (__pyx_t_6 != 0); if (__pyx_t_7) { /* "lupa/_lupa.pyx":1477 * s = str(py_obj.obj) * if isinstance(s, unicode): * if runtime._encoding is None: # <<<<<<<<<<<<<< * s = (s).encode('UTF-8') * else: */ __pyx_t_7 = (__pyx_v_runtime->_encoding == ((PyObject*)Py_None)); __pyx_t_6 = (__pyx_t_7 != 0); if (__pyx_t_6) { /* "lupa/_lupa.pyx":1478 * if isinstance(s, unicode): * if runtime._encoding is None: * s = (s).encode('UTF-8') # <<<<<<<<<<<<<< * else: * s = (s).encode(runtime._encoding) */ if (unlikely(__pyx_v_s == Py_None)) { PyErr_Format(PyExc_AttributeError, "'NoneType' object has no attribute '%.30s'", "encode"); __PYX_ERR(0, 1478, __pyx_L3_error) } __pyx_t_5 = PyUnicode_AsUTF8String(((PyObject*)__pyx_v_s)); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1478, __pyx_L3_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF_SET(__pyx_v_s, __pyx_t_5); __pyx_t_5 = 0; /* "lupa/_lupa.pyx":1477 * s = str(py_obj.obj) * if isinstance(s, unicode): * if runtime._encoding is None: # <<<<<<<<<<<<<< * s = (s).encode('UTF-8') * else: */ goto __pyx_L10; } /* "lupa/_lupa.pyx":1480 * s = (s).encode('UTF-8') * else: * s = (s).encode(runtime._encoding) # <<<<<<<<<<<<<< * else: * assert isinstance(s, bytes) */ /*else*/ { if (unlikely(__pyx_v_s == Py_None)) { PyErr_Format(PyExc_AttributeError, "'NoneType' object has no attribute '%.30s'", "encode"); __PYX_ERR(0, 1480, __pyx_L3_error) } if (unlikely(__pyx_v_runtime->_encoding == Py_None)) { PyErr_SetString(PyExc_TypeError, "expected bytes, NoneType found"); __PYX_ERR(0, 1480, __pyx_L3_error) } __pyx_t_8 = __Pyx_PyBytes_AsString(__pyx_v_runtime->_encoding); if (unlikely((!__pyx_t_8) && PyErr_Occurred())) __PYX_ERR(0, 1480, __pyx_L3_error) __pyx_t_5 = PyUnicode_AsEncodedString(((PyObject*)__pyx_v_s), __pyx_t_8, NULL); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1480, __pyx_L3_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF_SET(__pyx_v_s, __pyx_t_5); __pyx_t_5 = 0; } __pyx_L10:; /* "lupa/_lupa.pyx":1476 * runtime = py_obj.runtime * s = str(py_obj.obj) * if isinstance(s, unicode): # <<<<<<<<<<<<<< * if runtime._encoding is None: * s = (s).encode('UTF-8') */ goto __pyx_L9; } /* "lupa/_lupa.pyx":1482 * s = (s).encode(runtime._encoding) * else: * assert isinstance(s, bytes) # <<<<<<<<<<<<<< * lua.lua_pushlstring(L, s, len(s)) * return 1 # returning 1 value */ /*else*/ { #ifndef CYTHON_WITHOUT_ASSERTIONS if (unlikely(!Py_OptimizeFlag)) { __pyx_t_6 = PyBytes_Check(__pyx_v_s); if (unlikely(!(__pyx_t_6 != 0))) { PyErr_SetNone(PyExc_AssertionError); __PYX_ERR(0, 1482, __pyx_L3_error) } } #endif } __pyx_L9:; /* "lupa/_lupa.pyx":1483 * else: * assert isinstance(s, bytes) * lua.lua_pushlstring(L, s, len(s)) # <<<<<<<<<<<<<< * return 1 # returning 1 value * except: */ if (unlikely(__pyx_v_s == Py_None)) { PyErr_SetString(PyExc_TypeError, "expected bytes, NoneType found"); __PYX_ERR(0, 1483, __pyx_L3_error) } __pyx_t_9 = __Pyx_PyBytes_AsWritableString(__pyx_v_s); if (unlikely((!__pyx_t_9) && PyErr_Occurred())) __PYX_ERR(0, 1483, __pyx_L3_error) if (unlikely(__pyx_v_s == Py_None)) { PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()"); __PYX_ERR(0, 1483, __pyx_L3_error) } __pyx_t_10 = PyBytes_GET_SIZE(((PyObject*)__pyx_v_s)); if (unlikely(__pyx_t_10 == ((Py_ssize_t)-1))) __PYX_ERR(0, 1483, __pyx_L3_error) lua_pushlstring(__pyx_v_L, __pyx_t_9, __pyx_t_10); /* "lupa/_lupa.pyx":1484 * assert isinstance(s, bytes) * lua.lua_pushlstring(L, s, len(s)) * return 1 # returning 1 value # <<<<<<<<<<<<<< * except: * try: runtime.store_raised_exception(L, b'error during Python str() call') */ __pyx_r = 1; goto __pyx_L7_try_return; /* "lupa/_lupa.pyx":1473 * cdef int py_str_with_gil(lua_State* L, py_object* py_obj) with gil: * cdef LuaRuntime runtime * try: # <<<<<<<<<<<<<< * runtime = py_obj.runtime * s = str(py_obj.obj) */ } __pyx_L3_error:; __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; /* "lupa/_lupa.pyx":1485 * lua.lua_pushlstring(L, s, len(s)) * return 1 # returning 1 value * except: # <<<<<<<<<<<<<< * try: runtime.store_raised_exception(L, b'error during Python str() call') * finally: return -1 */ /*except:*/ { __Pyx_AddTraceback("lupa._lupa.py_str_with_gil", __pyx_clineno, __pyx_lineno, __pyx_filename); if (__Pyx_GetException(&__pyx_t_5, &__pyx_t_4, &__pyx_t_11) < 0) __PYX_ERR(0, 1485, __pyx_L5_except_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_GOTREF(__pyx_t_4); __Pyx_GOTREF(__pyx_t_11); /* "lupa/_lupa.pyx":1486 * return 1 # returning 1 value * except: * try: runtime.store_raised_exception(L, b'error during Python str() call') # <<<<<<<<<<<<<< * finally: return -1 * */ /*try:*/ { if (unlikely(!__pyx_v_runtime)) { __Pyx_RaiseUnboundLocalError("runtime"); __PYX_ERR(0, 1486, __pyx_L16_error) } __pyx_t_12 = __pyx_f_4lupa_5_lupa_10LuaRuntime_store_raised_exception(__pyx_v_runtime, __pyx_v_L, __pyx_kp_b_error_during_Python_str_call); if (unlikely(__pyx_t_12 == ((int)-1))) __PYX_ERR(0, 1486, __pyx_L16_error) } /* "lupa/_lupa.pyx":1487 * except: * try: runtime.store_raised_exception(L, b'error during Python str() call') * finally: return -1 # <<<<<<<<<<<<<< * * cdef int py_object_str(lua_State* L) nogil: */ /*finally:*/ { /*normal exit:*/{ __pyx_r = -1; __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; goto __pyx_L6_except_return; } __pyx_L16_error:; /*exception exit:*/{ __Pyx_PyThreadState_declare __Pyx_PyThreadState_assign __pyx_t_13 = 0; __pyx_t_14 = 0; __pyx_t_15 = 0; __pyx_t_16 = 0; __pyx_t_17 = 0; __pyx_t_18 = 0; if (PY_MAJOR_VERSION >= 3) __Pyx_ExceptionSwap(&__pyx_t_16, &__pyx_t_17, &__pyx_t_18); if ((PY_MAJOR_VERSION < 3) || unlikely(__Pyx_GetException(&__pyx_t_13, &__pyx_t_14, &__pyx_t_15) < 0)) __Pyx_ErrFetch(&__pyx_t_13, &__pyx_t_14, &__pyx_t_15); __Pyx_XGOTREF(__pyx_t_13); __Pyx_XGOTREF(__pyx_t_14); __Pyx_XGOTREF(__pyx_t_15); __Pyx_XGOTREF(__pyx_t_16); __Pyx_XGOTREF(__pyx_t_17); __Pyx_XGOTREF(__pyx_t_18); { __pyx_r = -1; __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; goto __pyx_L20_return; } __pyx_L20_return:; if (PY_MAJOR_VERSION >= 3) { __Pyx_XGIVEREF(__pyx_t_16); __Pyx_XGIVEREF(__pyx_t_17); __Pyx_XGIVEREF(__pyx_t_18); __Pyx_ExceptionReset(__pyx_t_16, __pyx_t_17, __pyx_t_18); } __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0; __Pyx_XDECREF(__pyx_t_14); __pyx_t_14 = 0; __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0; __pyx_t_16 = 0; __pyx_t_17 = 0; __pyx_t_18 = 0; goto __pyx_L6_except_return; } } } __pyx_L5_except_error:; /* "lupa/_lupa.pyx":1473 * cdef int py_str_with_gil(lua_State* L, py_object* py_obj) with gil: * cdef LuaRuntime runtime * try: # <<<<<<<<<<<<<< * runtime = py_obj.runtime * s = str(py_obj.obj) */ __Pyx_XGIVEREF(__pyx_t_1); __Pyx_XGIVEREF(__pyx_t_2); __Pyx_XGIVEREF(__pyx_t_3); __Pyx_ExceptionReset(__pyx_t_1, __pyx_t_2, __pyx_t_3); goto __pyx_L1_error; __pyx_L7_try_return:; __Pyx_XGIVEREF(__pyx_t_1); __Pyx_XGIVEREF(__pyx_t_2); __Pyx_XGIVEREF(__pyx_t_3); __Pyx_ExceptionReset(__pyx_t_1, __pyx_t_2, __pyx_t_3); goto __pyx_L0; __pyx_L6_except_return:; __Pyx_XGIVEREF(__pyx_t_1); __Pyx_XGIVEREF(__pyx_t_2); __Pyx_XGIVEREF(__pyx_t_3); __Pyx_ExceptionReset(__pyx_t_1, __pyx_t_2, __pyx_t_3); goto __pyx_L0; } /* "lupa/_lupa.pyx":1471 * # str() support for Python objects * * cdef int py_str_with_gil(lua_State* L, py_object* py_obj) with gil: # <<<<<<<<<<<<<< * cdef LuaRuntime runtime * try: */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_4); __Pyx_XDECREF(__pyx_t_5); __Pyx_XDECREF(__pyx_t_11); __Pyx_WriteUnraisable("lupa._lupa.py_str_with_gil", __pyx_clineno, __pyx_lineno, __pyx_filename, 1, 0); __pyx_r = 0; __pyx_L0:; __Pyx_XDECREF((PyObject *)__pyx_v_runtime); __Pyx_XDECREF(__pyx_v_s); __Pyx_RefNannyFinishContext(); #ifdef WITH_THREAD __Pyx_PyGILState_Release(__pyx_gilstate_save); #endif return __pyx_r; } /* "lupa/_lupa.pyx":1489 * finally: return -1 * * cdef int py_object_str(lua_State* L) nogil: # <<<<<<<<<<<<<< * cdef py_object* py_obj = unwrap_lua_object(L, 1) # may not return on error! * if not py_obj: */ static int __pyx_f_4lupa_5_lupa_py_object_str(lua_State *__pyx_v_L) { struct __pyx_t_4lupa_5_lupa_py_object *__pyx_v_py_obj; int __pyx_v_result; int __pyx_r; int __pyx_t_1; /* "lupa/_lupa.pyx":1490 * * cdef int py_object_str(lua_State* L) nogil: * cdef py_object* py_obj = unwrap_lua_object(L, 1) # may not return on error! # <<<<<<<<<<<<<< * if not py_obj: * return lua.luaL_argerror(L, 1, "not a python object") # never returns! */ __pyx_v_py_obj = __pyx_f_4lupa_5_lupa_unwrap_lua_object(__pyx_v_L, 1); /* "lupa/_lupa.pyx":1491 * cdef int py_object_str(lua_State* L) nogil: * cdef py_object* py_obj = unwrap_lua_object(L, 1) # may not return on error! * if not py_obj: # <<<<<<<<<<<<<< * return lua.luaL_argerror(L, 1, "not a python object") # never returns! * result = py_str_with_gil(L, py_obj) */ __pyx_t_1 = ((!(__pyx_v_py_obj != 0)) != 0); if (__pyx_t_1) { /* "lupa/_lupa.pyx":1492 * cdef py_object* py_obj = unwrap_lua_object(L, 1) # may not return on error! * if not py_obj: * return lua.luaL_argerror(L, 1, "not a python object") # never returns! # <<<<<<<<<<<<<< * result = py_str_with_gil(L, py_obj) * if result < 0: */ __pyx_r = luaL_argerror(__pyx_v_L, 1, ((char *)"not a python object")); goto __pyx_L0; /* "lupa/_lupa.pyx":1491 * cdef int py_object_str(lua_State* L) nogil: * cdef py_object* py_obj = unwrap_lua_object(L, 1) # may not return on error! * if not py_obj: # <<<<<<<<<<<<<< * return lua.luaL_argerror(L, 1, "not a python object") # never returns! * result = py_str_with_gil(L, py_obj) */ } /* "lupa/_lupa.pyx":1493 * if not py_obj: * return lua.luaL_argerror(L, 1, "not a python object") # never returns! * result = py_str_with_gil(L, py_obj) # <<<<<<<<<<<<<< * if result < 0: * return lua.lua_error(L) # never returns! */ __pyx_v_result = __pyx_f_4lupa_5_lupa_py_str_with_gil(__pyx_v_L, __pyx_v_py_obj); /* "lupa/_lupa.pyx":1494 * return lua.luaL_argerror(L, 1, "not a python object") # never returns! * result = py_str_with_gil(L, py_obj) * if result < 0: # <<<<<<<<<<<<<< * return lua.lua_error(L) # never returns! * return result */ __pyx_t_1 = ((__pyx_v_result < 0) != 0); if (__pyx_t_1) { /* "lupa/_lupa.pyx":1495 * result = py_str_with_gil(L, py_obj) * if result < 0: * return lua.lua_error(L) # never returns! # <<<<<<<<<<<<<< * return result * */ __pyx_r = lua_error(__pyx_v_L); goto __pyx_L0; /* "lupa/_lupa.pyx":1494 * return lua.luaL_argerror(L, 1, "not a python object") # never returns! * result = py_str_with_gil(L, py_obj) * if result < 0: # <<<<<<<<<<<<<< * return lua.lua_error(L) # never returns! * return result */ } /* "lupa/_lupa.pyx":1496 * if result < 0: * return lua.lua_error(L) # never returns! * return result # <<<<<<<<<<<<<< * * # item access for Python objects */ __pyx_r = __pyx_v_result; goto __pyx_L0; /* "lupa/_lupa.pyx":1489 * finally: return -1 * * cdef int py_object_str(lua_State* L) nogil: # <<<<<<<<<<<<<< * cdef py_object* py_obj = unwrap_lua_object(L, 1) # may not return on error! * if not py_obj: */ /* function exit code */ __pyx_L0:; return __pyx_r; } /* "lupa/_lupa.pyx":1516 * # using the getitem method of access. * * cdef int getitem_for_lua(LuaRuntime runtime, lua_State* L, py_object* py_obj, int key_n) except -1: # <<<<<<<<<<<<<< * return py_to_lua(runtime, L, * (py_obj.obj)[ py_from_lua(runtime, L, key_n) ]) */ static int __pyx_f_4lupa_5_lupa_getitem_for_lua(struct __pyx_obj_4lupa_5_lupa_LuaRuntime *__pyx_v_runtime, lua_State *__pyx_v_L, struct __pyx_t_4lupa_5_lupa_py_object *__pyx_v_py_obj, int __pyx_v_key_n) { int __pyx_r; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; PyObject *__pyx_t_2 = NULL; int __pyx_t_3; __Pyx_RefNannySetupContext("getitem_for_lua", 0); /* "lupa/_lupa.pyx":1518 * 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, * (py_obj.obj)[ py_from_lua(runtime, L, key_n) ]) # <<<<<<<<<<<<<< * * cdef int setitem_for_lua(LuaRuntime runtime, lua_State* L, py_object* py_obj, int key_n, int value_n) except -1: */ __pyx_t_1 = __pyx_f_4lupa_5_lupa_py_from_lua(__pyx_v_runtime, __pyx_v_L, __pyx_v_key_n); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1518, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_2 = PyObject_GetItem(((PyObject *)__pyx_v_py_obj->obj), __pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1518, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; /* "lupa/_lupa.pyx":1517 * * 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, # <<<<<<<<<<<<<< * (py_obj.obj)[ py_from_lua(runtime, L, key_n) ]) * */ __pyx_t_3 = __pyx_f_4lupa_5_lupa_py_to_lua(__pyx_v_runtime, __pyx_v_L, __pyx_t_2, NULL); if (unlikely(__pyx_t_3 == ((int)-1))) __PYX_ERR(0, 1517, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_r = __pyx_t_3; goto __pyx_L0; /* "lupa/_lupa.pyx":1516 * # using the getitem method of access. * * cdef int getitem_for_lua(LuaRuntime runtime, lua_State* L, py_object* py_obj, int key_n) except -1: # <<<<<<<<<<<<<< * return py_to_lua(runtime, L, * (py_obj.obj)[ py_from_lua(runtime, L, key_n) ]) */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_2); __Pyx_AddTraceback("lupa._lupa.getitem_for_lua", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = -1; __pyx_L0:; __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "lupa/_lupa.pyx":1520 * (py_obj.obj)[ py_from_lua(runtime, L, key_n) ]) * * cdef int setitem_for_lua(LuaRuntime runtime, lua_State* L, py_object* py_obj, int key_n, int value_n) except -1: # <<<<<<<<<<<<<< * (py_obj.obj)[ py_from_lua(runtime, L, key_n) ] = py_from_lua(runtime, L, value_n) * return 0 */ static int __pyx_f_4lupa_5_lupa_setitem_for_lua(struct __pyx_obj_4lupa_5_lupa_LuaRuntime *__pyx_v_runtime, lua_State *__pyx_v_L, struct __pyx_t_4lupa_5_lupa_py_object *__pyx_v_py_obj, int __pyx_v_key_n, int __pyx_v_value_n) { int __pyx_r; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; PyObject *__pyx_t_2 = NULL; __Pyx_RefNannySetupContext("setitem_for_lua", 0); /* "lupa/_lupa.pyx":1521 * * cdef int setitem_for_lua(LuaRuntime runtime, lua_State* L, py_object* py_obj, int key_n, int value_n) except -1: * (py_obj.obj)[ py_from_lua(runtime, L, key_n) ] = py_from_lua(runtime, L, value_n) # <<<<<<<<<<<<<< * return 0 * */ __pyx_t_1 = __pyx_f_4lupa_5_lupa_py_from_lua(__pyx_v_runtime, __pyx_v_L, __pyx_v_value_n); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1521, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_2 = __pyx_f_4lupa_5_lupa_py_from_lua(__pyx_v_runtime, __pyx_v_L, __pyx_v_key_n); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1521, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); if (unlikely(PyObject_SetItem(((PyObject *)__pyx_v_py_obj->obj), __pyx_t_2, __pyx_t_1) < 0)) __PYX_ERR(0, 1521, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; /* "lupa/_lupa.pyx":1522 * cdef int setitem_for_lua(LuaRuntime runtime, lua_State* L, py_object* py_obj, int key_n, int value_n) except -1: * (py_obj.obj)[ py_from_lua(runtime, L, key_n) ] = py_from_lua(runtime, L, value_n) * return 0 # <<<<<<<<<<<<<< * * cdef int getattr_for_lua(LuaRuntime runtime, lua_State* L, py_object* py_obj, int key_n) except -1: */ __pyx_r = 0; goto __pyx_L0; /* "lupa/_lupa.pyx":1520 * (py_obj.obj)[ py_from_lua(runtime, L, key_n) ]) * * cdef int setitem_for_lua(LuaRuntime runtime, lua_State* L, py_object* py_obj, int key_n, int value_n) except -1: # <<<<<<<<<<<<<< * (py_obj.obj)[ py_from_lua(runtime, L, key_n) ] = py_from_lua(runtime, L, value_n) * return 0 */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_2); __Pyx_AddTraceback("lupa._lupa.setitem_for_lua", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = -1; __pyx_L0:; __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "lupa/_lupa.pyx":1524 * return 0 * * cdef int getattr_for_lua(LuaRuntime runtime, lua_State* L, py_object* py_obj, int key_n) except -1: # <<<<<<<<<<<<<< * obj = py_obj.obj * attr_name = py_from_lua(runtime, L, key_n) */ static int __pyx_f_4lupa_5_lupa_getattr_for_lua(struct __pyx_obj_4lupa_5_lupa_LuaRuntime *__pyx_v_runtime, lua_State *__pyx_v_L, struct __pyx_t_4lupa_5_lupa_py_object *__pyx_v_py_obj, int __pyx_v_key_n) { PyObject *__pyx_v_obj = NULL; PyObject *__pyx_v_attr_name = NULL; PyObject *__pyx_v_value = NULL; int __pyx_r; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; int __pyx_t_2; int __pyx_t_3; PyObject *__pyx_t_4 = NULL; PyObject *__pyx_t_5 = NULL; int __pyx_t_6; PyObject *__pyx_t_7 = NULL; char const *__pyx_t_8; __Pyx_RefNannySetupContext("getattr_for_lua", 0); /* "lupa/_lupa.pyx":1525 * * cdef int getattr_for_lua(LuaRuntime runtime, lua_State* L, py_object* py_obj, int key_n) except -1: * obj = py_obj.obj # <<<<<<<<<<<<<< * attr_name = py_from_lua(runtime, L, key_n) * if runtime._attribute_getter is not None: */ __pyx_t_1 = ((PyObject *)__pyx_v_py_obj->obj); __Pyx_INCREF(__pyx_t_1); __pyx_v_obj = __pyx_t_1; __pyx_t_1 = 0; /* "lupa/_lupa.pyx":1526 * cdef int getattr_for_lua(LuaRuntime runtime, lua_State* L, py_object* py_obj, int key_n) except -1: * obj = py_obj.obj * attr_name = py_from_lua(runtime, L, key_n) # <<<<<<<<<<<<<< * if runtime._attribute_getter is not None: * value = runtime._attribute_getter(obj, attr_name) */ __pyx_t_1 = __pyx_f_4lupa_5_lupa_py_from_lua(__pyx_v_runtime, __pyx_v_L, __pyx_v_key_n); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1526, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_v_attr_name = __pyx_t_1; __pyx_t_1 = 0; /* "lupa/_lupa.pyx":1527 * obj = py_obj.obj * attr_name = py_from_lua(runtime, L, key_n) * if runtime._attribute_getter is not None: # <<<<<<<<<<<<<< * value = runtime._attribute_getter(obj, attr_name) * return py_to_lua(runtime, L, value) */ __pyx_t_2 = (__pyx_v_runtime->_attribute_getter != Py_None); __pyx_t_3 = (__pyx_t_2 != 0); if (__pyx_t_3) { /* "lupa/_lupa.pyx":1528 * attr_name = py_from_lua(runtime, L, key_n) * if runtime._attribute_getter is not None: * value = runtime._attribute_getter(obj, attr_name) # <<<<<<<<<<<<<< * return py_to_lua(runtime, L, value) * if runtime._attribute_filter is not None: */ __Pyx_INCREF(__pyx_v_runtime->_attribute_getter); __pyx_t_4 = __pyx_v_runtime->_attribute_getter; __pyx_t_5 = NULL; __pyx_t_6 = 0; if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_4))) { __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_4); if (likely(__pyx_t_5)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4); __Pyx_INCREF(__pyx_t_5); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_4, function); __pyx_t_6 = 1; } } #if CYTHON_FAST_PYCALL if (PyFunction_Check(__pyx_t_4)) { PyObject *__pyx_temp[3] = {__pyx_t_5, __pyx_v_obj, __pyx_v_attr_name}; __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_6, 2+__pyx_t_6); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1528, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_GOTREF(__pyx_t_1); } else #endif #if CYTHON_FAST_PYCCALL if (__Pyx_PyFastCFunction_Check(__pyx_t_4)) { PyObject *__pyx_temp[3] = {__pyx_t_5, __pyx_v_obj, __pyx_v_attr_name}; __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_6, 2+__pyx_t_6); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1528, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_GOTREF(__pyx_t_1); } else #endif { __pyx_t_7 = PyTuple_New(2+__pyx_t_6); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1528, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); if (__pyx_t_5) { __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_5); __pyx_t_5 = NULL; } __Pyx_INCREF(__pyx_v_obj); __Pyx_GIVEREF(__pyx_v_obj); PyTuple_SET_ITEM(__pyx_t_7, 0+__pyx_t_6, __pyx_v_obj); __Pyx_INCREF(__pyx_v_attr_name); __Pyx_GIVEREF(__pyx_v_attr_name); PyTuple_SET_ITEM(__pyx_t_7, 1+__pyx_t_6, __pyx_v_attr_name); __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_7, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1528, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; } __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_v_value = __pyx_t_1; __pyx_t_1 = 0; /* "lupa/_lupa.pyx":1529 * if runtime._attribute_getter is not None: * value = runtime._attribute_getter(obj, attr_name) * return py_to_lua(runtime, L, value) # <<<<<<<<<<<<<< * if runtime._attribute_filter is not None: * attr_name = runtime._attribute_filter(obj, attr_name, False) */ __pyx_t_6 = __pyx_f_4lupa_5_lupa_py_to_lua(__pyx_v_runtime, __pyx_v_L, __pyx_v_value, NULL); if (unlikely(__pyx_t_6 == ((int)-1))) __PYX_ERR(0, 1529, __pyx_L1_error) __pyx_r = __pyx_t_6; goto __pyx_L0; /* "lupa/_lupa.pyx":1527 * obj = py_obj.obj * attr_name = py_from_lua(runtime, L, key_n) * if runtime._attribute_getter is not None: # <<<<<<<<<<<<<< * value = runtime._attribute_getter(obj, attr_name) * return py_to_lua(runtime, L, value) */ } /* "lupa/_lupa.pyx":1530 * value = runtime._attribute_getter(obj, attr_name) * return py_to_lua(runtime, L, value) * if runtime._attribute_filter is not None: # <<<<<<<<<<<<<< * attr_name = runtime._attribute_filter(obj, attr_name, False) * if isinstance(attr_name, bytes): */ __pyx_t_3 = (__pyx_v_runtime->_attribute_filter != Py_None); __pyx_t_2 = (__pyx_t_3 != 0); if (__pyx_t_2) { /* "lupa/_lupa.pyx":1531 * return py_to_lua(runtime, L, value) * if runtime._attribute_filter is not None: * attr_name = runtime._attribute_filter(obj, attr_name, False) # <<<<<<<<<<<<<< * if isinstance(attr_name, bytes): * attr_name = (attr_name).decode(runtime._source_encoding) */ __Pyx_INCREF(__pyx_v_runtime->_attribute_filter); __pyx_t_4 = __pyx_v_runtime->_attribute_filter; __pyx_t_7 = NULL; __pyx_t_6 = 0; if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_4))) { __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_4); if (likely(__pyx_t_7)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4); __Pyx_INCREF(__pyx_t_7); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_4, function); __pyx_t_6 = 1; } } #if CYTHON_FAST_PYCALL if (PyFunction_Check(__pyx_t_4)) { PyObject *__pyx_temp[4] = {__pyx_t_7, __pyx_v_obj, __pyx_v_attr_name, Py_False}; __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_6, 3+__pyx_t_6); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1531, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0; __Pyx_GOTREF(__pyx_t_1); } else #endif #if CYTHON_FAST_PYCCALL if (__Pyx_PyFastCFunction_Check(__pyx_t_4)) { PyObject *__pyx_temp[4] = {__pyx_t_7, __pyx_v_obj, __pyx_v_attr_name, Py_False}; __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_6, 3+__pyx_t_6); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1531, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0; __Pyx_GOTREF(__pyx_t_1); } else #endif { __pyx_t_5 = PyTuple_New(3+__pyx_t_6); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1531, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); if (__pyx_t_7) { __Pyx_GIVEREF(__pyx_t_7); PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_7); __pyx_t_7 = NULL; } __Pyx_INCREF(__pyx_v_obj); __Pyx_GIVEREF(__pyx_v_obj); PyTuple_SET_ITEM(__pyx_t_5, 0+__pyx_t_6, __pyx_v_obj); __Pyx_INCREF(__pyx_v_attr_name); __Pyx_GIVEREF(__pyx_v_attr_name); PyTuple_SET_ITEM(__pyx_t_5, 1+__pyx_t_6, __pyx_v_attr_name); __Pyx_INCREF(Py_False); __Pyx_GIVEREF(Py_False); PyTuple_SET_ITEM(__pyx_t_5, 2+__pyx_t_6, Py_False); __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_5, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1531, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; } __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_DECREF_SET(__pyx_v_attr_name, __pyx_t_1); __pyx_t_1 = 0; /* "lupa/_lupa.pyx":1530 * value = runtime._attribute_getter(obj, attr_name) * return py_to_lua(runtime, L, value) * if runtime._attribute_filter is not None: # <<<<<<<<<<<<<< * attr_name = runtime._attribute_filter(obj, attr_name, False) * if isinstance(attr_name, bytes): */ } /* "lupa/_lupa.pyx":1532 * if runtime._attribute_filter is not None: * attr_name = runtime._attribute_filter(obj, attr_name, False) * if isinstance(attr_name, bytes): # <<<<<<<<<<<<<< * attr_name = (attr_name).decode(runtime._source_encoding) * return py_to_lua(runtime, L, getattr(obj, attr_name)) */ __pyx_t_2 = PyBytes_Check(__pyx_v_attr_name); __pyx_t_3 = (__pyx_t_2 != 0); if (__pyx_t_3) { /* "lupa/_lupa.pyx":1533 * attr_name = runtime._attribute_filter(obj, attr_name, False) * if isinstance(attr_name, bytes): * attr_name = (attr_name).decode(runtime._source_encoding) # <<<<<<<<<<<<<< * return py_to_lua(runtime, L, getattr(obj, attr_name)) * */ if (unlikely(__pyx_v_attr_name == Py_None)) { PyErr_Format(PyExc_AttributeError, "'NoneType' object has no attribute '%.30s'", "decode"); __PYX_ERR(0, 1533, __pyx_L1_error) } if (unlikely(__pyx_v_runtime->_source_encoding == Py_None)) { PyErr_SetString(PyExc_TypeError, "expected bytes, NoneType found"); __PYX_ERR(0, 1533, __pyx_L1_error) } __pyx_t_8 = __Pyx_PyBytes_AsString(__pyx_v_runtime->_source_encoding); if (unlikely((!__pyx_t_8) && PyErr_Occurred())) __PYX_ERR(0, 1533, __pyx_L1_error) __pyx_t_1 = __Pyx_decode_bytes(((PyObject*)__pyx_v_attr_name), 0, PY_SSIZE_T_MAX, __pyx_t_8, NULL, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1533, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF_SET(__pyx_v_attr_name, __pyx_t_1); __pyx_t_1 = 0; /* "lupa/_lupa.pyx":1532 * if runtime._attribute_filter is not None: * attr_name = runtime._attribute_filter(obj, attr_name, False) * if isinstance(attr_name, bytes): # <<<<<<<<<<<<<< * attr_name = (attr_name).decode(runtime._source_encoding) * return py_to_lua(runtime, L, getattr(obj, attr_name)) */ } /* "lupa/_lupa.pyx":1534 * if isinstance(attr_name, bytes): * attr_name = (attr_name).decode(runtime._source_encoding) * return py_to_lua(runtime, L, getattr(obj, attr_name)) # <<<<<<<<<<<<<< * * cdef int setattr_for_lua(LuaRuntime runtime, lua_State* L, py_object* py_obj, int key_n, int value_n) except -1: */ __pyx_t_1 = __Pyx_GetAttr(__pyx_v_obj, __pyx_v_attr_name); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1534, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_6 = __pyx_f_4lupa_5_lupa_py_to_lua(__pyx_v_runtime, __pyx_v_L, __pyx_t_1, NULL); if (unlikely(__pyx_t_6 == ((int)-1))) __PYX_ERR(0, 1534, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_r = __pyx_t_6; goto __pyx_L0; /* "lupa/_lupa.pyx":1524 * return 0 * * cdef int getattr_for_lua(LuaRuntime runtime, lua_State* L, py_object* py_obj, int key_n) except -1: # <<<<<<<<<<<<<< * obj = py_obj.obj * attr_name = py_from_lua(runtime, L, key_n) */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_4); __Pyx_XDECREF(__pyx_t_5); __Pyx_XDECREF(__pyx_t_7); __Pyx_AddTraceback("lupa._lupa.getattr_for_lua", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = -1; __pyx_L0:; __Pyx_XDECREF(__pyx_v_obj); __Pyx_XDECREF(__pyx_v_attr_name); __Pyx_XDECREF(__pyx_v_value); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "lupa/_lupa.pyx":1536 * return py_to_lua(runtime, L, getattr(obj, attr_name)) * * cdef int setattr_for_lua(LuaRuntime runtime, lua_State* L, py_object* py_obj, int key_n, int value_n) except -1: # <<<<<<<<<<<<<< * obj = py_obj.obj * attr_name = py_from_lua(runtime, L, key_n) */ static int __pyx_f_4lupa_5_lupa_setattr_for_lua(struct __pyx_obj_4lupa_5_lupa_LuaRuntime *__pyx_v_runtime, lua_State *__pyx_v_L, struct __pyx_t_4lupa_5_lupa_py_object *__pyx_v_py_obj, int __pyx_v_key_n, int __pyx_v_value_n) { PyObject *__pyx_v_obj = NULL; PyObject *__pyx_v_attr_name = NULL; PyObject *__pyx_v_attr_value = NULL; int __pyx_r; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; int __pyx_t_2; int __pyx_t_3; PyObject *__pyx_t_4 = NULL; PyObject *__pyx_t_5 = NULL; int __pyx_t_6; PyObject *__pyx_t_7 = NULL; char const *__pyx_t_8; int __pyx_t_9; __Pyx_RefNannySetupContext("setattr_for_lua", 0); /* "lupa/_lupa.pyx":1537 * * cdef int setattr_for_lua(LuaRuntime runtime, lua_State* L, py_object* py_obj, int key_n, int value_n) except -1: * obj = py_obj.obj # <<<<<<<<<<<<<< * attr_name = py_from_lua(runtime, L, key_n) * attr_value = py_from_lua(runtime, L, value_n) */ __pyx_t_1 = ((PyObject *)__pyx_v_py_obj->obj); __Pyx_INCREF(__pyx_t_1); __pyx_v_obj = __pyx_t_1; __pyx_t_1 = 0; /* "lupa/_lupa.pyx":1538 * cdef int setattr_for_lua(LuaRuntime runtime, lua_State* L, py_object* py_obj, int key_n, int value_n) except -1: * obj = py_obj.obj * attr_name = py_from_lua(runtime, L, key_n) # <<<<<<<<<<<<<< * attr_value = py_from_lua(runtime, L, value_n) * if runtime._attribute_setter is not None: */ __pyx_t_1 = __pyx_f_4lupa_5_lupa_py_from_lua(__pyx_v_runtime, __pyx_v_L, __pyx_v_key_n); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1538, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_v_attr_name = __pyx_t_1; __pyx_t_1 = 0; /* "lupa/_lupa.pyx":1539 * obj = py_obj.obj * attr_name = py_from_lua(runtime, L, key_n) * attr_value = py_from_lua(runtime, L, value_n) # <<<<<<<<<<<<<< * if runtime._attribute_setter is not None: * runtime._attribute_setter(obj, attr_name, attr_value) */ __pyx_t_1 = __pyx_f_4lupa_5_lupa_py_from_lua(__pyx_v_runtime, __pyx_v_L, __pyx_v_value_n); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1539, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_v_attr_value = __pyx_t_1; __pyx_t_1 = 0; /* "lupa/_lupa.pyx":1540 * attr_name = py_from_lua(runtime, L, key_n) * attr_value = py_from_lua(runtime, L, value_n) * if runtime._attribute_setter is not None: # <<<<<<<<<<<<<< * runtime._attribute_setter(obj, attr_name, attr_value) * else: */ __pyx_t_2 = (__pyx_v_runtime->_attribute_setter != Py_None); __pyx_t_3 = (__pyx_t_2 != 0); if (__pyx_t_3) { /* "lupa/_lupa.pyx":1541 * attr_value = py_from_lua(runtime, L, value_n) * if runtime._attribute_setter is not None: * runtime._attribute_setter(obj, attr_name, attr_value) # <<<<<<<<<<<<<< * else: * if runtime._attribute_filter is not None: */ __Pyx_INCREF(__pyx_v_runtime->_attribute_setter); __pyx_t_4 = __pyx_v_runtime->_attribute_setter; __pyx_t_5 = NULL; __pyx_t_6 = 0; if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_4))) { __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_4); if (likely(__pyx_t_5)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4); __Pyx_INCREF(__pyx_t_5); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_4, function); __pyx_t_6 = 1; } } #if CYTHON_FAST_PYCALL if (PyFunction_Check(__pyx_t_4)) { PyObject *__pyx_temp[4] = {__pyx_t_5, __pyx_v_obj, __pyx_v_attr_name, __pyx_v_attr_value}; __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_6, 3+__pyx_t_6); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1541, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_GOTREF(__pyx_t_1); } else #endif #if CYTHON_FAST_PYCCALL if (__Pyx_PyFastCFunction_Check(__pyx_t_4)) { PyObject *__pyx_temp[4] = {__pyx_t_5, __pyx_v_obj, __pyx_v_attr_name, __pyx_v_attr_value}; __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_6, 3+__pyx_t_6); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1541, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_GOTREF(__pyx_t_1); } else #endif { __pyx_t_7 = PyTuple_New(3+__pyx_t_6); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1541, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); if (__pyx_t_5) { __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_5); __pyx_t_5 = NULL; } __Pyx_INCREF(__pyx_v_obj); __Pyx_GIVEREF(__pyx_v_obj); PyTuple_SET_ITEM(__pyx_t_7, 0+__pyx_t_6, __pyx_v_obj); __Pyx_INCREF(__pyx_v_attr_name); __Pyx_GIVEREF(__pyx_v_attr_name); PyTuple_SET_ITEM(__pyx_t_7, 1+__pyx_t_6, __pyx_v_attr_name); __Pyx_INCREF(__pyx_v_attr_value); __Pyx_GIVEREF(__pyx_v_attr_value); PyTuple_SET_ITEM(__pyx_t_7, 2+__pyx_t_6, __pyx_v_attr_value); __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_7, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1541, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; } __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; /* "lupa/_lupa.pyx":1540 * attr_name = py_from_lua(runtime, L, key_n) * attr_value = py_from_lua(runtime, L, value_n) * if runtime._attribute_setter is not None: # <<<<<<<<<<<<<< * runtime._attribute_setter(obj, attr_name, attr_value) * else: */ goto __pyx_L3; } /* "lupa/_lupa.pyx":1543 * runtime._attribute_setter(obj, attr_name, attr_value) * else: * if runtime._attribute_filter is not None: # <<<<<<<<<<<<<< * attr_name = runtime._attribute_filter(obj, attr_name, True) * if isinstance(attr_name, bytes): */ /*else*/ { __pyx_t_3 = (__pyx_v_runtime->_attribute_filter != Py_None); __pyx_t_2 = (__pyx_t_3 != 0); if (__pyx_t_2) { /* "lupa/_lupa.pyx":1544 * else: * if runtime._attribute_filter is not None: * attr_name = runtime._attribute_filter(obj, attr_name, True) # <<<<<<<<<<<<<< * if isinstance(attr_name, bytes): * attr_name = (attr_name).decode(runtime._source_encoding) */ __Pyx_INCREF(__pyx_v_runtime->_attribute_filter); __pyx_t_4 = __pyx_v_runtime->_attribute_filter; __pyx_t_7 = NULL; __pyx_t_6 = 0; if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_4))) { __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_4); if (likely(__pyx_t_7)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4); __Pyx_INCREF(__pyx_t_7); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_4, function); __pyx_t_6 = 1; } } #if CYTHON_FAST_PYCALL if (PyFunction_Check(__pyx_t_4)) { PyObject *__pyx_temp[4] = {__pyx_t_7, __pyx_v_obj, __pyx_v_attr_name, Py_True}; __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_6, 3+__pyx_t_6); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1544, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0; __Pyx_GOTREF(__pyx_t_1); } else #endif #if CYTHON_FAST_PYCCALL if (__Pyx_PyFastCFunction_Check(__pyx_t_4)) { PyObject *__pyx_temp[4] = {__pyx_t_7, __pyx_v_obj, __pyx_v_attr_name, Py_True}; __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_6, 3+__pyx_t_6); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1544, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0; __Pyx_GOTREF(__pyx_t_1); } else #endif { __pyx_t_5 = PyTuple_New(3+__pyx_t_6); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1544, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); if (__pyx_t_7) { __Pyx_GIVEREF(__pyx_t_7); PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_7); __pyx_t_7 = NULL; } __Pyx_INCREF(__pyx_v_obj); __Pyx_GIVEREF(__pyx_v_obj); PyTuple_SET_ITEM(__pyx_t_5, 0+__pyx_t_6, __pyx_v_obj); __Pyx_INCREF(__pyx_v_attr_name); __Pyx_GIVEREF(__pyx_v_attr_name); PyTuple_SET_ITEM(__pyx_t_5, 1+__pyx_t_6, __pyx_v_attr_name); __Pyx_INCREF(Py_True); __Pyx_GIVEREF(Py_True); PyTuple_SET_ITEM(__pyx_t_5, 2+__pyx_t_6, Py_True); __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_5, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1544, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; } __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_DECREF_SET(__pyx_v_attr_name, __pyx_t_1); __pyx_t_1 = 0; /* "lupa/_lupa.pyx":1543 * runtime._attribute_setter(obj, attr_name, attr_value) * else: * if runtime._attribute_filter is not None: # <<<<<<<<<<<<<< * attr_name = runtime._attribute_filter(obj, attr_name, True) * if isinstance(attr_name, bytes): */ } /* "lupa/_lupa.pyx":1545 * if runtime._attribute_filter is not None: * attr_name = runtime._attribute_filter(obj, attr_name, True) * if isinstance(attr_name, bytes): # <<<<<<<<<<<<<< * attr_name = (attr_name).decode(runtime._source_encoding) * setattr(obj, attr_name, attr_value) */ __pyx_t_2 = PyBytes_Check(__pyx_v_attr_name); __pyx_t_3 = (__pyx_t_2 != 0); if (__pyx_t_3) { /* "lupa/_lupa.pyx":1546 * attr_name = runtime._attribute_filter(obj, attr_name, True) * if isinstance(attr_name, bytes): * attr_name = (attr_name).decode(runtime._source_encoding) # <<<<<<<<<<<<<< * setattr(obj, attr_name, attr_value) * return 0 */ if (unlikely(__pyx_v_attr_name == Py_None)) { PyErr_Format(PyExc_AttributeError, "'NoneType' object has no attribute '%.30s'", "decode"); __PYX_ERR(0, 1546, __pyx_L1_error) } if (unlikely(__pyx_v_runtime->_source_encoding == Py_None)) { PyErr_SetString(PyExc_TypeError, "expected bytes, NoneType found"); __PYX_ERR(0, 1546, __pyx_L1_error) } __pyx_t_8 = __Pyx_PyBytes_AsString(__pyx_v_runtime->_source_encoding); if (unlikely((!__pyx_t_8) && PyErr_Occurred())) __PYX_ERR(0, 1546, __pyx_L1_error) __pyx_t_1 = __Pyx_decode_bytes(((PyObject*)__pyx_v_attr_name), 0, PY_SSIZE_T_MAX, __pyx_t_8, NULL, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1546, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF_SET(__pyx_v_attr_name, __pyx_t_1); __pyx_t_1 = 0; /* "lupa/_lupa.pyx":1545 * if runtime._attribute_filter is not None: * attr_name = runtime._attribute_filter(obj, attr_name, True) * if isinstance(attr_name, bytes): # <<<<<<<<<<<<<< * attr_name = (attr_name).decode(runtime._source_encoding) * setattr(obj, attr_name, attr_value) */ } /* "lupa/_lupa.pyx":1547 * if isinstance(attr_name, bytes): * attr_name = (attr_name).decode(runtime._source_encoding) * setattr(obj, attr_name, attr_value) # <<<<<<<<<<<<<< * return 0 * */ __pyx_t_9 = PyObject_SetAttr(__pyx_v_obj, __pyx_v_attr_name, __pyx_v_attr_value); if (unlikely(__pyx_t_9 == ((int)-1))) __PYX_ERR(0, 1547, __pyx_L1_error) } __pyx_L3:; /* "lupa/_lupa.pyx":1548 * attr_name = (attr_name).decode(runtime._source_encoding) * setattr(obj, attr_name, attr_value) * return 0 # <<<<<<<<<<<<<< * * */ __pyx_r = 0; goto __pyx_L0; /* "lupa/_lupa.pyx":1536 * return py_to_lua(runtime, L, getattr(obj, attr_name)) * * cdef int setattr_for_lua(LuaRuntime runtime, lua_State* L, py_object* py_obj, int key_n, int value_n) except -1: # <<<<<<<<<<<<<< * obj = py_obj.obj * attr_name = py_from_lua(runtime, L, key_n) */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_4); __Pyx_XDECREF(__pyx_t_5); __Pyx_XDECREF(__pyx_t_7); __Pyx_AddTraceback("lupa._lupa.setattr_for_lua", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = -1; __pyx_L0:; __Pyx_XDECREF(__pyx_v_obj); __Pyx_XDECREF(__pyx_v_attr_name); __Pyx_XDECREF(__pyx_v_attr_value); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "lupa/_lupa.pyx":1551 * * * cdef int py_object_getindex_with_gil(lua_State* L, py_object* py_obj) with gil: # <<<<<<<<<<<<<< * cdef LuaRuntime runtime * try: */ static int __pyx_f_4lupa_5_lupa_py_object_getindex_with_gil(lua_State *__pyx_v_L, struct __pyx_t_4lupa_5_lupa_py_object *__pyx_v_py_obj) { struct __pyx_obj_4lupa_5_lupa_LuaRuntime *__pyx_v_runtime = 0; int __pyx_r; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; PyObject *__pyx_t_2 = NULL; PyObject *__pyx_t_3 = NULL; PyObject *__pyx_t_4 = NULL; int __pyx_t_5; int __pyx_t_6; int __pyx_t_7; int __pyx_t_8; PyObject *__pyx_t_9 = NULL; PyObject *__pyx_t_10 = NULL; #ifdef WITH_THREAD PyGILState_STATE __pyx_gilstate_save = __Pyx_PyGILState_Ensure(); #endif __Pyx_RefNannySetupContext("py_object_getindex_with_gil", 0); /* "lupa/_lupa.pyx":1553 * cdef int py_object_getindex_with_gil(lua_State* L, py_object* py_obj) with gil: * cdef LuaRuntime runtime * try: # <<<<<<<<<<<<<< * runtime = py_obj.runtime * if (py_obj.type_flags & OBJ_AS_INDEX) and not runtime._attribute_getter: */ { __Pyx_PyThreadState_declare __Pyx_PyThreadState_assign __Pyx_ExceptionSave(&__pyx_t_1, &__pyx_t_2, &__pyx_t_3); __Pyx_XGOTREF(__pyx_t_1); __Pyx_XGOTREF(__pyx_t_2); __Pyx_XGOTREF(__pyx_t_3); /*try:*/ { /* "lupa/_lupa.pyx":1554 * cdef LuaRuntime runtime * try: * runtime = py_obj.runtime # <<<<<<<<<<<<<< * if (py_obj.type_flags & OBJ_AS_INDEX) and not runtime._attribute_getter: * return getitem_for_lua(runtime, L, py_obj, 2) */ __pyx_t_4 = ((PyObject *)__pyx_v_py_obj->runtime); __Pyx_INCREF(__pyx_t_4); __pyx_v_runtime = ((struct __pyx_obj_4lupa_5_lupa_LuaRuntime *)__pyx_t_4); __pyx_t_4 = 0; /* "lupa/_lupa.pyx":1555 * try: * runtime = py_obj.runtime * if (py_obj.type_flags & OBJ_AS_INDEX) and not runtime._attribute_getter: # <<<<<<<<<<<<<< * return getitem_for_lua(runtime, L, py_obj, 2) * else: */ __pyx_t_6 = ((__pyx_v_py_obj->type_flags & __pyx_e_4lupa_5_lupa_OBJ_AS_INDEX) != 0); if (__pyx_t_6) { } else { __pyx_t_5 = __pyx_t_6; goto __pyx_L10_bool_binop_done; } __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_v_runtime->_attribute_getter); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(0, 1555, __pyx_L3_error) __pyx_t_7 = ((!__pyx_t_6) != 0); __pyx_t_5 = __pyx_t_7; __pyx_L10_bool_binop_done:; if (__pyx_t_5) { /* "lupa/_lupa.pyx":1556 * runtime = py_obj.runtime * if (py_obj.type_flags & OBJ_AS_INDEX) and not runtime._attribute_getter: * return getitem_for_lua(runtime, L, py_obj, 2) # <<<<<<<<<<<<<< * else: * return getattr_for_lua(runtime, L, py_obj, 2) */ __pyx_t_8 = __pyx_f_4lupa_5_lupa_getitem_for_lua(__pyx_v_runtime, __pyx_v_L, __pyx_v_py_obj, 2); if (unlikely(__pyx_t_8 == ((int)-1))) __PYX_ERR(0, 1556, __pyx_L3_error) __pyx_r = __pyx_t_8; goto __pyx_L7_try_return; /* "lupa/_lupa.pyx":1555 * try: * runtime = py_obj.runtime * if (py_obj.type_flags & OBJ_AS_INDEX) and not runtime._attribute_getter: # <<<<<<<<<<<<<< * return getitem_for_lua(runtime, L, py_obj, 2) * else: */ } /* "lupa/_lupa.pyx":1558 * return getitem_for_lua(runtime, L, py_obj, 2) * else: * return getattr_for_lua(runtime, L, py_obj, 2) # <<<<<<<<<<<<<< * except: * runtime.store_raised_exception(L, b'error reading Python attribute/item') */ /*else*/ { __pyx_t_8 = __pyx_f_4lupa_5_lupa_getattr_for_lua(__pyx_v_runtime, __pyx_v_L, __pyx_v_py_obj, 2); if (unlikely(__pyx_t_8 == ((int)-1))) __PYX_ERR(0, 1558, __pyx_L3_error) __pyx_r = __pyx_t_8; goto __pyx_L7_try_return; } /* "lupa/_lupa.pyx":1553 * cdef int py_object_getindex_with_gil(lua_State* L, py_object* py_obj) with gil: * cdef LuaRuntime runtime * try: # <<<<<<<<<<<<<< * runtime = py_obj.runtime * if (py_obj.type_flags & OBJ_AS_INDEX) and not runtime._attribute_getter: */ } __pyx_L3_error:; __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; /* "lupa/_lupa.pyx":1559 * else: * return getattr_for_lua(runtime, L, py_obj, 2) * except: # <<<<<<<<<<<<<< * runtime.store_raised_exception(L, b'error reading Python attribute/item') * return -1 */ /*except:*/ { __Pyx_AddTraceback("lupa._lupa.py_object_getindex_with_gil", __pyx_clineno, __pyx_lineno, __pyx_filename); if (__Pyx_GetException(&__pyx_t_4, &__pyx_t_9, &__pyx_t_10) < 0) __PYX_ERR(0, 1559, __pyx_L5_except_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_GOTREF(__pyx_t_9); __Pyx_GOTREF(__pyx_t_10); /* "lupa/_lupa.pyx":1560 * return getattr_for_lua(runtime, L, py_obj, 2) * except: * runtime.store_raised_exception(L, b'error reading Python attribute/item') # <<<<<<<<<<<<<< * return -1 * */ if (unlikely(!__pyx_v_runtime)) { __Pyx_RaiseUnboundLocalError("runtime"); __PYX_ERR(0, 1560, __pyx_L5_except_error) } __pyx_t_8 = __pyx_f_4lupa_5_lupa_10LuaRuntime_store_raised_exception(__pyx_v_runtime, __pyx_v_L, __pyx_kp_b_error_reading_Python_attribute_i); if (unlikely(__pyx_t_8 == ((int)-1))) __PYX_ERR(0, 1560, __pyx_L5_except_error) /* "lupa/_lupa.pyx":1561 * except: * runtime.store_raised_exception(L, b'error reading Python attribute/item') * return -1 # <<<<<<<<<<<<<< * * cdef int py_object_getindex(lua_State* L) nogil: */ __pyx_r = -1; __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; goto __pyx_L6_except_return; } __pyx_L5_except_error:; /* "lupa/_lupa.pyx":1553 * cdef int py_object_getindex_with_gil(lua_State* L, py_object* py_obj) with gil: * cdef LuaRuntime runtime * try: # <<<<<<<<<<<<<< * runtime = py_obj.runtime * if (py_obj.type_flags & OBJ_AS_INDEX) and not runtime._attribute_getter: */ __Pyx_XGIVEREF(__pyx_t_1); __Pyx_XGIVEREF(__pyx_t_2); __Pyx_XGIVEREF(__pyx_t_3); __Pyx_ExceptionReset(__pyx_t_1, __pyx_t_2, __pyx_t_3); goto __pyx_L1_error; __pyx_L7_try_return:; __Pyx_XGIVEREF(__pyx_t_1); __Pyx_XGIVEREF(__pyx_t_2); __Pyx_XGIVEREF(__pyx_t_3); __Pyx_ExceptionReset(__pyx_t_1, __pyx_t_2, __pyx_t_3); goto __pyx_L0; __pyx_L6_except_return:; __Pyx_XGIVEREF(__pyx_t_1); __Pyx_XGIVEREF(__pyx_t_2); __Pyx_XGIVEREF(__pyx_t_3); __Pyx_ExceptionReset(__pyx_t_1, __pyx_t_2, __pyx_t_3); goto __pyx_L0; } /* "lupa/_lupa.pyx":1551 * * * cdef int py_object_getindex_with_gil(lua_State* L, py_object* py_obj) with gil: # <<<<<<<<<<<<<< * cdef LuaRuntime runtime * try: */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_4); __Pyx_XDECREF(__pyx_t_9); __Pyx_XDECREF(__pyx_t_10); __Pyx_WriteUnraisable("lupa._lupa.py_object_getindex_with_gil", __pyx_clineno, __pyx_lineno, __pyx_filename, 1, 0); __pyx_r = 0; __pyx_L0:; __Pyx_XDECREF((PyObject *)__pyx_v_runtime); __Pyx_RefNannyFinishContext(); #ifdef WITH_THREAD __Pyx_PyGILState_Release(__pyx_gilstate_save); #endif return __pyx_r; } /* "lupa/_lupa.pyx":1563 * return -1 * * cdef int py_object_getindex(lua_State* L) nogil: # <<<<<<<<<<<<<< * cdef py_object* py_obj = unwrap_lua_object(L, 1) # may not return on error! * if not py_obj: */ static int __pyx_f_4lupa_5_lupa_py_object_getindex(lua_State *__pyx_v_L) { struct __pyx_t_4lupa_5_lupa_py_object *__pyx_v_py_obj; int __pyx_v_result; int __pyx_r; int __pyx_t_1; /* "lupa/_lupa.pyx":1564 * * cdef int py_object_getindex(lua_State* L) nogil: * cdef py_object* py_obj = unwrap_lua_object(L, 1) # may not return on error! # <<<<<<<<<<<<<< * if not py_obj: * return lua.luaL_argerror(L, 1, "not a python object") # never returns! */ __pyx_v_py_obj = __pyx_f_4lupa_5_lupa_unwrap_lua_object(__pyx_v_L, 1); /* "lupa/_lupa.pyx":1565 * cdef int py_object_getindex(lua_State* L) nogil: * cdef py_object* py_obj = unwrap_lua_object(L, 1) # may not return on error! * if not py_obj: # <<<<<<<<<<<<<< * return lua.luaL_argerror(L, 1, "not a python object") # never returns! * result = py_object_getindex_with_gil(L, py_obj) */ __pyx_t_1 = ((!(__pyx_v_py_obj != 0)) != 0); if (__pyx_t_1) { /* "lupa/_lupa.pyx":1566 * cdef py_object* py_obj = unwrap_lua_object(L, 1) # may not return on error! * if not py_obj: * return lua.luaL_argerror(L, 1, "not a python object") # never returns! # <<<<<<<<<<<<<< * result = py_object_getindex_with_gil(L, py_obj) * if result < 0: */ __pyx_r = luaL_argerror(__pyx_v_L, 1, ((char *)"not a python object")); goto __pyx_L0; /* "lupa/_lupa.pyx":1565 * cdef int py_object_getindex(lua_State* L) nogil: * cdef py_object* py_obj = unwrap_lua_object(L, 1) # may not return on error! * if not py_obj: # <<<<<<<<<<<<<< * return lua.luaL_argerror(L, 1, "not a python object") # never returns! * result = py_object_getindex_with_gil(L, py_obj) */ } /* "lupa/_lupa.pyx":1567 * if not py_obj: * return lua.luaL_argerror(L, 1, "not a python object") # never returns! * result = py_object_getindex_with_gil(L, py_obj) # <<<<<<<<<<<<<< * if result < 0: * return lua.lua_error(L) # never returns! */ __pyx_v_result = __pyx_f_4lupa_5_lupa_py_object_getindex_with_gil(__pyx_v_L, __pyx_v_py_obj); /* "lupa/_lupa.pyx":1568 * return lua.luaL_argerror(L, 1, "not a python object") # never returns! * result = py_object_getindex_with_gil(L, py_obj) * if result < 0: # <<<<<<<<<<<<<< * return lua.lua_error(L) # never returns! * return result */ __pyx_t_1 = ((__pyx_v_result < 0) != 0); if (__pyx_t_1) { /* "lupa/_lupa.pyx":1569 * result = py_object_getindex_with_gil(L, py_obj) * if result < 0: * return lua.lua_error(L) # never returns! # <<<<<<<<<<<<<< * return result * */ __pyx_r = lua_error(__pyx_v_L); goto __pyx_L0; /* "lupa/_lupa.pyx":1568 * return lua.luaL_argerror(L, 1, "not a python object") # never returns! * result = py_object_getindex_with_gil(L, py_obj) * if result < 0: # <<<<<<<<<<<<<< * return lua.lua_error(L) # never returns! * return result */ } /* "lupa/_lupa.pyx":1570 * if result < 0: * return lua.lua_error(L) # never returns! * return result # <<<<<<<<<<<<<< * * */ __pyx_r = __pyx_v_result; goto __pyx_L0; /* "lupa/_lupa.pyx":1563 * return -1 * * cdef int py_object_getindex(lua_State* L) nogil: # <<<<<<<<<<<<<< * cdef py_object* py_obj = unwrap_lua_object(L, 1) # may not return on error! * if not py_obj: */ /* function exit code */ __pyx_L0:; return __pyx_r; } /* "lupa/_lupa.pyx":1573 * * * cdef int py_object_setindex_with_gil(lua_State* L, py_object* py_obj) with gil: # <<<<<<<<<<<<<< * cdef LuaRuntime runtime * try: */ static int __pyx_f_4lupa_5_lupa_py_object_setindex_with_gil(lua_State *__pyx_v_L, struct __pyx_t_4lupa_5_lupa_py_object *__pyx_v_py_obj) { struct __pyx_obj_4lupa_5_lupa_LuaRuntime *__pyx_v_runtime = 0; int __pyx_r; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; PyObject *__pyx_t_2 = NULL; PyObject *__pyx_t_3 = NULL; PyObject *__pyx_t_4 = NULL; int __pyx_t_5; int __pyx_t_6; int __pyx_t_7; int __pyx_t_8; PyObject *__pyx_t_9 = NULL; PyObject *__pyx_t_10 = NULL; #ifdef WITH_THREAD PyGILState_STATE __pyx_gilstate_save = __Pyx_PyGILState_Ensure(); #endif __Pyx_RefNannySetupContext("py_object_setindex_with_gil", 0); /* "lupa/_lupa.pyx":1575 * cdef int py_object_setindex_with_gil(lua_State* L, py_object* py_obj) with gil: * cdef LuaRuntime runtime * try: # <<<<<<<<<<<<<< * runtime = py_obj.runtime * if (py_obj.type_flags & OBJ_AS_INDEX) and not runtime._attribute_setter: */ { __Pyx_PyThreadState_declare __Pyx_PyThreadState_assign __Pyx_ExceptionSave(&__pyx_t_1, &__pyx_t_2, &__pyx_t_3); __Pyx_XGOTREF(__pyx_t_1); __Pyx_XGOTREF(__pyx_t_2); __Pyx_XGOTREF(__pyx_t_3); /*try:*/ { /* "lupa/_lupa.pyx":1576 * cdef LuaRuntime runtime * try: * runtime = py_obj.runtime # <<<<<<<<<<<<<< * if (py_obj.type_flags & OBJ_AS_INDEX) and not runtime._attribute_setter: * return setitem_for_lua(runtime, L, py_obj, 2, 3) */ __pyx_t_4 = ((PyObject *)__pyx_v_py_obj->runtime); __Pyx_INCREF(__pyx_t_4); __pyx_v_runtime = ((struct __pyx_obj_4lupa_5_lupa_LuaRuntime *)__pyx_t_4); __pyx_t_4 = 0; /* "lupa/_lupa.pyx":1577 * try: * runtime = py_obj.runtime * if (py_obj.type_flags & OBJ_AS_INDEX) and not runtime._attribute_setter: # <<<<<<<<<<<<<< * return setitem_for_lua(runtime, L, py_obj, 2, 3) * else: */ __pyx_t_6 = ((__pyx_v_py_obj->type_flags & __pyx_e_4lupa_5_lupa_OBJ_AS_INDEX) != 0); if (__pyx_t_6) { } else { __pyx_t_5 = __pyx_t_6; goto __pyx_L10_bool_binop_done; } __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_v_runtime->_attribute_setter); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(0, 1577, __pyx_L3_error) __pyx_t_7 = ((!__pyx_t_6) != 0); __pyx_t_5 = __pyx_t_7; __pyx_L10_bool_binop_done:; if (__pyx_t_5) { /* "lupa/_lupa.pyx":1578 * runtime = py_obj.runtime * if (py_obj.type_flags & OBJ_AS_INDEX) and not runtime._attribute_setter: * return setitem_for_lua(runtime, L, py_obj, 2, 3) # <<<<<<<<<<<<<< * else: * return setattr_for_lua(runtime, L, py_obj, 2, 3) */ __pyx_t_8 = __pyx_f_4lupa_5_lupa_setitem_for_lua(__pyx_v_runtime, __pyx_v_L, __pyx_v_py_obj, 2, 3); if (unlikely(__pyx_t_8 == ((int)-1))) __PYX_ERR(0, 1578, __pyx_L3_error) __pyx_r = __pyx_t_8; goto __pyx_L7_try_return; /* "lupa/_lupa.pyx":1577 * try: * runtime = py_obj.runtime * if (py_obj.type_flags & OBJ_AS_INDEX) and not runtime._attribute_setter: # <<<<<<<<<<<<<< * return setitem_for_lua(runtime, L, py_obj, 2, 3) * else: */ } /* "lupa/_lupa.pyx":1580 * return setitem_for_lua(runtime, L, py_obj, 2, 3) * else: * return setattr_for_lua(runtime, L, py_obj, 2, 3) # <<<<<<<<<<<<<< * except: * runtime.store_raised_exception(L, b'error writing Python attribute/item') */ /*else*/ { __pyx_t_8 = __pyx_f_4lupa_5_lupa_setattr_for_lua(__pyx_v_runtime, __pyx_v_L, __pyx_v_py_obj, 2, 3); if (unlikely(__pyx_t_8 == ((int)-1))) __PYX_ERR(0, 1580, __pyx_L3_error) __pyx_r = __pyx_t_8; goto __pyx_L7_try_return; } /* "lupa/_lupa.pyx":1575 * cdef int py_object_setindex_with_gil(lua_State* L, py_object* py_obj) with gil: * cdef LuaRuntime runtime * try: # <<<<<<<<<<<<<< * runtime = py_obj.runtime * if (py_obj.type_flags & OBJ_AS_INDEX) and not runtime._attribute_setter: */ } __pyx_L3_error:; __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; /* "lupa/_lupa.pyx":1581 * else: * return setattr_for_lua(runtime, L, py_obj, 2, 3) * except: # <<<<<<<<<<<<<< * runtime.store_raised_exception(L, b'error writing Python attribute/item') * return -1 */ /*except:*/ { __Pyx_AddTraceback("lupa._lupa.py_object_setindex_with_gil", __pyx_clineno, __pyx_lineno, __pyx_filename); if (__Pyx_GetException(&__pyx_t_4, &__pyx_t_9, &__pyx_t_10) < 0) __PYX_ERR(0, 1581, __pyx_L5_except_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_GOTREF(__pyx_t_9); __Pyx_GOTREF(__pyx_t_10); /* "lupa/_lupa.pyx":1582 * return setattr_for_lua(runtime, L, py_obj, 2, 3) * except: * runtime.store_raised_exception(L, b'error writing Python attribute/item') # <<<<<<<<<<<<<< * return -1 * */ if (unlikely(!__pyx_v_runtime)) { __Pyx_RaiseUnboundLocalError("runtime"); __PYX_ERR(0, 1582, __pyx_L5_except_error) } __pyx_t_8 = __pyx_f_4lupa_5_lupa_10LuaRuntime_store_raised_exception(__pyx_v_runtime, __pyx_v_L, __pyx_kp_b_error_writing_Python_attribute_i); if (unlikely(__pyx_t_8 == ((int)-1))) __PYX_ERR(0, 1582, __pyx_L5_except_error) /* "lupa/_lupa.pyx":1583 * except: * runtime.store_raised_exception(L, b'error writing Python attribute/item') * return -1 # <<<<<<<<<<<<<< * * cdef int py_object_setindex(lua_State* L) nogil: */ __pyx_r = -1; __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; goto __pyx_L6_except_return; } __pyx_L5_except_error:; /* "lupa/_lupa.pyx":1575 * cdef int py_object_setindex_with_gil(lua_State* L, py_object* py_obj) with gil: * cdef LuaRuntime runtime * try: # <<<<<<<<<<<<<< * runtime = py_obj.runtime * if (py_obj.type_flags & OBJ_AS_INDEX) and not runtime._attribute_setter: */ __Pyx_XGIVEREF(__pyx_t_1); __Pyx_XGIVEREF(__pyx_t_2); __Pyx_XGIVEREF(__pyx_t_3); __Pyx_ExceptionReset(__pyx_t_1, __pyx_t_2, __pyx_t_3); goto __pyx_L1_error; __pyx_L7_try_return:; __Pyx_XGIVEREF(__pyx_t_1); __Pyx_XGIVEREF(__pyx_t_2); __Pyx_XGIVEREF(__pyx_t_3); __Pyx_ExceptionReset(__pyx_t_1, __pyx_t_2, __pyx_t_3); goto __pyx_L0; __pyx_L6_except_return:; __Pyx_XGIVEREF(__pyx_t_1); __Pyx_XGIVEREF(__pyx_t_2); __Pyx_XGIVEREF(__pyx_t_3); __Pyx_ExceptionReset(__pyx_t_1, __pyx_t_2, __pyx_t_3); goto __pyx_L0; } /* "lupa/_lupa.pyx":1573 * * * cdef int py_object_setindex_with_gil(lua_State* L, py_object* py_obj) with gil: # <<<<<<<<<<<<<< * cdef LuaRuntime runtime * try: */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_4); __Pyx_XDECREF(__pyx_t_9); __Pyx_XDECREF(__pyx_t_10); __Pyx_WriteUnraisable("lupa._lupa.py_object_setindex_with_gil", __pyx_clineno, __pyx_lineno, __pyx_filename, 1, 0); __pyx_r = 0; __pyx_L0:; __Pyx_XDECREF((PyObject *)__pyx_v_runtime); __Pyx_RefNannyFinishContext(); #ifdef WITH_THREAD __Pyx_PyGILState_Release(__pyx_gilstate_save); #endif return __pyx_r; } /* "lupa/_lupa.pyx":1585 * return -1 * * cdef int py_object_setindex(lua_State* L) nogil: # <<<<<<<<<<<<<< * cdef py_object* py_obj = unwrap_lua_object(L, 1) # may not return on error! * if not py_obj: */ static int __pyx_f_4lupa_5_lupa_py_object_setindex(lua_State *__pyx_v_L) { struct __pyx_t_4lupa_5_lupa_py_object *__pyx_v_py_obj; int __pyx_v_result; int __pyx_r; int __pyx_t_1; /* "lupa/_lupa.pyx":1586 * * cdef int py_object_setindex(lua_State* L) nogil: * cdef py_object* py_obj = unwrap_lua_object(L, 1) # may not return on error! # <<<<<<<<<<<<<< * if not py_obj: * return lua.luaL_argerror(L, 1, "not a python object") # never returns! */ __pyx_v_py_obj = __pyx_f_4lupa_5_lupa_unwrap_lua_object(__pyx_v_L, 1); /* "lupa/_lupa.pyx":1587 * cdef int py_object_setindex(lua_State* L) nogil: * cdef py_object* py_obj = unwrap_lua_object(L, 1) # may not return on error! * if not py_obj: # <<<<<<<<<<<<<< * return lua.luaL_argerror(L, 1, "not a python object") # never returns! * result = py_object_setindex_with_gil(L, py_obj) */ __pyx_t_1 = ((!(__pyx_v_py_obj != 0)) != 0); if (__pyx_t_1) { /* "lupa/_lupa.pyx":1588 * cdef py_object* py_obj = unwrap_lua_object(L, 1) # may not return on error! * if not py_obj: * return lua.luaL_argerror(L, 1, "not a python object") # never returns! # <<<<<<<<<<<<<< * result = py_object_setindex_with_gil(L, py_obj) * if result < 0: */ __pyx_r = luaL_argerror(__pyx_v_L, 1, ((char *)"not a python object")); goto __pyx_L0; /* "lupa/_lupa.pyx":1587 * cdef int py_object_setindex(lua_State* L) nogil: * cdef py_object* py_obj = unwrap_lua_object(L, 1) # may not return on error! * if not py_obj: # <<<<<<<<<<<<<< * return lua.luaL_argerror(L, 1, "not a python object") # never returns! * result = py_object_setindex_with_gil(L, py_obj) */ } /* "lupa/_lupa.pyx":1589 * if not py_obj: * return lua.luaL_argerror(L, 1, "not a python object") # never returns! * result = py_object_setindex_with_gil(L, py_obj) # <<<<<<<<<<<<<< * if result < 0: * return lua.lua_error(L) # never returns! */ __pyx_v_result = __pyx_f_4lupa_5_lupa_py_object_setindex_with_gil(__pyx_v_L, __pyx_v_py_obj); /* "lupa/_lupa.pyx":1590 * return lua.luaL_argerror(L, 1, "not a python object") # never returns! * result = py_object_setindex_with_gil(L, py_obj) * if result < 0: # <<<<<<<<<<<<<< * return lua.lua_error(L) # never returns! * return result */ __pyx_t_1 = ((__pyx_v_result < 0) != 0); if (__pyx_t_1) { /* "lupa/_lupa.pyx":1591 * result = py_object_setindex_with_gil(L, py_obj) * if result < 0: * return lua.lua_error(L) # never returns! # <<<<<<<<<<<<<< * return result * */ __pyx_r = lua_error(__pyx_v_L); goto __pyx_L0; /* "lupa/_lupa.pyx":1590 * return lua.luaL_argerror(L, 1, "not a python object") # never returns! * result = py_object_setindex_with_gil(L, py_obj) * if result < 0: # <<<<<<<<<<<<<< * return lua.lua_error(L) # never returns! * return result */ } /* "lupa/_lupa.pyx":1592 * if result < 0: * return lua.lua_error(L) # never returns! * return result # <<<<<<<<<<<<<< * * # special methods for Lua wrapped Python objects */ __pyx_r = __pyx_v_result; goto __pyx_L0; /* "lupa/_lupa.pyx":1585 * return -1 * * cdef int py_object_setindex(lua_State* L) nogil: # <<<<<<<<<<<<<< * cdef py_object* py_obj = unwrap_lua_object(L, 1) # may not return on error! * if not py_obj: */ /* function exit code */ __pyx_L0:; return __pyx_r; } /* "lupa/_lupa.pyx":1607 * ## # Python helper functions for Lua * * cdef inline py_object* unpack_single_python_argument_or_jump(lua_State* L) nogil: # <<<<<<<<<<<<<< * if lua.lua_gettop(L) > 1: * lua.luaL_argerror(L, 2, "invalid arguments") # never returns! */ static CYTHON_INLINE struct __pyx_t_4lupa_5_lupa_py_object *__pyx_f_4lupa_5_lupa_unpack_single_python_argument_or_jump(lua_State *__pyx_v_L) { struct __pyx_t_4lupa_5_lupa_py_object *__pyx_v_py_obj; struct __pyx_t_4lupa_5_lupa_py_object *__pyx_r; int __pyx_t_1; /* "lupa/_lupa.pyx":1608 * * cdef inline py_object* unpack_single_python_argument_or_jump(lua_State* L) nogil: * if lua.lua_gettop(L) > 1: # <<<<<<<<<<<<<< * lua.luaL_argerror(L, 2, "invalid arguments") # never returns! * cdef py_object* py_obj = unwrap_lua_object(L, 1) */ __pyx_t_1 = ((lua_gettop(__pyx_v_L) > 1) != 0); if (__pyx_t_1) { /* "lupa/_lupa.pyx":1609 * 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, ((char *)"invalid arguments")); /* "lupa/_lupa.pyx":1608 * * cdef inline py_object* unpack_single_python_argument_or_jump(lua_State* L) nogil: * if lua.lua_gettop(L) > 1: # <<<<<<<<<<<<<< * lua.luaL_argerror(L, 2, "invalid arguments") # never returns! * cdef py_object* py_obj = unwrap_lua_object(L, 1) */ } /* "lupa/_lupa.pyx":1610 * if lua.lua_gettop(L) > 1: * lua.luaL_argerror(L, 2, "invalid arguments") # never returns! * cdef py_object* py_obj = unwrap_lua_object(L, 1) # <<<<<<<<<<<<<< * if not py_obj: * lua.luaL_argerror(L, 1, "not a python object") # never returns! */ __pyx_v_py_obj = __pyx_f_4lupa_5_lupa_unwrap_lua_object(__pyx_v_L, 1); /* "lupa/_lupa.pyx":1611 * lua.luaL_argerror(L, 2, "invalid arguments") # never returns! * cdef py_object* py_obj = unwrap_lua_object(L, 1) * if not py_obj: # <<<<<<<<<<<<<< * lua.luaL_argerror(L, 1, "not a python object") # never returns! * return py_obj */ __pyx_t_1 = ((!(__pyx_v_py_obj != 0)) != 0); if (__pyx_t_1) { /* "lupa/_lupa.pyx":1612 * 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, ((char *)"not a python object")); /* "lupa/_lupa.pyx":1611 * lua.luaL_argerror(L, 2, "invalid arguments") # never returns! * cdef py_object* py_obj = unwrap_lua_object(L, 1) * if not py_obj: # <<<<<<<<<<<<<< * lua.luaL_argerror(L, 1, "not a python object") # never returns! * return py_obj */ } /* "lupa/_lupa.pyx":1613 * if not py_obj: * lua.luaL_argerror(L, 1, "not a python object") # never returns! * return py_obj # <<<<<<<<<<<<<< * * cdef py_object* unwrap_lua_object(lua_State* L, int n) nogil: */ __pyx_r = __pyx_v_py_obj; goto __pyx_L0; /* "lupa/_lupa.pyx":1607 * ## # Python helper functions for Lua * * cdef inline py_object* unpack_single_python_argument_or_jump(lua_State* L) nogil: # <<<<<<<<<<<<<< * if lua.lua_gettop(L) > 1: * lua.luaL_argerror(L, 2, "invalid arguments") # never returns! */ /* function exit code */ __pyx_L0:; return __pyx_r; } /* "lupa/_lupa.pyx":1615 * return py_obj * * cdef py_object* unwrap_lua_object(lua_State* L, int n) nogil: # <<<<<<<<<<<<<< * if lua.lua_isuserdata(L, n): * return unpack_userdata(L, n) */ static struct __pyx_t_4lupa_5_lupa_py_object *__pyx_f_4lupa_5_lupa_unwrap_lua_object(lua_State *__pyx_v_L, int __pyx_v_n) { struct __pyx_t_4lupa_5_lupa_py_object *__pyx_r; int __pyx_t_1; /* "lupa/_lupa.pyx":1616 * * cdef py_object* unwrap_lua_object(lua_State* L, int n) nogil: * if lua.lua_isuserdata(L, n): # <<<<<<<<<<<<<< * return unpack_userdata(L, n) * else: */ __pyx_t_1 = (lua_isuserdata(__pyx_v_L, __pyx_v_n) != 0); if (__pyx_t_1) { /* "lupa/_lupa.pyx":1617 * cdef py_object* unwrap_lua_object(lua_State* L, int n) nogil: * if lua.lua_isuserdata(L, n): * return unpack_userdata(L, n) # <<<<<<<<<<<<<< * else: * return unpack_wrapped_pyfunction(L, n) */ __pyx_r = __pyx_f_4lupa_5_lupa_unpack_userdata(__pyx_v_L, __pyx_v_n); goto __pyx_L0; /* "lupa/_lupa.pyx":1616 * * cdef py_object* unwrap_lua_object(lua_State* L, int n) nogil: * if lua.lua_isuserdata(L, n): # <<<<<<<<<<<<<< * return unpack_userdata(L, n) * else: */ } /* "lupa/_lupa.pyx":1619 * return unpack_userdata(L, n) * else: * return unpack_wrapped_pyfunction(L, n) # <<<<<<<<<<<<<< * * cdef int py_wrap_object_protocol_with_gil(lua_State* L, py_object* py_obj, int type_flags) with gil: */ /*else*/ { __pyx_r = __pyx_f_4lupa_5_lupa_unpack_wrapped_pyfunction(__pyx_v_L, __pyx_v_n); goto __pyx_L0; } /* "lupa/_lupa.pyx":1615 * return py_obj * * cdef py_object* unwrap_lua_object(lua_State* L, int n) nogil: # <<<<<<<<<<<<<< * if lua.lua_isuserdata(L, n): * return unpack_userdata(L, n) */ /* function exit code */ __pyx_L0:; return __pyx_r; } /* "lupa/_lupa.pyx":1621 * return unpack_wrapped_pyfunction(L, n) * * cdef int py_wrap_object_protocol_with_gil(lua_State* L, py_object* py_obj, int type_flags) with gil: # <<<<<<<<<<<<<< * cdef LuaRuntime runtime * try: */ static int __pyx_f_4lupa_5_lupa_py_wrap_object_protocol_with_gil(lua_State *__pyx_v_L, struct __pyx_t_4lupa_5_lupa_py_object *__pyx_v_py_obj, int __pyx_v_type_flags) { struct __pyx_obj_4lupa_5_lupa_LuaRuntime *__pyx_v_runtime = 0; int __pyx_r; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; PyObject *__pyx_t_2 = NULL; PyObject *__pyx_t_3 = NULL; PyObject *__pyx_t_4 = NULL; #ifdef WITH_THREAD PyGILState_STATE __pyx_gilstate_save = __Pyx_PyGILState_Ensure(); #endif __Pyx_RefNannySetupContext("py_wrap_object_protocol_with_gil", 0); /* "lupa/_lupa.pyx":1623 * 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 = py_obj.runtime * return py_to_lua_custom(runtime, L, py_obj.obj, type_flags) */ { (void)__pyx_t_1; (void)__pyx_t_2; (void)__pyx_t_3; /* mark used */ /*try:*/ { /* "lupa/_lupa.pyx":1624 * cdef LuaRuntime runtime * try: * runtime = py_obj.runtime # <<<<<<<<<<<<<< * return py_to_lua_custom(runtime, L, py_obj.obj, type_flags) * except: */ __pyx_t_4 = ((PyObject *)__pyx_v_py_obj->runtime); __Pyx_INCREF(__pyx_t_4); __pyx_v_runtime = ((struct __pyx_obj_4lupa_5_lupa_LuaRuntime *)__pyx_t_4); __pyx_t_4 = 0; /* "lupa/_lupa.pyx":1625 * try: * runtime = py_obj.runtime * return py_to_lua_custom(runtime, L, py_obj.obj, type_flags) # <<<<<<<<<<<<<< * except: * try: runtime.store_raised_exception(L, b'error during type adaptation') */ __pyx_t_4 = ((PyObject *)__pyx_v_py_obj->obj); __Pyx_INCREF(__pyx_t_4); __pyx_r = __pyx_f_4lupa_5_lupa_py_to_lua_custom(__pyx_v_runtime, __pyx_v_L, __pyx_t_4, __pyx_v_type_flags); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; goto __pyx_L7_try_return; /* "lupa/_lupa.pyx":1623 * 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 = py_obj.runtime * return py_to_lua_custom(runtime, L, py_obj.obj, type_flags) */ } __pyx_L7_try_return:; goto __pyx_L0; } /* "lupa/_lupa.pyx":1621 * return unpack_wrapped_pyfunction(L, n) * * cdef int py_wrap_object_protocol_with_gil(lua_State* L, py_object* py_obj, int type_flags) with gil: # <<<<<<<<<<<<<< * cdef LuaRuntime runtime * try: */ /* function exit code */ __pyx_L0:; __Pyx_XDECREF((PyObject *)__pyx_v_runtime); __Pyx_RefNannyFinishContext(); #ifdef WITH_THREAD __Pyx_PyGILState_Release(__pyx_gilstate_save); #endif return __pyx_r; } /* "lupa/_lupa.pyx":1630 * finally: return -1 * * cdef int py_wrap_object_protocol(lua_State* L, int type_flags) nogil: # <<<<<<<<<<<<<< * cdef py_object* py_obj = unpack_single_python_argument_or_jump(L) # never returns on error! * result = py_wrap_object_protocol_with_gil(L, py_obj, type_flags) */ static int __pyx_f_4lupa_5_lupa_py_wrap_object_protocol(lua_State *__pyx_v_L, int __pyx_v_type_flags) { struct __pyx_t_4lupa_5_lupa_py_object *__pyx_v_py_obj; int __pyx_v_result; int __pyx_r; int __pyx_t_1; /* "lupa/_lupa.pyx":1631 * * cdef int py_wrap_object_protocol(lua_State* L, int type_flags) nogil: * cdef py_object* py_obj = unpack_single_python_argument_or_jump(L) # never returns on error! # <<<<<<<<<<<<<< * result = py_wrap_object_protocol_with_gil(L, py_obj, type_flags) * if result < 0: */ __pyx_v_py_obj = __pyx_f_4lupa_5_lupa_unpack_single_python_argument_or_jump(__pyx_v_L); /* "lupa/_lupa.pyx":1632 * cdef int py_wrap_object_protocol(lua_State* L, int type_flags) nogil: * cdef py_object* py_obj = unpack_single_python_argument_or_jump(L) # never returns on error! * result = py_wrap_object_protocol_with_gil(L, py_obj, type_flags) # <<<<<<<<<<<<<< * if result < 0: * return lua.lua_error(L) # never returns! */ __pyx_v_result = __pyx_f_4lupa_5_lupa_py_wrap_object_protocol_with_gil(__pyx_v_L, __pyx_v_py_obj, __pyx_v_type_flags); /* "lupa/_lupa.pyx":1633 * cdef py_object* py_obj = unpack_single_python_argument_or_jump(L) # never returns on error! * result = py_wrap_object_protocol_with_gil(L, py_obj, type_flags) * if result < 0: # <<<<<<<<<<<<<< * return lua.lua_error(L) # never returns! * return result */ __pyx_t_1 = ((__pyx_v_result < 0) != 0); if (__pyx_t_1) { /* "lupa/_lupa.pyx":1634 * result = py_wrap_object_protocol_with_gil(L, py_obj, type_flags) * if result < 0: * return lua.lua_error(L) # never returns! # <<<<<<<<<<<<<< * return result * */ __pyx_r = lua_error(__pyx_v_L); goto __pyx_L0; /* "lupa/_lupa.pyx":1633 * cdef py_object* py_obj = unpack_single_python_argument_or_jump(L) # never returns on error! * result = py_wrap_object_protocol_with_gil(L, py_obj, type_flags) * if result < 0: # <<<<<<<<<<<<<< * return lua.lua_error(L) # never returns! * return result */ } /* "lupa/_lupa.pyx":1635 * if result < 0: * return lua.lua_error(L) # never returns! * return result # <<<<<<<<<<<<<< * * cdef int py_as_attrgetter(lua_State* L) nogil: */ __pyx_r = __pyx_v_result; goto __pyx_L0; /* "lupa/_lupa.pyx":1630 * finally: return -1 * * cdef int py_wrap_object_protocol(lua_State* L, int type_flags) nogil: # <<<<<<<<<<<<<< * cdef py_object* py_obj = unpack_single_python_argument_or_jump(L) # never returns on error! * result = py_wrap_object_protocol_with_gil(L, py_obj, type_flags) */ /* function exit code */ __pyx_L0:; return __pyx_r; } /* "lupa/_lupa.pyx":1637 * return result * * cdef int py_as_attrgetter(lua_State* L) nogil: # <<<<<<<<<<<<<< * return py_wrap_object_protocol(L, 0) * */ static int __pyx_f_4lupa_5_lupa_py_as_attrgetter(lua_State *__pyx_v_L) { int __pyx_r; /* "lupa/_lupa.pyx":1638 * * cdef int py_as_attrgetter(lua_State* L) nogil: * return py_wrap_object_protocol(L, 0) # <<<<<<<<<<<<<< * * cdef int py_as_itemgetter(lua_State* L) nogil: */ __pyx_r = __pyx_f_4lupa_5_lupa_py_wrap_object_protocol(__pyx_v_L, 0); goto __pyx_L0; /* "lupa/_lupa.pyx":1637 * return result * * cdef int py_as_attrgetter(lua_State* L) nogil: # <<<<<<<<<<<<<< * return py_wrap_object_protocol(L, 0) * */ /* function exit code */ __pyx_L0:; return __pyx_r; } /* "lupa/_lupa.pyx":1640 * return py_wrap_object_protocol(L, 0) * * cdef int py_as_itemgetter(lua_State* L) nogil: # <<<<<<<<<<<<<< * return py_wrap_object_protocol(L, OBJ_AS_INDEX) * */ static int __pyx_f_4lupa_5_lupa_py_as_itemgetter(lua_State *__pyx_v_L) { int __pyx_r; /* "lupa/_lupa.pyx":1641 * * cdef int py_as_itemgetter(lua_State* L) nogil: * return py_wrap_object_protocol(L, OBJ_AS_INDEX) # <<<<<<<<<<<<<< * * cdef int py_as_function(lua_State* L) nogil: */ __pyx_r = __pyx_f_4lupa_5_lupa_py_wrap_object_protocol(__pyx_v_L, __pyx_e_4lupa_5_lupa_OBJ_AS_INDEX); goto __pyx_L0; /* "lupa/_lupa.pyx":1640 * return py_wrap_object_protocol(L, 0) * * cdef int py_as_itemgetter(lua_State* L) nogil: # <<<<<<<<<<<<<< * return py_wrap_object_protocol(L, OBJ_AS_INDEX) * */ /* function exit code */ __pyx_L0:; return __pyx_r; } /* "lupa/_lupa.pyx":1643 * 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, py_asfunc_call, 1) */ static int __pyx_f_4lupa_5_lupa_py_as_function(lua_State *__pyx_v_L) { CYTHON_UNUSED struct __pyx_t_4lupa_5_lupa_py_object *__pyx_v_py_obj; int __pyx_r; /* "lupa/_lupa.pyx":1644 * * 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, py_asfunc_call, 1) * return 1 */ __pyx_v_py_obj = __pyx_f_4lupa_5_lupa_unpack_single_python_argument_or_jump(__pyx_v_L); /* "lupa/_lupa.pyx":1645 * 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, py_asfunc_call, 1) # <<<<<<<<<<<<<< * return 1 * */ lua_pushcclosure(__pyx_v_L, ((lua_CFunction)__pyx_f_4lupa_5_lupa_py_asfunc_call), 1); /* "lupa/_lupa.pyx":1646 * cdef py_object* py_obj = unpack_single_python_argument_or_jump(L) # never returns on error! * lua.lua_pushcclosure(L, py_asfunc_call, 1) * return 1 # <<<<<<<<<<<<<< * * # iteration support for Python objects in Lua */ __pyx_r = 1; goto __pyx_L0; /* "lupa/_lupa.pyx":1643 * 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, py_asfunc_call, 1) */ /* function exit code */ __pyx_L0:; return __pyx_r; } /* "lupa/_lupa.pyx":1650 * # iteration support for Python objects in Lua * * cdef int py_iter(lua_State* L) nogil: # <<<<<<<<<<<<<< * cdef py_object* py_obj = unpack_single_python_argument_or_jump(L) # never returns on error! * result = py_iter_with_gil(L, py_obj, 0) */ static int __pyx_f_4lupa_5_lupa_py_iter(lua_State *__pyx_v_L) { struct __pyx_t_4lupa_5_lupa_py_object *__pyx_v_py_obj; int __pyx_v_result; int __pyx_r; int __pyx_t_1; /* "lupa/_lupa.pyx":1651 * * cdef int py_iter(lua_State* L) nogil: * cdef py_object* py_obj = unpack_single_python_argument_or_jump(L) # never returns on error! # <<<<<<<<<<<<<< * result = py_iter_with_gil(L, py_obj, 0) * if result < 0: */ __pyx_v_py_obj = __pyx_f_4lupa_5_lupa_unpack_single_python_argument_or_jump(__pyx_v_L); /* "lupa/_lupa.pyx":1652 * cdef int py_iter(lua_State* L) nogil: * cdef py_object* py_obj = unpack_single_python_argument_or_jump(L) # never returns on error! * result = py_iter_with_gil(L, py_obj, 0) # <<<<<<<<<<<<<< * if result < 0: * return lua.lua_error(L) # never returns! */ __pyx_v_result = __pyx_f_4lupa_5_lupa_py_iter_with_gil(__pyx_v_L, __pyx_v_py_obj, 0); /* "lupa/_lupa.pyx":1653 * cdef py_object* py_obj = unpack_single_python_argument_or_jump(L) # never returns on error! * result = py_iter_with_gil(L, py_obj, 0) * if result < 0: # <<<<<<<<<<<<<< * return lua.lua_error(L) # never returns! * return result */ __pyx_t_1 = ((__pyx_v_result < 0) != 0); if (__pyx_t_1) { /* "lupa/_lupa.pyx":1654 * result = py_iter_with_gil(L, py_obj, 0) * if result < 0: * return lua.lua_error(L) # never returns! # <<<<<<<<<<<<<< * return result * */ __pyx_r = lua_error(__pyx_v_L); goto __pyx_L0; /* "lupa/_lupa.pyx":1653 * cdef py_object* py_obj = unpack_single_python_argument_or_jump(L) # never returns on error! * result = py_iter_with_gil(L, py_obj, 0) * if result < 0: # <<<<<<<<<<<<<< * return lua.lua_error(L) # never returns! * return result */ } /* "lupa/_lupa.pyx":1655 * if result < 0: * return lua.lua_error(L) # never returns! * return result # <<<<<<<<<<<<<< * * cdef int py_iterex(lua_State* L) nogil: */ __pyx_r = __pyx_v_result; goto __pyx_L0; /* "lupa/_lupa.pyx":1650 * # iteration support for Python objects in Lua * * cdef int py_iter(lua_State* L) nogil: # <<<<<<<<<<<<<< * cdef py_object* py_obj = unpack_single_python_argument_or_jump(L) # never returns on error! * result = py_iter_with_gil(L, py_obj, 0) */ /* function exit code */ __pyx_L0:; return __pyx_r; } /* "lupa/_lupa.pyx":1657 * return result * * cdef int py_iterex(lua_State* L) nogil: # <<<<<<<<<<<<<< * cdef py_object* py_obj = unpack_single_python_argument_or_jump(L) # never returns on error! * result = py_iter_with_gil(L, py_obj, OBJ_UNPACK_TUPLE) */ static int __pyx_f_4lupa_5_lupa_py_iterex(lua_State *__pyx_v_L) { struct __pyx_t_4lupa_5_lupa_py_object *__pyx_v_py_obj; int __pyx_v_result; int __pyx_r; int __pyx_t_1; /* "lupa/_lupa.pyx":1658 * * cdef int py_iterex(lua_State* L) nogil: * cdef py_object* py_obj = unpack_single_python_argument_or_jump(L) # never returns on error! # <<<<<<<<<<<<<< * result = py_iter_with_gil(L, py_obj, OBJ_UNPACK_TUPLE) * if result < 0: */ __pyx_v_py_obj = __pyx_f_4lupa_5_lupa_unpack_single_python_argument_or_jump(__pyx_v_L); /* "lupa/_lupa.pyx":1659 * cdef int py_iterex(lua_State* L) nogil: * cdef py_object* py_obj = unpack_single_python_argument_or_jump(L) # never returns on error! * result = py_iter_with_gil(L, py_obj, OBJ_UNPACK_TUPLE) # <<<<<<<<<<<<<< * if result < 0: * return lua.lua_error(L) # never returns! */ __pyx_v_result = __pyx_f_4lupa_5_lupa_py_iter_with_gil(__pyx_v_L, __pyx_v_py_obj, __pyx_e_4lupa_5_lupa_OBJ_UNPACK_TUPLE); /* "lupa/_lupa.pyx":1660 * cdef py_object* py_obj = unpack_single_python_argument_or_jump(L) # never returns on error! * result = py_iter_with_gil(L, py_obj, OBJ_UNPACK_TUPLE) * if result < 0: # <<<<<<<<<<<<<< * return lua.lua_error(L) # never returns! * return result */ __pyx_t_1 = ((__pyx_v_result < 0) != 0); if (__pyx_t_1) { /* "lupa/_lupa.pyx":1661 * result = py_iter_with_gil(L, py_obj, OBJ_UNPACK_TUPLE) * if result < 0: * return lua.lua_error(L) # never returns! # <<<<<<<<<<<<<< * return result * */ __pyx_r = lua_error(__pyx_v_L); goto __pyx_L0; /* "lupa/_lupa.pyx":1660 * cdef py_object* py_obj = unpack_single_python_argument_or_jump(L) # never returns on error! * result = py_iter_with_gil(L, py_obj, OBJ_UNPACK_TUPLE) * if result < 0: # <<<<<<<<<<<<<< * return lua.lua_error(L) # never returns! * return result */ } /* "lupa/_lupa.pyx":1662 * if result < 0: * return lua.lua_error(L) # never returns! * return result # <<<<<<<<<<<<<< * * cdef int py_enumerate(lua_State* L) nogil: */ __pyx_r = __pyx_v_result; goto __pyx_L0; /* "lupa/_lupa.pyx":1657 * return result * * cdef int py_iterex(lua_State* L) nogil: # <<<<<<<<<<<<<< * cdef py_object* py_obj = unpack_single_python_argument_or_jump(L) # never returns on error! * result = py_iter_with_gil(L, py_obj, OBJ_UNPACK_TUPLE) */ /* function exit code */ __pyx_L0:; return __pyx_r; } /* "lupa/_lupa.pyx":1664 * return result * * cdef int py_enumerate(lua_State* L) nogil: # <<<<<<<<<<<<<< * if lua.lua_gettop(L) > 2: * lua.luaL_argerror(L, 3, "invalid arguments") # never returns! */ static int __pyx_f_4lupa_5_lupa_py_enumerate(lua_State *__pyx_v_L) { struct __pyx_t_4lupa_5_lupa_py_object *__pyx_v_py_obj; double __pyx_v_start; int __pyx_v_result; int __pyx_r; int __pyx_t_1; double __pyx_t_2; /* "lupa/_lupa.pyx":1665 * * cdef int py_enumerate(lua_State* L) nogil: * if lua.lua_gettop(L) > 2: # <<<<<<<<<<<<<< * lua.luaL_argerror(L, 3, "invalid arguments") # never returns! * cdef py_object* py_obj = unwrap_lua_object(L, 1) */ __pyx_t_1 = ((lua_gettop(__pyx_v_L) > 2) != 0); if (__pyx_t_1) { /* "lupa/_lupa.pyx":1666 * 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, ((char *)"invalid arguments")); /* "lupa/_lupa.pyx":1665 * * cdef int py_enumerate(lua_State* L) nogil: * if lua.lua_gettop(L) > 2: # <<<<<<<<<<<<<< * lua.luaL_argerror(L, 3, "invalid arguments") # never returns! * cdef py_object* py_obj = unwrap_lua_object(L, 1) */ } /* "lupa/_lupa.pyx":1667 * if lua.lua_gettop(L) > 2: * lua.luaL_argerror(L, 3, "invalid arguments") # never returns! * cdef py_object* py_obj = unwrap_lua_object(L, 1) # <<<<<<<<<<<<<< * if not py_obj: * lua.luaL_argerror(L, 1, "not a python object") # never returns! */ __pyx_v_py_obj = __pyx_f_4lupa_5_lupa_unwrap_lua_object(__pyx_v_L, 1); /* "lupa/_lupa.pyx":1668 * lua.luaL_argerror(L, 3, "invalid arguments") # never returns! * cdef py_object* py_obj = unwrap_lua_object(L, 1) * if not py_obj: # <<<<<<<<<<<<<< * lua.luaL_argerror(L, 1, "not a python object") # never returns! * cdef double start = lua.lua_tonumber(L, -1) if lua.lua_gettop(L) == 2 else 0.0 */ __pyx_t_1 = ((!(__pyx_v_py_obj != 0)) != 0); if (__pyx_t_1) { /* "lupa/_lupa.pyx":1669 * 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, ((char *)"not a python object")); /* "lupa/_lupa.pyx":1668 * lua.luaL_argerror(L, 3, "invalid arguments") # never returns! * cdef py_object* py_obj = unwrap_lua_object(L, 1) * if not py_obj: # <<<<<<<<<<<<<< * lua.luaL_argerror(L, 1, "not a python object") # never returns! * cdef double start = lua.lua_tonumber(L, -1) if lua.lua_gettop(L) == 2 else 0.0 */ } /* "lupa/_lupa.pyx":1670 * if not py_obj: * lua.luaL_argerror(L, 1, "not a python object") # never returns! * cdef double start = lua.lua_tonumber(L, -1) if lua.lua_gettop(L) == 2 else 0.0 # <<<<<<<<<<<<<< * result = py_enumerate_with_gil(L, py_obj, start) * if result < 0: */ if (((lua_gettop(__pyx_v_L) == 2) != 0)) { __pyx_t_2 = lua_tonumber(__pyx_v_L, -1); } else { __pyx_t_2 = 0.0; } __pyx_v_start = __pyx_t_2; /* "lupa/_lupa.pyx":1671 * lua.luaL_argerror(L, 1, "not a python object") # never returns! * cdef double start = lua.lua_tonumber(L, -1) if lua.lua_gettop(L) == 2 else 0.0 * result = py_enumerate_with_gil(L, py_obj, start) # <<<<<<<<<<<<<< * if result < 0: * return lua.lua_error(L) # never returns! */ __pyx_v_result = __pyx_f_4lupa_5_lupa_py_enumerate_with_gil(__pyx_v_L, __pyx_v_py_obj, __pyx_v_start); /* "lupa/_lupa.pyx":1672 * cdef double start = lua.lua_tonumber(L, -1) if lua.lua_gettop(L) == 2 else 0.0 * result = py_enumerate_with_gil(L, py_obj, start) * if result < 0: # <<<<<<<<<<<<<< * return lua.lua_error(L) # never returns! * return result */ __pyx_t_1 = ((__pyx_v_result < 0) != 0); if (__pyx_t_1) { /* "lupa/_lupa.pyx":1673 * result = py_enumerate_with_gil(L, py_obj, start) * if result < 0: * return lua.lua_error(L) # never returns! # <<<<<<<<<<<<<< * return result * */ __pyx_r = lua_error(__pyx_v_L); goto __pyx_L0; /* "lupa/_lupa.pyx":1672 * cdef double start = lua.lua_tonumber(L, -1) if lua.lua_gettop(L) == 2 else 0.0 * result = py_enumerate_with_gil(L, py_obj, start) * if result < 0: # <<<<<<<<<<<<<< * return lua.lua_error(L) # never returns! * return result */ } /* "lupa/_lupa.pyx":1674 * if result < 0: * return lua.lua_error(L) # never returns! * return result # <<<<<<<<<<<<<< * * */ __pyx_r = __pyx_v_result; goto __pyx_L0; /* "lupa/_lupa.pyx":1664 * return result * * cdef int py_enumerate(lua_State* L) nogil: # <<<<<<<<<<<<<< * if lua.lua_gettop(L) > 2: * lua.luaL_argerror(L, 3, "invalid arguments") # never returns! */ /* function exit code */ __pyx_L0:; return __pyx_r; } /* "lupa/_lupa.pyx":1677 * * * cdef int py_enumerate_with_gil(lua_State* L, py_object* py_obj, double start) with gil: # <<<<<<<<<<<<<< * cdef LuaRuntime runtime * try: */ static int __pyx_f_4lupa_5_lupa_py_enumerate_with_gil(lua_State *__pyx_v_L, struct __pyx_t_4lupa_5_lupa_py_object *__pyx_v_py_obj, double __pyx_v_start) { struct __pyx_obj_4lupa_5_lupa_LuaRuntime *__pyx_v_runtime = 0; PyObject *__pyx_v_obj = NULL; int __pyx_r; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; PyObject *__pyx_t_2 = NULL; PyObject *__pyx_t_3 = NULL; PyObject *__pyx_t_4 = NULL; PyObject *__pyx_t_5 = NULL; PyObject *__pyx_t_6 = NULL; int __pyx_t_7; PyObject *__pyx_t_8 = NULL; PyObject *__pyx_t_9 = NULL; PyObject *__pyx_t_10 = NULL; PyObject *__pyx_t_11 = NULL; PyObject *__pyx_t_12 = NULL; PyObject *__pyx_t_13 = NULL; #ifdef WITH_THREAD PyGILState_STATE __pyx_gilstate_save = __Pyx_PyGILState_Ensure(); #endif __Pyx_RefNannySetupContext("py_enumerate_with_gil", 0); /* "lupa/_lupa.pyx":1679 * cdef int py_enumerate_with_gil(lua_State* L, py_object* py_obj, double start) with gil: * cdef LuaRuntime runtime * try: # <<<<<<<<<<<<<< * runtime = py_obj.runtime * obj = iter(py_obj.obj) */ { __Pyx_PyThreadState_declare __Pyx_PyThreadState_assign __Pyx_ExceptionSave(&__pyx_t_1, &__pyx_t_2, &__pyx_t_3); __Pyx_XGOTREF(__pyx_t_1); __Pyx_XGOTREF(__pyx_t_2); __Pyx_XGOTREF(__pyx_t_3); /*try:*/ { /* "lupa/_lupa.pyx":1680 * cdef LuaRuntime runtime * try: * runtime = py_obj.runtime # <<<<<<<<<<<<<< * obj = iter(py_obj.obj) * return py_push_iterator(runtime, L, obj, OBJ_ENUMERATOR, start - 1.0) */ __pyx_t_4 = ((PyObject *)__pyx_v_py_obj->runtime); __Pyx_INCREF(__pyx_t_4); __pyx_v_runtime = ((struct __pyx_obj_4lupa_5_lupa_LuaRuntime *)__pyx_t_4); __pyx_t_4 = 0; /* "lupa/_lupa.pyx":1681 * try: * runtime = py_obj.runtime * obj = iter(py_obj.obj) # <<<<<<<<<<<<<< * return py_push_iterator(runtime, L, obj, OBJ_ENUMERATOR, start - 1.0) * except: */ __pyx_t_4 = ((PyObject *)__pyx_v_py_obj->obj); __Pyx_INCREF(__pyx_t_4); __pyx_t_5 = PyObject_GetIter(__pyx_t_4); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1681, __pyx_L3_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_v_obj = __pyx_t_5; __pyx_t_5 = 0; /* "lupa/_lupa.pyx":1682 * runtime = py_obj.runtime * obj = iter(py_obj.obj) * return py_push_iterator(runtime, L, obj, OBJ_ENUMERATOR, start - 1.0) # <<<<<<<<<<<<<< * except: * try: runtime.store_raised_exception(L, b'error creating an iterator with enumerate()') */ __pyx_r = __pyx_f_4lupa_5_lupa_py_push_iterator(__pyx_v_runtime, __pyx_v_L, __pyx_v_obj, __pyx_e_4lupa_5_lupa_OBJ_ENUMERATOR, (__pyx_v_start - 1.0)); goto __pyx_L7_try_return; /* "lupa/_lupa.pyx":1679 * cdef int py_enumerate_with_gil(lua_State* L, py_object* py_obj, double start) with gil: * cdef LuaRuntime runtime * try: # <<<<<<<<<<<<<< * runtime = py_obj.runtime * obj = iter(py_obj.obj) */ } __pyx_L3_error:; __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; /* "lupa/_lupa.pyx":1683 * obj = iter(py_obj.obj) * return py_push_iterator(runtime, L, obj, OBJ_ENUMERATOR, start - 1.0) * except: # <<<<<<<<<<<<<< * try: runtime.store_raised_exception(L, b'error creating an iterator with enumerate()') * finally: return -1 */ /*except:*/ { __Pyx_AddTraceback("lupa._lupa.py_enumerate_with_gil", __pyx_clineno, __pyx_lineno, __pyx_filename); if (__Pyx_GetException(&__pyx_t_5, &__pyx_t_4, &__pyx_t_6) < 0) __PYX_ERR(0, 1683, __pyx_L5_except_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_GOTREF(__pyx_t_4); __Pyx_GOTREF(__pyx_t_6); /* "lupa/_lupa.pyx":1684 * return py_push_iterator(runtime, L, obj, OBJ_ENUMERATOR, start - 1.0) * except: * try: runtime.store_raised_exception(L, b'error creating an iterator with enumerate()') # <<<<<<<<<<<<<< * finally: return -1 * */ /*try:*/ { if (unlikely(!__pyx_v_runtime)) { __Pyx_RaiseUnboundLocalError("runtime"); __PYX_ERR(0, 1684, __pyx_L14_error) } __pyx_t_7 = __pyx_f_4lupa_5_lupa_10LuaRuntime_store_raised_exception(__pyx_v_runtime, __pyx_v_L, __pyx_kp_b_error_creating_an_iterator_with); if (unlikely(__pyx_t_7 == ((int)-1))) __PYX_ERR(0, 1684, __pyx_L14_error) } /* "lupa/_lupa.pyx":1685 * except: * try: runtime.store_raised_exception(L, b'error creating an iterator with enumerate()') * finally: return -1 # <<<<<<<<<<<<<< * * cdef int py_iter_with_gil(lua_State* L, py_object* py_obj, int type_flags) with gil: */ /*finally:*/ { /*normal exit:*/{ __pyx_r = -1; __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; goto __pyx_L6_except_return; } __pyx_L14_error:; /*exception exit:*/{ __Pyx_PyThreadState_declare __Pyx_PyThreadState_assign __pyx_t_8 = 0; __pyx_t_9 = 0; __pyx_t_10 = 0; __pyx_t_11 = 0; __pyx_t_12 = 0; __pyx_t_13 = 0; if (PY_MAJOR_VERSION >= 3) __Pyx_ExceptionSwap(&__pyx_t_11, &__pyx_t_12, &__pyx_t_13); if ((PY_MAJOR_VERSION < 3) || unlikely(__Pyx_GetException(&__pyx_t_8, &__pyx_t_9, &__pyx_t_10) < 0)) __Pyx_ErrFetch(&__pyx_t_8, &__pyx_t_9, &__pyx_t_10); __Pyx_XGOTREF(__pyx_t_8); __Pyx_XGOTREF(__pyx_t_9); __Pyx_XGOTREF(__pyx_t_10); __Pyx_XGOTREF(__pyx_t_11); __Pyx_XGOTREF(__pyx_t_12); __Pyx_XGOTREF(__pyx_t_13); { __pyx_r = -1; __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; goto __pyx_L18_return; } __pyx_L18_return:; if (PY_MAJOR_VERSION >= 3) { __Pyx_XGIVEREF(__pyx_t_11); __Pyx_XGIVEREF(__pyx_t_12); __Pyx_XGIVEREF(__pyx_t_13); __Pyx_ExceptionReset(__pyx_t_11, __pyx_t_12, __pyx_t_13); } __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0; __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0; __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0; __pyx_t_11 = 0; __pyx_t_12 = 0; __pyx_t_13 = 0; goto __pyx_L6_except_return; } } } __pyx_L5_except_error:; /* "lupa/_lupa.pyx":1679 * cdef int py_enumerate_with_gil(lua_State* L, py_object* py_obj, double start) with gil: * cdef LuaRuntime runtime * try: # <<<<<<<<<<<<<< * runtime = py_obj.runtime * obj = iter(py_obj.obj) */ __Pyx_XGIVEREF(__pyx_t_1); __Pyx_XGIVEREF(__pyx_t_2); __Pyx_XGIVEREF(__pyx_t_3); __Pyx_ExceptionReset(__pyx_t_1, __pyx_t_2, __pyx_t_3); goto __pyx_L1_error; __pyx_L7_try_return:; __Pyx_XGIVEREF(__pyx_t_1); __Pyx_XGIVEREF(__pyx_t_2); __Pyx_XGIVEREF(__pyx_t_3); __Pyx_ExceptionReset(__pyx_t_1, __pyx_t_2, __pyx_t_3); goto __pyx_L0; __pyx_L6_except_return:; __Pyx_XGIVEREF(__pyx_t_1); __Pyx_XGIVEREF(__pyx_t_2); __Pyx_XGIVEREF(__pyx_t_3); __Pyx_ExceptionReset(__pyx_t_1, __pyx_t_2, __pyx_t_3); goto __pyx_L0; } /* "lupa/_lupa.pyx":1677 * * * cdef int py_enumerate_with_gil(lua_State* L, py_object* py_obj, double start) with gil: # <<<<<<<<<<<<<< * cdef LuaRuntime runtime * try: */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_4); __Pyx_XDECREF(__pyx_t_5); __Pyx_XDECREF(__pyx_t_6); __Pyx_WriteUnraisable("lupa._lupa.py_enumerate_with_gil", __pyx_clineno, __pyx_lineno, __pyx_filename, 1, 0); __pyx_r = 0; __pyx_L0:; __Pyx_XDECREF((PyObject *)__pyx_v_runtime); __Pyx_XDECREF(__pyx_v_obj); __Pyx_RefNannyFinishContext(); #ifdef WITH_THREAD __Pyx_PyGILState_Release(__pyx_gilstate_save); #endif return __pyx_r; } /* "lupa/_lupa.pyx":1687 * finally: return -1 * * cdef int py_iter_with_gil(lua_State* L, py_object* py_obj, int type_flags) with gil: # <<<<<<<<<<<<<< * cdef LuaRuntime runtime * try: */ static int __pyx_f_4lupa_5_lupa_py_iter_with_gil(lua_State *__pyx_v_L, struct __pyx_t_4lupa_5_lupa_py_object *__pyx_v_py_obj, int __pyx_v_type_flags) { struct __pyx_obj_4lupa_5_lupa_LuaRuntime *__pyx_v_runtime = 0; PyObject *__pyx_v_obj = NULL; int __pyx_r; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; PyObject *__pyx_t_2 = NULL; PyObject *__pyx_t_3 = NULL; PyObject *__pyx_t_4 = NULL; PyObject *__pyx_t_5 = NULL; PyObject *__pyx_t_6 = NULL; int __pyx_t_7; PyObject *__pyx_t_8 = NULL; PyObject *__pyx_t_9 = NULL; PyObject *__pyx_t_10 = NULL; PyObject *__pyx_t_11 = NULL; PyObject *__pyx_t_12 = NULL; PyObject *__pyx_t_13 = NULL; #ifdef WITH_THREAD PyGILState_STATE __pyx_gilstate_save = __Pyx_PyGILState_Ensure(); #endif __Pyx_RefNannySetupContext("py_iter_with_gil", 0); /* "lupa/_lupa.pyx":1689 * cdef int py_iter_with_gil(lua_State* L, py_object* py_obj, int type_flags) with gil: * cdef LuaRuntime runtime * try: # <<<<<<<<<<<<<< * runtime = py_obj.runtime * obj = iter(py_obj.obj) */ { __Pyx_PyThreadState_declare __Pyx_PyThreadState_assign __Pyx_ExceptionSave(&__pyx_t_1, &__pyx_t_2, &__pyx_t_3); __Pyx_XGOTREF(__pyx_t_1); __Pyx_XGOTREF(__pyx_t_2); __Pyx_XGOTREF(__pyx_t_3); /*try:*/ { /* "lupa/_lupa.pyx":1690 * cdef LuaRuntime runtime * try: * runtime = py_obj.runtime # <<<<<<<<<<<<<< * obj = iter(py_obj.obj) * return py_push_iterator(runtime, L, obj, type_flags, 0.0) */ __pyx_t_4 = ((PyObject *)__pyx_v_py_obj->runtime); __Pyx_INCREF(__pyx_t_4); __pyx_v_runtime = ((struct __pyx_obj_4lupa_5_lupa_LuaRuntime *)__pyx_t_4); __pyx_t_4 = 0; /* "lupa/_lupa.pyx":1691 * try: * runtime = py_obj.runtime * obj = iter(py_obj.obj) # <<<<<<<<<<<<<< * return py_push_iterator(runtime, L, obj, type_flags, 0.0) * except: */ __pyx_t_4 = ((PyObject *)__pyx_v_py_obj->obj); __Pyx_INCREF(__pyx_t_4); __pyx_t_5 = PyObject_GetIter(__pyx_t_4); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1691, __pyx_L3_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_v_obj = __pyx_t_5; __pyx_t_5 = 0; /* "lupa/_lupa.pyx":1692 * runtime = py_obj.runtime * obj = iter(py_obj.obj) * return py_push_iterator(runtime, L, obj, type_flags, 0.0) # <<<<<<<<<<<<<< * except: * try: runtime.store_raised_exception(L, b'error creating an iterator') */ __pyx_r = __pyx_f_4lupa_5_lupa_py_push_iterator(__pyx_v_runtime, __pyx_v_L, __pyx_v_obj, __pyx_v_type_flags, 0.0); goto __pyx_L7_try_return; /* "lupa/_lupa.pyx":1689 * cdef int py_iter_with_gil(lua_State* L, py_object* py_obj, int type_flags) with gil: * cdef LuaRuntime runtime * try: # <<<<<<<<<<<<<< * runtime = py_obj.runtime * obj = iter(py_obj.obj) */ } __pyx_L3_error:; __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; /* "lupa/_lupa.pyx":1693 * obj = iter(py_obj.obj) * return py_push_iterator(runtime, L, obj, type_flags, 0.0) * except: # <<<<<<<<<<<<<< * try: runtime.store_raised_exception(L, b'error creating an iterator') * finally: return -1 */ /*except:*/ { __Pyx_AddTraceback("lupa._lupa.py_iter_with_gil", __pyx_clineno, __pyx_lineno, __pyx_filename); if (__Pyx_GetException(&__pyx_t_5, &__pyx_t_4, &__pyx_t_6) < 0) __PYX_ERR(0, 1693, __pyx_L5_except_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_GOTREF(__pyx_t_4); __Pyx_GOTREF(__pyx_t_6); /* "lupa/_lupa.pyx":1694 * return py_push_iterator(runtime, L, obj, type_flags, 0.0) * except: * try: runtime.store_raised_exception(L, b'error creating an iterator') # <<<<<<<<<<<<<< * finally: return -1 * */ /*try:*/ { if (unlikely(!__pyx_v_runtime)) { __Pyx_RaiseUnboundLocalError("runtime"); __PYX_ERR(0, 1694, __pyx_L14_error) } __pyx_t_7 = __pyx_f_4lupa_5_lupa_10LuaRuntime_store_raised_exception(__pyx_v_runtime, __pyx_v_L, __pyx_kp_b_error_creating_an_iterator); if (unlikely(__pyx_t_7 == ((int)-1))) __PYX_ERR(0, 1694, __pyx_L14_error) } /* "lupa/_lupa.pyx":1695 * except: * try: runtime.store_raised_exception(L, b'error creating an iterator') * finally: return -1 # <<<<<<<<<<<<<< * * cdef int py_push_iterator(LuaRuntime runtime, lua_State* L, iterator, int type_flags, */ /*finally:*/ { /*normal exit:*/{ __pyx_r = -1; __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; goto __pyx_L6_except_return; } __pyx_L14_error:; /*exception exit:*/{ __Pyx_PyThreadState_declare __Pyx_PyThreadState_assign __pyx_t_8 = 0; __pyx_t_9 = 0; __pyx_t_10 = 0; __pyx_t_11 = 0; __pyx_t_12 = 0; __pyx_t_13 = 0; if (PY_MAJOR_VERSION >= 3) __Pyx_ExceptionSwap(&__pyx_t_11, &__pyx_t_12, &__pyx_t_13); if ((PY_MAJOR_VERSION < 3) || unlikely(__Pyx_GetException(&__pyx_t_8, &__pyx_t_9, &__pyx_t_10) < 0)) __Pyx_ErrFetch(&__pyx_t_8, &__pyx_t_9, &__pyx_t_10); __Pyx_XGOTREF(__pyx_t_8); __Pyx_XGOTREF(__pyx_t_9); __Pyx_XGOTREF(__pyx_t_10); __Pyx_XGOTREF(__pyx_t_11); __Pyx_XGOTREF(__pyx_t_12); __Pyx_XGOTREF(__pyx_t_13); { __pyx_r = -1; __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; goto __pyx_L18_return; } __pyx_L18_return:; if (PY_MAJOR_VERSION >= 3) { __Pyx_XGIVEREF(__pyx_t_11); __Pyx_XGIVEREF(__pyx_t_12); __Pyx_XGIVEREF(__pyx_t_13); __Pyx_ExceptionReset(__pyx_t_11, __pyx_t_12, __pyx_t_13); } __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0; __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0; __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0; __pyx_t_11 = 0; __pyx_t_12 = 0; __pyx_t_13 = 0; goto __pyx_L6_except_return; } } } __pyx_L5_except_error:; /* "lupa/_lupa.pyx":1689 * cdef int py_iter_with_gil(lua_State* L, py_object* py_obj, int type_flags) with gil: * cdef LuaRuntime runtime * try: # <<<<<<<<<<<<<< * runtime = py_obj.runtime * obj = iter(py_obj.obj) */ __Pyx_XGIVEREF(__pyx_t_1); __Pyx_XGIVEREF(__pyx_t_2); __Pyx_XGIVEREF(__pyx_t_3); __Pyx_ExceptionReset(__pyx_t_1, __pyx_t_2, __pyx_t_3); goto __pyx_L1_error; __pyx_L7_try_return:; __Pyx_XGIVEREF(__pyx_t_1); __Pyx_XGIVEREF(__pyx_t_2); __Pyx_XGIVEREF(__pyx_t_3); __Pyx_ExceptionReset(__pyx_t_1, __pyx_t_2, __pyx_t_3); goto __pyx_L0; __pyx_L6_except_return:; __Pyx_XGIVEREF(__pyx_t_1); __Pyx_XGIVEREF(__pyx_t_2); __Pyx_XGIVEREF(__pyx_t_3); __Pyx_ExceptionReset(__pyx_t_1, __pyx_t_2, __pyx_t_3); goto __pyx_L0; } /* "lupa/_lupa.pyx":1687 * finally: return -1 * * cdef int py_iter_with_gil(lua_State* L, py_object* py_obj, int type_flags) with gil: # <<<<<<<<<<<<<< * cdef LuaRuntime runtime * try: */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_4); __Pyx_XDECREF(__pyx_t_5); __Pyx_XDECREF(__pyx_t_6); __Pyx_WriteUnraisable("lupa._lupa.py_iter_with_gil", __pyx_clineno, __pyx_lineno, __pyx_filename, 1, 0); __pyx_r = 0; __pyx_L0:; __Pyx_XDECREF((PyObject *)__pyx_v_runtime); __Pyx_XDECREF(__pyx_v_obj); __Pyx_RefNannyFinishContext(); #ifdef WITH_THREAD __Pyx_PyGILState_Release(__pyx_gilstate_save); #endif return __pyx_r; } /* "lupa/_lupa.pyx":1697 * finally: return -1 * * cdef int py_push_iterator(LuaRuntime runtime, lua_State* L, iterator, int type_flags, # <<<<<<<<<<<<<< * lua.lua_Number initial_value): * # Lua needs three values: iterator C function + state + control variable (last iter) value */ static int __pyx_f_4lupa_5_lupa_py_push_iterator(struct __pyx_obj_4lupa_5_lupa_LuaRuntime *__pyx_v_runtime, lua_State *__pyx_v_L, PyObject *__pyx_v_iterator, int __pyx_v_type_flags, lua_Number __pyx_v_initial_value) { int __pyx_v_old_top; int __pyx_r; __Pyx_RefNannyDeclarations int __pyx_t_1; __Pyx_RefNannySetupContext("py_push_iterator", 0); /* "lupa/_lupa.pyx":1700 * lua.lua_Number initial_value): * # Lua needs three values: iterator C function + state + control variable (last iter) value * old_top = lua.lua_gettop(L) # <<<<<<<<<<<<<< * lua.lua_pushcfunction(L, py_iter_next) * # push the wrapped iterator object as for-loop state object */ __pyx_v_old_top = lua_gettop(__pyx_v_L); /* "lupa/_lupa.pyx":1701 * # Lua needs three values: iterator C function + state + control variable (last iter) value * old_top = lua.lua_gettop(L) * lua.lua_pushcfunction(L, py_iter_next) # <<<<<<<<<<<<<< * # push the wrapped iterator object as for-loop state object * if runtime._unpack_returned_tuples: */ lua_pushcfunction(__pyx_v_L, ((lua_CFunction)__pyx_f_4lupa_5_lupa_py_iter_next)); /* "lupa/_lupa.pyx":1703 * lua.lua_pushcfunction(L, py_iter_next) * # push the wrapped iterator object as for-loop state object * if runtime._unpack_returned_tuples: # <<<<<<<<<<<<<< * type_flags |= OBJ_UNPACK_TUPLE * if py_to_lua_custom(runtime, L, iterator, type_flags) < 1: */ __pyx_t_1 = (__pyx_v_runtime->_unpack_returned_tuples != 0); if (__pyx_t_1) { /* "lupa/_lupa.pyx":1704 * # push the wrapped iterator object as for-loop state object * if runtime._unpack_returned_tuples: * type_flags |= OBJ_UNPACK_TUPLE # <<<<<<<<<<<<<< * if py_to_lua_custom(runtime, L, iterator, type_flags) < 1: * lua.lua_settop(L, old_top) */ __pyx_v_type_flags = (__pyx_v_type_flags | __pyx_e_4lupa_5_lupa_OBJ_UNPACK_TUPLE); /* "lupa/_lupa.pyx":1703 * lua.lua_pushcfunction(L, py_iter_next) * # push the wrapped iterator object as for-loop state object * if runtime._unpack_returned_tuples: # <<<<<<<<<<<<<< * type_flags |= OBJ_UNPACK_TUPLE * if py_to_lua_custom(runtime, L, iterator, type_flags) < 1: */ } /* "lupa/_lupa.pyx":1705 * if runtime._unpack_returned_tuples: * type_flags |= OBJ_UNPACK_TUPLE * if py_to_lua_custom(runtime, L, iterator, type_flags) < 1: # <<<<<<<<<<<<<< * lua.lua_settop(L, old_top) * return -1 */ __pyx_t_1 = ((__pyx_f_4lupa_5_lupa_py_to_lua_custom(__pyx_v_runtime, __pyx_v_L, __pyx_v_iterator, __pyx_v_type_flags) < 1) != 0); if (__pyx_t_1) { /* "lupa/_lupa.pyx":1706 * type_flags |= OBJ_UNPACK_TUPLE * if py_to_lua_custom(runtime, L, iterator, type_flags) < 1: * lua.lua_settop(L, old_top) # <<<<<<<<<<<<<< * return -1 * # push either enumerator index or nil as control variable value */ lua_settop(__pyx_v_L, __pyx_v_old_top); /* "lupa/_lupa.pyx":1707 * if py_to_lua_custom(runtime, L, iterator, type_flags) < 1: * lua.lua_settop(L, old_top) * return -1 # <<<<<<<<<<<<<< * # push either enumerator index or nil as control variable value * if type_flags & OBJ_ENUMERATOR: */ __pyx_r = -1; goto __pyx_L0; /* "lupa/_lupa.pyx":1705 * if runtime._unpack_returned_tuples: * type_flags |= OBJ_UNPACK_TUPLE * if py_to_lua_custom(runtime, L, iterator, type_flags) < 1: # <<<<<<<<<<<<<< * lua.lua_settop(L, old_top) * return -1 */ } /* "lupa/_lupa.pyx":1709 * return -1 * # push either enumerator index or nil as control variable value * if type_flags & OBJ_ENUMERATOR: # <<<<<<<<<<<<<< * lua.lua_pushnumber(L, initial_value) * else: */ __pyx_t_1 = ((__pyx_v_type_flags & __pyx_e_4lupa_5_lupa_OBJ_ENUMERATOR) != 0); if (__pyx_t_1) { /* "lupa/_lupa.pyx":1710 * # push either enumerator index or nil as control variable value * if type_flags & OBJ_ENUMERATOR: * lua.lua_pushnumber(L, initial_value) # <<<<<<<<<<<<<< * else: * lua.lua_pushnil(L) */ lua_pushnumber(__pyx_v_L, __pyx_v_initial_value); /* "lupa/_lupa.pyx":1709 * return -1 * # push either enumerator index or nil as control variable value * if type_flags & OBJ_ENUMERATOR: # <<<<<<<<<<<<<< * lua.lua_pushnumber(L, initial_value) * else: */ goto __pyx_L5; } /* "lupa/_lupa.pyx":1712 * lua.lua_pushnumber(L, initial_value) * else: * lua.lua_pushnil(L) # <<<<<<<<<<<<<< * return 3 * */ /*else*/ { lua_pushnil(__pyx_v_L); } __pyx_L5:; /* "lupa/_lupa.pyx":1713 * else: * lua.lua_pushnil(L) * return 3 # <<<<<<<<<<<<<< * * cdef int py_iter_next(lua_State* L) nogil: */ __pyx_r = 3; goto __pyx_L0; /* "lupa/_lupa.pyx":1697 * finally: return -1 * * cdef int py_push_iterator(LuaRuntime runtime, lua_State* L, iterator, int type_flags, # <<<<<<<<<<<<<< * lua.lua_Number initial_value): * # Lua needs three values: iterator C function + state + control variable (last iter) value */ /* function exit code */ __pyx_L0:; __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "lupa/_lupa.pyx":1715 * return 3 * * cdef int py_iter_next(lua_State* L) nogil: # <<<<<<<<<<<<<< * # first value in the C closure: the Python iterator object * cdef py_object* py_obj = unwrap_lua_object(L, 1) */ static int __pyx_f_4lupa_5_lupa_py_iter_next(lua_State *__pyx_v_L) { struct __pyx_t_4lupa_5_lupa_py_object *__pyx_v_py_obj; int __pyx_v_result; int __pyx_r; int __pyx_t_1; /* "lupa/_lupa.pyx":1717 * cdef int py_iter_next(lua_State* L) nogil: * # first value in the C closure: the Python iterator object * cdef py_object* py_obj = unwrap_lua_object(L, 1) # <<<<<<<<<<<<<< * if not py_obj: * return lua.luaL_argerror(L, 1, "not a python object") # never returns! */ __pyx_v_py_obj = __pyx_f_4lupa_5_lupa_unwrap_lua_object(__pyx_v_L, 1); /* "lupa/_lupa.pyx":1718 * # first value in the C closure: the Python iterator object * cdef py_object* py_obj = unwrap_lua_object(L, 1) * if not py_obj: # <<<<<<<<<<<<<< * return lua.luaL_argerror(L, 1, "not a python object") # never returns! * result = py_iter_next_with_gil(L, py_obj) */ __pyx_t_1 = ((!(__pyx_v_py_obj != 0)) != 0); if (__pyx_t_1) { /* "lupa/_lupa.pyx":1719 * cdef py_object* py_obj = unwrap_lua_object(L, 1) * if not py_obj: * return lua.luaL_argerror(L, 1, "not a python object") # never returns! # <<<<<<<<<<<<<< * result = py_iter_next_with_gil(L, py_obj) * if result < 0: */ __pyx_r = luaL_argerror(__pyx_v_L, 1, ((char *)"not a python object")); goto __pyx_L0; /* "lupa/_lupa.pyx":1718 * # first value in the C closure: the Python iterator object * cdef py_object* py_obj = unwrap_lua_object(L, 1) * if not py_obj: # <<<<<<<<<<<<<< * return lua.luaL_argerror(L, 1, "not a python object") # never returns! * result = py_iter_next_with_gil(L, py_obj) */ } /* "lupa/_lupa.pyx":1720 * if not py_obj: * return lua.luaL_argerror(L, 1, "not a python object") # never returns! * result = py_iter_next_with_gil(L, py_obj) # <<<<<<<<<<<<<< * if result < 0: * return lua.lua_error(L) # never returns! */ __pyx_v_result = __pyx_f_4lupa_5_lupa_py_iter_next_with_gil(__pyx_v_L, __pyx_v_py_obj); /* "lupa/_lupa.pyx":1721 * return lua.luaL_argerror(L, 1, "not a python object") # never returns! * result = py_iter_next_with_gil(L, py_obj) * if result < 0: # <<<<<<<<<<<<<< * return lua.lua_error(L) # never returns! * return result */ __pyx_t_1 = ((__pyx_v_result < 0) != 0); if (__pyx_t_1) { /* "lupa/_lupa.pyx":1722 * result = py_iter_next_with_gil(L, py_obj) * if result < 0: * return lua.lua_error(L) # never returns! # <<<<<<<<<<<<<< * return result * */ __pyx_r = lua_error(__pyx_v_L); goto __pyx_L0; /* "lupa/_lupa.pyx":1721 * return lua.luaL_argerror(L, 1, "not a python object") # never returns! * result = py_iter_next_with_gil(L, py_obj) * if result < 0: # <<<<<<<<<<<<<< * return lua.lua_error(L) # never returns! * return result */ } /* "lupa/_lupa.pyx":1723 * if result < 0: * return lua.lua_error(L) # never returns! * return result # <<<<<<<<<<<<<< * * cdef int py_iter_next_with_gil(lua_State* L, py_object* py_iter) with gil: */ __pyx_r = __pyx_v_result; goto __pyx_L0; /* "lupa/_lupa.pyx":1715 * return 3 * * cdef int py_iter_next(lua_State* L) nogil: # <<<<<<<<<<<<<< * # first value in the C closure: the Python iterator object * cdef py_object* py_obj = unwrap_lua_object(L, 1) */ /* function exit code */ __pyx_L0:; return __pyx_r; } /* "lupa/_lupa.pyx":1725 * return result * * cdef int py_iter_next_with_gil(lua_State* L, py_object* py_iter) with gil: # <<<<<<<<<<<<<< * cdef LuaRuntime runtime * try: */ static int __pyx_f_4lupa_5_lupa_py_iter_next_with_gil(lua_State *__pyx_v_L, struct __pyx_t_4lupa_5_lupa_py_object *__pyx_v_py_iter) { struct __pyx_obj_4lupa_5_lupa_LuaRuntime *__pyx_v_runtime = 0; PyObject *__pyx_v_obj = NULL; int __pyx_v_allow_nil; PyObject *__pyx_v_result = NULL; int __pyx_r; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; PyObject *__pyx_t_2 = NULL; PyObject *__pyx_t_3 = NULL; PyObject *__pyx_t_4 = NULL; PyObject *__pyx_t_5 = NULL; PyObject *__pyx_t_6 = NULL; PyObject *__pyx_t_7 = NULL; PyObject *__pyx_t_8 = NULL; int __pyx_t_9; PyObject *__pyx_t_10 = NULL; int __pyx_t_11; int __pyx_t_12; int __pyx_t_13; struct __pyx_opt_args_4lupa_5_lupa_push_lua_arguments __pyx_t_14; Py_ssize_t __pyx_t_15; struct __pyx_opt_args_4lupa_5_lupa_py_to_lua __pyx_t_16; PyObject *__pyx_t_17 = NULL; PyObject *__pyx_t_18 = NULL; PyObject *__pyx_t_19 = NULL; #ifdef WITH_THREAD PyGILState_STATE __pyx_gilstate_save = __Pyx_PyGILState_Ensure(); #endif __Pyx_RefNannySetupContext("py_iter_next_with_gil", 0); /* "lupa/_lupa.pyx":1727 * cdef int py_iter_next_with_gil(lua_State* L, py_object* py_iter) with gil: * cdef LuaRuntime runtime * try: # <<<<<<<<<<<<<< * runtime = py_iter.runtime * try: */ { __Pyx_PyThreadState_declare __Pyx_PyThreadState_assign __Pyx_ExceptionSave(&__pyx_t_1, &__pyx_t_2, &__pyx_t_3); __Pyx_XGOTREF(__pyx_t_1); __Pyx_XGOTREF(__pyx_t_2); __Pyx_XGOTREF(__pyx_t_3); /*try:*/ { /* "lupa/_lupa.pyx":1728 * cdef LuaRuntime runtime * try: * runtime = py_iter.runtime # <<<<<<<<<<<<<< * try: * obj = next(py_iter.obj) */ __pyx_t_4 = ((PyObject *)__pyx_v_py_iter->runtime); __Pyx_INCREF(__pyx_t_4); __pyx_v_runtime = ((struct __pyx_obj_4lupa_5_lupa_LuaRuntime *)__pyx_t_4); __pyx_t_4 = 0; /* "lupa/_lupa.pyx":1729 * try: * runtime = py_iter.runtime * try: # <<<<<<<<<<<<<< * obj = next(py_iter.obj) * except StopIteration: */ { __Pyx_PyThreadState_declare __Pyx_PyThreadState_assign __Pyx_ExceptionSave(&__pyx_t_5, &__pyx_t_6, &__pyx_t_7); __Pyx_XGOTREF(__pyx_t_5); __Pyx_XGOTREF(__pyx_t_6); __Pyx_XGOTREF(__pyx_t_7); /*try:*/ { /* "lupa/_lupa.pyx":1730 * runtime = py_iter.runtime * try: * obj = next(py_iter.obj) # <<<<<<<<<<<<<< * except StopIteration: * lua.lua_pushnil(L) */ __pyx_t_4 = ((PyObject *)__pyx_v_py_iter->obj); __Pyx_INCREF(__pyx_t_4); __pyx_t_8 = __Pyx_PyIter_Next(__pyx_t_4); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 1730, __pyx_L9_error) __Pyx_GOTREF(__pyx_t_8); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_v_obj = __pyx_t_8; __pyx_t_8 = 0; /* "lupa/_lupa.pyx":1729 * try: * runtime = py_iter.runtime * try: # <<<<<<<<<<<<<< * obj = next(py_iter.obj) * except StopIteration: */ } __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0; goto __pyx_L14_try_end; __pyx_L9_error:; __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0; /* "lupa/_lupa.pyx":1731 * try: * obj = next(py_iter.obj) * except StopIteration: # <<<<<<<<<<<<<< * lua.lua_pushnil(L) * return 1 */ __pyx_t_9 = __Pyx_PyErr_ExceptionMatches(__pyx_builtin_StopIteration); if (__pyx_t_9) { __Pyx_AddTraceback("lupa._lupa.py_iter_next_with_gil", __pyx_clineno, __pyx_lineno, __pyx_filename); if (__Pyx_GetException(&__pyx_t_8, &__pyx_t_4, &__pyx_t_10) < 0) __PYX_ERR(0, 1731, __pyx_L11_except_error) __Pyx_GOTREF(__pyx_t_8); __Pyx_GOTREF(__pyx_t_4); __Pyx_GOTREF(__pyx_t_10); /* "lupa/_lupa.pyx":1732 * obj = next(py_iter.obj) * except StopIteration: * lua.lua_pushnil(L) # <<<<<<<<<<<<<< * return 1 * */ lua_pushnil(__pyx_v_L); /* "lupa/_lupa.pyx":1733 * except StopIteration: * lua.lua_pushnil(L) * return 1 # <<<<<<<<<<<<<< * * # NOTE: cannot return nil for None as first item */ __pyx_r = 1; __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; goto __pyx_L12_except_return; } goto __pyx_L11_except_error; __pyx_L11_except_error:; /* "lupa/_lupa.pyx":1729 * try: * runtime = py_iter.runtime * try: # <<<<<<<<<<<<<< * obj = next(py_iter.obj) * except StopIteration: */ __Pyx_XGIVEREF(__pyx_t_5); __Pyx_XGIVEREF(__pyx_t_6); __Pyx_XGIVEREF(__pyx_t_7); __Pyx_ExceptionReset(__pyx_t_5, __pyx_t_6, __pyx_t_7); goto __pyx_L3_error; __pyx_L12_except_return:; __Pyx_XGIVEREF(__pyx_t_5); __Pyx_XGIVEREF(__pyx_t_6); __Pyx_XGIVEREF(__pyx_t_7); __Pyx_ExceptionReset(__pyx_t_5, __pyx_t_6, __pyx_t_7); goto __pyx_L7_try_return; __pyx_L14_try_end:; } /* "lupa/_lupa.pyx":1737 * # NOTE: cannot return nil for None as first item * # as Lua interprets it as end of the iterator * allow_nil = False # <<<<<<<<<<<<<< * if py_iter.type_flags & OBJ_ENUMERATOR: * lua.lua_pushnumber(L, lua.lua_tonumber(L, -1) + 1.0) */ __pyx_v_allow_nil = 0; /* "lupa/_lupa.pyx":1738 * # as Lua interprets it as end of the iterator * allow_nil = False * if py_iter.type_flags & OBJ_ENUMERATOR: # <<<<<<<<<<<<<< * lua.lua_pushnumber(L, lua.lua_tonumber(L, -1) + 1.0) * allow_nil = True */ __pyx_t_11 = ((__pyx_v_py_iter->type_flags & __pyx_e_4lupa_5_lupa_OBJ_ENUMERATOR) != 0); if (__pyx_t_11) { /* "lupa/_lupa.pyx":1739 * allow_nil = False * if py_iter.type_flags & OBJ_ENUMERATOR: * lua.lua_pushnumber(L, lua.lua_tonumber(L, -1) + 1.0) # <<<<<<<<<<<<<< * allow_nil = True * if (py_iter.type_flags & OBJ_UNPACK_TUPLE) and isinstance(obj, tuple): */ lua_pushnumber(__pyx_v_L, (lua_tonumber(__pyx_v_L, -1) + 1.0)); /* "lupa/_lupa.pyx":1740 * if py_iter.type_flags & OBJ_ENUMERATOR: * lua.lua_pushnumber(L, lua.lua_tonumber(L, -1) + 1.0) * allow_nil = True # <<<<<<<<<<<<<< * if (py_iter.type_flags & OBJ_UNPACK_TUPLE) and isinstance(obj, tuple): * # special case: when the iterable returns a tuple, unpack it */ __pyx_v_allow_nil = 1; /* "lupa/_lupa.pyx":1738 * # as Lua interprets it as end of the iterator * allow_nil = False * if py_iter.type_flags & OBJ_ENUMERATOR: # <<<<<<<<<<<<<< * lua.lua_pushnumber(L, lua.lua_tonumber(L, -1) + 1.0) * allow_nil = True */ } /* "lupa/_lupa.pyx":1741 * lua.lua_pushnumber(L, lua.lua_tonumber(L, -1) + 1.0) * allow_nil = True * if (py_iter.type_flags & OBJ_UNPACK_TUPLE) and isinstance(obj, tuple): # <<<<<<<<<<<<<< * # special case: when the iterable returns a tuple, unpack it * push_lua_arguments(runtime, L, obj, first_may_be_nil=allow_nil) */ __pyx_t_12 = ((__pyx_v_py_iter->type_flags & __pyx_e_4lupa_5_lupa_OBJ_UNPACK_TUPLE) != 0); if (__pyx_t_12) { } else { __pyx_t_11 = __pyx_t_12; goto __pyx_L19_bool_binop_done; } __pyx_t_12 = PyTuple_Check(__pyx_v_obj); __pyx_t_13 = (__pyx_t_12 != 0); __pyx_t_11 = __pyx_t_13; __pyx_L19_bool_binop_done:; if (__pyx_t_11) { /* "lupa/_lupa.pyx":1743 * 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, obj, first_may_be_nil=allow_nil) # <<<<<<<<<<<<<< * result = len(obj) * else: */ __pyx_t_14.__pyx_n = 1; __pyx_t_14.first_may_be_nil = __pyx_v_allow_nil; __pyx_t_9 = __pyx_f_4lupa_5_lupa_push_lua_arguments(__pyx_v_runtime, __pyx_v_L, ((PyObject*)__pyx_v_obj), &__pyx_t_14); if (unlikely(__pyx_t_9 == ((int)-1))) __PYX_ERR(0, 1743, __pyx_L3_error) /* "lupa/_lupa.pyx":1744 * # special case: when the iterable returns a tuple, unpack it * push_lua_arguments(runtime, L, obj, first_may_be_nil=allow_nil) * result = len(obj) # <<<<<<<<<<<<<< * else: * result = py_to_lua(runtime, L, obj, wrap_none=not allow_nil) */ if (unlikely(__pyx_v_obj == Py_None)) { PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()"); __PYX_ERR(0, 1744, __pyx_L3_error) } __pyx_t_15 = PyTuple_GET_SIZE(((PyObject*)__pyx_v_obj)); if (unlikely(__pyx_t_15 == ((Py_ssize_t)-1))) __PYX_ERR(0, 1744, __pyx_L3_error) __pyx_t_10 = PyInt_FromSsize_t(__pyx_t_15); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 1744, __pyx_L3_error) __Pyx_GOTREF(__pyx_t_10); __pyx_v_result = __pyx_t_10; __pyx_t_10 = 0; /* "lupa/_lupa.pyx":1741 * lua.lua_pushnumber(L, lua.lua_tonumber(L, -1) + 1.0) * allow_nil = True * if (py_iter.type_flags & OBJ_UNPACK_TUPLE) and isinstance(obj, tuple): # <<<<<<<<<<<<<< * # special case: when the iterable returns a tuple, unpack it * push_lua_arguments(runtime, L, obj, first_may_be_nil=allow_nil) */ goto __pyx_L18; } /* "lupa/_lupa.pyx":1746 * result = len(obj) * else: * result = py_to_lua(runtime, L, obj, wrap_none=not allow_nil) # <<<<<<<<<<<<<< * if result < 1: * return -1 */ /*else*/ { __pyx_t_16.__pyx_n = 1; __pyx_t_16.wrap_none = (!(__pyx_v_allow_nil != 0)); __pyx_t_9 = __pyx_f_4lupa_5_lupa_py_to_lua(__pyx_v_runtime, __pyx_v_L, __pyx_v_obj, &__pyx_t_16); if (unlikely(__pyx_t_9 == ((int)-1))) __PYX_ERR(0, 1746, __pyx_L3_error) __pyx_t_10 = __Pyx_PyInt_From_int(__pyx_t_9); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 1746, __pyx_L3_error) __Pyx_GOTREF(__pyx_t_10); __pyx_v_result = __pyx_t_10; __pyx_t_10 = 0; /* "lupa/_lupa.pyx":1747 * else: * result = py_to_lua(runtime, L, obj, wrap_none=not allow_nil) * if result < 1: # <<<<<<<<<<<<<< * return -1 * if py_iter.type_flags & OBJ_ENUMERATOR: */ __pyx_t_10 = PyObject_RichCompare(__pyx_v_result, __pyx_int_1, Py_LT); __Pyx_XGOTREF(__pyx_t_10); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 1747, __pyx_L3_error) __pyx_t_11 = __Pyx_PyObject_IsTrue(__pyx_t_10); if (unlikely(__pyx_t_11 < 0)) __PYX_ERR(0, 1747, __pyx_L3_error) __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; if (__pyx_t_11) { /* "lupa/_lupa.pyx":1748 * result = py_to_lua(runtime, L, obj, wrap_none=not allow_nil) * if result < 1: * return -1 # <<<<<<<<<<<<<< * if py_iter.type_flags & OBJ_ENUMERATOR: * result += 1 */ __pyx_r = -1; goto __pyx_L7_try_return; /* "lupa/_lupa.pyx":1747 * else: * result = py_to_lua(runtime, L, obj, wrap_none=not allow_nil) * if result < 1: # <<<<<<<<<<<<<< * return -1 * if py_iter.type_flags & OBJ_ENUMERATOR: */ } } __pyx_L18:; /* "lupa/_lupa.pyx":1749 * if result < 1: * return -1 * if py_iter.type_flags & OBJ_ENUMERATOR: # <<<<<<<<<<<<<< * result += 1 * return result */ __pyx_t_11 = ((__pyx_v_py_iter->type_flags & __pyx_e_4lupa_5_lupa_OBJ_ENUMERATOR) != 0); if (__pyx_t_11) { /* "lupa/_lupa.pyx":1750 * return -1 * if py_iter.type_flags & OBJ_ENUMERATOR: * result += 1 # <<<<<<<<<<<<<< * return result * except: */ __pyx_t_10 = __Pyx_PyInt_AddObjC(__pyx_v_result, __pyx_int_1, 1, 1); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 1750, __pyx_L3_error) __Pyx_GOTREF(__pyx_t_10); __Pyx_DECREF_SET(__pyx_v_result, __pyx_t_10); __pyx_t_10 = 0; /* "lupa/_lupa.pyx":1749 * if result < 1: * return -1 * if py_iter.type_flags & OBJ_ENUMERATOR: # <<<<<<<<<<<<<< * result += 1 * return result */ } /* "lupa/_lupa.pyx":1751 * if py_iter.type_flags & OBJ_ENUMERATOR: * result += 1 * return result # <<<<<<<<<<<<<< * except: * try: runtime.store_raised_exception(L, b'error while calling next(iterator)') */ __pyx_t_9 = __Pyx_PyInt_As_int(__pyx_v_result); if (unlikely((__pyx_t_9 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 1751, __pyx_L3_error) __pyx_r = __pyx_t_9; goto __pyx_L7_try_return; /* "lupa/_lupa.pyx":1727 * cdef int py_iter_next_with_gil(lua_State* L, py_object* py_iter) with gil: * cdef LuaRuntime runtime * try: # <<<<<<<<<<<<<< * runtime = py_iter.runtime * try: */ } __pyx_L3_error:; __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0; __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0; /* "lupa/_lupa.pyx":1752 * result += 1 * return result * except: # <<<<<<<<<<<<<< * try: runtime.store_raised_exception(L, b'error while calling next(iterator)') * finally: return -1 */ /*except:*/ { __Pyx_AddTraceback("lupa._lupa.py_iter_next_with_gil", __pyx_clineno, __pyx_lineno, __pyx_filename); if (__Pyx_GetException(&__pyx_t_10, &__pyx_t_4, &__pyx_t_8) < 0) __PYX_ERR(0, 1752, __pyx_L5_except_error) __Pyx_GOTREF(__pyx_t_10); __Pyx_GOTREF(__pyx_t_4); __Pyx_GOTREF(__pyx_t_8); /* "lupa/_lupa.pyx":1753 * return result * except: * try: runtime.store_raised_exception(L, b'error while calling next(iterator)') # <<<<<<<<<<<<<< * finally: return -1 * */ /*try:*/ { if (unlikely(!__pyx_v_runtime)) { __Pyx_RaiseUnboundLocalError("runtime"); __PYX_ERR(0, 1753, __pyx_L28_error) } __pyx_t_9 = __pyx_f_4lupa_5_lupa_10LuaRuntime_store_raised_exception(__pyx_v_runtime, __pyx_v_L, __pyx_kp_b_error_while_calling_next_iterato); if (unlikely(__pyx_t_9 == ((int)-1))) __PYX_ERR(0, 1753, __pyx_L28_error) } /* "lupa/_lupa.pyx":1754 * except: * try: runtime.store_raised_exception(L, b'error while calling next(iterator)') * finally: return -1 # <<<<<<<<<<<<<< * * # 'python' module functions in Lua */ /*finally:*/ { /*normal exit:*/{ __pyx_r = -1; __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; goto __pyx_L6_except_return; } __pyx_L28_error:; /*exception exit:*/{ __Pyx_PyThreadState_declare __Pyx_PyThreadState_assign __pyx_t_7 = 0; __pyx_t_6 = 0; __pyx_t_5 = 0; __pyx_t_17 = 0; __pyx_t_18 = 0; __pyx_t_19 = 0; if (PY_MAJOR_VERSION >= 3) __Pyx_ExceptionSwap(&__pyx_t_17, &__pyx_t_18, &__pyx_t_19); if ((PY_MAJOR_VERSION < 3) || unlikely(__Pyx_GetException(&__pyx_t_7, &__pyx_t_6, &__pyx_t_5) < 0)) __Pyx_ErrFetch(&__pyx_t_7, &__pyx_t_6, &__pyx_t_5); __Pyx_XGOTREF(__pyx_t_7); __Pyx_XGOTREF(__pyx_t_6); __Pyx_XGOTREF(__pyx_t_5); __Pyx_XGOTREF(__pyx_t_17); __Pyx_XGOTREF(__pyx_t_18); __Pyx_XGOTREF(__pyx_t_19); { __pyx_r = -1; __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; goto __pyx_L32_return; } __pyx_L32_return:; if (PY_MAJOR_VERSION >= 3) { __Pyx_XGIVEREF(__pyx_t_17); __Pyx_XGIVEREF(__pyx_t_18); __Pyx_XGIVEREF(__pyx_t_19); __Pyx_ExceptionReset(__pyx_t_17, __pyx_t_18, __pyx_t_19); } __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0; __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; __pyx_t_17 = 0; __pyx_t_18 = 0; __pyx_t_19 = 0; goto __pyx_L6_except_return; } } } __pyx_L5_except_error:; /* "lupa/_lupa.pyx":1727 * cdef int py_iter_next_with_gil(lua_State* L, py_object* py_iter) with gil: * cdef LuaRuntime runtime * try: # <<<<<<<<<<<<<< * runtime = py_iter.runtime * try: */ __Pyx_XGIVEREF(__pyx_t_1); __Pyx_XGIVEREF(__pyx_t_2); __Pyx_XGIVEREF(__pyx_t_3); __Pyx_ExceptionReset(__pyx_t_1, __pyx_t_2, __pyx_t_3); goto __pyx_L1_error; __pyx_L7_try_return:; __Pyx_XGIVEREF(__pyx_t_1); __Pyx_XGIVEREF(__pyx_t_2); __Pyx_XGIVEREF(__pyx_t_3); __Pyx_ExceptionReset(__pyx_t_1, __pyx_t_2, __pyx_t_3); goto __pyx_L0; __pyx_L6_except_return:; __Pyx_XGIVEREF(__pyx_t_1); __Pyx_XGIVEREF(__pyx_t_2); __Pyx_XGIVEREF(__pyx_t_3); __Pyx_ExceptionReset(__pyx_t_1, __pyx_t_2, __pyx_t_3); goto __pyx_L0; } /* "lupa/_lupa.pyx":1725 * return result * * cdef int py_iter_next_with_gil(lua_State* L, py_object* py_iter) with gil: # <<<<<<<<<<<<<< * cdef LuaRuntime runtime * try: */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_4); __Pyx_XDECREF(__pyx_t_8); __Pyx_XDECREF(__pyx_t_10); __Pyx_WriteUnraisable("lupa._lupa.py_iter_next_with_gil", __pyx_clineno, __pyx_lineno, __pyx_filename, 1, 0); __pyx_r = 0; __pyx_L0:; __Pyx_XDECREF((PyObject *)__pyx_v_runtime); __Pyx_XDECREF(__pyx_v_obj); __Pyx_XDECREF(__pyx_v_result); __Pyx_RefNannyFinishContext(); #ifdef WITH_THREAD __Pyx_PyGILState_Release(__pyx_gilstate_save); #endif return __pyx_r; } /* "lupa/_lupa.pyx":1770 * # Setup helpers for library tables (removed from C-API in Lua 5.3). * * cdef void luaL_setfuncs(lua_State *L, const lua.luaL_Reg *l, int nup): # <<<<<<<<<<<<<< * cdef int i * lua.luaL_checkstack(L, nup, "too many upvalues") */ static void __pyx_f_4lupa_5_lupa_luaL_setfuncs(lua_State *__pyx_v_L, luaL_Reg const *__pyx_v_l, int __pyx_v_nup) { CYTHON_UNUSED int __pyx_v_i; __Pyx_RefNannyDeclarations int __pyx_t_1; int __pyx_t_2; int __pyx_t_3; __Pyx_RefNannySetupContext("luaL_setfuncs", 0); /* "lupa/_lupa.pyx":1772 * cdef void luaL_setfuncs(lua_State *L, const lua.luaL_Reg *l, int nup): * cdef int i * lua.luaL_checkstack(L, nup, "too many upvalues") # <<<<<<<<<<<<<< * while l.name != NULL: * for i in range(nup): */ luaL_checkstack(__pyx_v_L, __pyx_v_nup, ((char *)"too many upvalues")); /* "lupa/_lupa.pyx":1773 * cdef int i * lua.luaL_checkstack(L, nup, "too many upvalues") * while l.name != NULL: # <<<<<<<<<<<<<< * for i in range(nup): * lua.lua_pushvalue(L, -nup) */ while (1) { __pyx_t_1 = ((__pyx_v_l->name != NULL) != 0); if (!__pyx_t_1) break; /* "lupa/_lupa.pyx":1774 * lua.luaL_checkstack(L, nup, "too many upvalues") * while l.name != NULL: * for i in range(nup): # <<<<<<<<<<<<<< * lua.lua_pushvalue(L, -nup) * lua.lua_pushcclosure(L, l.func, nup) */ __pyx_t_2 = __pyx_v_nup; for (__pyx_t_3 = 0; __pyx_t_3 < __pyx_t_2; __pyx_t_3+=1) { __pyx_v_i = __pyx_t_3; /* "lupa/_lupa.pyx":1775 * while l.name != NULL: * for i in range(nup): * lua.lua_pushvalue(L, -nup) # <<<<<<<<<<<<<< * lua.lua_pushcclosure(L, l.func, nup) * lua.lua_setfield(L, -(nup + 2), l.name) */ lua_pushvalue(__pyx_v_L, (-__pyx_v_nup)); } /* "lupa/_lupa.pyx":1776 * for i in range(nup): * lua.lua_pushvalue(L, -nup) * lua.lua_pushcclosure(L, l.func, nup) # <<<<<<<<<<<<<< * lua.lua_setfield(L, -(nup + 2), l.name) * l += 1 */ lua_pushcclosure(__pyx_v_L, __pyx_v_l->func, __pyx_v_nup); /* "lupa/_lupa.pyx":1777 * lua.lua_pushvalue(L, -nup) * lua.lua_pushcclosure(L, l.func, nup) * lua.lua_setfield(L, -(nup + 2), l.name) # <<<<<<<<<<<<<< * l += 1 * lua.lua_pop(L, nup) */ lua_setfield(__pyx_v_L, (-(__pyx_v_nup + 2)), __pyx_v_l->name); /* "lupa/_lupa.pyx":1778 * lua.lua_pushcclosure(L, l.func, nup) * lua.lua_setfield(L, -(nup + 2), l.name) * l += 1 # <<<<<<<<<<<<<< * lua.lua_pop(L, nup) * */ __pyx_v_l = (__pyx_v_l + 1); } /* "lupa/_lupa.pyx":1779 * lua.lua_setfield(L, -(nup + 2), l.name) * l += 1 * lua.lua_pop(L, nup) # <<<<<<<<<<<<<< * * */ lua_pop(__pyx_v_L, __pyx_v_nup); /* "lupa/_lupa.pyx":1770 * # Setup helpers for library tables (removed from C-API in Lua 5.3). * * cdef void luaL_setfuncs(lua_State *L, const lua.luaL_Reg *l, int nup): # <<<<<<<<<<<<<< * cdef int i * lua.luaL_checkstack(L, nup, "too many upvalues") */ /* function exit code */ __Pyx_RefNannyFinishContext(); } /* "lupa/_lupa.pyx":1782 * * * cdef int libsize(const lua.luaL_Reg *l): # <<<<<<<<<<<<<< * cdef int size = 0 * while l and l.name: */ static int __pyx_f_4lupa_5_lupa_libsize(luaL_Reg const *__pyx_v_l) { int __pyx_v_size; int __pyx_r; __Pyx_RefNannyDeclarations int __pyx_t_1; int __pyx_t_2; __Pyx_RefNannySetupContext("libsize", 0); /* "lupa/_lupa.pyx":1783 * * cdef int libsize(const lua.luaL_Reg *l): * cdef int size = 0 # <<<<<<<<<<<<<< * while l and l.name: * l += 1 */ __pyx_v_size = 0; /* "lupa/_lupa.pyx":1784 * cdef int libsize(const lua.luaL_Reg *l): * cdef int size = 0 * while l and l.name: # <<<<<<<<<<<<<< * l += 1 * size += 1 */ while (1) { __pyx_t_2 = (__pyx_v_l != 0); if (__pyx_t_2) { } else { __pyx_t_1 = __pyx_t_2; goto __pyx_L5_bool_binop_done; } __pyx_t_2 = (__pyx_v_l->name != 0); __pyx_t_1 = __pyx_t_2; __pyx_L5_bool_binop_done:; if (!__pyx_t_1) break; /* "lupa/_lupa.pyx":1785 * cdef int size = 0 * while l and l.name: * l += 1 # <<<<<<<<<<<<<< * size += 1 * return size */ __pyx_v_l = (__pyx_v_l + 1); /* "lupa/_lupa.pyx":1786 * while l and l.name: * l += 1 * size += 1 # <<<<<<<<<<<<<< * return size * */ __pyx_v_size = (__pyx_v_size + 1); } /* "lupa/_lupa.pyx":1787 * l += 1 * size += 1 * return size # <<<<<<<<<<<<<< * * */ __pyx_r = __pyx_v_size; goto __pyx_L0; /* "lupa/_lupa.pyx":1782 * * * cdef int libsize(const lua.luaL_Reg *l): # <<<<<<<<<<<<<< * cdef int size = 0 * while l and l.name: */ /* function exit code */ __pyx_L0:; __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "lupa/_lupa.pyx":1790 * * * cdef const char *luaL_findtable(lua_State *L, int idx, # <<<<<<<<<<<<<< * const char *fname, int size_hint): * cdef const char *end */ static char const *__pyx_f_4lupa_5_lupa_luaL_findtable(lua_State *__pyx_v_L, int __pyx_v_idx, char const *__pyx_v_fname, int __pyx_v_size_hint) { char const *__pyx_v_end; char const *__pyx_r; __Pyx_RefNannyDeclarations int __pyx_t_1; int __pyx_t_2; __Pyx_RefNannySetupContext("luaL_findtable", 0); /* "lupa/_lupa.pyx":1793 * const char *fname, int size_hint): * cdef const char *end * if idx: # <<<<<<<<<<<<<< * lua.lua_pushvalue(L, idx) * */ __pyx_t_1 = (__pyx_v_idx != 0); if (__pyx_t_1) { /* "lupa/_lupa.pyx":1794 * cdef const char *end * if idx: * lua.lua_pushvalue(L, idx) # <<<<<<<<<<<<<< * * while True: */ lua_pushvalue(__pyx_v_L, __pyx_v_idx); /* "lupa/_lupa.pyx":1793 * const char *fname, int size_hint): * cdef const char *end * if idx: # <<<<<<<<<<<<<< * lua.lua_pushvalue(L, idx) * */ } /* "lupa/_lupa.pyx":1796 * lua.lua_pushvalue(L, idx) * * while True: # <<<<<<<<<<<<<< * end = strchr(fname, '.') * if end == NULL: */ while (1) { /* "lupa/_lupa.pyx":1797 * * while True: * end = strchr(fname, '.') # <<<<<<<<<<<<<< * if end == NULL: * end = fname + strlen(fname) */ __pyx_v_end = strchr(__pyx_v_fname, '.'); /* "lupa/_lupa.pyx":1798 * while True: * end = strchr(fname, '.') * if end == NULL: # <<<<<<<<<<<<<< * end = fname + strlen(fname) * lua.lua_pushlstring(L, fname, end - fname) */ __pyx_t_1 = ((__pyx_v_end == NULL) != 0); if (__pyx_t_1) { /* "lupa/_lupa.pyx":1799 * end = strchr(fname, '.') * if end == NULL: * end = fname + strlen(fname) # <<<<<<<<<<<<<< * lua.lua_pushlstring(L, fname, end - fname) * lua.lua_rawget(L, -2) */ __pyx_v_end = (__pyx_v_fname + strlen(__pyx_v_fname)); /* "lupa/_lupa.pyx":1798 * while True: * end = strchr(fname, '.') * if end == NULL: # <<<<<<<<<<<<<< * end = fname + strlen(fname) * lua.lua_pushlstring(L, fname, end - fname) */ } /* "lupa/_lupa.pyx":1800 * if end == NULL: * end = fname + strlen(fname) * lua.lua_pushlstring(L, fname, end - fname) # <<<<<<<<<<<<<< * lua.lua_rawget(L, -2) * if lua.lua_type(L, -1) == lua.LUA_TNIL: */ lua_pushlstring(__pyx_v_L, __pyx_v_fname, (__pyx_v_end - __pyx_v_fname)); /* "lupa/_lupa.pyx":1801 * end = fname + strlen(fname) * lua.lua_pushlstring(L, fname, end - fname) * lua.lua_rawget(L, -2) # <<<<<<<<<<<<<< * if lua.lua_type(L, -1) == lua.LUA_TNIL: * lua.lua_pop(L, 1) */ lua_rawget(__pyx_v_L, -2); /* "lupa/_lupa.pyx":1802 * lua.lua_pushlstring(L, fname, end - fname) * lua.lua_rawget(L, -2) * if lua.lua_type(L, -1) == lua.LUA_TNIL: # <<<<<<<<<<<<<< * lua.lua_pop(L, 1) * lua.lua_createtable(L, 0, (1 if end[0] == '.' else size_hint)) */ __pyx_t_1 = ((lua_type(__pyx_v_L, -1) == LUA_TNIL) != 0); if (__pyx_t_1) { /* "lupa/_lupa.pyx":1803 * lua.lua_rawget(L, -2) * if lua.lua_type(L, -1) == lua.LUA_TNIL: * lua.lua_pop(L, 1) # <<<<<<<<<<<<<< * lua.lua_createtable(L, 0, (1 if end[0] == '.' else size_hint)) * lua.lua_pushlstring(L, fname, end - fname) */ lua_pop(__pyx_v_L, 1); /* "lupa/_lupa.pyx":1804 * if lua.lua_type(L, -1) == lua.LUA_TNIL: * lua.lua_pop(L, 1) * lua.lua_createtable(L, 0, (1 if end[0] == '.' else size_hint)) # <<<<<<<<<<<<<< * lua.lua_pushlstring(L, fname, end - fname) * lua.lua_pushvalue(L, -2) */ if ((((__pyx_v_end[0]) == '.') != 0)) { __pyx_t_2 = 1; } else { __pyx_t_2 = __pyx_v_size_hint; } lua_createtable(__pyx_v_L, 0, __pyx_t_2); /* "lupa/_lupa.pyx":1805 * lua.lua_pop(L, 1) * lua.lua_createtable(L, 0, (1 if end[0] == '.' else size_hint)) * lua.lua_pushlstring(L, fname, end - fname) # <<<<<<<<<<<<<< * lua.lua_pushvalue(L, -2) * lua.lua_settable(L, -4) */ lua_pushlstring(__pyx_v_L, __pyx_v_fname, (__pyx_v_end - __pyx_v_fname)); /* "lupa/_lupa.pyx":1806 * lua.lua_createtable(L, 0, (1 if end[0] == '.' else size_hint)) * lua.lua_pushlstring(L, fname, end - fname) * lua.lua_pushvalue(L, -2) # <<<<<<<<<<<<<< * lua.lua_settable(L, -4) * elif not lua.lua_istable(L, -1): */ lua_pushvalue(__pyx_v_L, -2); /* "lupa/_lupa.pyx":1807 * lua.lua_pushlstring(L, fname, end - fname) * lua.lua_pushvalue(L, -2) * lua.lua_settable(L, -4) # <<<<<<<<<<<<<< * elif not lua.lua_istable(L, -1): * lua.lua_pop(L, 2) */ lua_settable(__pyx_v_L, -4); /* "lupa/_lupa.pyx":1802 * lua.lua_pushlstring(L, fname, end - fname) * lua.lua_rawget(L, -2) * if lua.lua_type(L, -1) == lua.LUA_TNIL: # <<<<<<<<<<<<<< * lua.lua_pop(L, 1) * lua.lua_createtable(L, 0, (1 if end[0] == '.' else size_hint)) */ goto __pyx_L7; } /* "lupa/_lupa.pyx":1808 * lua.lua_pushvalue(L, -2) * lua.lua_settable(L, -4) * elif not lua.lua_istable(L, -1): # <<<<<<<<<<<<<< * lua.lua_pop(L, 2) * return fname */ __pyx_t_1 = ((!(lua_istable(__pyx_v_L, -1) != 0)) != 0); if (__pyx_t_1) { /* "lupa/_lupa.pyx":1809 * lua.lua_settable(L, -4) * elif not lua.lua_istable(L, -1): * lua.lua_pop(L, 2) # <<<<<<<<<<<<<< * return fname * lua.lua_remove(L, -2) */ lua_pop(__pyx_v_L, 2); /* "lupa/_lupa.pyx":1810 * elif not lua.lua_istable(L, -1): * lua.lua_pop(L, 2) * return fname # <<<<<<<<<<<<<< * lua.lua_remove(L, -2) * fname = end + 1 */ __pyx_r = __pyx_v_fname; goto __pyx_L0; /* "lupa/_lupa.pyx":1808 * lua.lua_pushvalue(L, -2) * lua.lua_settable(L, -4) * elif not lua.lua_istable(L, -1): # <<<<<<<<<<<<<< * lua.lua_pop(L, 2) * return fname */ } __pyx_L7:; /* "lupa/_lupa.pyx":1811 * lua.lua_pop(L, 2) * return fname * lua.lua_remove(L, -2) # <<<<<<<<<<<<<< * fname = end + 1 * if end[0] != '.': */ lua_remove(__pyx_v_L, -2); /* "lupa/_lupa.pyx":1812 * return fname * lua.lua_remove(L, -2) * fname = end + 1 # <<<<<<<<<<<<<< * if end[0] != '.': * break */ __pyx_v_fname = (__pyx_v_end + 1); /* "lupa/_lupa.pyx":1813 * lua.lua_remove(L, -2) * fname = end + 1 * if end[0] != '.': # <<<<<<<<<<<<<< * break * return NULL */ __pyx_t_1 = (((__pyx_v_end[0]) != '.') != 0); if (__pyx_t_1) { /* "lupa/_lupa.pyx":1814 * fname = end + 1 * if end[0] != '.': * break # <<<<<<<<<<<<<< * return NULL * */ goto __pyx_L5_break; /* "lupa/_lupa.pyx":1813 * lua.lua_remove(L, -2) * fname = end + 1 * if end[0] != '.': # <<<<<<<<<<<<<< * break * return NULL */ } } __pyx_L5_break:; /* "lupa/_lupa.pyx":1815 * if end[0] != '.': * break * return NULL # <<<<<<<<<<<<<< * * */ __pyx_r = NULL; goto __pyx_L0; /* "lupa/_lupa.pyx":1790 * * * cdef const char *luaL_findtable(lua_State *L, int idx, # <<<<<<<<<<<<<< * const char *fname, int size_hint): * cdef const char *end */ /* function exit code */ __pyx_L0:; __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "lupa/_lupa.pyx":1818 * * * cdef void luaL_pushmodule(lua_State *L, const char *modname, int size_hint): # <<<<<<<<<<<<<< * # XXX: "_LOADED" is the value of LUA_LOADED_TABLE, * # but it's absent in lua51 */ static void __pyx_f_4lupa_5_lupa_luaL_pushmodule(lua_State *__pyx_v_L, char const *__pyx_v_modname, int __pyx_v_size_hint) { __Pyx_RefNannyDeclarations int __pyx_t_1; __Pyx_RefNannySetupContext("luaL_pushmodule", 0); /* "lupa/_lupa.pyx":1821 * # XXX: "_LOADED" is the value of LUA_LOADED_TABLE, * # but it's absent in lua51 * luaL_findtable(L, lua.LUA_REGISTRYINDEX, "_LOADED", 1) # <<<<<<<<<<<<<< * lua.lua_getfield(L, -1, modname) * if lua.lua_type(L, -1) != lua.LUA_TTABLE: */ __pyx_f_4lupa_5_lupa_luaL_findtable(__pyx_v_L, LUA_REGISTRYINDEX, ((char const *)"_LOADED"), 1); /* "lupa/_lupa.pyx":1822 * # but it's absent in lua51 * luaL_findtable(L, lua.LUA_REGISTRYINDEX, "_LOADED", 1) * lua.lua_getfield(L, -1, modname) # <<<<<<<<<<<<<< * if lua.lua_type(L, -1) != lua.LUA_TTABLE: * lua.lua_pop(L, 1) */ lua_getfield(__pyx_v_L, -1, __pyx_v_modname); /* "lupa/_lupa.pyx":1823 * luaL_findtable(L, lua.LUA_REGISTRYINDEX, "_LOADED", 1) * lua.lua_getfield(L, -1, modname) * if lua.lua_type(L, -1) != lua.LUA_TTABLE: # <<<<<<<<<<<<<< * lua.lua_pop(L, 1) * lua.lua_getglobal(L, '_G') */ __pyx_t_1 = ((lua_type(__pyx_v_L, -1) != LUA_TTABLE) != 0); if (__pyx_t_1) { /* "lupa/_lupa.pyx":1824 * lua.lua_getfield(L, -1, modname) * if lua.lua_type(L, -1) != lua.LUA_TTABLE: * lua.lua_pop(L, 1) # <<<<<<<<<<<<<< * lua.lua_getglobal(L, '_G') * if luaL_findtable(L, 0, modname, size_hint) != NULL: */ lua_pop(__pyx_v_L, 1); /* "lupa/_lupa.pyx":1825 * if lua.lua_type(L, -1) != lua.LUA_TTABLE: * lua.lua_pop(L, 1) * lua.lua_getglobal(L, '_G') # <<<<<<<<<<<<<< * if luaL_findtable(L, 0, modname, size_hint) != NULL: * lua.luaL_error(L, "name conflict for module '%s'", modname) */ lua_getglobal(__pyx_v_L, ((char *)"_G")); /* "lupa/_lupa.pyx":1826 * lua.lua_pop(L, 1) * lua.lua_getglobal(L, '_G') * if luaL_findtable(L, 0, modname, size_hint) != NULL: # <<<<<<<<<<<<<< * lua.luaL_error(L, "name conflict for module '%s'", modname) * lua.lua_pushvalue(L, -1) */ __pyx_t_1 = ((__pyx_f_4lupa_5_lupa_luaL_findtable(__pyx_v_L, 0, __pyx_v_modname, __pyx_v_size_hint) != NULL) != 0); if (__pyx_t_1) { /* "lupa/_lupa.pyx":1827 * lua.lua_getglobal(L, '_G') * if luaL_findtable(L, 0, modname, size_hint) != NULL: * lua.luaL_error(L, "name conflict for module '%s'", modname) # <<<<<<<<<<<<<< * lua.lua_pushvalue(L, -1) * lua.lua_setfield(L, -3, modname) */ luaL_error(__pyx_v_L, ((char *)"name conflict for module '%s'"), __pyx_v_modname); /* "lupa/_lupa.pyx":1826 * lua.lua_pop(L, 1) * lua.lua_getglobal(L, '_G') * if luaL_findtable(L, 0, modname, size_hint) != NULL: # <<<<<<<<<<<<<< * lua.luaL_error(L, "name conflict for module '%s'", modname) * lua.lua_pushvalue(L, -1) */ } /* "lupa/_lupa.pyx":1828 * if luaL_findtable(L, 0, modname, size_hint) != NULL: * lua.luaL_error(L, "name conflict for module '%s'", modname) * lua.lua_pushvalue(L, -1) # <<<<<<<<<<<<<< * lua.lua_setfield(L, -3, modname) * lua.lua_remove(L, -2) */ lua_pushvalue(__pyx_v_L, -1); /* "lupa/_lupa.pyx":1829 * lua.luaL_error(L, "name conflict for module '%s'", modname) * lua.lua_pushvalue(L, -1) * lua.lua_setfield(L, -3, modname) # <<<<<<<<<<<<<< * lua.lua_remove(L, -2) * */ lua_setfield(__pyx_v_L, -3, __pyx_v_modname); /* "lupa/_lupa.pyx":1823 * luaL_findtable(L, lua.LUA_REGISTRYINDEX, "_LOADED", 1) * lua.lua_getfield(L, -1, modname) * if lua.lua_type(L, -1) != lua.LUA_TTABLE: # <<<<<<<<<<<<<< * lua.lua_pop(L, 1) * lua.lua_getglobal(L, '_G') */ } /* "lupa/_lupa.pyx":1830 * lua.lua_pushvalue(L, -1) * lua.lua_setfield(L, -3, modname) * lua.lua_remove(L, -2) # <<<<<<<<<<<<<< * * */ lua_remove(__pyx_v_L, -2); /* "lupa/_lupa.pyx":1818 * * * cdef void luaL_pushmodule(lua_State *L, const char *modname, int size_hint): # <<<<<<<<<<<<<< * # XXX: "_LOADED" is the value of LUA_LOADED_TABLE, * # but it's absent in lua51 */ /* function exit code */ __Pyx_RefNannyFinishContext(); } /* "lupa/_lupa.pyx":1833 * * * cdef void luaL_openlib(lua_State *L, const char *libname, # <<<<<<<<<<<<<< * const lua.luaL_Reg *l, int nup): * if libname: */ static void __pyx_f_4lupa_5_lupa_luaL_openlib(lua_State *__pyx_v_L, char const *__pyx_v_libname, luaL_Reg const *__pyx_v_l, int __pyx_v_nup) { __Pyx_RefNannyDeclarations int __pyx_t_1; __Pyx_RefNannySetupContext("luaL_openlib", 0); /* "lupa/_lupa.pyx":1835 * cdef void luaL_openlib(lua_State *L, const char *libname, * const lua.luaL_Reg *l, int nup): * if libname: # <<<<<<<<<<<<<< * luaL_pushmodule(L, libname, libsize(l)) * lua.lua_insert(L, -(nup + 1)) */ __pyx_t_1 = (__pyx_v_libname != 0); if (__pyx_t_1) { /* "lupa/_lupa.pyx":1836 * const lua.luaL_Reg *l, int nup): * if libname: * luaL_pushmodule(L, libname, libsize(l)) # <<<<<<<<<<<<<< * lua.lua_insert(L, -(nup + 1)) * if l: */ __pyx_f_4lupa_5_lupa_luaL_pushmodule(__pyx_v_L, __pyx_v_libname, __pyx_f_4lupa_5_lupa_libsize(__pyx_v_l)); /* "lupa/_lupa.pyx":1837 * if libname: * luaL_pushmodule(L, libname, libsize(l)) * lua.lua_insert(L, -(nup + 1)) # <<<<<<<<<<<<<< * if l: * luaL_setfuncs(L, l, nup) */ lua_insert(__pyx_v_L, (-(__pyx_v_nup + 1))); /* "lupa/_lupa.pyx":1835 * cdef void luaL_openlib(lua_State *L, const char *libname, * const lua.luaL_Reg *l, int nup): * if libname: # <<<<<<<<<<<<<< * luaL_pushmodule(L, libname, libsize(l)) * lua.lua_insert(L, -(nup + 1)) */ } /* "lupa/_lupa.pyx":1838 * luaL_pushmodule(L, libname, libsize(l)) * lua.lua_insert(L, -(nup + 1)) * if l: # <<<<<<<<<<<<<< * luaL_setfuncs(L, l, nup) * else: */ __pyx_t_1 = (__pyx_v_l != 0); if (__pyx_t_1) { /* "lupa/_lupa.pyx":1839 * lua.lua_insert(L, -(nup + 1)) * if l: * luaL_setfuncs(L, l, nup) # <<<<<<<<<<<<<< * else: * lua.lua_pop(L, nup) */ __pyx_f_4lupa_5_lupa_luaL_setfuncs(__pyx_v_L, __pyx_v_l, __pyx_v_nup); /* "lupa/_lupa.pyx":1838 * luaL_pushmodule(L, libname, libsize(l)) * lua.lua_insert(L, -(nup + 1)) * if l: # <<<<<<<<<<<<<< * luaL_setfuncs(L, l, nup) * else: */ goto __pyx_L4; } /* "lupa/_lupa.pyx":1841 * luaL_setfuncs(L, l, nup) * else: * lua.lua_pop(L, nup) # <<<<<<<<<<<<<< */ /*else*/ { lua_pop(__pyx_v_L, __pyx_v_nup); } __pyx_L4:; /* "lupa/_lupa.pyx":1833 * * * cdef void luaL_openlib(lua_State *L, const char *libname, # <<<<<<<<<<<<<< * const lua.luaL_Reg *l, int nup): * if libname: */ /* function exit code */ __Pyx_RefNannyFinishContext(); } static PyObject *__pyx_tp_new_4lupa_5_lupa_FastRLock(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) { PyObject *o; if (likely((t->tp_flags & Py_TPFLAGS_IS_ABSTRACT) == 0)) { o = (*t->tp_alloc)(t, 0); } else { o = (PyObject *) PyBaseObject_Type.tp_new(t, __pyx_empty_tuple, 0); } if (unlikely(!o)) return 0; if (unlikely(__pyx_pw_4lupa_5_lupa_9FastRLock_1__cinit__(o, __pyx_empty_tuple, NULL) < 0)) goto bad; return o; bad: Py_DECREF(o); o = 0; return NULL; } static void __pyx_tp_dealloc_4lupa_5_lupa_FastRLock(PyObject *o) { #if CYTHON_USE_TP_FINALIZE if (unlikely(PyType_HasFeature(Py_TYPE(o), Py_TPFLAGS_HAVE_FINALIZE) && Py_TYPE(o)->tp_finalize) && (!PyType_IS_GC(Py_TYPE(o)) || !_PyGC_FINALIZED(o))) { if (PyObject_CallFinalizerFromDealloc(o)) return; } #endif { PyObject *etype, *eval, *etb; PyErr_Fetch(&etype, &eval, &etb); ++Py_REFCNT(o); __pyx_pw_4lupa_5_lupa_9FastRLock_3__dealloc__(o); --Py_REFCNT(o); PyErr_Restore(etype, eval, etb); } (*Py_TYPE(o)->tp_free)(o); } static PyMethodDef __pyx_methods_4lupa_5_lupa_FastRLock[] = { {"acquire", (PyCFunction)__pyx_pw_4lupa_5_lupa_9FastRLock_5acquire, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4lupa_5_lupa_9FastRLock_4acquire}, {"release", (PyCFunction)__pyx_pw_4lupa_5_lupa_9FastRLock_7release, METH_NOARGS, __pyx_doc_4lupa_5_lupa_9FastRLock_6release}, {"__enter__", (PyCFunction)__pyx_pw_4lupa_5_lupa_9FastRLock_9__enter__, METH_NOARGS, __pyx_doc_4lupa_5_lupa_9FastRLock_8__enter__}, {"__exit__", (PyCFunction)__pyx_pw_4lupa_5_lupa_9FastRLock_11__exit__, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4lupa_5_lupa_9FastRLock_10__exit__}, {"_is_owned", (PyCFunction)__pyx_pw_4lupa_5_lupa_9FastRLock_13_is_owned, METH_NOARGS, __pyx_doc_4lupa_5_lupa_9FastRLock_12_is_owned}, {"__reduce_cython__", (PyCFunction)__pyx_pw_4lupa_5_lupa_9FastRLock_15__reduce_cython__, METH_NOARGS, __pyx_doc_4lupa_5_lupa_9FastRLock_14__reduce_cython__}, {"__setstate_cython__", (PyCFunction)__pyx_pw_4lupa_5_lupa_9FastRLock_17__setstate_cython__, METH_O, __pyx_doc_4lupa_5_lupa_9FastRLock_16__setstate_cython__}, {0, 0, 0, 0} }; static PyTypeObject __pyx_type_4lupa_5_lupa_FastRLock = { PyVarObject_HEAD_INIT(0, 0) "lupa._lupa.FastRLock", /*tp_name*/ sizeof(struct __pyx_obj_4lupa_5_lupa_FastRLock), /*tp_basicsize*/ 0, /*tp_itemsize*/ __pyx_tp_dealloc_4lupa_5_lupa_FastRLock, /*tp_dealloc*/ 0, /*tp_print*/ 0, /*tp_getattr*/ 0, /*tp_setattr*/ #if PY_MAJOR_VERSION < 3 0, /*tp_compare*/ #endif #if PY_MAJOR_VERSION >= 3 0, /*tp_as_async*/ #endif 0, /*tp_repr*/ 0, /*tp_as_number*/ 0, /*tp_as_sequence*/ 0, /*tp_as_mapping*/ 0, /*tp_hash*/ 0, /*tp_call*/ 0, /*tp_str*/ 0, /*tp_getattro*/ 0, /*tp_setattro*/ 0, /*tp_as_buffer*/ Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE, /*tp_flags*/ "Fast, re-entrant locking.\n\n Under uncongested conditions, the lock is never acquired but only\n counted. Only when a second thread comes in and notices that the\n lock is needed, it acquires the lock and notifies the first thread\n to release it when it's done. This is all made possible by the\n wonderful GIL.\n ", /*tp_doc*/ 0, /*tp_traverse*/ 0, /*tp_clear*/ 0, /*tp_richcompare*/ 0, /*tp_weaklistoffset*/ 0, /*tp_iter*/ 0, /*tp_iternext*/ __pyx_methods_4lupa_5_lupa_FastRLock, /*tp_methods*/ 0, /*tp_members*/ 0, /*tp_getset*/ 0, /*tp_base*/ 0, /*tp_dict*/ 0, /*tp_descr_get*/ 0, /*tp_descr_set*/ 0, /*tp_dictoffset*/ 0, /*tp_init*/ 0, /*tp_alloc*/ __pyx_tp_new_4lupa_5_lupa_FastRLock, /*tp_new*/ 0, /*tp_free*/ 0, /*tp_is_gc*/ 0, /*tp_bases*/ 0, /*tp_mro*/ 0, /*tp_cache*/ 0, /*tp_subclasses*/ 0, /*tp_weaklist*/ 0, /*tp_del*/ 0, /*tp_version_tag*/ #if PY_VERSION_HEX >= 0x030400a1 0, /*tp_finalize*/ #endif }; static struct __pyx_vtabstruct_4lupa_5_lupa_LuaRuntime __pyx_vtable_4lupa_5_lupa_LuaRuntime; static PyObject *__pyx_tp_new_4lupa_5_lupa_LuaRuntime(PyTypeObject *t, PyObject *a, PyObject *k) { struct __pyx_obj_4lupa_5_lupa_LuaRuntime *p; PyObject *o; if (likely((t->tp_flags & Py_TPFLAGS_IS_ABSTRACT) == 0)) { o = (*t->tp_alloc)(t, 0); } else { o = (PyObject *) PyBaseObject_Type.tp_new(t, __pyx_empty_tuple, 0); } if (unlikely(!o)) return 0; p = ((struct __pyx_obj_4lupa_5_lupa_LuaRuntime *)o); p->__pyx_vtab = __pyx_vtabptr_4lupa_5_lupa_LuaRuntime; p->_lock = ((struct __pyx_obj_4lupa_5_lupa_FastRLock *)Py_None); Py_INCREF(Py_None); p->_pyrefs_in_lua = ((PyObject*)Py_None); Py_INCREF(Py_None); p->_raised_exception = ((PyObject*)Py_None); Py_INCREF(Py_None); p->_encoding = ((PyObject*)Py_None); Py_INCREF(Py_None); p->_source_encoding = ((PyObject*)Py_None); Py_INCREF(Py_None); p->_attribute_filter = Py_None; Py_INCREF(Py_None); p->_attribute_getter = Py_None; Py_INCREF(Py_None); p->_attribute_setter = Py_None; Py_INCREF(Py_None); if (unlikely(__pyx_pw_4lupa_5_lupa_10LuaRuntime_1__cinit__(o, a, k) < 0)) goto bad; return o; bad: Py_DECREF(o); o = 0; return NULL; } static void __pyx_tp_dealloc_4lupa_5_lupa_LuaRuntime(PyObject *o) { struct __pyx_obj_4lupa_5_lupa_LuaRuntime *p = (struct __pyx_obj_4lupa_5_lupa_LuaRuntime *)o; #if CYTHON_USE_TP_FINALIZE if (unlikely(PyType_HasFeature(Py_TYPE(o), Py_TPFLAGS_HAVE_FINALIZE) && Py_TYPE(o)->tp_finalize) && !_PyGC_FINALIZED(o)) { if (PyObject_CallFinalizerFromDealloc(o)) return; } #endif PyObject_GC_UnTrack(o); { PyObject *etype, *eval, *etb; PyErr_Fetch(&etype, &eval, &etb); ++Py_REFCNT(o); __pyx_pw_4lupa_5_lupa_10LuaRuntime_3__dealloc__(o); --Py_REFCNT(o); PyErr_Restore(etype, eval, etb); } Py_CLEAR(p->_lock); Py_CLEAR(p->_pyrefs_in_lua); Py_CLEAR(p->_raised_exception); Py_CLEAR(p->_encoding); Py_CLEAR(p->_source_encoding); Py_CLEAR(p->_attribute_filter); Py_CLEAR(p->_attribute_getter); Py_CLEAR(p->_attribute_setter); (*Py_TYPE(o)->tp_free)(o); } static int __pyx_tp_traverse_4lupa_5_lupa_LuaRuntime(PyObject *o, visitproc v, void *a) { int e; struct __pyx_obj_4lupa_5_lupa_LuaRuntime *p = (struct __pyx_obj_4lupa_5_lupa_LuaRuntime *)o; if (p->_lock) { e = (*v)(((PyObject *)p->_lock), a); if (e) return e; } if (p->_pyrefs_in_lua) { e = (*v)(p->_pyrefs_in_lua, a); if (e) return e; } if (p->_raised_exception) { e = (*v)(p->_raised_exception, a); if (e) return e; } if (p->_attribute_filter) { e = (*v)(p->_attribute_filter, a); if (e) return e; } if (p->_attribute_getter) { e = (*v)(p->_attribute_getter, a); if (e) return e; } if (p->_attribute_setter) { e = (*v)(p->_attribute_setter, a); if (e) return e; } return 0; } static PyMethodDef __pyx_methods_4lupa_5_lupa_LuaRuntime[] = { {"eval", (PyCFunction)__pyx_pw_4lupa_5_lupa_10LuaRuntime_5eval, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4lupa_5_lupa_10LuaRuntime_4eval}, {"execute", (PyCFunction)__pyx_pw_4lupa_5_lupa_10LuaRuntime_7execute, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4lupa_5_lupa_10LuaRuntime_6execute}, {"compile", (PyCFunction)__pyx_pw_4lupa_5_lupa_10LuaRuntime_9compile, METH_O, __pyx_doc_4lupa_5_lupa_10LuaRuntime_8compile}, {"require", (PyCFunction)__pyx_pw_4lupa_5_lupa_10LuaRuntime_11require, METH_O, __pyx_doc_4lupa_5_lupa_10LuaRuntime_10require}, {"globals", (PyCFunction)__pyx_pw_4lupa_5_lupa_10LuaRuntime_13globals, METH_NOARGS, __pyx_doc_4lupa_5_lupa_10LuaRuntime_12globals}, {"table", (PyCFunction)__pyx_pw_4lupa_5_lupa_10LuaRuntime_15table, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4lupa_5_lupa_10LuaRuntime_14table}, {"table_from", (PyCFunction)__pyx_pw_4lupa_5_lupa_10LuaRuntime_17table_from, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4lupa_5_lupa_10LuaRuntime_16table_from}, {"__reduce_cython__", (PyCFunction)__pyx_pw_4lupa_5_lupa_10LuaRuntime_19__reduce_cython__, METH_NOARGS, __pyx_doc_4lupa_5_lupa_10LuaRuntime_18__reduce_cython__}, {"__setstate_cython__", (PyCFunction)__pyx_pw_4lupa_5_lupa_10LuaRuntime_21__setstate_cython__, METH_O, __pyx_doc_4lupa_5_lupa_10LuaRuntime_20__setstate_cython__}, {0, 0, 0, 0} }; static PyTypeObject __pyx_type_4lupa_5_lupa_LuaRuntime = { PyVarObject_HEAD_INIT(0, 0) "lupa._lupa.LuaRuntime", /*tp_name*/ sizeof(struct __pyx_obj_4lupa_5_lupa_LuaRuntime), /*tp_basicsize*/ 0, /*tp_itemsize*/ __pyx_tp_dealloc_4lupa_5_lupa_LuaRuntime, /*tp_dealloc*/ 0, /*tp_print*/ 0, /*tp_getattr*/ 0, /*tp_setattr*/ #if PY_MAJOR_VERSION < 3 0, /*tp_compare*/ #endif #if PY_MAJOR_VERSION >= 3 0, /*tp_as_async*/ #endif 0, /*tp_repr*/ 0, /*tp_as_number*/ 0, /*tp_as_sequence*/ 0, /*tp_as_mapping*/ 0, /*tp_hash*/ 0, /*tp_call*/ 0, /*tp_str*/ 0, /*tp_getattro*/ 0, /*tp_setattro*/ 0, /*tp_as_buffer*/ Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/ "The main entry point to the Lua runtime.\n\n Available options:\n\n * ``encoding``: the string encoding, defaulting to UTF-8. If set\n to ``None``, all string values will be returned as byte strings.\n Otherwise, they will be decoded to unicode strings on the way\n from Lua to Python and unicode strings will be encoded on the\n way to Lua. Note that ``str()`` calls on Lua objects will\n always return a unicode object.\n\n * ``source_encoding``: the encoding used for Lua code, defaulting to\n the string encoding or UTF-8 if the string encoding is ``None``.\n\n * ``attribute_filter``: filter function for attribute access\n (get/set). Must have the signature ``func(obj, attr_name,\n is_setting)``, where ``is_setting`` is True when the attribute\n is being set. If provided, the function will be called for all\n Python object attributes that are being accessed from Lua code.\n Normally, it should return an attribute name that will then be\n used for the lookup. If it wants to prevent access, it should\n raise an ``AttributeError``. Note that Lua does not guarantee\n that the names will be strings. (New in Lupa 0.20)\n\n * ``attribute_handlers``: like ``attribute_filter`` above, but\n handles the getting/setting itself rather than giving hints\n to the LuaRuntime. This must be a 2-tuple, ``(getter, setter)``\n where ``getter`` has the signature ``func(obj, attr_name)``\n and either returns the value for ``obj.attr_name`` or raises an\n ``AttributeError`` The function ``setter`` has the signature\n ``func(obj, attr_name, value)`` and may raise an ``AttributeError``.\n The return value of the setter is unused. (New in Lupa 1.0)\n\n * ``register_eval``: should Python's ``eval()`` function be available\n to Lua code as ``python.eval()``? Note that this does not remove it\n from the builtins. Use an ``attribute_filter`` function for t""hat.\n (default: True)\n\n * ``register_builtins``: should Python's builtins be available to Lua\n code as ``python.builtins.*``? Note that this does not prevent access\n to the globals available as special Python function attributes, for\n example. Use an ``attribute_filter`` function for that.\n (default: True, new in Lupa 1.2)\n\n * ``unpack_returned_tuples``: should Python tuples be unpacked in Lua?\n If ``py_fun()`` returns ``(1, 2, 3)``, then does ``a, b, c = py_fun()``\n give ``a == 1 and b == 2 and c == 3`` or does it give\n ``a == (1,2,3), b == nil, c == nil``? ``unpack_returned_tuples=True``\n gives the former.\n (default: False, new in Lupa 0.21)\n\n Example usage::\n\n >>> from lupa import LuaRuntime\n >>> lua = LuaRuntime()\n\n >>> lua.eval('1+1')\n 2\n\n >>> lua_func = lua.eval('function(f, n) return f(n) end')\n\n >>> def py_add1(n): return n+1\n >>> lua_func(py_add1, 2)\n 3\n ", /*tp_doc*/ __pyx_tp_traverse_4lupa_5_lupa_LuaRuntime, /*tp_traverse*/ 0, /*tp_clear*/ 0, /*tp_richcompare*/ 0, /*tp_weaklistoffset*/ 0, /*tp_iter*/ 0, /*tp_iternext*/ __pyx_methods_4lupa_5_lupa_LuaRuntime, /*tp_methods*/ 0, /*tp_members*/ 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*/ 0, /*tp_version_tag*/ #if PY_VERSION_HEX >= 0x030400a1 0, /*tp_finalize*/ #endif }; static struct __pyx_vtabstruct_4lupa_5_lupa__LuaObject __pyx_vtable_4lupa_5_lupa__LuaObject; static struct __pyx_obj_4lupa_5_lupa__LuaObject *__pyx_freelist_4lupa_5_lupa__LuaObject[16]; static int __pyx_freecount_4lupa_5_lupa__LuaObject = 0; static PyObject *__pyx_tp_new_4lupa_5_lupa__LuaObject(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) { struct __pyx_obj_4lupa_5_lupa__LuaObject *p; PyObject *o; if (CYTHON_COMPILING_IN_CPYTHON && likely((__pyx_freecount_4lupa_5_lupa__LuaObject > 0) & (t->tp_basicsize == sizeof(struct __pyx_obj_4lupa_5_lupa__LuaObject)) & ((t->tp_flags & (Py_TPFLAGS_IS_ABSTRACT | Py_TPFLAGS_HEAPTYPE)) == 0))) { o = (PyObject*)__pyx_freelist_4lupa_5_lupa__LuaObject[--__pyx_freecount_4lupa_5_lupa__LuaObject]; memset(o, 0, sizeof(struct __pyx_obj_4lupa_5_lupa__LuaObject)); (void) PyObject_INIT(o, t); PyObject_GC_Track(o); } else { if (likely((t->tp_flags & Py_TPFLAGS_IS_ABSTRACT) == 0)) { o = (*t->tp_alloc)(t, 0); } else { o = (PyObject *) PyBaseObject_Type.tp_new(t, __pyx_empty_tuple, 0); } if (unlikely(!o)) return 0; } p = ((struct __pyx_obj_4lupa_5_lupa__LuaObject *)o); p->__pyx_vtab = __pyx_vtabptr_4lupa_5_lupa__LuaObject; p->_runtime = ((struct __pyx_obj_4lupa_5_lupa_LuaRuntime *)Py_None); Py_INCREF(Py_None); return o; } static void __pyx_tp_dealloc_4lupa_5_lupa__LuaObject(PyObject *o) { struct __pyx_obj_4lupa_5_lupa__LuaObject *p = (struct __pyx_obj_4lupa_5_lupa__LuaObject *)o; #if CYTHON_USE_TP_FINALIZE if (unlikely(PyType_HasFeature(Py_TYPE(o), Py_TPFLAGS_HAVE_FINALIZE) && Py_TYPE(o)->tp_finalize) && !_PyGC_FINALIZED(o)) { if (PyObject_CallFinalizerFromDealloc(o)) return; } #endif PyObject_GC_UnTrack(o); { PyObject *etype, *eval, *etb; PyErr_Fetch(&etype, &eval, &etb); ++Py_REFCNT(o); __pyx_pw_4lupa_5_lupa_10_LuaObject_3__dealloc__(o); --Py_REFCNT(o); PyErr_Restore(etype, eval, etb); } Py_CLEAR(p->_runtime); if (CYTHON_COMPILING_IN_CPYTHON && ((__pyx_freecount_4lupa_5_lupa__LuaObject < 16) & (Py_TYPE(o)->tp_basicsize == sizeof(struct __pyx_obj_4lupa_5_lupa__LuaObject)) & ((Py_TYPE(o)->tp_flags & (Py_TPFLAGS_IS_ABSTRACT | Py_TPFLAGS_HEAPTYPE)) == 0))) { __pyx_freelist_4lupa_5_lupa__LuaObject[__pyx_freecount_4lupa_5_lupa__LuaObject++] = ((struct __pyx_obj_4lupa_5_lupa__LuaObject *)o); } else { (*Py_TYPE(o)->tp_free)(o); } } static int __pyx_tp_traverse_4lupa_5_lupa__LuaObject(PyObject *o, visitproc v, void *a) { int e; struct __pyx_obj_4lupa_5_lupa__LuaObject *p = (struct __pyx_obj_4lupa_5_lupa__LuaObject *)o; if (p->_runtime) { e = (*v)(((PyObject *)p->_runtime), a); if (e) return e; } return 0; } static PyObject *__pyx_sq_item_4lupa_5_lupa__LuaObject(PyObject *o, Py_ssize_t i) { PyObject *r; PyObject *x = PyInt_FromSsize_t(i); if(!x) return 0; r = Py_TYPE(o)->tp_as_mapping->mp_subscript(o, x); Py_DECREF(x); return r; } static PyObject *__pyx_tp_getattro_4lupa_5_lupa__LuaObject(PyObject *o, PyObject *n) { PyObject *v = PyObject_GenericGetAttr(o, n); if (!v && PyErr_ExceptionMatches(PyExc_AttributeError)) { PyErr_Clear(); v = __pyx_pw_4lupa_5_lupa_10_LuaObject_17__getattr__(o, n); } return v; } static PyMethodDef __pyx_methods_4lupa_5_lupa__LuaObject[] = { {"__getattr__", (PyCFunction)__pyx_pw_4lupa_5_lupa_10_LuaObject_17__getattr__, METH_O|METH_COEXIST, 0}, {"__reduce_cython__", (PyCFunction)__pyx_pw_4lupa_5_lupa_10_LuaObject_21__reduce_cython__, METH_NOARGS, __pyx_doc_4lupa_5_lupa_10_LuaObject_20__reduce_cython__}, {"__setstate_cython__", (PyCFunction)__pyx_pw_4lupa_5_lupa_10_LuaObject_23__setstate_cython__, METH_O, __pyx_doc_4lupa_5_lupa_10_LuaObject_22__setstate_cython__}, {0, 0, 0, 0} }; static PyNumberMethods __pyx_tp_as_number__LuaObject = { 0, /*nb_add*/ 0, /*nb_subtract*/ 0, /*nb_multiply*/ #if PY_MAJOR_VERSION < 3 || (CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX < 0x03050000) 0, /*nb_divide*/ #endif 0, /*nb_remainder*/ 0, /*nb_divmod*/ 0, /*nb_power*/ 0, /*nb_negative*/ 0, /*nb_positive*/ 0, /*nb_absolute*/ __pyx_pw_4lupa_5_lupa_10_LuaObject_9__nonzero__, /*nb_nonzero*/ 0, /*nb_invert*/ 0, /*nb_lshift*/ 0, /*nb_rshift*/ 0, /*nb_and*/ 0, /*nb_xor*/ 0, /*nb_or*/ #if PY_MAJOR_VERSION < 3 || (CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX < 0x03050000) 0, /*nb_coerce*/ #endif 0, /*nb_int*/ #if PY_MAJOR_VERSION < 3 0, /*nb_long*/ #else 0, /*reserved*/ #endif 0, /*nb_float*/ #if PY_MAJOR_VERSION < 3 || (CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX < 0x03050000) 0, /*nb_oct*/ #endif #if PY_MAJOR_VERSION < 3 || (CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX < 0x03050000) 0, /*nb_hex*/ #endif 0, /*nb_inplace_add*/ 0, /*nb_inplace_subtract*/ 0, /*nb_inplace_multiply*/ #if PY_MAJOR_VERSION < 3 || (CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX < 0x03050000) 0, /*nb_inplace_divide*/ #endif 0, /*nb_inplace_remainder*/ 0, /*nb_inplace_power*/ 0, /*nb_inplace_lshift*/ 0, /*nb_inplace_rshift*/ 0, /*nb_inplace_and*/ 0, /*nb_inplace_xor*/ 0, /*nb_inplace_or*/ 0, /*nb_floor_divide*/ 0, /*nb_true_divide*/ 0, /*nb_inplace_floor_divide*/ 0, /*nb_inplace_true_divide*/ 0, /*nb_index*/ #if PY_VERSION_HEX >= 0x03050000 0, /*nb_matrix_multiply*/ #endif #if PY_VERSION_HEX >= 0x03050000 0, /*nb_inplace_matrix_multiply*/ #endif }; static PySequenceMethods __pyx_tp_as_sequence__LuaObject = { __pyx_pw_4lupa_5_lupa_10_LuaObject_7__len__, /*sq_length*/ 0, /*sq_concat*/ 0, /*sq_repeat*/ __pyx_sq_item_4lupa_5_lupa__LuaObject, /*sq_item*/ 0, /*sq_slice*/ 0, /*sq_ass_item*/ 0, /*sq_ass_slice*/ 0, /*sq_contains*/ 0, /*sq_inplace_concat*/ 0, /*sq_inplace_repeat*/ }; static PyMappingMethods __pyx_tp_as_mapping__LuaObject = { __pyx_pw_4lupa_5_lupa_10_LuaObject_7__len__, /*mp_length*/ __pyx_pw_4lupa_5_lupa_10_LuaObject_19__getitem__, /*mp_subscript*/ 0, /*mp_ass_subscript*/ }; static PyTypeObject __pyx_type_4lupa_5_lupa__LuaObject = { PyVarObject_HEAD_INIT(0, 0) "lupa._lupa._LuaObject", /*tp_name*/ sizeof(struct __pyx_obj_4lupa_5_lupa__LuaObject), /*tp_basicsize*/ 0, /*tp_itemsize*/ __pyx_tp_dealloc_4lupa_5_lupa__LuaObject, /*tp_dealloc*/ 0, /*tp_print*/ 0, /*tp_getattr*/ 0, /*tp_setattr*/ #if PY_MAJOR_VERSION < 3 0, /*tp_compare*/ #endif #if PY_MAJOR_VERSION >= 3 0, /*tp_as_async*/ #endif __pyx_pw_4lupa_5_lupa_10_LuaObject_13__repr__, /*tp_repr*/ &__pyx_tp_as_number__LuaObject, /*tp_as_number*/ &__pyx_tp_as_sequence__LuaObject, /*tp_as_sequence*/ &__pyx_tp_as_mapping__LuaObject, /*tp_as_mapping*/ 0, /*tp_hash*/ __pyx_pw_4lupa_5_lupa_10_LuaObject_5__call__, /*tp_call*/ __pyx_pw_4lupa_5_lupa_10_LuaObject_15__str__, /*tp_str*/ __pyx_tp_getattro_4lupa_5_lupa__LuaObject, /*tp_getattro*/ 0, /*tp_setattro*/ 0, /*tp_as_buffer*/ Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/ "_LuaObject()\nA wrapper around a Lua object such as a table or function.\n ", /*tp_doc*/ __pyx_tp_traverse_4lupa_5_lupa__LuaObject, /*tp_traverse*/ 0, /*tp_clear*/ 0, /*tp_richcompare*/ 0, /*tp_weaklistoffset*/ __pyx_pw_4lupa_5_lupa_10_LuaObject_11__iter__, /*tp_iter*/ 0, /*tp_iternext*/ __pyx_methods_4lupa_5_lupa__LuaObject, /*tp_methods*/ 0, /*tp_members*/ 0, /*tp_getset*/ 0, /*tp_base*/ 0, /*tp_dict*/ 0, /*tp_descr_get*/ 0, /*tp_descr_set*/ 0, /*tp_dictoffset*/ __pyx_pw_4lupa_5_lupa_10_LuaObject_1__init__, /*tp_init*/ 0, /*tp_alloc*/ __pyx_tp_new_4lupa_5_lupa__LuaObject, /*tp_new*/ 0, /*tp_free*/ 0, /*tp_is_gc*/ 0, /*tp_bases*/ 0, /*tp_mro*/ 0, /*tp_cache*/ 0, /*tp_subclasses*/ 0, /*tp_weaklist*/ 0, /*tp_del*/ 0, /*tp_version_tag*/ #if PY_VERSION_HEX >= 0x030400a1 0, /*tp_finalize*/ #endif }; static struct __pyx_vtabstruct_4lupa_5_lupa__LuaTable __pyx_vtable_4lupa_5_lupa__LuaTable; static PyObject *__pyx_tp_new_4lupa_5_lupa__LuaTable(PyTypeObject *t, PyObject *a, PyObject *k) { struct __pyx_obj_4lupa_5_lupa__LuaTable *p; PyObject *o = __pyx_tp_new_4lupa_5_lupa__LuaObject(t, a, k); if (unlikely(!o)) return 0; p = ((struct __pyx_obj_4lupa_5_lupa__LuaTable *)o); p->__pyx_base.__pyx_vtab = (struct __pyx_vtabstruct_4lupa_5_lupa__LuaObject*)__pyx_vtabptr_4lupa_5_lupa__LuaTable; return o; } static int __pyx_mp_ass_subscript_4lupa_5_lupa__LuaTable(PyObject *o, PyObject *i, PyObject *v) { if (v) { return __pyx_pw_4lupa_5_lupa_9_LuaTable_11__setitem__(o, i, v); } else { return __pyx_pw_4lupa_5_lupa_9_LuaTable_15__delitem__(o, i); } } static int __pyx_tp_setattro_4lupa_5_lupa__LuaTable(PyObject *o, PyObject *n, PyObject *v) { if (v) { return __pyx_pw_4lupa_5_lupa_9_LuaTable_9__setattr__(o, n, v); } else { return __pyx_pw_4lupa_5_lupa_9_LuaTable_13__delattr__(o, n); } } static PyMethodDef __pyx_methods_4lupa_5_lupa__LuaTable[] = { {"keys", (PyCFunction)__pyx_pw_4lupa_5_lupa_9_LuaTable_3keys, METH_NOARGS, __pyx_doc_4lupa_5_lupa_9_LuaTable_2keys}, {"values", (PyCFunction)__pyx_pw_4lupa_5_lupa_9_LuaTable_5values, METH_NOARGS, __pyx_doc_4lupa_5_lupa_9_LuaTable_4values}, {"items", (PyCFunction)__pyx_pw_4lupa_5_lupa_9_LuaTable_7items, METH_NOARGS, __pyx_doc_4lupa_5_lupa_9_LuaTable_6items}, {"__reduce_cython__", (PyCFunction)__pyx_pw_4lupa_5_lupa_9_LuaTable_17__reduce_cython__, METH_NOARGS, __pyx_doc_4lupa_5_lupa_9_LuaTable_16__reduce_cython__}, {"__setstate_cython__", (PyCFunction)__pyx_pw_4lupa_5_lupa_9_LuaTable_19__setstate_cython__, METH_O, __pyx_doc_4lupa_5_lupa_9_LuaTable_18__setstate_cython__}, {0, 0, 0, 0} }; static PyMappingMethods __pyx_tp_as_mapping__LuaTable = { #if CYTHON_COMPILING_IN_PYPY __pyx_pw_4lupa_5_lupa_10_LuaObject_7__len__, /*mp_length*/ #else 0, /*mp_length*/ #endif #if CYTHON_COMPILING_IN_PYPY __pyx_pw_4lupa_5_lupa_10_LuaObject_19__getitem__, /*mp_subscript*/ #else 0, /*mp_subscript*/ #endif __pyx_mp_ass_subscript_4lupa_5_lupa__LuaTable, /*mp_ass_subscript*/ }; static PyTypeObject __pyx_type_4lupa_5_lupa__LuaTable = { PyVarObject_HEAD_INIT(0, 0) "lupa._lupa._LuaTable", /*tp_name*/ sizeof(struct __pyx_obj_4lupa_5_lupa__LuaTable), /*tp_basicsize*/ 0, /*tp_itemsize*/ __pyx_tp_dealloc_4lupa_5_lupa__LuaObject, /*tp_dealloc*/ 0, /*tp_print*/ 0, /*tp_getattr*/ 0, /*tp_setattr*/ #if PY_MAJOR_VERSION < 3 0, /*tp_compare*/ #endif #if PY_MAJOR_VERSION >= 3 0, /*tp_as_async*/ #endif #if CYTHON_COMPILING_IN_PYPY __pyx_pw_4lupa_5_lupa_10_LuaObject_13__repr__, /*tp_repr*/ #else 0, /*tp_repr*/ #endif 0, /*tp_as_number*/ 0, /*tp_as_sequence*/ &__pyx_tp_as_mapping__LuaTable, /*tp_as_mapping*/ 0, /*tp_hash*/ #if CYTHON_COMPILING_IN_PYPY __pyx_pw_4lupa_5_lupa_10_LuaObject_5__call__, /*tp_call*/ #else 0, /*tp_call*/ #endif #if CYTHON_COMPILING_IN_PYPY __pyx_pw_4lupa_5_lupa_10_LuaObject_15__str__, /*tp_str*/ #else 0, /*tp_str*/ #endif 0, /*tp_getattro*/ __pyx_tp_setattro_4lupa_5_lupa__LuaTable, /*tp_setattro*/ 0, /*tp_as_buffer*/ Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC, /*tp_flags*/ 0, /*tp_doc*/ __pyx_tp_traverse_4lupa_5_lupa__LuaObject, /*tp_traverse*/ 0, /*tp_clear*/ 0, /*tp_richcompare*/ 0, /*tp_weaklistoffset*/ __pyx_pw_4lupa_5_lupa_9_LuaTable_1__iter__, /*tp_iter*/ 0, /*tp_iternext*/ __pyx_methods_4lupa_5_lupa__LuaTable, /*tp_methods*/ 0, /*tp_members*/ 0, /*tp_getset*/ 0, /*tp_base*/ 0, /*tp_dict*/ 0, /*tp_descr_get*/ 0, /*tp_descr_set*/ 0, /*tp_dictoffset*/ #if CYTHON_COMPILING_IN_PYPY __pyx_pw_4lupa_5_lupa_10_LuaObject_1__init__, /*tp_init*/ #else 0, /*tp_init*/ #endif 0, /*tp_alloc*/ __pyx_tp_new_4lupa_5_lupa__LuaTable, /*tp_new*/ 0, /*tp_free*/ 0, /*tp_is_gc*/ 0, /*tp_bases*/ 0, /*tp_mro*/ 0, /*tp_cache*/ 0, /*tp_subclasses*/ 0, /*tp_weaklist*/ 0, /*tp_del*/ 0, /*tp_version_tag*/ #if PY_VERSION_HEX >= 0x030400a1 0, /*tp_finalize*/ #endif }; static struct __pyx_vtabstruct_4lupa_5_lupa__LuaFunction __pyx_vtable_4lupa_5_lupa__LuaFunction; static PyObject *__pyx_tp_new_4lupa_5_lupa__LuaFunction(PyTypeObject *t, PyObject *a, PyObject *k) { struct __pyx_obj_4lupa_5_lupa__LuaFunction *p; PyObject *o = __pyx_tp_new_4lupa_5_lupa__LuaObject(t, a, k); if (unlikely(!o)) return 0; p = ((struct __pyx_obj_4lupa_5_lupa__LuaFunction *)o); p->__pyx_base.__pyx_vtab = (struct __pyx_vtabstruct_4lupa_5_lupa__LuaObject*)__pyx_vtabptr_4lupa_5_lupa__LuaFunction; return o; } static PyMethodDef __pyx_methods_4lupa_5_lupa__LuaFunction[] = { {"coroutine", (PyCFunction)__pyx_pw_4lupa_5_lupa_12_LuaFunction_1coroutine, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4lupa_5_lupa_12_LuaFunction_coroutine}, {"__reduce_cython__", (PyCFunction)__pyx_pw_4lupa_5_lupa_12_LuaFunction_3__reduce_cython__, METH_NOARGS, __pyx_doc_4lupa_5_lupa_12_LuaFunction_2__reduce_cython__}, {"__setstate_cython__", (PyCFunction)__pyx_pw_4lupa_5_lupa_12_LuaFunction_5__setstate_cython__, METH_O, __pyx_doc_4lupa_5_lupa_12_LuaFunction_4__setstate_cython__}, {0, 0, 0, 0} }; static PyTypeObject __pyx_type_4lupa_5_lupa__LuaFunction = { PyVarObject_HEAD_INIT(0, 0) "lupa._lupa._LuaFunction", /*tp_name*/ sizeof(struct __pyx_obj_4lupa_5_lupa__LuaFunction), /*tp_basicsize*/ 0, /*tp_itemsize*/ __pyx_tp_dealloc_4lupa_5_lupa__LuaObject, /*tp_dealloc*/ 0, /*tp_print*/ 0, /*tp_getattr*/ 0, /*tp_setattr*/ #if PY_MAJOR_VERSION < 3 0, /*tp_compare*/ #endif #if PY_MAJOR_VERSION >= 3 0, /*tp_as_async*/ #endif #if CYTHON_COMPILING_IN_PYPY __pyx_pw_4lupa_5_lupa_10_LuaObject_13__repr__, /*tp_repr*/ #else 0, /*tp_repr*/ #endif 0, /*tp_as_number*/ 0, /*tp_as_sequence*/ 0, /*tp_as_mapping*/ 0, /*tp_hash*/ #if CYTHON_COMPILING_IN_PYPY __pyx_pw_4lupa_5_lupa_10_LuaObject_5__call__, /*tp_call*/ #else 0, /*tp_call*/ #endif #if CYTHON_COMPILING_IN_PYPY __pyx_pw_4lupa_5_lupa_10_LuaObject_15__str__, /*tp_str*/ #else 0, /*tp_str*/ #endif 0, /*tp_getattro*/ 0, /*tp_setattro*/ 0, /*tp_as_buffer*/ Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/ "A Lua function (which may become a coroutine).\n ", /*tp_doc*/ __pyx_tp_traverse_4lupa_5_lupa__LuaObject, /*tp_traverse*/ 0, /*tp_clear*/ 0, /*tp_richcompare*/ 0, /*tp_weaklistoffset*/ #if CYTHON_COMPILING_IN_PYPY __pyx_pw_4lupa_5_lupa_10_LuaObject_11__iter__, /*tp_iter*/ #else 0, /*tp_iter*/ #endif 0, /*tp_iternext*/ __pyx_methods_4lupa_5_lupa__LuaFunction, /*tp_methods*/ 0, /*tp_members*/ 0, /*tp_getset*/ 0, /*tp_base*/ 0, /*tp_dict*/ 0, /*tp_descr_get*/ 0, /*tp_descr_set*/ 0, /*tp_dictoffset*/ #if CYTHON_COMPILING_IN_PYPY __pyx_pw_4lupa_5_lupa_10_LuaObject_1__init__, /*tp_init*/ #else 0, /*tp_init*/ #endif 0, /*tp_alloc*/ __pyx_tp_new_4lupa_5_lupa__LuaFunction, /*tp_new*/ 0, /*tp_free*/ 0, /*tp_is_gc*/ 0, /*tp_bases*/ 0, /*tp_mro*/ 0, /*tp_cache*/ 0, /*tp_subclasses*/ 0, /*tp_weaklist*/ 0, /*tp_del*/ 0, /*tp_version_tag*/ #if PY_VERSION_HEX >= 0x030400a1 0, /*tp_finalize*/ #endif }; static struct __pyx_vtabstruct_4lupa_5_lupa__LuaCoroutineFunction __pyx_vtable_4lupa_5_lupa__LuaCoroutineFunction; static PyObject *__pyx_tp_new_4lupa_5_lupa__LuaCoroutineFunction(PyTypeObject *t, PyObject *a, PyObject *k) { struct __pyx_obj_4lupa_5_lupa__LuaCoroutineFunction *p; PyObject *o = __pyx_tp_new_4lupa_5_lupa__LuaFunction(t, a, k); if (unlikely(!o)) return 0; p = ((struct __pyx_obj_4lupa_5_lupa__LuaCoroutineFunction *)o); p->__pyx_base.__pyx_base.__pyx_vtab = (struct __pyx_vtabstruct_4lupa_5_lupa__LuaObject*)__pyx_vtabptr_4lupa_5_lupa__LuaCoroutineFunction; return o; } static PyMethodDef __pyx_methods_4lupa_5_lupa__LuaCoroutineFunction[] = { {"__reduce_cython__", (PyCFunction)__pyx_pw_4lupa_5_lupa_21_LuaCoroutineFunction_3__reduce_cython__, METH_NOARGS, __pyx_doc_4lupa_5_lupa_21_LuaCoroutineFunction_2__reduce_cython__}, {"__setstate_cython__", (PyCFunction)__pyx_pw_4lupa_5_lupa_21_LuaCoroutineFunction_5__setstate_cython__, METH_O, __pyx_doc_4lupa_5_lupa_21_LuaCoroutineFunction_4__setstate_cython__}, {0, 0, 0, 0} }; static PyTypeObject __pyx_type_4lupa_5_lupa__LuaCoroutineFunction = { PyVarObject_HEAD_INIT(0, 0) "lupa._lupa._LuaCoroutineFunction", /*tp_name*/ sizeof(struct __pyx_obj_4lupa_5_lupa__LuaCoroutineFunction), /*tp_basicsize*/ 0, /*tp_itemsize*/ __pyx_tp_dealloc_4lupa_5_lupa__LuaObject, /*tp_dealloc*/ 0, /*tp_print*/ 0, /*tp_getattr*/ 0, /*tp_setattr*/ #if PY_MAJOR_VERSION < 3 0, /*tp_compare*/ #endif #if PY_MAJOR_VERSION >= 3 0, /*tp_as_async*/ #endif #if CYTHON_COMPILING_IN_PYPY __pyx_pw_4lupa_5_lupa_10_LuaObject_13__repr__, /*tp_repr*/ #else 0, /*tp_repr*/ #endif 0, /*tp_as_number*/ 0, /*tp_as_sequence*/ 0, /*tp_as_mapping*/ 0, /*tp_hash*/ __pyx_pw_4lupa_5_lupa_21_LuaCoroutineFunction_1__call__, /*tp_call*/ #if CYTHON_COMPILING_IN_PYPY __pyx_pw_4lupa_5_lupa_10_LuaObject_15__str__, /*tp_str*/ #else 0, /*tp_str*/ #endif 0, /*tp_getattro*/ 0, /*tp_setattro*/ 0, /*tp_as_buffer*/ Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC, /*tp_flags*/ "A function that returns a new coroutine when called.\n ", /*tp_doc*/ __pyx_tp_traverse_4lupa_5_lupa__LuaObject, /*tp_traverse*/ 0, /*tp_clear*/ 0, /*tp_richcompare*/ 0, /*tp_weaklistoffset*/ #if CYTHON_COMPILING_IN_PYPY __pyx_pw_4lupa_5_lupa_10_LuaObject_11__iter__, /*tp_iter*/ #else 0, /*tp_iter*/ #endif 0, /*tp_iternext*/ __pyx_methods_4lupa_5_lupa__LuaCoroutineFunction, /*tp_methods*/ 0, /*tp_members*/ 0, /*tp_getset*/ 0, /*tp_base*/ 0, /*tp_dict*/ 0, /*tp_descr_get*/ 0, /*tp_descr_set*/ 0, /*tp_dictoffset*/ #if CYTHON_COMPILING_IN_PYPY __pyx_pw_4lupa_5_lupa_10_LuaObject_1__init__, /*tp_init*/ #else 0, /*tp_init*/ #endif 0, /*tp_alloc*/ __pyx_tp_new_4lupa_5_lupa__LuaCoroutineFunction, /*tp_new*/ 0, /*tp_free*/ 0, /*tp_is_gc*/ 0, /*tp_bases*/ 0, /*tp_mro*/ 0, /*tp_cache*/ 0, /*tp_subclasses*/ 0, /*tp_weaklist*/ 0, /*tp_del*/ 0, /*tp_version_tag*/ #if PY_VERSION_HEX >= 0x030400a1 0, /*tp_finalize*/ #endif }; static struct __pyx_vtabstruct_4lupa_5_lupa__LuaThread __pyx_vtable_4lupa_5_lupa__LuaThread; static PyObject *__pyx_tp_new_4lupa_5_lupa__LuaThread(PyTypeObject *t, PyObject *a, PyObject *k) { struct __pyx_obj_4lupa_5_lupa__LuaThread *p; PyObject *o = __pyx_tp_new_4lupa_5_lupa__LuaObject(t, a, k); if (unlikely(!o)) return 0; p = ((struct __pyx_obj_4lupa_5_lupa__LuaThread *)o); p->__pyx_base.__pyx_vtab = (struct __pyx_vtabstruct_4lupa_5_lupa__LuaObject*)__pyx_vtabptr_4lupa_5_lupa__LuaThread; p->_arguments = ((PyObject*)Py_None); Py_INCREF(Py_None); return o; } static void __pyx_tp_dealloc_4lupa_5_lupa__LuaThread(PyObject *o) { struct __pyx_obj_4lupa_5_lupa__LuaThread *p = (struct __pyx_obj_4lupa_5_lupa__LuaThread *)o; PyObject_GC_UnTrack(o); Py_CLEAR(p->_arguments); PyObject_GC_Track(o); __pyx_tp_dealloc_4lupa_5_lupa__LuaObject(o); } static int __pyx_tp_traverse_4lupa_5_lupa__LuaThread(PyObject *o, visitproc v, void *a) { int e; struct __pyx_obj_4lupa_5_lupa__LuaThread *p = (struct __pyx_obj_4lupa_5_lupa__LuaThread *)o; e = __pyx_tp_traverse_4lupa_5_lupa__LuaObject(o, v, a); if (e) return e; if (p->_arguments) { e = (*v)(p->_arguments, a); if (e) return e; } return 0; } static PyMethodDef __pyx_methods_4lupa_5_lupa__LuaThread[] = { {"__next__", (PyCFunction)__pyx_pw_4lupa_5_lupa_10_LuaThread_3__next__, METH_NOARGS|METH_COEXIST, 0}, {"send", (PyCFunction)__pyx_pw_4lupa_5_lupa_10_LuaThread_5send, METH_O, __pyx_doc_4lupa_5_lupa_10_LuaThread_4send}, {"__reduce_cython__", (PyCFunction)__pyx_pw_4lupa_5_lupa_10_LuaThread_9__reduce_cython__, METH_NOARGS, __pyx_doc_4lupa_5_lupa_10_LuaThread_8__reduce_cython__}, {"__setstate_cython__", (PyCFunction)__pyx_pw_4lupa_5_lupa_10_LuaThread_11__setstate_cython__, METH_O, __pyx_doc_4lupa_5_lupa_10_LuaThread_10__setstate_cython__}, {0, 0, 0, 0} }; static PyNumberMethods __pyx_tp_as_number__LuaThread = { 0, /*nb_add*/ 0, /*nb_subtract*/ 0, /*nb_multiply*/ #if PY_MAJOR_VERSION < 3 || (CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX < 0x03050000) 0, /*nb_divide*/ #endif 0, /*nb_remainder*/ 0, /*nb_divmod*/ 0, /*nb_power*/ 0, /*nb_negative*/ 0, /*nb_positive*/ 0, /*nb_absolute*/ __pyx_pw_4lupa_5_lupa_10_LuaThread_7__bool__, /*nb_nonzero*/ 0, /*nb_invert*/ 0, /*nb_lshift*/ 0, /*nb_rshift*/ 0, /*nb_and*/ 0, /*nb_xor*/ 0, /*nb_or*/ #if PY_MAJOR_VERSION < 3 || (CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX < 0x03050000) 0, /*nb_coerce*/ #endif 0, /*nb_int*/ #if PY_MAJOR_VERSION < 3 0, /*nb_long*/ #else 0, /*reserved*/ #endif 0, /*nb_float*/ #if PY_MAJOR_VERSION < 3 || (CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX < 0x03050000) 0, /*nb_oct*/ #endif #if PY_MAJOR_VERSION < 3 || (CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX < 0x03050000) 0, /*nb_hex*/ #endif 0, /*nb_inplace_add*/ 0, /*nb_inplace_subtract*/ 0, /*nb_inplace_multiply*/ #if PY_MAJOR_VERSION < 3 || (CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX < 0x03050000) 0, /*nb_inplace_divide*/ #endif 0, /*nb_inplace_remainder*/ 0, /*nb_inplace_power*/ 0, /*nb_inplace_lshift*/ 0, /*nb_inplace_rshift*/ 0, /*nb_inplace_and*/ 0, /*nb_inplace_xor*/ 0, /*nb_inplace_or*/ 0, /*nb_floor_divide*/ 0, /*nb_true_divide*/ 0, /*nb_inplace_floor_divide*/ 0, /*nb_inplace_true_divide*/ 0, /*nb_index*/ #if PY_VERSION_HEX >= 0x03050000 0, /*nb_matrix_multiply*/ #endif #if PY_VERSION_HEX >= 0x03050000 0, /*nb_inplace_matrix_multiply*/ #endif }; static PyTypeObject __pyx_type_4lupa_5_lupa__LuaThread = { PyVarObject_HEAD_INIT(0, 0) "lupa._lupa._LuaThread", /*tp_name*/ sizeof(struct __pyx_obj_4lupa_5_lupa__LuaThread), /*tp_basicsize*/ 0, /*tp_itemsize*/ __pyx_tp_dealloc_4lupa_5_lupa__LuaThread, /*tp_dealloc*/ 0, /*tp_print*/ 0, /*tp_getattr*/ 0, /*tp_setattr*/ #if PY_MAJOR_VERSION < 3 0, /*tp_compare*/ #endif #if PY_MAJOR_VERSION >= 3 0, /*tp_as_async*/ #endif #if CYTHON_COMPILING_IN_PYPY __pyx_pw_4lupa_5_lupa_10_LuaObject_13__repr__, /*tp_repr*/ #else 0, /*tp_repr*/ #endif &__pyx_tp_as_number__LuaThread, /*tp_as_number*/ 0, /*tp_as_sequence*/ 0, /*tp_as_mapping*/ 0, /*tp_hash*/ #if CYTHON_COMPILING_IN_PYPY __pyx_pw_4lupa_5_lupa_10_LuaObject_5__call__, /*tp_call*/ #else 0, /*tp_call*/ #endif #if CYTHON_COMPILING_IN_PYPY __pyx_pw_4lupa_5_lupa_10_LuaObject_15__str__, /*tp_str*/ #else 0, /*tp_str*/ #endif 0, /*tp_getattro*/ 0, /*tp_setattro*/ 0, /*tp_as_buffer*/ Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC, /*tp_flags*/ "A Lua thread (coroutine).\n ", /*tp_doc*/ __pyx_tp_traverse_4lupa_5_lupa__LuaThread, /*tp_traverse*/ 0, /*tp_clear*/ 0, /*tp_richcompare*/ 0, /*tp_weaklistoffset*/ __pyx_pw_4lupa_5_lupa_10_LuaThread_1__iter__, /*tp_iter*/ __pyx_pw_4lupa_5_lupa_10_LuaThread_3__next__, /*tp_iternext*/ __pyx_methods_4lupa_5_lupa__LuaThread, /*tp_methods*/ 0, /*tp_members*/ 0, /*tp_getset*/ 0, /*tp_base*/ 0, /*tp_dict*/ 0, /*tp_descr_get*/ 0, /*tp_descr_set*/ 0, /*tp_dictoffset*/ #if CYTHON_COMPILING_IN_PYPY __pyx_pw_4lupa_5_lupa_10_LuaObject_1__init__, /*tp_init*/ #else 0, /*tp_init*/ #endif 0, /*tp_alloc*/ __pyx_tp_new_4lupa_5_lupa__LuaThread, /*tp_new*/ 0, /*tp_free*/ 0, /*tp_is_gc*/ 0, /*tp_bases*/ 0, /*tp_mro*/ 0, /*tp_cache*/ 0, /*tp_subclasses*/ 0, /*tp_weaklist*/ 0, /*tp_del*/ 0, /*tp_version_tag*/ #if PY_VERSION_HEX >= 0x030400a1 0, /*tp_finalize*/ #endif }; static PyObject *__pyx_tp_new_4lupa_5_lupa__LuaIter(PyTypeObject *t, PyObject *a, PyObject *k) { struct __pyx_obj_4lupa_5_lupa__LuaIter *p; PyObject *o; o = (*t->tp_alloc)(t, 0); if (unlikely(!o)) return 0; p = ((struct __pyx_obj_4lupa_5_lupa__LuaIter *)o); p->_runtime = ((struct __pyx_obj_4lupa_5_lupa_LuaRuntime *)Py_None); Py_INCREF(Py_None); p->_obj = ((struct __pyx_obj_4lupa_5_lupa__LuaObject *)Py_None); Py_INCREF(Py_None); if (unlikely(__pyx_pw_4lupa_5_lupa_8_LuaIter_1__cinit__(o, a, k) < 0)) goto bad; return o; bad: Py_DECREF(o); o = 0; return NULL; } static void __pyx_tp_dealloc_4lupa_5_lupa__LuaIter(PyObject *o) { struct __pyx_obj_4lupa_5_lupa__LuaIter *p = (struct __pyx_obj_4lupa_5_lupa__LuaIter *)o; PyObject_GC_UnTrack(o); { PyObject *etype, *eval, *etb; PyErr_Fetch(&etype, &eval, &etb); ++Py_REFCNT(o); __pyx_pw_4lupa_5_lupa_8_LuaIter_3__dealloc__(o); --Py_REFCNT(o); PyErr_Restore(etype, eval, etb); } Py_CLEAR(p->_runtime); Py_CLEAR(p->_obj); (*Py_TYPE(o)->tp_free)(o); } static int __pyx_tp_traverse_4lupa_5_lupa__LuaIter(PyObject *o, visitproc v, void *a) { int e; struct __pyx_obj_4lupa_5_lupa__LuaIter *p = (struct __pyx_obj_4lupa_5_lupa__LuaIter *)o; if (p->_runtime) { e = (*v)(((PyObject *)p->_runtime), a); if (e) return e; } if (p->_obj) { e = (*v)(((PyObject *)p->_obj), a); if (e) return e; } return 0; } static PyMethodDef __pyx_methods_4lupa_5_lupa__LuaIter[] = { {"__next__", (PyCFunction)__pyx_pw_4lupa_5_lupa_8_LuaIter_9__next__, METH_NOARGS|METH_COEXIST, 0}, {"__reduce_cython__", (PyCFunction)__pyx_pw_4lupa_5_lupa_8_LuaIter_11__reduce_cython__, METH_NOARGS, __pyx_doc_4lupa_5_lupa_8_LuaIter_10__reduce_cython__}, {"__setstate_cython__", (PyCFunction)__pyx_pw_4lupa_5_lupa_8_LuaIter_13__setstate_cython__, METH_O, __pyx_doc_4lupa_5_lupa_8_LuaIter_12__setstate_cython__}, {0, 0, 0, 0} }; static PyTypeObject __pyx_type_4lupa_5_lupa__LuaIter = { PyVarObject_HEAD_INIT(0, 0) "lupa._lupa._LuaIter", /*tp_name*/ sizeof(struct __pyx_obj_4lupa_5_lupa__LuaIter), /*tp_basicsize*/ 0, /*tp_itemsize*/ __pyx_tp_dealloc_4lupa_5_lupa__LuaIter, /*tp_dealloc*/ 0, /*tp_print*/ 0, /*tp_getattr*/ 0, /*tp_setattr*/ #if PY_MAJOR_VERSION < 3 0, /*tp_compare*/ #endif #if PY_MAJOR_VERSION >= 3 0, /*tp_as_async*/ #endif __pyx_pw_4lupa_5_lupa_8_LuaIter_5__repr__, /*tp_repr*/ 0, /*tp_as_number*/ 0, /*tp_as_sequence*/ 0, /*tp_as_mapping*/ 0, /*tp_hash*/ 0, /*tp_call*/ 0, /*tp_str*/ 0, /*tp_getattro*/ 0, /*tp_setattro*/ 0, /*tp_as_buffer*/ Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC, /*tp_flags*/ 0, /*tp_doc*/ __pyx_tp_traverse_4lupa_5_lupa__LuaIter, /*tp_traverse*/ 0, /*tp_clear*/ 0, /*tp_richcompare*/ 0, /*tp_weaklistoffset*/ __pyx_pw_4lupa_5_lupa_8_LuaIter_7__iter__, /*tp_iter*/ __pyx_pw_4lupa_5_lupa_8_LuaIter_9__next__, /*tp_iternext*/ __pyx_methods_4lupa_5_lupa__LuaIter, /*tp_methods*/ 0, /*tp_members*/ 0, /*tp_getset*/ 0, /*tp_base*/ 0, /*tp_dict*/ 0, /*tp_descr_get*/ 0, /*tp_descr_set*/ 0, /*tp_dictoffset*/ 0, /*tp_init*/ 0, /*tp_alloc*/ __pyx_tp_new_4lupa_5_lupa__LuaIter, /*tp_new*/ 0, /*tp_free*/ 0, /*tp_is_gc*/ 0, /*tp_bases*/ 0, /*tp_mro*/ 0, /*tp_cache*/ 0, /*tp_subclasses*/ 0, /*tp_weaklist*/ 0, /*tp_del*/ 0, /*tp_version_tag*/ #if PY_VERSION_HEX >= 0x030400a1 0, /*tp_finalize*/ #endif }; static struct __pyx_obj_4lupa_5_lupa__PyProtocolWrapper *__pyx_freelist_4lupa_5_lupa__PyProtocolWrapper[8]; static int __pyx_freecount_4lupa_5_lupa__PyProtocolWrapper = 0; static PyObject *__pyx_tp_new_4lupa_5_lupa__PyProtocolWrapper(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) { struct __pyx_obj_4lupa_5_lupa__PyProtocolWrapper *p; PyObject *o; if (CYTHON_COMPILING_IN_CPYTHON && likely((__pyx_freecount_4lupa_5_lupa__PyProtocolWrapper > 0) & (t->tp_basicsize == sizeof(struct __pyx_obj_4lupa_5_lupa__PyProtocolWrapper)))) { o = (PyObject*)__pyx_freelist_4lupa_5_lupa__PyProtocolWrapper[--__pyx_freecount_4lupa_5_lupa__PyProtocolWrapper]; memset(o, 0, sizeof(struct __pyx_obj_4lupa_5_lupa__PyProtocolWrapper)); (void) PyObject_INIT(o, t); PyObject_GC_Track(o); } else { o = (*t->tp_alloc)(t, 0); if (unlikely(!o)) return 0; } p = ((struct __pyx_obj_4lupa_5_lupa__PyProtocolWrapper *)o); p->_obj = Py_None; Py_INCREF(Py_None); if (unlikely(__pyx_pw_4lupa_5_lupa_18_PyProtocolWrapper_1__cinit__(o, __pyx_empty_tuple, NULL) < 0)) goto bad; return o; bad: Py_DECREF(o); o = 0; return NULL; } static void __pyx_tp_dealloc_4lupa_5_lupa__PyProtocolWrapper(PyObject *o) { struct __pyx_obj_4lupa_5_lupa__PyProtocolWrapper *p = (struct __pyx_obj_4lupa_5_lupa__PyProtocolWrapper *)o; PyObject_GC_UnTrack(o); Py_CLEAR(p->_obj); if (CYTHON_COMPILING_IN_CPYTHON && ((__pyx_freecount_4lupa_5_lupa__PyProtocolWrapper < 8) & (Py_TYPE(o)->tp_basicsize == sizeof(struct __pyx_obj_4lupa_5_lupa__PyProtocolWrapper)))) { __pyx_freelist_4lupa_5_lupa__PyProtocolWrapper[__pyx_freecount_4lupa_5_lupa__PyProtocolWrapper++] = ((struct __pyx_obj_4lupa_5_lupa__PyProtocolWrapper *)o); } else { (*Py_TYPE(o)->tp_free)(o); } } static int __pyx_tp_traverse_4lupa_5_lupa__PyProtocolWrapper(PyObject *o, visitproc v, void *a) { int e; struct __pyx_obj_4lupa_5_lupa__PyProtocolWrapper *p = (struct __pyx_obj_4lupa_5_lupa__PyProtocolWrapper *)o; if (p->_obj) { e = (*v)(p->_obj, a); if (e) return e; } return 0; } static int __pyx_tp_clear_4lupa_5_lupa__PyProtocolWrapper(PyObject *o) { PyObject* tmp; struct __pyx_obj_4lupa_5_lupa__PyProtocolWrapper *p = (struct __pyx_obj_4lupa_5_lupa__PyProtocolWrapper *)o; tmp = ((PyObject*)p->_obj); p->_obj = Py_None; Py_INCREF(Py_None); Py_XDECREF(tmp); return 0; } static PyMethodDef __pyx_methods_4lupa_5_lupa__PyProtocolWrapper[] = { {"__reduce_cython__", (PyCFunction)__pyx_pw_4lupa_5_lupa_18_PyProtocolWrapper_5__reduce_cython__, METH_NOARGS, __pyx_doc_4lupa_5_lupa_18_PyProtocolWrapper_4__reduce_cython__}, {"__setstate_cython__", (PyCFunction)__pyx_pw_4lupa_5_lupa_18_PyProtocolWrapper_7__setstate_cython__, METH_O, __pyx_doc_4lupa_5_lupa_18_PyProtocolWrapper_6__setstate_cython__}, {0, 0, 0, 0} }; static PyTypeObject __pyx_type_4lupa_5_lupa__PyProtocolWrapper = { PyVarObject_HEAD_INIT(0, 0) "lupa._lupa._PyProtocolWrapper", /*tp_name*/ sizeof(struct __pyx_obj_4lupa_5_lupa__PyProtocolWrapper), /*tp_basicsize*/ 0, /*tp_itemsize*/ __pyx_tp_dealloc_4lupa_5_lupa__PyProtocolWrapper, /*tp_dealloc*/ 0, /*tp_print*/ 0, /*tp_getattr*/ 0, /*tp_setattr*/ #if PY_MAJOR_VERSION < 3 0, /*tp_compare*/ #endif #if PY_MAJOR_VERSION >= 3 0, /*tp_as_async*/ #endif 0, /*tp_repr*/ 0, /*tp_as_number*/ 0, /*tp_as_sequence*/ 0, /*tp_as_mapping*/ 0, /*tp_hash*/ 0, /*tp_call*/ 0, /*tp_str*/ 0, /*tp_getattro*/ 0, /*tp_setattro*/ 0, /*tp_as_buffer*/ Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC, /*tp_flags*/ "_PyProtocolWrapper()", /*tp_doc*/ __pyx_tp_traverse_4lupa_5_lupa__PyProtocolWrapper, /*tp_traverse*/ __pyx_tp_clear_4lupa_5_lupa__PyProtocolWrapper, /*tp_clear*/ 0, /*tp_richcompare*/ 0, /*tp_weaklistoffset*/ 0, /*tp_iter*/ 0, /*tp_iternext*/ __pyx_methods_4lupa_5_lupa__PyProtocolWrapper, /*tp_methods*/ 0, /*tp_members*/ 0, /*tp_getset*/ 0, /*tp_base*/ 0, /*tp_dict*/ 0, /*tp_descr_get*/ 0, /*tp_descr_set*/ 0, /*tp_dictoffset*/ __pyx_pw_4lupa_5_lupa_18_PyProtocolWrapper_3__init__, /*tp_init*/ 0, /*tp_alloc*/ __pyx_tp_new_4lupa_5_lupa__PyProtocolWrapper, /*tp_new*/ 0, /*tp_free*/ 0, /*tp_is_gc*/ 0, /*tp_bases*/ 0, /*tp_mro*/ 0, /*tp_cache*/ 0, /*tp_subclasses*/ 0, /*tp_weaklist*/ 0, /*tp_del*/ 0, /*tp_version_tag*/ #if PY_VERSION_HEX >= 0x030400a1 0, /*tp_finalize*/ #endif }; static struct __pyx_obj_4lupa_5_lupa___pyx_scope_struct__unpacks_lua_table *__pyx_freelist_4lupa_5_lupa___pyx_scope_struct__unpacks_lua_table[8]; static int __pyx_freecount_4lupa_5_lupa___pyx_scope_struct__unpacks_lua_table = 0; static PyObject *__pyx_tp_new_4lupa_5_lupa___pyx_scope_struct__unpacks_lua_table(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) { PyObject *o; if (CYTHON_COMPILING_IN_CPYTHON && likely((__pyx_freecount_4lupa_5_lupa___pyx_scope_struct__unpacks_lua_table > 0) & (t->tp_basicsize == sizeof(struct __pyx_obj_4lupa_5_lupa___pyx_scope_struct__unpacks_lua_table)))) { o = (PyObject*)__pyx_freelist_4lupa_5_lupa___pyx_scope_struct__unpacks_lua_table[--__pyx_freecount_4lupa_5_lupa___pyx_scope_struct__unpacks_lua_table]; memset(o, 0, sizeof(struct __pyx_obj_4lupa_5_lupa___pyx_scope_struct__unpacks_lua_table)); (void) PyObject_INIT(o, t); PyObject_GC_Track(o); } else { o = (*t->tp_alloc)(t, 0); if (unlikely(!o)) return 0; } return o; } static void __pyx_tp_dealloc_4lupa_5_lupa___pyx_scope_struct__unpacks_lua_table(PyObject *o) { struct __pyx_obj_4lupa_5_lupa___pyx_scope_struct__unpacks_lua_table *p = (struct __pyx_obj_4lupa_5_lupa___pyx_scope_struct__unpacks_lua_table *)o; PyObject_GC_UnTrack(o); Py_CLEAR(p->__pyx_v_func); if (CYTHON_COMPILING_IN_CPYTHON && ((__pyx_freecount_4lupa_5_lupa___pyx_scope_struct__unpacks_lua_table < 8) & (Py_TYPE(o)->tp_basicsize == sizeof(struct __pyx_obj_4lupa_5_lupa___pyx_scope_struct__unpacks_lua_table)))) { __pyx_freelist_4lupa_5_lupa___pyx_scope_struct__unpacks_lua_table[__pyx_freecount_4lupa_5_lupa___pyx_scope_struct__unpacks_lua_table++] = ((struct __pyx_obj_4lupa_5_lupa___pyx_scope_struct__unpacks_lua_table *)o); } else { (*Py_TYPE(o)->tp_free)(o); } } static int __pyx_tp_traverse_4lupa_5_lupa___pyx_scope_struct__unpacks_lua_table(PyObject *o, visitproc v, void *a) { int e; struct __pyx_obj_4lupa_5_lupa___pyx_scope_struct__unpacks_lua_table *p = (struct __pyx_obj_4lupa_5_lupa___pyx_scope_struct__unpacks_lua_table *)o; if (p->__pyx_v_func) { e = (*v)(p->__pyx_v_func, a); if (e) return e; } return 0; } static int __pyx_tp_clear_4lupa_5_lupa___pyx_scope_struct__unpacks_lua_table(PyObject *o) { PyObject* tmp; struct __pyx_obj_4lupa_5_lupa___pyx_scope_struct__unpacks_lua_table *p = (struct __pyx_obj_4lupa_5_lupa___pyx_scope_struct__unpacks_lua_table *)o; tmp = ((PyObject*)p->__pyx_v_func); p->__pyx_v_func = Py_None; Py_INCREF(Py_None); Py_XDECREF(tmp); return 0; } static PyTypeObject __pyx_type_4lupa_5_lupa___pyx_scope_struct__unpacks_lua_table = { PyVarObject_HEAD_INIT(0, 0) "lupa._lupa.__pyx_scope_struct__unpacks_lua_table", /*tp_name*/ sizeof(struct __pyx_obj_4lupa_5_lupa___pyx_scope_struct__unpacks_lua_table), /*tp_basicsize*/ 0, /*tp_itemsize*/ __pyx_tp_dealloc_4lupa_5_lupa___pyx_scope_struct__unpacks_lua_table, /*tp_dealloc*/ 0, /*tp_print*/ 0, /*tp_getattr*/ 0, /*tp_setattr*/ #if PY_MAJOR_VERSION < 3 0, /*tp_compare*/ #endif #if PY_MAJOR_VERSION >= 3 0, /*tp_as_async*/ #endif 0, /*tp_repr*/ 0, /*tp_as_number*/ 0, /*tp_as_sequence*/ 0, /*tp_as_mapping*/ 0, /*tp_hash*/ 0, /*tp_call*/ 0, /*tp_str*/ 0, /*tp_getattro*/ 0, /*tp_setattro*/ 0, /*tp_as_buffer*/ Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC, /*tp_flags*/ 0, /*tp_doc*/ __pyx_tp_traverse_4lupa_5_lupa___pyx_scope_struct__unpacks_lua_table, /*tp_traverse*/ __pyx_tp_clear_4lupa_5_lupa___pyx_scope_struct__unpacks_lua_table, /*tp_clear*/ 0, /*tp_richcompare*/ 0, /*tp_weaklistoffset*/ 0, /*tp_iter*/ 0, /*tp_iternext*/ 0, /*tp_methods*/ 0, /*tp_members*/ 0, /*tp_getset*/ 0, /*tp_base*/ 0, /*tp_dict*/ 0, /*tp_descr_get*/ 0, /*tp_descr_set*/ 0, /*tp_dictoffset*/ 0, /*tp_init*/ 0, /*tp_alloc*/ __pyx_tp_new_4lupa_5_lupa___pyx_scope_struct__unpacks_lua_table, /*tp_new*/ 0, /*tp_free*/ 0, /*tp_is_gc*/ 0, /*tp_bases*/ 0, /*tp_mro*/ 0, /*tp_cache*/ 0, /*tp_subclasses*/ 0, /*tp_weaklist*/ 0, /*tp_del*/ 0, /*tp_version_tag*/ #if PY_VERSION_HEX >= 0x030400a1 0, /*tp_finalize*/ #endif }; static struct __pyx_obj_4lupa_5_lupa___pyx_scope_struct_1_unpacks_lua_table_method *__pyx_freelist_4lupa_5_lupa___pyx_scope_struct_1_unpacks_lua_table_method[8]; static int __pyx_freecount_4lupa_5_lupa___pyx_scope_struct_1_unpacks_lua_table_method = 0; static PyObject *__pyx_tp_new_4lupa_5_lupa___pyx_scope_struct_1_unpacks_lua_table_method(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) { PyObject *o; if (CYTHON_COMPILING_IN_CPYTHON && likely((__pyx_freecount_4lupa_5_lupa___pyx_scope_struct_1_unpacks_lua_table_method > 0) & (t->tp_basicsize == sizeof(struct __pyx_obj_4lupa_5_lupa___pyx_scope_struct_1_unpacks_lua_table_method)))) { o = (PyObject*)__pyx_freelist_4lupa_5_lupa___pyx_scope_struct_1_unpacks_lua_table_method[--__pyx_freecount_4lupa_5_lupa___pyx_scope_struct_1_unpacks_lua_table_method]; memset(o, 0, sizeof(struct __pyx_obj_4lupa_5_lupa___pyx_scope_struct_1_unpacks_lua_table_method)); (void) PyObject_INIT(o, t); PyObject_GC_Track(o); } else { o = (*t->tp_alloc)(t, 0); if (unlikely(!o)) return 0; } return o; } static void __pyx_tp_dealloc_4lupa_5_lupa___pyx_scope_struct_1_unpacks_lua_table_method(PyObject *o) { struct __pyx_obj_4lupa_5_lupa___pyx_scope_struct_1_unpacks_lua_table_method *p = (struct __pyx_obj_4lupa_5_lupa___pyx_scope_struct_1_unpacks_lua_table_method *)o; PyObject_GC_UnTrack(o); Py_CLEAR(p->__pyx_v_meth); if (CYTHON_COMPILING_IN_CPYTHON && ((__pyx_freecount_4lupa_5_lupa___pyx_scope_struct_1_unpacks_lua_table_method < 8) & (Py_TYPE(o)->tp_basicsize == sizeof(struct __pyx_obj_4lupa_5_lupa___pyx_scope_struct_1_unpacks_lua_table_method)))) { __pyx_freelist_4lupa_5_lupa___pyx_scope_struct_1_unpacks_lua_table_method[__pyx_freecount_4lupa_5_lupa___pyx_scope_struct_1_unpacks_lua_table_method++] = ((struct __pyx_obj_4lupa_5_lupa___pyx_scope_struct_1_unpacks_lua_table_method *)o); } else { (*Py_TYPE(o)->tp_free)(o); } } static int __pyx_tp_traverse_4lupa_5_lupa___pyx_scope_struct_1_unpacks_lua_table_method(PyObject *o, visitproc v, void *a) { int e; struct __pyx_obj_4lupa_5_lupa___pyx_scope_struct_1_unpacks_lua_table_method *p = (struct __pyx_obj_4lupa_5_lupa___pyx_scope_struct_1_unpacks_lua_table_method *)o; if (p->__pyx_v_meth) { e = (*v)(p->__pyx_v_meth, a); if (e) return e; } return 0; } static int __pyx_tp_clear_4lupa_5_lupa___pyx_scope_struct_1_unpacks_lua_table_method(PyObject *o) { PyObject* tmp; struct __pyx_obj_4lupa_5_lupa___pyx_scope_struct_1_unpacks_lua_table_method *p = (struct __pyx_obj_4lupa_5_lupa___pyx_scope_struct_1_unpacks_lua_table_method *)o; tmp = ((PyObject*)p->__pyx_v_meth); p->__pyx_v_meth = Py_None; Py_INCREF(Py_None); Py_XDECREF(tmp); return 0; } static PyTypeObject __pyx_type_4lupa_5_lupa___pyx_scope_struct_1_unpacks_lua_table_method = { PyVarObject_HEAD_INIT(0, 0) "lupa._lupa.__pyx_scope_struct_1_unpacks_lua_table_method", /*tp_name*/ sizeof(struct __pyx_obj_4lupa_5_lupa___pyx_scope_struct_1_unpacks_lua_table_method), /*tp_basicsize*/ 0, /*tp_itemsize*/ __pyx_tp_dealloc_4lupa_5_lupa___pyx_scope_struct_1_unpacks_lua_table_method, /*tp_dealloc*/ 0, /*tp_print*/ 0, /*tp_getattr*/ 0, /*tp_setattr*/ #if PY_MAJOR_VERSION < 3 0, /*tp_compare*/ #endif #if PY_MAJOR_VERSION >= 3 0, /*tp_as_async*/ #endif 0, /*tp_repr*/ 0, /*tp_as_number*/ 0, /*tp_as_sequence*/ 0, /*tp_as_mapping*/ 0, /*tp_hash*/ 0, /*tp_call*/ 0, /*tp_str*/ 0, /*tp_getattro*/ 0, /*tp_setattro*/ 0, /*tp_as_buffer*/ Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC, /*tp_flags*/ 0, /*tp_doc*/ __pyx_tp_traverse_4lupa_5_lupa___pyx_scope_struct_1_unpacks_lua_table_method, /*tp_traverse*/ __pyx_tp_clear_4lupa_5_lupa___pyx_scope_struct_1_unpacks_lua_table_method, /*tp_clear*/ 0, /*tp_richcompare*/ 0, /*tp_weaklistoffset*/ 0, /*tp_iter*/ 0, /*tp_iternext*/ 0, /*tp_methods*/ 0, /*tp_members*/ 0, /*tp_getset*/ 0, /*tp_base*/ 0, /*tp_dict*/ 0, /*tp_descr_get*/ 0, /*tp_descr_set*/ 0, /*tp_dictoffset*/ 0, /*tp_init*/ 0, /*tp_alloc*/ __pyx_tp_new_4lupa_5_lupa___pyx_scope_struct_1_unpacks_lua_table_method, /*tp_new*/ 0, /*tp_free*/ 0, /*tp_is_gc*/ 0, /*tp_bases*/ 0, /*tp_mro*/ 0, /*tp_cache*/ 0, /*tp_subclasses*/ 0, /*tp_weaklist*/ 0, /*tp_del*/ 0, /*tp_version_tag*/ #if PY_VERSION_HEX >= 0x030400a1 0, /*tp_finalize*/ #endif }; static PyMethodDef __pyx_methods[] = { {0, 0, 0, 0} }; #if PY_MAJOR_VERSION >= 3 #if CYTHON_PEP489_MULTI_PHASE_INIT static PyObject* __pyx_pymod_create(PyObject *spec, PyModuleDef *def); /*proto*/ static int __pyx_pymod_exec__lupa(PyObject* module); /*proto*/ static PyModuleDef_Slot __pyx_moduledef_slots[] = { {Py_mod_create, (void*)__pyx_pymod_create}, {Py_mod_exec, (void*)__pyx_pymod_exec__lupa}, {0, NULL} }; #endif static struct PyModuleDef __pyx_moduledef = { PyModuleDef_HEAD_INIT, "_lupa", __pyx_k_A_fast_Python_wrapper_around_Lu, /* m_doc */ #if CYTHON_PEP489_MULTI_PHASE_INIT 0, /* m_size */ #else -1, /* m_size */ #endif __pyx_methods /* m_methods */, #if CYTHON_PEP489_MULTI_PHASE_INIT __pyx_moduledef_slots, /* m_slots */ #else NULL, /* m_reload */ #endif NULL, /* m_traverse */ NULL, /* m_clear */ NULL /* m_free */ }; #endif static __Pyx_StringTabEntry __pyx_string_tab[] = { {&__pyx_n_s_AttributeError, __pyx_k_AttributeError, sizeof(__pyx_k_AttributeError), 0, 0, 1, 1}, {&__pyx_n_s_BaseException, __pyx_k_BaseException, sizeof(__pyx_k_BaseException), 0, 0, 1, 1}, {&__pyx_kp_s_Base_class_for_errors_in_the_Lua, __pyx_k_Base_class_for_errors_in_the_Lua, sizeof(__pyx_k_Base_class_for_errors_in_the_Lua), 0, 0, 1, 0}, {&__pyx_kp_s_Failed_to_acquire_thread_lock, __pyx_k_Failed_to_acquire_thread_lock, sizeof(__pyx_k_Failed_to_acquire_thread_lock), 0, 0, 1, 0}, {&__pyx_kp_s_Failed_to_initialise_Lua_runtime, __pyx_k_Failed_to_initialise_Lua_runtime, sizeof(__pyx_k_Failed_to_initialise_Lua_runtime), 0, 0, 1, 0}, {&__pyx_n_s_FastRLock___enter, __pyx_k_FastRLock___enter, sizeof(__pyx_k_FastRLock___enter), 0, 0, 1, 1}, {&__pyx_n_s_FastRLock___exit, __pyx_k_FastRLock___exit, sizeof(__pyx_k_FastRLock___exit), 0, 0, 1, 1}, {&__pyx_n_s_FastRLock___reduce_cython, __pyx_k_FastRLock___reduce_cython, sizeof(__pyx_k_FastRLock___reduce_cython), 0, 0, 1, 1}, {&__pyx_n_s_FastRLock___setstate_cython, __pyx_k_FastRLock___setstate_cython, sizeof(__pyx_k_FastRLock___setstate_cython), 0, 0, 1, 1}, {&__pyx_n_s_FastRLock__is_owned, __pyx_k_FastRLock__is_owned, sizeof(__pyx_k_FastRLock__is_owned), 0, 0, 1, 1}, {&__pyx_n_s_FastRLock_acquire, __pyx_k_FastRLock_acquire, sizeof(__pyx_k_FastRLock_acquire), 0, 0, 1, 1}, {&__pyx_n_s_FastRLock_release, __pyx_k_FastRLock_release, sizeof(__pyx_k_FastRLock_release), 0, 0, 1, 1}, {&__pyx_n_s_ImportError, __pyx_k_ImportError, sizeof(__pyx_k_ImportError), 0, 0, 1, 1}, {&__pyx_n_s_KeyError, __pyx_k_KeyError, sizeof(__pyx_k_KeyError), 0, 0, 1, 1}, {&__pyx_n_s_L, __pyx_k_L, sizeof(__pyx_k_L), 0, 0, 1, 1}, {&__pyx_n_s_LuaCoroutineFunction___reduce_c, __pyx_k_LuaCoroutineFunction___reduce_c, sizeof(__pyx_k_LuaCoroutineFunction___reduce_c), 0, 0, 1, 1}, {&__pyx_n_s_LuaCoroutineFunction___setstate, __pyx_k_LuaCoroutineFunction___setstate, sizeof(__pyx_k_LuaCoroutineFunction___setstate), 0, 0, 1, 1}, {&__pyx_n_s_LuaError, __pyx_k_LuaError, sizeof(__pyx_k_LuaError), 0, 0, 1, 1}, {&__pyx_n_s_LuaFunction___reduce_cython, __pyx_k_LuaFunction___reduce_cython, sizeof(__pyx_k_LuaFunction___reduce_cython), 0, 0, 1, 1}, {&__pyx_n_s_LuaFunction___setstate_cython, __pyx_k_LuaFunction___setstate_cython, sizeof(__pyx_k_LuaFunction___setstate_cython), 0, 0, 1, 1}, {&__pyx_n_s_LuaFunction_coroutine, __pyx_k_LuaFunction_coroutine, sizeof(__pyx_k_LuaFunction_coroutine), 0, 0, 1, 1}, {&__pyx_n_s_LuaIter___reduce_cython, __pyx_k_LuaIter___reduce_cython, sizeof(__pyx_k_LuaIter___reduce_cython), 0, 0, 1, 1}, {&__pyx_n_s_LuaIter___setstate_cython, __pyx_k_LuaIter___setstate_cython, sizeof(__pyx_k_LuaIter___setstate_cython), 0, 0, 1, 1}, {&__pyx_kp_u_LuaIter_r, __pyx_k_LuaIter_r, sizeof(__pyx_k_LuaIter_r), 0, 1, 0, 0}, {&__pyx_n_s_LuaObject___reduce_cython, __pyx_k_LuaObject___reduce_cython, sizeof(__pyx_k_LuaObject___reduce_cython), 0, 0, 1, 1}, {&__pyx_n_s_LuaObject___setstate_cython, __pyx_k_LuaObject___setstate_cython, sizeof(__pyx_k_LuaObject___setstate_cython), 0, 0, 1, 1}, {&__pyx_n_s_LuaRuntime, __pyx_k_LuaRuntime, sizeof(__pyx_k_LuaRuntime), 0, 0, 1, 1}, {&__pyx_n_s_LuaRuntime___reduce_cython, __pyx_k_LuaRuntime___reduce_cython, sizeof(__pyx_k_LuaRuntime___reduce_cython), 0, 0, 1, 1}, {&__pyx_n_s_LuaRuntime___setstate_cython, __pyx_k_LuaRuntime___setstate_cython, sizeof(__pyx_k_LuaRuntime___setstate_cython), 0, 0, 1, 1}, {&__pyx_n_s_LuaRuntime_compile, __pyx_k_LuaRuntime_compile, sizeof(__pyx_k_LuaRuntime_compile), 0, 0, 1, 1}, {&__pyx_n_s_LuaRuntime_eval, __pyx_k_LuaRuntime_eval, sizeof(__pyx_k_LuaRuntime_eval), 0, 0, 1, 1}, {&__pyx_n_s_LuaRuntime_execute, __pyx_k_LuaRuntime_execute, sizeof(__pyx_k_LuaRuntime_execute), 0, 0, 1, 1}, {&__pyx_n_s_LuaRuntime_globals, __pyx_k_LuaRuntime_globals, sizeof(__pyx_k_LuaRuntime_globals), 0, 0, 1, 1}, {&__pyx_n_s_LuaRuntime_require, __pyx_k_LuaRuntime_require, sizeof(__pyx_k_LuaRuntime_require), 0, 0, 1, 1}, {&__pyx_n_s_LuaRuntime_table, __pyx_k_LuaRuntime_table, sizeof(__pyx_k_LuaRuntime_table), 0, 0, 1, 1}, {&__pyx_n_s_LuaRuntime_table_from, __pyx_k_LuaRuntime_table_from, sizeof(__pyx_k_LuaRuntime_table_from), 0, 0, 1, 1}, {&__pyx_n_s_LuaSyntaxError, __pyx_k_LuaSyntaxError, sizeof(__pyx_k_LuaSyntaxError), 0, 0, 1, 1}, {&__pyx_n_s_LuaTable___reduce_cython, __pyx_k_LuaTable___reduce_cython, sizeof(__pyx_k_LuaTable___reduce_cython), 0, 0, 1, 1}, {&__pyx_n_s_LuaTable___setstate_cython, __pyx_k_LuaTable___setstate_cython, sizeof(__pyx_k_LuaTable___setstate_cython), 0, 0, 1, 1}, {&__pyx_n_s_LuaTable_items, __pyx_k_LuaTable_items, sizeof(__pyx_k_LuaTable_items), 0, 0, 1, 1}, {&__pyx_n_s_LuaTable_keys, __pyx_k_LuaTable_keys, sizeof(__pyx_k_LuaTable_keys), 0, 0, 1, 1}, {&__pyx_n_s_LuaTable_values, __pyx_k_LuaTable_values, sizeof(__pyx_k_LuaTable_values), 0, 0, 1, 1}, {&__pyx_n_s_LuaThread___reduce_cython, __pyx_k_LuaThread___reduce_cython, sizeof(__pyx_k_LuaThread___reduce_cython), 0, 0, 1, 1}, {&__pyx_n_s_LuaThread___setstate_cython, __pyx_k_LuaThread___setstate_cython, sizeof(__pyx_k_LuaThread___setstate_cython), 0, 0, 1, 1}, {&__pyx_n_s_LuaThread_send, __pyx_k_LuaThread_send, sizeof(__pyx_k_LuaThread_send), 0, 0, 1, 1}, {&__pyx_kp_s_Lua_object_is_not_a_function, __pyx_k_Lua_object_is_not_a_function, sizeof(__pyx_k_Lua_object_is_not_a_function), 0, 0, 1, 0}, {&__pyx_n_s_Mapping, __pyx_k_Mapping, sizeof(__pyx_k_Mapping), 0, 0, 1, 1}, {&__pyx_n_s_MemoryError, __pyx_k_MemoryError, sizeof(__pyx_k_MemoryError), 0, 0, 1, 1}, {&__pyx_n_s_PyProtocolWrapper___reduce_cyth, __pyx_k_PyProtocolWrapper___reduce_cyth, sizeof(__pyx_k_PyProtocolWrapper___reduce_cyth), 0, 0, 1, 1}, {&__pyx_n_s_PyProtocolWrapper___setstate_cy, __pyx_k_PyProtocolWrapper___setstate_cy, sizeof(__pyx_k_PyProtocolWrapper___setstate_cy), 0, 0, 1, 1}, {&__pyx_n_b_Py_None, __pyx_k_Py_None, sizeof(__pyx_k_Py_None), 0, 0, 0, 1}, {&__pyx_n_s_RuntimeError, __pyx_k_RuntimeError, sizeof(__pyx_k_RuntimeError), 0, 0, 1, 1}, {&__pyx_n_s_StopIteration, __pyx_k_StopIteration, sizeof(__pyx_k_StopIteration), 0, 0, 1, 1}, {&__pyx_kp_s_Syntax_error_in_Lua_code, __pyx_k_Syntax_error_in_Lua_code, sizeof(__pyx_k_Syntax_error_in_Lua_code), 0, 0, 1, 0}, {&__pyx_n_s_TypeError, __pyx_k_TypeError, sizeof(__pyx_k_TypeError), 0, 0, 1, 1}, {&__pyx_kp_s_Type_cannot_be_instantiated_from, __pyx_k_Type_cannot_be_instantiated_from, sizeof(__pyx_k_Type_cannot_be_instantiated_from), 0, 0, 1, 0}, {&__pyx_kp_s_Type_cannot_be_instantiated_manu, __pyx_k_Type_cannot_be_instantiated_manu, sizeof(__pyx_k_Type_cannot_be_instantiated_manu), 0, 0, 1, 0}, {&__pyx_kp_b_UTF_8, __pyx_k_UTF_8, sizeof(__pyx_k_UTF_8), 0, 0, 0, 0}, {&__pyx_kp_s_UTF_8, __pyx_k_UTF_8, sizeof(__pyx_k_UTF_8), 0, 0, 1, 0}, {&__pyx_n_s_UnicodeDecodeError, __pyx_k_UnicodeDecodeError, sizeof(__pyx_k_UnicodeDecodeError), 0, 0, 1, 1}, {&__pyx_n_s_ValueError, __pyx_k_ValueError, sizeof(__pyx_k_ValueError), 0, 0, 1, 1}, {&__pyx_n_b__22, __pyx_k__22, sizeof(__pyx_k__22), 0, 0, 0, 1}, {&__pyx_n_u__22, __pyx_k__22, sizeof(__pyx_k__22), 0, 1, 0, 1}, {&__pyx_n_s_acquire, __pyx_k_acquire, sizeof(__pyx_k_acquire), 0, 0, 1, 1}, {&__pyx_n_s_all, __pyx_k_all, sizeof(__pyx_k_all), 0, 0, 1, 1}, {&__pyx_n_s_append, __pyx_k_append, sizeof(__pyx_k_append), 0, 0, 1, 1}, {&__pyx_n_s_arg, __pyx_k_arg, sizeof(__pyx_k_arg), 0, 0, 1, 1}, {&__pyx_n_s_args, __pyx_k_args, sizeof(__pyx_k_args), 0, 0, 1, 1}, {&__pyx_n_s_as_attrgetter, __pyx_k_as_attrgetter, sizeof(__pyx_k_as_attrgetter), 0, 0, 1, 1}, {&__pyx_n_s_as_itemgetter, __pyx_k_as_itemgetter, sizeof(__pyx_k_as_itemgetter), 0, 0, 1, 1}, {&__pyx_n_s_attribute_filter, __pyx_k_attribute_filter, sizeof(__pyx_k_attribute_filter), 0, 0, 1, 1}, {&__pyx_kp_s_attribute_filter_and_attribute_h, __pyx_k_attribute_filter_and_attribute_h, sizeof(__pyx_k_attribute_filter_and_attribute_h), 0, 0, 1, 0}, {&__pyx_kp_s_attribute_filter_must_be_callabl, __pyx_k_attribute_filter_must_be_callabl, sizeof(__pyx_k_attribute_filter_must_be_callabl), 0, 0, 1, 0}, {&__pyx_n_s_attribute_handlers, __pyx_k_attribute_handlers, sizeof(__pyx_k_attribute_handlers), 0, 0, 1, 1}, {&__pyx_kp_s_attribute_handlers_must_be_a_seq, __pyx_k_attribute_handlers_must_be_a_seq, sizeof(__pyx_k_attribute_handlers_must_be_a_seq), 0, 0, 1, 0}, {&__pyx_n_s_blocking, __pyx_k_blocking, sizeof(__pyx_k_blocking), 0, 0, 1, 1}, {&__pyx_n_s_builtin, __pyx_k_builtin, sizeof(__pyx_k_builtin), 0, 0, 1, 1}, {&__pyx_n_b_builtins, __pyx_k_builtins, sizeof(__pyx_k_builtins), 0, 0, 0, 1}, {&__pyx_n_s_builtins, __pyx_k_builtins, sizeof(__pyx_k_builtins), 0, 0, 1, 1}, {&__pyx_kp_s_byte_string_input_has_unknown_en, __pyx_k_byte_string_input_has_unknown_en, sizeof(__pyx_k_byte_string_input_has_unknown_en), 0, 0, 1, 0}, {&__pyx_kp_s_can_t_send_non_None_value_to_a_j, __pyx_k_can_t_send_non_None_value_to_a_j, sizeof(__pyx_k_can_t_send_non_None_value_to_a_j), 0, 0, 1, 0}, {&__pyx_kp_s_cannot_iterate_over_non_table_fo, __pyx_k_cannot_iterate_over_non_table_fo, sizeof(__pyx_k_cannot_iterate_over_non_table_fo), 0, 0, 1, 0}, {&__pyx_kp_s_cannot_mix_objects_from_differen, __pyx_k_cannot_mix_objects_from_differen, sizeof(__pyx_k_cannot_mix_objects_from_differen), 0, 0, 1, 0}, {&__pyx_kp_s_cannot_release_un_acquired_lock, __pyx_k_cannot_release_un_acquired_lock, sizeof(__pyx_k_cannot_release_un_acquired_lock), 0, 0, 1, 0}, {&__pyx_n_s_cline_in_traceback, __pyx_k_cline_in_traceback, sizeof(__pyx_k_cline_in_traceback), 0, 0, 1, 1}, {&__pyx_n_s_co, __pyx_k_co, sizeof(__pyx_k_co), 0, 0, 1, 1}, {&__pyx_n_s_collections, __pyx_k_collections, sizeof(__pyx_k_collections), 0, 0, 1, 1}, {&__pyx_n_s_compile, __pyx_k_compile, sizeof(__pyx_k_compile), 0, 0, 1, 1}, {&__pyx_n_s_coroutine, __pyx_k_coroutine, sizeof(__pyx_k_coroutine), 0, 0, 1, 1}, {&__pyx_n_s_delattr, __pyx_k_delattr, sizeof(__pyx_k_delattr), 0, 0, 1, 1}, {&__pyx_n_s_doc, __pyx_k_doc, sizeof(__pyx_k_doc), 0, 0, 1, 1}, {&__pyx_n_s_encoding, __pyx_k_encoding, sizeof(__pyx_k_encoding), 0, 0, 1, 1}, {&__pyx_n_s_enter, __pyx_k_enter, sizeof(__pyx_k_enter), 0, 0, 1, 1}, {&__pyx_n_s_enumerate, __pyx_k_enumerate, sizeof(__pyx_k_enumerate), 0, 0, 1, 1}, {&__pyx_n_s_err, __pyx_k_err, sizeof(__pyx_k_err), 0, 0, 1, 1}, {&__pyx_n_s_error, __pyx_k_error, sizeof(__pyx_k_error), 0, 0, 1, 1}, {&__pyx_kp_b_error_creating_an_iterator, __pyx_k_error_creating_an_iterator, sizeof(__pyx_k_error_creating_an_iterator), 0, 0, 0, 0}, {&__pyx_kp_b_error_creating_an_iterator_with, __pyx_k_error_creating_an_iterator_with, sizeof(__pyx_k_error_creating_an_iterator_with), 0, 0, 0, 0}, {&__pyx_kp_b_error_during_Python_call, __pyx_k_error_during_Python_call, sizeof(__pyx_k_error_during_Python_call), 0, 0, 0, 0}, {&__pyx_kp_b_error_during_Python_str_call, __pyx_k_error_during_Python_str_call, sizeof(__pyx_k_error_during_Python_str_call), 0, 0, 0, 0}, {&__pyx_kp_u_error_loading_code_s, __pyx_k_error_loading_code_s, sizeof(__pyx_k_error_loading_code_s), 0, 1, 0, 0}, {&__pyx_kp_b_error_reading_Python_attribute_i, __pyx_k_error_reading_Python_attribute_i, sizeof(__pyx_k_error_reading_Python_attribute_i), 0, 0, 0, 0}, {&__pyx_kp_b_error_while_calling_next_iterato, __pyx_k_error_while_calling_next_iterato, sizeof(__pyx_k_error_while_calling_next_iterato), 0, 0, 0, 0}, {&__pyx_kp_b_error_while_cleaning_up_a_Python, __pyx_k_error_while_cleaning_up_a_Python, sizeof(__pyx_k_error_while_cleaning_up_a_Python), 0, 0, 0, 0}, {&__pyx_kp_b_error_writing_Python_attribute_i, __pyx_k_error_writing_Python_attribute_i, sizeof(__pyx_k_error_writing_Python_attribute_i), 0, 0, 0, 0}, {&__pyx_n_b_eval, __pyx_k_eval, sizeof(__pyx_k_eval), 0, 0, 0, 1}, {&__pyx_n_s_eval, __pyx_k_eval, sizeof(__pyx_k_eval), 0, 0, 1, 1}, {&__pyx_n_s_exc_info, __pyx_k_exc_info, sizeof(__pyx_k_exc_info), 0, 0, 1, 1}, {&__pyx_n_s_execute, __pyx_k_execute, sizeof(__pyx_k_execute), 0, 0, 1, 1}, {&__pyx_n_s_exit, __pyx_k_exit, sizeof(__pyx_k_exit), 0, 0, 1, 1}, {&__pyx_kp_s_expected_string_got_s, __pyx_k_expected_string_got_s, sizeof(__pyx_k_expected_string_got_s), 0, 0, 1, 0}, {&__pyx_kp_s_failed_to_convert_argument_at_in, __pyx_k_failed_to_convert_argument_at_in, sizeof(__pyx_k_failed_to_convert_argument_at_in), 0, 0, 1, 0}, {&__pyx_kp_s_failed_to_convert_s_object, __pyx_k_failed_to_convert_s_object, sizeof(__pyx_k_failed_to_convert_s_object), 0, 0, 1, 0}, {&__pyx_n_s_func, __pyx_k_func, sizeof(__pyx_k_func), 0, 0, 1, 1}, {&__pyx_n_s_function, __pyx_k_function, sizeof(__pyx_k_function), 0, 0, 1, 1}, {&__pyx_n_s_functools, __pyx_k_functools, sizeof(__pyx_k_functools), 0, 0, 1, 1}, {&__pyx_n_s_getattr, __pyx_k_getattr, sizeof(__pyx_k_getattr), 0, 0, 1, 1}, {&__pyx_n_s_getitem, __pyx_k_getitem, sizeof(__pyx_k_getitem), 0, 0, 1, 1}, {&__pyx_n_s_getstate, __pyx_k_getstate, sizeof(__pyx_k_getstate), 0, 0, 1, 1}, {&__pyx_n_s_globals, __pyx_k_globals, sizeof(__pyx_k_globals), 0, 0, 1, 1}, {&__pyx_kp_s_globals_not_defined, __pyx_k_globals_not_defined, sizeof(__pyx_k_globals_not_defined), 0, 0, 1, 0}, {&__pyx_n_s_i, __pyx_k_i, sizeof(__pyx_k_i), 0, 0, 1, 1}, {&__pyx_n_s_import, __pyx_k_import, sizeof(__pyx_k_import), 0, 0, 1, 1}, {&__pyx_n_s_is_owned, __pyx_k_is_owned, sizeof(__pyx_k_is_owned), 0, 0, 1, 1}, {&__pyx_kp_s_item_attribute_access_not_suppor, __pyx_k_item_attribute_access_not_suppor, sizeof(__pyx_k_item_attribute_access_not_suppor), 0, 0, 1, 0}, {&__pyx_n_s_items, __pyx_k_items, sizeof(__pyx_k_items), 0, 0, 1, 1}, {&__pyx_kp_s_iteration_is_only_supported_for, __pyx_k_iteration_is_only_supported_for, sizeof(__pyx_k_iteration_is_only_supported_for), 0, 0, 1, 0}, {&__pyx_n_s_iteritems, __pyx_k_iteritems, sizeof(__pyx_k_iteritems), 0, 0, 1, 1}, {&__pyx_n_s_key, __pyx_k_key, sizeof(__pyx_k_key), 0, 0, 1, 1}, {&__pyx_n_s_keys, __pyx_k_keys, sizeof(__pyx_k_keys), 0, 0, 1, 1}, {&__pyx_n_s_kwargs, __pyx_k_kwargs, sizeof(__pyx_k_kwargs), 0, 0, 1, 1}, {&__pyx_kp_s_lost_reference, __pyx_k_lost_reference, sizeof(__pyx_k_lost_reference), 0, 0, 1, 0}, {&__pyx_n_s_ltype, __pyx_k_ltype, sizeof(__pyx_k_ltype), 0, 0, 1, 1}, {&__pyx_n_s_lua_code, __pyx_k_lua_code, sizeof(__pyx_k_lua_code), 0, 0, 1, 1}, {&__pyx_n_s_lua_object, __pyx_k_lua_object, sizeof(__pyx_k_lua_object), 0, 0, 1, 1}, {&__pyx_n_s_lua_type, __pyx_k_lua_type, sizeof(__pyx_k_lua_type), 0, 0, 1, 1}, {&__pyx_n_s_lua_type_name, __pyx_k_lua_type_name, sizeof(__pyx_k_lua_type_name), 0, 0, 1, 1}, {&__pyx_n_s_lupa__lupa, __pyx_k_lupa__lupa, sizeof(__pyx_k_lupa__lupa), 0, 0, 1, 1}, {&__pyx_kp_s_lupa__lupa_pyx, __pyx_k_lupa__lupa_pyx, sizeof(__pyx_k_lupa__lupa_pyx), 0, 0, 1, 0}, {&__pyx_kp_s_lupa_lock_pxi, __pyx_k_lupa_lock_pxi, sizeof(__pyx_k_lupa_lock_pxi), 0, 0, 1, 0}, {&__pyx_n_s_main, __pyx_k_main, sizeof(__pyx_k_main), 0, 0, 1, 1}, {&__pyx_n_s_metaclass, __pyx_k_metaclass, sizeof(__pyx_k_metaclass), 0, 0, 1, 1}, {&__pyx_n_s_meth, __pyx_k_meth, sizeof(__pyx_k_meth), 0, 0, 1, 1}, {&__pyx_n_s_module, __pyx_k_module, sizeof(__pyx_k_module), 0, 0, 1, 1}, {&__pyx_n_s_modulename, __pyx_k_modulename, sizeof(__pyx_k_modulename), 0, 0, 1, 1}, {&__pyx_kp_s_modulename_must_be_a_string, __pyx_k_modulename_must_be_a_string, sizeof(__pyx_k_modulename_must_be_a_string), 0, 0, 1, 0}, {&__pyx_n_s_name, __pyx_k_name, sizeof(__pyx_k_name), 0, 0, 1, 1}, {&__pyx_n_s_name_2, __pyx_k_name_2, sizeof(__pyx_k_name_2), 0, 0, 1, 1}, {&__pyx_kp_s_no_default___reduce___due_to_non, __pyx_k_no_default___reduce___due_to_non, sizeof(__pyx_k_no_default___reduce___due_to_non), 0, 0, 1, 0}, {&__pyx_n_b_none, __pyx_k_none, sizeof(__pyx_k_none), 0, 0, 0, 1}, {&__pyx_kp_s_not_a_python_object, __pyx_k_not_a_python_object, sizeof(__pyx_k_not_a_python_object), 0, 0, 1, 0}, {&__pyx_n_s_obj, __pyx_k_obj, sizeof(__pyx_k_obj), 0, 0, 1, 1}, {&__pyx_n_s_object, __pyx_k_object, sizeof(__pyx_k_object), 0, 0, 1, 1}, {&__pyx_n_s_old_top, __pyx_k_old_top, sizeof(__pyx_k_old_top), 0, 0, 1, 1}, {&__pyx_n_s_oldtop, __pyx_k_oldtop, sizeof(__pyx_k_oldtop), 0, 0, 1, 1}, {&__pyx_n_s_pop, __pyx_k_pop, sizeof(__pyx_k_pop), 0, 0, 1, 1}, {&__pyx_n_s_prepare, __pyx_k_prepare, sizeof(__pyx_k_prepare), 0, 0, 1, 1}, {&__pyx_n_s_pyx_state, __pyx_k_pyx_state, sizeof(__pyx_k_pyx_state), 0, 0, 1, 1}, {&__pyx_n_s_pyx_vtable, __pyx_k_pyx_vtable, sizeof(__pyx_k_pyx_vtable), 0, 0, 1, 1}, {&__pyx_n_s_qualname, __pyx_k_qualname, sizeof(__pyx_k_qualname), 0, 0, 1, 1}, {&__pyx_n_s_range, __pyx_k_range, sizeof(__pyx_k_range), 0, 0, 1, 1}, {&__pyx_n_s_reduce, __pyx_k_reduce, sizeof(__pyx_k_reduce), 0, 0, 1, 1}, {&__pyx_n_s_reduce_cython, __pyx_k_reduce_cython, sizeof(__pyx_k_reduce_cython), 0, 0, 1, 1}, {&__pyx_n_s_reduce_ex, __pyx_k_reduce_ex, sizeof(__pyx_k_reduce_ex), 0, 0, 1, 1}, {&__pyx_n_s_register_builtins, __pyx_k_register_builtins, sizeof(__pyx_k_register_builtins), 0, 0, 1, 1}, {&__pyx_n_s_register_eval, __pyx_k_register_eval, sizeof(__pyx_k_register_eval), 0, 0, 1, 1}, {&__pyx_n_s_release, __pyx_k_release, sizeof(__pyx_k_release), 0, 0, 1, 1}, {&__pyx_n_s_require, __pyx_k_require, sizeof(__pyx_k_require), 0, 0, 1, 1}, {&__pyx_kp_s_require_is_not_defined, __pyx_k_require_is_not_defined, sizeof(__pyx_k_require_is_not_defined), 0, 0, 1, 0}, {&__pyx_kp_b_return, __pyx_k_return, sizeof(__pyx_k_return), 0, 0, 0, 0}, {&__pyx_n_s_self, __pyx_k_self, sizeof(__pyx_k_self), 0, 0, 1, 1}, {&__pyx_kp_s_self__co_state_self__state_canno, __pyx_k_self__co_state_self__state_canno, sizeof(__pyx_k_self__co_state_self__state_canno), 0, 0, 1, 0}, {&__pyx_kp_s_self__state_cannot_be_converted, __pyx_k_self__state_cannot_be_converted, sizeof(__pyx_k_self__state_cannot_be_converted), 0, 0, 1, 0}, {&__pyx_n_s_send, __pyx_k_send, sizeof(__pyx_k_send), 0, 0, 1, 1}, {&__pyx_n_s_setattr, __pyx_k_setattr, sizeof(__pyx_k_setattr), 0, 0, 1, 1}, {&__pyx_n_s_setstate, __pyx_k_setstate, sizeof(__pyx_k_setstate), 0, 0, 1, 1}, {&__pyx_n_s_setstate_cython, __pyx_k_setstate_cython, sizeof(__pyx_k_setstate_cython), 0, 0, 1, 1}, {&__pyx_n_s_size, __pyx_k_size, sizeof(__pyx_k_size), 0, 0, 1, 1}, {&__pyx_n_s_source_encoding, __pyx_k_source_encoding, sizeof(__pyx_k_source_encoding), 0, 0, 1, 1}, {&__pyx_n_s_status, __pyx_k_status, sizeof(__pyx_k_status), 0, 0, 1, 1}, {&__pyx_kp_s_stringsource, __pyx_k_stringsource, sizeof(__pyx_k_stringsource), 0, 0, 1, 0}, {&__pyx_n_s_sys, __pyx_k_sys, sizeof(__pyx_k_sys), 0, 0, 1, 1}, {&__pyx_n_s_t, __pyx_k_t, sizeof(__pyx_k_t), 0, 0, 1, 1}, {&__pyx_n_s_table, __pyx_k_table, sizeof(__pyx_k_table), 0, 0, 1, 1}, {&__pyx_n_s_table_from, __pyx_k_table_from, sizeof(__pyx_k_table_from), 0, 0, 1, 1}, {&__pyx_n_s_tb, __pyx_k_tb, sizeof(__pyx_k_tb), 0, 0, 1, 1}, {&__pyx_n_s_test, __pyx_k_test, sizeof(__pyx_k_test), 0, 0, 1, 1}, {&__pyx_n_s_thread, __pyx_k_thread, sizeof(__pyx_k_thread), 0, 0, 1, 1}, {&__pyx_n_s_unpack_returned_tuples, __pyx_k_unpack_returned_tuples, sizeof(__pyx_k_unpack_returned_tuples), 0, 0, 1, 1}, {&__pyx_n_s_unpacks_lua_table, __pyx_k_unpacks_lua_table, sizeof(__pyx_k_unpacks_lua_table), 0, 0, 1, 1}, {&__pyx_n_s_unpacks_lua_table_locals_wrapper, __pyx_k_unpacks_lua_table_locals_wrapper, sizeof(__pyx_k_unpacks_lua_table_locals_wrapper), 0, 0, 1, 1}, {&__pyx_n_s_unpacks_lua_table_method, __pyx_k_unpacks_lua_table_method, sizeof(__pyx_k_unpacks_lua_table_method), 0, 0, 1, 1}, {&__pyx_n_s_unpacks_lua_table_method_locals, __pyx_k_unpacks_lua_table_method_locals, sizeof(__pyx_k_unpacks_lua_table_method_locals), 0, 0, 1, 1}, {&__pyx_n_s_userdata, __pyx_k_userdata, sizeof(__pyx_k_userdata), 0, 0, 1, 1}, {&__pyx_n_s_v, __pyx_k_v, sizeof(__pyx_k_v), 0, 0, 1, 1}, {&__pyx_n_s_value, __pyx_k_value, sizeof(__pyx_k_value), 0, 0, 1, 1}, {&__pyx_n_s_values, __pyx_k_values, sizeof(__pyx_k_values), 0, 0, 1, 1}, {&__pyx_n_s_what, __pyx_k_what, sizeof(__pyx_k_what), 0, 0, 1, 1}, {&__pyx_n_s_wrap, __pyx_k_wrap, sizeof(__pyx_k_wrap), 0, 0, 1, 1}, {&__pyx_n_s_wrapper, __pyx_k_wrapper, sizeof(__pyx_k_wrapper), 0, 0, 1, 1}, {&__pyx_n_s_wraps, __pyx_k_wraps, sizeof(__pyx_k_wraps), 0, 0, 1, 1}, {0, 0, 0, 0, 0, 0, 0} }; static int __Pyx_InitCachedBuiltins(void) { __pyx_builtin_ImportError = __Pyx_GetBuiltinName(__pyx_n_s_ImportError); if (!__pyx_builtin_ImportError) __PYX_ERR(0, 44, __pyx_L1_error) __pyx_builtin_RuntimeError = __Pyx_GetBuiltinName(__pyx_n_s_RuntimeError); if (!__pyx_builtin_RuntimeError) __PYX_ERR(1, 39, __pyx_L1_error) __pyx_builtin_TypeError = __Pyx_GetBuiltinName(__pyx_n_s_TypeError); if (!__pyx_builtin_TypeError) __PYX_ERR(2, 2, __pyx_L1_error) __pyx_builtin_ValueError = __Pyx_GetBuiltinName(__pyx_n_s_ValueError); if (!__pyx_builtin_ValueError) __PYX_ERR(0, 200, __pyx_L1_error) __pyx_builtin_eval = __Pyx_GetBuiltinName(__pyx_n_s_eval); if (!__pyx_builtin_eval) __PYX_ERR(0, 405, __pyx_L1_error) __pyx_builtin_range = __Pyx_GetBuiltinName(__pyx_n_s_range); if (!__pyx_builtin_range) __PYX_ERR(0, 473, __pyx_L1_error) __pyx_builtin_UnicodeDecodeError = __Pyx_GetBuiltinName(__pyx_n_s_UnicodeDecodeError); if (!__pyx_builtin_UnicodeDecodeError) __PYX_ERR(0, 602, __pyx_L1_error) __pyx_builtin_object = __Pyx_GetBuiltinName(__pyx_n_s_object); if (!__pyx_builtin_object) __PYX_ERR(0, 617, __pyx_L1_error) __pyx_builtin_AttributeError = __Pyx_GetBuiltinName(__pyx_n_s_AttributeError); if (!__pyx_builtin_AttributeError) __PYX_ERR(0, 637, __pyx_L1_error) __pyx_builtin_StopIteration = __Pyx_GetBuiltinName(__pyx_n_s_StopIteration); if (!__pyx_builtin_StopIteration) __PYX_ERR(0, 909, __pyx_L1_error) __pyx_builtin_MemoryError = __Pyx_GetBuiltinName(__pyx_n_s_MemoryError); if (!__pyx_builtin_MemoryError) __PYX_ERR(0, 1248, __pyx_L1_error) __pyx_builtin_BaseException = __Pyx_GetBuiltinName(__pyx_n_s_BaseException); if (!__pyx_builtin_BaseException) __PYX_ERR(0, 1312, __pyx_L1_error) __pyx_builtin_enumerate = __Pyx_GetBuiltinName(__pyx_n_s_enumerate); if (!__pyx_builtin_enumerate) __PYX_ERR(0, 1322, __pyx_L1_error) __pyx_builtin_KeyError = __Pyx_GetBuiltinName(__pyx_n_s_KeyError); if (!__pyx_builtin_KeyError) __PYX_ERR(0, 1379, __pyx_L1_error) return 0; __pyx_L1_error:; return -1; } static int __Pyx_InitCachedConstants(void) { __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__Pyx_InitCachedConstants", 0); /* "lupa/lock.pxi":39 * def release(self): * if self._owner != pythread.PyThread_get_thread_ident(): * raise RuntimeError("cannot release un-acquired lock") # <<<<<<<<<<<<<< * unlock_lock(self) * */ __pyx_tuple_ = PyTuple_Pack(1, __pyx_kp_s_cannot_release_un_acquired_lock); if (unlikely(!__pyx_tuple_)) __PYX_ERR(1, 39, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple_); __Pyx_GIVEREF(__pyx_tuple_); /* "lupa/lock.pxi":51 * # self.release() * if self._owner != pythread.PyThread_get_thread_ident(): * raise RuntimeError("cannot release un-acquired lock") # <<<<<<<<<<<<<< * unlock_lock(self) * */ __pyx_tuple__2 = PyTuple_Pack(1, __pyx_kp_s_cannot_release_un_acquired_lock); if (unlikely(!__pyx_tuple__2)) __PYX_ERR(1, 51, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__2); __Pyx_GIVEREF(__pyx_tuple__2); /* "(tree fragment)":2 * def __reduce_cython__(self): * raise TypeError("no default __reduce__ due to non-trivial __cinit__") # <<<<<<<<<<<<<< * def __setstate_cython__(self, __pyx_state): * raise TypeError("no default __reduce__ due to non-trivial __cinit__") */ __pyx_tuple__3 = PyTuple_Pack(1, __pyx_kp_s_no_default___reduce___due_to_non); if (unlikely(!__pyx_tuple__3)) __PYX_ERR(2, 2, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__3); __Pyx_GIVEREF(__pyx_tuple__3); /* "(tree fragment)":4 * raise TypeError("no default __reduce__ due to non-trivial __cinit__") * def __setstate_cython__(self, __pyx_state): * raise TypeError("no default __reduce__ due to non-trivial __cinit__") # <<<<<<<<<<<<<< */ __pyx_tuple__4 = PyTuple_Pack(1, __pyx_kp_s_no_default___reduce___due_to_non); if (unlikely(!__pyx_tuple__4)) __PYX_ERR(2, 4, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__4); __Pyx_GIVEREF(__pyx_tuple__4); /* "lupa/_lupa.pyx":193 * cdef lua_State* L = lua.luaL_newstate() * if L is NULL: * raise LuaError("Failed to initialise Lua runtime") # <<<<<<<<<<<<<< * self._state = L * self._lock = FastRLock() */ __pyx_tuple__5 = PyTuple_Pack(1, __pyx_kp_s_Failed_to_initialise_Lua_runtime); if (unlikely(!__pyx_tuple__5)) __PYX_ERR(0, 193, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__5); __Pyx_GIVEREF(__pyx_tuple__5); /* "lupa/_lupa.pyx":200 * self._source_encoding = _asciiOrNone(source_encoding) or self._encoding or b'UTF-8' * if attribute_filter is not None and not callable(attribute_filter): * raise ValueError("attribute_filter must be callable") # <<<<<<<<<<<<<< * self._attribute_filter = attribute_filter * self._unpack_returned_tuples = unpack_returned_tuples */ __pyx_tuple__6 = PyTuple_Pack(1, __pyx_kp_s_attribute_filter_must_be_callabl); if (unlikely(!__pyx_tuple__6)) __PYX_ERR(0, 200, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__6); __Pyx_GIVEREF(__pyx_tuple__6); /* "lupa/_lupa.pyx":215 * raise_error = True * if raise_error: * raise ValueError("attribute_handlers must be a sequence of two callables") # <<<<<<<<<<<<<< * if attribute_filter and (getter is not None or setter is not None): * raise ValueError("attribute_filter and attribute_handlers are mutually exclusive") */ __pyx_tuple__7 = PyTuple_Pack(1, __pyx_kp_s_attribute_handlers_must_be_a_seq); if (unlikely(!__pyx_tuple__7)) __PYX_ERR(0, 215, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__7); __Pyx_GIVEREF(__pyx_tuple__7); /* "lupa/_lupa.pyx":217 * raise ValueError("attribute_handlers must be a sequence of two callables") * if attribute_filter and (getter is not None or setter is not None): * raise ValueError("attribute_filter and attribute_handlers are mutually exclusive") # <<<<<<<<<<<<<< * self._attribute_getter, self._attribute_setter = getter, setter * */ __pyx_tuple__8 = PyTuple_Pack(1, __pyx_kp_s_attribute_filter_and_attribute_h); if (unlikely(!__pyx_tuple__8)) __PYX_ERR(0, 217, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__8); __Pyx_GIVEREF(__pyx_tuple__8); /* "lupa/_lupa.pyx":292 * cdef lua_State *L = self._state * if not isinstance(modulename, (bytes, unicode)): * raise TypeError("modulename must be a string") # <<<<<<<<<<<<<< * lock_runtime(self) * old_top = lua.lua_gettop(L) */ __pyx_tuple__9 = PyTuple_Pack(1, __pyx_kp_s_modulename_must_be_a_string); if (unlikely(!__pyx_tuple__9)) __PYX_ERR(0, 292, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__9); __Pyx_GIVEREF(__pyx_tuple__9); /* "lupa/_lupa.pyx":298 * lua.lua_getglobal(L, 'require') * if lua.lua_isnil(L, -1): * raise LuaError("require is not defined") # <<<<<<<<<<<<<< * return call_lua(self, L, (modulename,)) * finally: */ __pyx_tuple__10 = PyTuple_Pack(1, __pyx_kp_s_require_is_not_defined); if (unlikely(!__pyx_tuple__10)) __PYX_ERR(0, 298, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__10); __Pyx_GIVEREF(__pyx_tuple__10); /* "lupa/_lupa.pyx":315 * lua.lua_getglobal(L, '_G') * if lua.lua_isnil(L, -1): * raise LuaError("globals not defined") # <<<<<<<<<<<<<< * return py_from_lua(self, L, -1) * finally: */ __pyx_tuple__11 = PyTuple_Pack(1, __pyx_kp_s_globals_not_defined); if (unlikely(!__pyx_tuple__11)) __PYX_ERR(0, 315, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__11); __Pyx_GIVEREF(__pyx_tuple__11); /* "(tree fragment)":2 * def __reduce_cython__(self): * raise TypeError("no default __reduce__ due to non-trivial __cinit__") # <<<<<<<<<<<<<< * def __setstate_cython__(self, __pyx_state): * raise TypeError("no default __reduce__ due to non-trivial __cinit__") */ __pyx_tuple__12 = PyTuple_Pack(1, __pyx_kp_s_no_default___reduce___due_to_non); if (unlikely(!__pyx_tuple__12)) __PYX_ERR(2, 2, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__12); __Pyx_GIVEREF(__pyx_tuple__12); /* "(tree fragment)":4 * raise TypeError("no default __reduce__ due to non-trivial __cinit__") * def __setstate_cython__(self, __pyx_state): * raise TypeError("no default __reduce__ due to non-trivial __cinit__") # <<<<<<<<<<<<<< */ __pyx_tuple__13 = PyTuple_Pack(1, __pyx_kp_s_no_default___reduce___due_to_non); if (unlikely(!__pyx_tuple__13)) __PYX_ERR(2, 4, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__13); __Pyx_GIVEREF(__pyx_tuple__13); /* "lupa/_lupa.pyx":436 * """ * @wraps(func) * def wrapper(*args): # <<<<<<<<<<<<<< * args, kwargs = _fix_args_kwargs(args) * return func(*args, **kwargs) */ __pyx_tuple__14 = PyTuple_Pack(2, __pyx_n_s_args, __pyx_n_s_kwargs); if (unlikely(!__pyx_tuple__14)) __PYX_ERR(0, 436, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__14); __Pyx_GIVEREF(__pyx_tuple__14); __pyx_codeobj__15 = (PyObject*)__Pyx_PyCode_New(0, 0, 2, 0, CO_OPTIMIZED|CO_NEWLOCALS|CO_VARARGS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__14, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_lupa__lupa_pyx, __pyx_n_s_wrapper, 436, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__15)) __PYX_ERR(0, 436, __pyx_L1_error) /* "lupa/_lupa.pyx":448 * """ * @wraps(meth) * def wrapper(self, *args): # <<<<<<<<<<<<<< * args, kwargs = _fix_args_kwargs(args) * return meth(self, *args, **kwargs) */ __pyx_tuple__16 = PyTuple_Pack(3, __pyx_n_s_self, __pyx_n_s_args, __pyx_n_s_kwargs); if (unlikely(!__pyx_tuple__16)) __PYX_ERR(0, 448, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__16); __Pyx_GIVEREF(__pyx_tuple__16); __pyx_codeobj__17 = (PyObject*)__Pyx_PyCode_New(1, 0, 3, 0, CO_OPTIMIZED|CO_NEWLOCALS|CO_VARARGS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__16, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_lupa__lupa_pyx, __pyx_n_s_wrapper, 448, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__17)) __PYX_ERR(0, 448, __pyx_L1_error) /* "lupa/_lupa.pyx":490 * cdef inline int lock_runtime(LuaRuntime runtime) except -1: * if not lock_lock(runtime._lock, pythread.PyThread_get_thread_ident(), True): * raise LuaError("Failed to acquire thread lock") # <<<<<<<<<<<<<< * return 0 * */ __pyx_tuple__18 = PyTuple_Pack(1, __pyx_kp_s_Failed_to_acquire_thread_lock); if (unlikely(!__pyx_tuple__18)) __PYX_ERR(0, 490, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__18); __Pyx_GIVEREF(__pyx_tuple__18); /* "lupa/_lupa.pyx":511 * * def __init__(self): * raise TypeError("Type cannot be instantiated manually") # <<<<<<<<<<<<<< * * def __dealloc__(self): */ __pyx_tuple__19 = PyTuple_Pack(1, __pyx_kp_s_Type_cannot_be_instantiated_manu); if (unlikely(!__pyx_tuple__19)) __PYX_ERR(0, 511, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__19); __Pyx_GIVEREF(__pyx_tuple__19); /* "lupa/_lupa.pyx":532 * if lua.lua_isnil(L, -1): * lua.lua_pop(L, 1) * raise LuaError("lost reference") # <<<<<<<<<<<<<< * * def __call__(self, *args): */ __pyx_tuple__20 = PyTuple_Pack(1, __pyx_kp_s_lost_reference); if (unlikely(!__pyx_tuple__20)) __PYX_ERR(0, 532, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__20); __Pyx_GIVEREF(__pyx_tuple__20); /* "lupa/_lupa.pyx":568 * def __iter__(self): * # if not provided, iteration will try item access and call into Lua * raise TypeError("iteration is only supported for tables") # <<<<<<<<<<<<<< * * def __repr__(self): */ __pyx_tuple__21 = PyTuple_Pack(1, __pyx_kp_s_iteration_is_only_supported_for); if (unlikely(!__pyx_tuple__21)) __PYX_ERR(0, 568, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__21); __Pyx_GIVEREF(__pyx_tuple__21); /* "lupa/_lupa.pyx":637 * if lua_type == lua.LUA_TFUNCTION or lua_type == lua.LUA_TTHREAD: * lua.lua_pop(L, 1) * raise (AttributeError if is_attr_access else TypeError)( # <<<<<<<<<<<<<< * "item/attribute access not supported on functions") * # table[nil] fails, so map None -> python.none for Lua tables */ __pyx_tuple__23 = PyTuple_Pack(1, __pyx_kp_s_item_attribute_access_not_suppor); if (unlikely(!__pyx_tuple__23)) __PYX_ERR(0, 637, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__23); __Pyx_GIVEREF(__pyx_tuple__23); /* "(tree fragment)":2 * def __reduce_cython__(self): * raise TypeError("self._state cannot be converted to a Python object for pickling") # <<<<<<<<<<<<<< * def __setstate_cython__(self, __pyx_state): * raise TypeError("self._state cannot be converted to a Python object for pickling") */ __pyx_tuple__24 = PyTuple_Pack(1, __pyx_kp_s_self__state_cannot_be_converted); if (unlikely(!__pyx_tuple__24)) __PYX_ERR(2, 2, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__24); __Pyx_GIVEREF(__pyx_tuple__24); /* "(tree fragment)":4 * raise TypeError("self._state cannot be converted to a Python object for pickling") * def __setstate_cython__(self, __pyx_state): * raise TypeError("self._state cannot be converted to a Python object for pickling") # <<<<<<<<<<<<<< */ __pyx_tuple__25 = PyTuple_Pack(1, __pyx_kp_s_self__state_cannot_be_converted); if (unlikely(!__pyx_tuple__25)) __PYX_ERR(2, 4, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__25); __Pyx_GIVEREF(__pyx_tuple__25); /* "(tree fragment)":2 * def __reduce_cython__(self): * raise TypeError("self._state cannot be converted to a Python object for pickling") # <<<<<<<<<<<<<< * def __setstate_cython__(self, __pyx_state): * raise TypeError("self._state cannot be converted to a Python object for pickling") */ __pyx_tuple__26 = PyTuple_Pack(1, __pyx_kp_s_self__state_cannot_be_converted); if (unlikely(!__pyx_tuple__26)) __PYX_ERR(2, 2, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__26); __Pyx_GIVEREF(__pyx_tuple__26); /* "(tree fragment)":4 * raise TypeError("self._state cannot be converted to a Python object for pickling") * def __setstate_cython__(self, __pyx_state): * raise TypeError("self._state cannot be converted to a Python object for pickling") # <<<<<<<<<<<<<< */ __pyx_tuple__27 = PyTuple_Pack(1, __pyx_kp_s_self__state_cannot_be_converted); if (unlikely(!__pyx_tuple__27)) __PYX_ERR(2, 4, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__27); __Pyx_GIVEREF(__pyx_tuple__27); /* "lupa/_lupa.pyx":793 * self.push_lua_object() * if not lua.lua_isfunction(L, -1) or lua.lua_iscfunction(L, -1): * raise TypeError("Lua object is not a function") # <<<<<<<<<<<<<< * # create thread stack and push the function on it * co = lua.lua_newthread(L) */ __pyx_tuple__28 = PyTuple_Pack(1, __pyx_kp_s_Lua_object_is_not_a_function); if (unlikely(!__pyx_tuple__28)) __PYX_ERR(0, 793, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__28); __Pyx_GIVEREF(__pyx_tuple__28); /* "(tree fragment)":2 * def __reduce_cython__(self): * raise TypeError("self._state cannot be converted to a Python object for pickling") # <<<<<<<<<<<<<< * def __setstate_cython__(self, __pyx_state): * raise TypeError("self._state cannot be converted to a Python object for pickling") */ __pyx_tuple__29 = PyTuple_Pack(1, __pyx_kp_s_self__state_cannot_be_converted); if (unlikely(!__pyx_tuple__29)) __PYX_ERR(2, 2, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__29); __Pyx_GIVEREF(__pyx_tuple__29); /* "(tree fragment)":4 * raise TypeError("self._state cannot be converted to a Python object for pickling") * def __setstate_cython__(self, __pyx_state): * raise TypeError("self._state cannot be converted to a Python object for pickling") # <<<<<<<<<<<<<< */ __pyx_tuple__30 = PyTuple_Pack(1, __pyx_kp_s_self__state_cannot_be_converted); if (unlikely(!__pyx_tuple__30)) __PYX_ERR(2, 4, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__30); __Pyx_GIVEREF(__pyx_tuple__30); /* "(tree fragment)":2 * def __reduce_cython__(self): * raise TypeError("self._state cannot be converted to a Python object for pickling") # <<<<<<<<<<<<<< * def __setstate_cython__(self, __pyx_state): * raise TypeError("self._state cannot be converted to a Python object for pickling") */ __pyx_tuple__31 = PyTuple_Pack(1, __pyx_kp_s_self__state_cannot_be_converted); if (unlikely(!__pyx_tuple__31)) __PYX_ERR(2, 2, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__31); __Pyx_GIVEREF(__pyx_tuple__31); /* "(tree fragment)":4 * raise TypeError("self._state cannot be converted to a Python object for pickling") * def __setstate_cython__(self, __pyx_state): * raise TypeError("self._state cannot be converted to a Python object for pickling") # <<<<<<<<<<<<<< */ __pyx_tuple__32 = PyTuple_Pack(1, __pyx_kp_s_self__state_cannot_be_converted); if (unlikely(!__pyx_tuple__32)) __PYX_ERR(2, 4, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__32); __Pyx_GIVEREF(__pyx_tuple__32); /* "lupa/_lupa.pyx":852 * if value is not None: * if self._arguments is not None: * raise TypeError("can't send non-None value to a just-started generator") # <<<<<<<<<<<<<< * if not isinstance(value, tuple): * value = (value,) */ __pyx_tuple__33 = PyTuple_Pack(1, __pyx_kp_s_can_t_send_non_None_value_to_a_j); if (unlikely(!__pyx_tuple__33)) __PYX_ERR(0, 852, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__33); __Pyx_GIVEREF(__pyx_tuple__33); /* "(tree fragment)":2 * def __reduce_cython__(self): * raise TypeError("self._co_state,self._state cannot be converted to a Python object for pickling") # <<<<<<<<<<<<<< * def __setstate_cython__(self, __pyx_state): * raise TypeError("self._co_state,self._state cannot be converted to a Python object for pickling") */ __pyx_tuple__34 = PyTuple_Pack(1, __pyx_kp_s_self__co_state_self__state_canno); if (unlikely(!__pyx_tuple__34)) __PYX_ERR(2, 2, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__34); __Pyx_GIVEREF(__pyx_tuple__34); /* "(tree fragment)":4 * raise TypeError("self._co_state,self._state cannot be converted to a Python object for pickling") * def __setstate_cython__(self, __pyx_state): * raise TypeError("self._co_state,self._state cannot be converted to a Python object for pickling") # <<<<<<<<<<<<<< */ __pyx_tuple__35 = PyTuple_Pack(1, __pyx_kp_s_self__co_state_self__state_canno); if (unlikely(!__pyx_tuple__35)) __PYX_ERR(2, 4, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__35); __Pyx_GIVEREF(__pyx_tuple__35); /* "lupa/_lupa.pyx":996 * if lua.lua_isnil(L, -1): * lua.lua_pop(L, 1) * raise LuaError("lost reference") # <<<<<<<<<<<<<< * raise TypeError("cannot iterate over non-table (found %r)" % self._obj) * if not self._refiter: */ __pyx_tuple__36 = PyTuple_Pack(1, __pyx_kp_s_lost_reference); if (unlikely(!__pyx_tuple__36)) __PYX_ERR(0, 996, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__36); __Pyx_GIVEREF(__pyx_tuple__36); /* "(tree fragment)":2 * def __reduce_cython__(self): * raise TypeError("no default __reduce__ due to non-trivial __cinit__") # <<<<<<<<<<<<<< * def __setstate_cython__(self, __pyx_state): * raise TypeError("no default __reduce__ due to non-trivial __cinit__") */ __pyx_tuple__37 = PyTuple_Pack(1, __pyx_kp_s_no_default___reduce___due_to_non); if (unlikely(!__pyx_tuple__37)) __PYX_ERR(2, 2, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__37); __Pyx_GIVEREF(__pyx_tuple__37); /* "(tree fragment)":4 * raise TypeError("no default __reduce__ due to non-trivial __cinit__") * def __setstate_cython__(self, __pyx_state): * raise TypeError("no default __reduce__ due to non-trivial __cinit__") # <<<<<<<<<<<<<< */ __pyx_tuple__38 = PyTuple_Pack(1, __pyx_kp_s_no_default___reduce___due_to_non); if (unlikely(!__pyx_tuple__38)) __PYX_ERR(2, 4, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__38); __Pyx_GIVEREF(__pyx_tuple__38); /* "lupa/_lupa.pyx":1062 * self._type_flags = 0 * def __init__(self): * raise TypeError("Type cannot be instantiated from Python") # <<<<<<<<<<<<<< * * */ __pyx_tuple__39 = PyTuple_Pack(1, __pyx_kp_s_Type_cannot_be_instantiated_from); if (unlikely(!__pyx_tuple__39)) __PYX_ERR(0, 1062, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__39); __Pyx_GIVEREF(__pyx_tuple__39); /* "(tree fragment)":2 * def __reduce_cython__(self): * raise TypeError("no default __reduce__ due to non-trivial __cinit__") # <<<<<<<<<<<<<< * def __setstate_cython__(self, __pyx_state): * raise TypeError("no default __reduce__ due to non-trivial __cinit__") */ __pyx_tuple__40 = PyTuple_Pack(1, __pyx_kp_s_no_default___reduce___due_to_non); if (unlikely(!__pyx_tuple__40)) __PYX_ERR(2, 2, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__40); __Pyx_GIVEREF(__pyx_tuple__40); /* "(tree fragment)":4 * raise TypeError("no default __reduce__ due to non-trivial __cinit__") * def __setstate_cython__(self, __pyx_state): * raise TypeError("no default __reduce__ due to non-trivial __cinit__") # <<<<<<<<<<<<<< */ __pyx_tuple__41 = PyTuple_Pack(1, __pyx_kp_s_no_default___reduce___due_to_non); if (unlikely(!__pyx_tuple__41)) __PYX_ERR(2, 4, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__41); __Pyx_GIVEREF(__pyx_tuple__41); /* "lupa/_lupa.pyx":1176 * elif isinstance(o, _LuaObject): * if (<_LuaObject>o)._runtime is not runtime: * raise LuaError("cannot mix objects from different Lua runtimes") # <<<<<<<<<<<<<< * lua.lua_rawgeti(L, lua.LUA_REGISTRYINDEX, (<_LuaObject>o)._ref) * pushed_values_count = 1 */ __pyx_tuple__42 = PyTuple_Pack(1, __pyx_kp_s_cannot_mix_objects_from_differen); if (unlikely(!__pyx_tuple__42)) __PYX_ERR(0, 1176, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__42); __Pyx_GIVEREF(__pyx_tuple__42); /* "lupa/_lupa.pyx":1238 * raise ValueError("expected string, got %s" % type(s)) * if not _isascii(s): * raise ValueError("byte string input has unknown encoding, only ASCII is allowed") # <<<<<<<<<<<<<< * return s * */ __pyx_tuple__43 = PyTuple_Pack(1, __pyx_kp_s_byte_string_input_has_unknown_en); if (unlikely(!__pyx_tuple__43)) __PYX_ERR(0, 1238, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__43); __Pyx_GIVEREF(__pyx_tuple__43); /* "lupa/_lupa.pyx":1406 * * if not py_obj: * raise TypeError("not a python object") # <<<<<<<<<<<<<< * * f = py_obj.obj */ __pyx_tuple__44 = PyTuple_Pack(1, __pyx_kp_s_not_a_python_object); if (unlikely(!__pyx_tuple__44)) __PYX_ERR(0, 1406, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__44); __Pyx_GIVEREF(__pyx_tuple__44); /* "lupa/lock.pxi":34 * self._real_lock = NULL * * def acquire(self, bint blocking=True): # <<<<<<<<<<<<<< * return lock_lock(self, pythread.PyThread_get_thread_ident(), blocking) * */ __pyx_tuple__45 = PyTuple_Pack(2, __pyx_n_s_self, __pyx_n_s_blocking); if (unlikely(!__pyx_tuple__45)) __PYX_ERR(1, 34, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__45); __Pyx_GIVEREF(__pyx_tuple__45); __pyx_codeobj__46 = (PyObject*)__Pyx_PyCode_New(2, 0, 2, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__45, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_lupa_lock_pxi, __pyx_n_s_acquire, 34, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__46)) __PYX_ERR(1, 34, __pyx_L1_error) /* "lupa/lock.pxi":37 * return lock_lock(self, pythread.PyThread_get_thread_ident(), blocking) * * def release(self): # <<<<<<<<<<<<<< * if self._owner != pythread.PyThread_get_thread_ident(): * raise RuntimeError("cannot release un-acquired lock") */ __pyx_tuple__47 = PyTuple_Pack(1, __pyx_n_s_self); if (unlikely(!__pyx_tuple__47)) __PYX_ERR(1, 37, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__47); __Pyx_GIVEREF(__pyx_tuple__47); __pyx_codeobj__48 = (PyObject*)__Pyx_PyCode_New(1, 0, 1, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__47, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_lupa_lock_pxi, __pyx_n_s_release, 37, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__48)) __PYX_ERR(1, 37, __pyx_L1_error) /* "lupa/lock.pxi":44 * # compatibility with RLock * * def __enter__(self): # <<<<<<<<<<<<<< * # self.acquire() * return lock_lock(self, pythread.PyThread_get_thread_ident(), True) */ __pyx_tuple__49 = PyTuple_Pack(1, __pyx_n_s_self); if (unlikely(!__pyx_tuple__49)) __PYX_ERR(1, 44, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__49); __Pyx_GIVEREF(__pyx_tuple__49); __pyx_codeobj__50 = (PyObject*)__Pyx_PyCode_New(1, 0, 1, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__49, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_lupa_lock_pxi, __pyx_n_s_enter, 44, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__50)) __PYX_ERR(1, 44, __pyx_L1_error) /* "lupa/lock.pxi":48 * return lock_lock(self, pythread.PyThread_get_thread_ident(), True) * * def __exit__(self, t, v, tb): # <<<<<<<<<<<<<< * # self.release() * if self._owner != pythread.PyThread_get_thread_ident(): */ __pyx_tuple__51 = PyTuple_Pack(4, __pyx_n_s_self, __pyx_n_s_t, __pyx_n_s_v, __pyx_n_s_tb); if (unlikely(!__pyx_tuple__51)) __PYX_ERR(1, 48, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__51); __Pyx_GIVEREF(__pyx_tuple__51); __pyx_codeobj__52 = (PyObject*)__Pyx_PyCode_New(4, 0, 4, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__51, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_lupa_lock_pxi, __pyx_n_s_exit, 48, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__52)) __PYX_ERR(1, 48, __pyx_L1_error) /* "lupa/lock.pxi":54 * unlock_lock(self) * * def _is_owned(self): # <<<<<<<<<<<<<< * return self._owner == pythread.PyThread_get_thread_ident() * */ __pyx_tuple__53 = PyTuple_Pack(1, __pyx_n_s_self); if (unlikely(!__pyx_tuple__53)) __PYX_ERR(1, 54, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__53); __Pyx_GIVEREF(__pyx_tuple__53); __pyx_codeobj__54 = (PyObject*)__Pyx_PyCode_New(1, 0, 1, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__53, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_lupa_lock_pxi, __pyx_n_s_is_owned, 54, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__54)) __PYX_ERR(1, 54, __pyx_L1_error) /* "(tree fragment)":1 * def __reduce_cython__(self): # <<<<<<<<<<<<<< * raise TypeError("no default __reduce__ due to non-trivial __cinit__") * def __setstate_cython__(self, __pyx_state): */ __pyx_tuple__55 = PyTuple_Pack(1, __pyx_n_s_self); if (unlikely(!__pyx_tuple__55)) __PYX_ERR(2, 1, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__55); __Pyx_GIVEREF(__pyx_tuple__55); __pyx_codeobj__56 = (PyObject*)__Pyx_PyCode_New(1, 0, 1, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__55, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_stringsource, __pyx_n_s_reduce_cython, 1, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__56)) __PYX_ERR(2, 1, __pyx_L1_error) /* "(tree fragment)":3 * def __reduce_cython__(self): * raise TypeError("no default __reduce__ due to non-trivial __cinit__") * def __setstate_cython__(self, __pyx_state): # <<<<<<<<<<<<<< * raise TypeError("no default __reduce__ due to non-trivial __cinit__") */ __pyx_tuple__57 = PyTuple_Pack(2, __pyx_n_s_self, __pyx_n_s_pyx_state); if (unlikely(!__pyx_tuple__57)) __PYX_ERR(2, 3, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__57); __Pyx_GIVEREF(__pyx_tuple__57); __pyx_codeobj__58 = (PyObject*)__Pyx_PyCode_New(2, 0, 2, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__57, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_stringsource, __pyx_n_s_setstate_cython, 3, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__58)) __PYX_ERR(2, 3, __pyx_L1_error) /* "lupa/_lupa.pyx":75 * * * def lua_type(obj): # <<<<<<<<<<<<<< * """ * Return the Lua type name of a wrapped object as string, as provided */ __pyx_tuple__59 = PyTuple_Pack(6, __pyx_n_s_obj, __pyx_n_s_lua_object, __pyx_n_s_L, __pyx_n_s_old_top, __pyx_n_s_lua_type_name, __pyx_n_s_ltype); if (unlikely(!__pyx_tuple__59)) __PYX_ERR(0, 75, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__59); __Pyx_GIVEREF(__pyx_tuple__59); __pyx_codeobj__60 = (PyObject*)__Pyx_PyCode_New(1, 0, 6, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__59, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_lupa__lupa_pyx, __pyx_n_s_lua_type, 75, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__60)) __PYX_ERR(0, 75, __pyx_L1_error) /* "lupa/_lupa.pyx":248 * return 0 * * def eval(self, lua_code, *args): # <<<<<<<<<<<<<< * """Evaluate a Lua expression passed in a string. * """ */ __pyx_tuple__61 = PyTuple_Pack(3, __pyx_n_s_self, __pyx_n_s_lua_code, __pyx_n_s_args); if (unlikely(!__pyx_tuple__61)) __PYX_ERR(0, 248, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__61); __Pyx_GIVEREF(__pyx_tuple__61); __pyx_codeobj__62 = (PyObject*)__Pyx_PyCode_New(2, 0, 3, 0, CO_OPTIMIZED|CO_NEWLOCALS|CO_VARARGS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__61, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_lupa__lupa_pyx, __pyx_n_s_eval, 248, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__62)) __PYX_ERR(0, 248, __pyx_L1_error) /* "lupa/_lupa.pyx":256 * return run_lua(self, b'return ' + lua_code, args) * * def execute(self, lua_code, *args): # <<<<<<<<<<<<<< * """Execute a Lua program passed in a string. * """ */ __pyx_tuple__63 = PyTuple_Pack(3, __pyx_n_s_self, __pyx_n_s_lua_code, __pyx_n_s_args); if (unlikely(!__pyx_tuple__63)) __PYX_ERR(0, 256, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__63); __Pyx_GIVEREF(__pyx_tuple__63); __pyx_codeobj__64 = (PyObject*)__Pyx_PyCode_New(2, 0, 3, 0, CO_OPTIMIZED|CO_NEWLOCALS|CO_VARARGS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__63, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_lupa__lupa_pyx, __pyx_n_s_execute, 256, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__64)) __PYX_ERR(0, 256, __pyx_L1_error) /* "lupa/_lupa.pyx":264 * return run_lua(self, lua_code, args) * * def compile(self, lua_code): # <<<<<<<<<<<<<< * """Compile a Lua program into a callable Lua function. * """ */ __pyx_tuple__65 = PyTuple_Pack(8, __pyx_n_s_self, __pyx_n_s_lua_code, __pyx_n_s_err, __pyx_n_s_L, __pyx_n_s_oldtop, __pyx_n_s_size, __pyx_n_s_status, __pyx_n_s_error); if (unlikely(!__pyx_tuple__65)) __PYX_ERR(0, 264, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__65); __Pyx_GIVEREF(__pyx_tuple__65); __pyx_codeobj__66 = (PyObject*)__Pyx_PyCode_New(2, 0, 8, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__65, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_lupa__lupa_pyx, __pyx_n_s_compile, 264, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__66)) __PYX_ERR(0, 264, __pyx_L1_error) /* "lupa/_lupa.pyx":286 * unlock_runtime(self) * * def require(self, modulename): # <<<<<<<<<<<<<< * """Load a Lua library into the runtime. * """ */ __pyx_tuple__67 = PyTuple_Pack(4, __pyx_n_s_self, __pyx_n_s_modulename, __pyx_n_s_L, __pyx_n_s_old_top); if (unlikely(!__pyx_tuple__67)) __PYX_ERR(0, 286, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__67); __Pyx_GIVEREF(__pyx_tuple__67); __pyx_codeobj__68 = (PyObject*)__Pyx_PyCode_New(2, 0, 4, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__67, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_lupa__lupa_pyx, __pyx_n_s_require, 286, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__68)) __PYX_ERR(0, 286, __pyx_L1_error) /* "lupa/_lupa.pyx":304 * unlock_runtime(self) * * def globals(self): # <<<<<<<<<<<<<< * """Return the globals defined in this Lua runtime as a Lua * table. */ __pyx_tuple__69 = PyTuple_Pack(3, __pyx_n_s_self, __pyx_n_s_L, __pyx_n_s_old_top); if (unlikely(!__pyx_tuple__69)) __PYX_ERR(0, 304, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__69); __Pyx_GIVEREF(__pyx_tuple__69); __pyx_codeobj__70 = (PyObject*)__Pyx_PyCode_New(1, 0, 3, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__69, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_lupa__lupa_pyx, __pyx_n_s_globals, 304, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__70)) __PYX_ERR(0, 304, __pyx_L1_error) /* "lupa/_lupa.pyx":321 * unlock_runtime(self) * * def table(self, *items, **kwargs): # <<<<<<<<<<<<<< * """Create a new table with the provided items. Positional * arguments are placed in the table in order, keyword arguments */ __pyx_tuple__71 = PyTuple_Pack(3, __pyx_n_s_self, __pyx_n_s_items, __pyx_n_s_kwargs); if (unlikely(!__pyx_tuple__71)) __PYX_ERR(0, 321, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__71); __Pyx_GIVEREF(__pyx_tuple__71); __pyx_codeobj__72 = (PyObject*)__Pyx_PyCode_New(1, 0, 3, 0, CO_OPTIMIZED|CO_NEWLOCALS|CO_VARARGS|CO_VARKEYWORDS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__71, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_lupa__lupa_pyx, __pyx_n_s_table, 321, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__72)) __PYX_ERR(0, 321, __pyx_L1_error) /* "lupa/_lupa.pyx":328 * return self.table_from(items, kwargs) * * def table_from(self, *args): # <<<<<<<<<<<<<< * """Create a new table from Python mapping or iterable. * */ __pyx_tuple__73 = PyTuple_Pack(9, __pyx_n_s_self, __pyx_n_s_args, __pyx_n_s_L, __pyx_n_s_i, __pyx_n_s_old_top, __pyx_n_s_obj, __pyx_n_s_key, __pyx_n_s_value, __pyx_n_s_arg); if (unlikely(!__pyx_tuple__73)) __PYX_ERR(0, 328, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__73); __Pyx_GIVEREF(__pyx_tuple__73); __pyx_codeobj__74 = (PyObject*)__Pyx_PyCode_New(1, 0, 9, 0, CO_OPTIMIZED|CO_NEWLOCALS|CO_VARARGS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__73, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_lupa__lupa_pyx, __pyx_n_s_table_from, 328, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__74)) __PYX_ERR(0, 328, __pyx_L1_error) /* "(tree fragment)":1 * def __reduce_cython__(self): # <<<<<<<<<<<<<< * raise TypeError("no default __reduce__ due to non-trivial __cinit__") * def __setstate_cython__(self, __pyx_state): */ __pyx_tuple__75 = PyTuple_Pack(1, __pyx_n_s_self); if (unlikely(!__pyx_tuple__75)) __PYX_ERR(2, 1, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__75); __Pyx_GIVEREF(__pyx_tuple__75); __pyx_codeobj__76 = (PyObject*)__Pyx_PyCode_New(1, 0, 1, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__75, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_stringsource, __pyx_n_s_reduce_cython, 1, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__76)) __PYX_ERR(2, 1, __pyx_L1_error) /* "(tree fragment)":3 * def __reduce_cython__(self): * raise TypeError("no default __reduce__ due to non-trivial __cinit__") * def __setstate_cython__(self, __pyx_state): # <<<<<<<<<<<<<< * raise TypeError("no default __reduce__ due to non-trivial __cinit__") */ __pyx_tuple__77 = PyTuple_Pack(2, __pyx_n_s_self, __pyx_n_s_pyx_state); if (unlikely(!__pyx_tuple__77)) __PYX_ERR(2, 3, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__77); __Pyx_GIVEREF(__pyx_tuple__77); __pyx_codeobj__78 = (PyObject*)__Pyx_PyCode_New(2, 0, 2, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__77, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_stringsource, __pyx_n_s_setstate_cython, 3, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__78)) __PYX_ERR(2, 3, __pyx_L1_error) /* "lupa/_lupa.pyx":416 * # from Lua scripts * * def unpacks_lua_table(func): # <<<<<<<<<<<<<< * """ * A decorator to make the decorated function receive kwargs */ __pyx_tuple__79 = PyTuple_Pack(3, __pyx_n_s_func, __pyx_n_s_wrapper, __pyx_n_s_wrapper); if (unlikely(!__pyx_tuple__79)) __PYX_ERR(0, 416, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__79); __Pyx_GIVEREF(__pyx_tuple__79); __pyx_codeobj__80 = (PyObject*)__Pyx_PyCode_New(1, 0, 3, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__79, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_lupa__lupa_pyx, __pyx_n_s_unpacks_lua_table, 416, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__80)) __PYX_ERR(0, 416, __pyx_L1_error) /* "lupa/_lupa.pyx":442 * * * def unpacks_lua_table_method(meth): # <<<<<<<<<<<<<< * """ * This is :func:`unpacks_lua_table` for methods */ __pyx_tuple__81 = PyTuple_Pack(3, __pyx_n_s_meth, __pyx_n_s_wrapper, __pyx_n_s_wrapper); if (unlikely(!__pyx_tuple__81)) __PYX_ERR(0, 442, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__81); __Pyx_GIVEREF(__pyx_tuple__81); __pyx_codeobj__82 = (PyObject*)__Pyx_PyCode_New(1, 0, 3, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__81, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_lupa__lupa_pyx, __pyx_n_s_unpacks_lua_table_method, 442, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__82)) __PYX_ERR(0, 442, __pyx_L1_error) /* "(tree fragment)":1 * def __reduce_cython__(self): # <<<<<<<<<<<<<< * raise TypeError("self._state cannot be converted to a Python object for pickling") * def __setstate_cython__(self, __pyx_state): */ __pyx_tuple__83 = PyTuple_Pack(1, __pyx_n_s_self); if (unlikely(!__pyx_tuple__83)) __PYX_ERR(2, 1, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__83); __Pyx_GIVEREF(__pyx_tuple__83); __pyx_codeobj__84 = (PyObject*)__Pyx_PyCode_New(1, 0, 1, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__83, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_stringsource, __pyx_n_s_reduce_cython, 1, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__84)) __PYX_ERR(2, 1, __pyx_L1_error) /* "(tree fragment)":3 * def __reduce_cython__(self): * raise TypeError("self._state cannot be converted to a Python object for pickling") * def __setstate_cython__(self, __pyx_state): # <<<<<<<<<<<<<< * raise TypeError("self._state cannot be converted to a Python object for pickling") */ __pyx_tuple__85 = PyTuple_Pack(2, __pyx_n_s_self, __pyx_n_s_pyx_state); if (unlikely(!__pyx_tuple__85)) __PYX_ERR(2, 3, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__85); __Pyx_GIVEREF(__pyx_tuple__85); __pyx_codeobj__86 = (PyObject*)__Pyx_PyCode_New(2, 0, 2, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__85, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_stringsource, __pyx_n_s_setstate_cython, 3, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__86)) __PYX_ERR(2, 3, __pyx_L1_error) /* "lupa/_lupa.pyx":690 * return _LuaIter(self, KEYS) * * def keys(self): # <<<<<<<<<<<<<< * """Returns an iterator over the keys of a table that this * object represents. Same as iter(obj). */ __pyx_tuple__87 = PyTuple_Pack(1, __pyx_n_s_self); if (unlikely(!__pyx_tuple__87)) __PYX_ERR(0, 690, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__87); __Pyx_GIVEREF(__pyx_tuple__87); __pyx_codeobj__88 = (PyObject*)__Pyx_PyCode_New(1, 0, 1, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__87, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_lupa__lupa_pyx, __pyx_n_s_keys, 690, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__88)) __PYX_ERR(0, 690, __pyx_L1_error) /* "lupa/_lupa.pyx":696 * return _LuaIter(self, KEYS) * * def values(self): # <<<<<<<<<<<<<< * """Returns an iterator over the values of a table that this * object represents. */ __pyx_tuple__89 = PyTuple_Pack(1, __pyx_n_s_self); if (unlikely(!__pyx_tuple__89)) __PYX_ERR(0, 696, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__89); __Pyx_GIVEREF(__pyx_tuple__89); __pyx_codeobj__90 = (PyObject*)__Pyx_PyCode_New(1, 0, 1, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__89, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_lupa__lupa_pyx, __pyx_n_s_values, 696, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__90)) __PYX_ERR(0, 696, __pyx_L1_error) /* "lupa/_lupa.pyx":702 * return _LuaIter(self, VALUES) * * def items(self): # <<<<<<<<<<<<<< * """Returns an iterator over the key-value pairs of a table * that this object represents. */ __pyx_tuple__91 = PyTuple_Pack(1, __pyx_n_s_self); if (unlikely(!__pyx_tuple__91)) __PYX_ERR(0, 702, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__91); __Pyx_GIVEREF(__pyx_tuple__91); __pyx_codeobj__92 = (PyObject*)__Pyx_PyCode_New(1, 0, 1, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__91, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_lupa__lupa_pyx, __pyx_n_s_items, 702, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__92)) __PYX_ERR(0, 702, __pyx_L1_error) /* "(tree fragment)":1 * def __reduce_cython__(self): # <<<<<<<<<<<<<< * raise TypeError("self._state cannot be converted to a Python object for pickling") * def __setstate_cython__(self, __pyx_state): */ __pyx_tuple__93 = PyTuple_Pack(1, __pyx_n_s_self); if (unlikely(!__pyx_tuple__93)) __PYX_ERR(2, 1, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__93); __Pyx_GIVEREF(__pyx_tuple__93); __pyx_codeobj__94 = (PyObject*)__Pyx_PyCode_New(1, 0, 1, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__93, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_stringsource, __pyx_n_s_reduce_cython, 1, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__94)) __PYX_ERR(2, 1, __pyx_L1_error) /* "(tree fragment)":3 * def __reduce_cython__(self): * raise TypeError("self._state cannot be converted to a Python object for pickling") * def __setstate_cython__(self, __pyx_state): # <<<<<<<<<<<<<< * raise TypeError("self._state cannot be converted to a Python object for pickling") */ __pyx_tuple__95 = PyTuple_Pack(2, __pyx_n_s_self, __pyx_n_s_pyx_state); if (unlikely(!__pyx_tuple__95)) __PYX_ERR(2, 3, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__95); __Pyx_GIVEREF(__pyx_tuple__95); __pyx_codeobj__96 = (PyObject*)__Pyx_PyCode_New(2, 0, 2, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__95, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_stringsource, __pyx_n_s_setstate_cython, 3, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__96)) __PYX_ERR(2, 3, __pyx_L1_error) /* "lupa/_lupa.pyx":780 * """A Lua function (which may become a coroutine). * """ * def coroutine(self, *args): # <<<<<<<<<<<<<< * """Create a Lua coroutine from a Lua function and call it with * the passed parameters to start it up. */ __pyx_tuple__97 = PyTuple_Pack(6, __pyx_n_s_self, __pyx_n_s_args, __pyx_n_s_L, __pyx_n_s_co, __pyx_n_s_thread, __pyx_n_s_old_top); if (unlikely(!__pyx_tuple__97)) __PYX_ERR(0, 780, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__97); __Pyx_GIVEREF(__pyx_tuple__97); __pyx_codeobj__98 = (PyObject*)__Pyx_PyCode_New(1, 0, 6, 0, CO_OPTIMIZED|CO_NEWLOCALS|CO_VARARGS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__97, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_lupa__lupa_pyx, __pyx_n_s_coroutine, 780, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__98)) __PYX_ERR(0, 780, __pyx_L1_error) /* "(tree fragment)":1 * def __reduce_cython__(self): # <<<<<<<<<<<<<< * raise TypeError("self._state cannot be converted to a Python object for pickling") * def __setstate_cython__(self, __pyx_state): */ __pyx_tuple__99 = PyTuple_Pack(1, __pyx_n_s_self); if (unlikely(!__pyx_tuple__99)) __PYX_ERR(2, 1, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__99); __Pyx_GIVEREF(__pyx_tuple__99); __pyx_codeobj__100 = (PyObject*)__Pyx_PyCode_New(1, 0, 1, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__99, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_stringsource, __pyx_n_s_reduce_cython, 1, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__100)) __PYX_ERR(2, 1, __pyx_L1_error) /* "(tree fragment)":3 * def __reduce_cython__(self): * raise TypeError("self._state cannot be converted to a Python object for pickling") * def __setstate_cython__(self, __pyx_state): # <<<<<<<<<<<<<< * raise TypeError("self._state cannot be converted to a Python object for pickling") */ __pyx_tuple__101 = PyTuple_Pack(2, __pyx_n_s_self, __pyx_n_s_pyx_state); if (unlikely(!__pyx_tuple__101)) __PYX_ERR(2, 3, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__101); __Pyx_GIVEREF(__pyx_tuple__101); __pyx_codeobj__102 = (PyObject*)__Pyx_PyCode_New(2, 0, 2, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__101, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_stringsource, __pyx_n_s_setstate_cython, 3, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__102)) __PYX_ERR(2, 3, __pyx_L1_error) /* "(tree fragment)":1 * def __reduce_cython__(self): # <<<<<<<<<<<<<< * raise TypeError("self._state cannot be converted to a Python object for pickling") * def __setstate_cython__(self, __pyx_state): */ __pyx_tuple__103 = PyTuple_Pack(1, __pyx_n_s_self); if (unlikely(!__pyx_tuple__103)) __PYX_ERR(2, 1, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__103); __Pyx_GIVEREF(__pyx_tuple__103); __pyx_codeobj__104 = (PyObject*)__Pyx_PyCode_New(1, 0, 1, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__103, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_stringsource, __pyx_n_s_reduce_cython, 1, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__104)) __PYX_ERR(2, 1, __pyx_L1_error) /* "(tree fragment)":3 * def __reduce_cython__(self): * raise TypeError("self._state cannot be converted to a Python object for pickling") * def __setstate_cython__(self, __pyx_state): # <<<<<<<<<<<<<< * raise TypeError("self._state cannot be converted to a Python object for pickling") */ __pyx_tuple__105 = PyTuple_Pack(2, __pyx_n_s_self, __pyx_n_s_pyx_state); if (unlikely(!__pyx_tuple__105)) __PYX_ERR(2, 3, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__105); __Pyx_GIVEREF(__pyx_tuple__105); __pyx_codeobj__106 = (PyObject*)__Pyx_PyCode_New(2, 0, 2, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__105, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_stringsource, __pyx_n_s_setstate_cython, 3, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__106)) __PYX_ERR(2, 3, __pyx_L1_error) /* "lupa/_lupa.pyx":846 * return resume_lua_thread(self, args) * * def send(self, value): # <<<<<<<<<<<<<< * """Send a value into the coroutine. If the value is a tuple, * send the unpacked elements. */ __pyx_tuple__107 = PyTuple_Pack(2, __pyx_n_s_self, __pyx_n_s_value); if (unlikely(!__pyx_tuple__107)) __PYX_ERR(0, 846, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__107); __Pyx_GIVEREF(__pyx_tuple__107); __pyx_codeobj__108 = (PyObject*)__Pyx_PyCode_New(2, 0, 2, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__107, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_lupa__lupa_pyx, __pyx_n_s_send, 846, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__108)) __PYX_ERR(0, 846, __pyx_L1_error) /* "(tree fragment)":1 * def __reduce_cython__(self): # <<<<<<<<<<<<<< * raise TypeError("self._co_state,self._state cannot be converted to a Python object for pickling") * def __setstate_cython__(self, __pyx_state): */ __pyx_tuple__109 = PyTuple_Pack(1, __pyx_n_s_self); if (unlikely(!__pyx_tuple__109)) __PYX_ERR(2, 1, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__109); __Pyx_GIVEREF(__pyx_tuple__109); __pyx_codeobj__110 = (PyObject*)__Pyx_PyCode_New(1, 0, 1, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__109, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_stringsource, __pyx_n_s_reduce_cython, 1, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__110)) __PYX_ERR(2, 1, __pyx_L1_error) /* "(tree fragment)":3 * def __reduce_cython__(self): * raise TypeError("self._co_state,self._state cannot be converted to a Python object for pickling") * def __setstate_cython__(self, __pyx_state): # <<<<<<<<<<<<<< * raise TypeError("self._co_state,self._state cannot be converted to a Python object for pickling") */ __pyx_tuple__111 = PyTuple_Pack(2, __pyx_n_s_self, __pyx_n_s_pyx_state); if (unlikely(!__pyx_tuple__111)) __PYX_ERR(2, 3, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__111); __Pyx_GIVEREF(__pyx_tuple__111); __pyx_codeobj__112 = (PyObject*)__Pyx_PyCode_New(2, 0, 2, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__111, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_stringsource, __pyx_n_s_setstate_cython, 3, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__112)) __PYX_ERR(2, 3, __pyx_L1_error) /* "(tree fragment)":1 * def __reduce_cython__(self): # <<<<<<<<<<<<<< * raise TypeError("no default __reduce__ due to non-trivial __cinit__") * def __setstate_cython__(self, __pyx_state): */ __pyx_tuple__113 = PyTuple_Pack(1, __pyx_n_s_self); if (unlikely(!__pyx_tuple__113)) __PYX_ERR(2, 1, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__113); __Pyx_GIVEREF(__pyx_tuple__113); __pyx_codeobj__114 = (PyObject*)__Pyx_PyCode_New(1, 0, 1, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__113, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_stringsource, __pyx_n_s_reduce_cython, 1, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__114)) __PYX_ERR(2, 1, __pyx_L1_error) /* "(tree fragment)":3 * def __reduce_cython__(self): * raise TypeError("no default __reduce__ due to non-trivial __cinit__") * def __setstate_cython__(self, __pyx_state): # <<<<<<<<<<<<<< * raise TypeError("no default __reduce__ due to non-trivial __cinit__") */ __pyx_tuple__115 = PyTuple_Pack(2, __pyx_n_s_self, __pyx_n_s_pyx_state); if (unlikely(!__pyx_tuple__115)) __PYX_ERR(2, 3, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__115); __Pyx_GIVEREF(__pyx_tuple__115); __pyx_codeobj__116 = (PyObject*)__Pyx_PyCode_New(2, 0, 2, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__115, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_stringsource, __pyx_n_s_setstate_cython, 3, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__116)) __PYX_ERR(2, 3, __pyx_L1_error) /* "(tree fragment)":1 * def __reduce_cython__(self): # <<<<<<<<<<<<<< * raise TypeError("no default __reduce__ due to non-trivial __cinit__") * def __setstate_cython__(self, __pyx_state): */ __pyx_tuple__117 = PyTuple_Pack(1, __pyx_n_s_self); if (unlikely(!__pyx_tuple__117)) __PYX_ERR(2, 1, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__117); __Pyx_GIVEREF(__pyx_tuple__117); __pyx_codeobj__118 = (PyObject*)__Pyx_PyCode_New(1, 0, 1, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__117, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_stringsource, __pyx_n_s_reduce_cython, 1, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__118)) __PYX_ERR(2, 1, __pyx_L1_error) /* "(tree fragment)":3 * def __reduce_cython__(self): * raise TypeError("no default __reduce__ due to non-trivial __cinit__") * def __setstate_cython__(self, __pyx_state): # <<<<<<<<<<<<<< * raise TypeError("no default __reduce__ due to non-trivial __cinit__") */ __pyx_tuple__119 = PyTuple_Pack(2, __pyx_n_s_self, __pyx_n_s_pyx_state); if (unlikely(!__pyx_tuple__119)) __PYX_ERR(2, 3, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__119); __Pyx_GIVEREF(__pyx_tuple__119); __pyx_codeobj__120 = (PyObject*)__Pyx_PyCode_New(2, 0, 2, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__119, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_stringsource, __pyx_n_s_setstate_cython, 3, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__120)) __PYX_ERR(2, 3, __pyx_L1_error) /* "lupa/_lupa.pyx":1065 * * * def as_attrgetter(obj): # <<<<<<<<<<<<<< * cdef _PyProtocolWrapper wrap = _PyProtocolWrapper.__new__(_PyProtocolWrapper) * wrap._obj = obj */ __pyx_tuple__121 = PyTuple_Pack(2, __pyx_n_s_obj, __pyx_n_s_wrap); if (unlikely(!__pyx_tuple__121)) __PYX_ERR(0, 1065, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__121); __Pyx_GIVEREF(__pyx_tuple__121); __pyx_codeobj__122 = (PyObject*)__Pyx_PyCode_New(1, 0, 2, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__121, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_lupa__lupa_pyx, __pyx_n_s_as_attrgetter, 1065, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__122)) __PYX_ERR(0, 1065, __pyx_L1_error) /* "lupa/_lupa.pyx":1071 * return wrap * * def as_itemgetter(obj): # <<<<<<<<<<<<<< * cdef _PyProtocolWrapper wrap = _PyProtocolWrapper.__new__(_PyProtocolWrapper) * wrap._obj = obj */ __pyx_tuple__123 = PyTuple_Pack(2, __pyx_n_s_obj, __pyx_n_s_wrap); if (unlikely(!__pyx_tuple__123)) __PYX_ERR(0, 1071, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__123); __Pyx_GIVEREF(__pyx_tuple__123); __pyx_codeobj__124 = (PyObject*)__Pyx_PyCode_New(1, 0, 2, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__123, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_lupa__lupa_pyx, __pyx_n_s_as_itemgetter, 1071, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__124)) __PYX_ERR(0, 1071, __pyx_L1_error) __Pyx_RefNannyFinishContext(); return 0; __pyx_L1_error:; __Pyx_RefNannyFinishContext(); return -1; } static int __Pyx_InitGlobals(void) { __pyx_umethod_PyList_Type_pop.type = (PyObject*)&PyList_Type; if (__Pyx_InitStrings(__pyx_string_tab) < 0) __PYX_ERR(0, 1, __pyx_L1_error); __pyx_int_1 = PyInt_FromLong(1); if (unlikely(!__pyx_int_1)) __PYX_ERR(0, 1, __pyx_L1_error) return 0; __pyx_L1_error:; return -1; } #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) #if CYTHON_PEP489_MULTI_PHASE_INIT { return PyModuleDef_Init(&__pyx_moduledef); } static int __Pyx_copy_spec_to_module(PyObject *spec, PyObject *moddict, const char* from_name, const char* to_name) { PyObject *value = PyObject_GetAttrString(spec, from_name); int result = 0; if (likely(value)) { result = PyDict_SetItemString(moddict, to_name, value); Py_DECREF(value); } else if (PyErr_ExceptionMatches(PyExc_AttributeError)) { PyErr_Clear(); } else { result = -1; } return result; } static PyObject* __pyx_pymod_create(PyObject *spec, CYTHON_UNUSED PyModuleDef *def) { PyObject *module = NULL, *moddict, *modname; if (__pyx_m) return __Pyx_NewRef(__pyx_m); modname = PyObject_GetAttrString(spec, "name"); if (unlikely(!modname)) goto bad; module = PyModule_NewObject(modname); Py_DECREF(modname); if (unlikely(!module)) goto bad; moddict = PyModule_GetDict(module); if (unlikely(!moddict)) goto bad; if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "loader", "__loader__") < 0)) goto bad; if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "origin", "__file__") < 0)) goto bad; if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "parent", "__package__") < 0)) goto bad; if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "submodule_search_locations", "__path__") < 0)) goto bad; return module; bad: Py_XDECREF(module); return NULL; } static int __pyx_pymod_exec__lupa(PyObject *__pyx_pyinit_module) #endif #endif { PyObject *__pyx_t_1 = NULL; PyObject *__pyx_t_2 = NULL; PyObject *__pyx_t_3 = NULL; PyObject *__pyx_t_4 = NULL; PyObject *__pyx_t_5 = NULL; int __pyx_t_6; PyObject *__pyx_t_7 = NULL; PyObject *__pyx_t_8 = NULL; luaL_Reg __pyx_t_9; luaL_Reg __pyx_t_10; luaL_Reg __pyx_t_11; luaL_Reg __pyx_t_12; luaL_Reg __pyx_t_13; luaL_Reg __pyx_t_14; static luaL_Reg __pyx_t_15[6]; luaL_Reg __pyx_t_16; static luaL_Reg __pyx_t_17[7]; __Pyx_RefNannyDeclarations #if CYTHON_PEP489_MULTI_PHASE_INIT if (__pyx_m && __pyx_m == __pyx_pyinit_module) return 0; #endif #if CYTHON_REFNANNY __Pyx_RefNanny = __Pyx_RefNannyImportAPI("refnanny"); if (!__Pyx_RefNanny) { PyErr_Clear(); __Pyx_RefNanny = __Pyx_RefNannyImportAPI("Cython.Runtime.refnanny"); if (!__Pyx_RefNanny) Py_FatalError("failed to import 'refnanny' module"); } #endif __Pyx_RefNannySetupContext("PyMODINIT_FUNC PyInit__lupa(void)", 0); if (__Pyx_check_binary_version() < 0) __PYX_ERR(0, 1, __pyx_L1_error) __pyx_empty_tuple = PyTuple_New(0); if (unlikely(!__pyx_empty_tuple)) __PYX_ERR(0, 1, __pyx_L1_error) __pyx_empty_bytes = PyBytes_FromStringAndSize("", 0); if (unlikely(!__pyx_empty_bytes)) __PYX_ERR(0, 1, __pyx_L1_error) __pyx_empty_unicode = PyUnicode_FromStringAndSize("", 0); if (unlikely(!__pyx_empty_unicode)) __PYX_ERR(0, 1, __pyx_L1_error) #ifdef __Pyx_CyFunction_USED if (__pyx_CyFunction_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error) #endif #ifdef __Pyx_FusedFunction_USED if (__pyx_FusedFunction_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error) #endif #ifdef __Pyx_Coroutine_USED if (__pyx_Coroutine_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error) #endif #ifdef __Pyx_Generator_USED if (__pyx_Generator_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error) #endif #ifdef __Pyx_AsyncGen_USED if (__pyx_AsyncGen_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error) #endif #ifdef __Pyx_StopAsyncIteration_USED if (__pyx_StopAsyncIteration_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error) #endif /*--- Library function declarations ---*/ /*--- Threads initialization code ---*/ #if defined(__PYX_FORCE_INIT_THREADS) && __PYX_FORCE_INIT_THREADS #ifdef WITH_THREAD /* Python build with threading support? */ PyEval_InitThreads(); #endif #endif /*--- Module creation code ---*/ #if CYTHON_PEP489_MULTI_PHASE_INIT __pyx_m = __pyx_pyinit_module; Py_INCREF(__pyx_m); #else #if PY_MAJOR_VERSION < 3 __pyx_m = Py_InitModule4("_lupa", __pyx_methods, __pyx_k_A_fast_Python_wrapper_around_Lu, 0, PYTHON_API_VERSION); Py_XINCREF(__pyx_m); #else __pyx_m = PyModule_Create(&__pyx_moduledef); #endif if (unlikely(!__pyx_m)) __PYX_ERR(0, 1, __pyx_L1_error) #endif __pyx_d = PyModule_GetDict(__pyx_m); if (unlikely(!__pyx_d)) __PYX_ERR(0, 1, __pyx_L1_error) Py_INCREF(__pyx_d); __pyx_b = PyImport_AddModule(__Pyx_BUILTIN_MODULE_NAME); if (unlikely(!__pyx_b)) __PYX_ERR(0, 1, __pyx_L1_error) __pyx_cython_runtime = PyImport_AddModule((char *) "cython_runtime"); if (unlikely(!__pyx_cython_runtime)) __PYX_ERR(0, 1, __pyx_L1_error) #if CYTHON_COMPILING_IN_PYPY Py_INCREF(__pyx_b); #endif if (PyObject_SetAttrString(__pyx_m, "__builtins__", __pyx_b) < 0) __PYX_ERR(0, 1, __pyx_L1_error); /*--- Initialize various global constants etc. ---*/ if (__Pyx_InitGlobals() < 0) __PYX_ERR(0, 1, __pyx_L1_error) #if PY_MAJOR_VERSION < 3 && (__PYX_DEFAULT_STRING_ENCODING_IS_ASCII || __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT) if (__Pyx_init_sys_getdefaultencoding_params() < 0) __PYX_ERR(0, 1, __pyx_L1_error) #endif if (__pyx_module_is_main_lupa___lupa) { if (PyObject_SetAttrString(__pyx_m, "__name__", __pyx_n_s_main) < 0) __PYX_ERR(0, 1, __pyx_L1_error) } #if PY_MAJOR_VERSION >= 3 { PyObject *modules = PyImport_GetModuleDict(); if (unlikely(!modules)) __PYX_ERR(0, 1, __pyx_L1_error) if (!PyDict_GetItemString(modules, "lupa._lupa")) { if (unlikely(PyDict_SetItemString(modules, "lupa._lupa", __pyx_m) < 0)) __PYX_ERR(0, 1, __pyx_L1_error) } } #endif /*--- Builtin init code ---*/ if (__Pyx_InitCachedBuiltins() < 0) __PYX_ERR(0, 1, __pyx_L1_error) /*--- Constants init code ---*/ if (__Pyx_InitCachedConstants() < 0) __PYX_ERR(0, 1, __pyx_L1_error) /*--- Global init code ---*/ __pyx_v_4lupa_5_lupa_exc_info = Py_None; Py_INCREF(Py_None); __pyx_v_4lupa_5_lupa_Mapping = Py_None; Py_INCREF(Py_None); __pyx_v_4lupa_5_lupa_wraps = Py_None; Py_INCREF(Py_None); __pyx_v_4lupa_5_lupa_builtins = Py_None; Py_INCREF(Py_None); /*--- Variable export code ---*/ /*--- Function export code ---*/ /*--- Type init code ---*/ if (PyType_Ready(&__pyx_type_4lupa_5_lupa_FastRLock) < 0) __PYX_ERR(1, 5, __pyx_L1_error) __pyx_type_4lupa_5_lupa_FastRLock.tp_print = 0; if (PyObject_SetAttrString(__pyx_m, "FastRLock", (PyObject *)&__pyx_type_4lupa_5_lupa_FastRLock) < 0) __PYX_ERR(1, 5, __pyx_L1_error) if (__Pyx_setup_reduce((PyObject*)&__pyx_type_4lupa_5_lupa_FastRLock) < 0) __PYX_ERR(1, 5, __pyx_L1_error) __pyx_ptype_4lupa_5_lupa_FastRLock = &__pyx_type_4lupa_5_lupa_FastRLock; __pyx_vtabptr_4lupa_5_lupa_LuaRuntime = &__pyx_vtable_4lupa_5_lupa_LuaRuntime; __pyx_vtable_4lupa_5_lupa_LuaRuntime.reraise_on_exception = (int (*)(struct __pyx_obj_4lupa_5_lupa_LuaRuntime *))__pyx_f_4lupa_5_lupa_10LuaRuntime_reraise_on_exception; __pyx_vtable_4lupa_5_lupa_LuaRuntime.store_raised_exception = (int (*)(struct __pyx_obj_4lupa_5_lupa_LuaRuntime *, lua_State *, PyObject *))__pyx_f_4lupa_5_lupa_10LuaRuntime_store_raised_exception; __pyx_vtable_4lupa_5_lupa_LuaRuntime.register_py_object = (int (*)(struct __pyx_obj_4lupa_5_lupa_LuaRuntime *, PyObject *, PyObject *, PyObject *))__pyx_f_4lupa_5_lupa_10LuaRuntime_register_py_object; __pyx_vtable_4lupa_5_lupa_LuaRuntime.init_python_lib = (int (*)(struct __pyx_obj_4lupa_5_lupa_LuaRuntime *, int, int))__pyx_f_4lupa_5_lupa_10LuaRuntime_init_python_lib; if (PyType_Ready(&__pyx_type_4lupa_5_lupa_LuaRuntime) < 0) __PYX_ERR(0, 110, __pyx_L1_error) __pyx_type_4lupa_5_lupa_LuaRuntime.tp_print = 0; if (__Pyx_SetVtable(__pyx_type_4lupa_5_lupa_LuaRuntime.tp_dict, __pyx_vtabptr_4lupa_5_lupa_LuaRuntime) < 0) __PYX_ERR(0, 110, __pyx_L1_error) if (PyObject_SetAttrString(__pyx_m, "LuaRuntime", (PyObject *)&__pyx_type_4lupa_5_lupa_LuaRuntime) < 0) __PYX_ERR(0, 110, __pyx_L1_error) if (__Pyx_setup_reduce((PyObject*)&__pyx_type_4lupa_5_lupa_LuaRuntime) < 0) __PYX_ERR(0, 110, __pyx_L1_error) __pyx_ptype_4lupa_5_lupa_LuaRuntime = &__pyx_type_4lupa_5_lupa_LuaRuntime; __pyx_vtabptr_4lupa_5_lupa__LuaObject = &__pyx_vtable_4lupa_5_lupa__LuaObject; __pyx_vtable_4lupa_5_lupa__LuaObject.push_lua_object = (int (*)(struct __pyx_obj_4lupa_5_lupa__LuaObject *))__pyx_f_4lupa_5_lupa_10_LuaObject_push_lua_object; __pyx_vtable_4lupa_5_lupa__LuaObject._len = (size_t (*)(struct __pyx_obj_4lupa_5_lupa__LuaObject *))__pyx_f_4lupa_5_lupa_10_LuaObject__len; __pyx_vtable_4lupa_5_lupa__LuaObject._getitem = (PyObject *(*)(struct __pyx_obj_4lupa_5_lupa__LuaObject *, PyObject *, int))__pyx_f_4lupa_5_lupa_10_LuaObject__getitem; if (PyType_Ready(&__pyx_type_4lupa_5_lupa__LuaObject) < 0) __PYX_ERR(0, 503, __pyx_L1_error) __pyx_type_4lupa_5_lupa__LuaObject.tp_print = 0; if (__Pyx_SetVtable(__pyx_type_4lupa_5_lupa__LuaObject.tp_dict, __pyx_vtabptr_4lupa_5_lupa__LuaObject) < 0) __PYX_ERR(0, 503, __pyx_L1_error) if (__Pyx_setup_reduce((PyObject*)&__pyx_type_4lupa_5_lupa__LuaObject) < 0) __PYX_ERR(0, 503, __pyx_L1_error) __pyx_ptype_4lupa_5_lupa__LuaObject = &__pyx_type_4lupa_5_lupa__LuaObject; __pyx_vtabptr_4lupa_5_lupa__LuaTable = &__pyx_vtable_4lupa_5_lupa__LuaTable; __pyx_vtable_4lupa_5_lupa__LuaTable.__pyx_base = *__pyx_vtabptr_4lupa_5_lupa__LuaObject; __pyx_vtable_4lupa_5_lupa__LuaTable._setitem = (int (*)(struct __pyx_obj_4lupa_5_lupa__LuaTable *, PyObject *, PyObject *))__pyx_f_4lupa_5_lupa_9_LuaTable__setitem; __pyx_vtable_4lupa_5_lupa__LuaTable._delitem = (PyObject *(*)(struct __pyx_obj_4lupa_5_lupa__LuaTable *, PyObject *))__pyx_f_4lupa_5_lupa_9_LuaTable__delitem; __pyx_type_4lupa_5_lupa__LuaTable.tp_base = __pyx_ptype_4lupa_5_lupa__LuaObject; if (PyType_Ready(&__pyx_type_4lupa_5_lupa__LuaTable) < 0) __PYX_ERR(0, 686, __pyx_L1_error) __pyx_type_4lupa_5_lupa__LuaTable.tp_print = 0; if (__Pyx_SetVtable(__pyx_type_4lupa_5_lupa__LuaTable.tp_dict, __pyx_vtabptr_4lupa_5_lupa__LuaTable) < 0) __PYX_ERR(0, 686, __pyx_L1_error) if (__Pyx_setup_reduce((PyObject*)&__pyx_type_4lupa_5_lupa__LuaTable) < 0) __PYX_ERR(0, 686, __pyx_L1_error) __pyx_ptype_4lupa_5_lupa__LuaTable = &__pyx_type_4lupa_5_lupa__LuaTable; __pyx_vtabptr_4lupa_5_lupa__LuaFunction = &__pyx_vtable_4lupa_5_lupa__LuaFunction; __pyx_vtable_4lupa_5_lupa__LuaFunction.__pyx_base = *__pyx_vtabptr_4lupa_5_lupa__LuaObject; __pyx_type_4lupa_5_lupa__LuaFunction.tp_base = __pyx_ptype_4lupa_5_lupa__LuaObject; if (PyType_Ready(&__pyx_type_4lupa_5_lupa__LuaFunction) < 0) __PYX_ERR(0, 777, __pyx_L1_error) __pyx_type_4lupa_5_lupa__LuaFunction.tp_print = 0; if (__Pyx_SetVtable(__pyx_type_4lupa_5_lupa__LuaFunction.tp_dict, __pyx_vtabptr_4lupa_5_lupa__LuaFunction) < 0) __PYX_ERR(0, 777, __pyx_L1_error) if (__Pyx_setup_reduce((PyObject*)&__pyx_type_4lupa_5_lupa__LuaFunction) < 0) __PYX_ERR(0, 777, __pyx_L1_error) __pyx_ptype_4lupa_5_lupa__LuaFunction = &__pyx_type_4lupa_5_lupa__LuaFunction; __pyx_vtabptr_4lupa_5_lupa__LuaCoroutineFunction = &__pyx_vtable_4lupa_5_lupa__LuaCoroutineFunction; __pyx_vtable_4lupa_5_lupa__LuaCoroutineFunction.__pyx_base = *__pyx_vtabptr_4lupa_5_lupa__LuaFunction; __pyx_type_4lupa_5_lupa__LuaCoroutineFunction.tp_base = __pyx_ptype_4lupa_5_lupa__LuaFunction; if (PyType_Ready(&__pyx_type_4lupa_5_lupa__LuaCoroutineFunction) < 0) __PYX_ERR(0, 816, __pyx_L1_error) __pyx_type_4lupa_5_lupa__LuaCoroutineFunction.tp_print = 0; if (__Pyx_SetVtable(__pyx_type_4lupa_5_lupa__LuaCoroutineFunction.tp_dict, __pyx_vtabptr_4lupa_5_lupa__LuaCoroutineFunction) < 0) __PYX_ERR(0, 816, __pyx_L1_error) if (__Pyx_setup_reduce((PyObject*)&__pyx_type_4lupa_5_lupa__LuaCoroutineFunction) < 0) __PYX_ERR(0, 816, __pyx_L1_error) __pyx_ptype_4lupa_5_lupa__LuaCoroutineFunction = &__pyx_type_4lupa_5_lupa__LuaCoroutineFunction; __pyx_vtabptr_4lupa_5_lupa__LuaThread = &__pyx_vtable_4lupa_5_lupa__LuaThread; __pyx_vtable_4lupa_5_lupa__LuaThread.__pyx_base = *__pyx_vtabptr_4lupa_5_lupa__LuaObject; __pyx_type_4lupa_5_lupa__LuaThread.tp_base = __pyx_ptype_4lupa_5_lupa__LuaObject; if (PyType_Ready(&__pyx_type_4lupa_5_lupa__LuaThread) < 0) __PYX_ERR(0, 831, __pyx_L1_error) __pyx_type_4lupa_5_lupa__LuaThread.tp_print = 0; if (__Pyx_SetVtable(__pyx_type_4lupa_5_lupa__LuaThread.tp_dict, __pyx_vtabptr_4lupa_5_lupa__LuaThread) < 0) __PYX_ERR(0, 831, __pyx_L1_error) if (__Pyx_setup_reduce((PyObject*)&__pyx_type_4lupa_5_lupa__LuaThread) < 0) __PYX_ERR(0, 831, __pyx_L1_error) __pyx_ptype_4lupa_5_lupa__LuaThread = &__pyx_type_4lupa_5_lupa__LuaThread; if (PyType_Ready(&__pyx_type_4lupa_5_lupa__LuaIter) < 0) __PYX_ERR(0, 945, __pyx_L1_error) __pyx_type_4lupa_5_lupa__LuaIter.tp_print = 0; if (__Pyx_setup_reduce((PyObject*)&__pyx_type_4lupa_5_lupa__LuaIter) < 0) __PYX_ERR(0, 945, __pyx_L1_error) __pyx_ptype_4lupa_5_lupa__LuaIter = &__pyx_type_4lupa_5_lupa__LuaIter; if (PyType_Ready(&__pyx_type_4lupa_5_lupa__PyProtocolWrapper) < 0) __PYX_ERR(0, 1056, __pyx_L1_error) __pyx_type_4lupa_5_lupa__PyProtocolWrapper.tp_print = 0; if (__Pyx_setup_reduce((PyObject*)&__pyx_type_4lupa_5_lupa__PyProtocolWrapper) < 0) __PYX_ERR(0, 1056, __pyx_L1_error) __pyx_ptype_4lupa_5_lupa__PyProtocolWrapper = &__pyx_type_4lupa_5_lupa__PyProtocolWrapper; if (PyType_Ready(&__pyx_type_4lupa_5_lupa___pyx_scope_struct__unpacks_lua_table) < 0) __PYX_ERR(0, 416, __pyx_L1_error) __pyx_type_4lupa_5_lupa___pyx_scope_struct__unpacks_lua_table.tp_print = 0; __pyx_ptype_4lupa_5_lupa___pyx_scope_struct__unpacks_lua_table = &__pyx_type_4lupa_5_lupa___pyx_scope_struct__unpacks_lua_table; if (PyType_Ready(&__pyx_type_4lupa_5_lupa___pyx_scope_struct_1_unpacks_lua_table_method) < 0) __PYX_ERR(0, 442, __pyx_L1_error) __pyx_type_4lupa_5_lupa___pyx_scope_struct_1_unpacks_lua_table_method.tp_print = 0; __pyx_ptype_4lupa_5_lupa___pyx_scope_struct_1_unpacks_lua_table_method = &__pyx_type_4lupa_5_lupa___pyx_scope_struct_1_unpacks_lua_table_method; /*--- Type import code ---*/ __pyx_ptype_7cpython_4type_type = __Pyx_ImportType(__Pyx_BUILTIN_MODULE_NAME, "type", #if CYTHON_COMPILING_IN_PYPY sizeof(PyTypeObject), #else sizeof(PyHeapTypeObject), #endif 0); if (unlikely(!__pyx_ptype_7cpython_4type_type)) __PYX_ERR(3, 9, __pyx_L1_error) __pyx_ptype_7cpython_4bool_bool = __Pyx_ImportType(__Pyx_BUILTIN_MODULE_NAME, "bool", sizeof(PyBoolObject), 0); if (unlikely(!__pyx_ptype_7cpython_4bool_bool)) __PYX_ERR(4, 8, __pyx_L1_error) __pyx_ptype_7cpython_7complex_complex = __Pyx_ImportType(__Pyx_BUILTIN_MODULE_NAME, "complex", sizeof(PyComplexObject), 0); if (unlikely(!__pyx_ptype_7cpython_7complex_complex)) __PYX_ERR(5, 15, __pyx_L1_error) /*--- Variable import code ---*/ /*--- Function import code ---*/ /*--- Execution code ---*/ #if defined(__Pyx_Generator_USED) || defined(__Pyx_Coroutine_USED) if (__Pyx_patch_abc() < 0) __PYX_ERR(0, 1, __pyx_L1_error) #endif /* "lupa/_lupa.pyx":28 * * cdef object exc_info * from sys import exc_info # <<<<<<<<<<<<<< * * cdef object Mapping */ __pyx_t_1 = PyList_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 28, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_INCREF(__pyx_n_s_exc_info); __Pyx_GIVEREF(__pyx_n_s_exc_info); PyList_SET_ITEM(__pyx_t_1, 0, __pyx_n_s_exc_info); __pyx_t_2 = __Pyx_Import(__pyx_n_s_sys, __pyx_t_1, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 28, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_1 = __Pyx_ImportFrom(__pyx_t_2, __pyx_n_s_exc_info); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 28, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_INCREF(__pyx_t_1); __Pyx_XGOTREF(__pyx_v_4lupa_5_lupa_exc_info); __Pyx_DECREF_SET(__pyx_v_4lupa_5_lupa_exc_info, __pyx_t_1); __Pyx_GIVEREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; /* "lupa/_lupa.pyx":31 * * cdef object Mapping * from collections import Mapping # <<<<<<<<<<<<<< * * cdef object wraps */ __pyx_t_2 = PyList_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 31, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_INCREF(__pyx_n_s_Mapping); __Pyx_GIVEREF(__pyx_n_s_Mapping); PyList_SET_ITEM(__pyx_t_2, 0, __pyx_n_s_Mapping); __pyx_t_1 = __Pyx_Import(__pyx_n_s_collections, __pyx_t_2, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 31, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = __Pyx_ImportFrom(__pyx_t_1, __pyx_n_s_Mapping); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 31, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_INCREF(__pyx_t_2); __Pyx_XGOTREF(__pyx_v_4lupa_5_lupa_Mapping); __Pyx_DECREF_SET(__pyx_v_4lupa_5_lupa_Mapping, __pyx_t_2); __Pyx_GIVEREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; /* "lupa/_lupa.pyx":34 * * cdef object wraps * from functools import wraps # <<<<<<<<<<<<<< * * */ __pyx_t_1 = PyList_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 34, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_INCREF(__pyx_n_s_wraps); __Pyx_GIVEREF(__pyx_n_s_wraps); PyList_SET_ITEM(__pyx_t_1, 0, __pyx_n_s_wraps); __pyx_t_2 = __Pyx_Import(__pyx_n_s_functools, __pyx_t_1, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 34, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_1 = __Pyx_ImportFrom(__pyx_t_2, __pyx_n_s_wraps); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 34, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_INCREF(__pyx_t_1); __Pyx_XGOTREF(__pyx_v_4lupa_5_lupa_wraps); __Pyx_DECREF_SET(__pyx_v_4lupa_5_lupa_wraps, __pyx_t_1); __Pyx_GIVEREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; /* "lupa/_lupa.pyx":37 * * * __all__ = ['LuaRuntime', 'LuaError', 'LuaSyntaxError', # <<<<<<<<<<<<<< * 'as_itemgetter', 'as_attrgetter', 'lua_type', * 'unpacks_lua_table', 'unpacks_lua_table_method'] */ __pyx_t_2 = PyList_New(8); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 37, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_INCREF(__pyx_n_s_LuaRuntime); __Pyx_GIVEREF(__pyx_n_s_LuaRuntime); PyList_SET_ITEM(__pyx_t_2, 0, __pyx_n_s_LuaRuntime); __Pyx_INCREF(__pyx_n_s_LuaError); __Pyx_GIVEREF(__pyx_n_s_LuaError); PyList_SET_ITEM(__pyx_t_2, 1, __pyx_n_s_LuaError); __Pyx_INCREF(__pyx_n_s_LuaSyntaxError); __Pyx_GIVEREF(__pyx_n_s_LuaSyntaxError); PyList_SET_ITEM(__pyx_t_2, 2, __pyx_n_s_LuaSyntaxError); __Pyx_INCREF(__pyx_n_s_as_itemgetter); __Pyx_GIVEREF(__pyx_n_s_as_itemgetter); PyList_SET_ITEM(__pyx_t_2, 3, __pyx_n_s_as_itemgetter); __Pyx_INCREF(__pyx_n_s_as_attrgetter); __Pyx_GIVEREF(__pyx_n_s_as_attrgetter); PyList_SET_ITEM(__pyx_t_2, 4, __pyx_n_s_as_attrgetter); __Pyx_INCREF(__pyx_n_s_lua_type); __Pyx_GIVEREF(__pyx_n_s_lua_type); PyList_SET_ITEM(__pyx_t_2, 5, __pyx_n_s_lua_type); __Pyx_INCREF(__pyx_n_s_unpacks_lua_table); __Pyx_GIVEREF(__pyx_n_s_unpacks_lua_table); PyList_SET_ITEM(__pyx_t_2, 6, __pyx_n_s_unpacks_lua_table); __Pyx_INCREF(__pyx_n_s_unpacks_lua_table_method); __Pyx_GIVEREF(__pyx_n_s_unpacks_lua_table_method); PyList_SET_ITEM(__pyx_t_2, 7, __pyx_n_s_unpacks_lua_table_method); if (PyDict_SetItem(__pyx_d, __pyx_n_s_all, __pyx_t_2) < 0) __PYX_ERR(0, 37, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; /* "lupa/_lupa.pyx":42 * * cdef object builtins * try: # <<<<<<<<<<<<<< * import __builtin__ as builtins * except ImportError: */ { __Pyx_PyThreadState_declare __Pyx_PyThreadState_assign __Pyx_ExceptionSave(&__pyx_t_3, &__pyx_t_4, &__pyx_t_5); __Pyx_XGOTREF(__pyx_t_3); __Pyx_XGOTREF(__pyx_t_4); __Pyx_XGOTREF(__pyx_t_5); /*try:*/ { /* "lupa/_lupa.pyx":43 * cdef object builtins * try: * import __builtin__ as builtins # <<<<<<<<<<<<<< * except ImportError: * import builtins */ __pyx_t_2 = __Pyx_Import(__pyx_n_s_builtin, 0, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 43, __pyx_L2_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_XGOTREF(__pyx_v_4lupa_5_lupa_builtins); __Pyx_DECREF_SET(__pyx_v_4lupa_5_lupa_builtins, __pyx_t_2); __Pyx_GIVEREF(__pyx_t_2); __pyx_t_2 = 0; /* "lupa/_lupa.pyx":42 * * cdef object builtins * try: # <<<<<<<<<<<<<< * import __builtin__ as builtins * except ImportError: */ } __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; goto __pyx_L7_try_end; __pyx_L2_error:; __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; /* "lupa/_lupa.pyx":44 * try: * import __builtin__ as builtins * except ImportError: # <<<<<<<<<<<<<< * import builtins * */ __pyx_t_6 = __Pyx_PyErr_ExceptionMatches(__pyx_builtin_ImportError); if (__pyx_t_6) { __Pyx_AddTraceback("lupa._lupa", __pyx_clineno, __pyx_lineno, __pyx_filename); if (__Pyx_GetException(&__pyx_t_2, &__pyx_t_1, &__pyx_t_7) < 0) __PYX_ERR(0, 44, __pyx_L4_except_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_GOTREF(__pyx_t_1); __Pyx_GOTREF(__pyx_t_7); /* "lupa/_lupa.pyx":45 * import __builtin__ as builtins * except ImportError: * import builtins # <<<<<<<<<<<<<< * * DEF POBJECT = b"POBJECT" # as used by LunaticPython */ __pyx_t_8 = __Pyx_Import(__pyx_n_s_builtins, 0, 0); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 45, __pyx_L4_except_error) __Pyx_GOTREF(__pyx_t_8); __Pyx_XGOTREF(__pyx_v_4lupa_5_lupa_builtins); __Pyx_DECREF_SET(__pyx_v_4lupa_5_lupa_builtins, __pyx_t_8); __Pyx_GIVEREF(__pyx_t_8); __pyx_t_8 = 0; __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; goto __pyx_L3_exception_handled; } goto __pyx_L4_except_error; __pyx_L4_except_error:; /* "lupa/_lupa.pyx":42 * * cdef object builtins * try: # <<<<<<<<<<<<<< * import __builtin__ as builtins * except ImportError: */ __Pyx_XGIVEREF(__pyx_t_3); __Pyx_XGIVEREF(__pyx_t_4); __Pyx_XGIVEREF(__pyx_t_5); __Pyx_ExceptionReset(__pyx_t_3, __pyx_t_4, __pyx_t_5); goto __pyx_L1_error; __pyx_L3_exception_handled:; __Pyx_XGIVEREF(__pyx_t_3); __Pyx_XGIVEREF(__pyx_t_4); __Pyx_XGIVEREF(__pyx_t_5); __Pyx_ExceptionReset(__pyx_t_3, __pyx_t_4, __pyx_t_5); __pyx_L7_try_end:; } /* "lupa/_lupa.pyx":48 * * DEF POBJECT = b"POBJECT" # as used by LunaticPython * cdef int IS_PY2 = PY_MAJOR_VERSION == 2 # <<<<<<<<<<<<<< * * cdef enum WrappedObjectFlags: */ __pyx_v_4lupa_5_lupa_IS_PY2 = (PY_MAJOR_VERSION == 2); /* "lupa/lock.pxi":34 * self._real_lock = NULL * * def acquire(self, bint blocking=True): # <<<<<<<<<<<<<< * return lock_lock(self, pythread.PyThread_get_thread_ident(), blocking) * */ __pyx_t_7 = __Pyx_CyFunction_NewEx(&__pyx_mdef_4lupa_5_lupa_9FastRLock_5acquire, __Pyx_CYFUNCTION_CCLASS, __pyx_n_s_FastRLock_acquire, NULL, __pyx_n_s_lupa__lupa, __pyx_d, ((PyObject *)__pyx_codeobj__46)); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 34, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); if (PyDict_SetItem((PyObject *)__pyx_ptype_4lupa_5_lupa_FastRLock->tp_dict, __pyx_n_s_acquire, __pyx_t_7) < 0) __PYX_ERR(1, 34, __pyx_L1_error) __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; PyType_Modified(__pyx_ptype_4lupa_5_lupa_FastRLock); /* "lupa/lock.pxi":37 * return lock_lock(self, pythread.PyThread_get_thread_ident(), blocking) * * def release(self): # <<<<<<<<<<<<<< * if self._owner != pythread.PyThread_get_thread_ident(): * raise RuntimeError("cannot release un-acquired lock") */ __pyx_t_7 = __Pyx_CyFunction_NewEx(&__pyx_mdef_4lupa_5_lupa_9FastRLock_7release, __Pyx_CYFUNCTION_CCLASS, __pyx_n_s_FastRLock_release, NULL, __pyx_n_s_lupa__lupa, __pyx_d, ((PyObject *)__pyx_codeobj__48)); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 37, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); if (PyDict_SetItem((PyObject *)__pyx_ptype_4lupa_5_lupa_FastRLock->tp_dict, __pyx_n_s_release, __pyx_t_7) < 0) __PYX_ERR(1, 37, __pyx_L1_error) __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; PyType_Modified(__pyx_ptype_4lupa_5_lupa_FastRLock); /* "lupa/lock.pxi":44 * # compatibility with RLock * * def __enter__(self): # <<<<<<<<<<<<<< * # self.acquire() * return lock_lock(self, pythread.PyThread_get_thread_ident(), True) */ __pyx_t_7 = __Pyx_CyFunction_NewEx(&__pyx_mdef_4lupa_5_lupa_9FastRLock_9__enter__, __Pyx_CYFUNCTION_CCLASS, __pyx_n_s_FastRLock___enter, NULL, __pyx_n_s_lupa__lupa, __pyx_d, ((PyObject *)__pyx_codeobj__50)); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 44, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); if (PyDict_SetItem((PyObject *)__pyx_ptype_4lupa_5_lupa_FastRLock->tp_dict, __pyx_n_s_enter, __pyx_t_7) < 0) __PYX_ERR(1, 44, __pyx_L1_error) __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; PyType_Modified(__pyx_ptype_4lupa_5_lupa_FastRLock); /* "lupa/lock.pxi":48 * return lock_lock(self, pythread.PyThread_get_thread_ident(), True) * * def __exit__(self, t, v, tb): # <<<<<<<<<<<<<< * # self.release() * if self._owner != pythread.PyThread_get_thread_ident(): */ __pyx_t_7 = __Pyx_CyFunction_NewEx(&__pyx_mdef_4lupa_5_lupa_9FastRLock_11__exit__, __Pyx_CYFUNCTION_CCLASS, __pyx_n_s_FastRLock___exit, NULL, __pyx_n_s_lupa__lupa, __pyx_d, ((PyObject *)__pyx_codeobj__52)); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 48, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); if (PyDict_SetItem((PyObject *)__pyx_ptype_4lupa_5_lupa_FastRLock->tp_dict, __pyx_n_s_exit, __pyx_t_7) < 0) __PYX_ERR(1, 48, __pyx_L1_error) __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; PyType_Modified(__pyx_ptype_4lupa_5_lupa_FastRLock); /* "lupa/lock.pxi":54 * unlock_lock(self) * * def _is_owned(self): # <<<<<<<<<<<<<< * return self._owner == pythread.PyThread_get_thread_ident() * */ __pyx_t_7 = __Pyx_CyFunction_NewEx(&__pyx_mdef_4lupa_5_lupa_9FastRLock_13_is_owned, __Pyx_CYFUNCTION_CCLASS, __pyx_n_s_FastRLock__is_owned, NULL, __pyx_n_s_lupa__lupa, __pyx_d, ((PyObject *)__pyx_codeobj__54)); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 54, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); if (PyDict_SetItem((PyObject *)__pyx_ptype_4lupa_5_lupa_FastRLock->tp_dict, __pyx_n_s_is_owned, __pyx_t_7) < 0) __PYX_ERR(1, 54, __pyx_L1_error) __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; PyType_Modified(__pyx_ptype_4lupa_5_lupa_FastRLock); /* "(tree fragment)":1 * def __reduce_cython__(self): # <<<<<<<<<<<<<< * raise TypeError("no default __reduce__ due to non-trivial __cinit__") * def __setstate_cython__(self, __pyx_state): */ __pyx_t_7 = __Pyx_CyFunction_NewEx(&__pyx_mdef_4lupa_5_lupa_9FastRLock_15__reduce_cython__, __Pyx_CYFUNCTION_CCLASS, __pyx_n_s_FastRLock___reduce_cython, NULL, __pyx_n_s_lupa__lupa, __pyx_d, ((PyObject *)__pyx_codeobj__56)); if (unlikely(!__pyx_t_7)) __PYX_ERR(2, 1, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); if (PyDict_SetItem(__pyx_d, __pyx_n_s_reduce_cython, __pyx_t_7) < 0) __PYX_ERR(2, 1, __pyx_L1_error) __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; /* "(tree fragment)":3 * def __reduce_cython__(self): * raise TypeError("no default __reduce__ due to non-trivial __cinit__") * def __setstate_cython__(self, __pyx_state): # <<<<<<<<<<<<<< * raise TypeError("no default __reduce__ due to non-trivial __cinit__") */ __pyx_t_7 = __Pyx_CyFunction_NewEx(&__pyx_mdef_4lupa_5_lupa_9FastRLock_17__setstate_cython__, __Pyx_CYFUNCTION_CCLASS, __pyx_n_s_FastRLock___setstate_cython, NULL, __pyx_n_s_lupa__lupa, __pyx_d, ((PyObject *)__pyx_codeobj__58)); if (unlikely(!__pyx_t_7)) __PYX_ERR(2, 3, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); if (PyDict_SetItem(__pyx_d, __pyx_n_s_setstate_cython, __pyx_t_7) < 0) __PYX_ERR(2, 3, __pyx_L1_error) __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; /* "lupa/_lupa.pyx":65 * * * class LuaError(Exception): # <<<<<<<<<<<<<< * """Base class for errors in the Lua runtime. * """ */ __pyx_t_7 = PyTuple_New(1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 65, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __Pyx_INCREF(((PyObject *)(&((PyTypeObject*)PyExc_Exception)[0]))); __Pyx_GIVEREF(((PyObject *)(&((PyTypeObject*)PyExc_Exception)[0]))); PyTuple_SET_ITEM(__pyx_t_7, 0, ((PyObject *)(&((PyTypeObject*)PyExc_Exception)[0]))); __pyx_t_1 = __Pyx_CalculateMetaclass(NULL, __pyx_t_7); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 65, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_2 = __Pyx_Py3MetaclassPrepare(__pyx_t_1, __pyx_t_7, __pyx_n_s_LuaError, __pyx_n_s_LuaError, (PyObject *) NULL, __pyx_n_s_lupa__lupa, __pyx_kp_s_Base_class_for_errors_in_the_Lua); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 65, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_8 = __Pyx_Py3ClassCreate(__pyx_t_1, __pyx_n_s_LuaError, __pyx_t_7, __pyx_t_2, NULL, 0, 1); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 65, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); if (PyDict_SetItem(__pyx_d, __pyx_n_s_LuaError, __pyx_t_8) < 0) __PYX_ERR(0, 65, __pyx_L1_error) __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; /* "lupa/_lupa.pyx":70 * * * class LuaSyntaxError(LuaError): # <<<<<<<<<<<<<< * """Syntax error in Lua code. * """ */ __pyx_t_7 = __Pyx_GetModuleGlobalName(__pyx_n_s_LuaError); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 70, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 70, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_GIVEREF(__pyx_t_7); PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_7); __pyx_t_7 = 0; __pyx_t_7 = __Pyx_CalculateMetaclass(NULL, __pyx_t_1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 70, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __pyx_t_2 = __Pyx_Py3MetaclassPrepare(__pyx_t_7, __pyx_t_1, __pyx_n_s_LuaSyntaxError, __pyx_n_s_LuaSyntaxError, (PyObject *) NULL, __pyx_n_s_lupa__lupa, __pyx_kp_s_Syntax_error_in_Lua_code); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 70, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_8 = __Pyx_Py3ClassCreate(__pyx_t_7, __pyx_n_s_LuaSyntaxError, __pyx_t_1, __pyx_t_2, NULL, 0, 1); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 70, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); if (PyDict_SetItem(__pyx_d, __pyx_n_s_LuaSyntaxError, __pyx_t_8) < 0) __PYX_ERR(0, 70, __pyx_L1_error) __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; /* "lupa/_lupa.pyx":75 * * * def lua_type(obj): # <<<<<<<<<<<<<< * """ * Return the Lua type name of a wrapped object as string, as provided */ __pyx_t_1 = __Pyx_CyFunction_NewEx(&__pyx_mdef_4lupa_5_lupa_1lua_type, 0, __pyx_n_s_lua_type, NULL, __pyx_n_s_lupa__lupa, __pyx_d, ((PyObject *)__pyx_codeobj__60)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 75, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); if (PyDict_SetItem(__pyx_d, __pyx_n_s_lua_type, __pyx_t_1) < 0) __PYX_ERR(0, 75, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; /* "lupa/_lupa.pyx":248 * return 0 * * def eval(self, lua_code, *args): # <<<<<<<<<<<<<< * """Evaluate a Lua expression passed in a string. * """ */ __pyx_t_1 = __Pyx_CyFunction_NewEx(&__pyx_mdef_4lupa_5_lupa_10LuaRuntime_5eval, __Pyx_CYFUNCTION_CCLASS, __pyx_n_s_LuaRuntime_eval, NULL, __pyx_n_s_lupa__lupa, __pyx_d, ((PyObject *)__pyx_codeobj__62)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 248, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); if (PyDict_SetItem((PyObject *)__pyx_ptype_4lupa_5_lupa_LuaRuntime->tp_dict, __pyx_n_s_eval, __pyx_t_1) < 0) __PYX_ERR(0, 248, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; PyType_Modified(__pyx_ptype_4lupa_5_lupa_LuaRuntime); /* "lupa/_lupa.pyx":256 * return run_lua(self, b'return ' + lua_code, args) * * def execute(self, lua_code, *args): # <<<<<<<<<<<<<< * """Execute a Lua program passed in a string. * """ */ __pyx_t_1 = __Pyx_CyFunction_NewEx(&__pyx_mdef_4lupa_5_lupa_10LuaRuntime_7execute, __Pyx_CYFUNCTION_CCLASS, __pyx_n_s_LuaRuntime_execute, NULL, __pyx_n_s_lupa__lupa, __pyx_d, ((PyObject *)__pyx_codeobj__64)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 256, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); if (PyDict_SetItem((PyObject *)__pyx_ptype_4lupa_5_lupa_LuaRuntime->tp_dict, __pyx_n_s_execute, __pyx_t_1) < 0) __PYX_ERR(0, 256, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; PyType_Modified(__pyx_ptype_4lupa_5_lupa_LuaRuntime); /* "lupa/_lupa.pyx":264 * return run_lua(self, lua_code, args) * * def compile(self, lua_code): # <<<<<<<<<<<<<< * """Compile a Lua program into a callable Lua function. * """ */ __pyx_t_1 = __Pyx_CyFunction_NewEx(&__pyx_mdef_4lupa_5_lupa_10LuaRuntime_9compile, __Pyx_CYFUNCTION_CCLASS, __pyx_n_s_LuaRuntime_compile, NULL, __pyx_n_s_lupa__lupa, __pyx_d, ((PyObject *)__pyx_codeobj__66)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 264, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); if (PyDict_SetItem((PyObject *)__pyx_ptype_4lupa_5_lupa_LuaRuntime->tp_dict, __pyx_n_s_compile, __pyx_t_1) < 0) __PYX_ERR(0, 264, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; PyType_Modified(__pyx_ptype_4lupa_5_lupa_LuaRuntime); /* "lupa/_lupa.pyx":286 * unlock_runtime(self) * * def require(self, modulename): # <<<<<<<<<<<<<< * """Load a Lua library into the runtime. * """ */ __pyx_t_1 = __Pyx_CyFunction_NewEx(&__pyx_mdef_4lupa_5_lupa_10LuaRuntime_11require, __Pyx_CYFUNCTION_CCLASS, __pyx_n_s_LuaRuntime_require, NULL, __pyx_n_s_lupa__lupa, __pyx_d, ((PyObject *)__pyx_codeobj__68)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 286, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); if (PyDict_SetItem((PyObject *)__pyx_ptype_4lupa_5_lupa_LuaRuntime->tp_dict, __pyx_n_s_require, __pyx_t_1) < 0) __PYX_ERR(0, 286, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; PyType_Modified(__pyx_ptype_4lupa_5_lupa_LuaRuntime); /* "lupa/_lupa.pyx":304 * unlock_runtime(self) * * def globals(self): # <<<<<<<<<<<<<< * """Return the globals defined in this Lua runtime as a Lua * table. */ __pyx_t_1 = __Pyx_CyFunction_NewEx(&__pyx_mdef_4lupa_5_lupa_10LuaRuntime_13globals, __Pyx_CYFUNCTION_CCLASS, __pyx_n_s_LuaRuntime_globals, NULL, __pyx_n_s_lupa__lupa, __pyx_d, ((PyObject *)__pyx_codeobj__70)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 304, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); if (PyDict_SetItem((PyObject *)__pyx_ptype_4lupa_5_lupa_LuaRuntime->tp_dict, __pyx_n_s_globals, __pyx_t_1) < 0) __PYX_ERR(0, 304, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; PyType_Modified(__pyx_ptype_4lupa_5_lupa_LuaRuntime); /* "lupa/_lupa.pyx":321 * unlock_runtime(self) * * def table(self, *items, **kwargs): # <<<<<<<<<<<<<< * """Create a new table with the provided items. Positional * arguments are placed in the table in order, keyword arguments */ __pyx_t_1 = __Pyx_CyFunction_NewEx(&__pyx_mdef_4lupa_5_lupa_10LuaRuntime_15table, __Pyx_CYFUNCTION_CCLASS, __pyx_n_s_LuaRuntime_table, NULL, __pyx_n_s_lupa__lupa, __pyx_d, ((PyObject *)__pyx_codeobj__72)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 321, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); if (PyDict_SetItem((PyObject *)__pyx_ptype_4lupa_5_lupa_LuaRuntime->tp_dict, __pyx_n_s_table, __pyx_t_1) < 0) __PYX_ERR(0, 321, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; PyType_Modified(__pyx_ptype_4lupa_5_lupa_LuaRuntime); /* "lupa/_lupa.pyx":328 * return self.table_from(items, kwargs) * * def table_from(self, *args): # <<<<<<<<<<<<<< * """Create a new table from Python mapping or iterable. * */ __pyx_t_1 = __Pyx_CyFunction_NewEx(&__pyx_mdef_4lupa_5_lupa_10LuaRuntime_17table_from, __Pyx_CYFUNCTION_CCLASS, __pyx_n_s_LuaRuntime_table_from, NULL, __pyx_n_s_lupa__lupa, __pyx_d, ((PyObject *)__pyx_codeobj__74)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 328, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); if (PyDict_SetItem((PyObject *)__pyx_ptype_4lupa_5_lupa_LuaRuntime->tp_dict, __pyx_n_s_table_from, __pyx_t_1) < 0) __PYX_ERR(0, 328, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; PyType_Modified(__pyx_ptype_4lupa_5_lupa_LuaRuntime); /* "(tree fragment)":1 * def __reduce_cython__(self): # <<<<<<<<<<<<<< * raise TypeError("no default __reduce__ due to non-trivial __cinit__") * def __setstate_cython__(self, __pyx_state): */ __pyx_t_1 = __Pyx_CyFunction_NewEx(&__pyx_mdef_4lupa_5_lupa_10LuaRuntime_19__reduce_cython__, __Pyx_CYFUNCTION_CCLASS, __pyx_n_s_LuaRuntime___reduce_cython, NULL, __pyx_n_s_lupa__lupa, __pyx_d, ((PyObject *)__pyx_codeobj__76)); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 1, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); if (PyDict_SetItem(__pyx_d, __pyx_n_s_reduce_cython, __pyx_t_1) < 0) __PYX_ERR(2, 1, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; /* "(tree fragment)":3 * def __reduce_cython__(self): * raise TypeError("no default __reduce__ due to non-trivial __cinit__") * def __setstate_cython__(self, __pyx_state): # <<<<<<<<<<<<<< * raise TypeError("no default __reduce__ due to non-trivial __cinit__") */ __pyx_t_1 = __Pyx_CyFunction_NewEx(&__pyx_mdef_4lupa_5_lupa_10LuaRuntime_21__setstate_cython__, __Pyx_CYFUNCTION_CCLASS, __pyx_n_s_LuaRuntime___setstate_cython, NULL, __pyx_n_s_lupa__lupa, __pyx_d, ((PyObject *)__pyx_codeobj__78)); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 3, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); if (PyDict_SetItem(__pyx_d, __pyx_n_s_setstate_cython, __pyx_t_1) < 0) __PYX_ERR(2, 3, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; /* "lupa/_lupa.pyx":416 * # from Lua scripts * * def unpacks_lua_table(func): # <<<<<<<<<<<<<< * """ * A decorator to make the decorated function receive kwargs */ __pyx_t_1 = __Pyx_CyFunction_NewEx(&__pyx_mdef_4lupa_5_lupa_3unpacks_lua_table, 0, __pyx_n_s_unpacks_lua_table, NULL, __pyx_n_s_lupa__lupa, __pyx_d, ((PyObject *)__pyx_codeobj__80)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 416, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); if (PyDict_SetItem(__pyx_d, __pyx_n_s_unpacks_lua_table, __pyx_t_1) < 0) __PYX_ERR(0, 416, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; /* "lupa/_lupa.pyx":442 * * * def unpacks_lua_table_method(meth): # <<<<<<<<<<<<<< * """ * This is :func:`unpacks_lua_table` for methods */ __pyx_t_1 = __Pyx_CyFunction_NewEx(&__pyx_mdef_4lupa_5_lupa_5unpacks_lua_table_method, 0, __pyx_n_s_unpacks_lua_table_method, NULL, __pyx_n_s_lupa__lupa, __pyx_d, ((PyObject *)__pyx_codeobj__82)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 442, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); if (PyDict_SetItem(__pyx_d, __pyx_n_s_unpacks_lua_table_method, __pyx_t_1) < 0) __PYX_ERR(0, 442, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; /* "(tree fragment)":1 * def __reduce_cython__(self): # <<<<<<<<<<<<<< * raise TypeError("self._state cannot be converted to a Python object for pickling") * def __setstate_cython__(self, __pyx_state): */ __pyx_t_1 = __Pyx_CyFunction_NewEx(&__pyx_mdef_4lupa_5_lupa_10_LuaObject_21__reduce_cython__, __Pyx_CYFUNCTION_CCLASS, __pyx_n_s_LuaObject___reduce_cython, NULL, __pyx_n_s_lupa__lupa, __pyx_d, ((PyObject *)__pyx_codeobj__84)); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 1, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); if (PyDict_SetItem(__pyx_d, __pyx_n_s_reduce_cython, __pyx_t_1) < 0) __PYX_ERR(2, 1, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; /* "(tree fragment)":3 * def __reduce_cython__(self): * raise TypeError("self._state cannot be converted to a Python object for pickling") * def __setstate_cython__(self, __pyx_state): # <<<<<<<<<<<<<< * raise TypeError("self._state cannot be converted to a Python object for pickling") */ __pyx_t_1 = __Pyx_CyFunction_NewEx(&__pyx_mdef_4lupa_5_lupa_10_LuaObject_23__setstate_cython__, __Pyx_CYFUNCTION_CCLASS, __pyx_n_s_LuaObject___setstate_cython, NULL, __pyx_n_s_lupa__lupa, __pyx_d, ((PyObject *)__pyx_codeobj__86)); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 3, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); if (PyDict_SetItem(__pyx_d, __pyx_n_s_setstate_cython, __pyx_t_1) < 0) __PYX_ERR(2, 3, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; /* "lupa/_lupa.pyx":690 * return _LuaIter(self, KEYS) * * def keys(self): # <<<<<<<<<<<<<< * """Returns an iterator over the keys of a table that this * object represents. Same as iter(obj). */ __pyx_t_1 = __Pyx_CyFunction_NewEx(&__pyx_mdef_4lupa_5_lupa_9_LuaTable_3keys, __Pyx_CYFUNCTION_CCLASS, __pyx_n_s_LuaTable_keys, NULL, __pyx_n_s_lupa__lupa, __pyx_d, ((PyObject *)__pyx_codeobj__88)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 690, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); if (PyDict_SetItem((PyObject *)__pyx_ptype_4lupa_5_lupa__LuaTable->tp_dict, __pyx_n_s_keys, __pyx_t_1) < 0) __PYX_ERR(0, 690, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; PyType_Modified(__pyx_ptype_4lupa_5_lupa__LuaTable); /* "lupa/_lupa.pyx":696 * return _LuaIter(self, KEYS) * * def values(self): # <<<<<<<<<<<<<< * """Returns an iterator over the values of a table that this * object represents. */ __pyx_t_1 = __Pyx_CyFunction_NewEx(&__pyx_mdef_4lupa_5_lupa_9_LuaTable_5values, __Pyx_CYFUNCTION_CCLASS, __pyx_n_s_LuaTable_values, NULL, __pyx_n_s_lupa__lupa, __pyx_d, ((PyObject *)__pyx_codeobj__90)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 696, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); if (PyDict_SetItem((PyObject *)__pyx_ptype_4lupa_5_lupa__LuaTable->tp_dict, __pyx_n_s_values, __pyx_t_1) < 0) __PYX_ERR(0, 696, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; PyType_Modified(__pyx_ptype_4lupa_5_lupa__LuaTable); /* "lupa/_lupa.pyx":702 * return _LuaIter(self, VALUES) * * def items(self): # <<<<<<<<<<<<<< * """Returns an iterator over the key-value pairs of a table * that this object represents. */ __pyx_t_1 = __Pyx_CyFunction_NewEx(&__pyx_mdef_4lupa_5_lupa_9_LuaTable_7items, __Pyx_CYFUNCTION_CCLASS, __pyx_n_s_LuaTable_items, NULL, __pyx_n_s_lupa__lupa, __pyx_d, ((PyObject *)__pyx_codeobj__92)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 702, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); if (PyDict_SetItem((PyObject *)__pyx_ptype_4lupa_5_lupa__LuaTable->tp_dict, __pyx_n_s_items, __pyx_t_1) < 0) __PYX_ERR(0, 702, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; PyType_Modified(__pyx_ptype_4lupa_5_lupa__LuaTable); /* "(tree fragment)":1 * def __reduce_cython__(self): # <<<<<<<<<<<<<< * raise TypeError("self._state cannot be converted to a Python object for pickling") * def __setstate_cython__(self, __pyx_state): */ __pyx_t_1 = __Pyx_CyFunction_NewEx(&__pyx_mdef_4lupa_5_lupa_9_LuaTable_17__reduce_cython__, __Pyx_CYFUNCTION_CCLASS, __pyx_n_s_LuaTable___reduce_cython, NULL, __pyx_n_s_lupa__lupa, __pyx_d, ((PyObject *)__pyx_codeobj__94)); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 1, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); if (PyDict_SetItem(__pyx_d, __pyx_n_s_reduce_cython, __pyx_t_1) < 0) __PYX_ERR(2, 1, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; /* "(tree fragment)":3 * def __reduce_cython__(self): * raise TypeError("self._state cannot be converted to a Python object for pickling") * def __setstate_cython__(self, __pyx_state): # <<<<<<<<<<<<<< * raise TypeError("self._state cannot be converted to a Python object for pickling") */ __pyx_t_1 = __Pyx_CyFunction_NewEx(&__pyx_mdef_4lupa_5_lupa_9_LuaTable_19__setstate_cython__, __Pyx_CYFUNCTION_CCLASS, __pyx_n_s_LuaTable___setstate_cython, NULL, __pyx_n_s_lupa__lupa, __pyx_d, ((PyObject *)__pyx_codeobj__96)); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 3, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); if (PyDict_SetItem(__pyx_d, __pyx_n_s_setstate_cython, __pyx_t_1) < 0) __PYX_ERR(2, 3, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; /* "lupa/_lupa.pyx":780 * """A Lua function (which may become a coroutine). * """ * def coroutine(self, *args): # <<<<<<<<<<<<<< * """Create a Lua coroutine from a Lua function and call it with * the passed parameters to start it up. */ __pyx_t_1 = __Pyx_CyFunction_NewEx(&__pyx_mdef_4lupa_5_lupa_12_LuaFunction_1coroutine, __Pyx_CYFUNCTION_CCLASS, __pyx_n_s_LuaFunction_coroutine, NULL, __pyx_n_s_lupa__lupa, __pyx_d, ((PyObject *)__pyx_codeobj__98)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 780, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); if (PyDict_SetItem((PyObject *)__pyx_ptype_4lupa_5_lupa__LuaFunction->tp_dict, __pyx_n_s_coroutine, __pyx_t_1) < 0) __PYX_ERR(0, 780, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; PyType_Modified(__pyx_ptype_4lupa_5_lupa__LuaFunction); /* "(tree fragment)":1 * def __reduce_cython__(self): # <<<<<<<<<<<<<< * raise TypeError("self._state cannot be converted to a Python object for pickling") * def __setstate_cython__(self, __pyx_state): */ __pyx_t_1 = __Pyx_CyFunction_NewEx(&__pyx_mdef_4lupa_5_lupa_12_LuaFunction_3__reduce_cython__, __Pyx_CYFUNCTION_CCLASS, __pyx_n_s_LuaFunction___reduce_cython, NULL, __pyx_n_s_lupa__lupa, __pyx_d, ((PyObject *)__pyx_codeobj__100)); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 1, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); if (PyDict_SetItem(__pyx_d, __pyx_n_s_reduce_cython, __pyx_t_1) < 0) __PYX_ERR(2, 1, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; /* "(tree fragment)":3 * def __reduce_cython__(self): * raise TypeError("self._state cannot be converted to a Python object for pickling") * def __setstate_cython__(self, __pyx_state): # <<<<<<<<<<<<<< * raise TypeError("self._state cannot be converted to a Python object for pickling") */ __pyx_t_1 = __Pyx_CyFunction_NewEx(&__pyx_mdef_4lupa_5_lupa_12_LuaFunction_5__setstate_cython__, __Pyx_CYFUNCTION_CCLASS, __pyx_n_s_LuaFunction___setstate_cython, NULL, __pyx_n_s_lupa__lupa, __pyx_d, ((PyObject *)__pyx_codeobj__102)); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 3, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); if (PyDict_SetItem(__pyx_d, __pyx_n_s_setstate_cython, __pyx_t_1) < 0) __PYX_ERR(2, 3, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; /* "(tree fragment)":1 * def __reduce_cython__(self): # <<<<<<<<<<<<<< * raise TypeError("self._state cannot be converted to a Python object for pickling") * def __setstate_cython__(self, __pyx_state): */ __pyx_t_1 = __Pyx_CyFunction_NewEx(&__pyx_mdef_4lupa_5_lupa_21_LuaCoroutineFunction_3__reduce_cython__, __Pyx_CYFUNCTION_CCLASS, __pyx_n_s_LuaCoroutineFunction___reduce_c, NULL, __pyx_n_s_lupa__lupa, __pyx_d, ((PyObject *)__pyx_codeobj__104)); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 1, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); if (PyDict_SetItem(__pyx_d, __pyx_n_s_reduce_cython, __pyx_t_1) < 0) __PYX_ERR(2, 1, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; /* "(tree fragment)":3 * def __reduce_cython__(self): * raise TypeError("self._state cannot be converted to a Python object for pickling") * def __setstate_cython__(self, __pyx_state): # <<<<<<<<<<<<<< * raise TypeError("self._state cannot be converted to a Python object for pickling") */ __pyx_t_1 = __Pyx_CyFunction_NewEx(&__pyx_mdef_4lupa_5_lupa_21_LuaCoroutineFunction_5__setstate_cython__, __Pyx_CYFUNCTION_CCLASS, __pyx_n_s_LuaCoroutineFunction___setstate, NULL, __pyx_n_s_lupa__lupa, __pyx_d, ((PyObject *)__pyx_codeobj__106)); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 3, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); if (PyDict_SetItem(__pyx_d, __pyx_n_s_setstate_cython, __pyx_t_1) < 0) __PYX_ERR(2, 3, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; /* "lupa/_lupa.pyx":846 * return resume_lua_thread(self, args) * * def send(self, value): # <<<<<<<<<<<<<< * """Send a value into the coroutine. If the value is a tuple, * send the unpacked elements. */ __pyx_t_1 = __Pyx_CyFunction_NewEx(&__pyx_mdef_4lupa_5_lupa_10_LuaThread_5send, __Pyx_CYFUNCTION_CCLASS, __pyx_n_s_LuaThread_send, NULL, __pyx_n_s_lupa__lupa, __pyx_d, ((PyObject *)__pyx_codeobj__108)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 846, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); if (PyDict_SetItem((PyObject *)__pyx_ptype_4lupa_5_lupa__LuaThread->tp_dict, __pyx_n_s_send, __pyx_t_1) < 0) __PYX_ERR(0, 846, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; PyType_Modified(__pyx_ptype_4lupa_5_lupa__LuaThread); /* "(tree fragment)":1 * def __reduce_cython__(self): # <<<<<<<<<<<<<< * raise TypeError("self._co_state,self._state cannot be converted to a Python object for pickling") * def __setstate_cython__(self, __pyx_state): */ __pyx_t_1 = __Pyx_CyFunction_NewEx(&__pyx_mdef_4lupa_5_lupa_10_LuaThread_9__reduce_cython__, __Pyx_CYFUNCTION_CCLASS, __pyx_n_s_LuaThread___reduce_cython, NULL, __pyx_n_s_lupa__lupa, __pyx_d, ((PyObject *)__pyx_codeobj__110)); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 1, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); if (PyDict_SetItem(__pyx_d, __pyx_n_s_reduce_cython, __pyx_t_1) < 0) __PYX_ERR(2, 1, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; /* "(tree fragment)":3 * def __reduce_cython__(self): * raise TypeError("self._co_state,self._state cannot be converted to a Python object for pickling") * def __setstate_cython__(self, __pyx_state): # <<<<<<<<<<<<<< * raise TypeError("self._co_state,self._state cannot be converted to a Python object for pickling") */ __pyx_t_1 = __Pyx_CyFunction_NewEx(&__pyx_mdef_4lupa_5_lupa_10_LuaThread_11__setstate_cython__, __Pyx_CYFUNCTION_CCLASS, __pyx_n_s_LuaThread___setstate_cython, NULL, __pyx_n_s_lupa__lupa, __pyx_d, ((PyObject *)__pyx_codeobj__112)); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 3, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); if (PyDict_SetItem(__pyx_d, __pyx_n_s_setstate_cython, __pyx_t_1) < 0) __PYX_ERR(2, 3, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; /* "(tree fragment)":1 * def __reduce_cython__(self): # <<<<<<<<<<<<<< * raise TypeError("no default __reduce__ due to non-trivial __cinit__") * def __setstate_cython__(self, __pyx_state): */ __pyx_t_1 = __Pyx_CyFunction_NewEx(&__pyx_mdef_4lupa_5_lupa_8_LuaIter_11__reduce_cython__, __Pyx_CYFUNCTION_CCLASS, __pyx_n_s_LuaIter___reduce_cython, NULL, __pyx_n_s_lupa__lupa, __pyx_d, ((PyObject *)__pyx_codeobj__114)); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 1, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); if (PyDict_SetItem(__pyx_d, __pyx_n_s_reduce_cython, __pyx_t_1) < 0) __PYX_ERR(2, 1, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; /* "(tree fragment)":3 * def __reduce_cython__(self): * raise TypeError("no default __reduce__ due to non-trivial __cinit__") * def __setstate_cython__(self, __pyx_state): # <<<<<<<<<<<<<< * raise TypeError("no default __reduce__ due to non-trivial __cinit__") */ __pyx_t_1 = __Pyx_CyFunction_NewEx(&__pyx_mdef_4lupa_5_lupa_8_LuaIter_13__setstate_cython__, __Pyx_CYFUNCTION_CCLASS, __pyx_n_s_LuaIter___setstate_cython, NULL, __pyx_n_s_lupa__lupa, __pyx_d, ((PyObject *)__pyx_codeobj__116)); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 3, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); if (PyDict_SetItem(__pyx_d, __pyx_n_s_setstate_cython, __pyx_t_1) < 0) __PYX_ERR(2, 3, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; /* "(tree fragment)":1 * def __reduce_cython__(self): # <<<<<<<<<<<<<< * raise TypeError("no default __reduce__ due to non-trivial __cinit__") * def __setstate_cython__(self, __pyx_state): */ __pyx_t_1 = __Pyx_CyFunction_NewEx(&__pyx_mdef_4lupa_5_lupa_18_PyProtocolWrapper_5__reduce_cython__, __Pyx_CYFUNCTION_CCLASS, __pyx_n_s_PyProtocolWrapper___reduce_cyth, NULL, __pyx_n_s_lupa__lupa, __pyx_d, ((PyObject *)__pyx_codeobj__118)); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 1, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); if (PyDict_SetItem(__pyx_d, __pyx_n_s_reduce_cython, __pyx_t_1) < 0) __PYX_ERR(2, 1, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; /* "(tree fragment)":3 * def __reduce_cython__(self): * raise TypeError("no default __reduce__ due to non-trivial __cinit__") * def __setstate_cython__(self, __pyx_state): # <<<<<<<<<<<<<< * raise TypeError("no default __reduce__ due to non-trivial __cinit__") */ __pyx_t_1 = __Pyx_CyFunction_NewEx(&__pyx_mdef_4lupa_5_lupa_18_PyProtocolWrapper_7__setstate_cython__, __Pyx_CYFUNCTION_CCLASS, __pyx_n_s_PyProtocolWrapper___setstate_cy, NULL, __pyx_n_s_lupa__lupa, __pyx_d, ((PyObject *)__pyx_codeobj__120)); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 3, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); if (PyDict_SetItem(__pyx_d, __pyx_n_s_setstate_cython, __pyx_t_1) < 0) __PYX_ERR(2, 3, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; /* "lupa/_lupa.pyx":1065 * * * def as_attrgetter(obj): # <<<<<<<<<<<<<< * cdef _PyProtocolWrapper wrap = _PyProtocolWrapper.__new__(_PyProtocolWrapper) * wrap._obj = obj */ __pyx_t_1 = __Pyx_CyFunction_NewEx(&__pyx_mdef_4lupa_5_lupa_7as_attrgetter, 0, __pyx_n_s_as_attrgetter, NULL, __pyx_n_s_lupa__lupa, __pyx_d, ((PyObject *)__pyx_codeobj__122)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1065, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); if (PyDict_SetItem(__pyx_d, __pyx_n_s_as_attrgetter, __pyx_t_1) < 0) __PYX_ERR(0, 1065, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; /* "lupa/_lupa.pyx":1071 * return wrap * * def as_itemgetter(obj): # <<<<<<<<<<<<<< * cdef _PyProtocolWrapper wrap = _PyProtocolWrapper.__new__(_PyProtocolWrapper) * wrap._obj = obj */ __pyx_t_1 = __Pyx_CyFunction_NewEx(&__pyx_mdef_4lupa_5_lupa_9as_itemgetter, 0, __pyx_n_s_as_itemgetter, NULL, __pyx_n_s_lupa__lupa, __pyx_d, ((PyObject *)__pyx_codeobj__124)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1071, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); if (PyDict_SetItem(__pyx_d, __pyx_n_s_as_itemgetter, __pyx_t_1) < 0) __PYX_ERR(0, 1071, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; /* "lupa/_lupa.pyx":1597 * * cdef lua.luaL_Reg *py_object_lib = [ * lua.luaL_Reg(name = "__call", func = py_object_call), # <<<<<<<<<<<<<< * lua.luaL_Reg(name = "__index", func = py_object_getindex), * lua.luaL_Reg(name = "__newindex", func = py_object_setindex), */ __pyx_t_9.name = ((char *)"__call"); __pyx_t_9.func = ((lua_CFunction)__pyx_f_4lupa_5_lupa_py_object_call); /* "lupa/_lupa.pyx":1598 * cdef lua.luaL_Reg *py_object_lib = [ * lua.luaL_Reg(name = "__call", func = py_object_call), * lua.luaL_Reg(name = "__index", func = py_object_getindex), # <<<<<<<<<<<<<< * lua.luaL_Reg(name = "__newindex", func = py_object_setindex), * lua.luaL_Reg(name = "__tostring", func = py_object_str), */ __pyx_t_10.name = ((char *)"__index"); __pyx_t_10.func = ((lua_CFunction)__pyx_f_4lupa_5_lupa_py_object_getindex); /* "lupa/_lupa.pyx":1599 * lua.luaL_Reg(name = "__call", func = py_object_call), * lua.luaL_Reg(name = "__index", func = py_object_getindex), * lua.luaL_Reg(name = "__newindex", func = py_object_setindex), # <<<<<<<<<<<<<< * lua.luaL_Reg(name = "__tostring", func = py_object_str), * lua.luaL_Reg(name = "__gc", func = py_object_gc), */ __pyx_t_11.name = ((char *)"__newindex"); __pyx_t_11.func = ((lua_CFunction)__pyx_f_4lupa_5_lupa_py_object_setindex); /* "lupa/_lupa.pyx":1600 * lua.luaL_Reg(name = "__index", func = py_object_getindex), * lua.luaL_Reg(name = "__newindex", func = py_object_setindex), * lua.luaL_Reg(name = "__tostring", func = py_object_str), # <<<<<<<<<<<<<< * lua.luaL_Reg(name = "__gc", func = py_object_gc), * lua.luaL_Reg(name = NULL, func = NULL), */ __pyx_t_12.name = ((char *)"__tostring"); __pyx_t_12.func = ((lua_CFunction)__pyx_f_4lupa_5_lupa_py_object_str); /* "lupa/_lupa.pyx":1601 * lua.luaL_Reg(name = "__newindex", func = py_object_setindex), * lua.luaL_Reg(name = "__tostring", func = py_object_str), * lua.luaL_Reg(name = "__gc", func = py_object_gc), # <<<<<<<<<<<<<< * lua.luaL_Reg(name = NULL, func = NULL), * ] */ __pyx_t_13.name = ((char *)"__gc"); __pyx_t_13.func = ((lua_CFunction)__pyx_f_4lupa_5_lupa_py_object_gc); /* "lupa/_lupa.pyx":1602 * lua.luaL_Reg(name = "__tostring", func = py_object_str), * lua.luaL_Reg(name = "__gc", func = py_object_gc), * lua.luaL_Reg(name = NULL, func = NULL), # <<<<<<<<<<<<<< * ] * */ __pyx_t_14.name = NULL; __pyx_t_14.func = NULL; /* "lupa/_lupa.pyx":1596 * # special methods for Lua wrapped Python objects * * cdef lua.luaL_Reg *py_object_lib = [ # <<<<<<<<<<<<<< * lua.luaL_Reg(name = "__call", func = py_object_call), * lua.luaL_Reg(name = "__index", func = py_object_getindex), */ __pyx_t_15[0] = __pyx_t_9; __pyx_t_15[1] = __pyx_t_10; __pyx_t_15[2] = __pyx_t_11; __pyx_t_15[3] = __pyx_t_12; __pyx_t_15[4] = __pyx_t_13; __pyx_t_15[5] = __pyx_t_14; __pyx_v_4lupa_5_lupa_py_object_lib = __pyx_t_15; /* "lupa/_lupa.pyx":1759 * * cdef lua.luaL_Reg *py_lib = [ * lua.luaL_Reg(name = "as_attrgetter", func = py_as_attrgetter), # <<<<<<<<<<<<<< * lua.luaL_Reg(name = "as_itemgetter", func = py_as_itemgetter), * lua.luaL_Reg(name = "as_function", func = py_as_function), */ __pyx_t_14.name = ((char *)"as_attrgetter"); __pyx_t_14.func = ((lua_CFunction)__pyx_f_4lupa_5_lupa_py_as_attrgetter); /* "lupa/_lupa.pyx":1760 * cdef lua.luaL_Reg *py_lib = [ * lua.luaL_Reg(name = "as_attrgetter", func = py_as_attrgetter), * lua.luaL_Reg(name = "as_itemgetter", func = py_as_itemgetter), # <<<<<<<<<<<<<< * lua.luaL_Reg(name = "as_function", func = py_as_function), * lua.luaL_Reg(name = "iter", func = py_iter), */ __pyx_t_13.name = ((char *)"as_itemgetter"); __pyx_t_13.func = ((lua_CFunction)__pyx_f_4lupa_5_lupa_py_as_itemgetter); /* "lupa/_lupa.pyx":1761 * lua.luaL_Reg(name = "as_attrgetter", func = py_as_attrgetter), * lua.luaL_Reg(name = "as_itemgetter", func = py_as_itemgetter), * lua.luaL_Reg(name = "as_function", func = py_as_function), # <<<<<<<<<<<<<< * lua.luaL_Reg(name = "iter", func = py_iter), * lua.luaL_Reg(name = "iterex", func = py_iterex), */ __pyx_t_12.name = ((char *)"as_function"); __pyx_t_12.func = ((lua_CFunction)__pyx_f_4lupa_5_lupa_py_as_function); /* "lupa/_lupa.pyx":1762 * lua.luaL_Reg(name = "as_itemgetter", func = py_as_itemgetter), * lua.luaL_Reg(name = "as_function", func = py_as_function), * lua.luaL_Reg(name = "iter", func = py_iter), # <<<<<<<<<<<<<< * lua.luaL_Reg(name = "iterex", func = py_iterex), * lua.luaL_Reg(name = "enumerate", func = py_enumerate), */ __pyx_t_11.name = ((char *)"iter"); __pyx_t_11.func = ((lua_CFunction)__pyx_f_4lupa_5_lupa_py_iter); /* "lupa/_lupa.pyx":1763 * lua.luaL_Reg(name = "as_function", func = py_as_function), * lua.luaL_Reg(name = "iter", func = py_iter), * lua.luaL_Reg(name = "iterex", func = py_iterex), # <<<<<<<<<<<<<< * lua.luaL_Reg(name = "enumerate", func = py_enumerate), * lua.luaL_Reg(name = NULL, func = NULL), */ __pyx_t_10.name = ((char *)"iterex"); __pyx_t_10.func = ((lua_CFunction)__pyx_f_4lupa_5_lupa_py_iterex); /* "lupa/_lupa.pyx":1764 * lua.luaL_Reg(name = "iter", func = py_iter), * lua.luaL_Reg(name = "iterex", func = py_iterex), * lua.luaL_Reg(name = "enumerate", func = py_enumerate), # <<<<<<<<<<<<<< * lua.luaL_Reg(name = NULL, func = NULL), * ] */ __pyx_t_9.name = ((char *)"enumerate"); __pyx_t_9.func = ((lua_CFunction)__pyx_f_4lupa_5_lupa_py_enumerate); /* "lupa/_lupa.pyx":1765 * lua.luaL_Reg(name = "iterex", func = py_iterex), * lua.luaL_Reg(name = "enumerate", func = py_enumerate), * lua.luaL_Reg(name = NULL, func = NULL), # <<<<<<<<<<<<<< * ] * */ __pyx_t_16.name = NULL; __pyx_t_16.func = NULL; /* "lupa/_lupa.pyx":1758 * # 'python' module functions in Lua * * cdef lua.luaL_Reg *py_lib = [ # <<<<<<<<<<<<<< * lua.luaL_Reg(name = "as_attrgetter", func = py_as_attrgetter), * lua.luaL_Reg(name = "as_itemgetter", func = py_as_itemgetter), */ __pyx_t_17[0] = __pyx_t_14; __pyx_t_17[1] = __pyx_t_13; __pyx_t_17[2] = __pyx_t_12; __pyx_t_17[3] = __pyx_t_11; __pyx_t_17[4] = __pyx_t_10; __pyx_t_17[5] = __pyx_t_9; __pyx_t_17[6] = __pyx_t_16; __pyx_v_4lupa_5_lupa_py_lib = __pyx_t_17; /* "lupa/_lupa.pyx":1 * # cython: embedsignature=True, binding=True # <<<<<<<<<<<<<< * * """ */ __pyx_t_1 = __Pyx_PyDict_NewPresized(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); if (PyDict_SetItem(__pyx_d, __pyx_n_s_test, __pyx_t_1) < 0) __PYX_ERR(0, 1, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; /*--- Wrapped vars code ---*/ goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_2); __Pyx_XDECREF(__pyx_t_7); __Pyx_XDECREF(__pyx_t_8); if (__pyx_m) { if (__pyx_d) { __Pyx_AddTraceback("init lupa._lupa", 0, __pyx_lineno, __pyx_filename); } Py_DECREF(__pyx_m); __pyx_m = 0; } else if (!PyErr_Occurred()) { PyErr_SetString(PyExc_ImportError, "init lupa._lupa"); } __pyx_L0:; __Pyx_RefNannyFinishContext(); #if CYTHON_PEP489_MULTI_PHASE_INIT return (__pyx_m != NULL) ? 0 : -1; #elif PY_MAJOR_VERSION >= 3 return __pyx_m; #else return; #endif } /* --- Runtime support code --- */ /* Refnanny */ #if CYTHON_REFNANNY static __Pyx_RefNannyAPIStruct *__Pyx_RefNannyImportAPI(const char *modname) { PyObject *m = NULL, *p = NULL; void *r = NULL; m = PyImport_ImportModule((char *)modname); if (!m) goto end; p = PyObject_GetAttrString(m, (char *)"RefNannyAPI"); if (!p) goto end; r = PyLong_AsVoidPtr(p); end: Py_XDECREF(p); Py_XDECREF(m); return (__Pyx_RefNannyAPIStruct *)r; } #endif /* GetBuiltinName */ static PyObject *__Pyx_GetBuiltinName(PyObject *name) { PyObject* result = __Pyx_PyObject_GetAttrStr(__pyx_b, name); if (unlikely(!result)) { PyErr_Format(PyExc_NameError, #if PY_MAJOR_VERSION >= 3 "name '%U' is not defined", name); #else "name '%.200s' is not defined", PyString_AS_STRING(name)); #endif } return result; } /* RaiseArgTupleInvalid */ static void __Pyx_RaiseArgtupleInvalid( const char* func_name, int exact, Py_ssize_t num_min, Py_ssize_t num_max, Py_ssize_t num_found) { Py_ssize_t num_expected; const char *more_or_less; if (num_found < num_min) { num_expected = num_min; more_or_less = "at least"; } else { num_expected = num_max; more_or_less = "at most"; } if (exact) { more_or_less = "exactly"; } PyErr_Format(PyExc_TypeError, "%.200s() takes %.8s %" CYTHON_FORMAT_SSIZE_T "d positional argument%.1s (%" CYTHON_FORMAT_SSIZE_T "d given)", func_name, more_or_less, num_expected, (num_expected == 1) ? "" : "s", num_found); } /* KeywordStringCheck */ static int __Pyx_CheckKeywordStrings( PyObject *kwdict, const char* function_name, int kw_allowed) { PyObject* key = 0; Py_ssize_t pos = 0; #if CYTHON_COMPILING_IN_PYPY if (!kw_allowed && PyDict_Next(kwdict, &pos, &key, 0)) goto invalid_keyword; return 1; #else while (PyDict_Next(kwdict, &pos, &key, 0)) { #if PY_MAJOR_VERSION < 3 if (unlikely(!PyString_Check(key))) #endif if (unlikely(!PyUnicode_Check(key))) goto invalid_keyword_type; } if ((!kw_allowed) && unlikely(key)) goto invalid_keyword; return 1; invalid_keyword_type: PyErr_Format(PyExc_TypeError, "%.200s() keywords must be strings", function_name); return 0; #endif invalid_keyword: PyErr_Format(PyExc_TypeError, #if PY_MAJOR_VERSION < 3 "%.200s() got an unexpected keyword argument '%.200s'", function_name, PyString_AsString(key)); #else "%s() got an unexpected keyword argument '%U'", function_name, key); #endif return 0; } /* RaiseDoubleKeywords */ static void __Pyx_RaiseDoubleKeywordsError( const char* func_name, PyObject* kw_name) { PyErr_Format(PyExc_TypeError, #if PY_MAJOR_VERSION >= 3 "%s() got multiple values for keyword argument '%U'", func_name, kw_name); #else "%s() got multiple values for keyword argument '%s'", func_name, PyString_AsString(kw_name)); #endif } /* ParseKeywords */ static int __Pyx_ParseOptionalKeywords( PyObject *kwds, PyObject **argnames[], PyObject *kwds2, PyObject *values[], Py_ssize_t num_pos_args, const char* function_name) { PyObject *key = 0, *value = 0; Py_ssize_t pos = 0; PyObject*** name; PyObject*** first_kw_arg = argnames + num_pos_args; while (PyDict_Next(kwds, &pos, &key, &value)) { name = first_kw_arg; while (*name && (**name != key)) name++; if (*name) { values[name-argnames] = value; continue; } name = first_kw_arg; #if PY_MAJOR_VERSION < 3 if (likely(PyString_CheckExact(key)) || likely(PyString_Check(key))) { while (*name) { if ((CYTHON_COMPILING_IN_PYPY || PyString_GET_SIZE(**name) == PyString_GET_SIZE(key)) && _PyString_Eq(**name, key)) { values[name-argnames] = value; break; } name++; } if (*name) continue; else { PyObject*** argname = argnames; while (argname != first_kw_arg) { if ((**argname == key) || ( (CYTHON_COMPILING_IN_PYPY || PyString_GET_SIZE(**argname) == PyString_GET_SIZE(key)) && _PyString_Eq(**argname, key))) { goto arg_passed_twice; } argname++; } } } else #endif if (likely(PyUnicode_Check(key))) { while (*name) { int cmp = (**name == key) ? 0 : #if !CYTHON_COMPILING_IN_PYPY && PY_MAJOR_VERSION >= 3 (PyUnicode_GET_SIZE(**name) != PyUnicode_GET_SIZE(key)) ? 1 : #endif PyUnicode_Compare(**name, key); if (cmp < 0 && unlikely(PyErr_Occurred())) goto bad; if (cmp == 0) { values[name-argnames] = value; break; } name++; } if (*name) continue; else { PyObject*** argname = argnames; while (argname != first_kw_arg) { int cmp = (**argname == key) ? 0 : #if !CYTHON_COMPILING_IN_PYPY && PY_MAJOR_VERSION >= 3 (PyUnicode_GET_SIZE(**argname) != PyUnicode_GET_SIZE(key)) ? 1 : #endif PyUnicode_Compare(**argname, key); if (cmp < 0 && unlikely(PyErr_Occurred())) goto bad; if (cmp == 0) goto arg_passed_twice; argname++; } } } else goto invalid_keyword_type; if (kwds2) { if (unlikely(PyDict_SetItem(kwds2, key, value))) goto bad; } else { goto invalid_keyword; } } return 0; arg_passed_twice: __Pyx_RaiseDoubleKeywordsError(function_name, key); goto bad; invalid_keyword_type: PyErr_Format(PyExc_TypeError, "%.200s() keywords must be strings", function_name); goto bad; invalid_keyword: PyErr_Format(PyExc_TypeError, #if PY_MAJOR_VERSION < 3 "%.200s() got an unexpected keyword argument '%.200s'", function_name, PyString_AsString(key)); #else "%s() got an unexpected keyword argument '%U'", function_name, key); #endif bad: return -1; } /* PyObjectCall */ #if CYTHON_COMPILING_IN_CPYTHON static CYTHON_INLINE PyObject* __Pyx_PyObject_Call(PyObject *func, PyObject *arg, PyObject *kw) { PyObject *result; ternaryfunc call = func->ob_type->tp_call; if (unlikely(!call)) return PyObject_Call(func, arg, kw); if (unlikely(Py_EnterRecursiveCall((char*)" while calling a Python object"))) return NULL; result = (*call)(func, arg, kw); Py_LeaveRecursiveCall(); if (unlikely(!result) && unlikely(!PyErr_Occurred())) { PyErr_SetString( PyExc_SystemError, "NULL result without error in PyObject_Call"); } return result; } #endif /* PyErrFetchRestore */ #if CYTHON_FAST_THREAD_STATE static CYTHON_INLINE void __Pyx_ErrRestoreInState(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb) { PyObject *tmp_type, *tmp_value, *tmp_tb; tmp_type = tstate->curexc_type; tmp_value = tstate->curexc_value; tmp_tb = tstate->curexc_traceback; tstate->curexc_type = type; tstate->curexc_value = value; tstate->curexc_traceback = tb; Py_XDECREF(tmp_type); Py_XDECREF(tmp_value); Py_XDECREF(tmp_tb); } static CYTHON_INLINE void __Pyx_ErrFetchInState(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb) { *type = tstate->curexc_type; *value = tstate->curexc_value; *tb = tstate->curexc_traceback; tstate->curexc_type = 0; tstate->curexc_value = 0; tstate->curexc_traceback = 0; } #endif /* RaiseException */ #if PY_MAJOR_VERSION < 3 static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, CYTHON_UNUSED PyObject *cause) { __Pyx_PyThreadState_declare Py_XINCREF(type); if (!value || value == Py_None) value = NULL; else Py_INCREF(value); if (!tb || tb == Py_None) tb = NULL; else { Py_INCREF(tb); if (!PyTraceBack_Check(tb)) { PyErr_SetString(PyExc_TypeError, "raise: arg 3 must be a traceback or None"); goto raise_error; } } if (PyType_Check(type)) { #if CYTHON_COMPILING_IN_PYPY if (!value) { Py_INCREF(Py_None); value = Py_None; } #endif PyErr_NormalizeException(&type, &value, &tb); } else { if (value) { PyErr_SetString(PyExc_TypeError, "instance exception may not have a separate value"); goto raise_error; } value = type; type = (PyObject*) Py_TYPE(type); Py_INCREF(type); if (!PyType_IsSubtype((PyTypeObject *)type, (PyTypeObject *)PyExc_BaseException)) { PyErr_SetString(PyExc_TypeError, "raise: exception class must be a subclass of BaseException"); goto raise_error; } } __Pyx_PyThreadState_assign __Pyx_ErrRestore(type, value, tb); return; raise_error: Py_XDECREF(value); Py_XDECREF(type); Py_XDECREF(tb); return; } #else static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, PyObject *cause) { PyObject* owned_instance = NULL; if (tb == Py_None) { tb = 0; } else if (tb && !PyTraceBack_Check(tb)) { PyErr_SetString(PyExc_TypeError, "raise: arg 3 must be a traceback or None"); goto bad; } if (value == Py_None) value = 0; if (PyExceptionInstance_Check(type)) { if (value) { PyErr_SetString(PyExc_TypeError, "instance exception may not have a separate value"); goto bad; } value = type; type = (PyObject*) Py_TYPE(value); } else if (PyExceptionClass_Check(type)) { PyObject *instance_class = NULL; if (value && PyExceptionInstance_Check(value)) { instance_class = (PyObject*) Py_TYPE(value); if (instance_class != type) { int is_subclass = PyObject_IsSubclass(instance_class, type); if (!is_subclass) { instance_class = NULL; } else if (unlikely(is_subclass == -1)) { goto bad; } else { type = instance_class; } } } if (!instance_class) { PyObject *args; if (!value) args = PyTuple_New(0); else if (PyTuple_Check(value)) { Py_INCREF(value); args = value; } else args = PyTuple_Pack(1, value); if (!args) goto bad; owned_instance = PyObject_Call(type, args, NULL); Py_DECREF(args); if (!owned_instance) goto bad; value = owned_instance; if (!PyExceptionInstance_Check(value)) { PyErr_Format(PyExc_TypeError, "calling %R should have returned an instance of " "BaseException, not %R", type, Py_TYPE(value)); goto bad; } } } else { PyErr_SetString(PyExc_TypeError, "raise: exception class must be a subclass of BaseException"); goto bad; } if (cause) { PyObject *fixed_cause; if (cause == Py_None) { fixed_cause = NULL; } else if (PyExceptionClass_Check(cause)) { fixed_cause = PyObject_CallObject(cause, NULL); if (fixed_cause == NULL) goto bad; } else if (PyExceptionInstance_Check(cause)) { fixed_cause = cause; Py_INCREF(fixed_cause); } else { PyErr_SetString(PyExc_TypeError, "exception causes must derive from " "BaseException"); goto bad; } PyException_SetCause(value, fixed_cause); } PyErr_SetObject(type, value); if (tb) { #if CYTHON_COMPILING_IN_PYPY PyObject *tmp_type, *tmp_value, *tmp_tb; PyErr_Fetch(&tmp_type, &tmp_value, &tmp_tb); Py_INCREF(tb); PyErr_Restore(tmp_type, tmp_value, tb); Py_XDECREF(tmp_tb); #else PyThreadState *tstate = __Pyx_PyThreadState_Current; PyObject* tmp_tb = tstate->curexc_traceback; if (tb != tmp_tb) { Py_INCREF(tb); tstate->curexc_traceback = tb; Py_XDECREF(tmp_tb); } #endif } bad: Py_XDECREF(owned_instance); return; } #endif /* decode_c_string */ static CYTHON_INLINE PyObject* __Pyx_decode_c_string( const char* cstring, Py_ssize_t start, Py_ssize_t stop, const char* encoding, const char* errors, PyObject* (*decode_func)(const char *s, Py_ssize_t size, const char *errors)) { Py_ssize_t length; if (unlikely((start < 0) | (stop < 0))) { size_t slen = strlen(cstring); if (unlikely(slen > (size_t) PY_SSIZE_T_MAX)) { PyErr_SetString(PyExc_OverflowError, "c-string too long to convert to Python"); return NULL; } length = (Py_ssize_t) slen; if (start < 0) { start += length; if (start < 0) start = 0; } if (stop < 0) stop += length; } length = stop - start; if (unlikely(length <= 0)) return PyUnicode_FromUnicode(NULL, 0); cstring += start; if (decode_func) { return decode_func(cstring, length, errors); } else { return PyUnicode_Decode(cstring, length, encoding, errors); } } /* GetException */ #if CYTHON_FAST_THREAD_STATE static int __Pyx__GetException(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb) { #else static int __Pyx_GetException(PyObject **type, PyObject **value, PyObject **tb) { #endif PyObject *local_type, *local_value, *local_tb; #if CYTHON_FAST_THREAD_STATE PyObject *tmp_type, *tmp_value, *tmp_tb; local_type = tstate->curexc_type; local_value = tstate->curexc_value; local_tb = tstate->curexc_traceback; tstate->curexc_type = 0; tstate->curexc_value = 0; tstate->curexc_traceback = 0; #else PyErr_Fetch(&local_type, &local_value, &local_tb); #endif PyErr_NormalizeException(&local_type, &local_value, &local_tb); #if CYTHON_FAST_THREAD_STATE if (unlikely(tstate->curexc_type)) #else if (unlikely(PyErr_Occurred())) #endif goto bad; #if PY_MAJOR_VERSION >= 3 if (local_tb) { if (unlikely(PyException_SetTraceback(local_value, local_tb) < 0)) goto bad; } #endif Py_XINCREF(local_tb); Py_XINCREF(local_type); Py_XINCREF(local_value); *type = local_type; *value = local_value; *tb = local_tb; #if CYTHON_FAST_THREAD_STATE #if PY_VERSION_HEX >= 0x030700A2 tmp_type = tstate->exc_state.exc_type; tmp_value = tstate->exc_state.exc_value; tmp_tb = tstate->exc_state.exc_traceback; tstate->exc_state.exc_type = local_type; tstate->exc_state.exc_value = local_value; tstate->exc_state.exc_traceback = local_tb; #else tmp_type = tstate->exc_type; tmp_value = tstate->exc_value; tmp_tb = tstate->exc_traceback; tstate->exc_type = local_type; tstate->exc_value = local_value; tstate->exc_traceback = local_tb; #endif Py_XDECREF(tmp_type); Py_XDECREF(tmp_value); Py_XDECREF(tmp_tb); #else PyErr_SetExcInfo(local_type, local_value, local_tb); #endif return 0; bad: *type = 0; *value = 0; *tb = 0; Py_XDECREF(local_type); Py_XDECREF(local_value); Py_XDECREF(local_tb); return -1; } /* SwapException */ #if CYTHON_FAST_THREAD_STATE static CYTHON_INLINE void __Pyx__ExceptionSwap(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb) { PyObject *tmp_type, *tmp_value, *tmp_tb; #if PY_VERSION_HEX >= 0x030700A2 tmp_type = tstate->exc_state.exc_type; tmp_value = tstate->exc_state.exc_value; tmp_tb = tstate->exc_state.exc_traceback; tstate->exc_state.exc_type = *type; tstate->exc_state.exc_value = *value; tstate->exc_state.exc_traceback = *tb; #else tmp_type = tstate->exc_type; tmp_value = tstate->exc_value; tmp_tb = tstate->exc_traceback; tstate->exc_type = *type; tstate->exc_value = *value; tstate->exc_traceback = *tb; #endif *type = tmp_type; *value = tmp_value; *tb = tmp_tb; } #else static CYTHON_INLINE void __Pyx_ExceptionSwap(PyObject **type, PyObject **value, PyObject **tb) { PyObject *tmp_type, *tmp_value, *tmp_tb; PyErr_GetExcInfo(&tmp_type, &tmp_value, &tmp_tb); PyErr_SetExcInfo(*type, *value, *tb); *type = tmp_type; *value = tmp_value; *tb = tmp_tb; } #endif /* SaveResetException */ #if CYTHON_FAST_THREAD_STATE static CYTHON_INLINE void __Pyx__ExceptionSave(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb) { #if PY_VERSION_HEX >= 0x030700A2 *type = tstate->exc_state.exc_type; *value = tstate->exc_state.exc_value; *tb = tstate->exc_state.exc_traceback; #else *type = tstate->exc_type; *value = tstate->exc_value; *tb = tstate->exc_traceback; #endif Py_XINCREF(*type); Py_XINCREF(*value); Py_XINCREF(*tb); } static CYTHON_INLINE void __Pyx__ExceptionReset(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb) { PyObject *tmp_type, *tmp_value, *tmp_tb; #if PY_VERSION_HEX >= 0x030700A2 tmp_type = tstate->exc_state.exc_type; tmp_value = tstate->exc_state.exc_value; tmp_tb = tstate->exc_state.exc_traceback; tstate->exc_state.exc_type = type; tstate->exc_state.exc_value = value; tstate->exc_state.exc_traceback = tb; #else tmp_type = tstate->exc_type; tmp_value = tstate->exc_value; tmp_tb = tstate->exc_traceback; tstate->exc_type = type; tstate->exc_value = value; tstate->exc_traceback = tb; #endif Py_XDECREF(tmp_type); Py_XDECREF(tmp_value); Py_XDECREF(tmp_tb); } #endif /* GetModuleGlobalName */ static CYTHON_INLINE PyObject *__Pyx_GetModuleGlobalName(PyObject *name) { PyObject *result; #if !CYTHON_AVOID_BORROWED_REFS result = PyDict_GetItem(__pyx_d, name); if (likely(result)) { Py_INCREF(result); } else { #else result = PyObject_GetItem(__pyx_d, name); if (!result) { PyErr_Clear(); #endif result = __Pyx_GetBuiltinName(name); } return result; } /* RaiseTooManyValuesToUnpack */ static CYTHON_INLINE void __Pyx_RaiseTooManyValuesError(Py_ssize_t expected) { PyErr_Format(PyExc_ValueError, "too many values to unpack (expected %" CYTHON_FORMAT_SSIZE_T "d)", expected); } /* RaiseNeedMoreValuesToUnpack */ static CYTHON_INLINE void __Pyx_RaiseNeedMoreValuesError(Py_ssize_t index) { PyErr_Format(PyExc_ValueError, "need more than %" CYTHON_FORMAT_SSIZE_T "d value%.1s to unpack", index, (index == 1) ? "" : "s"); } /* IterFinish */ static CYTHON_INLINE int __Pyx_IterFinish(void) { #if CYTHON_FAST_THREAD_STATE PyThreadState *tstate = __Pyx_PyThreadState_Current; PyObject* exc_type = tstate->curexc_type; if (unlikely(exc_type)) { if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) { PyObject *exc_value, *exc_tb; exc_value = tstate->curexc_value; exc_tb = tstate->curexc_traceback; tstate->curexc_type = 0; tstate->curexc_value = 0; tstate->curexc_traceback = 0; Py_DECREF(exc_type); Py_XDECREF(exc_value); Py_XDECREF(exc_tb); return 0; } else { return -1; } } return 0; #else if (unlikely(PyErr_Occurred())) { if (likely(PyErr_ExceptionMatches(PyExc_StopIteration))) { PyErr_Clear(); return 0; } else { return -1; } } return 0; #endif } /* UnpackItemEndCheck */ static int __Pyx_IternextUnpackEndCheck(PyObject *retval, Py_ssize_t expected) { if (unlikely(retval)) { Py_DECREF(retval); __Pyx_RaiseTooManyValuesError(expected); return -1; } else { return __Pyx_IterFinish(); } return 0; } /* PyErrExceptionMatches */ #if CYTHON_FAST_THREAD_STATE static int __Pyx_PyErr_ExceptionMatchesTuple(PyObject *exc_type, PyObject *tuple) { Py_ssize_t i, n; n = PyTuple_GET_SIZE(tuple); #if PY_MAJOR_VERSION >= 3 for (i=0; icurexc_type; if (exc_type == err) return 1; if (unlikely(!exc_type)) return 0; if (unlikely(PyTuple_Check(err))) return __Pyx_PyErr_ExceptionMatchesTuple(exc_type, err); return __Pyx_PyErr_GivenExceptionMatches(exc_type, err); } #endif /* None */ static CYTHON_INLINE void __Pyx_RaiseUnboundLocalError(const char *varname) { PyErr_Format(PyExc_UnboundLocalError, "local variable '%s' referenced before assignment", varname); } /* GetItemInt */ static PyObject *__Pyx_GetItemInt_Generic(PyObject *o, PyObject* j) { PyObject *r; if (!j) return NULL; r = PyObject_GetItem(o, j); Py_DECREF(j); return r; } static CYTHON_INLINE PyObject *__Pyx_GetItemInt_List_Fast(PyObject *o, Py_ssize_t i, CYTHON_NCP_UNUSED int wraparound, CYTHON_NCP_UNUSED int boundscheck) { #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS Py_ssize_t wrapped_i = i; if (wraparound & unlikely(i < 0)) { wrapped_i += PyList_GET_SIZE(o); } if ((!boundscheck) || likely((0 <= wrapped_i) & (wrapped_i < PyList_GET_SIZE(o)))) { PyObject *r = PyList_GET_ITEM(o, wrapped_i); Py_INCREF(r); return r; } return __Pyx_GetItemInt_Generic(o, PyInt_FromSsize_t(i)); #else return PySequence_GetItem(o, i); #endif } static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Tuple_Fast(PyObject *o, Py_ssize_t i, CYTHON_NCP_UNUSED int wraparound, CYTHON_NCP_UNUSED int boundscheck) { #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS Py_ssize_t wrapped_i = i; if (wraparound & unlikely(i < 0)) { wrapped_i += PyTuple_GET_SIZE(o); } if ((!boundscheck) || likely((0 <= wrapped_i) & (wrapped_i < PyTuple_GET_SIZE(o)))) { PyObject *r = PyTuple_GET_ITEM(o, wrapped_i); Py_INCREF(r); return r; } return __Pyx_GetItemInt_Generic(o, PyInt_FromSsize_t(i)); #else return PySequence_GetItem(o, i); #endif } static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Fast(PyObject *o, Py_ssize_t i, int is_list, CYTHON_NCP_UNUSED int wraparound, CYTHON_NCP_UNUSED int boundscheck) { #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS && CYTHON_USE_TYPE_SLOTS if (is_list || PyList_CheckExact(o)) { Py_ssize_t n = ((!wraparound) | likely(i >= 0)) ? i : i + PyList_GET_SIZE(o); if ((!boundscheck) || (likely((n >= 0) & (n < PyList_GET_SIZE(o))))) { PyObject *r = PyList_GET_ITEM(o, n); Py_INCREF(r); return r; } } else if (PyTuple_CheckExact(o)) { Py_ssize_t n = ((!wraparound) | likely(i >= 0)) ? i : i + PyTuple_GET_SIZE(o); if ((!boundscheck) || likely((n >= 0) & (n < PyTuple_GET_SIZE(o)))) { PyObject *r = PyTuple_GET_ITEM(o, n); Py_INCREF(r); return r; } } else { PySequenceMethods *m = Py_TYPE(o)->tp_as_sequence; if (likely(m && m->sq_item)) { if (wraparound && unlikely(i < 0) && likely(m->sq_length)) { Py_ssize_t l = m->sq_length(o); if (likely(l >= 0)) { i += l; } else { if (!PyErr_ExceptionMatches(PyExc_OverflowError)) return NULL; PyErr_Clear(); } } return m->sq_item(o, i); } } #else if (is_list || PySequence_Check(o)) { return PySequence_GetItem(o, i); } #endif return __Pyx_GetItemInt_Generic(o, PyInt_FromSsize_t(i)); } /* PyCFunctionFastCall */ #if CYTHON_FAST_PYCCALL static CYTHON_INLINE PyObject * __Pyx_PyCFunction_FastCall(PyObject *func_obj, PyObject **args, Py_ssize_t nargs) { PyCFunctionObject *func = (PyCFunctionObject*)func_obj; PyCFunction meth = PyCFunction_GET_FUNCTION(func); PyObject *self = PyCFunction_GET_SELF(func); int flags = PyCFunction_GET_FLAGS(func); assert(PyCFunction_Check(func)); assert(METH_FASTCALL == (flags & ~(METH_CLASS | METH_STATIC | METH_COEXIST | METH_KEYWORDS))); assert(nargs >= 0); assert(nargs == 0 || args != NULL); /* _PyCFunction_FastCallDict() must not be called with an exception set, because it may clear it (directly or indirectly) and so the caller loses its exception */ assert(!PyErr_Occurred()); if ((PY_VERSION_HEX < 0x030700A0) || unlikely(flags & METH_KEYWORDS)) { return (*((__Pyx_PyCFunctionFastWithKeywords)meth)) (self, args, nargs, NULL); } else { return (*((__Pyx_PyCFunctionFast)meth)) (self, args, nargs); } } #endif /* PyFunctionFastCall */ #if CYTHON_FAST_PYCALL #include "frameobject.h" static PyObject* __Pyx_PyFunction_FastCallNoKw(PyCodeObject *co, PyObject **args, Py_ssize_t na, PyObject *globals) { PyFrameObject *f; PyThreadState *tstate = __Pyx_PyThreadState_Current; PyObject **fastlocals; Py_ssize_t i; PyObject *result; assert(globals != NULL); /* XXX Perhaps we should create a specialized PyFrame_New() that doesn't take locals, but does take builtins without sanity checking them. */ assert(tstate != NULL); f = PyFrame_New(tstate, co, globals, NULL); if (f == NULL) { return NULL; } fastlocals = f->f_localsplus; for (i = 0; i < na; i++) { Py_INCREF(*args); fastlocals[i] = *args++; } result = PyEval_EvalFrameEx(f,0); ++tstate->recursion_depth; Py_DECREF(f); --tstate->recursion_depth; return result; } #if 1 || PY_VERSION_HEX < 0x030600B1 static PyObject *__Pyx_PyFunction_FastCallDict(PyObject *func, PyObject **args, int nargs, PyObject *kwargs) { PyCodeObject *co = (PyCodeObject *)PyFunction_GET_CODE(func); PyObject *globals = PyFunction_GET_GLOBALS(func); PyObject *argdefs = PyFunction_GET_DEFAULTS(func); PyObject *closure; #if PY_MAJOR_VERSION >= 3 PyObject *kwdefs; #endif PyObject *kwtuple, **k; PyObject **d; Py_ssize_t nd; Py_ssize_t nk; PyObject *result; assert(kwargs == NULL || PyDict_Check(kwargs)); nk = kwargs ? PyDict_Size(kwargs) : 0; if (Py_EnterRecursiveCall((char*)" while calling a Python object")) { return NULL; } if ( #if PY_MAJOR_VERSION >= 3 co->co_kwonlyargcount == 0 && #endif likely(kwargs == NULL || nk == 0) && co->co_flags == (CO_OPTIMIZED | CO_NEWLOCALS | CO_NOFREE)) { if (argdefs == NULL && co->co_argcount == nargs) { result = __Pyx_PyFunction_FastCallNoKw(co, args, nargs, globals); goto done; } else if (nargs == 0 && argdefs != NULL && co->co_argcount == Py_SIZE(argdefs)) { /* function called with no arguments, but all parameters have a default value: use default values as arguments .*/ args = &PyTuple_GET_ITEM(argdefs, 0); result =__Pyx_PyFunction_FastCallNoKw(co, args, Py_SIZE(argdefs), globals); goto done; } } if (kwargs != NULL) { Py_ssize_t pos, i; kwtuple = PyTuple_New(2 * nk); if (kwtuple == NULL) { result = NULL; goto done; } k = &PyTuple_GET_ITEM(kwtuple, 0); pos = i = 0; while (PyDict_Next(kwargs, &pos, &k[i], &k[i+1])) { Py_INCREF(k[i]); Py_INCREF(k[i+1]); i += 2; } nk = i / 2; } else { kwtuple = NULL; k = NULL; } closure = PyFunction_GET_CLOSURE(func); #if PY_MAJOR_VERSION >= 3 kwdefs = PyFunction_GET_KW_DEFAULTS(func); #endif if (argdefs != NULL) { d = &PyTuple_GET_ITEM(argdefs, 0); nd = Py_SIZE(argdefs); } else { d = NULL; nd = 0; } #if PY_MAJOR_VERSION >= 3 result = PyEval_EvalCodeEx((PyObject*)co, globals, (PyObject *)NULL, args, nargs, k, (int)nk, d, (int)nd, kwdefs, closure); #else result = PyEval_EvalCodeEx(co, globals, (PyObject *)NULL, args, nargs, k, (int)nk, d, (int)nd, closure); #endif Py_XDECREF(kwtuple); done: Py_LeaveRecursiveCall(); return result; } #endif #endif /* PyObjectCallMethO */ #if CYTHON_COMPILING_IN_CPYTHON static CYTHON_INLINE PyObject* __Pyx_PyObject_CallMethO(PyObject *func, PyObject *arg) { PyObject *self, *result; PyCFunction cfunc; cfunc = PyCFunction_GET_FUNCTION(func); self = PyCFunction_GET_SELF(func); if (unlikely(Py_EnterRecursiveCall((char*)" while calling a Python object"))) return NULL; result = cfunc(self, arg); Py_LeaveRecursiveCall(); if (unlikely(!result) && unlikely(!PyErr_Occurred())) { PyErr_SetString( PyExc_SystemError, "NULL result without error in PyObject_Call"); } return result; } #endif /* PyObjectCallOneArg */ #if CYTHON_COMPILING_IN_CPYTHON static PyObject* __Pyx__PyObject_CallOneArg(PyObject *func, PyObject *arg) { PyObject *result; PyObject *args = PyTuple_New(1); if (unlikely(!args)) return NULL; Py_INCREF(arg); PyTuple_SET_ITEM(args, 0, arg); result = __Pyx_PyObject_Call(func, args, NULL); Py_DECREF(args); return result; } static CYTHON_INLINE PyObject* __Pyx_PyObject_CallOneArg(PyObject *func, PyObject *arg) { #if CYTHON_FAST_PYCALL if (PyFunction_Check(func)) { return __Pyx_PyFunction_FastCall(func, &arg, 1); } #endif if (likely(PyCFunction_Check(func))) { if (likely(PyCFunction_GET_FLAGS(func) & METH_O)) { return __Pyx_PyObject_CallMethO(func, arg); #if CYTHON_FAST_PYCCALL } else if (PyCFunction_GET_FLAGS(func) & METH_FASTCALL) { return __Pyx_PyCFunction_FastCall(func, &arg, 1); #endif } } return __Pyx__PyObject_CallOneArg(func, arg); } #else static CYTHON_INLINE PyObject* __Pyx_PyObject_CallOneArg(PyObject *func, PyObject *arg) { PyObject *result; PyObject *args = PyTuple_Pack(1, arg); if (unlikely(!args)) return NULL; result = __Pyx_PyObject_Call(func, args, NULL); Py_DECREF(args); return result; } #endif /* PyObjectCallNoArg */ #if CYTHON_COMPILING_IN_CPYTHON static CYTHON_INLINE PyObject* __Pyx_PyObject_CallNoArg(PyObject *func) { #if CYTHON_FAST_PYCALL if (PyFunction_Check(func)) { return __Pyx_PyFunction_FastCall(func, NULL, 0); } #endif #ifdef __Pyx_CyFunction_USED if (likely(PyCFunction_Check(func) || __Pyx_TypeCheck(func, __pyx_CyFunctionType))) { #else if (likely(PyCFunction_Check(func))) { #endif if (likely(PyCFunction_GET_FLAGS(func) & METH_NOARGS)) { return __Pyx_PyObject_CallMethO(func, NULL); } } return __Pyx_PyObject_Call(func, __pyx_empty_tuple, NULL); } #endif /* PyObjectCallMethod0 */ static PyObject* __Pyx_PyObject_CallMethod0(PyObject* obj, PyObject* method_name) { PyObject *method, *result = NULL; method = __Pyx_PyObject_GetAttrStr(obj, method_name); if (unlikely(!method)) goto bad; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(method))) { PyObject *self = PyMethod_GET_SELF(method); if (likely(self)) { PyObject *function = PyMethod_GET_FUNCTION(method); result = __Pyx_PyObject_CallOneArg(function, self); Py_DECREF(method); return result; } } #endif result = __Pyx_PyObject_CallNoArg(method); Py_DECREF(method); bad: return result; } /* RaiseNoneIterError */ static CYTHON_INLINE void __Pyx_RaiseNoneNotIterableError(void) { PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable"); } /* UnpackTupleError */ static void __Pyx_UnpackTupleError(PyObject *t, Py_ssize_t index) { if (t == Py_None) { __Pyx_RaiseNoneNotIterableError(); } else if (PyTuple_GET_SIZE(t) < index) { __Pyx_RaiseNeedMoreValuesError(PyTuple_GET_SIZE(t)); } else { __Pyx_RaiseTooManyValuesError(index); } } /* UnpackTuple2 */ static CYTHON_INLINE int __Pyx_unpack_tuple2_exact( PyObject* tuple, PyObject** pvalue1, PyObject** pvalue2, int decref_tuple) { PyObject *value1 = NULL, *value2 = NULL; #if CYTHON_COMPILING_IN_PYPY value1 = PySequence_ITEM(tuple, 0); if (unlikely(!value1)) goto bad; value2 = PySequence_ITEM(tuple, 1); if (unlikely(!value2)) goto bad; #else value1 = PyTuple_GET_ITEM(tuple, 0); Py_INCREF(value1); value2 = PyTuple_GET_ITEM(tuple, 1); Py_INCREF(value2); #endif if (decref_tuple) { Py_DECREF(tuple); } *pvalue1 = value1; *pvalue2 = value2; return 0; #if CYTHON_COMPILING_IN_PYPY bad: Py_XDECREF(value1); Py_XDECREF(value2); if (decref_tuple) { Py_XDECREF(tuple); } return -1; #endif } static int __Pyx_unpack_tuple2_generic(PyObject* tuple, PyObject** pvalue1, PyObject** pvalue2, int has_known_size, int decref_tuple) { Py_ssize_t index; PyObject *value1 = NULL, *value2 = NULL, *iter = NULL; iternextfunc iternext; iter = PyObject_GetIter(tuple); if (unlikely(!iter)) goto bad; if (decref_tuple) { Py_DECREF(tuple); tuple = NULL; } iternext = Py_TYPE(iter)->tp_iternext; value1 = iternext(iter); if (unlikely(!value1)) { index = 0; goto unpacking_failed; } value2 = iternext(iter); if (unlikely(!value2)) { index = 1; goto unpacking_failed; } if (!has_known_size && unlikely(__Pyx_IternextUnpackEndCheck(iternext(iter), 2))) goto bad; Py_DECREF(iter); *pvalue1 = value1; *pvalue2 = value2; return 0; unpacking_failed: if (!has_known_size && __Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index); bad: Py_XDECREF(iter); Py_XDECREF(value1); Py_XDECREF(value2); if (decref_tuple) { Py_XDECREF(tuple); } return -1; } /* dict_iter */ static CYTHON_INLINE PyObject* __Pyx_dict_iterator(PyObject* iterable, int is_dict, PyObject* method_name, Py_ssize_t* p_orig_length, int* p_source_is_dict) { is_dict = is_dict || likely(PyDict_CheckExact(iterable)); *p_source_is_dict = is_dict; if (is_dict) { #if !CYTHON_COMPILING_IN_PYPY *p_orig_length = PyDict_Size(iterable); Py_INCREF(iterable); return iterable; #elif PY_MAJOR_VERSION >= 3 static PyObject *py_items = NULL, *py_keys = NULL, *py_values = NULL; PyObject **pp = NULL; if (method_name) { const char *name = PyUnicode_AsUTF8(method_name); if (strcmp(name, "iteritems") == 0) pp = &py_items; else if (strcmp(name, "iterkeys") == 0) pp = &py_keys; else if (strcmp(name, "itervalues") == 0) pp = &py_values; if (pp) { if (!*pp) { *pp = PyUnicode_FromString(name + 4); if (!*pp) return NULL; } method_name = *pp; } } #endif } *p_orig_length = 0; if (method_name) { PyObject* iter; iterable = __Pyx_PyObject_CallMethod0(iterable, method_name); if (!iterable) return NULL; #if !CYTHON_COMPILING_IN_PYPY if (PyTuple_CheckExact(iterable) || PyList_CheckExact(iterable)) return iterable; #endif iter = PyObject_GetIter(iterable); Py_DECREF(iterable); return iter; } return PyObject_GetIter(iterable); } static CYTHON_INLINE int __Pyx_dict_iter_next( PyObject* iter_obj, CYTHON_NCP_UNUSED Py_ssize_t orig_length, CYTHON_NCP_UNUSED Py_ssize_t* ppos, PyObject** pkey, PyObject** pvalue, PyObject** pitem, int source_is_dict) { PyObject* next_item; #if !CYTHON_COMPILING_IN_PYPY if (source_is_dict) { PyObject *key, *value; if (unlikely(orig_length != PyDict_Size(iter_obj))) { PyErr_SetString(PyExc_RuntimeError, "dictionary changed size during iteration"); return -1; } if (unlikely(!PyDict_Next(iter_obj, ppos, &key, &value))) { return 0; } if (pitem) { PyObject* tuple = PyTuple_New(2); if (unlikely(!tuple)) { return -1; } Py_INCREF(key); Py_INCREF(value); PyTuple_SET_ITEM(tuple, 0, key); PyTuple_SET_ITEM(tuple, 1, value); *pitem = tuple; } else { if (pkey) { Py_INCREF(key); *pkey = key; } if (pvalue) { Py_INCREF(value); *pvalue = value; } } return 1; } else if (PyTuple_CheckExact(iter_obj)) { Py_ssize_t pos = *ppos; if (unlikely(pos >= PyTuple_GET_SIZE(iter_obj))) return 0; *ppos = pos + 1; next_item = PyTuple_GET_ITEM(iter_obj, pos); Py_INCREF(next_item); } else if (PyList_CheckExact(iter_obj)) { Py_ssize_t pos = *ppos; if (unlikely(pos >= PyList_GET_SIZE(iter_obj))) return 0; *ppos = pos + 1; next_item = PyList_GET_ITEM(iter_obj, pos); Py_INCREF(next_item); } else #endif { next_item = PyIter_Next(iter_obj); if (unlikely(!next_item)) { return __Pyx_IterFinish(); } } if (pitem) { *pitem = next_item; } else if (pkey && pvalue) { if (__Pyx_unpack_tuple2(next_item, pkey, pvalue, source_is_dict, source_is_dict, 1)) return -1; } else if (pkey) { *pkey = next_item; } else { *pvalue = next_item; } return 1; } /* None */ static CYTHON_INLINE void __Pyx_RaiseClosureNameError(const char *varname) { PyErr_Format(PyExc_NameError, "free variable '%s' referenced before assignment in enclosing scope", varname); } /* FetchCommonType */ static PyTypeObject* __Pyx_FetchCommonType(PyTypeObject* type) { PyObject* fake_module; PyTypeObject* cached_type = NULL; fake_module = PyImport_AddModule((char*) "_cython_" CYTHON_ABI); if (!fake_module) return NULL; Py_INCREF(fake_module); cached_type = (PyTypeObject*) PyObject_GetAttrString(fake_module, type->tp_name); if (cached_type) { if (!PyType_Check((PyObject*)cached_type)) { PyErr_Format(PyExc_TypeError, "Shared Cython type %.200s is not a type object", type->tp_name); goto bad; } if (cached_type->tp_basicsize != type->tp_basicsize) { PyErr_Format(PyExc_TypeError, "Shared Cython type %.200s has the wrong size, try recompiling", type->tp_name); goto bad; } } else { if (!PyErr_ExceptionMatches(PyExc_AttributeError)) goto bad; PyErr_Clear(); if (PyType_Ready(type) < 0) goto bad; if (PyObject_SetAttrString(fake_module, type->tp_name, (PyObject*) type) < 0) goto bad; Py_INCREF(type); cached_type = type; } done: Py_DECREF(fake_module); return cached_type; bad: Py_XDECREF(cached_type); cached_type = NULL; goto done; } /* CythonFunction */ static PyObject * __Pyx_CyFunction_get_doc(__pyx_CyFunctionObject *op, CYTHON_UNUSED void *closure) { if (unlikely(op->func_doc == NULL)) { if (op->func.m_ml->ml_doc) { #if PY_MAJOR_VERSION >= 3 op->func_doc = PyUnicode_FromString(op->func.m_ml->ml_doc); #else op->func_doc = PyString_FromString(op->func.m_ml->ml_doc); #endif if (unlikely(op->func_doc == NULL)) return NULL; } else { Py_INCREF(Py_None); return Py_None; } } Py_INCREF(op->func_doc); return op->func_doc; } static int __Pyx_CyFunction_set_doc(__pyx_CyFunctionObject *op, PyObject *value) { PyObject *tmp = op->func_doc; if (value == NULL) { value = Py_None; } Py_INCREF(value); op->func_doc = value; Py_XDECREF(tmp); return 0; } static PyObject * __Pyx_CyFunction_get_name(__pyx_CyFunctionObject *op) { if (unlikely(op->func_name == NULL)) { #if PY_MAJOR_VERSION >= 3 op->func_name = PyUnicode_InternFromString(op->func.m_ml->ml_name); #else op->func_name = PyString_InternFromString(op->func.m_ml->ml_name); #endif if (unlikely(op->func_name == NULL)) return NULL; } Py_INCREF(op->func_name); return op->func_name; } static int __Pyx_CyFunction_set_name(__pyx_CyFunctionObject *op, PyObject *value) { PyObject *tmp; #if PY_MAJOR_VERSION >= 3 if (unlikely(value == NULL || !PyUnicode_Check(value))) { #else if (unlikely(value == NULL || !PyString_Check(value))) { #endif PyErr_SetString(PyExc_TypeError, "__name__ must be set to a string object"); return -1; } tmp = op->func_name; Py_INCREF(value); op->func_name = value; Py_XDECREF(tmp); return 0; } static PyObject * __Pyx_CyFunction_get_qualname(__pyx_CyFunctionObject *op) { Py_INCREF(op->func_qualname); return op->func_qualname; } static int __Pyx_CyFunction_set_qualname(__pyx_CyFunctionObject *op, PyObject *value) { PyObject *tmp; #if PY_MAJOR_VERSION >= 3 if (unlikely(value == NULL || !PyUnicode_Check(value))) { #else if (unlikely(value == NULL || !PyString_Check(value))) { #endif PyErr_SetString(PyExc_TypeError, "__qualname__ must be set to a string object"); return -1; } tmp = op->func_qualname; Py_INCREF(value); op->func_qualname = value; Py_XDECREF(tmp); return 0; } static PyObject * __Pyx_CyFunction_get_self(__pyx_CyFunctionObject *m, CYTHON_UNUSED void *closure) { PyObject *self; self = m->func_closure; if (self == NULL) self = Py_None; Py_INCREF(self); return self; } static PyObject * __Pyx_CyFunction_get_dict(__pyx_CyFunctionObject *op) { if (unlikely(op->func_dict == NULL)) { op->func_dict = PyDict_New(); if (unlikely(op->func_dict == NULL)) return NULL; } Py_INCREF(op->func_dict); return op->func_dict; } static int __Pyx_CyFunction_set_dict(__pyx_CyFunctionObject *op, PyObject *value) { PyObject *tmp; if (unlikely(value == NULL)) { PyErr_SetString(PyExc_TypeError, "function's dictionary may not be deleted"); return -1; } if (unlikely(!PyDict_Check(value))) { PyErr_SetString(PyExc_TypeError, "setting function's dictionary to a non-dict"); return -1; } tmp = op->func_dict; Py_INCREF(value); op->func_dict = value; Py_XDECREF(tmp); return 0; } static PyObject * __Pyx_CyFunction_get_globals(__pyx_CyFunctionObject *op) { Py_INCREF(op->func_globals); return op->func_globals; } static PyObject * __Pyx_CyFunction_get_closure(CYTHON_UNUSED __pyx_CyFunctionObject *op) { Py_INCREF(Py_None); return Py_None; } static PyObject * __Pyx_CyFunction_get_code(__pyx_CyFunctionObject *op) { PyObject* result = (op->func_code) ? op->func_code : Py_None; Py_INCREF(result); return result; } static int __Pyx_CyFunction_init_defaults(__pyx_CyFunctionObject *op) { int result = 0; PyObject *res = op->defaults_getter((PyObject *) op); if (unlikely(!res)) return -1; #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS op->defaults_tuple = PyTuple_GET_ITEM(res, 0); Py_INCREF(op->defaults_tuple); op->defaults_kwdict = PyTuple_GET_ITEM(res, 1); Py_INCREF(op->defaults_kwdict); #else op->defaults_tuple = PySequence_ITEM(res, 0); if (unlikely(!op->defaults_tuple)) result = -1; else { op->defaults_kwdict = PySequence_ITEM(res, 1); if (unlikely(!op->defaults_kwdict)) result = -1; } #endif Py_DECREF(res); return result; } static int __Pyx_CyFunction_set_defaults(__pyx_CyFunctionObject *op, PyObject* value) { PyObject* tmp; if (!value) { value = Py_None; } else if (value != Py_None && !PyTuple_Check(value)) { PyErr_SetString(PyExc_TypeError, "__defaults__ must be set to a tuple object"); return -1; } Py_INCREF(value); tmp = op->defaults_tuple; op->defaults_tuple = value; Py_XDECREF(tmp); return 0; } static PyObject * __Pyx_CyFunction_get_defaults(__pyx_CyFunctionObject *op) { PyObject* result = op->defaults_tuple; if (unlikely(!result)) { if (op->defaults_getter) { if (__Pyx_CyFunction_init_defaults(op) < 0) return NULL; result = op->defaults_tuple; } else { result = Py_None; } } Py_INCREF(result); return result; } static int __Pyx_CyFunction_set_kwdefaults(__pyx_CyFunctionObject *op, PyObject* value) { PyObject* tmp; if (!value) { value = Py_None; } else if (value != Py_None && !PyDict_Check(value)) { PyErr_SetString(PyExc_TypeError, "__kwdefaults__ must be set to a dict object"); return -1; } Py_INCREF(value); tmp = op->defaults_kwdict; op->defaults_kwdict = value; Py_XDECREF(tmp); return 0; } static PyObject * __Pyx_CyFunction_get_kwdefaults(__pyx_CyFunctionObject *op) { PyObject* result = op->defaults_kwdict; if (unlikely(!result)) { if (op->defaults_getter) { if (__Pyx_CyFunction_init_defaults(op) < 0) return NULL; result = op->defaults_kwdict; } else { result = Py_None; } } Py_INCREF(result); return result; } static int __Pyx_CyFunction_set_annotations(__pyx_CyFunctionObject *op, PyObject* value) { PyObject* tmp; if (!value || value == Py_None) { value = NULL; } else if (!PyDict_Check(value)) { PyErr_SetString(PyExc_TypeError, "__annotations__ must be set to a dict object"); return -1; } Py_XINCREF(value); tmp = op->func_annotations; op->func_annotations = value; Py_XDECREF(tmp); return 0; } static PyObject * __Pyx_CyFunction_get_annotations(__pyx_CyFunctionObject *op) { PyObject* result = op->func_annotations; if (unlikely(!result)) { result = PyDict_New(); if (unlikely(!result)) return NULL; op->func_annotations = result; } Py_INCREF(result); return result; } static PyGetSetDef __pyx_CyFunction_getsets[] = { {(char *) "func_doc", (getter)__Pyx_CyFunction_get_doc, (setter)__Pyx_CyFunction_set_doc, 0, 0}, {(char *) "__doc__", (getter)__Pyx_CyFunction_get_doc, (setter)__Pyx_CyFunction_set_doc, 0, 0}, {(char *) "func_name", (getter)__Pyx_CyFunction_get_name, (setter)__Pyx_CyFunction_set_name, 0, 0}, {(char *) "__name__", (getter)__Pyx_CyFunction_get_name, (setter)__Pyx_CyFunction_set_name, 0, 0}, {(char *) "__qualname__", (getter)__Pyx_CyFunction_get_qualname, (setter)__Pyx_CyFunction_set_qualname, 0, 0}, {(char *) "__self__", (getter)__Pyx_CyFunction_get_self, 0, 0, 0}, {(char *) "func_dict", (getter)__Pyx_CyFunction_get_dict, (setter)__Pyx_CyFunction_set_dict, 0, 0}, {(char *) "__dict__", (getter)__Pyx_CyFunction_get_dict, (setter)__Pyx_CyFunction_set_dict, 0, 0}, {(char *) "func_globals", (getter)__Pyx_CyFunction_get_globals, 0, 0, 0}, {(char *) "__globals__", (getter)__Pyx_CyFunction_get_globals, 0, 0, 0}, {(char *) "func_closure", (getter)__Pyx_CyFunction_get_closure, 0, 0, 0}, {(char *) "__closure__", (getter)__Pyx_CyFunction_get_closure, 0, 0, 0}, {(char *) "func_code", (getter)__Pyx_CyFunction_get_code, 0, 0, 0}, {(char *) "__code__", (getter)__Pyx_CyFunction_get_code, 0, 0, 0}, {(char *) "func_defaults", (getter)__Pyx_CyFunction_get_defaults, (setter)__Pyx_CyFunction_set_defaults, 0, 0}, {(char *) "__defaults__", (getter)__Pyx_CyFunction_get_defaults, (setter)__Pyx_CyFunction_set_defaults, 0, 0}, {(char *) "__kwdefaults__", (getter)__Pyx_CyFunction_get_kwdefaults, (setter)__Pyx_CyFunction_set_kwdefaults, 0, 0}, {(char *) "__annotations__", (getter)__Pyx_CyFunction_get_annotations, (setter)__Pyx_CyFunction_set_annotations, 0, 0}, {0, 0, 0, 0, 0} }; static PyMemberDef __pyx_CyFunction_members[] = { {(char *) "__module__", T_OBJECT, offsetof(PyCFunctionObject, m_module), PY_WRITE_RESTRICTED, 0}, {0, 0, 0, 0, 0} }; static PyObject * __Pyx_CyFunction_reduce(__pyx_CyFunctionObject *m, CYTHON_UNUSED PyObject *args) { #if PY_MAJOR_VERSION >= 3 return PyUnicode_FromString(m->func.m_ml->ml_name); #else return PyString_FromString(m->func.m_ml->ml_name); #endif } static PyMethodDef __pyx_CyFunction_methods[] = { {"__reduce__", (PyCFunction)__Pyx_CyFunction_reduce, METH_VARARGS, 0}, {0, 0, 0, 0} }; #if PY_VERSION_HEX < 0x030500A0 #define __Pyx_CyFunction_weakreflist(cyfunc) ((cyfunc)->func_weakreflist) #else #define __Pyx_CyFunction_weakreflist(cyfunc) ((cyfunc)->func.m_weakreflist) #endif static PyObject *__Pyx_CyFunction_New(PyTypeObject *type, PyMethodDef *ml, int flags, PyObject* qualname, PyObject *closure, PyObject *module, PyObject* globals, PyObject* code) { __pyx_CyFunctionObject *op = PyObject_GC_New(__pyx_CyFunctionObject, type); if (op == NULL) return NULL; op->flags = flags; __Pyx_CyFunction_weakreflist(op) = NULL; op->func.m_ml = ml; op->func.m_self = (PyObject *) op; Py_XINCREF(closure); op->func_closure = closure; Py_XINCREF(module); op->func.m_module = module; op->func_dict = NULL; op->func_name = NULL; Py_INCREF(qualname); op->func_qualname = qualname; op->func_doc = NULL; op->func_classobj = NULL; op->func_globals = globals; Py_INCREF(op->func_globals); Py_XINCREF(code); op->func_code = code; op->defaults_pyobjects = 0; op->defaults = NULL; op->defaults_tuple = NULL; op->defaults_kwdict = NULL; op->defaults_getter = NULL; op->func_annotations = NULL; PyObject_GC_Track(op); return (PyObject *) op; } static int __Pyx_CyFunction_clear(__pyx_CyFunctionObject *m) { Py_CLEAR(m->func_closure); Py_CLEAR(m->func.m_module); Py_CLEAR(m->func_dict); Py_CLEAR(m->func_name); Py_CLEAR(m->func_qualname); Py_CLEAR(m->func_doc); Py_CLEAR(m->func_globals); Py_CLEAR(m->func_code); Py_CLEAR(m->func_classobj); Py_CLEAR(m->defaults_tuple); Py_CLEAR(m->defaults_kwdict); Py_CLEAR(m->func_annotations); if (m->defaults) { PyObject **pydefaults = __Pyx_CyFunction_Defaults(PyObject *, m); int i; for (i = 0; i < m->defaults_pyobjects; i++) Py_XDECREF(pydefaults[i]); PyObject_Free(m->defaults); m->defaults = NULL; } return 0; } static void __Pyx__CyFunction_dealloc(__pyx_CyFunctionObject *m) { if (__Pyx_CyFunction_weakreflist(m) != NULL) PyObject_ClearWeakRefs((PyObject *) m); __Pyx_CyFunction_clear(m); PyObject_GC_Del(m); } static void __Pyx_CyFunction_dealloc(__pyx_CyFunctionObject *m) { PyObject_GC_UnTrack(m); __Pyx__CyFunction_dealloc(m); } static int __Pyx_CyFunction_traverse(__pyx_CyFunctionObject *m, visitproc visit, void *arg) { Py_VISIT(m->func_closure); Py_VISIT(m->func.m_module); Py_VISIT(m->func_dict); Py_VISIT(m->func_name); Py_VISIT(m->func_qualname); Py_VISIT(m->func_doc); Py_VISIT(m->func_globals); Py_VISIT(m->func_code); Py_VISIT(m->func_classobj); Py_VISIT(m->defaults_tuple); Py_VISIT(m->defaults_kwdict); if (m->defaults) { PyObject **pydefaults = __Pyx_CyFunction_Defaults(PyObject *, m); int i; for (i = 0; i < m->defaults_pyobjects; i++) Py_VISIT(pydefaults[i]); } return 0; } static PyObject *__Pyx_CyFunction_descr_get(PyObject *func, PyObject *obj, PyObject *type) { __pyx_CyFunctionObject *m = (__pyx_CyFunctionObject *) func; if (m->flags & __Pyx_CYFUNCTION_STATICMETHOD) { Py_INCREF(func); return func; } if (m->flags & __Pyx_CYFUNCTION_CLASSMETHOD) { if (type == NULL) type = (PyObject *)(Py_TYPE(obj)); return __Pyx_PyMethod_New(func, type, (PyObject *)(Py_TYPE(type))); } if (obj == Py_None) obj = NULL; return __Pyx_PyMethod_New(func, obj, type); } static PyObject* __Pyx_CyFunction_repr(__pyx_CyFunctionObject *op) { #if PY_MAJOR_VERSION >= 3 return PyUnicode_FromFormat("", op->func_qualname, (void *)op); #else return PyString_FromFormat("", PyString_AsString(op->func_qualname), (void *)op); #endif } static PyObject * __Pyx_CyFunction_CallMethod(PyObject *func, PyObject *self, PyObject *arg, PyObject *kw) { PyCFunctionObject* f = (PyCFunctionObject*)func; PyCFunction meth = f->m_ml->ml_meth; Py_ssize_t size; switch (f->m_ml->ml_flags & (METH_VARARGS | METH_KEYWORDS | METH_NOARGS | METH_O)) { case METH_VARARGS: if (likely(kw == NULL || PyDict_Size(kw) == 0)) return (*meth)(self, arg); break; case METH_VARARGS | METH_KEYWORDS: return (*(PyCFunctionWithKeywords)meth)(self, arg, kw); case METH_NOARGS: if (likely(kw == NULL || PyDict_Size(kw) == 0)) { size = PyTuple_GET_SIZE(arg); if (likely(size == 0)) return (*meth)(self, NULL); PyErr_Format(PyExc_TypeError, "%.200s() takes no arguments (%" CYTHON_FORMAT_SSIZE_T "d given)", f->m_ml->ml_name, size); return NULL; } break; case METH_O: if (likely(kw == NULL || PyDict_Size(kw) == 0)) { size = PyTuple_GET_SIZE(arg); if (likely(size == 1)) { PyObject *result, *arg0; #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS arg0 = PyTuple_GET_ITEM(arg, 0); #else arg0 = PySequence_ITEM(arg, 0); if (unlikely(!arg0)) return NULL; #endif result = (*meth)(self, arg0); #if !(CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS) Py_DECREF(arg0); #endif return result; } PyErr_Format(PyExc_TypeError, "%.200s() takes exactly one argument (%" CYTHON_FORMAT_SSIZE_T "d given)", f->m_ml->ml_name, size); return NULL; } break; default: PyErr_SetString(PyExc_SystemError, "Bad call flags in " "__Pyx_CyFunction_Call. METH_OLDARGS is no " "longer supported!"); return NULL; } PyErr_Format(PyExc_TypeError, "%.200s() takes no keyword arguments", f->m_ml->ml_name); return NULL; } static CYTHON_INLINE PyObject *__Pyx_CyFunction_Call(PyObject *func, PyObject *arg, PyObject *kw) { return __Pyx_CyFunction_CallMethod(func, ((PyCFunctionObject*)func)->m_self, arg, kw); } static PyObject *__Pyx_CyFunction_CallAsMethod(PyObject *func, PyObject *args, PyObject *kw) { PyObject *result; __pyx_CyFunctionObject *cyfunc = (__pyx_CyFunctionObject *) func; if ((cyfunc->flags & __Pyx_CYFUNCTION_CCLASS) && !(cyfunc->flags & __Pyx_CYFUNCTION_STATICMETHOD)) { Py_ssize_t argc; PyObject *new_args; PyObject *self; argc = PyTuple_GET_SIZE(args); new_args = PyTuple_GetSlice(args, 1, argc); if (unlikely(!new_args)) return NULL; self = PyTuple_GetItem(args, 0); if (unlikely(!self)) { Py_DECREF(new_args); return NULL; } result = __Pyx_CyFunction_CallMethod(func, self, new_args, kw); Py_DECREF(new_args); } else { result = __Pyx_CyFunction_Call(func, args, kw); } return result; } static PyTypeObject __pyx_CyFunctionType_type = { PyVarObject_HEAD_INIT(0, 0) "cython_function_or_method", sizeof(__pyx_CyFunctionObject), 0, (destructor) __Pyx_CyFunction_dealloc, 0, 0, 0, #if PY_MAJOR_VERSION < 3 0, #else 0, #endif (reprfunc) __Pyx_CyFunction_repr, 0, 0, 0, 0, __Pyx_CyFunction_CallAsMethod, 0, 0, 0, 0, Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC, 0, (traverseproc) __Pyx_CyFunction_traverse, (inquiry) __Pyx_CyFunction_clear, 0, #if PY_VERSION_HEX < 0x030500A0 offsetof(__pyx_CyFunctionObject, func_weakreflist), #else offsetof(PyCFunctionObject, m_weakreflist), #endif 0, 0, __pyx_CyFunction_methods, __pyx_CyFunction_members, __pyx_CyFunction_getsets, 0, 0, __Pyx_CyFunction_descr_get, 0, offsetof(__pyx_CyFunctionObject, func_dict), 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, #if PY_VERSION_HEX >= 0x030400a1 0, #endif }; static int __pyx_CyFunction_init(void) { __pyx_CyFunctionType = __Pyx_FetchCommonType(&__pyx_CyFunctionType_type); if (unlikely(__pyx_CyFunctionType == NULL)) { return -1; } return 0; } static CYTHON_INLINE void *__Pyx_CyFunction_InitDefaults(PyObject *func, size_t size, int pyobjects) { __pyx_CyFunctionObject *m = (__pyx_CyFunctionObject *) func; m->defaults = PyObject_Malloc(size); if (unlikely(!m->defaults)) return PyErr_NoMemory(); memset(m->defaults, 0, size); m->defaults_pyobjects = pyobjects; return m->defaults; } static CYTHON_INLINE void __Pyx_CyFunction_SetDefaultsTuple(PyObject *func, PyObject *tuple) { __pyx_CyFunctionObject *m = (__pyx_CyFunctionObject *) func; m->defaults_tuple = tuple; Py_INCREF(tuple); } static CYTHON_INLINE void __Pyx_CyFunction_SetDefaultsKwDict(PyObject *func, PyObject *dict) { __pyx_CyFunctionObject *m = (__pyx_CyFunctionObject *) func; m->defaults_kwdict = dict; Py_INCREF(dict); } static CYTHON_INLINE void __Pyx_CyFunction_SetAnnotationsDict(PyObject *func, PyObject *dict) { __pyx_CyFunctionObject *m = (__pyx_CyFunctionObject *) func; m->func_annotations = dict; Py_INCREF(dict); } /* decode_c_bytes */ static CYTHON_INLINE PyObject* __Pyx_decode_c_bytes( const char* cstring, Py_ssize_t length, Py_ssize_t start, Py_ssize_t stop, const char* encoding, const char* errors, PyObject* (*decode_func)(const char *s, Py_ssize_t size, const char *errors)) { if (unlikely((start < 0) | (stop < 0))) { if (start < 0) { start += length; if (start < 0) start = 0; } if (stop < 0) stop += length; } if (stop > length) stop = length; length = stop - start; if (unlikely(length <= 0)) return PyUnicode_FromUnicode(NULL, 0); cstring += start; if (decode_func) { return decode_func(cstring, length, errors); } else { return PyUnicode_Decode(cstring, length, encoding, errors); } } /* WriteUnraisableException */ static void __Pyx_WriteUnraisable(const char *name, CYTHON_UNUSED int clineno, CYTHON_UNUSED int lineno, CYTHON_UNUSED const char *filename, int full_traceback, CYTHON_UNUSED int nogil) { PyObject *old_exc, *old_val, *old_tb; PyObject *ctx; __Pyx_PyThreadState_declare #ifdef WITH_THREAD PyGILState_STATE state; if (nogil) state = PyGILState_Ensure(); #ifdef _MSC_VER else state = (PyGILState_STATE)-1; #endif #endif __Pyx_PyThreadState_assign __Pyx_ErrFetch(&old_exc, &old_val, &old_tb); if (full_traceback) { Py_XINCREF(old_exc); Py_XINCREF(old_val); Py_XINCREF(old_tb); __Pyx_ErrRestore(old_exc, old_val, old_tb); PyErr_PrintEx(1); } #if PY_MAJOR_VERSION < 3 ctx = PyString_FromString(name); #else ctx = PyUnicode_FromString(name); #endif __Pyx_ErrRestore(old_exc, old_val, old_tb); if (!ctx) { PyErr_WriteUnraisable(Py_None); } else { PyErr_WriteUnraisable(ctx); Py_DECREF(ctx); } #ifdef WITH_THREAD if (nogil) PyGILState_Release(state); #endif } /* PyIntBinop */ #if !CYTHON_COMPILING_IN_PYPY static PyObject* __Pyx_PyInt_AddObjC(PyObject *op1, PyObject *op2, CYTHON_UNUSED long intval, CYTHON_UNUSED int inplace) { #if PY_MAJOR_VERSION < 3 if (likely(PyInt_CheckExact(op1))) { const long b = intval; long x; long a = PyInt_AS_LONG(op1); x = (long)((unsigned long)a + b); if (likely((x^a) >= 0 || (x^b) >= 0)) return PyInt_FromLong(x); return PyLong_Type.tp_as_number->nb_add(op1, op2); } #endif #if CYTHON_USE_PYLONG_INTERNALS if (likely(PyLong_CheckExact(op1))) { const long b = intval; long a, x; #ifdef HAVE_LONG_LONG const PY_LONG_LONG llb = intval; PY_LONG_LONG lla, llx; #endif const digit* digits = ((PyLongObject*)op1)->ob_digit; const Py_ssize_t size = Py_SIZE(op1); if (likely(__Pyx_sst_abs(size) <= 1)) { a = likely(size) ? digits[0] : 0; if (size == -1) a = -a; } else { switch (size) { case -2: if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) { a = -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])); break; #ifdef HAVE_LONG_LONG } else if (8 * sizeof(PY_LONG_LONG) - 1 > 2 * PyLong_SHIFT) { lla = -(PY_LONG_LONG) (((((unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0])); goto long_long; #endif } case 2: if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) { a = (long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])); break; #ifdef HAVE_LONG_LONG } else if (8 * sizeof(PY_LONG_LONG) - 1 > 2 * PyLong_SHIFT) { lla = (PY_LONG_LONG) (((((unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0])); goto long_long; #endif } case -3: if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) { a = -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])); break; #ifdef HAVE_LONG_LONG } else if (8 * sizeof(PY_LONG_LONG) - 1 > 3 * PyLong_SHIFT) { lla = -(PY_LONG_LONG) (((((((unsigned PY_LONG_LONG)digits[2]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0])); goto long_long; #endif } case 3: if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) { a = (long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])); break; #ifdef HAVE_LONG_LONG } else if (8 * sizeof(PY_LONG_LONG) - 1 > 3 * PyLong_SHIFT) { lla = (PY_LONG_LONG) (((((((unsigned PY_LONG_LONG)digits[2]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0])); goto long_long; #endif } case -4: if (8 * sizeof(long) - 1 > 4 * PyLong_SHIFT) { a = -(long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])); break; #ifdef HAVE_LONG_LONG } else if (8 * sizeof(PY_LONG_LONG) - 1 > 4 * PyLong_SHIFT) { lla = -(PY_LONG_LONG) (((((((((unsigned PY_LONG_LONG)digits[3]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[2]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0])); goto long_long; #endif } case 4: if (8 * sizeof(long) - 1 > 4 * PyLong_SHIFT) { a = (long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])); break; #ifdef HAVE_LONG_LONG } else if (8 * sizeof(PY_LONG_LONG) - 1 > 4 * PyLong_SHIFT) { lla = (PY_LONG_LONG) (((((((((unsigned PY_LONG_LONG)digits[3]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[2]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0])); goto long_long; #endif } default: return PyLong_Type.tp_as_number->nb_add(op1, op2); } } x = a + b; return PyLong_FromLong(x); #ifdef HAVE_LONG_LONG long_long: llx = lla + llb; return PyLong_FromLongLong(llx); #endif } #endif if (PyFloat_CheckExact(op1)) { const long b = intval; double a = PyFloat_AS_DOUBLE(op1); double result; PyFPE_START_PROTECT("add", return NULL) result = ((double)a) + (double)b; PyFPE_END_PROTECT(result) return PyFloat_FromDouble(result); } return (inplace ? PyNumber_InPlaceAdd : PyNumber_Add)(op1, op2); } #endif /* unicode_tailmatch */ static int __Pyx_PyUnicode_TailmatchTuple(PyObject* s, PyObject* substrings, Py_ssize_t start, Py_ssize_t end, int direction) { Py_ssize_t i, count = PyTuple_GET_SIZE(substrings); for (i = 0; i < count; i++) { Py_ssize_t result; #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS result = PyUnicode_Tailmatch(s, PyTuple_GET_ITEM(substrings, i), start, end, direction); #else PyObject* sub = PySequence_ITEM(substrings, i); if (unlikely(!sub)) return -1; result = PyUnicode_Tailmatch(s, sub, start, end, direction); Py_DECREF(sub); #endif if (result) { return (int) result; } } return 0; } static int __Pyx_PyUnicode_Tailmatch(PyObject* s, PyObject* substr, Py_ssize_t start, Py_ssize_t end, int direction) { if (unlikely(PyTuple_Check(substr))) { return __Pyx_PyUnicode_TailmatchTuple(s, substr, start, end, direction); } return (int) PyUnicode_Tailmatch(s, substr, start, end, direction); } /* bytes_tailmatch */ static int __Pyx_PyBytes_SingleTailmatch(PyObject* self, PyObject* arg, Py_ssize_t start, Py_ssize_t end, int direction) { const char* self_ptr = PyBytes_AS_STRING(self); Py_ssize_t self_len = PyBytes_GET_SIZE(self); const char* sub_ptr; Py_ssize_t sub_len; int retval; Py_buffer view; view.obj = NULL; if ( PyBytes_Check(arg) ) { sub_ptr = PyBytes_AS_STRING(arg); sub_len = PyBytes_GET_SIZE(arg); } #if PY_MAJOR_VERSION < 3 else if ( PyUnicode_Check(arg) ) { return (int) PyUnicode_Tailmatch(self, arg, start, end, direction); } #endif else { if (unlikely(PyObject_GetBuffer(self, &view, PyBUF_SIMPLE) == -1)) return -1; sub_ptr = (const char*) view.buf; sub_len = view.len; } if (end > self_len) end = self_len; else if (end < 0) end += self_len; if (end < 0) end = 0; if (start < 0) start += self_len; if (start < 0) start = 0; if (direction > 0) { if (end-sub_len > start) start = end - sub_len; } if (start + sub_len <= end) retval = !memcmp(self_ptr+start, sub_ptr, (size_t)sub_len); else retval = 0; if (view.obj) PyBuffer_Release(&view); return retval; } static int __Pyx_PyBytes_TailmatchTuple(PyObject* self, PyObject* substrings, Py_ssize_t start, Py_ssize_t end, int direction) { Py_ssize_t i, count = PyTuple_GET_SIZE(substrings); for (i = 0; i < count; i++) { int result; #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS result = __Pyx_PyBytes_SingleTailmatch(self, PyTuple_GET_ITEM(substrings, i), start, end, direction); #else PyObject* sub = PySequence_ITEM(substrings, i); if (unlikely(!sub)) return -1; result = __Pyx_PyBytes_SingleTailmatch(self, sub, start, end, direction); Py_DECREF(sub); #endif if (result) { return result; } } return 0; } static int __Pyx_PyBytes_Tailmatch(PyObject* self, PyObject* substr, Py_ssize_t start, Py_ssize_t end, int direction) { if (unlikely(PyTuple_Check(substr))) { return __Pyx_PyBytes_TailmatchTuple(self, substr, start, end, direction); } return __Pyx_PyBytes_SingleTailmatch(self, substr, start, end, direction); } /* ExtTypeTest */ static CYTHON_INLINE int __Pyx_TypeTest(PyObject *obj, PyTypeObject *type) { if (unlikely(!type)) { PyErr_SetString(PyExc_SystemError, "Missing type object"); return 0; } if (likely(__Pyx_TypeCheck(obj, type))) return 1; PyErr_Format(PyExc_TypeError, "Cannot convert %.200s to %.200s", Py_TYPE(obj)->tp_name, type->tp_name); return 0; } /* ArgTypeTest */ static int __Pyx__ArgTypeTest(PyObject *obj, PyTypeObject *type, const char *name, int exact) { if (unlikely(!type)) { PyErr_SetString(PyExc_SystemError, "Missing type object"); return 0; } else if (exact) { #if PY_MAJOR_VERSION == 2 if ((type == &PyBaseString_Type) && likely(__Pyx_PyBaseString_CheckExact(obj))) return 1; #endif } else { if (likely(__Pyx_TypeCheck(obj, type))) return 1; } PyErr_Format(PyExc_TypeError, "Argument '%.200s' has incorrect type (expected %.200s, got %.200s)", name, type->tp_name, Py_TYPE(obj)->tp_name); return 0; } /* GetAttr */ static CYTHON_INLINE PyObject *__Pyx_GetAttr(PyObject *o, PyObject *n) { #if CYTHON_USE_TYPE_SLOTS #if PY_MAJOR_VERSION >= 3 if (likely(PyUnicode_Check(n))) #else if (likely(PyString_Check(n))) #endif return __Pyx_PyObject_GetAttrStr(o, n); #endif return PyObject_GetAttr(o, n); } /* HasAttr */ static CYTHON_INLINE int __Pyx_HasAttr(PyObject *o, PyObject *n) { PyObject *r; if (unlikely(!__Pyx_PyBaseString_Check(n))) { PyErr_SetString(PyExc_TypeError, "hasattr(): attribute name must be string"); return -1; } r = __Pyx_GetAttr(o, n); if (unlikely(!r)) { PyErr_Clear(); return 0; } else { Py_DECREF(r); return 1; } } /* PyObjectCallMethod1 */ static PyObject* __Pyx__PyObject_CallMethod1(PyObject* method, PyObject* arg) { PyObject *result = NULL; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(method))) { PyObject *self = PyMethod_GET_SELF(method); if (likely(self)) { PyObject *args; PyObject *function = PyMethod_GET_FUNCTION(method); #if CYTHON_FAST_PYCALL if (PyFunction_Check(function)) { PyObject *args[2] = {self, arg}; result = __Pyx_PyFunction_FastCall(function, args, 2); goto done; } #endif #if CYTHON_FAST_PYCCALL if (__Pyx_PyFastCFunction_Check(function)) { PyObject *args[2] = {self, arg}; result = __Pyx_PyCFunction_FastCall(function, args, 2); goto done; } #endif args = PyTuple_New(2); if (unlikely(!args)) goto done; Py_INCREF(self); PyTuple_SET_ITEM(args, 0, self); Py_INCREF(arg); PyTuple_SET_ITEM(args, 1, arg); Py_INCREF(function); result = __Pyx_PyObject_Call(function, args, NULL); Py_DECREF(args); Py_DECREF(function); return result; } } #endif result = __Pyx_PyObject_CallOneArg(method, arg); goto done; done: return result; } static PyObject* __Pyx_PyObject_CallMethod1(PyObject* obj, PyObject* method_name, PyObject* arg) { PyObject *method, *result = NULL; method = __Pyx_PyObject_GetAttrStr(obj, method_name); if (unlikely(!method)) goto done; result = __Pyx__PyObject_CallMethod1(method, arg); done: Py_XDECREF(method); return result; } /* append */ static CYTHON_INLINE int __Pyx_PyObject_Append(PyObject* L, PyObject* x) { if (likely(PyList_CheckExact(L))) { if (unlikely(__Pyx_PyList_Append(L, x) < 0)) return -1; } else { PyObject* retval = __Pyx_PyObject_CallMethod1(L, __pyx_n_s_append, x); if (unlikely(!retval)) return -1; Py_DECREF(retval); } return 0; } /* UnpackUnboundCMethod */ static int __Pyx_TryUnpackUnboundCMethod(__Pyx_CachedCFunction* target) { PyObject *method; method = __Pyx_PyObject_GetAttrStr(target->type, *target->method_name); if (unlikely(!method)) return -1; target->method = method; #if CYTHON_COMPILING_IN_CPYTHON #if PY_MAJOR_VERSION >= 3 if (likely(__Pyx_TypeCheck(method, &PyMethodDescr_Type))) #endif { PyMethodDescrObject *descr = (PyMethodDescrObject*) method; target->func = descr->d_method->ml_meth; target->flag = descr->d_method->ml_flags & ~(METH_CLASS | METH_STATIC | METH_COEXIST); } #endif return 0; } /* CallUnboundCMethod0 */ static PyObject* __Pyx__CallUnboundCMethod0(__Pyx_CachedCFunction* cfunc, PyObject* self) { PyObject *args, *result = NULL; if (unlikely(!cfunc->method) && unlikely(__Pyx_TryUnpackUnboundCMethod(cfunc) < 0)) return NULL; #if CYTHON_ASSUME_SAFE_MACROS args = PyTuple_New(1); if (unlikely(!args)) goto bad; Py_INCREF(self); PyTuple_SET_ITEM(args, 0, self); #else args = PyTuple_Pack(1, self); if (unlikely(!args)) goto bad; #endif result = __Pyx_PyObject_Call(cfunc->method, args, NULL); Py_DECREF(args); bad: return result; } /* pop */ static CYTHON_INLINE PyObject* __Pyx__PyObject_Pop(PyObject* L) { if (Py_TYPE(L) == &PySet_Type) { return PySet_Pop(L); } return __Pyx_PyObject_CallMethod0(L, __pyx_n_s_pop); } #if CYTHON_USE_PYLIST_INTERNALS && CYTHON_ASSUME_SAFE_MACROS static CYTHON_INLINE PyObject* __Pyx_PyList_Pop(PyObject* L) { if (likely(PyList_GET_SIZE(L) > (((PyListObject*)L)->allocated >> 1))) { Py_SIZE(L) -= 1; return PyList_GET_ITEM(L, PyList_GET_SIZE(L)); } return __Pyx_CallUnboundCMethod0(&__pyx_umethod_PyList_Type_pop, L); } #endif /* IterNext */ static PyObject *__Pyx_PyIter_Next2Default(PyObject* defval) { PyObject* exc_type; __Pyx_PyThreadState_declare __Pyx_PyThreadState_assign exc_type = __Pyx_PyErr_Occurred(); if (unlikely(exc_type)) { if (unlikely(!__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) return NULL; if (defval) { __Pyx_PyErr_Clear(); Py_INCREF(defval); } return defval; } if (defval) { Py_INCREF(defval); return defval; } __Pyx_PyErr_SetNone(PyExc_StopIteration); return NULL; } static void __Pyx_PyIter_Next_ErrorNoIterator(PyObject *iterator) { PyErr_Format(PyExc_TypeError, "%.200s object is not an iterator", Py_TYPE(iterator)->tp_name); } static CYTHON_INLINE PyObject *__Pyx_PyIter_Next2(PyObject* iterator, PyObject* defval) { PyObject* next; iternextfunc iternext = Py_TYPE(iterator)->tp_iternext; if (likely(iternext)) { #if CYTHON_USE_TYPE_SLOTS next = iternext(iterator); if (likely(next)) return next; #if PY_VERSION_HEX >= 0x02070000 if (unlikely(iternext == &_PyObject_NextNotImplemented)) return NULL; #endif #else next = PyIter_Next(iterator); if (likely(next)) return next; #endif } else if (CYTHON_USE_TYPE_SLOTS || !PyIter_Check(iterator)) { __Pyx_PyIter_Next_ErrorNoIterator(iterator); return NULL; } return __Pyx_PyIter_Next2Default(defval); } /* SetupReduce */ static int __Pyx_setup_reduce_is_named(PyObject* meth, PyObject* name) { int ret; PyObject *name_attr; name_attr = __Pyx_PyObject_GetAttrStr(meth, __pyx_n_s_name); if (likely(name_attr)) { ret = PyObject_RichCompareBool(name_attr, name, Py_EQ); } else { ret = -1; } if (unlikely(ret < 0)) { PyErr_Clear(); ret = 0; } Py_XDECREF(name_attr); return ret; } static int __Pyx_setup_reduce(PyObject* type_obj) { int ret = 0; PyObject *object_reduce = NULL; PyObject *object_reduce_ex = NULL; PyObject *reduce = NULL; PyObject *reduce_ex = NULL; PyObject *reduce_cython = NULL; PyObject *setstate = NULL; PyObject *setstate_cython = NULL; #if CYTHON_USE_PYTYPE_LOOKUP if (_PyType_Lookup((PyTypeObject*)type_obj, __pyx_n_s_getstate)) goto GOOD; #else if (PyObject_HasAttr(type_obj, __pyx_n_s_getstate)) goto GOOD; #endif #if CYTHON_USE_PYTYPE_LOOKUP object_reduce_ex = _PyType_Lookup(&PyBaseObject_Type, __pyx_n_s_reduce_ex); if (!object_reduce_ex) goto BAD; #else object_reduce_ex = __Pyx_PyObject_GetAttrStr((PyObject*)&PyBaseObject_Type, __pyx_n_s_reduce_ex); if (!object_reduce_ex) goto BAD; #endif reduce_ex = __Pyx_PyObject_GetAttrStr(type_obj, __pyx_n_s_reduce_ex); if (unlikely(!reduce_ex)) goto BAD; if (reduce_ex == object_reduce_ex) { #if CYTHON_USE_PYTYPE_LOOKUP object_reduce = _PyType_Lookup(&PyBaseObject_Type, __pyx_n_s_reduce); if (!object_reduce) goto BAD; #else object_reduce = __Pyx_PyObject_GetAttrStr((PyObject*)&PyBaseObject_Type, __pyx_n_s_reduce); if (!object_reduce) goto BAD; #endif reduce = __Pyx_PyObject_GetAttrStr(type_obj, __pyx_n_s_reduce); if (unlikely(!reduce)) goto BAD; if (reduce == object_reduce || __Pyx_setup_reduce_is_named(reduce, __pyx_n_s_reduce_cython)) { reduce_cython = __Pyx_PyObject_GetAttrStr(type_obj, __pyx_n_s_reduce_cython); if (unlikely(!reduce_cython)) goto BAD; ret = PyDict_SetItem(((PyTypeObject*)type_obj)->tp_dict, __pyx_n_s_reduce, reduce_cython); if (unlikely(ret < 0)) goto BAD; ret = PyDict_DelItem(((PyTypeObject*)type_obj)->tp_dict, __pyx_n_s_reduce_cython); if (unlikely(ret < 0)) goto BAD; setstate = __Pyx_PyObject_GetAttrStr(type_obj, __pyx_n_s_setstate); if (!setstate) PyErr_Clear(); if (!setstate || __Pyx_setup_reduce_is_named(setstate, __pyx_n_s_setstate_cython)) { setstate_cython = __Pyx_PyObject_GetAttrStr(type_obj, __pyx_n_s_setstate_cython); if (unlikely(!setstate_cython)) goto BAD; ret = PyDict_SetItem(((PyTypeObject*)type_obj)->tp_dict, __pyx_n_s_setstate, setstate_cython); if (unlikely(ret < 0)) goto BAD; ret = PyDict_DelItem(((PyTypeObject*)type_obj)->tp_dict, __pyx_n_s_setstate_cython); if (unlikely(ret < 0)) goto BAD; } PyType_Modified((PyTypeObject*)type_obj); } } goto GOOD; BAD: if (!PyErr_Occurred()) PyErr_Format(PyExc_RuntimeError, "Unable to initialize pickling for %s", ((PyTypeObject*)type_obj)->tp_name); ret = -1; GOOD: #if !CYTHON_USE_PYTYPE_LOOKUP Py_XDECREF(object_reduce); Py_XDECREF(object_reduce_ex); #endif Py_XDECREF(reduce); Py_XDECREF(reduce_ex); Py_XDECREF(reduce_cython); Py_XDECREF(setstate); Py_XDECREF(setstate_cython); return ret; } /* SetVTable */ static int __Pyx_SetVtable(PyObject *dict, void *vtable) { #if PY_VERSION_HEX >= 0x02070000 PyObject *ob = PyCapsule_New(vtable, 0, 0); #else PyObject *ob = PyCObject_FromVoidPtr(vtable, 0); #endif if (!ob) goto bad; if (PyDict_SetItem(dict, __pyx_n_s_pyx_vtable, ob) < 0) goto bad; Py_DECREF(ob); return 0; bad: Py_XDECREF(ob); return -1; } /* Import */ static PyObject *__Pyx_Import(PyObject *name, PyObject *from_list, int level) { PyObject *empty_list = 0; PyObject *module = 0; PyObject *global_dict = 0; PyObject *empty_dict = 0; PyObject *list; #if PY_MAJOR_VERSION < 3 PyObject *py_import; py_import = __Pyx_PyObject_GetAttrStr(__pyx_b, __pyx_n_s_import); if (!py_import) goto bad; #endif if (from_list) list = from_list; else { empty_list = PyList_New(0); if (!empty_list) goto bad; list = empty_list; } global_dict = PyModule_GetDict(__pyx_m); if (!global_dict) goto bad; empty_dict = PyDict_New(); if (!empty_dict) goto bad; { #if PY_MAJOR_VERSION >= 3 if (level == -1) { if (strchr(__Pyx_MODULE_NAME, '.')) { module = PyImport_ImportModuleLevelObject( name, global_dict, empty_dict, list, 1); if (!module) { if (!PyErr_ExceptionMatches(PyExc_ImportError)) goto bad; PyErr_Clear(); } } level = 0; } #endif if (!module) { #if PY_MAJOR_VERSION < 3 PyObject *py_level = PyInt_FromLong(level); if (!py_level) goto bad; module = PyObject_CallFunctionObjArgs(py_import, name, global_dict, empty_dict, list, py_level, NULL); Py_DECREF(py_level); #else module = PyImport_ImportModuleLevelObject( name, global_dict, empty_dict, list, level); #endif } } bad: #if PY_MAJOR_VERSION < 3 Py_XDECREF(py_import); #endif Py_XDECREF(empty_list); Py_XDECREF(empty_dict); return module; } /* ImportFrom */ static PyObject* __Pyx_ImportFrom(PyObject* module, PyObject* name) { PyObject* value = __Pyx_PyObject_GetAttrStr(module, name); if (unlikely(!value) && PyErr_ExceptionMatches(PyExc_AttributeError)) { PyErr_Format(PyExc_ImportError, #if PY_MAJOR_VERSION < 3 "cannot import name %.230s", PyString_AS_STRING(name)); #else "cannot import name %S", name); #endif } return value; } /* CalculateMetaclass */ static PyObject *__Pyx_CalculateMetaclass(PyTypeObject *metaclass, PyObject *bases) { Py_ssize_t i, nbases = PyTuple_GET_SIZE(bases); for (i=0; i < nbases; i++) { PyTypeObject *tmptype; PyObject *tmp = PyTuple_GET_ITEM(bases, i); tmptype = Py_TYPE(tmp); #if PY_MAJOR_VERSION < 3 if (tmptype == &PyClass_Type) continue; #endif if (!metaclass) { metaclass = tmptype; continue; } if (PyType_IsSubtype(metaclass, tmptype)) continue; if (PyType_IsSubtype(tmptype, metaclass)) { metaclass = tmptype; continue; } PyErr_SetString(PyExc_TypeError, "metaclass conflict: " "the metaclass of a derived class " "must be a (non-strict) subclass " "of the metaclasses of all its bases"); return NULL; } if (!metaclass) { #if PY_MAJOR_VERSION < 3 metaclass = &PyClass_Type; #else metaclass = &PyType_Type; #endif } Py_INCREF((PyObject*) metaclass); return (PyObject*) metaclass; } /* Py3ClassCreate */ static PyObject *__Pyx_Py3MetaclassPrepare(PyObject *metaclass, PyObject *bases, PyObject *name, PyObject *qualname, PyObject *mkw, PyObject *modname, PyObject *doc) { PyObject *ns; if (metaclass) { PyObject *prep = __Pyx_PyObject_GetAttrStr(metaclass, __pyx_n_s_prepare); if (prep) { PyObject *pargs = PyTuple_Pack(2, name, bases); if (unlikely(!pargs)) { Py_DECREF(prep); return NULL; } ns = PyObject_Call(prep, pargs, mkw); Py_DECREF(prep); Py_DECREF(pargs); } else { if (unlikely(!PyErr_ExceptionMatches(PyExc_AttributeError))) return NULL; PyErr_Clear(); ns = PyDict_New(); } } else { ns = PyDict_New(); } if (unlikely(!ns)) return NULL; if (unlikely(PyObject_SetItem(ns, __pyx_n_s_module, modname) < 0)) goto bad; if (unlikely(PyObject_SetItem(ns, __pyx_n_s_qualname, qualname) < 0)) goto bad; if (unlikely(doc && PyObject_SetItem(ns, __pyx_n_s_doc, doc) < 0)) goto bad; return ns; bad: Py_DECREF(ns); return NULL; } static PyObject *__Pyx_Py3ClassCreate(PyObject *metaclass, PyObject *name, PyObject *bases, PyObject *dict, PyObject *mkw, int calculate_metaclass, int allow_py2_metaclass) { PyObject *result, *margs; PyObject *owned_metaclass = NULL; if (allow_py2_metaclass) { owned_metaclass = PyObject_GetItem(dict, __pyx_n_s_metaclass); if (owned_metaclass) { metaclass = owned_metaclass; } else if (likely(PyErr_ExceptionMatches(PyExc_KeyError))) { PyErr_Clear(); } else { return NULL; } } if (calculate_metaclass && (!metaclass || PyType_Check(metaclass))) { metaclass = __Pyx_CalculateMetaclass((PyTypeObject*) metaclass, bases); Py_XDECREF(owned_metaclass); if (unlikely(!metaclass)) return NULL; owned_metaclass = metaclass; } margs = PyTuple_Pack(3, name, bases, dict); if (unlikely(!margs)) { result = NULL; } else { result = PyObject_Call(metaclass, margs, mkw); Py_DECREF(margs); } Py_XDECREF(owned_metaclass); return result; } /* CLineInTraceback */ #ifndef CYTHON_CLINE_IN_TRACEBACK static int __Pyx_CLineForTraceback(CYTHON_UNUSED PyThreadState *tstate, int c_line) { PyObject *use_cline; PyObject *ptype, *pvalue, *ptraceback; #if CYTHON_COMPILING_IN_CPYTHON PyObject **cython_runtime_dict; #endif __Pyx_ErrFetchInState(tstate, &ptype, &pvalue, &ptraceback); #if CYTHON_COMPILING_IN_CPYTHON cython_runtime_dict = _PyObject_GetDictPtr(__pyx_cython_runtime); if (likely(cython_runtime_dict)) { use_cline = PyDict_GetItem(*cython_runtime_dict, __pyx_n_s_cline_in_traceback); } else #endif { PyObject *use_cline_obj = __Pyx_PyObject_GetAttrStr(__pyx_cython_runtime, __pyx_n_s_cline_in_traceback); if (use_cline_obj) { use_cline = PyObject_Not(use_cline_obj) ? Py_False : Py_True; Py_DECREF(use_cline_obj); } else { PyErr_Clear(); use_cline = NULL; } } if (!use_cline) { c_line = 0; PyObject_SetAttr(__pyx_cython_runtime, __pyx_n_s_cline_in_traceback, Py_False); } else if (PyObject_Not(use_cline) != 0) { c_line = 0; } __Pyx_ErrRestoreInState(tstate, ptype, pvalue, ptraceback); return c_line; } #endif /* CodeObjectCache */ static int __pyx_bisect_code_objects(__Pyx_CodeObjectCacheEntry* entries, int count, int code_line) { int start = 0, mid = 0, end = count - 1; if (end >= 0 && code_line > entries[end].code_line) { return count; } while (start < end) { mid = start + (end - start) / 2; if (code_line < entries[mid].code_line) { end = mid; } else if (code_line > entries[mid].code_line) { start = mid + 1; } else { return mid; } } if (code_line <= entries[mid].code_line) { return mid; } else { return mid + 1; } } static PyCodeObject *__pyx_find_code_object(int code_line) { PyCodeObject* code_object; int pos; if (unlikely(!code_line) || unlikely(!__pyx_code_cache.entries)) { return NULL; } pos = __pyx_bisect_code_objects(__pyx_code_cache.entries, __pyx_code_cache.count, code_line); if (unlikely(pos >= __pyx_code_cache.count) || unlikely(__pyx_code_cache.entries[pos].code_line != code_line)) { return NULL; } code_object = __pyx_code_cache.entries[pos].code_object; Py_INCREF(code_object); return code_object; } static void __pyx_insert_code_object(int code_line, PyCodeObject* code_object) { int pos, i; __Pyx_CodeObjectCacheEntry* entries = __pyx_code_cache.entries; if (unlikely(!code_line)) { return; } if (unlikely(!entries)) { entries = (__Pyx_CodeObjectCacheEntry*)PyMem_Malloc(64*sizeof(__Pyx_CodeObjectCacheEntry)); if (likely(entries)) { __pyx_code_cache.entries = entries; __pyx_code_cache.max_count = 64; __pyx_code_cache.count = 1; entries[0].code_line = code_line; entries[0].code_object = code_object; Py_INCREF(code_object); } return; } pos = __pyx_bisect_code_objects(__pyx_code_cache.entries, __pyx_code_cache.count, code_line); if ((pos < __pyx_code_cache.count) && unlikely(__pyx_code_cache.entries[pos].code_line == code_line)) { PyCodeObject* tmp = entries[pos].code_object; entries[pos].code_object = code_object; Py_DECREF(tmp); return; } if (__pyx_code_cache.count == __pyx_code_cache.max_count) { int new_max = __pyx_code_cache.max_count + 64; entries = (__Pyx_CodeObjectCacheEntry*)PyMem_Realloc( __pyx_code_cache.entries, (size_t)new_max*sizeof(__Pyx_CodeObjectCacheEntry)); if (unlikely(!entries)) { return; } __pyx_code_cache.entries = entries; __pyx_code_cache.max_count = new_max; } for (i=__pyx_code_cache.count; i>pos; i--) { entries[i] = entries[i-1]; } entries[pos].code_line = code_line; entries[pos].code_object = code_object; __pyx_code_cache.count++; Py_INCREF(code_object); } /* AddTraceback */ #include "compile.h" #include "frameobject.h" #include "traceback.h" static PyCodeObject* __Pyx_CreateCodeObjectForTraceback( const char *funcname, int c_line, int py_line, const char *filename) { PyCodeObject *py_code = 0; PyObject *py_srcfile = 0; PyObject *py_funcname = 0; #if PY_MAJOR_VERSION < 3 py_srcfile = PyString_FromString(filename); #else py_srcfile = PyUnicode_FromString(filename); #endif if (!py_srcfile) goto bad; if (c_line) { #if PY_MAJOR_VERSION < 3 py_funcname = PyString_FromFormat( "%s (%s:%d)", funcname, __pyx_cfilenm, c_line); #else py_funcname = PyUnicode_FromFormat( "%s (%s:%d)", funcname, __pyx_cfilenm, c_line); #endif } else { #if PY_MAJOR_VERSION < 3 py_funcname = PyString_FromString(funcname); #else py_funcname = PyUnicode_FromString(funcname); #endif } if (!py_funcname) goto bad; py_code = __Pyx_PyCode_New( 0, 0, 0, 0, 0, __pyx_empty_bytes, /*PyObject *code,*/ __pyx_empty_tuple, /*PyObject *consts,*/ __pyx_empty_tuple, /*PyObject *names,*/ __pyx_empty_tuple, /*PyObject *varnames,*/ __pyx_empty_tuple, /*PyObject *freevars,*/ __pyx_empty_tuple, /*PyObject *cellvars,*/ py_srcfile, /*PyObject *filename,*/ py_funcname, /*PyObject *name,*/ py_line, __pyx_empty_bytes /*PyObject *lnotab*/ ); Py_DECREF(py_srcfile); Py_DECREF(py_funcname); return py_code; bad: Py_XDECREF(py_srcfile); Py_XDECREF(py_funcname); return NULL; } static void __Pyx_AddTraceback(const char *funcname, int c_line, int py_line, const char *filename) { PyCodeObject *py_code = 0; PyFrameObject *py_frame = 0; PyThreadState *tstate = __Pyx_PyThreadState_Current; if (c_line) { c_line = __Pyx_CLineForTraceback(tstate, c_line); } py_code = __pyx_find_code_object(c_line ? -c_line : py_line); if (!py_code) { py_code = __Pyx_CreateCodeObjectForTraceback( funcname, c_line, py_line, filename); if (!py_code) goto bad; __pyx_insert_code_object(c_line ? -c_line : py_line, py_code); } py_frame = PyFrame_New( tstate, /*PyThreadState *tstate,*/ py_code, /*PyCodeObject *code,*/ __pyx_d, /*PyObject *globals,*/ 0 /*PyObject *locals*/ ); if (!py_frame) goto bad; __Pyx_PyFrame_SetLineNumber(py_frame, py_line); PyTraceBack_Here(py_frame); bad: Py_XDECREF(py_code); Py_XDECREF(py_frame); } /* CIntFromPyVerify */ #define __PYX_VERIFY_RETURN_INT(target_type, func_type, func_value)\ __PYX__VERIFY_RETURN_INT(target_type, func_type, func_value, 0) #define __PYX_VERIFY_RETURN_INT_EXC(target_type, func_type, func_value)\ __PYX__VERIFY_RETURN_INT(target_type, func_type, func_value, 1) #define __PYX__VERIFY_RETURN_INT(target_type, func_type, func_value, exc)\ {\ func_type value = func_value;\ if (sizeof(target_type) < sizeof(func_type)) {\ if (unlikely(value != (func_type) (target_type) value)) {\ func_type zero = 0;\ if (exc && unlikely(value == (func_type)-1 && PyErr_Occurred()))\ return (target_type) -1;\ if (is_unsigned && unlikely(value < zero))\ goto raise_neg_overflow;\ else\ goto raise_overflow;\ }\ }\ return (target_type) value;\ } /* CIntToPy */ static CYTHON_INLINE PyObject* __Pyx_PyInt_From_long(long value) { const long neg_one = (long) -1, const_zero = (long) 0; const int is_unsigned = neg_one > const_zero; if (is_unsigned) { if (sizeof(long) < sizeof(long)) { return PyInt_FromLong((long) value); } else if (sizeof(long) <= sizeof(unsigned long)) { return PyLong_FromUnsignedLong((unsigned long) value); #ifdef HAVE_LONG_LONG } else if (sizeof(long) <= sizeof(unsigned PY_LONG_LONG)) { return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG) value); #endif } } else { if (sizeof(long) <= sizeof(long)) { return PyInt_FromLong((long) value); #ifdef HAVE_LONG_LONG } else if (sizeof(long) <= sizeof(PY_LONG_LONG)) { return PyLong_FromLongLong((PY_LONG_LONG) value); #endif } } { int one = 1; int little = (int)*(unsigned char *)&one; unsigned char *bytes = (unsigned char *)&value; return _PyLong_FromByteArray(bytes, sizeof(long), little, !is_unsigned); } } /* CIntToPy */ static CYTHON_INLINE PyObject* __Pyx_PyInt_From_int(int value) { const int neg_one = (int) -1, const_zero = (int) 0; const int is_unsigned = neg_one > const_zero; if (is_unsigned) { if (sizeof(int) < sizeof(long)) { return PyInt_FromLong((long) value); } else if (sizeof(int) <= sizeof(unsigned long)) { return PyLong_FromUnsignedLong((unsigned long) value); #ifdef HAVE_LONG_LONG } else if (sizeof(int) <= sizeof(unsigned PY_LONG_LONG)) { return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG) value); #endif } } else { if (sizeof(int) <= sizeof(long)) { return PyInt_FromLong((long) value); #ifdef HAVE_LONG_LONG } else if (sizeof(int) <= sizeof(PY_LONG_LONG)) { return PyLong_FromLongLong((PY_LONG_LONG) value); #endif } } { int one = 1; int little = (int)*(unsigned char *)&one; unsigned char *bytes = (unsigned char *)&value; return _PyLong_FromByteArray(bytes, sizeof(int), little, !is_unsigned); } } /* CIntFromPy */ static CYTHON_INLINE int __Pyx_PyInt_As_int(PyObject *x) { const int neg_one = (int) -1, const_zero = (int) 0; const int is_unsigned = neg_one > const_zero; #if PY_MAJOR_VERSION < 3 if (likely(PyInt_Check(x))) { if (sizeof(int) < sizeof(long)) { __PYX_VERIFY_RETURN_INT(int, long, PyInt_AS_LONG(x)) } else { long val = PyInt_AS_LONG(x); if (is_unsigned && unlikely(val < 0)) { goto raise_neg_overflow; } return (int) val; } } else #endif if (likely(PyLong_Check(x))) { if (is_unsigned) { #if CYTHON_USE_PYLONG_INTERNALS const digit* digits = ((PyLongObject*)x)->ob_digit; switch (Py_SIZE(x)) { case 0: return (int) 0; case 1: __PYX_VERIFY_RETURN_INT(int, digit, digits[0]) case 2: if (8 * sizeof(int) > 1 * PyLong_SHIFT) { if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) { __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if (8 * sizeof(int) >= 2 * PyLong_SHIFT) { return (int) (((((int)digits[1]) << PyLong_SHIFT) | (int)digits[0])); } } break; case 3: if (8 * sizeof(int) > 2 * PyLong_SHIFT) { if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) { __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if (8 * sizeof(int) >= 3 * PyLong_SHIFT) { return (int) (((((((int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])); } } break; case 4: if (8 * sizeof(int) > 3 * PyLong_SHIFT) { if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) { __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if (8 * sizeof(int) >= 4 * PyLong_SHIFT) { return (int) (((((((((int)digits[3]) << PyLong_SHIFT) | (int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])); } } break; } #endif #if CYTHON_COMPILING_IN_CPYTHON if (unlikely(Py_SIZE(x) < 0)) { goto raise_neg_overflow; } #else { int result = PyObject_RichCompareBool(x, Py_False, Py_LT); if (unlikely(result < 0)) return (int) -1; if (unlikely(result == 1)) goto raise_neg_overflow; } #endif if (sizeof(int) <= sizeof(unsigned long)) { __PYX_VERIFY_RETURN_INT_EXC(int, unsigned long, PyLong_AsUnsignedLong(x)) #ifdef HAVE_LONG_LONG } else if (sizeof(int) <= sizeof(unsigned PY_LONG_LONG)) { __PYX_VERIFY_RETURN_INT_EXC(int, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x)) #endif } } else { #if CYTHON_USE_PYLONG_INTERNALS const digit* digits = ((PyLongObject*)x)->ob_digit; switch (Py_SIZE(x)) { case 0: return (int) 0; case -1: __PYX_VERIFY_RETURN_INT(int, sdigit, (sdigit) (-(sdigit)digits[0])) case 1: __PYX_VERIFY_RETURN_INT(int, digit, +digits[0]) case -2: if (8 * sizeof(int) - 1 > 1 * PyLong_SHIFT) { if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) { __PYX_VERIFY_RETURN_INT(int, long, -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if (8 * sizeof(int) - 1 > 2 * PyLong_SHIFT) { return (int) (((int)-1)*(((((int)digits[1]) << PyLong_SHIFT) | (int)digits[0]))); } } break; case 2: if (8 * sizeof(int) > 1 * PyLong_SHIFT) { if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) { __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if (8 * sizeof(int) - 1 > 2 * PyLong_SHIFT) { return (int) ((((((int)digits[1]) << PyLong_SHIFT) | (int)digits[0]))); } } break; case -3: if (8 * sizeof(int) - 1 > 2 * PyLong_SHIFT) { if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) { __PYX_VERIFY_RETURN_INT(int, long, -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if (8 * sizeof(int) - 1 > 3 * PyLong_SHIFT) { return (int) (((int)-1)*(((((((int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0]))); } } break; case 3: if (8 * sizeof(int) > 2 * PyLong_SHIFT) { if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) { __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if (8 * sizeof(int) - 1 > 3 * PyLong_SHIFT) { return (int) ((((((((int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0]))); } } break; case -4: if (8 * sizeof(int) - 1 > 3 * PyLong_SHIFT) { if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) { __PYX_VERIFY_RETURN_INT(int, long, -(long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if (8 * sizeof(int) - 1 > 4 * PyLong_SHIFT) { return (int) (((int)-1)*(((((((((int)digits[3]) << PyLong_SHIFT) | (int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0]))); } } break; case 4: if (8 * sizeof(int) > 3 * PyLong_SHIFT) { if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) { __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if (8 * sizeof(int) - 1 > 4 * PyLong_SHIFT) { return (int) ((((((((((int)digits[3]) << PyLong_SHIFT) | (int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0]))); } } break; } #endif if (sizeof(int) <= sizeof(long)) { __PYX_VERIFY_RETURN_INT_EXC(int, long, PyLong_AsLong(x)) #ifdef HAVE_LONG_LONG } else if (sizeof(int) <= sizeof(PY_LONG_LONG)) { __PYX_VERIFY_RETURN_INT_EXC(int, PY_LONG_LONG, PyLong_AsLongLong(x)) #endif } } { #if CYTHON_COMPILING_IN_PYPY && !defined(_PyLong_AsByteArray) PyErr_SetString(PyExc_RuntimeError, "_PyLong_AsByteArray() not available in PyPy, cannot convert large numbers"); #else int val; PyObject *v = __Pyx_PyNumber_IntOrLong(x); #if PY_MAJOR_VERSION < 3 if (likely(v) && !PyLong_Check(v)) { PyObject *tmp = v; v = PyNumber_Long(tmp); Py_DECREF(tmp); } #endif if (likely(v)) { int one = 1; int is_little = (int)*(unsigned char *)&one; unsigned char *bytes = (unsigned char *)&val; int ret = _PyLong_AsByteArray((PyLongObject *)v, bytes, sizeof(val), is_little, !is_unsigned); Py_DECREF(v); if (likely(!ret)) return val; } #endif return (int) -1; } } else { int val; PyObject *tmp = __Pyx_PyNumber_IntOrLong(x); if (!tmp) return (int) -1; val = __Pyx_PyInt_As_int(tmp); Py_DECREF(tmp); return val; } raise_overflow: PyErr_SetString(PyExc_OverflowError, "value too large to convert to int"); return (int) -1; raise_neg_overflow: PyErr_SetString(PyExc_OverflowError, "can't convert negative value to int"); return (int) -1; } /* CIntFromPy */ static CYTHON_INLINE size_t __Pyx_PyInt_As_size_t(PyObject *x) { const size_t neg_one = (size_t) -1, const_zero = (size_t) 0; const int is_unsigned = neg_one > const_zero; #if PY_MAJOR_VERSION < 3 if (likely(PyInt_Check(x))) { if (sizeof(size_t) < sizeof(long)) { __PYX_VERIFY_RETURN_INT(size_t, long, PyInt_AS_LONG(x)) } else { long val = PyInt_AS_LONG(x); if (is_unsigned && unlikely(val < 0)) { goto raise_neg_overflow; } return (size_t) val; } } else #endif if (likely(PyLong_Check(x))) { if (is_unsigned) { #if CYTHON_USE_PYLONG_INTERNALS const digit* digits = ((PyLongObject*)x)->ob_digit; switch (Py_SIZE(x)) { case 0: return (size_t) 0; case 1: __PYX_VERIFY_RETURN_INT(size_t, digit, digits[0]) case 2: if (8 * sizeof(size_t) > 1 * PyLong_SHIFT) { if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) { __PYX_VERIFY_RETURN_INT(size_t, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if (8 * sizeof(size_t) >= 2 * PyLong_SHIFT) { return (size_t) (((((size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0])); } } break; case 3: if (8 * sizeof(size_t) > 2 * PyLong_SHIFT) { if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) { __PYX_VERIFY_RETURN_INT(size_t, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if (8 * sizeof(size_t) >= 3 * PyLong_SHIFT) { return (size_t) (((((((size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0])); } } break; case 4: if (8 * sizeof(size_t) > 3 * PyLong_SHIFT) { if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) { __PYX_VERIFY_RETURN_INT(size_t, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if (8 * sizeof(size_t) >= 4 * PyLong_SHIFT) { return (size_t) (((((((((size_t)digits[3]) << PyLong_SHIFT) | (size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0])); } } break; } #endif #if CYTHON_COMPILING_IN_CPYTHON if (unlikely(Py_SIZE(x) < 0)) { goto raise_neg_overflow; } #else { int result = PyObject_RichCompareBool(x, Py_False, Py_LT); if (unlikely(result < 0)) return (size_t) -1; if (unlikely(result == 1)) goto raise_neg_overflow; } #endif if (sizeof(size_t) <= sizeof(unsigned long)) { __PYX_VERIFY_RETURN_INT_EXC(size_t, unsigned long, PyLong_AsUnsignedLong(x)) #ifdef HAVE_LONG_LONG } else if (sizeof(size_t) <= sizeof(unsigned PY_LONG_LONG)) { __PYX_VERIFY_RETURN_INT_EXC(size_t, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x)) #endif } } else { #if CYTHON_USE_PYLONG_INTERNALS const digit* digits = ((PyLongObject*)x)->ob_digit; switch (Py_SIZE(x)) { case 0: return (size_t) 0; case -1: __PYX_VERIFY_RETURN_INT(size_t, sdigit, (sdigit) (-(sdigit)digits[0])) case 1: __PYX_VERIFY_RETURN_INT(size_t, digit, +digits[0]) case -2: if (8 * sizeof(size_t) - 1 > 1 * PyLong_SHIFT) { if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) { __PYX_VERIFY_RETURN_INT(size_t, long, -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if (8 * sizeof(size_t) - 1 > 2 * PyLong_SHIFT) { return (size_t) (((size_t)-1)*(((((size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]))); } } break; case 2: if (8 * sizeof(size_t) > 1 * PyLong_SHIFT) { if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) { __PYX_VERIFY_RETURN_INT(size_t, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if (8 * sizeof(size_t) - 1 > 2 * PyLong_SHIFT) { return (size_t) ((((((size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]))); } } break; case -3: if (8 * sizeof(size_t) - 1 > 2 * PyLong_SHIFT) { if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) { __PYX_VERIFY_RETURN_INT(size_t, long, -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if (8 * sizeof(size_t) - 1 > 3 * PyLong_SHIFT) { return (size_t) (((size_t)-1)*(((((((size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]))); } } break; case 3: if (8 * sizeof(size_t) > 2 * PyLong_SHIFT) { if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) { __PYX_VERIFY_RETURN_INT(size_t, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if (8 * sizeof(size_t) - 1 > 3 * PyLong_SHIFT) { return (size_t) ((((((((size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]))); } } break; case -4: if (8 * sizeof(size_t) - 1 > 3 * PyLong_SHIFT) { if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) { __PYX_VERIFY_RETURN_INT(size_t, long, -(long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if (8 * sizeof(size_t) - 1 > 4 * PyLong_SHIFT) { return (size_t) (((size_t)-1)*(((((((((size_t)digits[3]) << PyLong_SHIFT) | (size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]))); } } break; case 4: if (8 * sizeof(size_t) > 3 * PyLong_SHIFT) { if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) { __PYX_VERIFY_RETURN_INT(size_t, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if (8 * sizeof(size_t) - 1 > 4 * PyLong_SHIFT) { return (size_t) ((((((((((size_t)digits[3]) << PyLong_SHIFT) | (size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]))); } } break; } #endif if (sizeof(size_t) <= sizeof(long)) { __PYX_VERIFY_RETURN_INT_EXC(size_t, long, PyLong_AsLong(x)) #ifdef HAVE_LONG_LONG } else if (sizeof(size_t) <= sizeof(PY_LONG_LONG)) { __PYX_VERIFY_RETURN_INT_EXC(size_t, PY_LONG_LONG, PyLong_AsLongLong(x)) #endif } } { #if CYTHON_COMPILING_IN_PYPY && !defined(_PyLong_AsByteArray) PyErr_SetString(PyExc_RuntimeError, "_PyLong_AsByteArray() not available in PyPy, cannot convert large numbers"); #else size_t val; PyObject *v = __Pyx_PyNumber_IntOrLong(x); #if PY_MAJOR_VERSION < 3 if (likely(v) && !PyLong_Check(v)) { PyObject *tmp = v; v = PyNumber_Long(tmp); Py_DECREF(tmp); } #endif if (likely(v)) { int one = 1; int is_little = (int)*(unsigned char *)&one; unsigned char *bytes = (unsigned char *)&val; int ret = _PyLong_AsByteArray((PyLongObject *)v, bytes, sizeof(val), is_little, !is_unsigned); Py_DECREF(v); if (likely(!ret)) return val; } #endif return (size_t) -1; } } else { size_t val; PyObject *tmp = __Pyx_PyNumber_IntOrLong(x); if (!tmp) return (size_t) -1; val = __Pyx_PyInt_As_size_t(tmp); Py_DECREF(tmp); return val; } raise_overflow: PyErr_SetString(PyExc_OverflowError, "value too large to convert to size_t"); return (size_t) -1; raise_neg_overflow: PyErr_SetString(PyExc_OverflowError, "can't convert negative value to size_t"); return (size_t) -1; } /* CIntFromPy */ static CYTHON_INLINE long __Pyx_PyInt_As_long(PyObject *x) { const long neg_one = (long) -1, const_zero = (long) 0; const int is_unsigned = neg_one > const_zero; #if PY_MAJOR_VERSION < 3 if (likely(PyInt_Check(x))) { if (sizeof(long) < sizeof(long)) { __PYX_VERIFY_RETURN_INT(long, long, PyInt_AS_LONG(x)) } else { long val = PyInt_AS_LONG(x); if (is_unsigned && unlikely(val < 0)) { goto raise_neg_overflow; } return (long) val; } } else #endif if (likely(PyLong_Check(x))) { if (is_unsigned) { #if CYTHON_USE_PYLONG_INTERNALS const digit* digits = ((PyLongObject*)x)->ob_digit; switch (Py_SIZE(x)) { case 0: return (long) 0; case 1: __PYX_VERIFY_RETURN_INT(long, digit, digits[0]) case 2: if (8 * sizeof(long) > 1 * PyLong_SHIFT) { if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) { __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if (8 * sizeof(long) >= 2 * PyLong_SHIFT) { return (long) (((((long)digits[1]) << PyLong_SHIFT) | (long)digits[0])); } } break; case 3: if (8 * sizeof(long) > 2 * PyLong_SHIFT) { if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) { __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if (8 * sizeof(long) >= 3 * PyLong_SHIFT) { return (long) (((((((long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])); } } break; case 4: if (8 * sizeof(long) > 3 * PyLong_SHIFT) { if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) { __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if (8 * sizeof(long) >= 4 * PyLong_SHIFT) { return (long) (((((((((long)digits[3]) << PyLong_SHIFT) | (long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])); } } break; } #endif #if CYTHON_COMPILING_IN_CPYTHON if (unlikely(Py_SIZE(x) < 0)) { goto raise_neg_overflow; } #else { int result = PyObject_RichCompareBool(x, Py_False, Py_LT); if (unlikely(result < 0)) return (long) -1; if (unlikely(result == 1)) goto raise_neg_overflow; } #endif if (sizeof(long) <= sizeof(unsigned long)) { __PYX_VERIFY_RETURN_INT_EXC(long, unsigned long, PyLong_AsUnsignedLong(x)) #ifdef HAVE_LONG_LONG } else if (sizeof(long) <= sizeof(unsigned PY_LONG_LONG)) { __PYX_VERIFY_RETURN_INT_EXC(long, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x)) #endif } } else { #if CYTHON_USE_PYLONG_INTERNALS const digit* digits = ((PyLongObject*)x)->ob_digit; switch (Py_SIZE(x)) { case 0: return (long) 0; case -1: __PYX_VERIFY_RETURN_INT(long, sdigit, (sdigit) (-(sdigit)digits[0])) case 1: __PYX_VERIFY_RETURN_INT(long, digit, +digits[0]) case -2: if (8 * sizeof(long) - 1 > 1 * PyLong_SHIFT) { if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) { __PYX_VERIFY_RETURN_INT(long, long, -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) { return (long) (((long)-1)*(((((long)digits[1]) << PyLong_SHIFT) | (long)digits[0]))); } } break; case 2: if (8 * sizeof(long) > 1 * PyLong_SHIFT) { if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) { __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) { return (long) ((((((long)digits[1]) << PyLong_SHIFT) | (long)digits[0]))); } } break; case -3: if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) { if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) { __PYX_VERIFY_RETURN_INT(long, long, -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) { return (long) (((long)-1)*(((((((long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0]))); } } break; case 3: if (8 * sizeof(long) > 2 * PyLong_SHIFT) { if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) { __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) { return (long) ((((((((long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0]))); } } break; case -4: if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) { if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) { __PYX_VERIFY_RETURN_INT(long, long, -(long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if (8 * sizeof(long) - 1 > 4 * PyLong_SHIFT) { return (long) (((long)-1)*(((((((((long)digits[3]) << PyLong_SHIFT) | (long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0]))); } } break; case 4: if (8 * sizeof(long) > 3 * PyLong_SHIFT) { if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) { __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if (8 * sizeof(long) - 1 > 4 * PyLong_SHIFT) { return (long) ((((((((((long)digits[3]) << PyLong_SHIFT) | (long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0]))); } } break; } #endif if (sizeof(long) <= sizeof(long)) { __PYX_VERIFY_RETURN_INT_EXC(long, long, PyLong_AsLong(x)) #ifdef HAVE_LONG_LONG } else if (sizeof(long) <= sizeof(PY_LONG_LONG)) { __PYX_VERIFY_RETURN_INT_EXC(long, PY_LONG_LONG, PyLong_AsLongLong(x)) #endif } } { #if CYTHON_COMPILING_IN_PYPY && !defined(_PyLong_AsByteArray) PyErr_SetString(PyExc_RuntimeError, "_PyLong_AsByteArray() not available in PyPy, cannot convert large numbers"); #else long val; PyObject *v = __Pyx_PyNumber_IntOrLong(x); #if PY_MAJOR_VERSION < 3 if (likely(v) && !PyLong_Check(v)) { PyObject *tmp = v; v = PyNumber_Long(tmp); Py_DECREF(tmp); } #endif if (likely(v)) { int one = 1; int is_little = (int)*(unsigned char *)&one; unsigned char *bytes = (unsigned char *)&val; int ret = _PyLong_AsByteArray((PyLongObject *)v, bytes, sizeof(val), is_little, !is_unsigned); Py_DECREF(v); if (likely(!ret)) return val; } #endif return (long) -1; } } else { long val; PyObject *tmp = __Pyx_PyNumber_IntOrLong(x); if (!tmp) return (long) -1; val = __Pyx_PyInt_As_long(tmp); Py_DECREF(tmp); return val; } raise_overflow: PyErr_SetString(PyExc_OverflowError, "value too large to convert to long"); return (long) -1; raise_neg_overflow: PyErr_SetString(PyExc_OverflowError, "can't convert negative value to long"); return (long) -1; } /* FastTypeChecks */ #if CYTHON_COMPILING_IN_CPYTHON static int __Pyx_InBases(PyTypeObject *a, PyTypeObject *b) { while (a) { a = a->tp_base; if (a == b) return 1; } return b == &PyBaseObject_Type; } static CYTHON_INLINE int __Pyx_IsSubtype(PyTypeObject *a, PyTypeObject *b) { PyObject *mro; if (a == b) return 1; mro = a->tp_mro; if (likely(mro)) { Py_ssize_t i, n; n = PyTuple_GET_SIZE(mro); for (i = 0; i < n; i++) { if (PyTuple_GET_ITEM(mro, i) == (PyObject *)b) return 1; } return 0; } return __Pyx_InBases(a, b); } #if PY_MAJOR_VERSION == 2 static int __Pyx_inner_PyErr_GivenExceptionMatches2(PyObject *err, PyObject* exc_type1, PyObject* exc_type2) { PyObject *exception, *value, *tb; int res; __Pyx_PyThreadState_declare __Pyx_PyThreadState_assign __Pyx_ErrFetch(&exception, &value, &tb); res = exc_type1 ? PyObject_IsSubclass(err, exc_type1) : 0; if (unlikely(res == -1)) { PyErr_WriteUnraisable(err); res = 0; } if (!res) { res = PyObject_IsSubclass(err, exc_type2); if (unlikely(res == -1)) { PyErr_WriteUnraisable(err); res = 0; } } __Pyx_ErrRestore(exception, value, tb); return res; } #else static CYTHON_INLINE int __Pyx_inner_PyErr_GivenExceptionMatches2(PyObject *err, PyObject* exc_type1, PyObject *exc_type2) { int res = exc_type1 ? __Pyx_IsSubtype((PyTypeObject*)err, (PyTypeObject*)exc_type1) : 0; if (!res) { res = __Pyx_IsSubtype((PyTypeObject*)err, (PyTypeObject*)exc_type2); } return res; } #endif static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches(PyObject *err, PyObject* exc_type) { if (likely(err == exc_type)) return 1; if (likely(PyExceptionClass_Check(err))) { return __Pyx_inner_PyErr_GivenExceptionMatches2(err, NULL, exc_type); } return PyErr_GivenExceptionMatches(err, exc_type); } static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches2(PyObject *err, PyObject *exc_type1, PyObject *exc_type2) { if (likely(err == exc_type1 || err == exc_type2)) return 1; if (likely(PyExceptionClass_Check(err))) { return __Pyx_inner_PyErr_GivenExceptionMatches2(err, exc_type1, exc_type2); } return (PyErr_GivenExceptionMatches(err, exc_type1) || PyErr_GivenExceptionMatches(err, exc_type2)); } #endif /* CheckBinaryVersion */ static int __Pyx_check_binary_version(void) { char ctversion[4], rtversion[4]; PyOS_snprintf(ctversion, 4, "%d.%d", PY_MAJOR_VERSION, PY_MINOR_VERSION); PyOS_snprintf(rtversion, 4, "%s", Py_GetVersion()); if (ctversion[0] != rtversion[0] || ctversion[2] != rtversion[2]) { char message[200]; PyOS_snprintf(message, sizeof(message), "compiletime version %s of module '%.100s' " "does not match runtime version %s", ctversion, __Pyx_MODULE_NAME, rtversion); return PyErr_WarnEx(NULL, message, 1); } return 0; } /* ModuleImport */ #ifndef __PYX_HAVE_RT_ImportModule #define __PYX_HAVE_RT_ImportModule static PyObject *__Pyx_ImportModule(const char *name) { PyObject *py_name = 0; PyObject *py_module = 0; py_name = __Pyx_PyIdentifier_FromString(name); if (!py_name) goto bad; py_module = PyImport_Import(py_name); Py_DECREF(py_name); return py_module; bad: Py_XDECREF(py_name); return 0; } #endif /* TypeImport */ #ifndef __PYX_HAVE_RT_ImportType #define __PYX_HAVE_RT_ImportType static PyTypeObject *__Pyx_ImportType(const char *module_name, const char *class_name, size_t size, int strict) { PyObject *py_module = 0; PyObject *result = 0; PyObject *py_name = 0; char warning[200]; Py_ssize_t basicsize; #ifdef Py_LIMITED_API PyObject *py_basicsize; #endif py_module = __Pyx_ImportModule(module_name); if (!py_module) goto bad; py_name = __Pyx_PyIdentifier_FromString(class_name); if (!py_name) goto bad; result = PyObject_GetAttr(py_module, py_name); Py_DECREF(py_name); py_name = 0; Py_DECREF(py_module); py_module = 0; if (!result) goto bad; if (!PyType_Check(result)) { PyErr_Format(PyExc_TypeError, "%.200s.%.200s is not a type object", module_name, class_name); goto bad; } #ifndef Py_LIMITED_API basicsize = ((PyTypeObject *)result)->tp_basicsize; #else py_basicsize = PyObject_GetAttrString(result, "__basicsize__"); if (!py_basicsize) goto bad; basicsize = PyLong_AsSsize_t(py_basicsize); Py_DECREF(py_basicsize); py_basicsize = 0; if (basicsize == (Py_ssize_t)-1 && PyErr_Occurred()) goto bad; #endif if (!strict && (size_t)basicsize > size) { PyOS_snprintf(warning, sizeof(warning), "%s.%s size changed, may indicate binary incompatibility. Expected %zd, got %zd", module_name, class_name, basicsize, size); if (PyErr_WarnEx(NULL, warning, 0) < 0) goto bad; } else if ((size_t)basicsize != size) { PyErr_Format(PyExc_ValueError, "%.200s.%.200s has the wrong size, try recompiling. Expected %zd, got %zd", module_name, class_name, basicsize, size); goto bad; } return (PyTypeObject *)result; bad: Py_XDECREF(py_module); Py_XDECREF(result); return NULL; } #endif /* InitStrings */ static int __Pyx_InitStrings(__Pyx_StringTabEntry *t) { while (t->p) { #if PY_MAJOR_VERSION < 3 if (t->is_unicode) { *t->p = PyUnicode_DecodeUTF8(t->s, t->n - 1, NULL); } else if (t->intern) { *t->p = PyString_InternFromString(t->s); } else { *t->p = PyString_FromStringAndSize(t->s, t->n - 1); } #else if (t->is_unicode | t->is_str) { if (t->intern) { *t->p = PyUnicode_InternFromString(t->s); } else if (t->encoding) { *t->p = PyUnicode_Decode(t->s, t->n - 1, t->encoding, NULL); } else { *t->p = PyUnicode_FromStringAndSize(t->s, t->n - 1); } } else { *t->p = PyBytes_FromStringAndSize(t->s, t->n - 1); } #endif if (!*t->p) return -1; if (PyObject_Hash(*t->p) == -1) PyErr_Clear(); ++t; } return 0; } static CYTHON_INLINE PyObject* __Pyx_PyUnicode_FromString(const char* c_str) { return __Pyx_PyUnicode_FromStringAndSize(c_str, (Py_ssize_t)strlen(c_str)); } static CYTHON_INLINE const char* __Pyx_PyObject_AsString(PyObject* o) { Py_ssize_t ignore; return __Pyx_PyObject_AsStringAndSize(o, &ignore); } #if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII || __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT #if !CYTHON_PEP393_ENABLED static const char* __Pyx_PyUnicode_AsStringAndSize(PyObject* o, Py_ssize_t *length) { char* defenc_c; PyObject* defenc = _PyUnicode_AsDefaultEncodedString(o, NULL); if (!defenc) return NULL; defenc_c = PyBytes_AS_STRING(defenc); #if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII { char* end = defenc_c + PyBytes_GET_SIZE(defenc); char* c; for (c = defenc_c; c < end; c++) { if ((unsigned char) (*c) >= 128) { PyUnicode_AsASCIIString(o); return NULL; } } } #endif *length = PyBytes_GET_SIZE(defenc); return defenc_c; } #else static CYTHON_INLINE const char* __Pyx_PyUnicode_AsStringAndSize(PyObject* o, Py_ssize_t *length) { if (unlikely(__Pyx_PyUnicode_READY(o) == -1)) return NULL; #if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII if (likely(PyUnicode_IS_ASCII(o))) { *length = PyUnicode_GET_LENGTH(o); return PyUnicode_AsUTF8(o); } else { PyUnicode_AsASCIIString(o); return NULL; } #else return PyUnicode_AsUTF8AndSize(o, length); #endif } #endif #endif static CYTHON_INLINE const char* __Pyx_PyObject_AsStringAndSize(PyObject* o, Py_ssize_t *length) { #if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII || __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT if ( #if PY_MAJOR_VERSION < 3 && __PYX_DEFAULT_STRING_ENCODING_IS_ASCII __Pyx_sys_getdefaultencoding_not_ascii && #endif PyUnicode_Check(o)) { return __Pyx_PyUnicode_AsStringAndSize(o, length); } else #endif #if (!CYTHON_COMPILING_IN_PYPY) || (defined(PyByteArray_AS_STRING) && defined(PyByteArray_GET_SIZE)) if (PyByteArray_Check(o)) { *length = PyByteArray_GET_SIZE(o); return PyByteArray_AS_STRING(o); } else #endif { char* result; int r = PyBytes_AsStringAndSize(o, &result, length); if (unlikely(r < 0)) { return NULL; } else { return result; } } } static CYTHON_INLINE int __Pyx_PyObject_IsTrue(PyObject* x) { int is_true = x == Py_True; if (is_true | (x == Py_False) | (x == Py_None)) return is_true; else return PyObject_IsTrue(x); } static PyObject* __Pyx_PyNumber_IntOrLongWrongResultType(PyObject* result, const char* type_name) { #if PY_MAJOR_VERSION >= 3 if (PyLong_Check(result)) { if (PyErr_WarnFormat(PyExc_DeprecationWarning, 1, "__int__ returned non-int (type %.200s). " "The ability to return an instance of a strict subclass of int " "is deprecated, and may be removed in a future version of Python.", Py_TYPE(result)->tp_name)) { Py_DECREF(result); return NULL; } return result; } #endif PyErr_Format(PyExc_TypeError, "__%.4s__ returned non-%.4s (type %.200s)", type_name, type_name, Py_TYPE(result)->tp_name); Py_DECREF(result); return NULL; } static CYTHON_INLINE PyObject* __Pyx_PyNumber_IntOrLong(PyObject* x) { #if CYTHON_USE_TYPE_SLOTS PyNumberMethods *m; #endif const char *name = NULL; PyObject *res = NULL; #if PY_MAJOR_VERSION < 3 if (likely(PyInt_Check(x) || PyLong_Check(x))) #else if (likely(PyLong_Check(x))) #endif return __Pyx_NewRef(x); #if CYTHON_USE_TYPE_SLOTS m = Py_TYPE(x)->tp_as_number; #if PY_MAJOR_VERSION < 3 if (m && m->nb_int) { name = "int"; res = m->nb_int(x); } else if (m && m->nb_long) { name = "long"; res = m->nb_long(x); } #else if (likely(m && m->nb_int)) { name = "int"; res = m->nb_int(x); } #endif #else if (!PyBytes_CheckExact(x) && !PyUnicode_CheckExact(x)) { res = PyNumber_Int(x); } #endif if (likely(res)) { #if PY_MAJOR_VERSION < 3 if (unlikely(!PyInt_Check(res) && !PyLong_Check(res))) { #else if (unlikely(!PyLong_CheckExact(res))) { #endif return __Pyx_PyNumber_IntOrLongWrongResultType(res, name); } } else if (!PyErr_Occurred()) { PyErr_SetString(PyExc_TypeError, "an integer is required"); } return res; } static CYTHON_INLINE Py_ssize_t __Pyx_PyIndex_AsSsize_t(PyObject* b) { Py_ssize_t ival; PyObject *x; #if PY_MAJOR_VERSION < 3 if (likely(PyInt_CheckExact(b))) { if (sizeof(Py_ssize_t) >= sizeof(long)) return PyInt_AS_LONG(b); else return PyInt_AsSsize_t(x); } #endif if (likely(PyLong_CheckExact(b))) { #if CYTHON_USE_PYLONG_INTERNALS const digit* digits = ((PyLongObject*)b)->ob_digit; const Py_ssize_t size = Py_SIZE(b); if (likely(__Pyx_sst_abs(size) <= 1)) { ival = likely(size) ? digits[0] : 0; if (size == -1) ival = -ival; return ival; } else { switch (size) { case 2: if (8 * sizeof(Py_ssize_t) > 2 * PyLong_SHIFT) { return (Py_ssize_t) (((((size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0])); } break; case -2: if (8 * sizeof(Py_ssize_t) > 2 * PyLong_SHIFT) { return -(Py_ssize_t) (((((size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0])); } break; case 3: if (8 * sizeof(Py_ssize_t) > 3 * PyLong_SHIFT) { return (Py_ssize_t) (((((((size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0])); } break; case -3: if (8 * sizeof(Py_ssize_t) > 3 * PyLong_SHIFT) { return -(Py_ssize_t) (((((((size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0])); } break; case 4: if (8 * sizeof(Py_ssize_t) > 4 * PyLong_SHIFT) { return (Py_ssize_t) (((((((((size_t)digits[3]) << PyLong_SHIFT) | (size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0])); } break; case -4: if (8 * sizeof(Py_ssize_t) > 4 * PyLong_SHIFT) { return -(Py_ssize_t) (((((((((size_t)digits[3]) << PyLong_SHIFT) | (size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0])); } break; } } #endif return PyLong_AsSsize_t(b); } x = PyNumber_Index(b); if (!x) return -1; ival = PyInt_AsSsize_t(x); Py_DECREF(x); return ival; } static CYTHON_INLINE PyObject * __Pyx_PyInt_FromSize_t(size_t ival) { return PyInt_FromSize_t(ival); } #endif /* Py_PYTHON_H */ lupa-1.6/LICENSE.txt0000644000175000017500000000426713204640231014732 0ustar stefanstefan00000000000000License ======= Lupa ---- Copyright (c) 2010-2017 Stefan Behnel. All rights reserved. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. Lua --- (See https://www.lua.org/license.html) Copyright © 1994–2017 Lua.org, PUC-Rio. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. lupa-1.6/README.rst0000664000175000017500000007121612650713160014604 0ustar stefanstefan00000000000000Lupa ==== Lupa integrates the runtimes of Lua_ or LuaJIT2_ into CPython. It is a partial rewrite of LunaticPython_ in Cython_ with some additional features such as proper coroutine support. .. _Lua: http://lua.org/ .. _LuaJIT2: http://luajit.org/ .. _LunaticPython: http://labix.org/lunatic-python .. _Cython: http://cython.org For questions not answered here, please contact the `Lupa mailing list`_. .. _`Lupa mailing list`: http://www.freelists.org/list/lupa-dev .. contents:: :local: Major features -------------- * separate Lua runtime states through a ``LuaRuntime`` class * Python coroutine wrapper for Lua coroutines * iteration support for Python objects in Lua and Lua objects in Python * proper encoding and decoding of strings (configurable per runtime, UTF-8 by default) * frees the GIL and supports threading in separate runtimes when calling into Lua * tested with Python 2.6/3.2 and later * written for LuaJIT2 (tested with LuaJIT 2.0.2), but also works with the normal Lua interpreter (5.1 and 5.2) * easy to hack on and extend as it is written in Cython, not C Why the name? ------------- In Latin, "lupa" is a female wolf, as elegant and wild as it sounds. If you don't like this kind of straight forward allegory to an endangered species, you may also happily assume it's just an amalgamation of the phonetic sounds that start the words "Lua" and "Python", two from each to keep the balance. Why use it? ----------- It complements Python very well. Lua is a language as dynamic as Python, but LuaJIT compiles it to very fast machine code, sometimes faster than many statically compiled languages for computational code. The language runtime is very small and carefully designed for embedding. The complete binary module of Lupa, including a statically linked LuaJIT2 runtime, only weighs some 700KB on a 64 bit machine. With standard Lua 5.1, it's less than 400KB. However, the Lua ecosystem lacks many of the batteries that Python readily includes, either directly in its standard library or as third party packages. This makes real-world Lua applications harder to write than equivalent Python applications. Lua is therefore not commonly used as primary language for large applications, but it makes for a fast, high-level and resource-friendly backup language inside of Python when raw speed is required and the edit-compile-run cycle of binary extension modules is too heavy and too static for agile development or hot-deployment. Lupa is a very fast and thin wrapper around Lua or LuaJIT. It makes it easy to write dynamic Lua code that accompanies dynamic Python code by switching between the two languages at runtime, based on the tradeoff between simplicity and speed. Examples -------- .. ## doctest helpers: >>> try: _ = sorted ... except NameError: ... def sorted(seq): ... l = list(seq) ... l.sort() ... return l .. code:: python >>> import lupa >>> from lupa import LuaRuntime >>> lua = LuaRuntime(unpack_returned_tuples=True) >>> lua.eval('1+1') 2 >>> lua_func = lua.eval('function(f, n) return f(n) end') >>> def py_add1(n): return n+1 >>> lua_func(py_add1, 2) 3 >>> lua.eval('python.eval(" 2 ** 2 ")') == 4 True >>> lua.eval('python.builtins.str(4)') == '4' True The function ``lua_type(obj)`` can be used to find out the type of a wrapped Lua object in Python code, as provided by Lua's ``type()`` function: .. code:: python >>> lupa.lua_type(lua_func) 'function' >>> lupa.lua_type(lua.eval('{}')) 'table' To help in distinguishing between wrapped Lua objects and normal Python objects, it returns ``None`` for the latter: .. code:: python >>> lupa.lua_type(123) is None True >>> lupa.lua_type('abc') is None True >>> lupa.lua_type({}) is None True Note the flag ``unpack_returned_tuples=True`` that is passed to create the Lua runtime. It is new in Lupa 0.21 and changes the behaviour of tuples that get returned by Python functions. With this flag, they explode into separate Lua values: .. code:: python >>> lua.execute('a,b,c = python.eval("(1,2)")') >>> g = lua.globals() >>> g.a 1 >>> g.b 2 >>> g.c is None True When set to False, functions that return a tuple pass it through to the Lua code: .. code:: python >>> non_explode_lua = lupa.LuaRuntime(unpack_returned_tuples=False) >>> non_explode_lua.execute('a,b,c = python.eval("(1,2)")') >>> g = non_explode_lua.globals() >>> g.a (1, 2) >>> g.b is None True >>> g.c is None True Since the default behaviour (to not explode tuples) might change in a later version of Lupa, it is best to always pass this flag explicitly. Python objects in Lua --------------------- Python objects are either converted when passed into Lua (e.g. numbers and strings) or passed as wrapped object references. .. code:: python >>> wrapped_type = lua.globals().type # Lua's own type() function >>> wrapped_type(1) == 'number' True >>> wrapped_type('abc') == 'string' True Wrapped Lua objects get unwrapped when they are passed back into Lua, and arbitrary Python objects get wrapped in different ways: .. code:: python >>> wrapped_type(wrapped_type) == 'function' # unwrapped Lua function True >>> wrapped_type(len) == 'userdata' # wrapped Python function True >>> wrapped_type([]) == 'userdata' # wrapped Python object True Lua supports two main protocols on objects: calling and indexing. It does not distinguish between attribute access and item access like Python does, so the Lua operations ``obj[x]`` and ``obj.x`` both map to indexing. To decide which Python protocol to use for Lua wrapped objects, Lupa employs a simple heuristic. Pratically all Python objects allow attribute access, so if the object also has a ``__getitem__`` method, it is preferred when turning it into an indexable Lua object. Otherwise, it becomes a simple object that uses attribute access for indexing from inside Lua. Obviously, this heuristic will fail to provide the required behaviour in many cases, e.g. when attribute access is required to an object that happens to support item access. To be explicit about the protocol that should be used, Lupa provides the helper functions ``as_attrgetter()`` and ``as_itemgetter()`` that restrict the view on an object to a certain protocol, both from Python and from inside Lua: .. code:: python >>> lua_func = lua.eval('function(obj) return obj["get"] end') >>> d = {'get' : 'value'} >>> value = lua_func(d) >>> value == d['get'] == 'value' True >>> value = lua_func( lupa.as_itemgetter(d) ) >>> value == d['get'] == 'value' True >>> dict_get = lua_func( lupa.as_attrgetter(d) ) >>> dict_get == d.get True >>> dict_get('get') == d.get('get') == 'value' True >>> lua_func = lua.eval( ... 'function(obj) return python.as_attrgetter(obj)["get"] end') >>> dict_get = lua_func(d) >>> dict_get('get') == d.get('get') == 'value' True Note that unlike Lua function objects, callable Python objects support indexing in Lua: .. code:: python >>> def py_func(): pass >>> py_func.ATTR = 2 >>> lua_func = lua.eval('function(obj) return obj.ATTR end') >>> lua_func(py_func) 2 >>> lua_func = lua.eval( ... 'function(obj) return python.as_attrgetter(obj).ATTR end') >>> lua_func(py_func) 2 >>> lua_func = lua.eval( ... 'function(obj) return python.as_attrgetter(obj)["ATTR"] end') >>> lua_func(py_func) 2 Iteration in Lua ---------------- Iteration over Python objects from Lua's for-loop is fully supported. However, Python iterables need to be converted using one of the utility functions which are described here. This is similar to the functions like ``pairs()`` in Lua. To iterate over a plain Python iterable, use the ``python.iter()`` function. For example, you can manually copy a Python list into a Lua table like this: .. code:: python >>> lua_copy = lua.eval(''' ... function(L) ... local t, i = {}, 1 ... for item in python.iter(L) do ... t[i] = item ... i = i + 1 ... end ... return t ... end ... ''') >>> table = lua_copy([1,2,3,4]) >>> len(table) 4 >>> table[1] # Lua indexing 1 Python's ``enumerate()`` function is also supported, so the above could be simplified to: .. code:: python >>> lua_copy = lua.eval(''' ... function(L) ... local t = {} ... for index, item in python.enumerate(L) do ... t[ index+1 ] = item ... end ... return t ... end ... ''') >>> table = lua_copy([1,2,3,4]) >>> len(table) 4 >>> table[1] # Lua indexing 1 For iterators that return tuples, such as ``dict.iteritems()``, it is convenient to use the special ``python.iterex()`` function that automatically explodes the tuple items into separate Lua arguments: .. code:: python >>> lua_copy = lua.eval(''' ... function(d) ... local t = {} ... for key, value in python.iterex(d.items()) do ... t[key] = value ... end ... return t ... end ... ''') >>> d = dict(a=1, b=2, c=3) >>> table = lua_copy( lupa.as_attrgetter(d) ) >>> table['b'] 2 Note that accessing the ``d.items`` method from Lua requires passing the dict as ``attrgetter``. Otherwise, attribute access in Lua would use the ``getitem`` protocol of Python dicts and look up ``d['items']`` instead. None vs. nil ------------ While ``None`` in Python and ``nil`` in Lua differ in their semantics, they usually just mean the same thing: no value. Lupa therefore tries to map one directly to the other whenever possible: .. code:: python >>> lua.eval('nil') is None True >>> is_nil = lua.eval('function(x) return x == nil end') >>> is_nil(None) True The only place where this cannot work is during iteration, because Lua considers a ``nil`` value the termination marker of iterators. Therefore, Lupa special cases ``None`` values here and replaces them by a constant ``python.none`` instead of returning ``nil``: .. code:: python >>> _ = lua.require("table") >>> func = lua.eval(''' ... function(items) ... local t = {} ... for value in python.iter(items) do ... table.insert(t, value == python.none) ... end ... return t ... end ... ''') >>> items = [1, None ,2] >>> list(func(items).values()) [False, True, False] Lupa avoids this value escaping whenever it's obviously not necessary. Thus, when unpacking tuples during iteration, only the first value will be subject to ``python.none`` replacement, as Lua does not look at the other items for loop termination anymore. And on ``enumerate()`` iteration, the first value is known to be always a number and never None, so no replacement is needed. .. code:: python >>> func = lua.eval(''' ... function(items) ... for a, b, c, d in python.iterex(items) do ... return {a == python.none, a == nil, --> a == python.none ... b == python.none, b == nil, --> b == nil ... c == python.none, c == nil, --> c == nil ... d == python.none, d == nil} --> d == nil ... ... end ... end ... ''') >>> items = [(None, None, None, None)] >>> list(func(items).values()) [True, False, False, True, False, True, False, True] >>> items = [(None, None)] # note: no values for c/d => nil in Lua >>> list(func(items).values()) [True, False, False, True, False, True, False, True] Note that this behaviour changed in Lupa 1.0. Previously, the ``python.none`` replacement was done in more places, which made it not always very predictable. Lua Tables ---------- Lua tables mimic Python's mapping protocol. For the special case of array tables, Lua automatically inserts integer indices as keys into the table. Therefore, indexing starts from 1 as in Lua instead of 0 as in Python. For the same reason, negative indexing does not work. It is best to think of Lua tables as mappings rather than arrays, even for plain array tables. .. code:: python >>> table = lua.eval('{10,20,30,40}') >>> table[1] 10 >>> table[4] 40 >>> list(table) [1, 2, 3, 4] >>> list(table.values()) [10, 20, 30, 40] >>> len(table) 4 >>> mapping = lua.eval('{ [1] = -1 }') >>> list(mapping) [1] >>> mapping = lua.eval('{ [20] = -20; [3] = -3 }') >>> mapping[20] -20 >>> mapping[3] -3 >>> sorted(mapping.values()) [-20, -3] >>> sorted(mapping.items()) [(3, -3), (20, -20)] >>> mapping[-3] = 3 # -3 used as key, not index! >>> mapping[-3] 3 >>> sorted(mapping) [-3, 3, 20] >>> sorted(mapping.items()) [(-3, 3), (3, -3), (20, -20)] To simplify the table creation from Python, the ``LuaRuntime`` comes with a helper method that creates a Lua table from Python arguments: .. code:: python >>> t = lua.table(1, 2, 3, 4) >>> lupa.lua_type(t) 'table' >>> list(t) [1, 2, 3, 4] >>> t = lua.table(1, 2, 3, 4, a=1, b=2) >>> t[3] 3 >>> t['b'] 2 A second helper method, ``.table_from()``, is new in Lupa 1.1 and accepts any number of mappings and sequences/iterables as arguments. It collects all values and key-value pairs and builds a single Lua table from them. Any keys that appear in multiple mappings get overwritten with their last value (going from left to right). .. code:: python >>> t = lua.table_from([1, 2, 3], {'a': 1, 'b': 2}, (4, 5), {'b': 42}) >>> t['b'] 42 >>> t[5] 5 A lookup of non-existing keys or indices returns None (actually ``nil`` inside of Lua). A lookup is therefore more similar to the ``.get()`` method of Python dicts than to a mapping lookup in Python. .. code:: python >>> table[1000000] is None True >>> table['no such key'] is None True >>> mapping['no such key'] is None True Note that ``len()`` does the right thing for array tables but does not work on mappings: .. code:: python >>> len(table) 4 >>> len(mapping) 0 This is because ``len()`` is based on the ``#`` (length) operator in Lua and because of the way Lua defines the length of a table. Remember that unset table indices always return ``nil``, including indices outside of the table size. Thus, Lua basically looks for an index that returns ``nil`` and returns the index before that. This works well for array tables that do not contain ``nil`` values, gives barely predictable results for tables with 'holes' and does not work at all for mapping tables. For tables with both sequential and mapping content, this ignores the mapping part completely. Note that it is best not to rely on the behaviour of len() for mappings. It might change in a later version of Lupa. Similar to the table interface provided by Lua, Lupa also supports attribute access to table members: .. code:: python >>> table = lua.eval('{ a=1, b=2 }') >>> table.a, table.b (1, 2) >>> table.a == table['a'] True This enables access to Lua 'methods' that are associated with a table, as used by the standard library modules: .. code:: python >>> string = lua.eval('string') # get the 'string' library table >>> print( string.lower('A') ) a Python Callables ---------------- As discussed earlier, Lupa allows Lua scripts to call Python functions and methods: .. code:: python >>> def add_one(num): ... return num + 1 >>> lua_func = lua.eval('function(num, py_func) return py_func(num) end') >>> lua_func(48, add_one) 49 >>> class MyClass(): ... def my_method(self): ... return 345 >>> obj = MyClass() >>> lua_func = lua.eval('function(py_obj) return py_obj:my_method() end') >>> lua_func(obj) 345 Lua doesn't have a dedicated syntax for named arguments, so by default Python callables can only be called using positional arguments. A common pattern for implementing named arguments in Lua is passing them in a table as the first and only function argument. See http://lua-users.org/wiki/NamedParameters for more details. Lupa supports this pattern by providing two decorators: ``lupa.unpacks_lua_table`` for Python functions and ``lupa.unpacks_lua_table_method`` for methods of Python objects. Python functions/methods wrapped in these decorators can be called from Lua code as ``func(foo, bar)``, ``func{foo=foo, bar=bar}`` or ``func{foo, bar=bar}``. Example: .. code:: python >>> @lupa.unpacks_lua_table ... def add(a, b): ... return a + b >>> lua_func = lua.eval('function(a, b, py_func) return py_func{a=a, b=b} end') >>> lua_func(5, 6, add) 11 >>> lua_func = lua.eval('function(a, b, py_func) return py_func{a, b=b} end') >>> lua_func(5, 6, add) 11 If you do not control the function implementation, you can also just manually wrap a callable object when passing it into Lupa: .. code:: python >>> import operator >>> wrapped_py_add = lupa.unpacks_lua_table(operator.add) >>> lua_func = lua.eval('function(a, b, py_func) return py_func{a, b} end') >>> lua_func(5, 6, wrapped_py_add) 11 There are some limitations: 1. Avoid using ``lupa.unpacks_lua_table`` and ``lupa.unpacks_lua_table_method`` for functions where the first argument can be a Lua table. In this case ``py_func{foo=bar}`` (which is the same as ``py_func({foo=bar})`` in Lua) becomes ambiguous: it could mean either "call ``py_func`` with a named ``foo`` argument" or "call ``py_func`` with a positional ``{foo=bar}`` argument". 2. One should be careful with passing ``nil`` values to callables wrapped in ``lupa.unpacks_lua_table`` or ``lupa.unpacks_lua_table_method`` decorators. Depending on the context, passing ``nil`` as a parameter can mean either "omit a parameter" or "pass None". This even depends on the Lua version. It is possible to use ``python.none`` instead of ``nil`` to pass None values robustly. Arguments with ``nil`` values are also fine when standard braces ``func(a, b, c)`` syntax is used. Because of these limitations lupa doesn't enable named arguments for all Python callables automatically. Decorators allow to enable named arguments on a per-callable basis. Lua Coroutines -------------- The next is an example of Lua coroutines. A wrapped Lua coroutine behaves exactly like a Python coroutine. It needs to get created at the beginning, either by using the ``.coroutine()`` method of a function or by creating it in Lua code. Then, values can be sent into it using the ``.send()`` method or it can be iterated over. Note that the ``.throw()`` method is not supported, though. .. code:: python >>> lua_code = '''\ ... function(N) ... for i=0,N do ... coroutine.yield( i%2 ) ... end ... end ... ''' >>> lua = LuaRuntime() >>> f = lua.eval(lua_code) >>> gen = f.coroutine(4) >>> list(enumerate(gen)) [(0, 0), (1, 1), (2, 0), (3, 1), (4, 0)] An example where values are passed into the coroutine using its ``.send()`` method: .. code:: python >>> lua_code = '''\ ... function() ... local t,i = {},0 ... local value = coroutine.yield() ... while value do ... t[i] = value ... i = i + 1 ... value = coroutine.yield() ... end ... return t ... end ... ''' >>> f = lua.eval(lua_code) >>> co = f.coroutine() # create coroutine >>> co.send(None) # start coroutine (stops at first yield) >>> for i in range(3): ... co.send(i*2) >>> mapping = co.send(None) # loop termination signal >>> sorted(mapping.items()) [(0, 0), (1, 2), (2, 4)] It also works to create coroutines in Lua and to pass them back into Python space: .. code:: python >>> lua_code = '''\ ... function f(N) ... for i=0,N do ... coroutine.yield( i%2 ) ... end ... end ; ... co1 = coroutine.create(f) ; ... co2 = coroutine.create(f) ; ... ... status, first_result = coroutine.resume(co2, 2) ; -- starting! ... ... return f, co1, co2, status, first_result ... ''' >>> lua = LuaRuntime() >>> f, co, lua_gen, status, first_result = lua.execute(lua_code) >>> # a running coroutine: >>> status True >>> first_result 0 >>> list(lua_gen) [1, 0] >>> list(lua_gen) [] >>> # an uninitialised coroutine: >>> gen = co(4) >>> list(enumerate(gen)) [(0, 0), (1, 1), (2, 0), (3, 1), (4, 0)] >>> gen = co(2) >>> list(enumerate(gen)) [(0, 0), (1, 1), (2, 0)] >>> # a plain function: >>> gen = f.coroutine(4) >>> list(enumerate(gen)) [(0, 0), (1, 1), (2, 0), (3, 1), (4, 0)] Threading --------- The following example calculates a mandelbrot image in parallel threads and displays the result in PIL. It is based on a `benchmark implementation`_ for the `Computer Language Benchmarks Game`_. .. _`Computer Language Benchmarks Game`: http://shootout.alioth.debian.org/u64/benchmark.php?test=all&lang=luajit&lang2=python3 .. _`benchmark implementation`: http://shootout.alioth.debian.org/u64/program.php?test=mandelbrot&lang=luajit&id=1 .. code:: python lua_code = '''\ function(N, i, total) local char, unpack = string.char, unpack local result = "" local M, ba, bb, buf = 2/N, 2^(N%8+1)-1, 2^(8-N%8), {} local start_line, end_line = N/total * (i-1), N/total * i - 1 for y=start_line,end_line do local Ci, b, p = y*M-1, 1, 0 for x=0,N-1 do local Cr = x*M-1.5 local Zr, Zi, Zrq, Ziq = Cr, Ci, Cr*Cr, Ci*Ci b = b + b for i=1,49 do Zi = Zr*Zi*2 + Ci Zr = Zrq-Ziq + Cr Ziq = Zi*Zi Zrq = Zr*Zr if Zrq+Ziq > 4.0 then b = b + 1; break; end end if b >= 256 then p = p + 1; buf[p] = 511 - b; b = 1; end end if b ~= 1 then p = p + 1; buf[p] = (ba-b)*bb; end result = result .. char(unpack(buf, 1, p)) end return result end ''' image_size = 1280 # == 1280 x 1280 thread_count = 8 from lupa import LuaRuntime lua_funcs = [ LuaRuntime(encoding=None).eval(lua_code) for _ in range(thread_count) ] results = [None] * thread_count def mandelbrot(i, lua_func): results[i] = lua_func(image_size, i+1, thread_count) import threading threads = [ threading.Thread(target=mandelbrot, args=(i,lua_func)) for i, lua_func in enumerate(lua_funcs) ] for thread in threads: thread.start() for thread in threads: thread.join() result_buffer = b''.join(results) # use PIL to display the image import Image image = Image.fromstring('1', (image_size, image_size), result_buffer) image.show() Note how the example creates a separate ``LuaRuntime`` for each thread to enable parallel execution. Each ``LuaRuntime`` is protected by a global lock that prevents concurrent access to it. The low memory footprint of Lua makes it reasonable to use multiple runtimes, but this setup also means that values cannot easily be exchanged between threads inside of Lua. They must either get copied through Python space (passing table references will not work, either) or use some Lua mechanism for explicit communication, such as a pipe or some kind of shared memory setup. Restricting Lua access to Python objects ---------------------------------------- .. >>> try: unicode = unicode ... except NameError: unicode = str Lupa provides a simple mechanism to control access to Python objects. Each attribute access can be passed through a filter function as follows: .. code:: python >>> def filter_attribute_access(obj, attr_name, is_setting): ... if isinstance(attr_name, unicode): ... if not attr_name.startswith('_'): ... return attr_name ... raise AttributeError('access denied') >>> lua = lupa.LuaRuntime( ... register_eval=False, ... attribute_filter=filter_attribute_access) >>> func = lua.eval('function(x) return x.__class__ end') >>> func(lua) Traceback (most recent call last): ... AttributeError: access denied The ``is_setting`` flag indicates whether the attribute is being read or set. Note that the attributes of Python functions provide access to the current ``globals()`` and therefore to the builtins etc. If you want to safely restrict access to a known set of Python objects, it is best to work with a whitelist of safe attribute names. One way to do that could be to use a well selected list of dedicated API objects that you provide to Lua code, and to only allow Python attribute access to the set of public attribute/method names of these objects. Since Lupa 1.0, you can alternatively provide dedicated getter and setter function implementations for a ``LuaRuntime``: .. code:: python >>> def getter(obj, attr_name): ... if attr_name == 'yes': ... return getattr(obj, attr_name) ... raise AttributeError( ... 'not allowed to read attribute "%s"' % attr_name) >>> def setter(obj, attr_name, value): ... if attr_name == 'put': ... setattr(obj, attr_name, value) ... return ... raise AttributeError( ... 'not allowed to write attribute "%s"' % attr_name) >>> class X(object): ... yes = 123 ... put = 'abc' ... noway = 2.1 >>> x = X() >>> lua = lupa.LuaRuntime(attribute_handlers=(getter, setter)) >>> func = lua.eval('function(x) return x.yes end') >>> func(x) # getting 'yes' 123 >>> func = lua.eval('function(x) x.put = "ABC"; end') >>> func(x) # setting 'put' >>> print(x.put) ABC >>> func = lua.eval('function(x) x.noway = 42; end') >>> func(x) # setting 'noway' Traceback (most recent call last): ... AttributeError: not allowed to write attribute "noway" Importing Lua binary modules ---------------------------- **This will usually work as is**, but here are the details, in case anything goes wrong for you. To use binary modules in Lua, you need to compile them against the header files of the LuaJIT sources that you used to build Lupa, but do not link them against the LuaJIT library. Furthermore, CPython needs to enable global symbol visibility for shared libraries before loading the Lupa module. This can be done by calling ``sys.setdlopenflags(flag_values)``. Importing the ``lupa`` module will automatically try to set up the correct ``dlopen`` flags if it can find the platform specific ``DLFCN`` Python module that defines the necessary flag constants. In that case, using binary modules in Lua should work out of the box. If this setup fails, however, you have to set the flags manually. When using the above configuration call, the argument ``flag_values`` must represent the sum of your system's values for ``RTLD_NEW`` and ``RTLD_GLOBAL``. If ``RTLD_NEW`` is 2 and ``RTLD_GLOBAL`` is 256, you need to call ``sys.setdlopenflags(258)``. Assuming that the Lua luaposix_ (``posix``) module is available, the following should work on a Linux system: .. code:: python >>> import sys >>> orig_dlflags = sys.getdlopenflags() >>> sys.setdlopenflags(258) >>> import lupa >>> sys.setdlopenflags(orig_dlflags) >>> lua = lupa.LuaRuntime() >>> posix_module = lua.require('posix') # doctest: +SKIP .. _luaposix: http://git.alpinelinux.org/cgit/luaposix lupa-1.6/setup.cfg0000664000175000017500000000007313215037350014725 0ustar stefanstefan00000000000000[egg_info] tag_build = tag_date = 0 tag_svn_revision = 0 lupa-1.6/CHANGES.rst0000664000175000017500000002653013215036356014721 0ustar stefanstefan00000000000000Lupa change log =============== 1.6 (2017-12-15) ---------------- * GH#95: Improved compatibility with Lua 5.3. (patch by TitanSnow) 1.5 (2017-09-16) ---------------- * GH#93: New method ``LuaRuntime.compile()`` to compile Lua code without executing it. (patch by TitanSnow) * GH#91: Lua 5.3 is bundled in the source distribution to simplify one-shot installs. (patch by TitanSnow) * GH#87: Lua stack trace is included in output in debug mode. (patch by aaiyer) * GH#78: Allow Lua code to intercept Python exceptions. (patch by Sergey Dobrov) * Built with Cython 0.26.1. 1.4 (2016-12-10) ---------------- * GH#82: Lua coroutines were using the wrong runtime state (patch by Sergey Dobrov) * GH#81: copy locally provided Lua DLL into installed package on Windows (patch by Gareth Coles) * built with Cython 0.25.2 1.3 (2016-04-12) ---------------- * GH#70: ``eval()`` and ``execute()`` accept optional positional arguments (patch by John Vandenberg) * GH#65: calling ``str()`` on a Python object from Lua could fail if the ``LuaRuntime`` is set up without auto-encoding (patch by Mikhail Korobov) * GH#63: attribute/keyword names were not properly encoded if the ``LuaRuntime`` is set up without auto-encoding (patch by Mikhail Korobov) * built with Cython 0.24 1.2 (2015-10-10) ---------------- * callbacks returned from Lua coroutines were incorrectly mixing coroutine state with global Lua state (patch by Mikhail Korobov) * availability of ``python.builtins`` in Lua can be disabled via ``LuaRuntime`` option. * built with Cython 0.23.4 1.1 (2014-11-21) ---------------- * new module function ``lupa.lua_type()`` that returns the Lua type of a wrapped object as string, or ``None`` for normal Python objects * new helper method ``LuaRuntime.table_from(...)`` that creates a Lua table from one or more Python mappings and/or sequences * new ``lupa.unpacks_lua_table`` and ``lupa.unpacks_lua_table_method`` decorators to allow calling Python functions from Lua using named arguments * fix a hang on shutdown where the LuaRuntime failed to deallocate due to reference cycles * Lupa now plays more nicely with other Lua extensions that create userdata objects 1.0.1 (2014-10-11) ------------------ * fix a crash when requesting attributes of wrapped Lua coroutine objects * looking up attributes on Lua objects that do not support it now always raises an AttributeError instead of sometimes raising a TypeError depending on the attribute name 1.0 (2014-09-28) ---------------- * NOTE: this release includes the major backwards incompatible changes listed below. It is believed that they simplify the interaction between Python code and Lua code by more strongly following idiomatic Lua on the Lua side. * Instead of passing a wrapped ``python.none`` object into Lua, ``None`` return values are now mapped to ``nil``, making them more straight forward to handle in Lua code. This makes the behaviour more consistent, as it was previously somewhat arbitrary where ``none`` could appear and where a ``nil`` value was used. The only remaining exception is during iteration, where the first returned value must not be ``nil`` in Lua, or otherwise the loop terminates prematurely. To prevent this, any ``None`` value that the iterator returns, or any first item in exploded tuples that is ``None``, is still mapped to ``python.none``. Any further values returned in the same iteration will be mapped to ``nil`` if they are ``None``, not to ``none``. This means that only the first argument needs to be manually checked for this special case. For the ``enumerate()`` iterator, the counter is never ``None`` and thus the following unpacked items will never be mapped to ``python.none``. * When ``unpack_returned_tuples=True``, iteration now also unpacks tuple values, including ``enumerate()`` iteration, which yields a flat sequence of counter and unpacked values. * When calling bound Python methods from Lua as "obj:meth()", Lupa now prevents Python from prepending the self argument a second time, so that the Python method is now called as "obj.meth()". Previously, it was called as "obj.meth(obj)". Note that this can be undesired when the object itself is explicitly passed as first argument from Lua, e.g. when calling "func(obj)" where "func" is "obj.meth", but these constellations should be rare. As a work-around for this case, user code can wrap the bound method in another function so that the final call comes from Python. * garbage collection works for reference cycles that span both runtimes, Python and Lua * calling from Python into Lua and back into Python did not clean up the Lua call arguments before the innermost call, so that they could leak into the nested Python call or its return arguments * support for Lua 5.2 (in addition to Lua 5.1 and LuaJIT 2.0) * Lua tables support Python's "del" statement for item deletion (patch by Jason Fried) * Attribute lookup can use a more fine-grained control mechanism by implementing explicit getter and setter functions for a LuaRuntime (``attribute_handlers`` argument). Patch by Brian Moe. * item assignments/lookups on Lua objects from Python no longer special case double underscore names (as opposed to attribute lookups) 0.21 (2014-02-12) ----------------- * some garbage collection issues were cleaned up using new Cython features * new ``LuaRuntime`` option ``unpack_returned_tuples`` which automatically unpacks tuples returned from Python functions into separate Lua objects (instead of returning a single Python tuple object) * some internal wrapper classes were removed from the module API * Windows build fixes * Py3.x build fixes * support for building with Lua 5.1 instead of LuaJIT (setup.py --no-luajit) * no longer uses Cython by default when building from released sources (pass ``--with-cython`` to explicitly request a rebuild) * requires Cython 0.20+ when building from unreleased sources * built with Cython 0.20.1 0.20 (2011-05-22) ----------------- * fix "deallocating None" crash while iterating over Lua tables in Python code * support for filtering attribute access to Python objects for Lua code * fix: setting source encoding for Lua code was broken 0.19 (2011-03-06) ----------------- * fix serious resource leak when creating multiple LuaRuntime instances * portability fix for binary module importing 0.18 (2010-11-06) ----------------- * fix iteration by returning ``Py_None`` object for ``None`` instead of ``nil``, which would terminate the iteration * when converting Python values to Lua, represent ``None`` as a ``Py_None`` object in places where ``nil`` has a special meaning, but leave it as ``nil`` where it doesn't hurt * support for counter start value in ``python.enumerate()`` * native implementation for ``python.enumerate()`` that is several times faster * much faster Lua iteration over Python objects 0.17 (2010-11-05) ----------------- * new helper function ``python.enumerate()`` in Lua that returns a Lua iterator for a Python object and adds the 0-based index to each item. * new helper function ``python.iterex()`` in Lua that returns a Lua iterator for a Python object and unpacks any tuples that the iterator yields. * new helper function ``python.iter()`` in Lua that returns a Lua iterator for a Python object. * reestablished the ``python.as_function()`` helper function for Lua code as it can be needed in cases where Lua cannot determine how to run a Python function. 0.16 (2010-09-03) ----------------- * dropped ``python.as_function()`` helper function for Lua as all Python objects are callable from Lua now (potentially raising a ``TypeError`` at call time if they are not callable) * fix regression in 0.13 and later where ordinary Lua functions failed to print due to an accidentally used meta table * fix crash when calling ``str()`` on wrapped Lua objects without metatable 0.15 (2010-09-02) ----------------- * support for loading binary Lua modules on systems that support it 0.14 (2010-08-31) ----------------- * relicensed to the MIT license used by LuaJIT2 to simplify licensing considerations 0.13.1 (2010-08-30) ------------------- * fix Cython generated C file using Cython 0.13 0.13 (2010-08-29) ----------------- * fixed undefined behaviour on ``str(lua_object)`` when the object's ``__tostring()`` meta method fails * removed redundant "error:" prefix from ``LuaError`` messages * access to Python's ``python.builtins`` from Lua code * more generic wrapping rules for Python objects based on supported protocols (callable, getitem, getattr) * new helper functions ``as_attrgetter()`` and ``as_itemgetter()`` to specify the Python object protocol used by Lua indexing when wrapping Python objects in Python code * new helper functions ``python.as_attrgetter()``, ``python.as_itemgetter()`` and ``python.as_function()`` to specify the Python object protocol used by Lua indexing of Python objects in Lua code * item and attribute access for Python objects from Lua code 0.12 (2010-08-16) ----------------- * fix Lua stack leak during table iteration * fix lost Lua object reference after iteration 0.11 (2010-08-07) ----------------- * error reporting on Lua syntax errors failed to clean up the stack so that errors could leak into the next Lua run * Lua error messages were not properly decoded 0.10 (2010-07-27) ----------------- * much faster locking of the LuaRuntime, especially in the single threaded case (see http://code.activestate.com/recipes/577336-fast-re-entrant-optimistic-lock-implemented-in-cyt/) * fixed several error handling problems when executing Python code inside of Lua 0.9 (2010-07-23) ---------------- * fixed Python special double-underscore method access on LuaObject instances * Lua coroutine support through dedicated wrapper classes, including Python iteration support. In Python space, Lua coroutines behave exactly like Python generators. 0.8 (2010-07-21) ---------------- * support for returning multiple values from Lua evaluation * ``repr()`` support for Lua objects * ``LuaRuntime.table()`` method for creating Lua tables from Python space * encoding fix for ``str(LuaObject)`` 0.7 (2010-07-18) ---------------- * ``LuaRuntime.require()`` and ``LuaRuntime.globals()`` methods * renamed ``LuaRuntime.run()`` to ``LuaRuntime.execute()`` * support for ``len()``, ``setattr()`` and subscripting of Lua objects * provide all built-in Lua libraries in ``LuaRuntime``, including support for library loading * fixed a thread locking issue * fix passing Lua objects back into the runtime from Python space 0.6 (2010-07-18) ---------------- * Python iteration support for Lua objects (e.g. tables) * threading fixes * fix compile warnings 0.5 (2010-07-14) ---------------- * explicit encoding options per LuaRuntime instance to decode/encode strings and Lua code 0.4 (2010-07-14) ---------------- * attribute read access on Lua objects, e.g. to read Lua table values from Python * str() on Lua objects * include .hg repository in source downloads * added missing files to source distribution 0.3 (2010-07-13) ---------------- * fix several threading issues * safely free the GIL when calling into Lua 0.2 (2010-07-13) ---------------- * propagate Python exceptions through Lua calls 0.1 (2010-07-12) ---------------- * first public release lupa-1.6/MANIFEST.in0000644000175000017500000000024713157027625014654 0ustar stefanstefan00000000000000include MANIFEST.in include CHANGES.rst INSTALL.rst LICENSE.txt README.rst recursive-include lupa *.py *.pyx *.pxd *.pxi *.c *.h recursive-include third-party *.c *.h lupa-1.6/INSTALL.rst0000664000175000017500000000732212575262575014771 0ustar stefanstefan00000000000000Installing lupa =============== Building with LuaJIT2 --------------------- #) Download and unpack lupa http://pypi.python.org/pypi/lupa #) Download LuaJIT2 http://luajit.org/download.html #) Unpack the archive into the lupa base directory, e.g.:: .../lupa-0.1/LuaJIT-2.0.2 #) Build LuaJIT:: cd LuaJIT-2.0.2 make cd .. If you need specific C compiler flags, pass them to ``make`` as follows:: make CFLAGS="..." For trickier target platforms like Windows and MacOS-X, please see the official `installation instructions for LuaJIT`_. NOTE: When building on Windows, make sure that lua51.lib is made in addition to lua51.dll. The MSVC build produces this file, MinGW does NOT. #) Build lupa:: python setup.py install Or any other distutils target of your choice, such as ``build`` or one of the ``bdist`` targets. See the `distutils documentation`_ for help, also the `hints on building extension modules`_. Note that on 64bit MacOS-X installations, the following additional compiler flags are reportedly required due to the embedded LuaJIT:: -pagezero_size 10000 -image_base 100000000 You can find additional installation hints for MacOS-X in this `somewhat unclear blog post`_, which may or may not tell you at which point in the installation process to provide these flags. Also, on 64bit MacOS-X, you will typically have to set the environment variable ``ARCHFLAGS`` to make sure it only builds for your system instead of trying to generate a fat binary with both 32bit and 64bit support:: export ARCHFLAGS="-arch x86_64" Note that this applies to both LuaJIT and Lupa, so make sure you try a clean build of everything if you forgot to set it initially. .. _`installation instructions for LuaJIT`: http://luajit.org/install.html .. _`somewhat unclear blog post`: http://t-p-j.blogspot.com/2010/11/lupa-on-os-x-with-macports-python-26.html .. _`distutils documentation`: http://docs.python.org/install/index.html#install-index .. _`hints on building extension modules`: http://docs.python.org/install/index.html#building-extensions-tips-and-tricks Building with Lua 5.1 --------------------- Reportedly, it also works to use Lupa with the standard (non-JIT) Lua runtime. To that end, install Lua 5.1 instead of LuaJIT2, including any development packages (header files etc.). On systems that use the "pkg-config" configuration mechanism, Lupa's setup.py will pick up either LuaJIT2 or Lua automatically, with a preference for LuaJIT2 if it is found. Pass the ``--no-luajit`` option to the setup.py script if you have both installed but do not want to use LuaJIT2. On other systems, you may have to supply the build parameters externally, e.g. using environment variables or by changing the setup.py script manually. Pass the ``--no-luajit`` option to the setup.py script in order to ignore the failure you get when neither LuaJIT2 nor Lua are found automatically. For further information, read this mailing list post: http://article.gmane.org/gmane.comp.python.lupa.devel/31 Installing lupa from packages ============================= Debian/Ubuntu + Lua 5.2 ----------------------- #) Install Lua 5.2 development package:: $ apt-get install liblua5.2-dev #) Install lupa:: $ pip install lupa Debian/Ubuntu + LuaJIT2 ----------------------- #) Install LuaJIT2 development package:: $ apt-get install libluajit-5.1-dev #) Install lupa:: $ pip install lupa Depending on OS version, you might get an older LuaJIT2 version. OS X + Lua 5.2 + Homebrew ------------------------- #) Install Lua:: $ brew install lua #) Install pkg-config:: $ brew install pkg-config #) Install lupa:: $ pip install lupa lupa-1.6/lupa.egg-info/0000775000175000017500000000000013215037350015537 5ustar stefanstefan00000000000000lupa-1.6/lupa.egg-info/PKG-INFO0000644000175000017500000016551413215037347016654 0ustar stefanstefan00000000000000Metadata-Version: 1.1 Name: lupa Version: 1.6 Summary: Python wrapper around Lua and LuaJIT Home-page: https://github.com/scoder/lupa Author: Lupa-dev mailing list Author-email: lupa-dev@freelists.org License: MIT style Description: Lupa ==== Lupa integrates the runtimes of Lua_ or LuaJIT2_ into CPython. It is a partial rewrite of LunaticPython_ in Cython_ with some additional features such as proper coroutine support. .. _Lua: http://lua.org/ .. _LuaJIT2: http://luajit.org/ .. _LunaticPython: http://labix.org/lunatic-python .. _Cython: http://cython.org For questions not answered here, please contact the `Lupa mailing list`_. .. _`Lupa mailing list`: http://www.freelists.org/list/lupa-dev .. contents:: :local: Major features -------------- * separate Lua runtime states through a ``LuaRuntime`` class * Python coroutine wrapper for Lua coroutines * iteration support for Python objects in Lua and Lua objects in Python * proper encoding and decoding of strings (configurable per runtime, UTF-8 by default) * frees the GIL and supports threading in separate runtimes when calling into Lua * tested with Python 2.6/3.2 and later * written for LuaJIT2 (tested with LuaJIT 2.0.2), but also works with the normal Lua interpreter (5.1 and 5.2) * easy to hack on and extend as it is written in Cython, not C Why the name? ------------- In Latin, "lupa" is a female wolf, as elegant and wild as it sounds. If you don't like this kind of straight forward allegory to an endangered species, you may also happily assume it's just an amalgamation of the phonetic sounds that start the words "Lua" and "Python", two from each to keep the balance. Why use it? ----------- It complements Python very well. Lua is a language as dynamic as Python, but LuaJIT compiles it to very fast machine code, sometimes faster than many statically compiled languages for computational code. The language runtime is very small and carefully designed for embedding. The complete binary module of Lupa, including a statically linked LuaJIT2 runtime, only weighs some 700KB on a 64 bit machine. With standard Lua 5.1, it's less than 400KB. However, the Lua ecosystem lacks many of the batteries that Python readily includes, either directly in its standard library or as third party packages. This makes real-world Lua applications harder to write than equivalent Python applications. Lua is therefore not commonly used as primary language for large applications, but it makes for a fast, high-level and resource-friendly backup language inside of Python when raw speed is required and the edit-compile-run cycle of binary extension modules is too heavy and too static for agile development or hot-deployment. Lupa is a very fast and thin wrapper around Lua or LuaJIT. It makes it easy to write dynamic Lua code that accompanies dynamic Python code by switching between the two languages at runtime, based on the tradeoff between simplicity and speed. Examples -------- .. ## doctest helpers: >>> try: _ = sorted ... except NameError: ... def sorted(seq): ... l = list(seq) ... l.sort() ... return l .. code:: python >>> import lupa >>> from lupa import LuaRuntime >>> lua = LuaRuntime(unpack_returned_tuples=True) >>> lua.eval('1+1') 2 >>> lua_func = lua.eval('function(f, n) return f(n) end') >>> def py_add1(n): return n+1 >>> lua_func(py_add1, 2) 3 >>> lua.eval('python.eval(" 2 ** 2 ")') == 4 True >>> lua.eval('python.builtins.str(4)') == '4' True The function ``lua_type(obj)`` can be used to find out the type of a wrapped Lua object in Python code, as provided by Lua's ``type()`` function: .. code:: python >>> lupa.lua_type(lua_func) 'function' >>> lupa.lua_type(lua.eval('{}')) 'table' To help in distinguishing between wrapped Lua objects and normal Python objects, it returns ``None`` for the latter: .. code:: python >>> lupa.lua_type(123) is None True >>> lupa.lua_type('abc') is None True >>> lupa.lua_type({}) is None True Note the flag ``unpack_returned_tuples=True`` that is passed to create the Lua runtime. It is new in Lupa 0.21 and changes the behaviour of tuples that get returned by Python functions. With this flag, they explode into separate Lua values: .. code:: python >>> lua.execute('a,b,c = python.eval("(1,2)")') >>> g = lua.globals() >>> g.a 1 >>> g.b 2 >>> g.c is None True When set to False, functions that return a tuple pass it through to the Lua code: .. code:: python >>> non_explode_lua = lupa.LuaRuntime(unpack_returned_tuples=False) >>> non_explode_lua.execute('a,b,c = python.eval("(1,2)")') >>> g = non_explode_lua.globals() >>> g.a (1, 2) >>> g.b is None True >>> g.c is None True Since the default behaviour (to not explode tuples) might change in a later version of Lupa, it is best to always pass this flag explicitly. Python objects in Lua --------------------- Python objects are either converted when passed into Lua (e.g. numbers and strings) or passed as wrapped object references. .. code:: python >>> wrapped_type = lua.globals().type # Lua's own type() function >>> wrapped_type(1) == 'number' True >>> wrapped_type('abc') == 'string' True Wrapped Lua objects get unwrapped when they are passed back into Lua, and arbitrary Python objects get wrapped in different ways: .. code:: python >>> wrapped_type(wrapped_type) == 'function' # unwrapped Lua function True >>> wrapped_type(len) == 'userdata' # wrapped Python function True >>> wrapped_type([]) == 'userdata' # wrapped Python object True Lua supports two main protocols on objects: calling and indexing. It does not distinguish between attribute access and item access like Python does, so the Lua operations ``obj[x]`` and ``obj.x`` both map to indexing. To decide which Python protocol to use for Lua wrapped objects, Lupa employs a simple heuristic. Pratically all Python objects allow attribute access, so if the object also has a ``__getitem__`` method, it is preferred when turning it into an indexable Lua object. Otherwise, it becomes a simple object that uses attribute access for indexing from inside Lua. Obviously, this heuristic will fail to provide the required behaviour in many cases, e.g. when attribute access is required to an object that happens to support item access. To be explicit about the protocol that should be used, Lupa provides the helper functions ``as_attrgetter()`` and ``as_itemgetter()`` that restrict the view on an object to a certain protocol, both from Python and from inside Lua: .. code:: python >>> lua_func = lua.eval('function(obj) return obj["get"] end') >>> d = {'get' : 'value'} >>> value = lua_func(d) >>> value == d['get'] == 'value' True >>> value = lua_func( lupa.as_itemgetter(d) ) >>> value == d['get'] == 'value' True >>> dict_get = lua_func( lupa.as_attrgetter(d) ) >>> dict_get == d.get True >>> dict_get('get') == d.get('get') == 'value' True >>> lua_func = lua.eval( ... 'function(obj) return python.as_attrgetter(obj)["get"] end') >>> dict_get = lua_func(d) >>> dict_get('get') == d.get('get') == 'value' True Note that unlike Lua function objects, callable Python objects support indexing in Lua: .. code:: python >>> def py_func(): pass >>> py_func.ATTR = 2 >>> lua_func = lua.eval('function(obj) return obj.ATTR end') >>> lua_func(py_func) 2 >>> lua_func = lua.eval( ... 'function(obj) return python.as_attrgetter(obj).ATTR end') >>> lua_func(py_func) 2 >>> lua_func = lua.eval( ... 'function(obj) return python.as_attrgetter(obj)["ATTR"] end') >>> lua_func(py_func) 2 Iteration in Lua ---------------- Iteration over Python objects from Lua's for-loop is fully supported. However, Python iterables need to be converted using one of the utility functions which are described here. This is similar to the functions like ``pairs()`` in Lua. To iterate over a plain Python iterable, use the ``python.iter()`` function. For example, you can manually copy a Python list into a Lua table like this: .. code:: python >>> lua_copy = lua.eval(''' ... function(L) ... local t, i = {}, 1 ... for item in python.iter(L) do ... t[i] = item ... i = i + 1 ... end ... return t ... end ... ''') >>> table = lua_copy([1,2,3,4]) >>> len(table) 4 >>> table[1] # Lua indexing 1 Python's ``enumerate()`` function is also supported, so the above could be simplified to: .. code:: python >>> lua_copy = lua.eval(''' ... function(L) ... local t = {} ... for index, item in python.enumerate(L) do ... t[ index+1 ] = item ... end ... return t ... end ... ''') >>> table = lua_copy([1,2,3,4]) >>> len(table) 4 >>> table[1] # Lua indexing 1 For iterators that return tuples, such as ``dict.iteritems()``, it is convenient to use the special ``python.iterex()`` function that automatically explodes the tuple items into separate Lua arguments: .. code:: python >>> lua_copy = lua.eval(''' ... function(d) ... local t = {} ... for key, value in python.iterex(d.items()) do ... t[key] = value ... end ... return t ... end ... ''') >>> d = dict(a=1, b=2, c=3) >>> table = lua_copy( lupa.as_attrgetter(d) ) >>> table['b'] 2 Note that accessing the ``d.items`` method from Lua requires passing the dict as ``attrgetter``. Otherwise, attribute access in Lua would use the ``getitem`` protocol of Python dicts and look up ``d['items']`` instead. None vs. nil ------------ While ``None`` in Python and ``nil`` in Lua differ in their semantics, they usually just mean the same thing: no value. Lupa therefore tries to map one directly to the other whenever possible: .. code:: python >>> lua.eval('nil') is None True >>> is_nil = lua.eval('function(x) return x == nil end') >>> is_nil(None) True The only place where this cannot work is during iteration, because Lua considers a ``nil`` value the termination marker of iterators. Therefore, Lupa special cases ``None`` values here and replaces them by a constant ``python.none`` instead of returning ``nil``: .. code:: python >>> _ = lua.require("table") >>> func = lua.eval(''' ... function(items) ... local t = {} ... for value in python.iter(items) do ... table.insert(t, value == python.none) ... end ... return t ... end ... ''') >>> items = [1, None ,2] >>> list(func(items).values()) [False, True, False] Lupa avoids this value escaping whenever it's obviously not necessary. Thus, when unpacking tuples during iteration, only the first value will be subject to ``python.none`` replacement, as Lua does not look at the other items for loop termination anymore. And on ``enumerate()`` iteration, the first value is known to be always a number and never None, so no replacement is needed. .. code:: python >>> func = lua.eval(''' ... function(items) ... for a, b, c, d in python.iterex(items) do ... return {a == python.none, a == nil, --> a == python.none ... b == python.none, b == nil, --> b == nil ... c == python.none, c == nil, --> c == nil ... d == python.none, d == nil} --> d == nil ... ... end ... end ... ''') >>> items = [(None, None, None, None)] >>> list(func(items).values()) [True, False, False, True, False, True, False, True] >>> items = [(None, None)] # note: no values for c/d => nil in Lua >>> list(func(items).values()) [True, False, False, True, False, True, False, True] Note that this behaviour changed in Lupa 1.0. Previously, the ``python.none`` replacement was done in more places, which made it not always very predictable. Lua Tables ---------- Lua tables mimic Python's mapping protocol. For the special case of array tables, Lua automatically inserts integer indices as keys into the table. Therefore, indexing starts from 1 as in Lua instead of 0 as in Python. For the same reason, negative indexing does not work. It is best to think of Lua tables as mappings rather than arrays, even for plain array tables. .. code:: python >>> table = lua.eval('{10,20,30,40}') >>> table[1] 10 >>> table[4] 40 >>> list(table) [1, 2, 3, 4] >>> list(table.values()) [10, 20, 30, 40] >>> len(table) 4 >>> mapping = lua.eval('{ [1] = -1 }') >>> list(mapping) [1] >>> mapping = lua.eval('{ [20] = -20; [3] = -3 }') >>> mapping[20] -20 >>> mapping[3] -3 >>> sorted(mapping.values()) [-20, -3] >>> sorted(mapping.items()) [(3, -3), (20, -20)] >>> mapping[-3] = 3 # -3 used as key, not index! >>> mapping[-3] 3 >>> sorted(mapping) [-3, 3, 20] >>> sorted(mapping.items()) [(-3, 3), (3, -3), (20, -20)] To simplify the table creation from Python, the ``LuaRuntime`` comes with a helper method that creates a Lua table from Python arguments: .. code:: python >>> t = lua.table(1, 2, 3, 4) >>> lupa.lua_type(t) 'table' >>> list(t) [1, 2, 3, 4] >>> t = lua.table(1, 2, 3, 4, a=1, b=2) >>> t[3] 3 >>> t['b'] 2 A second helper method, ``.table_from()``, is new in Lupa 1.1 and accepts any number of mappings and sequences/iterables as arguments. It collects all values and key-value pairs and builds a single Lua table from them. Any keys that appear in multiple mappings get overwritten with their last value (going from left to right). .. code:: python >>> t = lua.table_from([1, 2, 3], {'a': 1, 'b': 2}, (4, 5), {'b': 42}) >>> t['b'] 42 >>> t[5] 5 A lookup of non-existing keys or indices returns None (actually ``nil`` inside of Lua). A lookup is therefore more similar to the ``.get()`` method of Python dicts than to a mapping lookup in Python. .. code:: python >>> table[1000000] is None True >>> table['no such key'] is None True >>> mapping['no such key'] is None True Note that ``len()`` does the right thing for array tables but does not work on mappings: .. code:: python >>> len(table) 4 >>> len(mapping) 0 This is because ``len()`` is based on the ``#`` (length) operator in Lua and because of the way Lua defines the length of a table. Remember that unset table indices always return ``nil``, including indices outside of the table size. Thus, Lua basically looks for an index that returns ``nil`` and returns the index before that. This works well for array tables that do not contain ``nil`` values, gives barely predictable results for tables with 'holes' and does not work at all for mapping tables. For tables with both sequential and mapping content, this ignores the mapping part completely. Note that it is best not to rely on the behaviour of len() for mappings. It might change in a later version of Lupa. Similar to the table interface provided by Lua, Lupa also supports attribute access to table members: .. code:: python >>> table = lua.eval('{ a=1, b=2 }') >>> table.a, table.b (1, 2) >>> table.a == table['a'] True This enables access to Lua 'methods' that are associated with a table, as used by the standard library modules: .. code:: python >>> string = lua.eval('string') # get the 'string' library table >>> print( string.lower('A') ) a Python Callables ---------------- As discussed earlier, Lupa allows Lua scripts to call Python functions and methods: .. code:: python >>> def add_one(num): ... return num + 1 >>> lua_func = lua.eval('function(num, py_func) return py_func(num) end') >>> lua_func(48, add_one) 49 >>> class MyClass(): ... def my_method(self): ... return 345 >>> obj = MyClass() >>> lua_func = lua.eval('function(py_obj) return py_obj:my_method() end') >>> lua_func(obj) 345 Lua doesn't have a dedicated syntax for named arguments, so by default Python callables can only be called using positional arguments. A common pattern for implementing named arguments in Lua is passing them in a table as the first and only function argument. See http://lua-users.org/wiki/NamedParameters for more details. Lupa supports this pattern by providing two decorators: ``lupa.unpacks_lua_table`` for Python functions and ``lupa.unpacks_lua_table_method`` for methods of Python objects. Python functions/methods wrapped in these decorators can be called from Lua code as ``func(foo, bar)``, ``func{foo=foo, bar=bar}`` or ``func{foo, bar=bar}``. Example: .. code:: python >>> @lupa.unpacks_lua_table ... def add(a, b): ... return a + b >>> lua_func = lua.eval('function(a, b, py_func) return py_func{a=a, b=b} end') >>> lua_func(5, 6, add) 11 >>> lua_func = lua.eval('function(a, b, py_func) return py_func{a, b=b} end') >>> lua_func(5, 6, add) 11 If you do not control the function implementation, you can also just manually wrap a callable object when passing it into Lupa: .. code:: python >>> import operator >>> wrapped_py_add = lupa.unpacks_lua_table(operator.add) >>> lua_func = lua.eval('function(a, b, py_func) return py_func{a, b} end') >>> lua_func(5, 6, wrapped_py_add) 11 There are some limitations: 1. Avoid using ``lupa.unpacks_lua_table`` and ``lupa.unpacks_lua_table_method`` for functions where the first argument can be a Lua table. In this case ``py_func{foo=bar}`` (which is the same as ``py_func({foo=bar})`` in Lua) becomes ambiguous: it could mean either "call ``py_func`` with a named ``foo`` argument" or "call ``py_func`` with a positional ``{foo=bar}`` argument". 2. One should be careful with passing ``nil`` values to callables wrapped in ``lupa.unpacks_lua_table`` or ``lupa.unpacks_lua_table_method`` decorators. Depending on the context, passing ``nil`` as a parameter can mean either "omit a parameter" or "pass None". This even depends on the Lua version. It is possible to use ``python.none`` instead of ``nil`` to pass None values robustly. Arguments with ``nil`` values are also fine when standard braces ``func(a, b, c)`` syntax is used. Because of these limitations lupa doesn't enable named arguments for all Python callables automatically. Decorators allow to enable named arguments on a per-callable basis. Lua Coroutines -------------- The next is an example of Lua coroutines. A wrapped Lua coroutine behaves exactly like a Python coroutine. It needs to get created at the beginning, either by using the ``.coroutine()`` method of a function or by creating it in Lua code. Then, values can be sent into it using the ``.send()`` method or it can be iterated over. Note that the ``.throw()`` method is not supported, though. .. code:: python >>> lua_code = '''\ ... function(N) ... for i=0,N do ... coroutine.yield( i%2 ) ... end ... end ... ''' >>> lua = LuaRuntime() >>> f = lua.eval(lua_code) >>> gen = f.coroutine(4) >>> list(enumerate(gen)) [(0, 0), (1, 1), (2, 0), (3, 1), (4, 0)] An example where values are passed into the coroutine using its ``.send()`` method: .. code:: python >>> lua_code = '''\ ... function() ... local t,i = {},0 ... local value = coroutine.yield() ... while value do ... t[i] = value ... i = i + 1 ... value = coroutine.yield() ... end ... return t ... end ... ''' >>> f = lua.eval(lua_code) >>> co = f.coroutine() # create coroutine >>> co.send(None) # start coroutine (stops at first yield) >>> for i in range(3): ... co.send(i*2) >>> mapping = co.send(None) # loop termination signal >>> sorted(mapping.items()) [(0, 0), (1, 2), (2, 4)] It also works to create coroutines in Lua and to pass them back into Python space: .. code:: python >>> lua_code = '''\ ... function f(N) ... for i=0,N do ... coroutine.yield( i%2 ) ... end ... end ; ... co1 = coroutine.create(f) ; ... co2 = coroutine.create(f) ; ... ... status, first_result = coroutine.resume(co2, 2) ; -- starting! ... ... return f, co1, co2, status, first_result ... ''' >>> lua = LuaRuntime() >>> f, co, lua_gen, status, first_result = lua.execute(lua_code) >>> # a running coroutine: >>> status True >>> first_result 0 >>> list(lua_gen) [1, 0] >>> list(lua_gen) [] >>> # an uninitialised coroutine: >>> gen = co(4) >>> list(enumerate(gen)) [(0, 0), (1, 1), (2, 0), (3, 1), (4, 0)] >>> gen = co(2) >>> list(enumerate(gen)) [(0, 0), (1, 1), (2, 0)] >>> # a plain function: >>> gen = f.coroutine(4) >>> list(enumerate(gen)) [(0, 0), (1, 1), (2, 0), (3, 1), (4, 0)] Threading --------- The following example calculates a mandelbrot image in parallel threads and displays the result in PIL. It is based on a `benchmark implementation`_ for the `Computer Language Benchmarks Game`_. .. _`Computer Language Benchmarks Game`: http://shootout.alioth.debian.org/u64/benchmark.php?test=all&lang=luajit&lang2=python3 .. _`benchmark implementation`: http://shootout.alioth.debian.org/u64/program.php?test=mandelbrot&lang=luajit&id=1 .. code:: python lua_code = '''\ function(N, i, total) local char, unpack = string.char, unpack local result = "" local M, ba, bb, buf = 2/N, 2^(N%8+1)-1, 2^(8-N%8), {} local start_line, end_line = N/total * (i-1), N/total * i - 1 for y=start_line,end_line do local Ci, b, p = y*M-1, 1, 0 for x=0,N-1 do local Cr = x*M-1.5 local Zr, Zi, Zrq, Ziq = Cr, Ci, Cr*Cr, Ci*Ci b = b + b for i=1,49 do Zi = Zr*Zi*2 + Ci Zr = Zrq-Ziq + Cr Ziq = Zi*Zi Zrq = Zr*Zr if Zrq+Ziq > 4.0 then b = b + 1; break; end end if b >= 256 then p = p + 1; buf[p] = 511 - b; b = 1; end end if b ~= 1 then p = p + 1; buf[p] = (ba-b)*bb; end result = result .. char(unpack(buf, 1, p)) end return result end ''' image_size = 1280 # == 1280 x 1280 thread_count = 8 from lupa import LuaRuntime lua_funcs = [ LuaRuntime(encoding=None).eval(lua_code) for _ in range(thread_count) ] results = [None] * thread_count def mandelbrot(i, lua_func): results[i] = lua_func(image_size, i+1, thread_count) import threading threads = [ threading.Thread(target=mandelbrot, args=(i,lua_func)) for i, lua_func in enumerate(lua_funcs) ] for thread in threads: thread.start() for thread in threads: thread.join() result_buffer = b''.join(results) # use PIL to display the image import Image image = Image.fromstring('1', (image_size, image_size), result_buffer) image.show() Note how the example creates a separate ``LuaRuntime`` for each thread to enable parallel execution. Each ``LuaRuntime`` is protected by a global lock that prevents concurrent access to it. The low memory footprint of Lua makes it reasonable to use multiple runtimes, but this setup also means that values cannot easily be exchanged between threads inside of Lua. They must either get copied through Python space (passing table references will not work, either) or use some Lua mechanism for explicit communication, such as a pipe or some kind of shared memory setup. Restricting Lua access to Python objects ---------------------------------------- .. >>> try: unicode = unicode ... except NameError: unicode = str Lupa provides a simple mechanism to control access to Python objects. Each attribute access can be passed through a filter function as follows: .. code:: python >>> def filter_attribute_access(obj, attr_name, is_setting): ... if isinstance(attr_name, unicode): ... if not attr_name.startswith('_'): ... return attr_name ... raise AttributeError('access denied') >>> lua = lupa.LuaRuntime( ... register_eval=False, ... attribute_filter=filter_attribute_access) >>> func = lua.eval('function(x) return x.__class__ end') >>> func(lua) Traceback (most recent call last): ... AttributeError: access denied The ``is_setting`` flag indicates whether the attribute is being read or set. Note that the attributes of Python functions provide access to the current ``globals()`` and therefore to the builtins etc. If you want to safely restrict access to a known set of Python objects, it is best to work with a whitelist of safe attribute names. One way to do that could be to use a well selected list of dedicated API objects that you provide to Lua code, and to only allow Python attribute access to the set of public attribute/method names of these objects. Since Lupa 1.0, you can alternatively provide dedicated getter and setter function implementations for a ``LuaRuntime``: .. code:: python >>> def getter(obj, attr_name): ... if attr_name == 'yes': ... return getattr(obj, attr_name) ... raise AttributeError( ... 'not allowed to read attribute "%s"' % attr_name) >>> def setter(obj, attr_name, value): ... if attr_name == 'put': ... setattr(obj, attr_name, value) ... return ... raise AttributeError( ... 'not allowed to write attribute "%s"' % attr_name) >>> class X(object): ... yes = 123 ... put = 'abc' ... noway = 2.1 >>> x = X() >>> lua = lupa.LuaRuntime(attribute_handlers=(getter, setter)) >>> func = lua.eval('function(x) return x.yes end') >>> func(x) # getting 'yes' 123 >>> func = lua.eval('function(x) x.put = "ABC"; end') >>> func(x) # setting 'put' >>> print(x.put) ABC >>> func = lua.eval('function(x) x.noway = 42; end') >>> func(x) # setting 'noway' Traceback (most recent call last): ... AttributeError: not allowed to write attribute "noway" Importing Lua binary modules ---------------------------- **This will usually work as is**, but here are the details, in case anything goes wrong for you. To use binary modules in Lua, you need to compile them against the header files of the LuaJIT sources that you used to build Lupa, but do not link them against the LuaJIT library. Furthermore, CPython needs to enable global symbol visibility for shared libraries before loading the Lupa module. This can be done by calling ``sys.setdlopenflags(flag_values)``. Importing the ``lupa`` module will automatically try to set up the correct ``dlopen`` flags if it can find the platform specific ``DLFCN`` Python module that defines the necessary flag constants. In that case, using binary modules in Lua should work out of the box. If this setup fails, however, you have to set the flags manually. When using the above configuration call, the argument ``flag_values`` must represent the sum of your system's values for ``RTLD_NEW`` and ``RTLD_GLOBAL``. If ``RTLD_NEW`` is 2 and ``RTLD_GLOBAL`` is 256, you need to call ``sys.setdlopenflags(258)``. Assuming that the Lua luaposix_ (``posix``) module is available, the following should work on a Linux system: .. code:: python >>> import sys >>> orig_dlflags = sys.getdlopenflags() >>> sys.setdlopenflags(258) >>> import lupa >>> sys.setdlopenflags(orig_dlflags) >>> lua = lupa.LuaRuntime() >>> posix_module = lua.require('posix') # doctest: +SKIP .. _luaposix: http://git.alpinelinux.org/cgit/luaposix Installing lupa =============== Building with LuaJIT2 --------------------- #) Download and unpack lupa http://pypi.python.org/pypi/lupa #) Download LuaJIT2 http://luajit.org/download.html #) Unpack the archive into the lupa base directory, e.g.:: .../lupa-0.1/LuaJIT-2.0.2 #) Build LuaJIT:: cd LuaJIT-2.0.2 make cd .. If you need specific C compiler flags, pass them to ``make`` as follows:: make CFLAGS="..." For trickier target platforms like Windows and MacOS-X, please see the official `installation instructions for LuaJIT`_. NOTE: When building on Windows, make sure that lua51.lib is made in addition to lua51.dll. The MSVC build produces this file, MinGW does NOT. #) Build lupa:: python setup.py install Or any other distutils target of your choice, such as ``build`` or one of the ``bdist`` targets. See the `distutils documentation`_ for help, also the `hints on building extension modules`_. Note that on 64bit MacOS-X installations, the following additional compiler flags are reportedly required due to the embedded LuaJIT:: -pagezero_size 10000 -image_base 100000000 You can find additional installation hints for MacOS-X in this `somewhat unclear blog post`_, which may or may not tell you at which point in the installation process to provide these flags. Also, on 64bit MacOS-X, you will typically have to set the environment variable ``ARCHFLAGS`` to make sure it only builds for your system instead of trying to generate a fat binary with both 32bit and 64bit support:: export ARCHFLAGS="-arch x86_64" Note that this applies to both LuaJIT and Lupa, so make sure you try a clean build of everything if you forgot to set it initially. .. _`installation instructions for LuaJIT`: http://luajit.org/install.html .. _`somewhat unclear blog post`: http://t-p-j.blogspot.com/2010/11/lupa-on-os-x-with-macports-python-26.html .. _`distutils documentation`: http://docs.python.org/install/index.html#install-index .. _`hints on building extension modules`: http://docs.python.org/install/index.html#building-extensions-tips-and-tricks Building with Lua 5.1 --------------------- Reportedly, it also works to use Lupa with the standard (non-JIT) Lua runtime. To that end, install Lua 5.1 instead of LuaJIT2, including any development packages (header files etc.). On systems that use the "pkg-config" configuration mechanism, Lupa's setup.py will pick up either LuaJIT2 or Lua automatically, with a preference for LuaJIT2 if it is found. Pass the ``--no-luajit`` option to the setup.py script if you have both installed but do not want to use LuaJIT2. On other systems, you may have to supply the build parameters externally, e.g. using environment variables or by changing the setup.py script manually. Pass the ``--no-luajit`` option to the setup.py script in order to ignore the failure you get when neither LuaJIT2 nor Lua are found automatically. For further information, read this mailing list post: http://article.gmane.org/gmane.comp.python.lupa.devel/31 Installing lupa from packages ============================= Debian/Ubuntu + Lua 5.2 ----------------------- #) Install Lua 5.2 development package:: $ apt-get install liblua5.2-dev #) Install lupa:: $ pip install lupa Debian/Ubuntu + LuaJIT2 ----------------------- #) Install LuaJIT2 development package:: $ apt-get install libluajit-5.1-dev #) Install lupa:: $ pip install lupa Depending on OS version, you might get an older LuaJIT2 version. OS X + Lua 5.2 + Homebrew ------------------------- #) Install Lua:: $ brew install lua #) Install pkg-config:: $ brew install pkg-config #) Install lupa:: $ pip install lupa Lupa change log =============== 1.6 (2017-12-15) ---------------- * GH#95: Improved compatibility with Lua 5.3. (patch by TitanSnow) 1.5 (2017-09-16) ---------------- * GH#93: New method ``LuaRuntime.compile()`` to compile Lua code without executing it. (patch by TitanSnow) * GH#91: Lua 5.3 is bundled in the source distribution to simplify one-shot installs. (patch by TitanSnow) * GH#87: Lua stack trace is included in output in debug mode. (patch by aaiyer) * GH#78: Allow Lua code to intercept Python exceptions. (patch by Sergey Dobrov) * Built with Cython 0.26.1. 1.4 (2016-12-10) ---------------- * GH#82: Lua coroutines were using the wrong runtime state (patch by Sergey Dobrov) * GH#81: copy locally provided Lua DLL into installed package on Windows (patch by Gareth Coles) * built with Cython 0.25.2 1.3 (2016-04-12) ---------------- * GH#70: ``eval()`` and ``execute()`` accept optional positional arguments (patch by John Vandenberg) * GH#65: calling ``str()`` on a Python object from Lua could fail if the ``LuaRuntime`` is set up without auto-encoding (patch by Mikhail Korobov) * GH#63: attribute/keyword names were not properly encoded if the ``LuaRuntime`` is set up without auto-encoding (patch by Mikhail Korobov) * built with Cython 0.24 1.2 (2015-10-10) ---------------- * callbacks returned from Lua coroutines were incorrectly mixing coroutine state with global Lua state (patch by Mikhail Korobov) * availability of ``python.builtins`` in Lua can be disabled via ``LuaRuntime`` option. * built with Cython 0.23.4 1.1 (2014-11-21) ---------------- * new module function ``lupa.lua_type()`` that returns the Lua type of a wrapped object as string, or ``None`` for normal Python objects * new helper method ``LuaRuntime.table_from(...)`` that creates a Lua table from one or more Python mappings and/or sequences * new ``lupa.unpacks_lua_table`` and ``lupa.unpacks_lua_table_method`` decorators to allow calling Python functions from Lua using named arguments * fix a hang on shutdown where the LuaRuntime failed to deallocate due to reference cycles * Lupa now plays more nicely with other Lua extensions that create userdata objects 1.0.1 (2014-10-11) ------------------ * fix a crash when requesting attributes of wrapped Lua coroutine objects * looking up attributes on Lua objects that do not support it now always raises an AttributeError instead of sometimes raising a TypeError depending on the attribute name 1.0 (2014-09-28) ---------------- * NOTE: this release includes the major backwards incompatible changes listed below. It is believed that they simplify the interaction between Python code and Lua code by more strongly following idiomatic Lua on the Lua side. * Instead of passing a wrapped ``python.none`` object into Lua, ``None`` return values are now mapped to ``nil``, making them more straight forward to handle in Lua code. This makes the behaviour more consistent, as it was previously somewhat arbitrary where ``none`` could appear and where a ``nil`` value was used. The only remaining exception is during iteration, where the first returned value must not be ``nil`` in Lua, or otherwise the loop terminates prematurely. To prevent this, any ``None`` value that the iterator returns, or any first item in exploded tuples that is ``None``, is still mapped to ``python.none``. Any further values returned in the same iteration will be mapped to ``nil`` if they are ``None``, not to ``none``. This means that only the first argument needs to be manually checked for this special case. For the ``enumerate()`` iterator, the counter is never ``None`` and thus the following unpacked items will never be mapped to ``python.none``. * When ``unpack_returned_tuples=True``, iteration now also unpacks tuple values, including ``enumerate()`` iteration, which yields a flat sequence of counter and unpacked values. * When calling bound Python methods from Lua as "obj:meth()", Lupa now prevents Python from prepending the self argument a second time, so that the Python method is now called as "obj.meth()". Previously, it was called as "obj.meth(obj)". Note that this can be undesired when the object itself is explicitly passed as first argument from Lua, e.g. when calling "func(obj)" where "func" is "obj.meth", but these constellations should be rare. As a work-around for this case, user code can wrap the bound method in another function so that the final call comes from Python. * garbage collection works for reference cycles that span both runtimes, Python and Lua * calling from Python into Lua and back into Python did not clean up the Lua call arguments before the innermost call, so that they could leak into the nested Python call or its return arguments * support for Lua 5.2 (in addition to Lua 5.1 and LuaJIT 2.0) * Lua tables support Python's "del" statement for item deletion (patch by Jason Fried) * Attribute lookup can use a more fine-grained control mechanism by implementing explicit getter and setter functions for a LuaRuntime (``attribute_handlers`` argument). Patch by Brian Moe. * item assignments/lookups on Lua objects from Python no longer special case double underscore names (as opposed to attribute lookups) 0.21 (2014-02-12) ----------------- * some garbage collection issues were cleaned up using new Cython features * new ``LuaRuntime`` option ``unpack_returned_tuples`` which automatically unpacks tuples returned from Python functions into separate Lua objects (instead of returning a single Python tuple object) * some internal wrapper classes were removed from the module API * Windows build fixes * Py3.x build fixes * support for building with Lua 5.1 instead of LuaJIT (setup.py --no-luajit) * no longer uses Cython by default when building from released sources (pass ``--with-cython`` to explicitly request a rebuild) * requires Cython 0.20+ when building from unreleased sources * built with Cython 0.20.1 0.20 (2011-05-22) ----------------- * fix "deallocating None" crash while iterating over Lua tables in Python code * support for filtering attribute access to Python objects for Lua code * fix: setting source encoding for Lua code was broken 0.19 (2011-03-06) ----------------- * fix serious resource leak when creating multiple LuaRuntime instances * portability fix for binary module importing 0.18 (2010-11-06) ----------------- * fix iteration by returning ``Py_None`` object for ``None`` instead of ``nil``, which would terminate the iteration * when converting Python values to Lua, represent ``None`` as a ``Py_None`` object in places where ``nil`` has a special meaning, but leave it as ``nil`` where it doesn't hurt * support for counter start value in ``python.enumerate()`` * native implementation for ``python.enumerate()`` that is several times faster * much faster Lua iteration over Python objects 0.17 (2010-11-05) ----------------- * new helper function ``python.enumerate()`` in Lua that returns a Lua iterator for a Python object and adds the 0-based index to each item. * new helper function ``python.iterex()`` in Lua that returns a Lua iterator for a Python object and unpacks any tuples that the iterator yields. * new helper function ``python.iter()`` in Lua that returns a Lua iterator for a Python object. * reestablished the ``python.as_function()`` helper function for Lua code as it can be needed in cases where Lua cannot determine how to run a Python function. 0.16 (2010-09-03) ----------------- * dropped ``python.as_function()`` helper function for Lua as all Python objects are callable from Lua now (potentially raising a ``TypeError`` at call time if they are not callable) * fix regression in 0.13 and later where ordinary Lua functions failed to print due to an accidentally used meta table * fix crash when calling ``str()`` on wrapped Lua objects without metatable 0.15 (2010-09-02) ----------------- * support for loading binary Lua modules on systems that support it 0.14 (2010-08-31) ----------------- * relicensed to the MIT license used by LuaJIT2 to simplify licensing considerations 0.13.1 (2010-08-30) ------------------- * fix Cython generated C file using Cython 0.13 0.13 (2010-08-29) ----------------- * fixed undefined behaviour on ``str(lua_object)`` when the object's ``__tostring()`` meta method fails * removed redundant "error:" prefix from ``LuaError`` messages * access to Python's ``python.builtins`` from Lua code * more generic wrapping rules for Python objects based on supported protocols (callable, getitem, getattr) * new helper functions ``as_attrgetter()`` and ``as_itemgetter()`` to specify the Python object protocol used by Lua indexing when wrapping Python objects in Python code * new helper functions ``python.as_attrgetter()``, ``python.as_itemgetter()`` and ``python.as_function()`` to specify the Python object protocol used by Lua indexing of Python objects in Lua code * item and attribute access for Python objects from Lua code 0.12 (2010-08-16) ----------------- * fix Lua stack leak during table iteration * fix lost Lua object reference after iteration 0.11 (2010-08-07) ----------------- * error reporting on Lua syntax errors failed to clean up the stack so that errors could leak into the next Lua run * Lua error messages were not properly decoded 0.10 (2010-07-27) ----------------- * much faster locking of the LuaRuntime, especially in the single threaded case (see http://code.activestate.com/recipes/577336-fast-re-entrant-optimistic-lock-implemented-in-cyt/) * fixed several error handling problems when executing Python code inside of Lua 0.9 (2010-07-23) ---------------- * fixed Python special double-underscore method access on LuaObject instances * Lua coroutine support through dedicated wrapper classes, including Python iteration support. In Python space, Lua coroutines behave exactly like Python generators. 0.8 (2010-07-21) ---------------- * support for returning multiple values from Lua evaluation * ``repr()`` support for Lua objects * ``LuaRuntime.table()`` method for creating Lua tables from Python space * encoding fix for ``str(LuaObject)`` 0.7 (2010-07-18) ---------------- * ``LuaRuntime.require()`` and ``LuaRuntime.globals()`` methods * renamed ``LuaRuntime.run()`` to ``LuaRuntime.execute()`` * support for ``len()``, ``setattr()`` and subscripting of Lua objects * provide all built-in Lua libraries in ``LuaRuntime``, including support for library loading * fixed a thread locking issue * fix passing Lua objects back into the runtime from Python space 0.6 (2010-07-18) ---------------- * Python iteration support for Lua objects (e.g. tables) * threading fixes * fix compile warnings 0.5 (2010-07-14) ---------------- * explicit encoding options per LuaRuntime instance to decode/encode strings and Lua code 0.4 (2010-07-14) ---------------- * attribute read access on Lua objects, e.g. to read Lua table values from Python * str() on Lua objects * include .hg repository in source downloads * added missing files to source distribution 0.3 (2010-07-13) ---------------- * fix several threading issues * safely free the GIL when calling into Lua 0.2 (2010-07-13) ---------------- * propagate Python exceptions through Lua calls 0.1 (2010-07-12) ---------------- * first public release License ======= Lupa ---- Copyright (c) 2010-2017 Stefan Behnel. All rights reserved. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. Lua --- (See https://www.lua.org/license.html) Copyright © 1994–2017 Lua.org, PUC-Rio. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. Platform: UNKNOWN Classifier: Development Status :: 5 - Production/Stable Classifier: Intended Audience :: Developers Classifier: Intended Audience :: Information Technology Classifier: License :: OSI Approved :: MIT License Classifier: Programming Language :: Cython Classifier: Programming Language :: Python :: 2 Classifier: Programming Language :: Python :: 2.6 Classifier: Programming Language :: Python :: 2.7 Classifier: Programming Language :: Python :: 3 Classifier: Programming Language :: Python :: 3.3 Classifier: Programming Language :: Python :: 3.4 Classifier: Programming Language :: Python :: 3.5 Classifier: Programming Language :: Python :: 3.6 Classifier: Programming Language :: Other Scripting Engines Classifier: Operating System :: OS Independent Classifier: Topic :: Software Development lupa-1.6/lupa.egg-info/top_level.txt0000644000175000017500000000000513215037347020270 0ustar stefanstefan00000000000000lupa lupa-1.6/lupa.egg-info/not-zip-safe0000644000175000017500000000000112307151721017763 0ustar stefanstefan00000000000000 lupa-1.6/lupa.egg-info/SOURCES.txt0000644000175000017500000000347713215037350017434 0ustar stefanstefan00000000000000CHANGES.rst INSTALL.rst LICENSE.txt MANIFEST.in README.rst setup.py lupa/__init__.py lupa/_lupa.c lupa/_lupa.pyx lupa/lock.pxi lupa/lua.pxd lupa/lupa_defs.h lupa/version.py lupa.egg-info/PKG-INFO lupa.egg-info/SOURCES.txt lupa.egg-info/dependency_links.txt lupa.egg-info/not-zip-safe lupa.egg-info/top_level.txt lupa/tests/__init__.py lupa/tests/test.py third-party/lua/lapi.c third-party/lua/lapi.h third-party/lua/lauxlib.c third-party/lua/lauxlib.h third-party/lua/lbaselib.c third-party/lua/lbitlib.c third-party/lua/lcode.c third-party/lua/lcode.h third-party/lua/lcorolib.c third-party/lua/lctype.c third-party/lua/lctype.h third-party/lua/ldblib.c third-party/lua/ldebug.c third-party/lua/ldebug.h third-party/lua/ldo.c third-party/lua/ldo.h third-party/lua/ldump.c third-party/lua/lfunc.c third-party/lua/lfunc.h third-party/lua/lgc.c third-party/lua/lgc.h third-party/lua/linit.c third-party/lua/liolib.c third-party/lua/llex.c third-party/lua/llex.h third-party/lua/llimits.h third-party/lua/lmathlib.c third-party/lua/lmem.c third-party/lua/lmem.h third-party/lua/loadlib.c third-party/lua/lobject.c third-party/lua/lobject.h third-party/lua/lopcodes.c third-party/lua/lopcodes.h third-party/lua/loslib.c third-party/lua/lparser.c third-party/lua/lparser.h third-party/lua/lprefix.h third-party/lua/lstate.c third-party/lua/lstate.h third-party/lua/lstring.c third-party/lua/lstring.h third-party/lua/lstrlib.c third-party/lua/ltable.c third-party/lua/ltable.h third-party/lua/ltablib.c third-party/lua/ltests.c third-party/lua/ltests.h third-party/lua/ltm.c third-party/lua/ltm.h third-party/lua/lua.c third-party/lua/lua.h third-party/lua/luaconf.h third-party/lua/lualib.h third-party/lua/lundump.c third-party/lua/lundump.h third-party/lua/lutf8lib.c third-party/lua/lvm.c third-party/lua/lvm.h third-party/lua/lzio.c third-party/lua/lzio.hlupa-1.6/lupa.egg-info/dependency_links.txt0000644000175000017500000000000113215037347021611 0ustar stefanstefan00000000000000