#26495: Storage save method wraps StringIO in File object which is identified as
False.
--------------------------------------+--------------------
Reporter: m-novikov | Owner: nobody
Type: Uncategorized | Status: new
Component: File uploads/storage | Version: master
Severity: Normal | Keywords:
Triage Stage: Unreviewed | Has patch: 0
Easy pickings: 0 | UI/UX: 0
--------------------------------------+--------------------
https://github.com/django/django/blob/master/django/core/files/storage.py#L50
{{{
#!python
class Storage(object):
def save(self, name, content, max_length=None):
...
if not hasattr(content, 'chunks'):
content = File(content)
}}}
Underlying libraries may use following pattern of code:
{{{
#!python
def store(data, name):
data = data or ''
}}}
But File object without a name resolved into False which can produce bugs.
Possibly better to pass a name to File object. To ensure bool(content) is
True
{{{
#!python
if not hasattr(content, 'chunks'):
content = File(content, name=name)
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/26495>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/052.56593bc6a00d2e3cb6af0b79c0cdb6d2%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.