Mercurial > cpython-lru_cache-weakref
comparison Python/random.c @ 85199:fe949918616c
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:49:32 +0200 |
| parents | e52df05b496a 193bcc12575d |
| children | ef889c3d5dc6 |
comparison
equal
deleted
inserted
replaced
| 85197:96c51207e7cd | 85199:fe949918616c |
|---|---|
| 136 Py_BEGIN_ALLOW_THREADS | 136 Py_BEGIN_ALLOW_THREADS |
| 137 fd = open("/dev/urandom", O_RDONLY); | 137 fd = open("/dev/urandom", O_RDONLY); |
| 138 Py_END_ALLOW_THREADS | 138 Py_END_ALLOW_THREADS |
| 139 if (fd < 0) | 139 if (fd < 0) |
| 140 { | 140 { |
| 141 PyErr_SetString(PyExc_NotImplementedError, | 141 if (errno == ENOENT || errno == ENXIO || |
| 142 "/dev/urandom (or equivalent) not found"); | 142 errno == ENODEV || errno == EACCES) |
| 143 PyErr_SetString(PyExc_NotImplementedError, | |
| 144 "/dev/urandom (or equivalent) not found"); | |
| 145 else | |
| 146 PyErr_SetFromErrno(PyExc_OSError); | |
| 143 return -1; | 147 return -1; |
| 144 } | 148 } |
| 145 | 149 |
| 146 Py_BEGIN_ALLOW_THREADS | 150 Py_BEGIN_ALLOW_THREADS |
| 147 do { | 151 do { |
