Uploaded files should not set mode to None
I ran across this issue when attempting to open an uploaded file with GzipFile(fileobj=uploaded_file). If you don't pass in the mode parameter as well, GzipFile crashes. GzipFile looks to see if the fileobj has a mode attribute, and if it does, it uses it; however, using a mode of None causes it to crash.
I filed a bug and patch for GzipFile (http://bugs.python.org/issue10392), but it was rejected, saying that the bug was in Django for setting the mode on the file to None. So I've attached a patch (with test) to django.core.files.base.File that only sets mode if mode is present.
Change History
(10)
Keywords: |
sprintdec2010 added
|
milestone: |
→ 1.3
|
Owner: |
changed from nobody to Brett Haydon
|
Status: |
new → assigned
|
Triage Stage: |
Unreviewed → Accepted
|
milestone: |
1.3
|
Severity: |
→ Normal
|
Type: |
→ Bug
|
Easy pickings: |
unset
|
Patch needs improvement: |
set
|
Patch needs improvement: |
unset
|
Cc: |
moritz.sichert@… added
|
Triage Stage: |
Accepted → Ready for checkin
|
Resolution: |
→ fixed
|
Status: |
assigned → closed
|
Added a revised test patch to explicity test against stdlib gzip.Gzip which is the point of failure.