mirror of
https://github.com/python-pillow/Pillow.git
synced 2025-08-10 07:14:46 +03:00
Reduce duplicate code in Image open
This commit is contained in:
parent
926a08cdb3
commit
53a966d80f
15
PIL/Image.py
15
PIL/Image.py
|
@ -2299,19 +2299,8 @@ def open(fp, mode="r"):
|
||||||
|
|
||||||
preinit()
|
preinit()
|
||||||
|
|
||||||
for i in ID:
|
for i in range(0, 2):
|
||||||
try:
|
if i == 0 or init():
|
||||||
factory, accept = OPEN[i]
|
|
||||||
if not accept or accept(prefix):
|
|
||||||
fp.seek(0)
|
|
||||||
im = factory(fp, filename)
|
|
||||||
_decompression_bomb_check(im.size)
|
|
||||||
return im
|
|
||||||
except (SyntaxError, IndexError, TypeError, struct.error):
|
|
||||||
logger.debug("", exc_info=True)
|
|
||||||
|
|
||||||
if init():
|
|
||||||
|
|
||||||
for i in ID:
|
for i in ID:
|
||||||
try:
|
try:
|
||||||
factory, accept = OPEN[i]
|
factory, accept = OPEN[i]
|
||||||
|
|
Loading…
Reference in New Issue
Block a user