mirror of
https://github.com/python-pillow/Pillow.git
synced 2025-01-26 09:14:27 +03:00
Close exclusive fp on open exception
This commit is contained in:
parent
3d76a686c4
commit
747eccbfc2
|
@ -17,11 +17,15 @@ class TestBmpReference(PillowTestCase):
|
||||||
""" These shouldn't crash/dos, but they shouldn't return anything
|
""" These shouldn't crash/dos, but they shouldn't return anything
|
||||||
either """
|
either """
|
||||||
for f in self.get_files('b'):
|
for f in self.get_files('b'):
|
||||||
try:
|
def open(f):
|
||||||
im = Image.open(f)
|
try:
|
||||||
im.load()
|
im = Image.open(f)
|
||||||
except Exception: # as msg:
|
im.load()
|
||||||
pass
|
except Exception: # as msg:
|
||||||
|
pass
|
||||||
|
|
||||||
|
# Assert that there is no unclosed file warning
|
||||||
|
self.assert_warning(None, open, f)
|
||||||
|
|
||||||
def test_questionable(self):
|
def test_questionable(self):
|
||||||
""" These shouldn't crash/dos, but it's not well defined that these
|
""" These shouldn't crash/dos, but it's not well defined that these
|
||||||
|
|
|
@ -2641,6 +2641,10 @@ def open(fp, mode="r"):
|
||||||
# opening failures that are entirely expected.
|
# opening failures that are entirely expected.
|
||||||
# logger.debug("", exc_info=True)
|
# logger.debug("", exc_info=True)
|
||||||
continue
|
continue
|
||||||
|
except Exception:
|
||||||
|
if exclusive_fp:
|
||||||
|
fp.close()
|
||||||
|
raise
|
||||||
return None
|
return None
|
||||||
|
|
||||||
im = _open_core(fp, filename, prefix)
|
im = _open_core(fp, filename, prefix)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user