Python中的FTPServer在'mget'上抛出异常

时间:2012-11-30 15:12:40

标签: python python-3.x ftp-server

I implemented a FTP Server in Python using pyftpdlib.ftpserver
This works fine with mput/put operations but fails with mget/get. Following exception is thrown:
  

[] 10.203.200.136:62408已连接。       10.203.200.136:62408 ==> 220 pyftpdlib 0.5.2准备好了。       10.203.200.136:62408< == USER用户       10.203.200.136:62408 ==> 331用户名ok,发送密码。       10.203.200.136:62408< == PASS **       10.203.200.136:62408 ==> 230登录成功。       [user] @ 10.203.200.136:62408用户用户已登录。       10.203.200.136:62408< == TYPE A.       10.203.200.136:62408 ==> 200类型设置为:ASCII。       10.203.200.136:62408< == PORT 10,203,200,136,243,206       10.203.200.136:62408 ==>建立了200个活动数据连接。       10.203.200.136:62408< == NLST RS.pcap       [user] @ 10.203.200.136:62408 OK NLST“/RS.pcap”。转移开始。       10.203.200.136:62408 ==> 125数据连接已打开。转移开始。       10.203.200.136:62408 ==> 226转移完成。       10.203.200.136:62408< == TYPE A.       10.203.200.136:62408 ==> 200类型设置为:ASCII。       10.203.200.136:62408< == PORT 10,203,200,136,243,208       10.203.200.136:62408 ==>建立了200个活动数据连接。       10.203.200.136:62408< == RETR RS.pcap       [user] @ 10.203.200.136:62408 OK RETR“/RS.pcap”。下载开始。       10.203.200.136:62408 ==> 125数据连接已打开。转移开始。       10.203.200.136:62408 ==> 426内部错误;转移中止。

Traceback (most recent call last):
    File "C:\Python31\lib\asynchat.py", line 244, in initiate_send
        data = buffer(first, 0, obs)
    File "C:\Python31\lib\asynchat.py", line 56, in buffer
        memoryview(obj)
TypeError: cannot make memory view because object does not have the buffer interface

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
    File "C:\Python31\lib\pyftpdlib\ftpserver.py", line 2077, in push_dtp_data
        self.data_channel.push_with_producer(data)
    File "C:\Python31\lib\asynchat.py", line 211, in push_with_producer
        self.initiate_send()
    File "C:\Python31\lib\asynchat.py", line 246, in initiate_send
        data = first.more()
    File "C:\Python31\lib\pyftpdlib\ftpserver.py", line 1143, in more
        return bytes(data, BYTES_ENCODING)
TypeError: encoding or errors without a string argument

现在在asynchat.py(内部调用)中,在initiate_send中调用buffer,当memoryview(obj)完成时抛出异常; obj是FileProducer类型的对象。

任何人都可以建议可能的错误吗? python库中有问题吗?怎么解决?

1 个答案:

答案 0 :(得分:0)

很难说没有看到一些实际的代码。它似乎与str / bytes的区别有关(Python 3中的Python 3已经改变)。从pyftpdlib主页看,pyftpdlib看起来还不支持Python 3。