mirror of
https://github.com/python/cpython.git
synced 2025-12-23 09:19:18 +00:00
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.
This commit is contained in:
parent
e4d300e07c
commit
022be02dcf
11 changed files with 200 additions and 108 deletions
|
|
@ -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 */
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue