Commit c6d4e57b authored by Stefan Behnel's avatar Stefan Behnel

Fix passing Python classes through "cython.inline()".

Closes GH-2936.
parent a5dba3d8
......@@ -18,6 +18,9 @@ Bugs fixed
* Starred expressions in %-formatting tuples could fail to compile for
unicode strings. (Github issue #2939)
* Passing Python class references through ``cython.inline()`` was broken.
(Github issue #2936)
0.29.7 (2019-04-14)
===================
......
......@@ -90,7 +90,7 @@ def safe_type(arg, context=None):
elif 'numpy' in sys.modules and isinstance(arg, sys.modules['numpy'].ndarray):
return 'numpy.ndarray[numpy.%s_t, ndim=%s]' % (arg.dtype.name, arg.ndim)
else:
for base_type in py_type.mro():
for base_type in py_type.__mro__:
if base_type.__module__ in ('__builtin__', 'builtins'):
return 'object'
module = context.find_module(base_type.__module__, need_pxd=False)
......
......@@ -51,6 +51,12 @@ class TestInline(CythonTest):
foo = inline("def foo(x): return x * x", **self.test_kwds)['foo']
self.assertEquals(foo(7), 49)
def test_class_ref(self):
class Type(object):
pass
tp = inline("Type")['Type']
self.assertEqual(tp, Type)
def test_pure(self):
import cython as cy
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