Skip to content

Commit 73d60ca

Browse files
remove _static field
1 parent 8fe1a88 commit 73d60ca

File tree

4 files changed

+6
-16
lines changed

4 files changed

+6
-16
lines changed

Include/cpython/pystate.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -120,9 +120,6 @@ struct _ts {
120120
after allocation. */
121121
int _initialized;
122122

123-
/* Was this thread state statically allocated? */
124-
int _static;
125-
126123
int py_recursion_remaining;
127124
int py_recursion_limit;
128125

Include/internal/pycore_interp.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -115,9 +115,6 @@ struct _is {
115115
int _initialized;
116116
int finalizing;
117117

118-
/* Was this interpreter statically allocated? */
119-
bool _static;
120-
121118
struct _ceval_state ceval;
122119
struct _gc_runtime_state gc;
123120

Include/internal/pycore_runtime_init.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,6 @@ extern "C" {
4747

4848
#define _PyInterpreterState_INIT \
4949
{ \
50-
._static = 1, \
5150
.id_refcount = -1, \
5251
DLOPENFLAGS_INIT \
5352
.ceval = { \
@@ -67,7 +66,6 @@ extern "C" {
6766

6867
#define _PyThreadState_INIT \
6968
{ \
70-
._static = 1, \
7169
.py_recursion_limit = Py_DEFAULT_RECURSION_LIMIT, \
7270
.context_ver = 1, \
7371
}

Python/pystate.c

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -272,7 +272,9 @@ alloc_interpreter(void)
272272
static void
273273
free_interpreter(PyInterpreterState *interp)
274274
{
275-
if (!interp->_static) {
275+
// The main interpreter is statically allocated so
276+
// should not be freed.
277+
if (interp != &_PyRuntime._main_interpreter) {
276278
PyMem_RawFree(interp);
277279
}
278280
}
@@ -356,7 +358,6 @@ PyInterpreterState_New(void)
356358
interp = &runtime->_main_interpreter;
357359
assert(interp->id == 0);
358360
assert(interp->next == NULL);
359-
assert(interp->_static);
360361

361362
interpreters->main = interp;
362363
}
@@ -371,9 +372,6 @@ PyInterpreterState_New(void)
371372
// Set to _PyInterpreterState_INIT.
372373
memcpy(interp, &initial._main_interpreter,
373374
sizeof(*interp));
374-
// We need to adjust any fields that are different from the initial
375-
// interpreter (as defined in _PyInterpreterState_INIT):
376-
interp->_static = false;
377375

378376
if (id < 0) {
379377
/* overflow or Py_Initialize() not called yet! */
@@ -759,7 +757,9 @@ alloc_threadstate(void)
759757
static void
760758
free_threadstate(PyThreadState *tstate)
761759
{
762-
if (!tstate->_static) {
760+
// The main thread of the interpreter is allocated
761+
// as part of the interpreter state so should not be freed.
762+
if (tstate != &tstate->interp->_initial_thread) {
763763
PyMem_RawFree(tstate);
764764
}
765765
}
@@ -842,7 +842,6 @@ new_threadstate(PyInterpreterState *interp)
842842
assert(id == 1);
843843
used_newtstate = 0;
844844
tstate = &interp->_initial_thread;
845-
assert(tstate->_static);
846845
}
847846
else {
848847
// Every valid interpreter must have at least one thread.
@@ -856,7 +855,6 @@ new_threadstate(PyInterpreterState *interp)
856855
sizeof(*tstate));
857856
// We need to adjust any fields that are different from the initial
858857
// thread (as defined in _PyThreadState_INIT):
859-
tstate->_static = false;
860858
}
861859
interp->threads.head = tstate;
862860

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy