stop bad unicode data from crashing teh test harness

instead of exploding if monkey returns a bad unicode string instead
 a warning will be reported and the unicode decode performed with
 character replacemnt instead
This commit is contained in:
Vincent Sanders 2019-12-31 19:42:33 +00:00
parent bcc64cf263
commit 5632c9c8c0

View File

@ -115,7 +115,11 @@ class MonkeyFarmer(asyncore.dispatcher):
self.buffer += cmd.encode('utf-8')
def monkey_says(self, line):
line = line.decode('utf-8')
try:
line = line.decode('utf-8')
except UnicodeDecodeError:
print("WARNING: Unicode decode error")
line = line.decode('utf-8', 'replace')
if not self.quiet:
print("<<< {}".format(line))
self.discussion.append(("<", line))