Fix bug in comparing function objects detected by Sjoerd:

SystemError: bad argument to internal function

caused by comparing NULL pointer default args.
This commit is contained in:
Guido van Rossum 1997-08-05 16:51:05 +00:00
parent d6615ab30c
commit 83f9ad8399
1 changed files with 9 additions and 3 deletions

View 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);
}