[Python-bugs-list] [ python-Bugs-476138 ] tempfile behavior across platforms (original) (raw)

noreply@sourceforge.net noreply@sourceforge.net
Mon, 29 Oct 2001 13:31:43 -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: Tim Peters (timone) 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:

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


Comment By: Tim Peters (timone) Date: 2001-10-29 13:31

Message: Logged In: YES user_id=31435

Well, on Unix the file is unlinked before the tempfile create returns. That isn't possible on Windows.

I agree a tempfile should-- like a Python file object --be closeable any number of times, although it should raise an exception if the first attempt to unlink it fails.


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