]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
Fix bug in class instance hash (forgot to clear error condition).
authorGuido van Rossum <guido@python.org>
Thu, 8 Apr 1993 12:56:19 +0000 (12:56 +0000)
committerGuido van Rossum <guido@python.org>
Thu, 8 Apr 1993 12:56:19 +0000 (12:56 +0000)
Objects/classobject.c

index 823e397f7955e4aa0aeee4432047260da5d9592d..587d122aeedcbee7731d80e73e31b48e023c4996 100644 (file)
@@ -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;
        }