Compiler crash

37 views
Skip to first unread message

Stefan van Zwam

unread,
Nov 8, 2011, 11:42:11 AM11/8/11
to cython...@googlegroups.com
Dear all,

I have a problem with forward declarations and public attributes. I need both since I want to subclass SageObject and support rename() (so I need to add "cdef public __custom_name"), and I want my class to have methods that produce instances of subclasses (so I need forward declarations).


Small example:

thing.pxd
=========
cdef class Thing:
cdef public outcry
=========

thing.pyx
=========
cdef class Thing # Forward declaration

cdef int i = 3

cdef class Thing:
pass
=========

Result of "python setup.py build"
=========
cythoning thing.pyx to thing.c

Error compiling Cython file:
------------------------------------------------------------
...
cdef class Thing
^
------------------------------------------------------------

thing.pyx:1:5: Compiler crash in AnalyseDeclarationsTransform

ModuleNode.body = StatListNode(thing.pyx:1:0)
StatListNode.stats[0] = CClassDefNode(thing.pyx:1:5,
as_name = u'Thing',
class_name = u'Thing',
module_name = u'',
visibility = u'private')

Compiler crash traceback from this point on:
File "Visitor.py", line 173, in Cython.Compiler.Visitor.TreeVisitor._visitchild (Cython/Compiler/Visitor.c:3558)
File "/Library/Python/2.7/site-packages/Cython/Compiler/ParseTreeTransforms.py", line 1413, in visit_CClassDefNode
node.body.stats += stats
AttributeError: 'NoneType' object has no attribute 'stats'
=========

Note that I tested both with Sage's bundled Cython 0.14.1 and with the latest Cython from cython.org. Both give the same error. Any suggestions?

--Stefan.

Stefan

unread,
Nov 15, 2011, 1:00:22 PM11/15/11
to cython...@googlegroups.com
Anyone? Is this a Cython bug or am I doing something wrong?
Reply all
Reply to author
Forward
0 new messages