[Cython] Compiler crash at parsing stage

Vitja Makarov vitja.makarov at gmail.com
Sun Oct 23 11:05:09 CEST 2011


2011/10/23 Stefan Behnel <stefan_ml at behnel.de>:
> 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.
>

Yes, I've added print for debug purpose actually there is:
        if 'pxd' in s.level:

> 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.
>

Hmm, that will help for compiled cython. I'm running uncompiled.
It seems that when lambda is spotted level is not set yet. Btw it
works fine if def node precedes lamda:

def foo(): pass
lambda i=1: i


-- 
vitja.


More information about the cython-devel mailing list