]> arthur.barton.de Git - bup.git/commitdiff
helpers: use // not / for division
authorRob Browning <rlb@defaultvalue.org>
Sun, 21 Jan 2018 22:26:24 +0000 (16:26 -0600)
committerRob Browning <rlb@defaultvalue.org>
Sat, 7 Jul 2018 17:56:01 +0000 (12:56 -0500)
...because Python 3 changed / to floating point.

Signed-off-by: Rob Browning <rlb@defaultvalue.org>
Tested-by: Rob Browning <rlb@defaultvalue.org>
lib/bup/helpers.py

index 1bae59d22e99da707daac8198bcba5c0275882b7..b88fabf2df5ea59fe1421fe59ab714cfbddfaba9 100644 (file)
@@ -1,6 +1,6 @@
 """Helper functions and classes for bup."""
 
-from __future__ import absolute_import
+from __future__ import absolute_import, division
 from collections import namedtuple
 from contextlib import contextmanager
 from ctypes import sizeof, c_void_p
@@ -474,9 +474,9 @@ def format_filesize(size):
     size = float(size)
     if size < unit:
         return "%d" % (size)
-    exponent = int(math.log(size) / math.log(unit))
+    exponent = int(math.log(size) // math.log(unit))
     size_prefix = "KMGTPE"[exponent - 1]
-    return "%.1f%s" % (size / math.pow(unit, exponent), size_prefix)
+    return "%.1f%s" % (size // math.pow(unit, exponent), size_prefix)
 
 
 class NotOk(Exception):
@@ -813,7 +813,7 @@ if _mincore:
         pref_chunk_size = 64 * 1024 * 1024
         chunk_size = sc_page_size
         if (sc_page_size < pref_chunk_size):
-            chunk_size = sc_page_size * (pref_chunk_size / sc_page_size)
+            chunk_size = sc_page_size * (pref_chunk_size // sc_page_size)
         _fmincore_chunk_size = chunk_size
 
     def fmincore(fd):
@@ -825,9 +825,9 @@ if _mincore:
             return bytearray(0)
         if not _fmincore_chunk_size:
             _set_fmincore_chunk_size()
-        pages_per_chunk = _fmincore_chunk_size / sc_page_size;
-        page_count = (st.st_size + sc_page_size - 1) / sc_page_size;
-        chunk_count = page_count / _fmincore_chunk_size
+        pages_per_chunk = _fmincore_chunk_size // sc_page_size;
+        page_count = (st.st_size + sc_page_size - 1) // sc_page_size;
+        chunk_count = page_count // _fmincore_chunk_size
         if chunk_count < 1:
             chunk_count = 1
         result = bytearray(page_count)