<div dir="ltr">I think this is an issue unrelated to the big discussion from a little while ago. The problem isn't that os.urandom() uses getrandom(), it's that it calls it in a mode that may block.</div><div class="gmail_extra"><br><div class="gmail_quote">2016-06-14 8:07 GMT-07:00 Steven D'Aprano <span dir="ltr"><<a href="mailto:steve@pearwood.info" target="_blank">steve@pearwood.info</a>></span>:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Is this right? I thought we had decided that os.urandom should *not*<br>
fall back on getrandom on Linux?<br>
<br>
<br>
<br>
On Tue, Jun 14, 2016 at 02:36:27PM +0000, victor. stinner wrote:<br>
> <a href="https://hg.python.org/cpython/rev/e028e86a5b73" rel="noreferrer" target="_blank">https://hg.python.org/cpython/rev/e028e86a5b73</a><br>
> changeset: 102033:e028e86a5b73<br>
> branch: 3.5<br>
> parent: 102031:a36238de31ae<br>
> user: Victor Stinner <<a href="mailto:victor.stinner@gmail.com">victor.stinner@gmail.com</a>><br>
> date: Tue Jun 14 16:31:35 2016 +0200<br>
> summary:<br>
> Fix os.urandom() using getrandom() on Linux<br>
><br>
> Issue #27278: Fix os.urandom() implementation using getrandom() on Linux.<br>
> Truncate size to INT_MAX and loop until we collected enough random bytes,<br>
> instead of casting a directly Py_ssize_t to int.<br>
><br>
> files:<br>
> Misc/NEWS | 4 ++++<br>
> Python/random.c | 2 +-<br>
> 2 files changed, 5 insertions(+), 1 deletions(-)<br>
><br>
><br>
> diff --git a/Misc/NEWS b/Misc/NEWS<br>
> --- a/Misc/NEWS<br>
> +++ b/Misc/NEWS<br>
> @@ -13,6 +13,10 @@<br>
> Library<br>
> -------<br>
><br>
> +- Issue #27278: Fix os.urandom() implementation using getrandom() on Linux.<br>
> + Truncate size to INT_MAX and loop until we collected enough random bytes,<br>
> + instead of casting a directly Py_ssize_t to int.<br>
> +<br>
> - Issue #26386: Fixed ttk.TreeView selection operations with item id's<br>
> containing spaces.<br>
><br>
> diff --git a/Python/random.c b/Python/random.c<br>
> --- a/Python/random.c<br>
> +++ b/Python/random.c<br>
> @@ -143,7 +143,7 @@<br>
> to 1024 bytes */<br>
> n = Py_MIN(size, 1024);<br>
> #else<br>
> - n = size;<br>
> + n = Py_MIN(size, INT_MAX);<br>
> #endif<br>
><br>
> errno = 0;<br>
><br>
> --<br>
> Repository URL: <a href="https://hg.python.org/cpython" rel="noreferrer" target="_blank">https://hg.python.org/cpython</a><br>
<br>
> _______________________________________________<br>
> Python-checkins mailing list<br>
> <a href="mailto:Python-checkins@python.org">Python-checkins@python.org</a><br>
> <a href="https://mail.python.org/mailman/listinfo/python-checkins" rel="noreferrer" target="_blank">https://mail.python.org/mailman/listinfo/python-checkins</a><br>
<br>
_______________________________________________<br>
Python-Dev mailing list<br>
<a href="mailto:Python-Dev@python.org">Python-Dev@python.org</a><br>
<a href="https://mail.python.org/mailman/listinfo/python-dev" rel="noreferrer" target="_blank">https://mail.python.org/mailman/listinfo/python-dev</a><br>
Unsubscribe: <a href="https://mail.python.org/mailman/options/python-dev/jelle.zijlstra%40gmail.com" rel="noreferrer" target="_blank">https://mail.python.org/mailman/options/python-dev/jelle.zijlstra%40gmail.com</a><br>
</blockquote></div><br></div>