summaryrefslogtreecommitdiffstats
path: root/Python
diff options
context:
space:
mode:
authorAntoine Pitrou <solipsis@pitrou.net>2013-08-16 18:44:38 (GMT)
committerAntoine Pitrou <solipsis@pitrou.net>2013-08-16 18:44:38 (GMT)
commitec34ab501025f7fd677e0f6b8a8d0c9f960f069f (patch)
tree8355f48954c0e12ac739ea58218aeafbe7780129 /Python
parent802bf8aea1cff2122fc64cca33dc73b50b85e09c (diff)
downloadcpython-ec34ab501025f7fd677e0f6b8a8d0c9f960f069f.zip
cpython-ec34ab501025f7fd677e0f6b8a8d0c9f960f069f.tar.gz
cpython-ec34ab501025f7fd677e0f6b8a8d0c9f960f069f.tar.bz2
Issue #18756: Improve error reporting in os.urandom() when the failure is due to something else than /dev/urandom not existing.
Diffstat (limited to 'Python')
-rw-r--r--Python/random.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/Python/random.c b/Python/random.c
index 53518c2..e5caa82 100644
--- a/Python/random.c
+++ b/Python/random.c
@@ -165,8 +165,12 @@ dev_urandom_python(char *buffer, Py_ssize_t size)
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;
}