﻿id	summary	reporter	owner	description	type	status	priority	milestone	component	version	resolution	keywords	cc	launchpad_bug
3854	builtins.TypeError: write() argument must be str, not bytes from allmydata/webish.py usage of FileUploadFieldStorage	exarkun	itamarst	"On Python 3.9 when issuing some request to the Tahoe-LAFS web API, this traceback comes up:

{{{
 2022-01-04T10:36:04-0500 [_GenericHTTPChannelProtocol,1,127.0.0.1] Unhandled Error
        Traceback (most recent call last):
          File ""python3.9/site-packages/twisted/python/log.py"", line 103, in callWithLogger
            return callWithContext({""system"": lp}, func, *args, **kw)
          File ""python3.9/site-packages/twisted/python/log.py"", line 86, in callWithContext
            return context.call({ILogContext: newCtx}, func, *args, **kw)
          File ""python3.9/site-packages/twisted/python/context.py"", line 122, in callWithContext
            return self.currentContext().callWithContext(ctx, func, *args, **kw)
          File ""python3.9/site-packages/twisted/python/context.py"", line 85, in callWithContext
            return func(*args,**kw)
        --- <exception caught here> ---
          File ""python3.9/site-packages/twisted/internet/posixbase.py"", line 614, in _doReadOrWrite
            why = selectable.doRead()
          File ""python3.9/site-packages/twisted/internet/tcp.py"", line 243, in doRead
            return self._dataReceived(data)
          File ""python3.9/site-packages/twisted/internet/tcp.py"", line 249, in _dataReceived
            rval = self.protocol.dataReceived(data)
          File ""python3.9/site-packages/twisted/web/http.py"", line 3024, in dataReceived
            return self._channel.dataReceived(data)
          File ""python3.9/site-packages/twisted/web/http.py"", line 2305, in dataReceived
            return basic.LineReceiver.dataReceived(self, data)
          File ""python3.9/site-packages/twisted/protocols/basic.py"", line 579, in dataReceived
            why = self.rawDataReceived(data)
          File ""python3.9/site-packages/twisted/web/http.py"", line 2312, in rawDataReceived
            self._transferDecoder.dataReceived(data)
          File ""python3.9/site-packages/twisted/web/http.py"", line 1755, in dataReceived
            finishCallback(data[contentLength:])
          File ""python3.9/site-packages/twisted/web/http.py"", line 2171, in _finishRequestBody
            self.allContentReceived()
          File ""python3.9/site-packages/twisted/web/http.py"", line 2284, in allContentReceived
            req.requestReceived(command, path, version)
          File ""python3.9/site-packages/allmydata/webish.py"", line 134, in requestReceived
            self.fields = FileUploadFieldStorage(
          File ""python3.9/cgi.py"", line 482, in __init__
            self.read_single()
          File ""python3.9/cgi.py"", line 675, in read_single
            self.read_binary()
          File ""python3.9/cgi.py"", line 697, in read_binary
            self.file.write(data)
        builtins.TypeError: write() argument must be str, not bytes
}}}

I'm not exactly sure yet what request triggers this.
"	defect	closed	normal	undecided	unknown	n/a	fixed	python3		
