Fix bug in class instance hash (forgot to clear error condition).

This commit is contained in:
Guido van Rossum 1993-04-08 12:56:19 +00:00
parent 9575a44575
commit 8a0c3456c2

View File

@ -317,7 +317,7 @@ instance_hash(inst)
{ {
object *func; object *func;
object *res; object *res;
int outcome; long outcome;
func = instance_getattr(inst, "__hash__"); func = instance_getattr(inst, "__hash__");
if (func == NULL) { if (func == NULL) {
@ -325,8 +325,13 @@ instance_hash(inst)
If a __cmp__ method exists, there must be a __hash__. */ If a __cmp__ method exists, there must be a __hash__. */
err_clear(); err_clear();
func = instance_getattr(inst, "__cmp__"); func = instance_getattr(inst, "__cmp__");
if (func == NULL) if (func == NULL) {
return (long)inst; err_clear();
outcome = (long)inst;
if (outcome == -1)
outcome = -2;
return outcome;
}
err_setstr(TypeError, "unhashable instance"); err_setstr(TypeError, "unhashable instance");
return -1; return -1;
} }