summaryrefslogtreecommitdiffstats
path: root/Modules/_codecsmodule.c
diff options
context:
space:
mode:
Diffstat (limited to 'Modules/_codecsmodule.c')
-rw-r--r--Modules/_codecsmodule.c19
1 files changed, 13 insertions, 6 deletions
diff --git a/Modules/_codecsmodule.c b/Modules/_codecsmodule.c
index 0716f3a..d4eb0d5 100644
--- a/Modules/_codecsmodule.c
+++ b/Modules/_codecsmodule.c
@@ -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 *