Created
June 11, 2014 17:24
-
-
Save loic/c9394317d8f950761588 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
commit e0b05dfcd74c803f872500c040cc6de88fcefe45 | |
Author: Loic Bistuer <[email protected]> | |
Date: Thu Jun 12 00:21:14 2014 +0700 | |
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. | |
diff --git a/django/core/files/temp.py b/django/core/files/temp.py | |
index 58fbd23..77563ee 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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
ship it.