File: e_cstruct.pyx

package info (click to toggle)
cython 3.0.11%2Bdfsg-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 19,092 kB
  • sloc: python: 83,539; ansic: 18,831; cpp: 1,402; xml: 1,031; javascript: 511; makefile: 403; sh: 204; sed: 11
file content (33 lines) | stat: -rw-r--r-- 887 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# mode: error

cdef struct Spam:
    int i
    char c
    float[42] *p
    obj             # error - py object

#cdef struct Spam: # error - redefined (not an error in Cython, should it be?)
#    int j

cdef struct Grail

cdef void eggs(Spam s):
    cdef int j
    cdef Grail *gp
    j = s.k # error - undef attribute
    j = s.p # type error
    s.p = j # type error
    j = j.i # no error - coercion to Python object
    j.i = j # no error - coercion to Python object
    j = gp.x # error - incomplete type
    gp.x = j # error - incomplete type


_ERRORS = u"""
7:4: C struct/union member cannot be a Python object
17:9: Object of type 'Spam' has no attribute 'k'
18:9: Cannot assign type 'float (*)[42]' to 'int'
19:10: Cannot assign type 'int' to 'float (*)[42]'
22:10: Cannot select attribute of incomplete type 'Grail'
23:6: Cannot select attribute of incomplete type 'Grail'
"""