• Matti Picus's avatar
    Emit init code before body code (GH-3166) · 8d8795c6
    Matti Picus authored
    The test crash in cdef_multiple_inheritance has to do with a change in the method assignment. In the old version, the code
    
    cdef class Both(CBase, PyBase):
        cdef dict __dict__
        cdef c_method(self):
            return "Both"
        cpdef cp_method(self):
            return "Both"
        def call_c_method(self):
            return self.c_method()
    
    would assign cp_method and call_c_method to a PyMethodDef struct. In the new code only call_c_method is assigned in the PyMethodDef struct, but both are assigned to the __pyx_ptype...Both->tp_dict inside __Pyx_Init_Globals which happens while __pyx_ptype...Both is still NULL. The assignment __pyx_ptype...Both = &__pyx_type...Both happens in the next fragment, a few lines down.
    
    This PR reorders the fragments so that __pyx_type...Both is set up before the method assignments and does not seem to cause any new test failures.
    8d8795c6
cdef_multiple_inheritance.pyx 1.3 KB