Skip to content

Commit c885978

Browse files
gh-116245: Document getentropy() use in os.urandom() (#162108)
Co-authored-by: Stan Ulbrych <89152624+StanFromIreland@users.noreply.github.com>
1 parent aedb2c1 commit c885978

1 file changed

Lines changed: 6 additions & 3 deletions

File tree

‎Doc/library/os.rst‎

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6466,9 +6466,12 @@ 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()`` function is used if it is
6470+
available, otherwise the C ``getentropy()`` function.
6471+
6472+
If none of these functions can be used, random bytes are read from the
6473+
``/dev/urandom`` device. If the ``/dev/urandom`` device is not available or
6474+
not readable, the :exc:`NotImplementedError` exception is raised.
64726475

64736476
On Windows, it will use ``BCryptGenRandom()``.
64746477

0 commit comments

Comments
 (0)