summaryrefslogtreecommitdiffstats
path: root/Include
diff options
context:
space:
mode:
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>2021-10-14 17:02:20 (GMT)
committerGitHub <noreply@github.com>2021-10-14 17:02:20 (GMT)
commit0bff4ccbfd3297b0adf690655d3e9ddb0033bc69 (patch)
tree439b5ad3c00be6899738d124277dc79daa50377b /Include
parent70b150a366e4d8e426f45d24a421fd70f833a8c5 (diff)
downloadcpython-0bff4ccbfd3297b0adf690655d3e9ddb0033bc69.zip
cpython-0bff4ccbfd3297b0adf690655d3e9ddb0033bc69.tar.gz
cpython-0bff4ccbfd3297b0adf690655d3e9ddb0033bc69.tar.bz2
[3.10] bpo-45461: Fix IncrementalDecoder and StreamReader in the "unicode-escape" codec (GH-28939) (GH-28943)
They support now splitting escape sequences between input chunks. Add the third parameter "final" in codecs.unicode_escape_decode(). It is True by default to match the former behavior. (cherry picked from commit c96d1546b11b4c282a7e21737cb1f5d16349656d) Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
Diffstat (limited to 'Include')
-rw-r--r--Include/cpython/unicodeobject.h10
1 files changed, 9 insertions, 1 deletions
diff --git a/Include/cpython/unicodeobject.h b/Include/cpython/unicodeobject.h
index 0b5067f..a004895 100644
--- a/Include/cpython/unicodeobject.h
+++ b/Include/cpython/unicodeobject.h
@@ -834,12 +834,20 @@ PyAPI_FUNC(PyObject*) _PyUnicode_EncodeUTF16(
/* --- Unicode-Escape Codecs ---------------------------------------------- */
+/* Variant of PyUnicode_DecodeUnicodeEscape that supports partial decoding. */
+PyAPI_FUNC(PyObject*) _PyUnicode_DecodeUnicodeEscapeStateful(
+ const char *string, /* Unicode-Escape encoded string */
+ Py_ssize_t length, /* size of string */
+ const char *errors, /* error handling */
+ Py_ssize_t *consumed /* bytes consumed */
+);
/* Helper for PyUnicode_DecodeUnicodeEscape that detects invalid escape
chars. */
-PyAPI_FUNC(PyObject*) _PyUnicode_DecodeUnicodeEscape(
+PyAPI_FUNC(PyObject*) _PyUnicode_DecodeUnicodeEscapeInternal(
const char *string, /* Unicode-Escape encoded string */
Py_ssize_t length, /* size of string */
const char *errors, /* error handling */
+ Py_ssize_t *consumed, /* bytes consumed */
const char **first_invalid_escape /* on return, points to first
invalid escaped char in
string. */