diff options
author | Antoine Pitrou <solipsis@pitrou.net> | 2013-08-16 20:49:32 +0200 |
---|---|---|
committer | Antoine Pitrou <solipsis@pitrou.net> | 2013-08-16 20:49:32 +0200 |
commit | bbbedd60d01bca6ef1947fe76ef1068f320a6ab9 (patch) | |
tree | 7266291d4fd2d6930d83fc0ee7c023cbe0f8799c /Python/random.c | |
parent | 8bd5240aa44981d37f45f3cacf4f7a25c55566fe (diff) | |
parent | a9a4ac217e58ba0e4244ba4e20f466f6db6accf5 (diff) | |
download | cpython-bbbedd60d01bca6ef1947fe76ef1068f320a6ab9.tar.gz |
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/random.c')
-rw-r--r-- | Python/random.c | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/Python/random.c b/Python/random.c index 1ad4c3df7f..709f980dca 100644 --- a/Python/random.c +++ b/Python/random.c @@ -138,8 +138,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; } |