mirror of
https://github.com/python/cpython.git
synced 2025-08-04 00:48:58 +00:00
Issue #18756: Improve error reporting in os.urandom() when the failure is due to something else than /dev/urandom not existing.
This commit is contained in:
parent
802bf8aea1
commit
ec34ab5010
3 changed files with 30 additions and 2 deletions
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue