Cython has moved to github.
cython-devel
view tests/run/exttype.pyx @ 1622:4f0327bdebc9
test for temp allocation bug in call
| author | Robert Bradshaw <robertwb@math.washington.edu> |
|---|---|
| date | Sat Jan 17 01:25:34 2009 -0800 (3 years ago) |
| parents | 612957ef6e8f |
| children | 82d312a9f1fc |
line source
1 __doc__ = u"""
2 >>> s = Spam(12)
3 >>> s.eat()
4 12 42
5 >>> f(s)
6 Traceback (most recent call last):
7 AttributeError: 'exttype.Spam' object has no attribute 'foo'
8 >>> s.eat()
9 12 42
11 >>> class Spam2(Spam):
12 ... foo = 1
13 >>> s = Spam2(12)
14 >>> s.eat()
15 12 42
16 >>> f(s)
17 >>> s.eat()
18 12 42
19 """
21 cdef gobble(a, b):
22 print a, b
24 cdef class Spam:
26 cdef eggs
27 cdef int ham
29 def __cinit__(self, eggs):
30 self.eggs = eggs
31 self.ham = 42
33 def __dealloc__(self):
34 self.ham = 0
36 def eat(self):
37 gobble(self.eggs, self.ham)
39 def f(Spam spam):
40 x = spam.eggs
41 y = spam.ham
42 z = spam.foo
43 spam.eggs = x
44 spam.ham = y
45 spam.foo = z
