Django

Code

Changeset 4044

Show
Ignore:
Timestamp:
11/06/06 22:58:10 (2 years ago)
Author:
jacob
Message:

Fixed #2914: filesizeformat no longer dies on invalid values. Thanks, dev@simon.net.nz

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • django/trunk/django/template/defaultfilters.py

    r3799 r4044  
    422422    bytes, etc). 
    423423    """ 
    424     bytes = float(bytes) 
     424    try: 
     425        bytes = float(bytes) 
     426    except TypeError: 
     427        return "0 bytes" 
     428         
    425429    if bytes < 1024: 
    426430        return "%d byte%s" % (bytes, bytes != 1 and 's' or '')