[issue29208] BlockingIOError during system startup
Martin Panter
report at bugs.python.org
Sun Jan 8 16:20:02 EST 2017
Martin Panter added the comment:
It looks like the logic for handling an error seeding from urandom is reversed: <https://hg.python.org/cpython/rev/45fc0c83ed42#l6.66>. Random_seed_urandom() actually returns -1 if is an exception set, and 0 if it was successful.
The result would be a normal working urandom setup ignores urandom and seeds from the time and PID. Not a big deal, since the old code always seeded from a (lower resolution) time anyway. But if urandom failed, we get the SystemError.
The fix should be simple, in Modules/_randommodule.c change the random_seed() function to read
if (arg == NULL || arg == Py_None) {
if (random_seed_urandom(self) < 0) { // was >= 0!
PyErr_Clear();
/* Reading system entropy failed, fall back on the worst entropy:
use the current time and process identifier. */
random_seed_time_pid(self);
}
Py_RETURN_NONE;
}
----------
keywords: +3.6regression
nosy: +haypo, martin.panter
type: -> behavior
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue29208>
_______________________________________
More information about the Python-bugs-list
mailing list