summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVincent Sanders <vince@kyllikki.org>2019-12-31 19:42:33 +0000
committerVincent Sanders <vince@kyllikki.org>2019-12-31 19:42:33 +0000
commit5632c9c8c0e8ddf3b5945fd36b19dff7367851c5 (patch)
treeaa5d12f13d3dae323cdda293487624f911a465ca
parentbcc64cf263cd730ba8c13d31870528c160403e88 (diff)
downloadnetsurf-5632c9c8c0e8ddf3b5945fd36b19dff7367851c5.tar.gz
netsurf-5632c9c8c0e8ddf3b5945fd36b19dff7367851c5.tar.bz2
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
-rw-r--r--test/monkeyfarmer.py6
1 files changed, 5 insertions, 1 deletions
diff --git a/test/monkeyfarmer.py b/test/monkeyfarmer.py
index cbdda0c07..4dfc41a30 100644
--- a/test/monkeyfarmer.py
+++ b/test/monkeyfarmer.py
@@ -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))