diff options
author | Tim Peters <tim.peters@gmail.com> | 2001-11-29 03:26:37 (GMT) |
---|---|---|
committer | Tim Peters <tim.peters@gmail.com> | 2001-11-29 03:26:37 (GMT) |
commit | cffed4bc2162e453a8458d3014e23fa07b627aff (patch) | |
tree | b36a24eaaea05b20201f562ca35d4415528f67a6 /Python | |
parent | 42f5332f6de308c1d9b8f4df076aacf87d23ac11 (diff) | |
download | cpython-cffed4bc2162e453a8458d3014e23fa07b627aff.zip cpython-cffed4bc2162e453a8458d3014e23fa07b627aff.tar.gz cpython-cffed4bc2162e453a8458d3014e23fa07b627aff.tar.bz2 |
SF bug 486278 SystemError: Python/getargs.c:1086: bad.
vgetargskeywords(): Now that this routine is checking for bad input
(rather than dump core in some cases), some bad calls are raising errors
that previously "worked". This patch makes the error strings more
revealing, and changes the exceptions from SystemError to RuntimeError
(under the theory that SystemError is more of a "can't happen!" assert-
like thing, and so inappropriate for bad arguments to a public C API
function).
Diffstat (limited to 'Python')
-rw-r--r-- | Python/getargs.c | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/Python/getargs.c b/Python/getargs.c index 3a31913..a58816f 100644 --- a/Python/getargs.c +++ b/Python/getargs.c @@ -1049,7 +1049,7 @@ vgetargskeywords(PyObject *args, PyObject *keywords, char *format, /* Search the format: message <- error msg, if any (else NULL). - name <- routine name, if any (else NULL). + fname <- routine name, if any (else NULL). min <- # of required arguments, or -1 if all are required. max <- most arguments (required + optional). Check that kwlist has a non-NULL entry for each arg. @@ -1064,8 +1064,9 @@ vgetargskeywords(PyObject *args, PyObject *keywords, char *format, if (isalpha(i) && i != 'e') { max++; if (*p == NULL) { - /* kwlist is too short */ - PyErr_BadInternalCall(); + PyErr_SetString(PyExc_RuntimeError, + "more argument specifiers than " + "keyword list entries"); return 0; } p++; @@ -1081,15 +1082,17 @@ vgetargskeywords(PyObject *args, PyObject *keywords, char *format, break; } else if (i == '(') { - PyErr_SetString(PyExc_SystemError, - "tuple found in format when using keyword arguments"); + PyErr_SetString(PyExc_RuntimeError, + "tuple found in format when using keyword " + "arguments"); return 0; } } format = formatsave; if (*p != NULL) { - /* kwlist is too long */ - PyErr_BadInternalCall(); + PyErr_SetString(PyExc_RuntimeError, + "more keyword list entries than " + "argument specifiers"); return 0; } if (min < 0) { |