You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Trying to make StringIO handle unicode and pass it through to
FieldStorage to eliminate the error:
self = FieldStorage(None, None, ''), line = '{ "data": "Joe Doe 1" }'
def __write(self, line):
"""line is always bytes, not string"""
if self.__file is not None:
if self.__file.tell() + len(line) > 1000:
self.file = self.make_file()
data = self.__file.getvalue()
self.file.write(data)
self.__file = None
if self._binary_file:
# keep bytes
self.file.write(line)
else:
# decode to string
> self.file.write(line.decode(self.encoding, self.errors))
E AttributeError: 'str' object has no attribute 'decode'
0 commit comments