Skip to content

Commit 4e285f2

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 aeea95a commit 4e285f2

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

5972-
On a Unix-like system, random bytes are read from the ``/dev/urandom``
5973-
device. If the ``/dev/urandom`` device is not available or not readable, the
5974-
:exc:`NotImplementedError` exception is raised.
5972+
On other Unix-like systems, the C ``getrandom()`` function is used if it is
5973+
available, otherwise the C ``getentropy()`` function.
5974+
5975+
If none of these functions can be used, random bytes are read from the
5976+
``/dev/urandom`` device. If the ``/dev/urandom`` device is not available or
5977+
not readable, the :exc:`NotImplementedError` exception is raised.
59755978

59765979
On Windows, it will use ``BCryptGenRandom()``.
59775980

0 commit comments

Comments
 (0)