# HG changeset patch # User Fredrik Lundh # Date 1237271621 -3600 # Node ID 454b4d2672f38b368713d1f3365c6fff62597620 # Parent 64f9636f4d921ea0612f65fddde12fa8666aa6eb Don't try to open files twice if plugins are already loaded. diff -r 64f9636f4d921ea0612f65fddde12fa8666aa6eb -r 454b4d2672f38b368713d1f3365c6fff62597620 PIL/Image.py --- a/PIL/Image.py Tue Mar 17 07:13:59 2009 +0100 +++ b/PIL/Image.py Tue Mar 17 07:33:41 2009 +0100 @@ -321,7 +321,7 @@ global _initialized if _initialized >= 2: - return + return 0 visited = {} @@ -354,7 +354,7 @@ if OPEN or SAVE: _initialized = 2 - + return 1 # -------------------------------------------------------------------- # Codec factories (used by tostring/fromstring and ImageFile.load) @@ -1957,16 +1957,16 @@ except (SyntaxError, IndexError, TypeError): pass - init() + if init(): - for i in ID: - try: - factory, accept = OPEN[i] - if not accept or accept(prefix): - fp.seek(0) - return factory(fp, filename) - except (SyntaxError, IndexError, TypeError): - pass + for i in ID: + try: + factory, accept = OPEN[i] + if not accept or accept(prefix): + fp.seek(0) + return factory(fp, filename) + except (SyntaxError, IndexError, TypeError): + pass raise IOError("cannot identify image file")