summaryrefslogtreecommitdiff
path: root/Modules
diff options
context:
space:
mode:
authorEric Snow <ericsnowcurrently@gmail.com>2023-05-15 13:59:26 -0600
committerGitHub <noreply@github.com>2023-05-15 13:59:26 -0600
commit26baa747c2ebc2beeff769bb07b5fb5a51ad5f4b (patch)
treee54b52c2c950d59a20f4b0658d8eb2af3adec246 /Modules
parentcb88ae635e96d7020ba6187bcfd45ace4dcd8395 (diff)
downloadcpython-git-26baa747c2ebc2beeff769bb07b5fb5a51ad5f4b.tar.gz
gh-104341: Adjust tstate_must_exit() to Respect Interpreter Finalization (gh-104437)
With the move to a per-interpreter GIL, this check slipped through the cracks.
Diffstat (limited to 'Modules')
-rw-r--r--Modules/_asynciomodule.c2
-rw-r--r--Modules/_io/bufferedio.c3
-rw-r--r--Modules/_sqlite/connection.c2
-rw-r--r--Modules/_winapi.c2
4 files changed, 5 insertions, 4 deletions
diff --git a/Modules/_asynciomodule.c b/Modules/_asynciomodule.c
index 3830245abe..7e33558dba 100644
--- a/Modules/_asynciomodule.c
+++ b/Modules/_asynciomodule.c
@@ -526,7 +526,7 @@ future_init(FutureObj *fut, PyObject *loop)
if (is_true < 0) {
return -1;
}
- if (is_true && !_Py_IsFinalizing()) {
+ if (is_true && !_Py_IsInterpreterFinalizing(PyInterpreterState_Get())) {
/* Only try to capture the traceback if the interpreter is not being
finalized. The original motivation to add a `_Py_IsFinalizing()`
call was to prevent SIGSEGV when a Future is created in a __del__
diff --git a/Modules/_io/bufferedio.c b/Modules/_io/bufferedio.c
index 6f291c3449..7a0c516411 100644
--- a/Modules/_io/bufferedio.c
+++ b/Modules/_io/bufferedio.c
@@ -293,7 +293,8 @@ _enter_buffered_busy(buffered *self)
"reentrant call inside %R", self);
return 0;
}
- relax_locking = _Py_IsFinalizing();
+ PyInterpreterState *interp = PyInterpreterState_Get();
+ relax_locking = _Py_IsInterpreterFinalizing(interp);
Py_BEGIN_ALLOW_THREADS
if (!relax_locking)
st = PyThread_acquire_lock(self->lock, 1);
diff --git a/Modules/_sqlite/connection.c b/Modules/_sqlite/connection.c
index 7bbb462ed5..5c57a4101c 100644
--- a/Modules/_sqlite/connection.c
+++ b/Modules/_sqlite/connection.c
@@ -419,7 +419,7 @@ connection_close(pysqlite_Connection *self)
{
/* If close is implicitly called as a result of interpreter
* tear-down, we must not call back into Python. */
- if (_Py_IsFinalizing()) {
+ if (_Py_IsInterpreterFinalizing(PyInterpreterState_Get())) {
remove_callbacks(self->db);
}
(void)connection_exec_stmt(self, "ROLLBACK");
diff --git a/Modules/_winapi.c b/Modules/_winapi.c
index 473bcb4736..1e02dbc1a4 100644
--- a/Modules/_winapi.c
+++ b/Modules/_winapi.c
@@ -133,7 +133,7 @@ overlapped_dealloc(OverlappedObject *self)
{
/* The operation is no longer pending -- nothing to do. */
}
- else if (_Py_IsFinalizing())
+ else if (_Py_IsInterpreterFinalizing(PyInterpreterState_Get()))
{
/* The operation is still pending -- give a warning. This
will probably only happen on Windows XP. */