[Python-checkins] python/nondist/sandbox/twister _random.c,1.19,1.20 test_random.py,1.6,1.7

tim_one@users.sourceforge.net tim_one@users.sourceforge.net
Sun, 29 Dec 2002 01:05:48 -0800


Update of /cvsroot/python/python/nondist/sandbox/twister
In directory sc8-pr-cvs1:/tmp/cvs-serv10188

Modified Files:
	_random.c test_random.py 
Log Message:
random_seed():  A number of error cases aren't caught here.  This begins
localizing some of the declarations so it's feasible to see what is and
isn't essential.


Index: _random.c
===================================================================
RCS file: /cvsroot/python/python/nondist/sandbox/twister/_random.c,v
retrieving revision 1.19
retrieving revision 1.20
diff -C2 -d -r1.19 -r1.20
*** _random.c	29 Dec 2002 08:57:03 -0000	1.19
--- _random.c	29 Dec 2002 09:05:46 -0000	1.20
***************
*** 207,210 ****
--- 207,211 ----
  random_seed(RandomObject *self, PyObject *args)
  {
+ 	PyObject *result = NULL;	/* guilty until proved innocent */
  	unsigned long *key;
  	unsigned long keylength;
***************
*** 212,221 ****
  	unsigned int i;
  	PyObject *split;
- 	PyObject *result = NULL;
  	PyObject *arg = NULL;
  	PyObject *masklower;
  	PyObject *thirtytwo;
- 	PyObject *little = NULL;
- 	PyObject *newarg;
  	int err;
  	long hash;
--- 213,219 ----
***************
*** 253,256 ****
--- 251,257 ----
  	thirtytwo = PyInt_FromLong(32L);
  	while (PyObject_IsTrue(arg)) {
+ 		PyObject *little;
+ 		PyObject *newarg;
+ 
  		little = PyNumber_And(arg, masklower);
  		if (little == NULL)

Index: test_random.py
===================================================================
RCS file: /cvsroot/python/python/nondist/sandbox/twister/test_random.py,v
retrieving revision 1.6
retrieving revision 1.7
diff -C2 -d -r1.6 -r1.7
*** test_random.py	29 Dec 2002 08:57:03 -0000	1.6
--- test_random.py	29 Dec 2002 09:05:46 -0000	1.7
***************
*** 53,57 ****
          self.assertRaises(TypeError, self.gen.jumpahead, 2.3)  # wrong type
          self.assertRaises(TypeError, self.gen.jumpahead, 2, 3)  # too many
!         
      def test_sample(self):
          # For the entire allowable range of 0 <= k <= N, validate that
--- 53,57 ----
          self.assertRaises(TypeError, self.gen.jumpahead, 2.3)  # wrong type
          self.assertRaises(TypeError, self.gen.jumpahead, 2, 3)  # too many
! 
      def test_sample(self):
          # For the entire allowable range of 0 <= k <= N, validate that