mirror of https://github.com/python/cpython
Issue #24009: Got rid of using rare "y#" format unit in TextIOWrapper.tell().
Parsed value should be bytes, not general robuffer, this is required in other places.
This commit is contained in:
parent
9749b5a6a3
commit
008d88b462
|
@ -2262,7 +2262,6 @@ _io_TextIOWrapper_tell_impl(textio *self)
|
||||||
Py_ssize_t skip_bytes, skip_back;
|
Py_ssize_t skip_bytes, skip_back;
|
||||||
PyObject *saved_state = NULL;
|
PyObject *saved_state = NULL;
|
||||||
char *input, *input_end;
|
char *input, *input_end;
|
||||||
char *dec_buffer;
|
|
||||||
Py_ssize_t dec_buffer_len;
|
Py_ssize_t dec_buffer_len;
|
||||||
int dec_flags;
|
int dec_flags;
|
||||||
|
|
||||||
|
@ -2327,14 +2326,24 @@ _io_TextIOWrapper_tell_impl(textio *self)
|
||||||
goto fail;
|
goto fail;
|
||||||
|
|
||||||
#define DECODER_GETSTATE() do { \
|
#define DECODER_GETSTATE() do { \
|
||||||
|
PyObject *dec_buffer; \
|
||||||
PyObject *_state = PyObject_CallMethodObjArgs(self->decoder, \
|
PyObject *_state = PyObject_CallMethodObjArgs(self->decoder, \
|
||||||
_PyIO_str_getstate, NULL); \
|
_PyIO_str_getstate, NULL); \
|
||||||
if (_state == NULL) \
|
if (_state == NULL) \
|
||||||
goto fail; \
|
goto fail; \
|
||||||
if (!PyArg_ParseTuple(_state, "y#i", &dec_buffer, &dec_buffer_len, &dec_flags)) { \
|
if (!PyArg_ParseTuple(_state, "Oi", &dec_buffer, &dec_flags)) { \
|
||||||
Py_DECREF(_state); \
|
Py_DECREF(_state); \
|
||||||
goto fail; \
|
goto fail; \
|
||||||
} \
|
} \
|
||||||
|
if (!PyBytes_Check(dec_buffer)) { \
|
||||||
|
PyErr_Format(PyExc_TypeError, \
|
||||||
|
"decoder getstate() should have returned a bytes " \
|
||||||
|
"object, not '%.200s'", \
|
||||||
|
Py_TYPE(dec_buffer)->tp_name); \
|
||||||
|
Py_DECREF(_state); \
|
||||||
|
goto fail; \
|
||||||
|
} \
|
||||||
|
dec_buffer_len = PyBytes_GET_SIZE(dec_buffer); \
|
||||||
Py_DECREF(_state); \
|
Py_DECREF(_state); \
|
||||||
} while (0)
|
} while (0)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue