Skip to content

bpo-40286: Put methods in correct sections. Add security notice #19870

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
May 5, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 15 additions & 10 deletions Doc/library/random.rst
Original file line number Diff line number Diff line change
Expand Up @@ -104,21 +104,16 @@ Bookkeeping functions
the time :func:`getstate` was called.


.. function:: getrandbits(k)

Returns a Python integer with *k* random bits. This method is supplied with
the Mersenne Twister generator and some other generators may also provide it
as an optional part of the API. When available, :meth:`getrandbits` enables
:meth:`randrange` to handle arbitrarily large ranges.

.. versionchanged:: 3.9
This method now accepts zero for *k*.

Functions for bytes
-------------------

.. function:: randbytes(n)

Generate *n* random bytes.

This method should not be used for generating security tokens.
Use :func:`secrets.token_bytes` instead.

.. versionadded:: 3.9


Expand All @@ -145,6 +140,16 @@ Functions for integers
Return a random integer *N* such that ``a <= N <= b``. Alias for
``randrange(a, b+1)``.

.. function:: getrandbits(k)

Returns a Python integer with *k* random bits. This method is supplied with
the MersenneTwister generator and some other generators may also provide it
as an optional part of the API. When available, :meth:`getrandbits` enables
:meth:`randrange` to handle arbitrarily large ranges.

.. versionchanged:: 3.9
This method now accepts zero for *k*.


Functions for sequences
-----------------------
Expand Down