The following Cython source: cdef extern from "header": cdef cppclass String cdef cppclass List[T] cdef cppclass StringList(List[String])
cdef cppclass String: String() int length() cdef cppclass List[T]: List() int length() cdef cppclass StringList(List[String]): StringList() void sort() causes a crash: Error compiling Cython file: ------------------------------------------------------------ ... cdef cppclass List[T]: List() int length() cdef cppclass StringList(List[String]): ^ ------------------------------------------------------------ s.pyx:14:9: Cannot inherit from incomplete type Error compiling Cython file: ------------------------------------------------------------ ... cdef cppclass List[T]: List() int length() cdef cppclass StringList(List[String]): StringList() ^ ------------------------------------------------------------ s.pyx:15:8: Compiler crash in AnalyseDeclarationsTransform File 'ModuleNode.py', line 101, in analyse_declarations: ModuleNode(s.pyx:1:0, full_module_name = 's') File 'Nodes.py', line 382, in analyse_declarations: StatListNode(s.pyx:1:5) File 'Nodes.py', line 438, in analyse_declarations: CDefExternNode(s.pyx:1:5, include_file = u'header') File 'Nodes.py', line 382, in analyse_declarations: StatListNode(s.pyx:2:4) File 'Nodes.py', line 1313, in analyse_declarations: CppClassNode(s.pyx:14:9, base_classes = [...]/1, name = u'StringList', visibility = u'extern') File 'Nodes.py', line 1203, in analyse_declarations: CVarDefNode(s.pyx:15:8, modifiers = [...]/0, visibility = u'extern') Compiler crash traceback from this point on: File ".../Cython/Compiler/Nodes.py", line 1203, in analyse_declarations api = self.api, modifiers = self.modifiers) File ".../Cython/Compiler/Symtab.py", line 2131, in declare_cfunction self.check_base_default_constructor(pos) File ".../Cython/Compiler/Symtab.py", line 2108, in \ check_base_default_constructor temp_entry = base_class.scope.lookup_here("<init>") AttributeError: 'NoneType' object has no attribute 'lookup_here' There seem to be two problems here: the AttributeError crash, but also the earlier "Cannot inherit from incomplete type" message. None of the types look incomplete; if you comment out the forward declarations, no error is reported: so it looks as if the forward declarations aren't being tied up with the actual declarations. In the actual use case, of course, I need the forward decls. Regards, Vinay Sajip _______________________________________________ cython-devel mailing list cython-devel@python.org https://mail.python.org/mailman/listinfo/cython-devel