mirror of
https://github.com/python/cpython.git
synced 2025-11-25 21:11:09 +00:00
The incremental decoder for utf-7 must preserve its state between calls.
Solves issue1460. Might not be a backport candidate: a new API function was added, and some code may rely on details in utf-7.py.
This commit is contained in:
parent
8c4592a77a
commit
5087980c1e
5 changed files with 61 additions and 23 deletions
|
|
@ -230,18 +230,25 @@ unicode_internal_decode(PyObject *self,
|
|||
|
||||
static PyObject *
|
||||
utf_7_decode(PyObject *self,
|
||||
PyObject *args)
|
||||
PyObject *args)
|
||||
{
|
||||
const char *data;
|
||||
Py_ssize_t size;
|
||||
const char *errors = NULL;
|
||||
int final = 0;
|
||||
Py_ssize_t consumed;
|
||||
PyObject *decoded = NULL;
|
||||
|
||||
if (!PyArg_ParseTuple(args, "t#|z:utf_7_decode",
|
||||
&data, &size, &errors))
|
||||
return NULL;
|
||||
if (!PyArg_ParseTuple(args, "t#|zi:utf_7_decode",
|
||||
&data, &size, &errors, &final))
|
||||
return NULL;
|
||||
consumed = size;
|
||||
|
||||
return codec_tuple(PyUnicode_DecodeUTF7(data, size, errors),
|
||||
size);
|
||||
decoded = PyUnicode_DecodeUTF7Stateful(data, size, errors,
|
||||
final ? NULL : &consumed);
|
||||
if (decoded == NULL)
|
||||
return NULL;
|
||||
return codec_tuple(decoded, consumed);
|
||||
}
|
||||
|
||||
static PyObject *
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue