Skip to content

Commit 91a5b9d

Browse files
committed
fix error for 32bit systems
1 parent 2cbe562 commit 91a5b9d

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

lib/bx/interval_index_file.py

+7-6
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,6 @@
8282
"""
8383

8484
import os.path
85-
import sys
8685
from bisect import (
8786
insort,
8887
insort_right,
@@ -124,7 +123,7 @@
124123
BIN_OFFSETS_MAX.insert(0, (BIN_OFFSETS_MAX[0] << BIN_NEXT_SHIFT))
125124
# The maximum size for the top bin is actually bigger than the signed integers
126125
# we use to store positions in the file, so we'll change it to prevent confusion
127-
BIN_OFFSETS_MAX[0] = sys.maxsize
126+
BIN_OFFSETS_MAX[0] = 2**63
128127

129128
# Constants for the minimum and maximum size of the overall interval
130129
MIN = 0
@@ -137,12 +136,14 @@ def offsets_for_max_size(max_size):
137136
"""
138137
Return the subset of offsets needed to contain intervals over (0,max_size)
139138
"""
140-
for i, max in enumerate(reversed(BIN_OFFSETS_MAX)):
141-
if max_size < max:
139+
offset_index = None
140+
for i, off_max in enumerate(reversed(BIN_OFFSETS_MAX)):
141+
if max_size <= off_max:
142+
offset_index = i
142143
break
143-
else:
144+
if offset_index is None:
144145
raise Exception("%d is larger than the maximum possible size (%d)" % (max_size, BIN_OFFSETS_MAX[0]))
145-
return BIN_OFFSETS[(len(BIN_OFFSETS) - i - 1) :]
146+
return BIN_OFFSETS[(len(BIN_OFFSETS) - offset_index - 1):]
146147

147148

148149
def bin_for_range(start, end, offsets=None):

0 commit comments

Comments
 (0)