giampaolo / pyftpdlib

Extremely fast and scalable Python FTP server library
MIT License
1.68k stars 263 forks source link

Improve reliability of BufferedIteratorProducer when handling strings #623

Closed ABCurado closed 4 months ago

ABCurado commented 6 months ago

The implementation improves the existing code for the following reasons:

giampaolo commented 6 months 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...)