Vitja Makarov | 23 Apr 09:26 2012
Picon

Re: [Cython] Cython 0.16: "eval" problem

2012/4/22 Vitja Makarov <vitja.makarov@...>:
> 2012/4/22 Nathan Dunfield <nmd@...>:
>> On Apr 22, 2012, at 1:22 PM, Vitja Makarov wrote:
>>> Oops, it seems to be a problem with locals() dict creation.
>>
>> Yes it does.   The following variants of my original example both work:
>>
>> ## prob.pyx version 1
>>
>> def cy_eval(s):
>>    return eval(s)
>>
>> def f(x):
>>    cdef int* p
>>    return cy_eval(x)
>>
>> ## prob.pyx version 2
>>
>> def f(x):
>>    cdef int* p
>>    return eval(x, {})
>>
>> Best,
>>
>>        Nathan
>>
>
> I've fixed it here:
> https://github.com/vitek/cython/commit/6dc132731b8f3f7eaabf55e51d89bcbc7b8f4eb7
>
> Now waiting for jenkins, then I'll push it into upstream. As a
> workaround you can manually pass locals dictionary, e.g.:
>
> eval(x, None, {'a: a})
>

Btw before 0.16 locals() weren't passed to eval. I've tried the
following code and it fails with 0.15:

def foo():
    cdef int *a
    return locals()

I've pushed fix to upstream/master
https://github.com/cython/cython/commit/0b133e00a7bc3c53ea60d3cf4ae8eb3e20ef49ec

--

-- 
vitja.

Gmane