mirror of
https://github.com/python/cpython.git
synced 2025-08-04 17:08:35 +00:00
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.
This commit is contained in:
parent
d413c50363
commit
39aa98346d
7 changed files with 116 additions and 35 deletions
|
@ -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
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue