Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 380c55c

Browse files
committed
Issue #15340: Fix importing the random module when /dev/urandom cannot be opened.
This was a regression caused by the hash randomization patch.
1 parent 0398985 commit 380c55c

2 files changed

Lines changed: 5 additions & 1 deletion

File tree

Misc/NEWS

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@ Core and Builtins
1818
Library
1919
-------
2020

21+
- Issue #15340: Fix importing the random module when /dev/urandom cannot
22+
be opened. This was a regression caused by the hash randomization patch.
23+
2124
- Issue #15785: Modify window.get_wch() API of the curses module: return
2225
a character for most keys, and an integer for special keys, instead of
2326
always returning an integer. So it is now possible to distinguish special

Python/random.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,8 @@ dev_urandom_python(char *buffer, Py_ssize_t size)
165165
Py_END_ALLOW_THREADS
166166
if (fd < 0)
167167
{
168-
PyErr_SetFromErrnoWithFilename(PyExc_OSError, "/dev/urandom");
168+
PyErr_SetString(PyExc_NotImplementedError,
169+
"/dev/urandom (or equivalent) not found");
169170
return -1;
170171
}
171172

0 commit comments

Comments
 (0)