Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 1 addition & 5 deletions Include/cpython/coreconfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -382,9 +382,6 @@ typedef struct {
If set to -1 (default), inherit Py_FrozenFlag value. */
int _frozen;

/* If non-zero, use "main" Python initialization */
int _init_main;

} _PyCoreConfig;

#ifdef MS_WINDOWS
Expand Down Expand Up @@ -418,8 +415,7 @@ typedef struct {
.buffered_stdio = -1, \
._install_importlib = 1, \
.check_hash_pycs_mode = NULL, \
._frozen = -1, \
._init_main = 1}
._frozen = -1}
/* Note: _PyCoreConfig_INIT sets other fields to 0/NULL */

#ifdef __cplusplus
Expand Down
13 changes: 8 additions & 5 deletions Lib/test/test_embed.py
Original file line number Diff line number Diff line change
Expand Up @@ -348,7 +348,6 @@ class InitConfigTests(EmbeddingTestsMixin, unittest.TestCase):
'_install_importlib': 1,
'check_hash_pycs_mode': 'default',
'_frozen': 0,
'_init_main': 1,
}
if MS_WINDOWS:
DEFAULT_PRE_CONFIG.update({
Expand Down Expand Up @@ -443,7 +442,10 @@ def get_expected_config(self, expected, env):
raise Exception(f"failed to get the default config: "
f"stdout={proc.stdout!r} stderr={proc.stderr!r}")
stdout = proc.stdout.decode('utf-8')
config = json.loads(stdout)
try:
config = json.loads(stdout)
except json.JSONDecodeError:
self.fail(f"fail to decode stdout: {stdout!r}")

for key, value in expected.items():
if value is self.GET_DEFAULT_CONFIG:
Expand Down Expand Up @@ -496,7 +498,10 @@ def check_config(self, testname, expected_config, expected_preconfig):

out, err = self.run_embedded_interpreter(testname, env=env)
# Ignore err
config = json.loads(out)
try:
config = json.loads(out)
except json.JSONDecodeError:
self.fail(f"fail to decode stdout: {out!r}")

expected_preconfig = dict(self.DEFAULT_PRE_CONFIG, **expected_preconfig)
expected_config = self.get_expected_config(expected_config, env)
Expand Down Expand Up @@ -533,7 +538,6 @@ def test_init_global_config(self):
'filesystem_encoding': 'utf-8',
'filesystem_errors': self.UTF8_MODE_ERRORS,
'user_site_directory': 0,
'_frozen': 1,
}
self.check_config("init_global_config", config, preconfig)

Expand Down Expand Up @@ -578,7 +582,6 @@ def test_init_from_config(self):
'faulthandler': 1,

'check_hash_pycs_mode': 'always',
'_frozen': 1,
}
self.check_config("init_from_config", config, preconfig)

Expand Down
1 change: 0 additions & 1 deletion Programs/_freeze_importlib.c
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,6 @@ main(int argc, char *argv[])
/* Don't install importlib, since it could execute outdated bytecode. */
config._install_importlib = 0;
config._frozen = 1;
config._init_main = 0;

_PyInitError err = _Py_InitializeFromConfig(&config);
/* No need to call _PyCoreConfig_Clear() since we didn't allocate any
Expand Down
5 changes: 0 additions & 5 deletions Programs/_testembed.c
Original file line number Diff line number Diff line change
Expand Up @@ -354,8 +354,6 @@ static int test_init_global_config(void)
putenv("PYTHONUNBUFFERED=");
Py_UnbufferedStdioFlag = 1;

Py_FrozenFlag = 1;

/* FIXME: test Py_LegacyWindowsFSEncodingFlag */
/* FIXME: test Py_LegacyWindowsStdioFlag */

Expand Down Expand Up @@ -497,9 +495,6 @@ static int test_init_from_config(void)

config.check_hash_pycs_mode = L"always";

Py_FrozenFlag = 0;
config._frozen = 1;

err = _Py_InitializeFromConfig(&config);
if (_Py_INIT_FAILED(err)) {
_Py_ExitInitError(err);
Expand Down
2 changes: 0 additions & 2 deletions Python/coreconfig.c
Original file line number Diff line number Diff line change
Expand Up @@ -689,7 +689,6 @@ _PyCoreConfig_Copy(_PyCoreConfig *config, const _PyCoreConfig *config2)
COPY_WSTR_ATTR(run_filename);
COPY_WSTR_ATTR(check_hash_pycs_mode);
COPY_ATTR(_frozen);
COPY_ATTR(_init_main);

#undef COPY_ATTR
#undef COPY_STR_ATTR
Expand Down Expand Up @@ -795,7 +794,6 @@ _PyCoreConfig_AsDict(const _PyCoreConfig *config)
SET_ITEM_INT(_install_importlib);
SET_ITEM_WSTR(check_hash_pycs_mode);
SET_ITEM_INT(_frozen);
SET_ITEM_INT(_init_main);

return dict;

Expand Down
2 changes: 1 addition & 1 deletion Python/pylifecycle.c
Original file line number Diff line number Diff line change
Expand Up @@ -990,7 +990,7 @@ init_python(const _PyCoreConfig *config, const _PyArgv *args)
}
config = &interp->core_config;

if (config->_init_main) {
if (!config->_frozen) {
err = _Py_InitializeMainInterpreter(runtime, interp);
if (_Py_INIT_FAILED(err)) {
return err;
Expand Down