blob: dbabc47835d13c5f92b6c428892c27e7b810ddfb (
plain)
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
|
__doc__ = u"""
>>> test(0)
0
>>> test(1)
1
>>> test(2)
2
>>> str(test((1<<32)-1))
'4294967295'
>>> try: test(-1)
... except (OverflowError, TypeError): print("ERROR")
ERROR
>>> test(1<<128) #doctest: +ELLIPSIS
Traceback (most recent call last):
...
OverflowError: ...
>>> a = A(1,2)
>>> a.a == 1
True
>>> a.b == 2
True
>>> a.foo(5)
5
>>> try: a.foo(-1)
... except (OverflowError, TypeError): print("ERROR")
ERROR
>>> a.foo(1 << 180) #doctest: +ELLIPSIS
Traceback (most recent call last):
...
OverflowError: ...
"""
# XXX This should generate a warning !!!
cdef extern from *:
ctypedef unsigned long size_t
def test(size_t i):
return i
cdef class A:
cdef public size_t a
cdef readonly size_t b
def __init__(self, size_t a, object b):
self.a = a
self.b = b
cpdef size_t foo(self, size_t x):
cdef object o = x
return o
|