[Python-checkins] python/dist/src/Lib random.py,1.67,1.68

rhettinger at users.sourceforge.net rhettinger at users.sourceforge.net
Tue Sep 14 00:23:23 CEST 2004


Update of /cvsroot/python/python/dist/src/Lib
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv4508/Lib

Modified Files:
	random.py 
Log Message:
SF #1027105:  HardwareRandom should be renamed OSRandom

Renamed the new generator at Trevor's recommendation.
The name HardwareRandom suggested a bit more than it 
delivered (no radioactive decay detectors or such).



Index: random.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/random.py,v
retrieving revision 1.67
retrieving revision 1.68
diff -u -d -r1.67 -r1.68
--- random.py	5 Sep 2004 00:00:41 -0000	1.67
+++ random.py	13 Sep 2004 22:23:20 -0000	1.68
@@ -52,7 +52,7 @@
            "expovariate","vonmisesvariate","gammavariate",
            "gauss","betavariate","paretovariate","weibullvariate",
            "getstate","setstate","jumpahead", "WichmannHill", "getrandbits",
-           "HardwareRandom"]
+           "SystemRandom"]
 
 NV_MAGICCONST = 4 * _exp(-0.5)/_sqrt(2.0)
 TWOPI = 2.0*_pi
@@ -99,8 +99,8 @@
     def seed(self, a=None):
         """Initialize internal state from hashable object.
 
-        None or no argument seeds from current time or from a hardware
-        randomness source if available.
+        None or no argument seeds from current time or from an operating
+        system specific randomness source if available.
 
         If a is not None or an int or long, hash(a) is used instead.
         """
@@ -603,8 +603,8 @@
     def seed(self, a=None):
         """Initialize internal state from hashable object.
 
-        None or no argument seeds from current time or from a hardware
-        randomness source if available.
+        None or no argument seeds from current time or from an operating
+        system specific randomness source if available.
 
         If a is not None or an int or long, hash(a) is used instead.
 
@@ -744,10 +744,12 @@
         z = (z + a) % 256 or 1
         self.__whseed(x, y, z)
 
-## -------------------- Hardware Random Source  -------------------
+## --------------- Operating System Random Source  ------------------
 
-class HardwareRandom(Random):
-    """Alternate random number generator using hardware sources.
+class SystemRandom(Random):
+    """Alternate random number generator using sources provided
+    by the operating system (such as /dev/urandom on Unix or
+    CryptGenRandom on Windows).
 
      Not available on all systems (see os.urandom() for details).
     """
@@ -767,13 +769,13 @@
         return x >> (bytes * 8 - k)             # trim excess bits
 
     def _stub(self, *args, **kwds):
-        "Stub method.  Not used for a hardware random number generator."
+        "Stub method.  Not used for a system random number generator."
         return None
     seed = jumpahead = _stub
 
     def _notimplemented(self, *args, **kwds):
-        "Method should not be called for a hardware random number generator."
-        raise NotImplementedError('Hardware entropy source does not have state.')
+        "Method should not be called for a system random number generator."
+        raise NotImplementedError('System entropy source does not have state.')
     getstate = setstate = _notimplemented
 
 ## -------------------- test program --------------------



More information about the Python-checkins mailing list