diff options
author | Raymond Hettinger <rhettinger@users.noreply.github.com> | 2019-08-22 16:19:36 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-08-22 16:19:36 (GMT) |
commit | d0cdeaab76fef8a6e5a04665df226b6659111e4e (patch) | |
tree | 71f9d3b0791543ef421090997152c713ef4f8684 /Doc | |
parent | 4109263a7edce11194e301138cf66fa2d07f7ce4 (diff) | |
download | cpython-d0cdeaab76fef8a6e5a04665df226b6659111e4e.zip cpython-d0cdeaab76fef8a6e5a04665df226b6659111e4e.tar.gz cpython-d0cdeaab76fef8a6e5a04665df226b6659111e4e.tar.bz2 |
bpo-32554: Deprecate hashing arbitrary types in random.seed() (GH-15382)
Diffstat (limited to 'Doc')
-rw-r--r-- | Doc/library/random.rst | 10 | ||||
-rw-r--r-- | Doc/whatsnew/3.9.rst | 6 |
2 files changed, 16 insertions, 0 deletions
diff --git a/Doc/library/random.rst b/Doc/library/random.rst index 90b8624..1bd1856 100644 --- a/Doc/library/random.rst +++ b/Doc/library/random.rst @@ -86,6 +86,11 @@ Bookkeeping functions .. versionchanged:: 3.2 Moved to the version 2 scheme which uses all of the bits in a string seed. + .. deprecated:: 3.9 + In the future, the *seed* must be one of the following types: + *NoneType*, :class:`int`, :class:`float`, :class:`str`, + :class:`bytes`, or :class:`bytearray`. + .. function:: getstate() Return an object capturing the current internal state of the generator. This @@ -316,6 +321,11 @@ Alternative Generator Class that implements the default pseudo-random number generator used by the :mod:`random` module. + .. deprecated:: 3.9 + In the future, the *seed* must be one of the following types: + :class:`NoneType`, :class:`int`, :class:`float`, :class:`str`, + :class:`bytes`, or :class:`bytearray`. + .. class:: SystemRandom([seed]) Class that uses the :func:`os.urandom` function for generating random numbers diff --git a/Doc/whatsnew/3.9.rst b/Doc/whatsnew/3.9.rst index 6615a2e..05a17a5 100644 --- a/Doc/whatsnew/3.9.rst +++ b/Doc/whatsnew/3.9.rst @@ -169,6 +169,12 @@ Deprecated of Python. For the majority of use cases users can leverage the Abstract Syntax Tree (AST) generation and compilation stage, using the :mod:`ast` module. +* The :mod:`random` module currently accepts any hashable type as a + possible seed value. Unfortunately, some of those types are not + guaranteed to have a deterministic hash value. After Python 3.9, + the module will restrict its seeds to *None*, :class:`int`, + :class:`float`, :class:`str`, :class:`bytes`, and :class:`bytearray`. + Removed ======= |