mirror of
https://github.com/python/cpython.git
synced 2025-11-25 21:11:09 +00:00
Patch #1455898: Incremental mode for "mbcs" codec.
This commit is contained in:
parent
6ce9fe880b
commit
d825143be1
6 changed files with 214 additions and 50 deletions
|
|
@ -479,15 +479,20 @@ mbcs_decode(PyObject *self,
|
|||
PyObject *args)
|
||||
{
|
||||
const char *data;
|
||||
Py_ssize_t size;
|
||||
Py_ssize_t size, consumed;
|
||||
const char *errors = NULL;
|
||||
int final = 1;
|
||||
PyObject *decoded;
|
||||
|
||||
if (!PyArg_ParseTuple(args, "t#|z:mbcs_decode",
|
||||
&data, &size, &errors))
|
||||
if (!PyArg_ParseTuple(args, "t#|zi:mbcs_decode",
|
||||
&data, &size, &errors, &final))
|
||||
return NULL;
|
||||
|
||||
return codec_tuple(PyUnicode_DecodeMBCS(data, size, errors),
|
||||
size);
|
||||
decoded = PyUnicode_DecodeMBCSStateful(
|
||||
data, size, errors, final ? NULL : &consumed);
|
||||
if (!decoded)
|
||||
return NULL;
|
||||
return codec_tuple(decoded, final ? size : consumed);
|
||||
}
|
||||
|
||||
#endif /* MS_WINDOWS */
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue