diff options
author | Vincent Sanders <vince@kyllikki.org> | 2019-12-31 19:42:33 +0000 |
---|---|---|
committer | Vincent Sanders <vince@kyllikki.org> | 2019-12-31 19:42:33 +0000 |
commit | 5632c9c8c0e8ddf3b5945fd36b19dff7367851c5 (patch) | |
tree | aa5d12f13d3dae323cdda293487624f911a465ca /test | |
parent | bcc64cf263cd730ba8c13d31870528c160403e88 (diff) | |
download | netsurf-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
Diffstat (limited to 'test')
-rw-r--r-- | test/monkeyfarmer.py | 6 |
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)) |