core.files.File assumes name attribute on file-like objects
|Reported by:||Paul McMillan||Owned by:||Simon Charette|
|Cc:||charette.s@…, nickname123||Triage Stage:||Accepted|
|Has patch:||yes||Needs documentation:||no|
|Needs tests:||yes||Patch needs improvement:||yes|
The django.core.files.File object is a wrapper to add some django-specific stuff around standard python file-like objects.
__init__ and elsewhere,
File works around file-like objects which may not have a
name attribute (optional for python file objects). However, down in the
_size() getter, it slips up and makes the assumption that the file-like object has a name attribute. This means that it produces a confusing attribute error about
name rather than the desired error about being unable to determine a file's size.
This should be patched to check for self.name before doing the os.path.exists, like line 113.
Change History (10)
comment:2 Changed 6 years ago by
|Component:||Uncategorized → Core (Other)|
|Triage Stage:||Unreviewed → Accepted|
|Type:||Uncategorized → Bug|
comment:4 Changed 6 years ago by
|Owner:||changed from nobody to Simon Charette|
|Status:||new → assigned|