]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
Give more detailed error message when the argument count isn't right.
authorGuido van Rossum <guido@python.org>
Wed, 19 Nov 1997 16:05:40 +0000 (16:05 +0000)
committerGuido van Rossum <guido@python.org>
Wed, 19 Nov 1997 16:05:40 +0000 (16:05 +0000)
Python/ceval.c

index fb179d1aa6e1a18724ce7f4d98a10ae038439d1c..fad8c2bf58d6724e2a57e648f82c171c1582d8a4 100644 (file)
@@ -454,8 +454,9 @@ eval_code2(co, globals, locals,
                }
                if (argcount > co->co_argcount) {
                        if (!(co->co_flags & CO_VARARGS)) {
-                               PyErr_SetString(PyExc_TypeError,
-                                               "too many arguments");
+                               PyErr_Format(PyExc_TypeError,
+                               "too many arguments; expected %d, got %d",
+                                            co->co_argcount, argcount);
                                goto fail;
                        }
                        n = co->co_argcount;
@@ -513,8 +514,9 @@ eval_code2(co, globals, locals,
                        int m = co->co_argcount - defcount;
                        for (i = argcount; i < m; i++) {
                                if (GETLOCAL(i) == NULL) {
-                                       PyErr_SetString(PyExc_TypeError,
-                                                  "not enough arguments");
+                                       PyErr_Format(PyExc_TypeError,
+                               "not enough arguments; expected %d, got %d",
+                                                    m, i);
                                        goto fail;
                                }
                        }