On Dec 7, 2009, at 11:57 AM, Lisandro Dalcin wrote:

> On Mon, Dec 7, 2009 at 3:29 PM, Robert Bradshaw
> <[email protected]> wrote:
>>
>> I'd rather be overly cautious.
>
> Indeed. However, I think Cython should switch from an error to a
> warning. That way, everybody should be more or less happy.
>
>>
>> I don't think it's strange
>> to have to recompile when a C-level dependancy changes, even if the
>> change is compatible.
>>
>
> You are right, but developers should keep in mind that having to
> recompile is a major hurdle for other end-users.
>
>>
>> I'm still a bit confused though--numpy types are declared as "extern"
>> so I wouldn't expect their size to be checked.
>>
>
> This is not the case. The code is here:

Oh, I forgot that it used sizeof(...) on the externally declared struct.

>
>
> #ifndef __PYX_HAVE_RT_ImportType
> #define __PYX_HAVE_RT_ImportType
> static PyTypeObject *__Pyx_ImportType(const char *module_name, const
> char *class_name, long size)
> {
> .....
>    if (((PyTypeObject *)result)->tp_basicsize != size) {
>        PyErr_Format(PyExc_ValueError,
>            "%s.%s does not appear to be the correct type object",
>            module_name, class_name);
>        goto bad;
>    }
> ....
> }
> #endif
>
>
> So, in short, what about making this at least a (silenceable) warning,
> instead of an (unrecoverable) error ?

You do make a good argument for issuing a warning rather than an  
error. Are you sure this is the only place we use the size of the  
type? Should we be more strict with Cython-defined (non-extern) types?  
Should we require that the struct size at least goes up? What about if  
one tried to extend one of these "expanded" types?

One hesitation I have is that allowing this is that very strange and  
hard to debug errors can result due to undetected binary  
incompatibilities--I certainly don't want it to be too easy to ignore  
this warning. This is one of those situations where I want a big sign  
that says "undefined behavior ahead, you better know what you're doing!"

- Robert

_______________________________________________
Cython-dev mailing list
[email protected]
http://codespeak.net/mailman/listinfo/cython-dev

Reply via email to