No need to test "istep==1" twice. (GH-24064)
This commit is contained in:
parent
768fa145cf
commit
8f8de7380c
|
@ -351,9 +351,9 @@ class Random(_random.Random):
|
||||||
DeprecationWarning, 2)
|
DeprecationWarning, 2)
|
||||||
raise ValueError("non-integer step for randrange()")
|
raise ValueError("non-integer step for randrange()")
|
||||||
width = istop - istart
|
width = istop - istart
|
||||||
if istep == 1 and width > 0:
|
|
||||||
return istart + self._randbelow(width)
|
|
||||||
if istep == 1:
|
if istep == 1:
|
||||||
|
if width > 0:
|
||||||
|
return istart + self._randbelow(width)
|
||||||
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.
|
# Non-unit step argument supplied.
|
||||||
|
@ -363,10 +363,8 @@ class Random(_random.Random):
|
||||||
n = (width + istep + 1) // istep
|
n = (width + istep + 1) // istep
|
||||||
else:
|
else:
|
||||||
raise ValueError("zero step for randrange()")
|
raise ValueError("zero step for randrange()")
|
||||||
|
|
||||||
if n <= 0:
|
if n <= 0:
|
||||||
raise ValueError("empty range for randrange()")
|
raise ValueError("empty range for randrange()")
|
||||||
|
|
||||||
return istart + istep * self._randbelow(n)
|
return istart + istep * self._randbelow(n)
|
||||||
|
|
||||||
def randint(self, a, b):
|
def randint(self, a, b):
|
||||||
|
|
Loading…
Reference in New Issue