Skip to content

Commit

Permalink
Merge pull request #74 from matthiask/master
Browse files Browse the repository at this point in the history
Close OnDiscPlaceholderImage files after reading to avoid a ResourceWarning
  • Loading branch information
respondcreate committed Sep 29, 2016
2 parents 3d0845b + b168838 commit 60c9ee7
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions versatileimagefield/placeholder.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ def __init__(self, path):

def setup(self):
folder, name = os.path.split(self.path)
file = open(self.path, 'rb')
content_file = ContentFile(file.read(), name=name)
with open(self.path, 'rb') as file:
content_file = ContentFile(file.read(), name=name)
self.file = content_file
self.name = name
super(OnDiscPlaceholderImage, self).setup()
Expand Down

0 comments on commit 60c9ee7

Please sign in to comment.