Skip to content

Commit

Permalink
Moved non-codec code outside of try block
Browse files Browse the repository at this point in the history
  • Loading branch information
radarhere committed Feb 28, 2022
1 parent a606fd8 commit 4d868ab
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/PIL/ImageFile.py
Original file line number Diff line number Diff line change
Expand Up @@ -223,11 +223,11 @@ def load(self):
)
]
for decoder_name, extents, offset, args in self.tile:
seek(offset)
decoder = Image._getdecoder(
self.mode, decoder_name, args, self.decoderconfig
)
try:
seek(offset)
decoder.setimage(self.im, extents)
if decoder.pulls_fd:
decoder.setfd(self.fp)
Expand Down Expand Up @@ -502,10 +502,10 @@ def _save(im, fp, tile, bufsize=0):
except (AttributeError, io.UnsupportedOperation) as exc:
# compress to Python file-compatible object
for e, b, o, a in tile:
if o > 0:
fp.seek(o)
e = Image._getencoder(im.mode, e, a, im.encoderconfig)
try:
if o > 0:
fp.seek(o)
e.setimage(im.im, b)
if e.pushes_fd:
e.setfd(fp)
Expand All @@ -523,10 +523,10 @@ def _save(im, fp, tile, bufsize=0):
else:
# slight speedup: compress to real file object
for e, b, o, a in tile:
if o > 0:
fp.seek(o)
e = Image._getencoder(im.mode, e, a, im.encoderconfig)
try:
if o > 0:
fp.seek(o)
e.setimage(im.im, b)
if e.pushes_fd:
e.setfd(fp)
Expand Down

0 comments on commit 4d868ab

Please sign in to comment.