Skip to content

Commit bc02eac

Browse files
bpo-46370: Move the static initializer for _PyRuntime to its own header file. (gh-30587)
https://bugs.python.org/issue46370
1 parent 276c234 commit bc02eac

File tree

9 files changed

+611
-583
lines changed

9 files changed

+611
-583
lines changed

Include/internal/pycore_global_objects.h

Lines changed: 1 addition & 568 deletions
Large diffs are not rendered by default.

Include/internal/pycore_object.h

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,19 @@ extern "C" {
1212
#include "pycore_interp.h" // PyInterpreterState.gc
1313
#include "pycore_pystate.h" // _PyInterpreterState_GET()
1414

15+
16+
#define _PyObject_IMMORTAL_INIT(type) \
17+
{ \
18+
.ob_refcnt = 999999999, \
19+
.ob_type = type, \
20+
}
21+
#define _PyVarObject_IMMORTAL_INIT(type, size) \
22+
{ \
23+
.ob_base = _PyObject_IMMORTAL_INIT(type), \
24+
.ob_size = size, \
25+
}
26+
27+
1528
PyAPI_FUNC(int) _PyType_CheckConsistency(PyTypeObject *type);
1629
PyAPI_FUNC(int) _PyDict_CheckConsistency(PyObject *mp, int check_content);
1730

Include/internal/pycore_runtime.h

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -148,21 +148,6 @@ typedef struct pyruntimestate {
148148
PyInterpreterState _main_interpreter;
149149
} _PyRuntimeState;
150150

151-
#define _PyThreadState_INIT \
152-
{ \
153-
._static = 1, \
154-
}
155-
#define _PyInterpreterState_INIT \
156-
{ \
157-
._static = 1, \
158-
._initial_thread = _PyThreadState_INIT, \
159-
}
160-
#define _PyRuntimeState_INIT \
161-
{ \
162-
.global_objects = _Py_global_objects_INIT, \
163-
._main_interpreter = _PyInterpreterState_INIT, \
164-
}
165-
166151

167152
/* other API */
168153

0 commit comments

Comments
 (0)