Opened 6 years ago
Closed 6 years ago
#29454 closed Cleanup/optimization (needsinfo)
Default size for django.core.files.uploadedfile is None and then len will raise error
Reported by: | jxltom | Owned by: | nobody |
---|---|---|---|
Component: | File uploads/storage | Version: | 2.0 |
Severity: | Normal | Keywords: | |
Cc: | Triage Stage: | Unreviewed | |
Has patch: | no | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description (last modified by )
By default, size
of django.core.files.uploadedfile is None
and __len__
will return size
by default. Calling len
will raise TypeError: 'NoneType' object cannot be interpreted as an integer
error if size is not assigned specifically.
Can this be handled better? Such not implementing __len__
method if size
is set as None
.
Change History (3)
comment:1 by , 6 years ago
Description: | modified (diff) |
---|
comment:2 by , 6 years ago
the code is in https://github.com/django/django/blob/master/django/core/files/base.py#L28, I'm not sure we should handle if the file doesn't have size.
comment:3 by , 6 years ago
Resolution: | → needsinfo |
---|---|
Status: | new → closed |
Closing, absent some use case for the fix.
Did you find this to be a problem in practice?