This also manifests itself when using web.py: if the underlying code throws an exception, this is emitted:
File "/usr/local/lib/python3.5/dist-packages/web/webapi.py", line 364, in input
out = rawinput(_method)
File "/usr/local/lib/python3.5/dist-packages/web/webapi.py", line 341, in rawinput
a = cgi.FieldStorage(fp=fp, environ=e, keep_blank_values=1)
File "/usr/lib/python3.5/cgi.py", line 561, in __init__
self.read_single()
File "/usr/lib/python3.5/cgi.py", line 740, in read_single
self.read_binary()
File "/usr/lib/python3.5/cgi.py", line 762, in read_binary
self.file.write(data)
TypeError: write() argument must be str, not bytes