summaryrefslogtreecommitdiffstats
path: root/Include
diff options
context:
space:
mode:
authorVictor Stinner <vstinner@redhat.com>2019-05-22 21:58:50 (GMT)
committerGitHub <noreply@github.com>2019-05-22 21:58:50 (GMT)
commit022be02dcfdfd9011415804bb4553a33fa7ec8f3 (patch)
tree6c4f3b4afed8475e6504786cb176044eade9ef02 /Include
parente4d300e07c33a9a77549c62d8687d8fe130c53d5 (diff)
downloadcpython-022be02dcfdfd9011415804bb4553a33fa7ec8f3.zip
cpython-022be02dcfdfd9011415804bb4553a33fa7ec8f3.tar.gz
cpython-022be02dcfdfd9011415804bb4553a33fa7ec8f3.tar.bz2
bpo-36763: Add _PyPreConfig._config_init (GH-13481)
* _PyPreConfig_GetGlobalConfig() and _PyCoreConfig_GetGlobalConfig() now do nothing if the configuration was not initialized with _PyPreConfig_InitCompatConfig() and _PyCoreConfig_InitCompatConfig() * Remove utf8_mode=-2 special case: use utf8_mode=-1 instead. * Fix _PyPreConfig_InitPythonConfig(): * isolated = 0 instead of -1 * use_environment = 1 instead of -1 * Rename _PyConfig_INIT to _PyConfig_INIT_COMPAT * Rename _PyPreConfig_Init() to _PyPreConfig_InitCompatConfig() * Rename _PyCoreConfig_Init() to _PyCoreConfig_InitCompatConfig() * PyInterpreterState_New() now uses _PyCoreConfig_InitPythonConfig() as default configuration, but it's very quickly overriden anyway. * _freeze_importlib.c uses _PyCoreConfig_SetString() to set program_name. * Cleanup preconfig_init_utf8_mode(): cmdline is always non-NULL.
Diffstat (limited to 'Include')
-rw-r--r--Include/cpython/coreconfig.h22
-rw-r--r--Include/internal/pycore_coreconfig.h4
2 files changed, 13 insertions, 13 deletions
diff --git a/Include/cpython/coreconfig.h b/Include/cpython/coreconfig.h
index decfb70..ef5fde2 100644
--- a/Include/cpython/coreconfig.h
+++ b/Include/cpython/coreconfig.h
@@ -40,9 +40,18 @@ typedef struct {
#define _Py_CONFIG_VERSION 1
+typedef enum {
+ /* Py_Initialize() API: backward compatibility with Python 3.6 and 3.7 */
+ _PyConfig_INIT_COMPAT = 1,
+ _PyConfig_INIT_PYTHON = 2,
+ _PyConfig_INIT_ISOLATED = 3
+} _PyConfigInitEnum;
+
+
typedef struct {
int _config_version; /* Internal configuration version,
used for ABI compatibility */
+ int _config_init; /* _PyConfigInitEnum value */
/* Parse _Py_PreInitializeFromArgs() arguments?
See _PyCoreConfig.parse_argv */
@@ -107,10 +116,7 @@ typedef struct {
Set to 0 by "-X utf8=0" and PYTHONUTF8=0.
If equals to -1, it is set to 1 if the LC_CTYPE locale is "C" or
- "POSIX", otherwise it is set to 0.
-
- If equals to -2, inherit Py_UTF8Mode value value (which is equal to 0
- by default). */
+ "POSIX", otherwise it is set to 0. Inherit Py_UTF8Mode value value. */
int utf8_mode;
int dev_mode; /* Development mode. PYTHONDEVMODE, -X dev */
@@ -126,16 +132,10 @@ PyAPI_FUNC(void) _PyPreConfig_InitIsolatedConfig(_PyPreConfig *config);
/* --- _PyCoreConfig ---------------------------------------------- */
-typedef enum {
- _PyCoreConfig_INIT = 0,
- _PyCoreConfig_INIT_PYTHON = 1,
- _PyCoreConfig_INIT_ISOLATED = 2
-} _PyCoreConfigInitEnum;
-
typedef struct {
int _config_version; /* Internal configuration version,
used for ABI compatibility */
- int _config_init; /* _PyCoreConfigInitEnum value */
+ int _config_init; /* _PyConfigInitEnum value */
int isolated; /* Isolated mode? see _PyPreConfig.isolated */
int use_environment; /* Use environment variables? see _PyPreConfig.use_environment */
diff --git a/Include/internal/pycore_coreconfig.h b/Include/internal/pycore_coreconfig.h
index 324e0b8..b17737a 100644
--- a/Include/internal/pycore_coreconfig.h
+++ b/Include/internal/pycore_coreconfig.h
@@ -120,7 +120,7 @@ PyAPI_FUNC(_PyInitError) _PyPreCmdline_Read(_PyPreCmdline *cmdline,
/* --- _PyPreConfig ----------------------------------------------- */
-PyAPI_FUNC(void) _PyPreConfig_Init(_PyPreConfig *config);
+PyAPI_FUNC(void) _PyPreConfig_InitCompatConfig(_PyPreConfig *config);
PyAPI_FUNC(void) _PyPreConfig_InitFromCoreConfig(
_PyPreConfig *config,
const _PyCoreConfig *coreconfig);
@@ -139,7 +139,7 @@ PyAPI_FUNC(_PyInitError) _PyPreConfig_Write(const _PyPreConfig *config);
/* --- _PyCoreConfig ---------------------------------------------- */
-PyAPI_FUNC(void) _PyCoreConfig_Init(_PyCoreConfig *config);
+PyAPI_FUNC(void) _PyCoreConfig_InitCompatConfig(_PyCoreConfig *config);
PyAPI_FUNC(_PyInitError) _PyCoreConfig_Copy(
_PyCoreConfig *config,
const _PyCoreConfig *config2);