summaryrefslogtreecommitdiffstats
path: root/Include
diff options
context:
space:
mode:
authorVictor Stinner <vstinner@redhat.com>2019-03-27 12:40:14 (GMT)
committerGitHub <noreply@github.com>2019-03-27 12:40:14 (GMT)
commit5ac27a50ff2b42216746fedc0522a92c53089bb3 (patch)
tree5fbf53a0b5e47f6704f01397de3e01799bf87d41 /Include
parent364f0b0f19cc3f0d5e63f571ec9163cf41c62958 (diff)
downloadcpython-5ac27a50ff2b42216746fedc0522a92c53089bb3.zip
cpython-5ac27a50ff2b42216746fedc0522a92c53089bb3.tar.gz
cpython-5ac27a50ff2b42216746fedc0522a92c53089bb3.tar.bz2
bpo-36444: Rework _Py_InitializeFromConfig() API (GH-12576)
Diffstat (limited to 'Include')
-rw-r--r--Include/cpython/coreconfig.h10
-rw-r--r--Include/cpython/pylifecycle.h28
-rw-r--r--Include/internal/pycore_coreconfig.h76
-rw-r--r--Include/internal/pycore_pylifecycle.h4
4 files changed, 62 insertions, 56 deletions
diff --git a/Include/cpython/coreconfig.h b/Include/cpython/coreconfig.h
index 53493ff..27ee1f4 100644
--- a/Include/cpython/coreconfig.h
+++ b/Include/cpython/coreconfig.h
@@ -5,16 +5,6 @@
extern "C" {
#endif
-/* --- _PyArgv ---------------------------------------------------- */
-
-typedef struct {
- int argc;
- int use_bytes_argv;
- char **bytes_argv;
- wchar_t **wchar_argv;
-} _PyArgv;
-
-
/* --- _PyInitError ----------------------------------------------- */
typedef struct {
diff --git a/Include/cpython/pylifecycle.h b/Include/cpython/pylifecycle.h
index 496dcb2..e293b04 100644
--- a/Include/cpython/pylifecycle.h
+++ b/Include/cpython/pylifecycle.h
@@ -14,23 +14,33 @@ PyAPI_FUNC(int) Py_SetStandardStreamEncoding(const char *encoding,
/* PEP 432 Multi-phase initialization API (Private while provisional!) */
-PyAPI_FUNC(_PyInitError) _Py_PreInitialize(void);
-PyAPI_FUNC(_PyInitError) _Py_PreInitializeFromPreConfig(
- const _PyPreConfig *preconfig);
-PyAPI_FUNC(_PyInitError) _Py_PreInitializeFromConfig(
- const _PyCoreConfig *coreconfig);
+PyAPI_FUNC(_PyInitError) _Py_PreInitialize(
+ const _PyPreConfig *src_config);
+PyAPI_FUNC(_PyInitError) _Py_PreInitializeFromArgs(
+ const _PyPreConfig *src_config,
+ int argc,
+ char **argv);
+PyAPI_FUNC(_PyInitError) _Py_PreInitializeFromWideArgs(
+ const _PyPreConfig *src_config,
+ int argc,
+ wchar_t **argv);
PyAPI_FUNC(int) _Py_IsCoreInitialized(void);
-PyAPI_FUNC(_PyInitError) _Py_InitializeMainInterpreter(
- PyInterpreterState *interp);
-
/* Initialization and finalization */
PyAPI_FUNC(_PyInitError) _Py_InitializeFromConfig(
+ const _PyCoreConfig *config);
+PyAPI_FUNC(_PyInitError) _Py_InitializeFromArgs(
+ const _PyCoreConfig *config,
+ int argc,
+ char **argv);
+PyAPI_FUNC(_PyInitError) _Py_InitializeFromWideArgs(
const _PyCoreConfig *config,
- PyInterpreterState **interp_p);
+ int argc,
+ wchar_t **argv);
+
PyAPI_FUNC(void) _Py_NO_RETURN _Py_ExitInitError(_PyInitError err);
/* Py_PyAtExit is for the atexit module, Py_AtExit is for low-level
diff --git a/Include/internal/pycore_coreconfig.h b/Include/internal/pycore_coreconfig.h
index c5f39ba..3a27628 100644
--- a/Include/internal/pycore_coreconfig.h
+++ b/Include/internal/pycore_coreconfig.h
@@ -9,34 +9,6 @@ extern "C" {
#endif
-/* --- _PyPreCmdline ------------------------------------------------- */
-
-typedef struct {
- _PyWstrList argv;
- _PyWstrList xoptions; /* "-X value" option */
- int isolated; /* -I option */
- int use_environment; /* -E option */
- int dev_mode; /* -X dev and PYTHONDEVMODE */
-} _PyPreCmdline;
-
-#define _PyPreCmdline_INIT \
- (_PyPreCmdline){ \
- .use_environment = -1, \
- .isolated = -1, \
- .dev_mode = -1}
-/* Note: _PyPreCmdline_INIT sets other fields to 0/NULL */
-
-PyAPI_FUNC(void) _PyPreCmdline_Clear(_PyPreCmdline *cmdline);
-PyAPI_FUNC(_PyInitError) _PyPreCmdline_SetArgv(_PyPreCmdline *cmdline,
- const _PyArgv *args);
-PyAPI_FUNC(int) _PyPreCmdline_SetCoreConfig(
- const _PyPreCmdline *cmdline,
- _PyCoreConfig *config);
-PyAPI_FUNC(_PyInitError) _PyPreCmdline_Read(_PyPreCmdline *cmdline,
- const _PyPreConfig *preconfig,
- const _PyCoreConfig *coreconfig);
-
-
/* --- _PyWstrList ------------------------------------------------ */
#ifndef NDEBUG
@@ -54,15 +26,17 @@ PyAPI_FUNC(int) _PyWstrList_Extend(_PyWstrList *list,
/* --- _PyArgv ---------------------------------------------------- */
+typedef struct {
+ int argc;
+ int use_bytes_argv;
+ char **bytes_argv;
+ wchar_t **wchar_argv;
+} _PyArgv;
+
PyAPI_FUNC(_PyInitError) _PyArgv_AsWstrList(const _PyArgv *args,
_PyWstrList *list);
-/* --- Py_GetArgcArgv() helpers ----------------------------------- */
-
-PyAPI_FUNC(void) _Py_ClearArgcArgv(void);
-
-
/* --- Helper functions ------------------------------------------- */
PyAPI_FUNC(int) _Py_str_to_int(
@@ -79,15 +53,47 @@ PyAPI_FUNC(void) _Py_get_env_flag(
int *flag,
const char *name);
+/* Py_GetArgcArgv() helper */
+PyAPI_FUNC(void) _Py_ClearArgcArgv(void);
+
+
+/* --- _PyPreCmdline ------------------------------------------------- */
+
+typedef struct {
+ _PyWstrList argv;
+ _PyWstrList xoptions; /* "-X value" option */
+ int isolated; /* -I option */
+ int use_environment; /* -E option */
+ int dev_mode; /* -X dev and PYTHONDEVMODE */
+} _PyPreCmdline;
+
+#define _PyPreCmdline_INIT \
+ (_PyPreCmdline){ \
+ .use_environment = -1, \
+ .isolated = -1, \
+ .dev_mode = -1}
+/* Note: _PyPreCmdline_INIT sets other fields to 0/NULL */
+
+PyAPI_FUNC(void) _PyPreCmdline_Clear(_PyPreCmdline *cmdline);
+PyAPI_FUNC(_PyInitError) _PyPreCmdline_SetArgv(_PyPreCmdline *cmdline,
+ const _PyArgv *args);
+PyAPI_FUNC(int) _PyPreCmdline_SetCoreConfig(
+ const _PyPreCmdline *cmdline,
+ _PyCoreConfig *config);
+PyAPI_FUNC(_PyInitError) _PyPreCmdline_Read(_PyPreCmdline *cmdline,
+ const _PyPreConfig *preconfig);
+
+
/* --- _PyPreConfig ----------------------------------------------- */
PyAPI_FUNC(void) _PyPreConfig_Clear(_PyPreConfig *config);
PyAPI_FUNC(int) _PyPreConfig_Copy(_PyPreConfig *config,
const _PyPreConfig *config2);
PyAPI_FUNC(PyObject*) _PyPreConfig_AsDict(const _PyPreConfig *config);
+PyAPI_FUNC(void) _PyCoreConfig_GetCoreConfig(_PyPreConfig *config,
+ const _PyCoreConfig *core_config);
PyAPI_FUNC(_PyInitError) _PyPreConfig_Read(_PyPreConfig *config,
- const _PyArgv *args,
- const _PyCoreConfig *coreconfig);
+ const _PyArgv *args);
PyAPI_FUNC(_PyInitError) _PyPreConfig_Write(_PyPreConfig *config);
diff --git a/Include/internal/pycore_pylifecycle.h b/Include/internal/pycore_pylifecycle.h
index 3214d6b..d837ea4 100644
--- a/Include/internal/pycore_pylifecycle.h
+++ b/Include/internal/pycore_pylifecycle.h
@@ -77,8 +77,8 @@ extern void _PyGILState_Fini(void);
PyAPI_FUNC(void) _PyGC_DumpShutdownStats(void);
-PyAPI_FUNC(_PyInitError) _Py_PreInitializeInPlace(
- _PyPreConfig *config);
+PyAPI_FUNC(_PyInitError) _Py_PreInitializeFromCoreConfig(
+ const _PyCoreConfig *coreconfig);
#ifdef __cplusplus
}