Nick wrote:
More info:
python 2.4.2 on Linux:
>>> import tempfile
>>> t = tempfile.TemporaryFile()
>>> t
<open file '<fdopen>', mode 'w+b' at 0xb7df07b8>
>>> type(t)
<type 'file'>
>>> dir(t)
['__class__', '__delattr__', '__doc__', '__getattribute__', '__hash__',
'__init__', '__iter__', '__new__', '__reduce__', '__reduce_ex__',
'__repr__', '__setattr__', '__str__', 'close', 'closed', 'encoding',
'fileno', 'flush', 'isatty', 'mode', 'name', 'newlines', 'next', 'read',
'readinto', 'readline', 'readlines', 'seek', 'softspace', 'tell',
'truncate', 'write', 'writelines', 'xreadlines']
python 2.4.1 on windows:
>>> import tempfile
>>> t = tempfile.TemporaryFile()
>>> t
<open file '<fdopen>', mode 'w+b' at 0x0099FBA8>
>>> type(t)
<type 'instance'>
>>> dir(t)
['__doc__', '__getattr__', '__init__', '__module__', '__repr__',
'close_called', 'file', 'name']
So this is an inconsistency within Python. Should mod_python attempt to
correct it, or just claim a Python bug?
I think we should correct it. I'm sure users don't care that we
implement this with TemporaryFile. That being said, I wonder how many
applications on Windows we may break by fixing this? Version 3.1.4 also
used TemporaryFile, so this is not a new bug.
Jim
Nick wrote:
This may be a Python Windows thing, but it shows up in mod_python:
When using util.FieldStorage on multipart/form-data encoded POST data
containing a file, in Linux a field.file will yield a file object
(actually a subclass of file), but in Windows you have to get the file
object through field.file.file. This probably has something to do
with the fact that Windows' implementation of tempfile.TemporaryFile
is different from Linux, but it should be made consistent in the
mod_python interface.
Nick