diff options
author | Serhiy Storchaka <storchaka@gmail.com> | 2016-02-07 23:22:47 (GMT) |
---|---|---|
committer | Serhiy Storchaka <storchaka@gmail.com> | 2016-02-07 23:22:47 (GMT) |
commit | 4cd63ef67a3e0974f0c48c550769babd401075e3 (patch) | |
tree | d96420c663097f5a73a1a29f9fa29dd231563591 /Python | |
parent | 3e17c788a877ad65a48ad357cf3947934e036075 (diff) | |
download | cpython-4cd63ef67a3e0974f0c48c550769babd401075e3.zip cpython-4cd63ef67a3e0974f0c48c550769babd401075e3.tar.gz cpython-4cd63ef67a3e0974f0c48c550769babd401075e3.tar.bz2 |
Issue #26198: ValueError is now raised instead of TypeError on buffer
overflow in parsing "es#" and "et#" format units. SystemError is now raised
instead of TypeError on programmical error in parsing format string.
Diffstat (limited to 'Python')
-rw-r--r-- | Python/getargs.c | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/Python/getargs.c b/Python/getargs.c index 60b7677..be6e375 100644 --- a/Python/getargs.c +++ b/Python/getargs.c @@ -394,7 +394,12 @@ seterror(Py_ssize_t iarg, const char *msg, int *levels, const char *fname, PyOS_snprintf(p, sizeof(buf) - (p - buf), " %.256s", msg); message = buf; } - PyErr_SetString(PyExc_TypeError, message); + if (msg[0] == '(') { + PyErr_SetString(PyExc_SystemError, message); + } + else { + PyErr_SetString(PyExc_TypeError, message); + } } @@ -1129,7 +1134,7 @@ convertsimple(PyObject *arg, const char **p_format, va_list *p_va, int flags, } else { if (size + 1 > BUFFER_LEN) { Py_DECREF(s); - PyErr_Format(PyExc_TypeError, + PyErr_Format(PyExc_ValueError, "encoded string too long " "(%zd, maximum length %zd)", (Py_ssize_t)size, (Py_ssize_t)(BUFFER_LEN-1)); |