[Python-checkins] python/dist/src/Lib random.py,1.60,1.61

rhettinger at users.sourceforge.net rhettinger at users.sourceforge.net
Sat Jun 5 10:53:24 EDT 2004


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

Modified Files:
	random.py 
Log Message:
SF bug #964230:  random.choice([]) should return more intelligible exception

Add a comment to make the traceback less mysterious.



Index: random.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/random.py,v
retrieving revision 1.60
retrieving revision 1.61
diff -C2 -d -r1.60 -r1.61
*** random.py	23 Feb 2004 17:27:57 -0000	1.60
--- random.py	5 Jun 2004 14:53:22 -0000	1.61
***************
*** 238,242 ****
      def choice(self, seq):
          """Choose a random element from a non-empty sequence."""
!         return seq[int(self.random() * len(seq))]
  
      def shuffle(self, x, random=None, int=int):
--- 238,242 ----
      def choice(self, seq):
          """Choose a random element from a non-empty sequence."""
!         return seq[int(self.random() * len(seq))]  # raises IndexError in seq is empty
  
      def shuffle(self, x, random=None, int=int):




More information about the Python-checkins mailing list