<p dir="ltr">Sorry, I don't hve the bandwith to follow the huge discussion around random in Python. If you want my help, please write a PEP to summarize the discussion.</p>
<p dir="ltr">My change fixes an obvious bug. Even if the Python API changes, I don't expect that all the C code will be removed.</p>
<p dir="ltr">Victor<br>
</p>
<div class="gmail_quote">Le 14 juin 2016 5:11 PM, "Steven D'Aprano" <<a href="mailto:steve@pearwood.info">steve@pearwood.info</a>> a écrit :<br type="attribution"><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/victor.stinner%40gmail.com" rel="noreferrer" target="_blank">https://mail.python.org/mailman/options/python-dev/victor.stinner%40gmail.com</a><br>
</blockquote></div>