Re: [Cython] Compiler crash at parsing stage

2011-10-23 Thread Stefan Behnel

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
___
cython-devel mailing list
cython-devel@python.org
http://mail.python.org/mailman/listinfo/cython-devel


Re: [Cython] What's wrong with py3k pyregr tests?

2011-10-23 Thread Stefan Behnel

Vitja Makarov, 21.10.2011 22:38:

2011/10/21 Stefan Behnel:

Stefan Behnel, 21.10.2011 12:01:


Vitja Makarov, 21.10.2011 11:44:


I tried to run pyregr tests on my localhost and it doesn't sigsegv.


It's a crash bug in the debug builds of the latest py3k branch.



Perhaps I should try compiled version of Cython.


Yes, but it's not required to reproduce the crash.


Hmm, I may have been mistaken. At least it seems to be a problem with
getattr(), which breaks the lookup of builtin names. My guess is that
unicode hashing is broken in some way for str subtypes (as we use for
names).


I switched to py3k-opt and it worked! Now we got ~13K/265:

https://sage.math.washington.edu:8091/hudson/view/dev-vitek/job/cython-vitek-tests-pyregr-py3k-c/


Very cool.

Note that the bug in CPython has finally been fixed, so the debug builds 
should be back to normal again. I re-enabled the tests for the master branch.


Stefan
___
cython-devel mailing list
cython-devel@python.org
http://mail.python.org/mailman/listinfo/cython-devel


Re: [Cython] Compiler crash at parsing stage

2011-10-23 Thread Vitja Makarov
2011/10/23 Stefan Behnel :
> 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.
___
cython-devel mailing list
cython-devel@python.org
http://mail.python.org/mailman/listinfo/cython-devel