unix/main: Add support for MICROPYINSPECT environment variable.

This adds support for a MICROPYINSPECT environment variable that works
exactly like PYTHONINSPECT; per CPython docs:

    If this is set to a non-empty string it is equivalent to specifying the
    -i option.

    This variable can also be modified by Python code using os.environ to
    force inspect mode on program termination.
This commit is contained in:
David Lechner 2020-01-15 12:05:06 -06:00 committed by Damien George
parent bc3ce86a5a
commit 122baa6787
1 changed files with 4 additions and 0 deletions

View File

@ -647,6 +647,10 @@ MP_NOINLINE int main_(int argc, char **argv) {
}
}
const char *inspect_env = getenv("MICROPYINSPECT");
if (inspect_env && inspect_env[0] != '\0') {
inspect = true;
}
if (ret == NOTHING_EXECUTED || inspect) {
if (isatty(0)) {
prompt_read_history();