1__doc__ = u""" 2>>> test(0) 30 4>>> test(1) 51 6>>> test(2) 72 8>>> str(test((1<<32)-1)) 9'4294967295' 10 11>>> try: test(-1) 12... except (OverflowError, TypeError): print("ERROR") 13ERROR 14 15>>> test(1<<128) #doctest: +ELLIPSIS 16Traceback (most recent call last): 17 ... 18OverflowError: ... 19 20>>> a = A(1,2) 21>>> a.a == 1 22True 23>>> a.b == 2 24True 25>>> a.foo(5) 265 27>>> try: a.foo(-1) 28... except (OverflowError, TypeError): print("ERROR") 29ERROR 30>>> a.foo(1 << 180) #doctest: +ELLIPSIS 31Traceback (most recent call last): 32 ... 33OverflowError: ... 34""" 35 36# XXX This should generate a warning !!! 37cdef extern from *: 38 ctypedef unsigned long size_t 39 40def test(size_t i): 41 return i 42 43cdef class A: 44 cdef public size_t a 45 cdef readonly size_t b 46 47 def __init__(self, size_t a, object b): 48 self.a = a 49 self.b = b 50 51 cpdef size_t foo(self, size_t x): 52 cdef object o = x 53 return o 54