Commits

Anonymous committed 8dfca4a

Bugfix in format_data_size if size <=0, found by Marcin Kuzminski.

  • Participants
  • Parent commits bc149bf

Comments (0)

Files changed (2)

  - New ``format_exception`` helper to display an exception as Python would but
    without the traceback.
 
+* webhelpers.number:
+
+  - Bugfix in format_data_size and derivatives if size <= 0. Found by
+    Marcin Kuzminski.
+
 1.0b7 (2010-05-16)
 ------------------
 

webhelpers/number.py

         else:
             multiples = ('', 'Ki', 'Mi', 'Gi', 'Ti', 'Pi', 'Ei', 'Zi', 'Yi')
             
-    m = int(math.log(size) / math.log(base))
+    if size <= 0:
+        m = 0
+    else:
+        m = int(math.log(size) / math.log(base))
     if m > 8:
         m = 8