]> granicus.if.org Git - python/commitdiff
Fix bug in comparing function objects detected by Sjoerd:
authorGuido van Rossum <guido@python.org>
Tue, 5 Aug 1997 16:51:05 +0000 (16:51 +0000)
committerGuido van Rossum <guido@python.org>
Tue, 5 Aug 1997 16:51:05 +0000 (16:51 +0000)
SystemError: bad argument to internal function

caused by comparing NULL pointer default args.

Objects/funcobject.c

index 53c926f3ca4197445f763efc86cf80d8a0de4228..be67259ce9884600f0b7ad0c2995b10b6725f6fd 100644 (file)
@@ -182,9 +182,15 @@ func_compare(f, g)
        int c;
        if (f->func_globals != g->func_globals)
                return (f->func_globals < g->func_globals) ? -1 : 1;
-       c = PyObject_Compare(f->func_defaults, g->func_defaults);
-       if (c != 0)
-               return c;
+       if (f->func_defaults != g->func_defaults) {
+               if (f->func_defaults == NULL)
+                       return -1;
+               if (g->func_defaults == NULL)
+                       return 1;
+               c = PyObject_Compare(f->func_defaults, g->func_defaults);
+               if (c != 0)
+                       return c;
+       }
        return PyObject_Compare(f->func_code, g->func_code);
 }