mirror of
https://github.com/wagtail/wagtail.git
synced 2024-12-01 11:41:20 +01:00
parent
b445f2a28f
commit
6ae8213e05
@ -95,13 +95,19 @@ class AbstractImage(models.Model, TagSearchable):
|
||||
# these from IOErrors elsewhere in the process
|
||||
raise SourceImageIOError(text_type(e))
|
||||
|
||||
image_file.open('rb')
|
||||
# Open file if it is closed
|
||||
close_file = False
|
||||
if image_file.closed:
|
||||
image_file.open('rb')
|
||||
close_file = True
|
||||
|
||||
image_file.seek(0)
|
||||
|
||||
try:
|
||||
yield WillowImage.open(image_file)
|
||||
finally:
|
||||
image_file.close()
|
||||
if close_file:
|
||||
image_file.close()
|
||||
|
||||
def get_rect(self):
|
||||
return Rect(0, 0, self.width, self.height)
|
||||
|
@ -238,7 +238,6 @@ class TestGetWillowImage(TestCase):
|
||||
|
||||
self.assertTrue(self.image.file.closed)
|
||||
|
||||
@unittest.expectedFailure
|
||||
def test_doesnt_close_open_image(self):
|
||||
# This tests that when the image file is already open, get_willow_image doesn't close it (#1256)
|
||||
self.image.file.open('rb')
|
||||
|
Loading…
Reference in New Issue
Block a user