giampaolo / pyftpdlib

Extremely fast and scalable Python FTP server library
MIT License
1.65k stars 265 forks source link

Improve reliability of BufferedIteratorProducer when handling strings #623

Closed ABCurado closed 1 week ago

ABCurado commented 1 month ago

The implementation improves the existing code for the following reasons:

giampaolo commented 1 month ago

BufferedIteratorProducer is used by listing commands (LIST, MLSD), which use AbstractedFS.format_list and AbstractedFS.format_mlsx. You can simply have these last 2 methods return bytes instead of strings (like they do). That's basically part of the contract between the fiilesystem class and the handler class.

I don't think it's worth it to modify BufferedIteratorProducer for this. In addition, isinstance() has some computational cost (not big but still...)