我正在使用Python和paramiko通过SFTP获取文件。最近文件号已经增长到〜56k,现在我得到了#Overflow错误的Python int太大而无法转换为C long" 当我尝试连接时尝试listdir()。这是我的代码:
transport = paramiko.Transport(host)
transport.connect(username=username, password=password)
sftp = paramiko.SFTPClient.from_transport(transport) # fails here
all_xmls = sftp.listdir(path=path_to_xml)
sftp.close()
transport.close()
我感兴趣的是:
更新1 : paramiko的日志输出:
DEB [20150819-12:18:26.055] thr=1 paramiko.transport: Switch to new keys ...
DEB [20150819-12:18:26.056] thr=2 paramiko.transport: Attempting password auth...
DEB [20150819-12:18:26.223] thr=1 paramiko.transport: userauth is OK
INF [20150819-12:18:26.285] thr=1 paramiko.transport: Authentication (password) successful!
DEB [20150819-12:18:26.288] thr=2 paramiko.transport: [chan 1] Max packet in: 34816 bytes
ERR [20150819-12:18:26.348] thr=1 paramiko.transport: Unknown exception: Python int too large to convert to C long
ERR [20150819-12:18:26.351] thr=1 paramiko.transport: Traceback (most recent call last):
ERR [20150819-12:18:26.351] thr=1 paramiko.transport: File "C:\Python27\lib\site-packages\paramiko\transport.py", line 1442, in run
ERR [20150819-12:18:26.351] thr=1 paramiko.transport: self._handler_table[ptype](self, m)
ERR [20150819-12:18:26.351] thr=1 paramiko.transport: File "C:\Python27\lib\site-packages\paramiko\transport.py", line 1848, in _parse_channel_open_success
ERR [20150819-12:18:26.351] thr=1 paramiko.transport: server_window_size = m.get_int()
ERR [20150819-12:18:26.351] thr=1 paramiko.transport: File "C:\Python27\lib\site-packages\paramiko\message.py", line 140, in get_int
ERR [20150819-12:18:26.351] thr=1 paramiko.transport: return util.inflate_long(self.get_binary())
ERR [20150819-12:18:26.351] thr=1 paramiko.transport: File "C:\Python27\lib\site-packages\paramiko\message.py", line 198, in get_binary
ERR [20150819-12:18:26.351] thr=1 paramiko.transport: return self.get_bytes(self.get_size())
ERR [20150819-12:18:26.351] thr=1 paramiko.transport: File "C:\Python27\lib\site-packages\paramiko\message.py", line 108, in get_bytes
ERR [20150819-12:18:26.351] thr=1 paramiko.transport: b = self.packet.read(n)
ERR [20150819-12:18:26.351] thr=1 paramiko.transport: OverflowError: Python int too large to convert to C long
ERR [20150819-12:18:26.351] thr=1 paramiko.transport:
更新2 : 我发现超量包。这是字节数 - 4294967040(为paramiko代码添加了简单的打印)
更新3 : 我找到了关于那个问题的paramiko的big tread at the github(这是第一个带有正确搜索查询的结果,对我感到羞耻)。他们说paramiko / message.py需要修复。 Commit #482就是这样。 我将观察它是如何工作的,然后发表答案。