Skip to content

Commit 5bf7165

Browse files
[3.12] gh-98608: Move PyInterpreterConfig to pylifecycle.h (GH-107191) (#107198)
gh-98608: Move PyInterpreterConfig to pylifecycle.h (GH-107191) Move PyInterpreterConfig structure and associated macros from initconfig.h to pylifecycle.h: it's not related to the Python Initialization Configuration. (cherry picked from commit e717b47) Co-authored-by: Victor Stinner <[email protected]>
1 parent f573a6a commit 5bf7165

File tree

2 files changed

+39
-39
lines changed

2 files changed

+39
-39
lines changed

Include/cpython/initconfig.h

-39
Original file line numberDiff line numberDiff line change
@@ -242,45 +242,6 @@ PyAPI_FUNC(PyStatus) PyConfig_SetWideStringList(PyConfig *config,
242242
Py_ssize_t length, wchar_t **items);
243243

244244

245-
/* --- PyInterpreterConfig ------------------------------------ */
246-
247-
#define PyInterpreterConfig_DEFAULT_GIL (0)
248-
#define PyInterpreterConfig_SHARED_GIL (1)
249-
#define PyInterpreterConfig_OWN_GIL (2)
250-
251-
typedef struct {
252-
// XXX "allow_object_sharing"? "own_objects"?
253-
int use_main_obmalloc;
254-
int allow_fork;
255-
int allow_exec;
256-
int allow_threads;
257-
int allow_daemon_threads;
258-
int check_multi_interp_extensions;
259-
int gil;
260-
} PyInterpreterConfig;
261-
262-
#define _PyInterpreterConfig_INIT \
263-
{ \
264-
.use_main_obmalloc = 0, \
265-
.allow_fork = 0, \
266-
.allow_exec = 0, \
267-
.allow_threads = 1, \
268-
.allow_daemon_threads = 0, \
269-
.check_multi_interp_extensions = 1, \
270-
.gil = PyInterpreterConfig_OWN_GIL, \
271-
}
272-
273-
#define _PyInterpreterConfig_LEGACY_INIT \
274-
{ \
275-
.use_main_obmalloc = 1, \
276-
.allow_fork = 1, \
277-
.allow_exec = 1, \
278-
.allow_threads = 1, \
279-
.allow_daemon_threads = 1, \
280-
.check_multi_interp_extensions = 0, \
281-
.gil = PyInterpreterConfig_SHARED_GIL, \
282-
}
283-
284245
/* --- Helper functions --------------------------------------- */
285246

286247
/* Get the original command line arguments, before Python modified them.

Include/cpython/pylifecycle.h

+39
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,45 @@ PyAPI_FUNC(int) _Py_CoerceLegacyLocale(int warn);
6363
PyAPI_FUNC(int) _Py_LegacyLocaleDetected(int warn);
6464
PyAPI_FUNC(char *) _Py_SetLocaleFromEnv(int category);
6565

66+
/* --- PyInterpreterConfig ------------------------------------ */
67+
68+
#define PyInterpreterConfig_DEFAULT_GIL (0)
69+
#define PyInterpreterConfig_SHARED_GIL (1)
70+
#define PyInterpreterConfig_OWN_GIL (2)
71+
72+
typedef struct {
73+
// XXX "allow_object_sharing"? "own_objects"?
74+
int use_main_obmalloc;
75+
int allow_fork;
76+
int allow_exec;
77+
int allow_threads;
78+
int allow_daemon_threads;
79+
int check_multi_interp_extensions;
80+
int gil;
81+
} PyInterpreterConfig;
82+
83+
#define _PyInterpreterConfig_INIT \
84+
{ \
85+
.use_main_obmalloc = 0, \
86+
.allow_fork = 0, \
87+
.allow_exec = 0, \
88+
.allow_threads = 1, \
89+
.allow_daemon_threads = 0, \
90+
.check_multi_interp_extensions = 1, \
91+
.gil = PyInterpreterConfig_OWN_GIL, \
92+
}
93+
94+
#define _PyInterpreterConfig_LEGACY_INIT \
95+
{ \
96+
.use_main_obmalloc = 1, \
97+
.allow_fork = 1, \
98+
.allow_exec = 1, \
99+
.allow_threads = 1, \
100+
.allow_daemon_threads = 1, \
101+
.check_multi_interp_extensions = 0, \
102+
.gil = PyInterpreterConfig_SHARED_GIL, \
103+
}
104+
66105
PyAPI_FUNC(PyStatus) Py_NewInterpreterFromConfig(
67106
PyThreadState **tstate_p,
68107
const PyInterpreterConfig *config);

0 commit comments

Comments
 (0)