Commit 606b4f44 authored by da-woods's avatar da-woods Committed by GitHub

Mark view.* extension types as non-imported so that they can be inherited from. (GH-3413)

parent 05f7a479
......@@ -127,6 +127,15 @@ class CythonScope(ModuleScope):
self.viewscope, cython_scope=self,
whitelist=MemoryView.view_utility_whitelist)
# Marks the types as being cython_builtin_type so that they can be
# extended from without Cython attempting to import cython.view
ext_types = [ entry.type
for entry in view_utility_scope.entries.values()
if entry.type.is_extension_type ]
for ext_type in ext_types:
ext_type.is_cython_builtin_type = 1
# self.entries["array"] = view_utility_scope.entries.pop("array")
......
......@@ -3379,7 +3379,8 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode):
def generate_base_type_import_code(self, env, entry, code, import_generator):
base_type = entry.type.base_type
if (base_type and base_type.module_name != env.qualified_name and not
base_type.is_builtin_type and not entry.utility_code_definition):
(base_type.is_builtin_type or base_type.is_cython_builtin_type)
and not entry.utility_code_definition):
self.generate_type_import_code(env, base_type, self.pos, code, import_generator)
def generate_type_import_code(self, env, type, pos, code, import_generator):
......
......@@ -229,6 +229,7 @@ class PyrexType(BaseType):
is_extension_type = 0
is_final_type = 0
is_builtin_type = 0
is_cython_builtin_type = 0
is_numeric = 0
is_int = 0
is_float = 0
......
......@@ -209,3 +209,11 @@ def test_cyarray_from_carray():
mslice = a
print mslice[0, 0], mslice[1, 0], mslice[2, 5]
class InheritFrom(v.array):
"""
Test is just to confirm it works, not to do anything meaningful with it
(Be aware that itemsize isn't necessarily right)
>>> inst = InheritFrom(shape=(3, 3, 3), itemsize=4, format="i")
"""
pass
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