[Python-checkins] python/dist/src/Lib random.py,1.27,1.28

tim_one@sourceforge.net tim_one@sourceforge.net
Sun, 05 May 2002 13:40:01 -0700


Update of /cvsroot/python/python/dist/src/Lib
In directory usw-pr-cvs1:/tmp/cvs-serv14885/python/Lib

Modified Files:
	random.py 
Log Message:
random.gauss() uses a piece of hidden state used by nothing else,
and the .seed() and .whseed() methods failed to reset it.  In other
words, setting the seed didn't completely determine the sequence of
results produced by random.gauss().  It does now.  Programs repeatedly
mixing calls to a seed method with calls to gauss() may see different
results now.

Bugfix candidate (random.gauss() has always been broken in this way),
despite that it may change results.


Index: random.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/random.py,v
retrieving revision 1.27
retrieving revision 1.28
diff -C2 -d -r1.27 -r1.28
*** random.py	13 Apr 2002 14:41:19 -0000	1.27
--- random.py	5 May 2002 20:39:59 -0000	1.28
***************
*** 117,121 ****
  
          self.seed(x)
-         self.gauss_next = None
  
  ## -------------------- core generator -------------------
--- 117,120 ----
***************
*** 151,154 ****
--- 150,155 ----
          self._seed = int(x)+1, int(y)+1, int(z)+1
  
+         self.gauss_next = None
+ 
      def random(self):
          """Get the next random number in the range [0.0, 1.0)."""
***************
*** 238,241 ****
--- 239,244 ----
          # Zero is a poor seed, so substitute 1
          self._seed = (x or 1, y or 1, z or 1)
+ 
+         self.gauss_next = None
  
      def whseed(self, a=None):