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

Skip to content

Commit 8c195af

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.
2 parents 2dabaf6 + 7ff1822 commit 8c195af

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
@@ -88,6 +88,9 @@ Core and Builtins
8888
Library
8989
-------
9090

91+
- Issue #15340: Fix importing the random module when /dev/urandom cannot
92+
be opened. This was a regression caused by the hash randomization patch.
93+
9194
- Issue #15828: Restore support for C extensions in imp.load_module()
9295

9396
- Issue #10650: Deprecate the watchexp parameter of the Decimal.quantize()

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)