[reportlab-users] Appengine - Reportlab (Get Photo from Model)

Andy Robinson andy at reportlab.com
Tue Oct 5 03:45:10 EDT 2010

On 5 October 2010 08:20, Henning von Bargen <H.vonBargen at t-p.com> wrote:

> The following code in utils.py is bad coding style IMHO

> as it hides the actual cause and results in a possibly misleading message:


>                    from reportlab.pdfbase.pdfutils import readJPEGInfo

>                    try:

>                        self._width,self._height,c=readJPEGInfo(self.fp)

>                    except:

>                        raise RuntimeError('Imaging Library not available, unable to import bitmaps only jpegs')

>                    ...

I agree completely. If PIL cannot be imported, readJPEGInfo should
raise an exception saying so. If it's otherwise unexpected 'bad JPEG
data' it should either say so or raise the naked exception.

I guess we could fix this and write a unit test to verify appropriate
exceptions occur..

- Andy

More information about the reportlab-users mailing list