From: Neal Norwitz Date: Sun, 16 Jul 2006 02:35:47 +0000 (+0000) Subject: PyFunction_SetDefaults() is documented as taking None or a tuple. X-Git-Tag: v2.5b3~235 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=ee4cc698ca906c519054a85d119c76e757227e82;p=python PyFunction_SetDefaults() is documented as taking None or a tuple. A NULL would crash the PyTuple_Check(). Now make NULL return a SystemError. Reported by Klocwork #73. --- diff --git a/Objects/funcobject.c b/Objects/funcobject.c index 59cb519507..e514eeb2d3 100644 --- a/Objects/funcobject.c +++ b/Objects/funcobject.c @@ -109,8 +109,8 @@ PyFunction_SetDefaults(PyObject *op, PyObject *defaults) } if (defaults == Py_None) defaults = NULL; - else if (PyTuple_Check(defaults)) { - Py_XINCREF(defaults); + else if (defaults && PyTuple_Check(defaults)) { + Py_INCREF(defaults); } else { PyErr_SetString(PyExc_SystemError, "non-tuple default args");