Cython has moved to github.

cython-devel

view tests/run/typedfieldbug_T303.pyx @ 3091:1a2e04bc1395

remove dependency on structmember.h
author Lisandro Dalcin <dalcinl@gmail.com>
date Thu Mar 11 17:21:13 2010 -0300 (2 years ago)
parents 55355f898a02
children 371b4a8148d6
line source
1 __doc__ = """
2 >>> readonly() #doctest: +ELLIPSIS
3 Traceback (most recent call last):
4 ...
5 TypeError: ...
6 """
8 import sys
9 if sys.version_info[0:2] >= (2,4):
10 __doc__ = __doc__.replace(u'TypeError:', u'AttributeError:')
13 cdef extern from "external_defs.h":
14 ctypedef float DoubleTypedef
15 ctypedef float LongDoubleTypedef
17 cdef public DoubleTypedef global_tdef
18 cdef public double global_double
20 cdef class MyClass:
21 cdef readonly:
22 double actual_double
23 DoubleTypedef float_isreally_double
24 LongDoubleTypedef float_isreally_longdouble
26 def __init__(self):
27 self.actual_double = 42.0
28 self.float_isreally_double = 42.0
29 self.float_isreally_longdouble = 42.0
31 def global_vars(x):
32 """
33 >>> global_vars(12.0)
34 12.0 12.0
35 """
36 global global_tdef, global_double
37 global_tdef = x
38 global_double = x
39 print global_tdef, global_double
41 def f():
42 """
43 >>> f()
44 42.0
45 42.0
46 """
47 cdef object c = MyClass()
48 print c.actual_double
49 print c.float_isreally_double
51 def longdouble_access():
52 """
53 >>> longdouble_access()
54 42.0
55 """
56 cdef object c = MyClass()
57 print c.float_isreally_longdouble
60 def readonly():
61 cdef object c = MyClass()
62 c.actual_double = 3