Can this be handled better? such as do not implement ```__len__``` method
if ```size``` is set as ```None```
--
Ticket URL: <https://code.djangoproject.com/ticket/29454>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
Old description:
> 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 as do not implement ```__len__``` method
> if ```size``` is set as ```None```
New description:
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`.
--
Comment (by Tim Graham):
Did you find this to be a problem in practice?
--
Ticket URL: <https://code.djangoproject.com/ticket/29454#comment:1>
Comment (by Windson yang):
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.
--
Ticket URL: <https://code.djangoproject.com/ticket/29454#comment:2>
* status: new => closed
* resolution: => needsinfo
Comment:
Closing, absent some use case for the fix.
--
Ticket URL: <https://code.djangoproject.com/ticket/29454#comment:3>