This issue tracker has been migrated to GitHub ,
and is currently read-only.
For more information,
see the GitHub FAQs in the Python's Developer Guide.
Created on 2012年04月06日 02:00 by r.david.murray, last changed 2022年04月11日 14:57 by admin. This issue is now closed.
| Messages (4) | |||
|---|---|---|---|
| msg157634 - (view) | Author: R. David Murray (r.david.murray) * (Python committer) | Date: 2012年04月06日 02:00 | |
A common pattern (especially in writing tests) is to create a named temporary file, operate on it with tools that take the filename, and then delete the file. This pattern would be facilitated by a version of NamedTemporaryFile that deleted the named file at the end of the context, but allowed the file to continue to exist when closed. This latter requirement arises because the file cannot be opened a second time on Windows, and so needs to be closed before other operations that open it can be performed in order for the code to work cross platform. It's tempting just to change delete=True to mean delete on exit (not close) if and only if NamedTemporaryFile is being used as a context manager, but there might be backward compatibility issues with that. It might be acceptable as a feature change, though, since the likelyhood of someone closing such a tempfile inside the context and then depending on it *not* existing between then and the end of the context seems low. If that it deemed unacceptable, this could be implemented as a new flag on NamedTemporaryFile, or by changing the delete flag to take additional values (True/False == current behavior, but add delete='onclose', delete='onexit', delete='no', and document True/False as deprecated.) |
|||
| msg157637 - (view) | Author: Eric V. Smith (eric.smith) * (Python committer) | Date: 2012年04月06日 02:46 | |
See also issue 14243. |
|||
| msg157638 - (view) | Author: R. David Murray (r.david.murray) * (Python committer) | Date: 2012年04月06日 02:52 | |
Grr. I did a search first, and even used google because I know search is currently broken, and I did not find that issue. |
|||
| msg157926 - (view) | Author: Alyssa Coghlan (ncoghlan) * (Python committer) | Date: 2012年04月10日 01:31 | |
I converted issue #14243 to a feature request, so this is now a duplicate. |
|||
| History | |||
|---|---|---|---|
| Date | User | Action | Args |
| 2022年04月11日 14:57:28 | admin | set | github: 58719 |
| 2012年04月10日 01:31:35 | ncoghlan | set | status: open -> closed nosy: + ncoghlan messages: + msg157926 superseder: tempfile.NamedTemporaryFile not particularly useful on Windows resolution: duplicate |
| 2012年04月06日 02:52:13 | r.david.murray | set | messages: + msg157638 |
| 2012年04月06日 02:46:24 | eric.smith | set | nosy:
+ eric.smith messages: + msg157637 |
| 2012年04月06日 02:00:28 | r.david.murray | create | |