Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #31252 > unrolled thread

Re: Understanding and dealing with an exception

Started byMRAB <python@mrabarnett.plus.com>
First post2012-10-14 16:13 +0100
Last post2012-10-14 16:13 +0100
Articles 1 — 1 participant

Back to article view | Back to comp.lang.python

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  Re: Understanding and dealing with an exception MRAB <python@mrabarnett.plus.com> - 2012-10-14 16:13 +0100

#31252 — Re: Understanding and dealing with an exception

FromMRAB <python@mrabarnett.plus.com>
Date2012-10-14 16:13 +0100
SubjectRe: Understanding and dealing with an exception
Message-ID<mailman.2177.1350227640.27098.python-list@python.org>
On 2012-10-14 05:23, Vincent Davis wrote:
> I am working on a script to find bad image files. I am using PIL
> and specifically image.verify() I have a set of known to be bad image
> files to test. I also what to be able to test any file for example a
> .txt and deal with the exception.
> Currently my code is basically
>
> try:
>      im = Image.open(ifile)
>      try:
>          print(im.verify())
>      except:
>          print('Pil image.verify() failed: ' + afile)
> except IOError:
>      print('PIL cannot identify image file: ' + afile)
> except:
>      print(ifile)
>      print("Unexpected error doing PIL.Image.open():", sys.exc_info()[0])
>      raise
>
[snip]
I notice that you have both "ifile" and "afile". Is that correct?

[toc] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web