Mercurial > cpython-lru_cache-weakref
comparison Python/random.c @ 78875:edbf37ace03c 2.7
Issue #15340: Fix importing the random module when /dev/urandom cannot be opened.
This was a regression caused by the hash randomization patch.
| author | Antoine Pitrou <solipsis@pitrou.net> |
|---|---|
| date | Fri, 07 Sep 2012 23:49:07 +0200 |
| parents | 357e268e7c5f |
| children | ec296a36156b |
comparison
equal
deleted
inserted
replaced
| 78871:8cd6acffbcb9 | 78875:edbf37ace03c |
|---|---|
| 163 Py_BEGIN_ALLOW_THREADS | 163 Py_BEGIN_ALLOW_THREADS |
| 164 fd = open("/dev/urandom", O_RDONLY); | 164 fd = open("/dev/urandom", O_RDONLY); |
| 165 Py_END_ALLOW_THREADS | 165 Py_END_ALLOW_THREADS |
| 166 if (fd < 0) | 166 if (fd < 0) |
| 167 { | 167 { |
| 168 PyErr_SetFromErrnoWithFilename(PyExc_OSError, "/dev/urandom"); | 168 PyErr_SetString(PyExc_NotImplementedError, |
| 169 "/dev/urandom (or equivalent) not found"); | |
| 169 return -1; | 170 return -1; |
| 170 } | 171 } |
| 171 | 172 |
| 172 Py_BEGIN_ALLOW_THREADS | 173 Py_BEGIN_ALLOW_THREADS |
| 173 do { | 174 do { |
