effbot / pil-2009-raclette (http://effbot.org/zone/pil-index.htm)

Work repository for PIL 1.1.7 and beyond. The "default" branch should be fairly solid, the other branches less so. For production use, see the pil-117 repository.

Clone this repository (size: 1.3 MB): HTTPS / SSH
$ hg clone http://hg.effbot.org/pil-2009-raclette
commit 229: 454b4d2672f3
parent 228: 64f9636f4d92
branch: default
tags: pil-117-20090317, pil-117a1-20090317
Don't try to open files twice if plugins are already loaded.
Fredrik Lundh / effbot
17 months ago

Changed (Δ54 bytes):

raw changeset »

PIL/Image.py (11 lines added, 11 lines removed)

Up to file-list PIL/Image.py:

@@ -321,7 +321,7 @@ def init():
321
321
322
322
    global _initialized
323
323
    if _initialized >= 2:
324
        return
324
        return 0
325
325
326
326
    visited = {}
327
327
@@ -354,7 +354,7 @@ def init():
354
354
355
355
    if OPEN or SAVE:
356
356
        _initialized = 2
357
357
        return 1
358
358
359
359
# --------------------------------------------------------------------
360
360
# Codec factories (used by tostring/fromstring and ImageFile.load)
@@ -1957,16 +1957,16 @@ def open(fp, mode="r"):
1957
1957
        except (SyntaxError, IndexError, TypeError):
1958
1958
            pass
1959
1959
1960
    init()
1960
    if init():
1961
1961
1962
    for i in ID:
1963
        try:
1964
            factory, accept = OPEN[i]
1965
            if not accept or accept(prefix):
1966
                fp.seek(0)
1967
                return factory(fp, filename)
1968
        except (SyntaxError, IndexError, TypeError):
1969
            pass
1962
        for i in ID:
1963
            try:
1964
                factory, accept = OPEN[i]
1965
                if not accept or accept(prefix):
1966
                    fp.seek(0)
1967
                    return factory(fp, filename)
1968
            except (SyntaxError, IndexError, TypeError):
1969
                pass
1970
1970
1971
1971
    raise IOError("cannot identify image file")
1972
1972