[Cython] strange error message

B. Clausius barcc at gmx.de
Fri Jan 1 04:53:11 EST 2016


Am 31.12.2015 um 01:00 schrieb Robert Bradshaw:
> On Mon, Dec 28, 2015 at 1:15 PM, Baptiste Carvello
> <devel at baptiste-carvello.net> wrote:
>> Le 28/12/2015 17:12, Baptiste Carvello a écrit :
>>> Hi,
>>>
>>> not a cython dev, but I believe I hit the very same problem (I'm going
>>> on vacation now, full report in January).
>>>
>>> You may fix the compilation error by adding the following unused import:
>>>>>> from gldraw import vec4
>>
>> sorry, that's a cimport, i.e.
>>
>>>>> from gldraw cimport vec4
> 
> +1, that's the solution. We should make the error better...

I added that line and replaced "cdef void sync():" by
"cpdef void sync():" to be able to test it:

$ cat glarea.pyx
cimport gldraw
from gldraw cimport vec4

cdef struct Data:
    gldraw.mat4 matrix

cdef Data data

cpdef void sync():
    data.changed = True  # <- this wrong line produces the error

It compiles without errors, but i get a exception at runtime (not
surprised):

$ python3
Python 3.4.3+ (default, Oct 14 2015, 16:03:50)
[GCC 5.2.1 20151010] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import glarea
>>> glarea.sync()
Exception ignored in: 'glarea.sync'
AttributeError: 'dict' object has no attribute 'changed'
>>>

This would be ok for me, but i wonder if cython should recognize this at
compile time. The code tries to assign a new attribute to a cdef struct
and that will always fail, or am I wrong?



More information about the cython-devel mailing list