robertwb / issues-import-test

0 stars 0 forks source link

Bad code generated for closures in cdef methods #1006

Open robertwb opened 9 years ago

robertwb commented 9 years ago

From http://thread.gmane.org/gmane.comp.python.cython.user/13701, the following generates invalid name references in the C code:

cdef class A:
    cdef list x

    def __init__(self):
        self.x = [1,2,3]

    cdef f(self):
        pass

cdef class B(A):
    cdef f(self):
        z = tuple(None for y in self.x)

Generated C code contains this:

struct __pyx_obj_13cython_module___pyx_scope_struct____pyx_base.f;

Migrated from http://trac.cython.org/ticket/854

robertwb commented 9 years ago

scoder changed description from

cdef class A:
    cdef list x

    def __init__(self):
        self.x = [   cdef f(self):
        pass

cdef class B(A):
    cdef f(self):
        z = tuple(None for y in self.x)

to

From http://thread.gmane.org/gmane.comp.python.cython.user/13701, the following generates invalid name references in the C code:

cdef class A:
    cdef list x

    def __init__(self):
        self.x = [1,2,3](1,2,3]

)

    cdef f(self):
        pass

cdef class B(A):
    cdef f(self):
        z = tuple(None for y in self.x)

Generated C code contains this:

struct __pyx_obj_13cython_module___pyx_scope_struct____pyx_base.f;

summary from

Bad code generated for closures in cdef methods. to

Bad code generated for closures in cdef methods