paramiko SftpServer doesn't pass O_BINARY

Robey Pointer robey at lag.net
Fri Dec 2 03:44:58 GMT 2005


On 1 Dec 2005, at 18:51, John A Meinel wrote:

> Robey Pointer wrote:
>>
>> On 1 Dec 2005, at 18:09, John A Meinel wrote:
>>
>>> In trying to test on Win32, I've been having problems with line- 
>>> ending
>>> conversions.
>>>
>>> It turned out that the StubSFTPServer is actually converting the  
>>> lines.
>>> What happens is that paramiko/sftp_server.py never passes  
>>> os.O_BINARY
>>>
>>> My workaround is as follows:
>>
>> The workaround looks good.  This is my mistake, sorry.  SFTP declares
>> all files to be in "binary mode", so a fake SFTP server should do  
>> the same.
>>
>
> If that is the sftp spec, why doesn't Paramiko's SftpServer send
> O_BINARY? Just because it is implied?

The O_BINARY thing confused me, but I just now figured out what you  
mean.  I'm guessing that on Windows, python defines an "os.O_BINARY"  
flag?  There's no such flag on posix.  I suppose paramiko could  
always add that flag when running on Windows, but maybe it's better  
if I just document more clearly that files are always in binary mode.

robey


PS. It looks like in v4 of the sftp protocol, they added a TEXT_MODE  
flag for clients to ask for line-ending translation.  Then they made  
it useless by adding a server option, mandatory for clients to obey,  
where the server can define what a newline looks like, putting all  
the work back on the client's side.  This is moot since nobody  
implements anything past v3, but I thought it was worth a chuckle.





More information about the bazaar mailing list