Skip to content

Commit 2f80e46

Browse files
committed
gh-116245: Document getentropy() use in os.urandom()
1 parent cc98745 commit 2f80e46

1 file changed

Lines changed: 8 additions & 3 deletions

File tree

‎Doc/library/os.rst‎

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6466,9 +6466,14 @@ Random numbers
64666466
random bytes in non-blocking mode (using the :data:`GRND_NONBLOCK` flag) or
64676467
to poll until the system urandom entropy pool is initialized.
64686468

6469-
On a Unix-like system, random bytes are read from the ``/dev/urandom``
6470-
device. If the ``/dev/urandom`` device is not available or not readable, the
6471-
:exc:`NotImplementedError` exception is raised.
6469+
On other Unix-like systems, the C ``getrandom()`` or ``getentropy()``
6470+
function is used if it is available, for example ``getentropy()`` on OpenBSD
6471+
and on macOS 10.12 and newer.
6472+
6473+
On any Unix-like system, if none of these functions can be used, random
6474+
bytes are read from the ``/dev/urandom`` device. If the ``/dev/urandom``
6475+
device is not available or not readable, the :exc:`NotImplementedError`
6476+
exception is raised.
64726477

64736478
On Windows, it will use ``BCryptGenRandom()``.
64746479

0 commit comments

Comments
 (0)