Skip to content

Commit 5743f29

Browse files
committed
server.py: slightly rearrange previous commit.
Add some documentation about the int() vs long() and the reason behind _shl(). Instead of "from __future__ import generators", just don't use generators.
1 parent 42bc6d6 commit 5743f29

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

server.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
from __future__ import generators # add yield for python2.2
21
import re, struct, socket, select, traceback, time
32
if not globals().get('skip_imports'):
43
import ssnet, helpers, hostwatch
@@ -44,6 +43,11 @@ def _maskbits(netmask):
4443

4544

4645
def _shl(n, bits):
46+
# we use our own implementation of left-shift because
47+
# results may be different between older and newer versions
48+
# of python for numbers like 1<<32. We use long() because
49+
# int(2**32) doesn't work in older python, which has limited
50+
# int sizes.
4751
return n * long(2**bits)
4852

4953

@@ -69,9 +73,11 @@ def _list_routes():
6973

7074

7175
def list_routes():
76+
l = []
7277
for (ip,width) in _list_routes():
7378
if not ip.startswith('0.') and not ip.startswith('127.'):
74-
yield (ip,width)
79+
l.append((ip,width))
80+
return l
7581

7682

7783
def _exc_dump():

0 commit comments

Comments
 (0)