summaryrefslogtreecommitdiffstats
path: root/Include/cpython/pystate.h
diff options
context:
space:
mode:
authorEric Snow <ericsnowcurrently@gmail.com>2023-01-23 15:30:20 (GMT)
committerGitHub <noreply@github.com>2023-01-23 15:30:20 (GMT)
commit7b20a0f55a16b3e2d274cc478e4d04bd8a836a9f (patch)
treec2b341aca1b1298d230d44a76be1960a62d77cd6 /Include/cpython/pystate.h
parent984387f39a3385ed5699bd7e21797c348e543b19 (diff)
downloadcpython-7b20a0f55a16b3e2d274cc478e4d04bd8a836a9f.zip
cpython-7b20a0f55a16b3e2d274cc478e4d04bd8a836a9f.tar.gz
cpython-7b20a0f55a16b3e2d274cc478e4d04bd8a836a9f.tar.bz2
gh-59956: Allow the "Trashcan" Mechanism to Work Without a Thread State (gh-101209)
We've factored out a struct from the two PyThreadState fields. This accomplishes two things: * make it clear that the trashcan-related code doesn't need any other parts of PyThreadState * allows us to use the trashcan mechanism even when there isn't a "current" thread state We still expect the caller to hold the GIL. https://github.com/python/cpython/issues/59956
Diffstat (limited to 'Include/cpython/pystate.h')
-rw-r--r--Include/cpython/pystate.h8
1 files changed, 6 insertions, 2 deletions
diff --git a/Include/cpython/pystate.h b/Include/cpython/pystate.h
index 81944a5..3c1e70d 100644
--- a/Include/cpython/pystate.h
+++ b/Include/cpython/pystate.h
@@ -107,6 +107,11 @@ typedef struct _stack_chunk {
PyObject * data[1]; /* Variable sized */
} _PyStackChunk;
+struct _py_trashcan {
+ int delete_nesting;
+ PyObject *delete_later;
+};
+
struct _ts {
/* See Python/ceval.c for comments explaining most fields */
@@ -160,8 +165,7 @@ struct _ts {
*/
unsigned long native_thread_id;
- int trash_delete_nesting;
- PyObject *trash_delete_later;
+ struct _py_trashcan trash;
/* Called when a thread state is deleted normally, but not when it
* is destroyed after fork().