[Python-bugs-list] [ python-Bugs-476138 ] tempfile behavior across platforms

noreply@sourceforge.net noreply@sourceforge.net
Mon, 29 Oct 2001 13:21:02 -0800


Bugs item #476138, was opened at 2001-10-29 13:14
You can respond by visiting: 
http://sourceforge.net/tracker/?func=detail&atid=105470&aid=476138&group_id=5470

Category: Python Library
Group: None
Status: Open
Resolution: None
Priority: 5
Submitted By: Jeremy Hylton (jhylton)
Assigned to: Nobody/Anonymous (nobody)
Summary: tempfile behavior across platforms

Initial Comment:
The object returned by TemporaryFile.tempfile() has a 
close() method.  On Unix, this is a builtin file 
object's close method.  On Windows, it is a 
TemporaryFileWrapper object's close method.

The two have different semantics, which limits the 
utility of the module in code that should run on both 
platforms.  There are two differences:

   - The close() method on Windows unlinks the 
     file after closing it.  The close() method
     on Unix does not.

   - Calling close() on a closed tempfile raises
     an exception on Windows, but has no effect
     on Unix.  (This is a consequence of the
     previous difference.  The second attempt to
     unlink the file fails.)

I think the sensible fix is to catch and ignore failed 
unlink calls on Windows.


----------------------------------------------------------------------

>Comment By: Guido van Rossum (gvanrossum)
Date: 2001-10-29 13:21

Message:
Logged In: YES 
user_id=6380

The first difference doesn't really bother you, does it? On
Unix, the file has already been unlinked when it was first
created.

It sounds like the real difference you're after is that the
Unix version allows calling close() more than once, because
open files can be closed more than once.

I think this is a useful semantic to retain, and propose to
fix it as you suggest.

----------------------------------------------------------------------

You can respond by visiting: 
http://sourceforge.net/tracker/?func=detail&atid=105470&aid=476138&group_id=5470