From 122baa678733636336689feeb4e2c8b4807649db Mon Sep 17 00:00:00 2001 From: David Lechner Date: Wed, 15 Jan 2020 12:05:06 -0600 Subject: [PATCH] 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. --- ports/unix/main.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/ports/unix/main.c b/ports/unix/main.c index e129154544..deda8eb708 100644 --- a/ports/unix/main.c +++ b/ports/unix/main.c @@ -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();