mirror of
https://github.com/python/cpython.git
synced 2025-08-04 00:48:58 +00:00
Merge: #16564: Fix regression in use of encoders.encode_noop with binary data.
This commit is contained in:
commit
6cb1d67eb3
4 changed files with 28 additions and 0 deletions
|
@ -76,3 +76,9 @@ def encode_7or8bit(msg):
|
|||
|
||||
def encode_noop(msg):
|
||||
"""Do nothing."""
|
||||
# Well, not quite *nothing*: in Python3 we have to turn bytes into a string
|
||||
# in our internal surrogateescaped form in order to keep the model
|
||||
# consistent.
|
||||
orig = msg.get_payload()
|
||||
if not isinstance(orig, str):
|
||||
msg.set_payload(orig.decode('ascii', 'surrogateescape'))
|
||||
|
|
|
@ -406,6 +406,9 @@ class BytesGenerator(Generator):
|
|||
else:
|
||||
super(BytesGenerator,self)._handle_text(msg)
|
||||
|
||||
# Default body handler
|
||||
_writeBody = _handle_text
|
||||
|
||||
@classmethod
|
||||
def _compile_re(cls, s, flags):
|
||||
return re.compile(s.encode('ascii'), flags)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue