Raise statement normalization in Lib/.

This commit is contained in:
Collin Winter 2007-08-30 01:19:48 +00:00
parent 8b3febef2f
commit ce36ad8a46
80 changed files with 502 additions and 530 deletions

View file

@ -157,18 +157,18 @@ class Random(_random.Random):
# common case while still doing adequate error checking.
istart = int(start)
if istart != start:
raise ValueError, "non-integer arg 1 for randrange()"
raise ValueError("non-integer arg 1 for randrange()")
if stop is default:
if istart > 0:
if istart >= maxwidth:
return self._randbelow(istart)
return int(self.random() * istart)
raise ValueError, "empty range for randrange()"
raise ValueError("empty range for randrange()")
# stop argument supplied.
istop = int(stop)
if istop != stop:
raise ValueError, "non-integer stop for randrange()"
raise ValueError("non-integer stop for randrange()")
width = istop - istart
if step == 1 and width > 0:
# Note that
@ -188,21 +188,21 @@ class Random(_random.Random):
return int(istart + self._randbelow(width))
return int(istart + int(self.random()*width))
if step == 1:
raise ValueError, "empty range for randrange() (%d,%d, %d)" % (istart, istop, width)
raise ValueError("empty range for randrange() (%d,%d, %d)" % (istart, istop, width))
# Non-unit step argument supplied.
istep = int(step)
if istep != step:
raise ValueError, "non-integer step for randrange()"
raise ValueError("non-integer step for randrange()")
if istep > 0:
n = (width + istep - 1) // istep
elif istep < 0:
n = (width + istep + 1) // istep
else:
raise ValueError, "zero step for randrange()"
raise ValueError("zero step for randrange()")
if n <= 0:
raise ValueError, "empty range for randrange()"
raise ValueError("empty range for randrange()")
if n >= maxwidth:
return istart + istep*self._randbelow(n)
@ -300,7 +300,7 @@ class Random(_random.Random):
n = len(population)
if not 0 <= k <= n:
raise ValueError, "sample larger than population"
raise ValueError("sample larger than population")
random = self.random
_int = int
result = [None] * k
@ -459,7 +459,7 @@ class Random(_random.Random):
# Warning: a few older sources define the gamma distribution in terms
# of alpha > -1.0
if alpha <= 0.0 or beta <= 0.0:
raise ValueError, 'gammavariate: alpha and beta must be > 0.0'
raise ValueError('gammavariate: alpha and beta must be > 0.0')
random = self.random
if alpha > 1.0: