Update ImageFile.py

This commit is contained in:
Joshua Blum 2017-05-12 18:48:03 -04:00
parent 82c51e4df9
commit e763c2281f

View File

@ -380,11 +380,8 @@ class Parser(object):
# attempt to open this file # attempt to open this file
try: try:
try: with io.BytesIO(self.data) as fp:
fp = io.BytesIO(self.data)
im = Image.open(fp) im = Image.open(fp)
finally:
fp.close() # explicitly close the virtual file
except IOError: except IOError:
# traceback.print_exc() # traceback.print_exc()
pass # not enough data pass # not enough data
@ -432,12 +429,11 @@ class Parser(object):
if self.data: if self.data:
# incremental parsing not possible; reopen the file # incremental parsing not possible; reopen the file
# not that we have all data # not that we have all data
try: with io.BytesIO(self.data) as fp:
fp = io.BytesIO(self.data) try:
self.image = Image.open(fp) self.image = Image.open(fp)
finally: finally:
self.image.load() self.image.load()
fp.close() # explicitly close the virtual file
return self.image return self.image