Skip to content

Commit 8f8de73

Browse files
authored
No need to test "istep==1" twice. (GH-24064)
1 parent 768fa14 commit 8f8de73

File tree

1 file changed

+2
-4
lines changed

1 file changed

+2
-4
lines changed

Lib/random.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -351,9 +351,9 @@ def randrange(self, start, stop=None, step=_ONE):
351351
DeprecationWarning, 2)
352352
raise ValueError("non-integer step for randrange()")
353353
width = istop - istart
354-
if istep == 1 and width > 0:
355-
return istart + self._randbelow(width)
356354
if istep == 1:
355+
if width > 0:
356+
return istart + self._randbelow(width)
357357
raise ValueError("empty range for randrange() (%d, %d, %d)" % (istart, istop, width))
358358

359359
# Non-unit step argument supplied.
@@ -363,10 +363,8 @@ def randrange(self, start, stop=None, step=_ONE):
363363
n = (width + istep + 1) // istep
364364
else:
365365
raise ValueError("zero step for randrange()")
366-
367366
if n <= 0:
368367
raise ValueError("empty range for randrange()")
369-
370368
return istart + istep * self._randbelow(n)
371369

372370
def randint(self, a, b):

0 commit comments

Comments
 (0)