Fix BytesGenerator._handle_text() if the message has no payload (None)

This commit is contained in:
Victor Stinner 2011-01-26 00:39:19 +00:00
parent 0c4cc559cb
commit 3a7ee3ab5a
1 changed files with 5 additions and 2 deletions

View File

@ -377,8 +377,11 @@ class BytesGenerator(Generator):
def _handle_text(self, msg):
# If the string has surrogates the original source was bytes, so
# just write it back out.
if _has_surrogates(msg._payload):
self.write(msg._payload)
payload = msg.get_payload()
if payload is None:
return
if _has_surrogates(payload):
self.write(payload)
else:
super(BytesGenerator,self)._handle_text(msg)