]> granicus.if.org Git - python/commitdiff
Fix PR117. The error message is "keywords must be strings". Perhaps
authorGuido van Rossum <guido@python.org>
Tue, 26 Oct 1999 00:12:20 +0000 (00:12 +0000)
committerGuido van Rossum <guido@python.org>
Tue, 26 Oct 1999 00:12:20 +0000 (00:12 +0000)
not as descriptive as what Barry suggests, but this also catches the
(in my opinion important) case where some other C code besides apply()
constructs a kwdict that doesn't have the right format.  All the other
possibilities of getting it wrong (non-dict, wrong keywords etc) are
already caught so this makes sense to check here.

Python/ceval.c

index 4c1bf2f8b4304d66e09c6c92faae2e97ef18ffe9..fe2e0a2910f69fd73a9b3d1dd0528dcb6419de0d 100644 (file)
@@ -482,6 +482,11 @@ eval_code2(co, globals, locals,
                        PyObject *keyword = kws[2*i];
                        PyObject *value = kws[2*i + 1];
                        int j;
+                       if (keyword == NULL || !PyString_Check(keyword)) {
+                               PyErr_SetString(PyExc_TypeError,
+                                               "keywords must be strings");
+                               goto fail;
+                       }
                        /* XXX slow -- speed up using dictionary? */
                        for (j = 0; j < co->co_argcount; j++) {
                                PyObject *nm = PyTuple_GET_ITEM(