[Cython] Compiler crash in AnalyseExpressionsTransform
Hi, another bug report: mic@mic /tmp $ cat t11.pyx cdef cppclass foo: pass def test(): foo() mic@mic /tmp $ cython --cplus t11.pyx Error compiling Cython file: ... cdef cppclass foo: pass def test(): foo() ^ t11.pyx:5:7: Compiler crash in AnalyseExpressionsTransform ModuleNode.body = StatListNode(t11.pyx:1:0) StatListNode.stats[1] = DefNode(t11.pyx:4:0, modifiers = [...]/0, name = u'test', py_wrapper_required = True, reqd_kw_flags_cname = '0', used = True) File 'Nodes.py', line 421, in analyse_expressions: StatListNode(t11.pyx:5:7) File 'Nodes.py', line 4652, in analyse_expressions: ExprStatNode(t11.pyx:5:7) File 'ExprNodes.py', line 434, in analyse_expressions: SimpleCallNode(t11.pyx:5:7, use_managed_ref = True) File 'ExprNodes.py', line 4495, in analyse_types: SimpleCallNode(t11.pyx:5:7, use_managed_ref = True) File 'ExprNodes.py', line 4429, in analyse_as_type_constructor: SimpleCallNode(t11.pyx:5:7, use_managed_ref = True) Compiler crash traceback from this point on: File "/usr/lib/python2.7/dist-packages/Cython/Compiler/ExprNodes.py", line 4429, in analyse_as_type_constructor self.function = RawCNameExprNode(self.function.pos, constructor.type) AttributeError: 'NoneType' object has no attribute 'type' The code is obviously nonsensical, but Cython should produce a proper error message instead of crashing. signature.asc Description: OpenPGP digital signature ___ cython-devel mailing list cython-devel@python.org https://mail.python.org/mailman/listinfo/cython-devel
[Cython] Can't call functions with multi-token template arguments such as 'char *'
Hi, it seems to be impossible to use anything but a single word as a template type for functions. Classes don't suffer from this issue, as seen below. As a workaround, complex types can be ctypedef-d to a single word (also seen below). $ cat t10.pyx cdef extern from "nope.h": cdef cppclass bar[T]: void func(T arg) void foo[T](T arg) ctypedef char * charptr def test(): # works cdef bar[char *] barobj barobj.func(NULL) # works foo[int](5) # works foo[charptr](NULL) # fails foo[char *](NULL) $ cython --cplus t10.pyx Error compiling Cython file: ... # works foo[charptr](NULL) # fails foo[char *](NULL) ^ t10.pyx:27:14: Expected an identifier or literal Happy debugging, ~ mic_e signature.asc Description: OpenPGP digital signature ___ cython-devel mailing list cython-devel@python.org https://mail.python.org/mailman/listinfo/cython-devel
[Cython] Feature request: Flag to enable warnings when 'extern' functions are not declared 'except +'
Hi everybody, as you surely have guessed from the amount of Bug reports I have recently submitted to this mailing list, I'm currently working on a rather large Cython project. More precisely: I'm using Cython as the glue layer between the Python and C++ components of openage; an overview and source code may be found here: https://github.com/mic-e/openage/blob/pyinterface/doc/implementation/pyinterface.md https://github.com/mic-e/openage/tree/pyinterface/cpp/pyinterface https://github.com/mic-e/openage/tree/pyinterface/openage/cppinterface In openage, almost all C++ functions that are exposed to Cython SHOULD be declared as 'except +'. Forgetting to do so can cause hard-to-debug issues, including useless Exception messages, corruption of CPython and right-out program termination, if those methods should throw a C++ exception. As a solution, I'd like to see Cython warnings if an extern cimport has no 'except' declaration. To intentionally omit the "except +", I suggest a new except declaration, "except -", or, even better, the C++11 keyword "noexcept" (since precisely those methods that are declared 'noexcept' should be cimported without 'except+'). Of course, those warnings (or errors?) should be disabled by default, and enabled by a special command-line flag. Any thoughts on this? ~ mic_e ___ cython-devel mailing list cython-devel@python.org https://mail.python.org/mailman/listinfo/cython-devel