Opened 10 years ago

Closed 10 years ago

Last modified 7 years ago

#10485 closed (duplicate)

Incomplete file interface for django.core.files.temp.TemporaryFile (Windows only)

Reported by: tzonghao Owned by: tzonghao
Component: File uploads/storage Version: 1.0
Severity: Keywords: file, seek, tell
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no


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,

  1. Upload any file large enough for it to be stored as a temp file to a server running on Windows.
  2. Construct a zipfile.ZipFile object with the TemporaryFile instance.
  3. 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.

Attachments (1) (721 bytes) - added by tzonghao 10 years ago.

Download all attachments as: .zip

Change History (5)

Changed 10 years ago by tzonghao

Attachment: added

comment:1 Changed 10 years ago by tzonghao

Owner: changed from nobody to tzonghao
Status: newassigned

The problem could have been fixed with the above patch. Please review.

comment:2 Changed 10 years ago by Ramiro Morales

The seek() problem has already been reported in #10047 (no patch attached to that ticket) and the tell() issue has already been reported in #9344 (has a patch).

comment:3 Changed 10 years ago by Jacob

Resolution: duplicate
Status: assignedclosed

Duplicate of #9344, #10047

comment:4 Changed 7 years ago by Jacob

milestone: 1.0.3

Milestone 1.0.3 deleted

Note: See TracTickets for help on using tickets.
Back to Top