Skip to content

Commit e299cae

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 bc71f2c commit e299cae

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
@@ -103,6 +103,9 @@ Core and Builtins
103103
Library
104104
-------
105105

106+
- Issue #15340: Fix importing the random module when /dev/urandom cannot
107+
be opened. This was a regression caused by the hash randomization patch.
108+
106109
- Issue #15841: The readable(), writable() and seekable() methods of
107110
io.BytesIO and io.StringIO objects now raise ValueError when the object has
108111
been closed. Patch by Alessandro Moura.

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)