mirror of
https://github.com/python/cpython.git
synced 2025-11-25 04:34:37 +00:00
gh-77782: Deprecate global configuration variable (#93943)
Deprecate global configuration variable like Py_IgnoreEnvironmentFlag: the Py_InitializeFromConfig() API should be instead. Fix declaration of Py_GETENV(): use PyAPI_FUNC(), not PyAPI_DATA().
This commit is contained in:
parent
f64557f480
commit
0ff626f210
8 changed files with 96 additions and 28 deletions
|
|
@ -479,12 +479,23 @@ error:
|
|||
}
|
||||
|
||||
|
||||
static void
|
||||
pymain_set_inspect(PyConfig *config, int inspect)
|
||||
{
|
||||
config->inspect = inspect;
|
||||
_Py_COMP_DIAG_PUSH
|
||||
_Py_COMP_DIAG_IGNORE_DEPR_DECLS
|
||||
Py_InspectFlag = inspect;
|
||||
_Py_COMP_DIAG_POP
|
||||
}
|
||||
|
||||
|
||||
static int
|
||||
pymain_run_stdin(PyConfig *config)
|
||||
{
|
||||
if (stdin_is_interactive(config)) {
|
||||
config->inspect = 0;
|
||||
Py_InspectFlag = 0; /* do exit on SystemExit */
|
||||
// do exit on SystemExit
|
||||
pymain_set_inspect(config, 0);
|
||||
|
||||
int exitcode;
|
||||
if (pymain_run_startup(config, &exitcode)) {
|
||||
|
|
@ -517,16 +528,14 @@ pymain_repl(PyConfig *config, int *exitcode)
|
|||
/* Check this environment variable at the end, to give programs the
|
||||
opportunity to set it from Python. */
|
||||
if (!config->inspect && _Py_GetEnv(config->use_environment, "PYTHONINSPECT")) {
|
||||
config->inspect = 1;
|
||||
Py_InspectFlag = 1;
|
||||
pymain_set_inspect(config, 1);
|
||||
}
|
||||
|
||||
if (!(config->inspect && stdin_is_interactive(config) && config_run_code(config))) {
|
||||
return;
|
||||
}
|
||||
|
||||
config->inspect = 0;
|
||||
Py_InspectFlag = 0;
|
||||
pymain_set_inspect(config, 0);
|
||||
if (pymain_run_interactive_hook(exitcode)) {
|
||||
return;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue