Incomplete file interface for django.core.files.temp.TemporaryFile (Windows only)
On Windows, when an uploaded is stored as a temporary file, it is wrapped as django.core.files.temp.TemporaryFile
. That class lacks proper seek and tell interfaces which will result in errors when a client of the class is trying to use the file's seek
and tell
methods. Specifically, the seek implementation only takes one argument, while a file's seek
method can take an optional 'whence' argument. And the tell
method is missing.
For example, to reproduce the error caused by this,
- Upload any file large enough for it to be stored as a temp file to a server running on Windows.
- Construct a
zipfile.ZipFile
object with the TemporaryFile
instance.
- The
ZipFile.__init__
will fail when it tries to call TemporaryFile
's seek
with two arguments, or when it calls the file's tell
method.
The problem could have been fixed with the above patch. Please review.