Modify frozenmain.c to use _Py_InitializeFromConfig().
See PEP 552 "Deterministic pycs" for more details. */
const char *_check_hash_pycs_mode;
+
+ /* If greater than 0, suppress _PyPathConfig_Calculate() warnings.
+
+ If set to -1 (default), inherit Py_FrozenFlag value. */
+ int _frozen;
+
} _PyCoreConfig;
#ifdef MS_WINDOWS
.user_site_directory = -1, \
.unbuffered_stdio = -1, \
_PyCoreConfig_WINDOWS_INIT \
- ._install_importlib = 1}
+ ._install_importlib = 1, \
+ ._frozen = -1}
/* Note: _PyCoreConfig_INIT sets other fields to 0/NULL */
/* Placeholders while working on the new configuration API
'_install_importlib': 1,
'_check_hash_pycs_mode': 'default',
+ '_frozen': 0,
}
def check_config(self, testname, expected):
'unbuffered_stdio': 1,
'utf8_mode': 1,
'user_site_directory': 0,
+ '_frozen': 1,
}
self.check_config("init_global_config", config)
'unbuffered_stdio': 1,
'user_site_directory': 0,
'faulthandler': 1,
+
'_check_hash_pycs_mode': 'always',
+ '_frozen': 1,
}
self.check_config("init_from_config", config)
{
calculate->prefix_found = search_for_prefix(core_config, calculate, prefix);
if (!calculate->prefix_found) {
- if (!Py_FrozenFlag) {
+ if (!core_config->_frozen) {
fprintf(stderr,
"Could not find platform independent libraries <prefix>\n");
}
calculate,
exec_prefix);
if (!calculate->exec_prefix_found) {
- if (!Py_FrozenFlag) {
+ if (!core_config->_frozen) {
fprintf(stderr,
"Could not find platform dependent libraries <exec_prefix>\n");
}
calculate_exec_prefix(core_config, calculate, exec_prefix);
if ((!calculate->prefix_found || !calculate->exec_prefix_found) &&
- !Py_FrozenFlag)
+ !core_config->_frozen)
{
fprintf(stderr,
"Consider setting $PYTHONHOME to <prefix>[:<exec_prefix>]\n");
COPY_FLAG(legacy_windows_fs_encoding, Py_LegacyWindowsFSEncodingFlag);
COPY_FLAG(legacy_windows_stdio, Py_LegacyWindowsStdioFlag);
#endif
+ COPY_FLAG(_frozen, Py_FrozenFlag);
COPY_NOT_FLAG(use_environment, Py_IgnoreEnvironmentFlag);
COPY_NOT_FLAG(site_import, Py_NoSiteFlag);
COPY_ATTR(legacy_windows_stdio);
#endif
COPY_ATTR(_check_hash_pycs_mode);
+ COPY_ATTR(_frozen);
#undef COPY_ATTR
#undef COPY_STR_ATTR
if (config->utf8_mode < 0) {
config->utf8_mode = 0;
}
+ if (config->_frozen < 0) {
+ config->_frozen = 0;
+ }
return _Py_INIT_OK();
}
/* Don't install importlib, since it could execute outdated bytecode. */
config._install_importlib = 0;
config.install_signal_handlers = 1;
-
- Py_FrozenFlag++;
+ config._frozen = 1;
_PyInitError err = _Py_InitializeFromConfig(&config);
/* No need to call _PyCoreConfig_Clear() since we didn't allocate any
printf("_install_importlib = %i\n", config->_install_importlib);
printf("_check_hash_pycs_mode = %s\n", config->_check_hash_pycs_mode);
+ printf("_frozen = %i\n", config->_frozen);
#undef ASSERT_EQUAL
#undef ASSERT_STR_EQUAL
putenv("PYTHONUNBUFFERED=");
Py_UnbufferedStdioFlag = 1;
+ Py_FrozenFlag = 1;
+
/* FIXME: test Py_LegacyWindowsFSEncodingFlag */
/* FIXME: test Py_LegacyWindowsStdioFlag */
config._check_hash_pycs_mode = "always";
+ Py_FrozenFlag = 0;
+ config._frozen = 1;
+
_PyInitError err = _Py_InitializeFromConfig(&config);
/* Don't call _PyCoreConfig_Clear() since all strings are static */
if (_Py_INIT_FAILED(err)) {
}
}
- Py_FrozenFlag = 1; /* Suppress errors from getpath.c */
+ _PyCoreConfig config = _PyCoreConfig_INIT;
+ config._frozen = 1; /* Suppress errors from getpath.c */
if ((p = Py_GETENV("PYTHONINSPECT")) && *p != '\0')
inspect = 1;
#endif /* MS_WINDOWS */
if (argc >= 1)
Py_SetProgramName(argv_copy[0]);
- Py_Initialize();
+
+ err = _Py_InitializeFromConfig(&config);
+ /* No need to call _PyCoreConfig_Clear() since we didn't allocate any
+ memory: program_name is a constant string. */
+ if (_Py_INIT_FAILED(err)) {
+ _Py_FatalInitError(err);
+ }
+
#ifdef MS_WINDOWS
PyWinFreeze_ExeInit();
#endif