mirror of
				https://github.com/django/django.git
				synced 2025-10-31 09:41:08 +00:00 
			
		
		
		
	[1.7.x] Made the vendored NamedTemporaryFile work as a context manager. Refs #22680.
This fixes a regression on Windows introduced byb7de5f5. Thanks Tim Graham for the report and review. Backport of6e8d614acdfrom master
This commit is contained in:
		| @@ -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 | ||||
|   | ||||
		Reference in New Issue
	
	Block a user