[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[minion-cvs] Check explicity for 32-bit ints for getInt; clarify XXX...
Update of /home/minion/cvsroot/src/minion/lib/mixminion
In directory moria.seul.org:/tmp/cvs-serv8910/lib/mixminion
Modified Files:
Crypto.py
Log Message:
Check explicity for 32-bit ints for getInt; clarify XXXX comments
Index: Crypto.py
===================================================================
RCS file: /home/minion/cvsroot/src/minion/lib/mixminion/Crypto.py,v
retrieving revision 1.23
retrieving revision 1.24
diff -u -d -r1.23 -r1.24
--- Crypto.py 22 Nov 2002 00:21:20 -0000 1.23
+++ Crypto.py 2 Dec 2002 03:22:28 -0000 1.24
@@ -426,6 +426,10 @@
#---------------------------------------------------------------------
# Random number generators
+# The getInt code below assumes that ints are at least 32 bits long. Here
+# we assert it.
+assert sys.maxint >= 0x7fffffff
+
class RNG:
'''Base implementation class for random number generators. Works
by requesting a bunch of bytes via self._prng, and doling them
@@ -484,7 +488,8 @@
# FFFF This implementation is about 2-4x as good as the last one, but
# FFFF still could be better. It's faster than getFloat()*max.
- # XXXX (This code assumes that integers are at least 32 bits.)
+ # FFFF (This code assumes that integers are at least 32 bits. Maybe
+ # FFFF we could do better.)
assert 0 < max < 0x3fffffff
_ord = ord