projects
/
cython.git
/ blob
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
history
|
raw
|
HEAD
Remove trailing whitespace.
[cython.git]
/
tests
/
run
/
hash_T326.pyx
1
__doc__ = u"""
2
3
>>> hash(A(5))
4
5
5
>>> hash(A(-1))
6
-2
7
>>> hash(A(-2))
8
-2
9
>>> hash(A(100))
10
Traceback (most recent call last):
11
...
12
TypeError: That's kind of a round number...
13
14
"""
15
16
cdef class A:
17
cdef long a
18
def __init__(self, a):
19
self.a = a
20
def __hash__(self):
21
if self.a == 100:
22
raise TypeError, u"That's kind of a round number..."
23
else:
24
return self.a
25
26
cpdef long __hash__(long x):
27
"""
28
>>> __hash__(-1)
29
-1
30
"""
31
return x