Merge: #16564: Fix regression in use of encoders.encode_noop with binary data.

This commit is contained in:
R David Murray 2013-02-09 13:10:54 -05:00
commit 6cb1d67eb3
4 changed files with 28 additions and 0 deletions

View file

@ -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'))

View file

@ -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)