mirror of
https://github.com/python/cpython.git
synced 2025-08-04 00:48:58 +00:00
bpo-31243: Fixed PyArg_ParseTuple failure checks. (#3171)
This commit is contained in:
parent
e9d978fd1b
commit
ba7d736521
4 changed files with 65 additions and 21 deletions
|
@ -1513,15 +1513,23 @@ textiowrapper_read_chunk(textio *self, Py_ssize_t size_hint)
|
|||
/* Given this, we know there was a valid snapshot point
|
||||
* len(dec_buffer) bytes ago with decoder state (b'', dec_flags).
|
||||
*/
|
||||
if (PyArg_ParseTuple(state, "OO", &dec_buffer, &dec_flags) < 0) {
|
||||
if (!PyTuple_Check(state)) {
|
||||
PyErr_SetString(PyExc_TypeError,
|
||||
"illegal decoder state");
|
||||
Py_DECREF(state);
|
||||
return -1;
|
||||
}
|
||||
if (!PyArg_ParseTuple(state,
|
||||
"OO;illegal decoder state", &dec_buffer, &dec_flags))
|
||||
{
|
||||
Py_DECREF(state);
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (!PyBytes_Check(dec_buffer)) {
|
||||
PyErr_Format(PyExc_TypeError,
|
||||
"decoder getstate() should have returned a bytes "
|
||||
"object, not '%.200s'",
|
||||
"illegal decoder state: the first item should be a "
|
||||
"bytes object, not '%.200s'",
|
||||
Py_TYPE(dec_buffer)->tp_name);
|
||||
Py_DECREF(state);
|
||||
return -1;
|
||||
|
@ -2408,8 +2416,8 @@ _io_TextIOWrapper_tell_impl(textio *self)
|
|||
} \
|
||||
if (!PyBytes_Check(dec_buffer)) { \
|
||||
PyErr_Format(PyExc_TypeError, \
|
||||
"decoder getstate() should have returned a bytes " \
|
||||
"object, not '%.200s'", \
|
||||
"illegal decoder state: the first item should be a " \
|
||||
"bytes object, not '%.200s'", \
|
||||
Py_TYPE(dec_buffer)->tp_name); \
|
||||
Py_DECREF(_state); \
|
||||
goto fail; \
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue