Code

Opened 5 years ago

Closed 5 years ago

Last modified 3 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: UI/UX:

Description

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)

temp.py.diff (721 bytes) - added by tzonghao 5 years ago.

Download all attachments as: .zip

Change History (5)

Changed 5 years ago by tzonghao

comment:1 Changed 5 years ago by tzonghao

  • Owner changed from nobody to tzonghao
  • Status changed from new to assigned

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

comment:2 Changed 5 years ago by ramiro

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 5 years ago by jacob

  • Resolution set to duplicate
  • Status changed from assigned to closed

Duplicate of #9344, #10047

comment:4 Changed 3 years ago by jacob

  • milestone 1.0.3 deleted

Milestone 1.0.3 deleted

Add Comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
as The resolution will be set. Next status will be 'closed'
The resolution will be deleted. Next status will be 'new'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.