Skip to content
Merged
Prev Previous commit
Next Next commit
Merge branch 'master' into randrange-index
  • Loading branch information
serhiy-storchaka committed Dec 28, 2020
commit 5749575ba5407e543d5427ea17ca64d9af086196
1 change: 0 additions & 1 deletion Doc/library/random.rst
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,6 @@ Functions for integers
or ``randrange('10')`` will be changed from :exc:`ValueError` to
:exc:`TypeError`.


.. function:: randint(a, b)

Return a random integer *N* such that ``a <= N <= b``. Alias for
Expand Down
1 change: 0 additions & 1 deletion Lib/random.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@
from operator import index as _index
from itertools import accumulate as _accumulate, repeat as _repeat
from bisect import bisect as _bisect
from operator import index as _index
import os as _os
import _random

Expand Down
5 changes: 4 additions & 1 deletion Lib/test/test_random.py
Original file line number Diff line number Diff line change
Expand Up @@ -535,7 +535,6 @@ def test_randrange_errors(self):
raises(3, 3)
raises(-721)
raises(0, 100, -12)
self.assertWarns(DeprecationWarning, raises, 3, 3, 1.0)
# Non-integer start/stop
self.assertWarns(DeprecationWarning, raises, 3.14159)
self.assertWarns(DeprecationWarning, self.gen.randrange, 3.0)
Expand All @@ -547,10 +546,14 @@ def test_randrange_errors(self):
self.assertWarns(DeprecationWarning, raises, 0, '2')
# Zero and non-integer step
raises(0, 42, 0)
self.assertWarns(DeprecationWarning, raises, 0, 42, 0.0)
self.assertWarns(DeprecationWarning, raises, 0, 0, 0.0)
self.assertWarns(DeprecationWarning, raises, 0, 42, 3.14159)
self.assertWarns(DeprecationWarning, self.gen.randrange, 0, 42, 3.0)
self.assertWarns(DeprecationWarning, self.gen.randrange, 0, 42, Fraction(3, 1))
self.assertWarns(DeprecationWarning, raises, 0, 42, '3')
self.assertWarns(DeprecationWarning, self.gen.randrange, 0, 42, 1.0)
self.assertWarns(DeprecationWarning, raises, 0, 0, 1.0)

def test_randrange_argument_handling(self):
randrange = self.gen.randrange
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
Harmonized random.randrange() argument handling to match range().
Harmonized :func:`random.randrange` argument handling to match :func:`range`.

* The integer test and conversion in randrange() now uses
operator.index().
* Non-integer arguments to randrange() are deprecated.
* The *ValueError* is deprecated in favor of a *TypeError*.
* The integer test and conversion in ``randrange()`` now uses
:func:`operator.index`.
* Non-integer arguments to ``randrange()`` are deprecated.
* The ``ValueError`` is deprecated in favor of a ``TypeError``.
* It now runs a little faster than before.

(Contributed by Raymond Hettinger and Serhiy Storchaka.)
You are viewing a condensed version of this merge commit. You can view the full changes here.