diff options
author | Tim Peters <tim.peters@gmail.com> | 2003-06-19 03:23:06 (GMT) |
---|---|---|
committer | Tim Peters <tim.peters@gmail.com> | 2003-06-19 03:23:06 (GMT) |
commit | afb8979771e78ef8fe3d610c023463f7ec4f3e1b (patch) | |
tree | f00bd7a3376c8a178ddc2920951e664f8b0e5936 | |
parent | 0b1b5adaee0221401da75523d2fe32ed469d17ae (diff) | |
download | cpython-afb8979771e78ef8fe3d610c023463f7ec4f3e1b.zip cpython-afb8979771e78ef8fe3d610c023463f7ec4f3e1b.tar.gz cpython-afb8979771e78ef8fe3d610c023463f7ec4f3e1b.tar.bz2 |
randrange(): 2.3 can no longer raises OverflowError on an int() call, so
some of this code because useless, and (worse) could return a long
instead of int (in Zope that's important, because a long can't be used
as a key in an IOBTree or IIBTree).
-rw-r--r-- | Lib/random.py | 11 |
1 files changed, 1 insertions, 10 deletions
diff --git a/Lib/random.py b/Lib/random.py index defddbe..0937ba2 100644 --- a/Lib/random.py +++ b/Lib/random.py @@ -148,16 +148,7 @@ class Random(_random.Random): if istop != stop: raise ValueError, "non-integer stop for randrange()" if step == 1 and istart < istop: - try: - return istart + int(self.random()*(istop - istart)) - except OverflowError: - # This can happen if istop-istart > sys.maxint + 1, and - # multiplying by random() doesn't reduce it to something - # <= sys.maxint. We know that the overall result fits - # in an int, and can still do it correctly via math.floor(). - # But that adds another function call, so for speed we - # avoided that whenever possible. - return int(istart + _floor(self.random()*(istop - istart))) + return int(istart + self.random()*(istop - istart)) if step == 1: raise ValueError, "empty range for randrange()" |