~sschwarzer/ftputil#114: 
Uncaught EOF error in host._avaliable_child

There is an uncaught ftplib EOF exception in _avaliable_child that does not get transformed to standard FTPUtil errors.

File "/usr/lib/python3.6/site-packages/ftputil/host.py", line 523, in download
    conditional=False, callback=callback)
  File "/usr/lib/python3.6/site-packages/ftputil/file_transfer.py", line 182, in copy_file
    source_fobj = source_file.fobj()
  File "/usr/lib/python3.6/site-packages/ftputil/file_transfer.py", line 94, in fobj
    return self._host.open(self.name, self.mode)
  File "/usr/lib/python3.6/site-packages/ftputil/host.py", line 203, in open
    host = self._available_child()
  File "/usr/lib/python3.6/site-packages/ftputil/host.py", line 167, in _available_child
    host._session.pwd()
  File "/usr/lib64/python3.6/ftplib.py", line 654, in pwd
    resp = self.voidcmd('PWD')
  File "/usr/lib64/python3.6/ftplib.py", line 276, in voidcmd
    return self.voidresp()
  File "/usr/lib64/python3.6/ftplib.py", line 249, in voidresp
    resp = self.getresp()
  File "/usr/lib64/python3.6/ftplib.py", line 234, in getresp
    resp = self.getmultiline()
  File "/usr/lib64/python3.6/ftplib.py", line 220, in getmultiline
    line = self.getline()
  File "/usr/lib64/python3.6/ftplib.py", line 208, in getline
    raise EOFError
Status
RESOLVED FIXED
Submitter
ftputiluser (unverified)
Assigned to
No-one
Submitted
6 years ago
Updated
6 years ago
Labels
bug library

schwa (unverified) 6 years ago · edit

Thanks for the report! I think I'll look into it on Saturday.

schwa (unverified) 6 years ago · edit

Do you have a small example script to reproduce the problem? I'd like to see why an EOFError would be raised in pwd.

ftputiluser (unverified) 6 years ago · edit

Don't have a script right now, what we did is to first connect to ​ftp://208.74.245.143 as annonymous.

Then we used fptHost.download to try to download /CompanyManager/Quickbooks? (10).2/MF/C/Program Files (x86)/Common Files/Intuit/Sync?/Sybase10/mlrsa10.dll

That's when this came up.

schwa (unverified) 6 years ago · edit

I tried the following code to reproduce the error:

import ftputil


with ftputil.FTPHost("208.74.245.143", "anonymous", "me@here.org") as host:
    host.download("/CompanyManager/Quickbooks (10).2/MF/C/Program Files (x86)/"
                  "Common Files/Intuit/Sync/Sybase10/mlrsa10.dll",
                  "mlrsa10.dll")

However, in three runs of this code I wasn't able to reproduce the traceback. The download succeeded without any errors.

That said, this error looks somewhat similar to that in ticket #112, although there's a difference. In ticket #112, self.file.readline in getline raises an OSError whereas here, in ticket #114, the readline call succeeds and the following check if not line raises an EOFError.

The comment for the getline method is interesting:

# Raise EOFError if the connection is closed

I assume the server closed the connection at some point while downloading many files.

Usually, I don't add exception handling code because of an assumption and not even being able to reproduce an error. However, _available_child already catches several exceptions and the pwd call in _available_child is an implementation detail whose exceptions the user shouldn't have to deal with. Therefore, I'll catch EOFError there in addition to ftplib.error_temp, ftplib.error_reply and OSError.

schwa (unverified) 6 years ago · edit

Register here or Log in to comment, or comment via email.