diff options
author | Serhiy Storchaka <storchaka@gmail.com> | 2021-10-14 17:04:19 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-10-14 17:04:19 (GMT) |
commit | 39aa98346d5dd8ac591a7cafb467af21c53f1e5d (patch) | |
tree | d363b62f299171467fce0cd3e1fe155c2ca41a09 /Lib/encodings | |
parent | d413c503636cde2a6ab0ada25dccb0134633a8e6 (diff) | |
download | cpython-39aa98346d5dd8ac591a7cafb467af21c53f1e5d.zip cpython-39aa98346d5dd8ac591a7cafb467af21c53f1e5d.tar.gz cpython-39aa98346d5dd8ac591a7cafb467af21c53f1e5d.tar.bz2 |
bpo-45467: Fix IncrementalDecoder and StreamReader in the "raw-unicode-escape" codec (GH-28944)
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.
Diffstat (limited to 'Lib/encodings')
-rw-r--r-- | Lib/encodings/raw_unicode_escape.py | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/Lib/encodings/raw_unicode_escape.py b/Lib/encodings/raw_unicode_escape.py index 2b919b4..46c8e07 100644 --- a/Lib/encodings/raw_unicode_escape.py +++ b/Lib/encodings/raw_unicode_escape.py @@ -21,15 +21,16 @@ class IncrementalEncoder(codecs.IncrementalEncoder): def encode(self, input, final=False): return codecs.raw_unicode_escape_encode(input, self.errors)[0] -class IncrementalDecoder(codecs.IncrementalDecoder): - def decode(self, input, final=False): - return codecs.raw_unicode_escape_decode(input, self.errors)[0] +class IncrementalDecoder(codecs.BufferedIncrementalDecoder): + def _buffer_decode(self, input, errors, final): + return codecs.raw_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.raw_unicode_escape_decode(input, errors, False) ### encodings module API |