[tarfile] Difficultis catching an exception

Wojtek Walczak gminick at bzt.bzt
Wed Aug 20 05:39:38 EDT 2008


On Wed, 20 Aug 2008 02:07:33 -0700 (PDT), boblatest at googlemail.com wrote:
> I'm trying to catch an "EOFError" exception that occurs when reading
> truncated tarfile. Here's my routine, and below that the callback
> trace. Note that although I'm trying to catch all TarFile exceptions,
> the tarfile.EOFError ecxeption, and the global EOFError exception, the
> program still falls through and fails.
...
>     except tarfile.TarError, EOFError, tarfile.EOFError:
...

Multiple exceptions should be parenthesized. BTW, are you sure
your tarfile has EOFError attribute?
Try this:

...
except (tarfile.TarError, EOFError):
...

-- 
Regards,
Wojtek Walczak,
http://tosh.pl/gminick/



More information about the Python-list mailing list