[Python-checkins] cpython: Issue #15340: Fix importing the random module when /dev/urandom cannot be

georg.brandl python-checkins at python.org
Sun Sep 9 11:19:04 CEST 2012


http://hg.python.org/cpython/rev/6a782496f90a
changeset:   78901:6a782496f90a
user:        Antoine Pitrou <solipsis at pitrou.net>
date:        Fri Sep 07 23:49:07 2012 +0200
summary:
  Issue #15340: Fix importing the random module when /dev/urandom cannot be opened.
This was a regression caused by the hash randomization patch.

files:
  Misc/NEWS       |  3 +++
  Python/random.c |  3 ++-
  2 files changed, 5 insertions(+), 1 deletions(-)


diff --git a/Misc/NEWS b/Misc/NEWS
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -18,6 +18,9 @@
 Library
 -------
 
+- Issue #15340: Fix importing the random module when /dev/urandom cannot
+  be opened.  This was a regression caused by the hash randomization patch.
+
 - Issue #15785: Modify window.get_wch() API of the curses module: return
   a character for most keys, and an integer for special keys, instead of
   always returning an integer. So it is now possible to distinguish special
diff --git a/Python/random.c b/Python/random.c
--- a/Python/random.c
+++ b/Python/random.c
@@ -165,7 +165,8 @@
     Py_END_ALLOW_THREADS
     if (fd < 0)
     {
-        PyErr_SetFromErrnoWithFilename(PyExc_OSError, "/dev/urandom");
+        PyErr_SetString(PyExc_NotImplementedError,
+                        "/dev/urandom (or equivalent) not found");
         return -1;
     }
 

-- 
Repository URL: http://hg.python.org/cpython


More information about the Python-checkins mailing list