diff options
author | Miss Islington (bot) <31488909+miss-islington@users.noreply.github.com> | 2021-10-14 17:02:20 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-10-14 17:02:20 (GMT) |
commit | 0bff4ccbfd3297b0adf690655d3e9ddb0033bc69 (patch) | |
tree | 439b5ad3c00be6899738d124277dc79daa50377b /Lib/encodings | |
parent | 70b150a366e4d8e426f45d24a421fd70f833a8c5 (diff) | |
download | cpython-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 'Lib/encodings')
-rw-r--r-- | Lib/encodings/unicode_escape.py | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/Lib/encodings/unicode_escape.py b/Lib/encodings/unicode_escape.py index 817f932..9b1ce99b 100644 --- a/Lib/encodings/unicode_escape.py +++ b/Lib/encodings/unicode_escape.py @@ -21,15 +21,16 @@ class IncrementalEncoder(codecs.IncrementalEncoder): def encode(self, input, final=False): return codecs.unicode_escape_encode(input, self.errors)[0] -class IncrementalDecoder(codecs.IncrementalDecoder): - def decode(self, input, final=False): - return codecs.unicode_escape_decode(input, self.errors)[0] +class IncrementalDecoder(codecs.BufferedIncrementalDecoder): + def _buffer_decode(self, input, errors, final): + return codecs.unicode_escape_decode(input, errors, final) class StreamWriter(Codec,codecs.StreamWriter): pass class StreamReader(Codec,codecs.StreamReader): - pass + def decode(self, input, errors='strict'): + return codecs.unicode_escape_decode(input, errors, False) ### encodings module API |