[Cython] Compiler crash at parsing stage

Stefan Behnel stefan_ml at behnel.de
Sun Oct 23 10:15:52 CEST 2011


Vitja Makarov, 23.10.2011 08:39:
> This simple code crashes compiler:
>
> lambda i=1: i
>
> """
>    File "/home/vitja/work/cython-vitek-git/Cython/Compiler/Parsing.py",
> line 122, in p_test
>      return p_lambdef(s)
>    File "/home/vitja/work/cython-vitek-git/Cython/Compiler/Parsing.py",
> line 102, in p_lambdef
>      s, terminator=':', annotated=False)
>    File "/home/vitja/work/cython-vitek-git/Cython/Compiler/Parsing.py",
> line 2741, in p_varargslist
>      annotated = annotated)
>    File "/home/vitja/work/cython-vitek-git/Cython/Compiler/Parsing.py",
> line 2388, in p_c_arg_list
>      annotated = annotated))
>    File "/home/vitja/work/cython-vitek-git/Cython/Compiler/Parsing.py",
> line 2435, in p_c_arg_decl
>      print s.level
> AttributeError: 'PyrexScanner' object has no attribute 'level'
> """
>
> I'm not sure what's the best way to fix this.

I don't see a "print" statement anywhere, but it seems that the "level" 
attribute is really missing from the compiled scanner.

This should do the trick:

diff -r 886697a10602 Cython/Compiler/Scanning.pxd
--- a/Cython/Compiler/Scanning.pxd      Sat Oct 22 19:43:45 2011 +0100
+++ b/Cython/Compiler/Scanning.pxd      Sun Oct 23 10:11:10 2011 +0200
@@ -28,6 +28,7 @@
      cdef public int bracket_nesting_level
      cdef public sy
      cdef public systring
+    cdef public level

      cdef long current_level(self)
      #cpdef commentline(self, text)

I didn't commit it, just go ahead and do so if it works for you.

Stefan


More information about the cython-devel mailing list