summaryrefslogtreecommitdiff
path: root/django/core/files/temp.py
diff options
context:
space:
mode:
authorLoic Bistuer <loic.bistuer@gmail.com>2014-06-12 00:21:14 +0700
committerLoic Bistuer <loic.bistuer@gmail.com>2014-06-12 08:07:34 +0700
commit6e8d614acd1b65a1ae472da7db88a7b2751dc388 (patch)
tree8f01e47306744c7b6c0f1e477987b058ce808b54 /django/core/files/temp.py
parentc307383ec9d30cd59f858cfdad9621a4d5adf200 (diff)
downloaddjango-6e8d614acd1b65a1ae472da7db88a7b2751dc388.tar.gz
Made the vendored NamedTemporaryFile work as a context manager. Refs #22680.
This fixes a regression on Windows introduced by b7de5f5. Thanks Tim Graham for the report and review.
Diffstat (limited to 'django/core/files/temp.py')
-rw-r--r--django/core/files/temp.py7
1 files changed, 7 insertions, 0 deletions
diff --git a/django/core/files/temp.py b/django/core/files/temp.py
index 58fbd231dc..77563eed37 100644
--- a/django/core/files/temp.py
+++ b/django/core/files/temp.py
@@ -69,6 +69,13 @@ if os.name == 'nt':
def __del__(self):
self.close()
+ def __enter__(self):
+ self.file.__enter__()
+ return self
+
+ def __exit__(self, exc, value, tb):
+ self.file.__exit__(exc, value, tb)
+
NamedTemporaryFile = TemporaryFile
else:
NamedTemporaryFile = tempfile.NamedTemporaryFile