summaryrefslogtreecommitdiffstats
path: root/Modules
diff options
context:
space:
mode:
authorVictor Stinner <vstinner@python.org>2022-06-17 14:12:00 (GMT)
committerGitHub <noreply@github.com>2022-06-17 14:12:00 (GMT)
commit0ff626f210c69643d0d5afad1e6ec6511272b3ce (patch)
treecc6b273fa241aeaccbcfa1ecff5bb6793f746e84 /Modules
parentf64557f4803528c53bb9a1d565e3cdf92e97152f (diff)
downloadcpython-0ff626f210c69643d0d5afad1e6ec6511272b3ce.zip
cpython-0ff626f210c69643d0d5afad1e6ec6511272b3ce.tar.gz
cpython-0ff626f210c69643d0d5afad1e6ec6511272b3ce.tar.bz2
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().
Diffstat (limited to 'Modules')
-rw-r--r--Modules/main.c21
1 files changed, 15 insertions, 6 deletions
diff --git a/Modules/main.c b/Modules/main.c
index cca669b..90f2372 100644
--- a/Modules/main.c
+++ b/Modules/main.c
@@ -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;
}