Skip to content

Commit cecdd96

Browse files
committed
Issue #27776: _PyRandom_Init() doesn't call PyErr_CheckSignals() anymore
Modify py_getrandom() to not call PyErr_CheckSignals() if raise is zero. _PyRandom_Init() is called very early in the Python initialization, so it's safer to not call PyErr_CheckSignals().
1 parent 4bad3b6 commit cecdd96

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

Python/random.c

+6-3
Original file line numberDiff line numberDiff line change
@@ -191,10 +191,13 @@ py_getrandom(void *buffer, Py_ssize_t size, int raise)
191191
}
192192

193193
if (errno == EINTR) {
194-
if (PyErr_CheckSignals()) {
195-
return -1;
194+
if (raise) {
195+
if (PyErr_CheckSignals()) {
196+
return -1;
197+
}
196198
}
197-
/* retry getrandom() */
199+
200+
/* retry getrandom() if it was interrupted by a signal */
198201
continue;
199202
}
200203

0 commit comments

Comments
 (0)