Commit 80638c1a authored by Robert Bradshaw's avatar Robert Bradshaw

Let cython.inline return all defined variables by default.

parent 87049841
...@@ -185,7 +185,11 @@ def cython_inline(code, ...@@ -185,7 +185,11 @@ def cython_inline(code,
%(cimports)s %(cimports)s
def __invoke(%(params)s): def __invoke(%(params)s):
%(func_body)s %(func_body)s
""" % {'cimports': '\n'.join(cimports), 'module_body': module_body, 'params': params, 'func_body': func_body } return locals()
""" % {'cimports': '\n'.join(cimports),
'module_body': module_body,
'params': params,
'func_body': func_body }
for key, value in literals.items(): for key, value in literals.items():
module_code = module_code.replace(key, value) module_code = module_code.replace(key, value)
pyx_file = os.path.join(lib_dir, module_name + '.pyx') pyx_file = os.path.join(lib_dir, module_name + '.pyx')
......
...@@ -40,6 +40,13 @@ class TestInline(CythonTest): ...@@ -40,6 +40,13 @@ class TestInline(CythonTest):
def test_globals(self): def test_globals(self):
self.assertEquals(inline("return global_value + 1", **self.test_kwds), global_value + 1) self.assertEquals(inline("return global_value + 1", **self.test_kwds), global_value + 1)
def test_no_return(self):
self.assertEquals(inline("""
a = 1
cdef double b = 2
cdef c = []
"""), dict(a=1, b=2.0, c=[]))
def test_pure(self): def test_pure(self):
import cython as cy import cython as cy
b = inline(""" b = inline("""
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment