2010/12/6 Stefan Behnel <[email protected]>: > Vitja Makarov, 06.12.2010 08:33: >> 2010/12/6 Stefan Behnel: >>> Vitja Makarov, 06.12.2010 07:05: >>>> 2010/12/6 Stefan Behnel: >>>>> Vitja Makarov, 05.12.2010 08:41: >>>>>> >>>>>> I've updated patch. >>>>>> >>>>>> I removed pretty_name, bad idea should use name instead in >>>>>> pydeclare_lambda. >>>>>> `is_lambda` is now called `is_anonymous`, that means that entry itself >>>>>> doesn't know how it will be named inside scope, so its anonymous (both >>>>>> lambda and pyfunctions) >>>>> >>>>> That's ok and the patch looks good to me now. >>>>> >>>>> However, it lacks error tests and the modified code actually fails to >>>>> detect >>>>> redefinitions of cdef functions as Python functions and vice versa, which >>>>> is >>>>> not supported (and IMHO doesn't make sense either). Similarly, >>>>> redefinitions >>>>> in cdef classes aren't currently supported but are not detected either. >>>>> >>>>> I've attached a patch that currently breaks cpdef functions, but that >>>>> handles (and tests) at least some of the error cases. I'm not sure what to >>>>> do to fix the cpdef functions, though. >>>> >>>> I can't say it breaks cpdefs, this is "classic" cython behavior. >>> >>> Did you try running the test suite with it? >> >> I mean that cython wo redefinition patches will copile code like this >> but gcc will not: >> >> cpdef foo(): pass >> cpdef foo(): pass >> >> xxx.c:444: error: redefinition of ‘__pyx_f_3xxx_foo’ > > Right. That needs fixing, but I agree that it's not related to your patch. > > >>>> May by we need some flag like is_hardcoded? >>> >>> Which would mean what exactly? >> >> Means that symbol is defined in method table, bad name for flag. >> >> So as I understand when function is cpdef it first declare cfunction, >> then pycfunction. >> >> So entry is always of type CFunction so maybe this flag should be >> called has_pyfunction? and error message should be raised in >> _declare_pyfunction() if has_pyfunction flag is set? > > Something like that. There should be a way to detect a cpdef function and > to prevent overriding cdef functions otherwise. > > Stefan
I've update patch (just fixed typo, and added "first declared here" error) I think we should create ticket for cpdef issue. What the problem is: cpdef foo(): pass cpdef foo(): pass 1. declare pyfunction `foo` with allow_redefine=False 2. declare cfunction `foo`, overwriting entry 3. declare pyfunction `foo` with allow_redefine=False 3. declare cfunction `foo`, already overwrited So the problem actually is in declare_cfunction() -- vitja. _______________________________________________ Cython-dev mailing list [email protected] http://codespeak.net/mailman/listinfo/cython-dev
