Index: modsupport.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Python/modsupport.c,v retrieving revision 2.70 diff -u -r2.70 modsupport.c --- modsupport.c 19 Nov 2003 15:24:47 -0000 2.70 +++ modsupport.c 13 Jul 2004 20:51:45 -0000 @@ -152,6 +152,7 @@ { PyObject *d; int i; + int itemfailed = 0; if (n < 0) return NULL; if ((d = PyDict_New()) == NULL) @@ -161,19 +162,22 @@ int err; k = do_mkvalue(p_format, p_va); if (k == NULL) { - Py_DECREF(d); - return NULL; + /* continue on error, must process all 'N' arguments */ + itemfailed = 1; + Py_INCREF(Py_None); + k = Py_None; } v = do_mkvalue(p_format, p_va); if (v == NULL) { - Py_DECREF(k); - Py_DECREF(d); - return NULL; + /* continue on error, must process all 'N' arguments */ + itemfailed = 1; + Py_INCREF(Py_None); + v = Py_None; } err = PyDict_SetItem(d, k, v); Py_DECREF(k); Py_DECREF(v); - if (err < 0) { + if (err < 0 || itemfailed) { Py_DECREF(d); return NULL; } @@ -194,6 +198,7 @@ { PyObject *v; int i; + int itemfailed = 0; if (n < 0) return NULL; if ((v = PyList_New(n)) == NULL) @@ -201,8 +206,10 @@ for (i = 0; i < n; i++) { PyObject *w = do_mkvalue(p_format, p_va); if (w == NULL) { - Py_DECREF(v); - return NULL; + /* continue on error, must process all 'N' arguments */ + itemfailed = 1; + Py_INCREF(Py_None); + w = Py_None; } PyList_SetItem(v, i, w); } @@ -214,6 +221,10 @@ } else if (endchar) ++*p_format; + if (itemfailed) { + Py_DECREF(v); + v = NULL; + } return v; } @@ -233,6 +244,7 @@ { PyObject *v; int i; + int itemfailed = 0; if (n < 0) return NULL; if ((v = PyTuple_New(n)) == NULL) @@ -240,8 +252,10 @@ for (i = 0; i < n; i++) { PyObject *w = do_mkvalue(p_format, p_va); if (w == NULL) { - Py_DECREF(v); - return NULL; + /* continue on error, must process all 'N' arguments */ + itemfailed = 1; + Py_INCREF(Py_None); + w = Py_None; } PyTuple_SetItem(v, i, w); } @@ -253,6 +267,10 @@ } else if (endchar) ++*p_format; + if (itemfailed) { + Py_DECREF(v); + v = NULL; + } return v; }