]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
Py_Main(): Add a check for the PYTHONINSPECT environment variable
authorBarry Warsaw <barry@python.org>
Sun, 29 Jun 2003 17:07:06 +0000 (17:07 +0000)
committerBarry Warsaw <barry@python.org>
Sun, 29 Jun 2003 17:07:06 +0000 (17:07 +0000)
after running the script so that a program could do something like:

os.environ['PYTHONINSPECT'] = 1

to programmatically enter a prompt at the end.

(After a patch by Skip Montanaro w/ proposal by Troy Melhase

Modules/main.c

index 50440b33b285140194d16d032d300c5f79003d22..83721da660d90a105c83a844832718441b3a5f84 100644 (file)
@@ -418,6 +418,15 @@ Py_Main(int argc, char **argv)
                        filename != NULL, &cf) != 0;
        }
 
+       /* Check this environment variable at the end, to give programs the
+        * opportunity to set it from Python.
+        */
+       if (!saw_inspect_flag &&
+           (p = Py_GETENV("PYTHONINSPECT")) && *p != '\0')
+       {
+               inspect = 1;
+       }
+
        if (inspect && stdin_is_interactive &&
            (filename != NULL || command != NULL))
                /* XXX */