~sschwarzer/ftputil

1

host.walk fails on ftputil.error.ParserError

Details
Message ID
<CAM1O0_8Rsr2dBBRjccETrk-bgNA8ygN8j2J8_Fv7qTaMu4bvtw@mail.gmail.com>
DKIM signature
missing
Download raw message
I'm using ftputil 5.0.4 with Python 3.7 on Windows. I am getting an
unhandled ftputil.error.ParserError with host.walk. Probably the FTP
server doing something weird (or a corrupt file or something). But the
walk interface shouldn't fail on this error (imho).

Suggest changing line 1031 in host.py to:

        except (ftputil.error.FTPOSError, ftputil.error.ParserError) as err:

This fixes the error for me.
Details
Message ID
<73a03192-08e5-e0f5-6159-704db4e71060@sschwarzer.net>
In-Reply-To
<CAM1O0_8Rsr2dBBRjccETrk-bgNA8ygN8j2J8_Fv7qTaMu4bvtw@mail.gmail.com> (view parent)
DKIM signature
missing
Download raw message
Hi Simon,

On 2022-09-01 11:51, Simon Cox wrote:
> I'm using ftputil 5.0.4 with Python 3.7 on Windows. I am getting an
> unhandled ftputil.error.ParserError with host.walk. Probably the FTP
> server doing something weird (or a corrupt file or something). But the
> walk interface shouldn't fail on this error (imho).
> 
> Suggest changing line 1031 in host.py to:
> 
>          except (ftputil.error.FTPOSError, ftputil.error.ParserError) as err:
> 
> This fixes the error for me.

Thank you for the heads up and the patch. :-)

I'd be curious what the actual directory listing line from
the server is that causes the error. At the moment I think
it would make more sense to fix/extend the directory listing
parser in
https://git.sr.ht/~sschwarzer/ftputil/tree/main/item/ftputil/stat.py
instead of just ignoring the error. (Also, your patch would
skip all lines that follow the problematic line and maybe
you want to include at least these in your `walk` result.)

Can you send the actual traceback to the list? If the
traceback isn't enough to understand the parser error, it
might help to print the line at the beginning of the
`parse_line` method,
https://git.sr.ht/~sschwarzer/ftputil/tree/main/item/ftputil/stat.py#L444
or
https://git.sr.ht/~sschwarzer/ftputil/tree/main/item/ftputil/stat.py#L528 ,
depending on which parser is selected, and send this line in
the mail, too.

Best regards,
Stefan
Reply to thread Export thread (mbox)