On Aug 5, 2008, at 4:51 AM, Dag Sverre Seljebotn wrote:

> While dealing with my pragma code I encountered this issue which I  
> want
> to note down (I need to know how to deal with it for pragmas):
>
> cimport python_int as a
> a.PyInt_Check(3)
> cimport python_dict as a
> a.PyInt_Check(3)
> a.PyDict_New()
>
> Apparently, only the first cimport is considered, so that  
> PyDict_New is
> turned into a module dict lookup and PyInt_Check is a native C call  
> also
> the second time. If the order of the cimports are reversed, the  
> opposite
> happen.
>
> It wouldn't take long to raise a compiler error on the second  
> cimport as
> a fix for now ("name a already taken by a cimport"), but since it  
> would
> break backwards compatability to some degree (of already broken  
> code, I
> suppose) I wanted to check with you first.

I think there should be a compile time error here. Code that violates  
this assumption is clearly wrong and easily fixed.

Cython is much looser about allowing re-declarations of things then  
it should be--and this needs to be fixed.

> Long term I suppose having the second PyInt_Check above turn into a
> dictionary lookup above is the wanted behaviour, but given that we  
> give
> a compiler error now then such behaviour will be backwards compatible.

I'm not even sure how to sanely do that with cimports. What happens  
here?

cimport x as a

def foo():
     return a.foo()

cimport y as a


- Robert


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

Reply via email to