Skip to content

Commit f3d3502

Browse files
committed
Change / to // (integer division) in several places
This fixes a bunch of bugs and test failures in Python 3, which uses "true division" for /
1 parent 137d5b1 commit f3d3502

File tree

3 files changed

+5
-5
lines changed

3 files changed

+5
-5
lines changed

smmap/test/test_mman.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -95,8 +95,8 @@ def test_memman_operation(self):
9595
fd = os.open(fc.path, os.O_RDONLY)
9696
max_num_handles = 15
9797
#small_size =
98-
for mtype, args in ( (StaticWindowMapManager, (0, fc.size / 3, max_num_handles)),
99-
(SlidingWindowMapManager, (fc.size / 100, fc.size / 3, max_num_handles)),):
98+
for mtype, args in ( (StaticWindowMapManager, (0, fc.size // 3, max_num_handles)),
99+
(SlidingWindowMapManager, (fc.size // 100, fc.size // 3, max_num_handles)),):
100100
for item in (fc.path, fd):
101101
assert len(data) == fc.size
102102

@@ -110,7 +110,7 @@ def test_memman_operation(self):
110110

111111
base_offset = 5000
112112
# window size is 0 for static managers, hence size will be 0. We take that into consideration
113-
size = man.window_size() / 2
113+
size = man.window_size() // 2
114114
assert c.use_region(base_offset, size).is_valid()
115115
rr = c.region_ref()
116116
assert rr().client_count() == 2 # the manager and the cursor and us

smmap/test/test_util.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ def test_window(self):
5454

5555
def test_region(self):
5656
fc = FileCreator(self.k_window_test_size, "window_test")
57-
half_size = fc.size / 2
57+
half_size = fc.size // 2
5858
rofs = align_to_mmap(4200, False)
5959
rfull = MapRegion(fc.path, 0, fc.size)
6060
rhalfofs = MapRegion(fc.path, rofs, fc.size)

smmap/util.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ def align_to_mmap(num, round_up):
3131
:param round_up: if True, the next higher multiple of page size is used, otherwise
3232
the lower page_size will be used (i.e. if True, 1 becomes 4096, otherwise it becomes 0)
3333
:return: num rounded to closest page"""
34-
res = (num / ALLOCATIONGRANULARITY) * ALLOCATIONGRANULARITY;
34+
res = (num // ALLOCATIONGRANULARITY) * ALLOCATIONGRANULARITY;
3535
if round_up and (res != num):
3636
res += ALLOCATIONGRANULARITY
3737
#END handle size

0 commit comments

Comments
 (0)