From d31142655aa76d98b2ddc425ce451062088239e4 Mon Sep 17 00:00:00 2001 From: Stan Ulbrych <89152624+StanFromIreland@users.noreply.github.com> Date: Tue, 6 May 2025 17:37:39 +0100 Subject: [PATCH 1/2] Add bounds --- Doc/library/random.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Doc/library/random.rst b/Doc/library/random.rst index ef0cfb0e76cef6..6b11f46fa9db81 100644 --- a/Doc/library/random.rst +++ b/Doc/library/random.rst @@ -113,7 +113,7 @@ Functions for bytes .. function:: randbytes(n) - Generate *n* random bytes. + Generate *n* random bytes where *n* is ``0 <= n < 2 ** 28``. This method should not be used for generating security tokens. Use :func:`secrets.token_bytes` instead. From b10664c0da6253c8df216d51c6fe143e614f3df4 Mon Sep 17 00:00:00 2001 From: Stan Ulbrych <89152624+StanFromIreland@users.noreply.github.com> Date: Tue, 6 May 2025 18:23:36 +0100 Subject: [PATCH 2/2] Reword --- Doc/library/random.rst | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Doc/library/random.rst b/Doc/library/random.rst index 6b11f46fa9db81..0e20f697b048b6 100644 --- a/Doc/library/random.rst +++ b/Doc/library/random.rst @@ -113,7 +113,10 @@ Functions for bytes .. function:: randbytes(n) - Generate *n* random bytes where *n* is ``0 <= n < 2 ** 28``. + Generate *n* random bytes. + + *n* must be greater or equal to ``0``. The upper bound depends + on platform integer size. This method should not be used for generating security tokens. Use :func:`secrets.token_bytes` instead.