From: Victor Stinner Date: Tue, 16 Aug 2016 13:19:09 +0000 (+0200) Subject: Issue #27776: _PyRandom_Init() doesn't call PyErr_CheckSignals() anymore X-Git-Tag: v3.6.0b1~706 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=cecdd9634b8ca3f0b260681d75cc1fd00a350efd;p=thirdparty%2FPython%2Fcpython.git 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(). --- diff --git a/Python/random.c b/Python/random.c index 7d37fe95753e..4d0eabc001c9 100644 --- a/Python/random.c +++ b/Python/random.c @@ -191,10 +191,13 @@ py_getrandom(void *buffer, Py_ssize_t size, int raise) } if (errno == EINTR) { - if (PyErr_CheckSignals()) { - return -1; + if (raise) { + if (PyErr_CheckSignals()) { + return -1; + } } - /* retry getrandom() */ + + /* retry getrandom() if it was interrupted by a signal */ continue; }