mirror of
https://github.com/python/cpython.git
synced 2025-08-03 00:23:06 +00:00
bpo-45467: Fix IncrementalDecoder and StreamReader in the "raw-unicode-escape" codec (GH-28944) (GH-28953)
They support now splitting escape sequences between input chunks.
Add the third parameter "final" in codecs.raw_unicode_escape_decode().
It is True by default to match the former behavior.
(cherry picked from commit 39aa98346d
)
This commit is contained in:
parent
7c722e32bf
commit
6848602806
8 changed files with 444 additions and 352 deletions
|
@ -507,17 +507,20 @@ _codecs_unicode_escape_decode_impl(PyObject *module, Py_buffer *data,
|
|||
_codecs.raw_unicode_escape_decode
|
||||
data: Py_buffer(accept={str, buffer})
|
||||
errors: str(accept={str, NoneType}) = None
|
||||
final: bool(accept={int}) = True
|
||||
/
|
||||
[clinic start generated code]*/
|
||||
|
||||
static PyObject *
|
||||
_codecs_raw_unicode_escape_decode_impl(PyObject *module, Py_buffer *data,
|
||||
const char *errors)
|
||||
/*[clinic end generated code: output=c98eeb56028070a6 input=d2f5159ce3b3392f]*/
|
||||
const char *errors, int final)
|
||||
/*[clinic end generated code: output=11dbd96301e2879e input=2d166191beb3235a]*/
|
||||
{
|
||||
PyObject *decoded = PyUnicode_DecodeRawUnicodeEscape(data->buf, data->len,
|
||||
errors);
|
||||
return codec_tuple(decoded, data->len);
|
||||
Py_ssize_t consumed = data->len;
|
||||
PyObject *decoded = _PyUnicode_DecodeRawUnicodeEscapeStateful(data->buf, data->len,
|
||||
errors,
|
||||
final ? NULL : &consumed);
|
||||
return codec_tuple(decoded, consumed);
|
||||
}
|
||||
|
||||
/*[clinic input]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue