Skip to content

Commit cadfee0

Browse files
kirtiagwl1595StanFromIreland
authored andcommitted
gh-116245: Document getentropy() use in os.urandom() (GH-162108)
(cherry picked from commit c885978) Co-authored-by: Kirti Aggarwal <47375858+kirtiagwl1595@users.noreply.github.com> Co-authored-by: Stan Ulbrych <89152624+StanFromIreland@users.noreply.github.com>
1 parent aded5b9 commit cadfee0

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
@@ -6392,9 +6392,12 @@ Random numbers
63926392
random bytes in non-blocking mode (using the :data:`GRND_NONBLOCK` flag) or
63936393
to poll until the system urandom entropy pool is initialized.
63946394

6395-
On a Unix-like system, random bytes are read from the ``/dev/urandom``
6396-
device. If the ``/dev/urandom`` device is not available or not readable, the
6397-
:exc:`NotImplementedError` exception is raised.
6395+
On other Unix-like systems, the C ``getrandom()`` function is used if it is
6396+
available, otherwise the C ``getentropy()`` function.
6397+
6398+
If none of these functions can be used, random bytes are read from the
6399+
``/dev/urandom`` device. If the ``/dev/urandom`` device is not available or
6400+
not readable, the :exc:`NotImplementedError` exception is raised.
63986401

63996402
On Windows, it will use ``BCryptGenRandom()``.
64006403

0 commit comments

Comments
 (0)