mirror of
https://github.com/python-pillow/Pillow.git
synced 2024-12-24 17:06:16 +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
|
||||
either """
|
||||
for f in self.get_files('b'):
|
||||
try:
|
||||
im = Image.open(f)
|
||||
im.load()
|
||||
except Exception: # as msg:
|
||||
pass
|
||||
def open(f):
|
||||
try:
|
||||
im = Image.open(f)
|
||||
im.load()
|
||||
except Exception: # as msg:
|
||||
pass
|
||||
|
||||
# Assert that there is no unclosed file warning
|
||||
self.assert_warning(None, open, f)
|
||||
|
||||
def test_questionable(self):
|
||||
""" 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.
|
||||
# logger.debug("", exc_info=True)
|
||||
continue
|
||||
except Exception:
|
||||
if exclusive_fp:
|
||||
fp.close()
|
||||
raise
|
||||
return None
|
||||
|
||||
im = _open_core(fp, filename, prefix)
|
||||
|
|
Loading…
Reference in New Issue
Block a user