Author martin.panter
Recipients martin.panter, virtuald, vstinner
Date 2017-01-08.21:20:02
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <>
It looks like the logic for handling an error seeding from urandom is reversed: <>. 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!
        /* Reading system entropy failed, fall back on the worst entropy:
           use the current time and process identifier. */
Date User Action Args
2017-01-08 21:20:02martin.pantersetrecipients: + martin.panter, vstinner, virtuald
2017-01-08 21:20:02martin.pantersetmessageid: <>
2017-01-08 21:20:02martin.panterlinkissue29208 messages
2017-01-08 21:20:02martin.pantercreate