[Python-checkins] [3.12] gh-98608: Move PyInterpreterConfig to pylifecycle.h (GH-107191) (#107198)

vstinner webhook-mailer at python.org
Mon Jul 24 16:13:11 EDT 2023


https://github.com/python/cpython/commit/5bf7165e591f2e7502672cc591cea480a5b91a8f
commit: 5bf7165e591f2e7502672cc591cea480a5b91a8f
branch: 3.12
author: Miss Islington (bot) <31488909+miss-islington at users.noreply.github.com>
committer: vstinner <vstinner at python.org>
date: 2023-07-24T20:13:07Z
summary:

[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 e717b47ed8ae7017f0bfb835fe673aa836e8fcca)

Co-authored-by: Victor Stinner <vstinner at python.org>

files:
M Include/cpython/initconfig.h
M Include/cpython/pylifecycle.h

diff --git a/Include/cpython/initconfig.h b/Include/cpython/initconfig.h
index c103c2026e40e..cbae97f12f537 100644
--- a/Include/cpython/initconfig.h
+++ b/Include/cpython/initconfig.h
@@ -242,45 +242,6 @@ PyAPI_FUNC(PyStatus) PyConfig_SetWideStringList(PyConfig *config,
     Py_ssize_t length, wchar_t **items);
 
 
-/* --- PyInterpreterConfig ------------------------------------ */
-
-#define PyInterpreterConfig_DEFAULT_GIL (0)
-#define PyInterpreterConfig_SHARED_GIL (1)
-#define PyInterpreterConfig_OWN_GIL (2)
-
-typedef struct {
-    // XXX "allow_object_sharing"?  "own_objects"?
-    int use_main_obmalloc;
-    int allow_fork;
-    int allow_exec;
-    int allow_threads;
-    int allow_daemon_threads;
-    int check_multi_interp_extensions;
-    int gil;
-} PyInterpreterConfig;
-
-#define _PyInterpreterConfig_INIT \
-    { \
-        .use_main_obmalloc = 0, \
-        .allow_fork = 0, \
-        .allow_exec = 0, \
-        .allow_threads = 1, \
-        .allow_daemon_threads = 0, \
-        .check_multi_interp_extensions = 1, \
-        .gil = PyInterpreterConfig_OWN_GIL, \
-    }
-
-#define _PyInterpreterConfig_LEGACY_INIT \
-    { \
-        .use_main_obmalloc = 1, \
-        .allow_fork = 1, \
-        .allow_exec = 1, \
-        .allow_threads = 1, \
-        .allow_daemon_threads = 1, \
-        .check_multi_interp_extensions = 0, \
-        .gil = PyInterpreterConfig_SHARED_GIL, \
-    }
-
 /* --- Helper functions --------------------------------------- */
 
 /* Get the original command line arguments, before Python modified them.
diff --git a/Include/cpython/pylifecycle.h b/Include/cpython/pylifecycle.h
index 314a5cc5b942a..4daea33bf8011 100644
--- a/Include/cpython/pylifecycle.h
+++ b/Include/cpython/pylifecycle.h
@@ -63,6 +63,45 @@ PyAPI_FUNC(int) _Py_CoerceLegacyLocale(int warn);
 PyAPI_FUNC(int) _Py_LegacyLocaleDetected(int warn);
 PyAPI_FUNC(char *) _Py_SetLocaleFromEnv(int category);
 
+/* --- PyInterpreterConfig ------------------------------------ */
+
+#define PyInterpreterConfig_DEFAULT_GIL (0)
+#define PyInterpreterConfig_SHARED_GIL (1)
+#define PyInterpreterConfig_OWN_GIL (2)
+
+typedef struct {
+    // XXX "allow_object_sharing"?  "own_objects"?
+    int use_main_obmalloc;
+    int allow_fork;
+    int allow_exec;
+    int allow_threads;
+    int allow_daemon_threads;
+    int check_multi_interp_extensions;
+    int gil;
+} PyInterpreterConfig;
+
+#define _PyInterpreterConfig_INIT \
+    { \
+        .use_main_obmalloc = 0, \
+        .allow_fork = 0, \
+        .allow_exec = 0, \
+        .allow_threads = 1, \
+        .allow_daemon_threads = 0, \
+        .check_multi_interp_extensions = 1, \
+        .gil = PyInterpreterConfig_OWN_GIL, \
+    }
+
+#define _PyInterpreterConfig_LEGACY_INIT \
+    { \
+        .use_main_obmalloc = 1, \
+        .allow_fork = 1, \
+        .allow_exec = 1, \
+        .allow_threads = 1, \
+        .allow_daemon_threads = 1, \
+        .check_multi_interp_extensions = 0, \
+        .gil = PyInterpreterConfig_SHARED_GIL, \
+    }
+
 PyAPI_FUNC(PyStatus) Py_NewInterpreterFromConfig(
     PyThreadState **tstate_p,
     const PyInterpreterConfig *config);



More information about the Python-checkins mailing list