0
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 用户名好,发送密码。10.203.200.136:62408 <== 通过** 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 <== 端口 10,203,200,136,243,206 10.203.200.136:62408 ==> 200 已建立活动数据连接。10.203.200.136:62408 <== NLST RS.pcap [用户]@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 <== A 型 10.203.200.136:62408 ==> 200 类型设置为:ASCII。10.203.200.136:62408 <== 端口 10,203,200,136,243,208 10.203.200.136:62408 ==> 200 已建立活动数据连接。10.203.200.136:62408 <== RETR RS.pcap [用户]@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(内部调用)中,在initial_send 中调用缓冲区,当 memoryview(obj) 完成时抛出异常;obj 是 FileProducer 类型的对象。

谁能提出可能的错误是什么?python库有问题吗?如何解决?

4

1 回答 1

0

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

于 2012-11-30T17:04:38.657 回答