diff options
author | Eric Snow <ericsnowcurrently@gmail.com> | 2019-02-23 15:40:43 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-02-23 15:40:43 -0700 |
commit | 64d6cc826dacebc2493b1bb5e8cb97828eb76f81 (patch) | |
tree | 93185a0a288ead9ac51ccaa606cd2aae7a4e45ed /Python/ceval.c | |
parent | 06babb24225d41a76e4aee975380294ca1ee1d7c (diff) | |
download | cpython-git-64d6cc826dacebc2493b1bb5e8cb97828eb76f81.tar.gz |
bpo-35724: Explicitly require the main interpreter for signal-handling. (GH-11530)
Ensure that the main interpreter is active (in the main thread) for signal-handling operations. This is increasingly relevant as people use subinterpreters more.
https://bugs.python.org/issue35724
Diffstat (limited to 'Python/ceval.c')
-rw-r--r-- | Python/ceval.c | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/Python/ceval.c b/Python/ceval.c index 03456f6d2a..439f4f156e 100644 --- a/Python/ceval.c +++ b/Python/ceval.c @@ -379,9 +379,16 @@ handle_signals(void) { return 0; } + /* + * Ensure that the thread isn't currently running some other + * interpreter. + */ + if (_PyInterpreterState_GET_UNSAFE() != _PyRuntime.interpreters.main) { + return 0; + } UNSIGNAL_PENDING_SIGNALS(); - if (PyErr_CheckSignals() < 0) { + if (_PyErr_CheckSignals() < 0) { SIGNAL_PENDING_SIGNALS(); /* We're not done yet */ return -1; } |