What happens if you write "cdef class ..." instead of "cpdef class
..." on your pxd?

On Mon, Apr 13, 2009 at 6:14 PM, Riccardo Murri
<[email protected]> wrote:
> Hello,
>
> I have started using Cython recently to spped up some Python code; it
> works very well and stably, but today I managed to crash Cython 0.11
> while trying to compile the following pure Python code:
>
>  # iter.py
>  class Iter(object):
>
>      """A docstring."""
>
>      def __iter__(self):
>          return self
>
>      def __next__(self):
>          raise StopIteration
>
> I'm augmenting the pure Python code with the following .pxd file::
>
>  # iter.pxd
>  cpdef class Iter(object)
>
> The Cython-0.11 invocation "cython iter.py" dies with the following 
> backtrace::
>
>  $ cython iter.py
>
>  Error converting Pyrex file to C:
>  ------------------------------------------------------------
>  ...
>  class Iter(object):
>
>      """A docstring."""
>
>      def __iter__(self):
>     ^
>  ------------------------------------------------------------
>
>  /tmp/iter.py:5:4: Compiler crash in AlignFunctionDefinitions
>
>  ModuleNode.body = StatListNode(iter.py:1:0)
>  StatListNode.stats[0] = PyClassDefNode(iter.py:1:0,
>      doc = 'A docstring.',
>      name = u'Iter')
>  CClassDefNode.body = StatListNode(iter.py:5:4)
>  StatListNode.stats[0] = DefNode(iter.py:5:4,
>      name = u'__iter__',
>      num_required_args = 1,
>      reqd_kw_flags_cname = '0')
>
>  Compiler crash traceback from this point on:
>    File "Visitor.py", line 149, in Cython.Compiler.Visitor.visitchild
> (/home/rmurri/phd.cython/src/Cython-0.11/Cython/Compiler/Visitor.c:2814)
>    File "Visitor.py", line 45, in
> Cython.Compiler.Visitor.BasicVisitor.visit
> (/home/rmurri/phd.cython/src/Cython-0.11/Cython/Compiler/Visitor.c:1356)
>    File 
> "/home/rmurri/phd.cython/src/Cython-0.11/Cython/Compiler/ParseTreeTransforms.py",
> line 788, in visit_DefNode
>      pxd_def = self.scope.lookup(node.name)
>  AttributeError: 'NoneType' object has no attribute 'lookup'
>
>
> Compilation is fine if I merge the .pxd and the .py into a .pyx::
>
>  cpdef class Iter(object):
>
>      """A docstring."""
>
>      def __iter__(self):
>          return self
>
>      def __next__(self):
>          raise StopIteration
>
>
> Best regards,
> Riccardo
>
>
> --
> Riccardo Murri, via Rossée 17, 6987 Caslano (CH)
> _______________________________________________
> Cython-dev mailing list
> [email protected]
> http://codespeak.net/mailman/listinfo/cython-dev
>



-- 
Lisandro Dalcín
---------------
Centro Internacional de Métodos Computacionales en Ingeniería (CIMEC)
Instituto de Desarrollo Tecnológico para la Industria Química (INTEC)
Consejo Nacional de Investigaciones Científicas y Técnicas (CONICET)
PTLC - Güemes 3450, (3000) Santa Fe, Argentina
Tel/Fax: +54-(0)342-451.1594
_______________________________________________
Cython-dev mailing list
[email protected]
http://codespeak.net/mailman/listinfo/cython-dev

Reply via email to