]> granicus.if.org Git - python/commitdiff
Issue #27776: _PyRandom_Init() doesn't call PyErr_CheckSignals() anymore
authorVictor Stinner <victor.stinner@gmail.com>
Tue, 16 Aug 2016 13:19:09 +0000 (15:19 +0200)
committerVictor Stinner <victor.stinner@gmail.com>
Tue, 16 Aug 2016 13:19:09 +0000 (15:19 +0200)
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().

Python/random.c

index 7d37fe95753e8622f16860edd9ce97ee8487e4ff..4d0eabc001c9024fca11e5de9a9e9e3ae028736a 100644 (file)
@@ -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;
             }