Mercurial > cpython-lru_cache-weakref
diff Python/random.c @ 85200:ec296a36156b 2.7
Issue #18756: Improve error reporting in os.urandom() when the failure is due to something else than /dev/urandom not existing.
| author | Antoine Pitrou <solipsis@pitrou.net> |
|---|---|
| date | Fri, 16 Aug 2013 20:44:38 +0200 |
| parents | edbf37ace03c |
| children | 3e5078c3784e |
line wrap: on
line diff
--- a/Python/random.c Fri Aug 16 21:32:25 2013 +0300 +++ b/Python/random.c Fri Aug 16 20:44:38 2013 +0200 @@ -165,8 +165,12 @@ Py_END_ALLOW_THREADS if (fd < 0) { - PyErr_SetString(PyExc_NotImplementedError, - "/dev/urandom (or equivalent) not found"); + if (errno == ENOENT || errno == ENXIO || + errno == ENODEV || errno == EACCES) + PyErr_SetString(PyExc_NotImplementedError, + "/dev/urandom (or equivalent) not found"); + else + PyErr_SetFromErrno(PyExc_OSError); return -1; }
