summaryrefslogtreecommitdiffstats
path: root/Objects/classobject.c
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>1993-04-08 12:56:19 (GMT)
committerGuido van Rossum <guido@python.org>1993-04-08 12:56:19 (GMT)
commit8a0c3456c2020d1a1f87619c4651e4eab831938a (patch)
treeb5832b6f3c092a198b34c75b377389abee57d32a /Objects/classobject.c
parent9575a4457559ed280bdd66e600fbd9f1b54d86d2 (diff)
downloadcpython-8a0c3456c2020d1a1f87619c4651e4eab831938a.zip
cpython-8a0c3456c2020d1a1f87619c4651e4eab831938a.tar.gz
cpython-8a0c3456c2020d1a1f87619c4651e4eab831938a.tar.bz2
Fix bug in class instance hash (forgot to clear error condition).
Diffstat (limited to 'Objects/classobject.c')
-rw-r--r--Objects/classobject.c11
1 files changed, 8 insertions, 3 deletions
diff --git a/Objects/classobject.c b/Objects/classobject.c
index 823e397..587d122 100644
--- a/Objects/classobject.c
+++ b/Objects/classobject.c
@@ -317,7 +317,7 @@ instance_hash(inst)
{
object *func;
object *res;
- int outcome;
+ long outcome;
func = instance_getattr(inst, "__hash__");
if (func == NULL) {
@@ -325,8 +325,13 @@ instance_hash(inst)
If a __cmp__ method exists, there must be a __hash__. */
err_clear();
func = instance_getattr(inst, "__cmp__");
- if (func == NULL)
- return (long)inst;
+ if (func == NULL) {
+ err_clear();
+ outcome = (long)inst;
+ if (outcome == -1)
+ outcome = -2;
+ return outcome;
+ }
err_setstr(TypeError, "unhashable instance");
return -1;
}