[Twisted-Python] Twisted FTP: Data must not be unicode

Tobias Oberstein tobias.oberstein at tavendo.de
Thu Nov 24 09:26:12 EST 2011


> An even more correct solution would be for `line` to have been encoded
> properly already before it was passed to `sendLine`.  Where did the data
> come from, and why wasn't it encoded already?

The data is coming from the FTP directory listing formatting function

ftp.DTP. _formatOneListResponse

Here is a more localized fix:

[autobahn at autobahnhub ~/Twisted]$ svn diff twisted/protocols/ftp.py
Index: twisted/protocols/ftp.py
===================================================================
--- twisted/protocols/ftp.py    (revision 33225)
+++ twisted/protocols/ftp.py    (working copy)
@@ -415,7 +415,7 @@
             'group': group[:8],
             'size': size,
             'date': formatDate(time.gmtime(modified)),
-            'name': name}
+            'name': name.encode("utf-8")}

     def sendListResponse(self, name, response):
         self.sendLine(self._formatOneListResponse(name, *response))




More information about the Twisted-Python mailing list