[Python-checkins] cpython: Issue #22181: Fix dev_urandom_noraise(), try calling py_getrandom() before
victor.stinner
python-checkins at python.org
Thu Mar 19 23:30:18 CET 2015
https://hg.python.org/cpython/rev/8c73af0b3cd9
changeset: 95071:8c73af0b3cd9
user: Victor Stinner <victor.stinner at gmail.com>
date: Thu Mar 19 23:24:45 2015 +0100
summary:
Issue #22181: Fix dev_urandom_noraise(), try calling py_getrandom() before
opening /dev/urandom.
files:
Python/random.c | 8 ++++----
1 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/Python/random.c b/Python/random.c
--- a/Python/random.c
+++ b/Python/random.c
@@ -166,10 +166,6 @@
assert (0 < size);
- fd = _Py_open_noraise("/dev/urandom", O_RDONLY);
- if (fd < 0)
- Py_FatalError("Failed to open /dev/urandom");
-
#ifdef HAVE_GETRANDOM_SYSCALL
if (py_getrandom(buffer, size, 0) == 1)
return;
@@ -177,6 +173,10 @@
* on reading /dev/urandom */
#endif
+ fd = _Py_open_noraise("/dev/urandom", O_RDONLY);
+ if (fd < 0)
+ Py_FatalError("Failed to open /dev/urandom");
+
while (0 < size)
{
do {
--
Repository URL: https://hg.python.org/cpython
More information about the Python-checkins
mailing list