简体   繁体   中英

FTPServer in Python throws exception on 'mget'

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 Connected. 10.203.200.136:62408 ==> 220 pyftpdlib 0.5.2 ready. 10.203.200.136:62408 <== USER user 10.203.200.136:62408 ==> 331 Username ok, send password. 10.203.200.136:62408 <== PASS ** 10.203.200.136:62408 ==> 230 Login successful. [user]@10.203.200.136:62408 User user logged in. 10.203.200.136:62408 <== TYPE A 10.203.200.136:62408 ==> 200 Type set to: ASCII. 10.203.200.136:62408 <== PORT 10,203,200,136,243,206 10.203.200.136:62408 ==> 200 Active data connection established. 10.203.200.136:62408 <== NLST RS.pcap [user]@10.203.200.136:62408 OK NLST "/RS.pcap". Transfer starting. 10.203.200.136:62408 ==> 125 Data connection already open. Transfer starting. 10.203.200.136:62408 ==> 226 Transfer complete. 10.203.200.136:62408 <== TYPE A 10.203.200.136:62408 ==> 200 Type set to: ASCII. 10.203.200.136:62408 <== PORT 10,203,200,136,243,208 10.203.200.136:62408 ==> 200 Active data connection established. 10.203.200.136:62408 <== RETR RS.pcap [user]@10.203.200.136:62408 OK RETR "/RS.pcap". Download starting. 10.203.200.136:62408 ==> 125 Data connection already open. Transfer starting. 10.203.200.136:62408 ==> 426 Internal error; transfer aborted.

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

Now in asynchat.py (which is called internally), in initiate_send, buffer is called which throws an exception when memoryview(obj) is done; obj being a FileProducer type of object.

Can anyone please suggest what possible error is it? Is there a problem in python library? How to solve it?

Hard to say without seeing some actual code. It seems to be related to the str/bytes distinction (which has changed in Python 3 from Python 2). From the pyftpdlib homepage, it looks like pyftpdlib doesn't support Python 3 yet.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM