summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlex Gaynor <alex.gaynor@gmail.com>2011-07-08 09:39:56 +0000
committerAlex Gaynor <alex.gaynor@gmail.com>2011-07-08 09:39:56 +0000
commit319b0cfb83b07e46f3a23b7cb0dc1677da4b02eb (patch)
tree1e8b3fe750c38d4d2f6ca1e2ff662c640cdbc437
parent68d18b8492c52e138994c62cc3336986a2002859 (diff)
Explicitly close a file in the collectstatic management command.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@16525 bcc190cf-cafb-0310-a4f2-bffc1f526a37
-rw-r--r--django/contrib/staticfiles/management/commands/collectstatic.py7
1 files changed, 5 insertions, 2 deletions
diff --git a/django/contrib/staticfiles/management/commands/collectstatic.py b/django/contrib/staticfiles/management/commands/collectstatic.py
index 246f960583..341537ffa7 100644
--- a/django/contrib/staticfiles/management/commands/collectstatic.py
+++ b/django/contrib/staticfiles/management/commands/collectstatic.py
@@ -1,3 +1,5 @@
+from __future__ import with_statement
+
import os
import sys
from optparse import make_option
@@ -9,6 +11,7 @@ from django.utils.encoding import smart_str, smart_unicode
from django.contrib.staticfiles import finders
+
class Command(NoArgsCommand):
"""
Command that allows to copy or symlink media files from different
@@ -236,7 +239,7 @@ Type 'yes' to continue, or 'no' to cancel: """
os.makedirs(os.path.dirname(full_path))
except OSError:
pass
- source_file = source_storage.open(path)
- self.storage.save(prefixed_path, source_file)
+ with source_storage.open(path) as source_file:
+ self.storage.save(prefixed_path, source_file)
if not prefixed_path in self.copied_files:
self.copied_files.append(prefixed_path)