Author vstinner
Recipients vstinner
Date 2016-06-08.09:19:01
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <>
Follow-up of the issue #26839: I propose to add a "block" keyword-only optional parameter to os.urandom(). I chose to make the parameter a keyword-only to avoid suprises and backward incompatible change and because I want to make this change in Python 3.5.2.

The attached patch:

* add block parameter to os.urandom()
* modify random.Random constructor to call os.urandom() with block=False
* modify _PyOS_URandom() to add a block parameter
* modify dev_urandom_noraise() to not block

The block parameter currently only changes the behaviour on Linux when the getrandom() syscall is used and the urandom entropy pool is not initialized.

With the change, os.urandom() blocks by default, but Python startup and "import random" doesn't block even if the urandom entropy pool is not initialized yet.
Date User Action Args
2016-06-08 09:19:03vstinnersetrecipients: + vstinner
2016-06-08 09:19:03vstinnersetmessageid: <>
2016-06-08 09:19:03vstinnerlinkissue27266 messages
2016-06-08 09:19:03vstinnercreate