﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
16569	NamedTemporaryFile is missing the delete argument	Leon van der Ree	nobody	"I am developing under Linux, while my test server is running Windows, which made me aware of the following error.

I wrote the following piece of code:
[code]
from django.core.files.temp import NamedTemporaryFile

img_temp = NamedTemporaryFile(delete=True)
[/code]
which works fine under Linux, but fails under Windows.

I looked at the code in the django.core.files.temp module, and see it makes a distinction between Windows and other systems:

[code]
if os.name == 'nt':
[/code]
in which case NamedTemporaryFile = TemporaryFile as defined above it.

However, according to http://docs.python.org/library/tempfile.html#tempfile.NamedTemporaryFile NamedTemporaryFile should be able to handle delete as well!


A solution would be to define NamedTemporaryFile as follows:
[code]
    class NamedTemporaryFile(TemporaryFile):
        def __init__(self, **kwargs):
            kwargs.pop('delete', True) # TODO: handle this delete flag
            super(NamedTemporaryFile,self).__init__(**kwargs)
[/code]
But I haven't thought about  how to handle the delete argument."	Bug	closed	Core (Other)	1.3	Normal	invalid	NamedTemporaryFile, delete		Unreviewed	0	0	0	0	0	0
