From: Benjamin Peterson Date: Thu, 29 Dec 2016 04:02:35 +0000 (-0800) Subject: fix error check, so that Random.seed actually uses OS randomness (closes #29085) X-Git-Tag: v3.6.1rc1~241 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=acc2f74ca991f6579f5b9055dfe885b9a8af4645;p=thirdparty%2FPython%2Fcpython.git fix error check, so that Random.seed actually uses OS randomness (closes #29085) --- diff --git a/Misc/NEWS b/Misc/NEWS index 1112257a28af..3436c0a52fbe 100644 --- a/Misc/NEWS +++ b/Misc/NEWS @@ -40,6 +40,9 @@ Core and Builtins Library ------- +- Issue #29085: Allow random.Random.seed() to use high quality OS randomness + rather than the pid and time. + - Issue #29079: Prevent infinite loop in pathlib.resolve() on Windows - Issue #13051: Fixed recursion errors in large or resized diff --git a/Modules/_randommodule.c b/Modules/_randommodule.c index 63759d556248..0d3282db8f28 100644 --- a/Modules/_randommodule.c +++ b/Modules/_randommodule.c @@ -245,7 +245,7 @@ random_seed(RandomObject *self, PyObject *args) return NULL; if (arg == NULL || arg == Py_None) { - if (random_seed_urandom(self) >= 0) { + if (random_seed_urandom(self) < 0) { PyErr_Clear(); /* Reading system entropy failed, fall back on the worst entropy: