[Twisted-Python] Twisted FTP: Data must not be unicode
Adi Roiban
adi at roiban.ro
Thu Nov 24 10:26:42 EST 2011
On Jo, 2011-11-24 at 15:00 +0000, exarkun at twistedmatrix.com wrote:
> On 02:26 pm, tobias.oberstein at tavendo.de wrote:
> >>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))
>
> Cool, that seems much more reasonable. It would be great if you could
> file a ticket for this. Thanks!
The source of this evil is FTPAnonymousShell.list as this is the entry
point for the file name.
FTPAnonymousShell.list
--
Adi Roiban
More information about the Twisted-Python
mailing list