Is this a bug in the windows tempfile.py?

Jonathan Wright quaggy at gmail.com
Wed Sep 15 02:15:36 CEST 2004


import tempfile
import types
print isinstance(tempfile.TemporaryFile(), types.FileType)


Prints False on Windows and True on linux or any other posix system.
The reason for the difference is on posix systems TemporaryFile returns
an actual file (the result of os.fdopen()) and on windows,
TemporaryFile returns a file wrapper which forwards getattr calls to
the underlying file.

The wrapper used on windows provides an alternative close method that
deletes the temporary file.
Should the wrapper inherit types.FileType?

Jonathan.




More information about the Python-list mailing list