diff options
Diffstat (limited to 'Modules/main.c')
-rw-r--r-- | Modules/main.c | 25 |
1 files changed, 18 insertions, 7 deletions
diff --git a/Modules/main.c b/Modules/main.c index 72b756b..ad2616d 100644 --- a/Modules/main.c +++ b/Modules/main.c @@ -28,7 +28,7 @@ static char **orig_argv; static int orig_argc; /* command line options */ -#define BASE_OPTS "c:diOStuUvxXhVW:" +#define BASE_OPTS "c:diOSEtuUvxXhVW:" #ifndef RISCOS #define PROGRAM_OPTS BASE_OPTS @@ -53,6 +53,7 @@ Options and arguments (and corresponding environment variables):\n\ -O : optimize generated bytecode (a tad; also PYTHONOPTIMIZE=x)\n\ -OO : remove doc-strings in addition to the -O optimizations\n\ -S : don't imply 'import site' on initialization\n\ +-E : ignore environment variables (such as PYTHONPATH)\n\ -t : issue warnings about inconsistent tab usage (-tt: issue errors)\n\ "; static char *usage_mid = "\ @@ -108,6 +109,8 @@ Py_Main(int argc, char **argv) int stdin_is_interactive = 0; int help = 0; int version = 0; + int saw_inspect_flag = 0; + int saw_unbuffered_flag = 0; PyCompilerFlags cf; orig_argc = argc; /* For Py_GetArgcArgv() */ @@ -117,11 +120,6 @@ Py_Main(int argc, char **argv) Py_RISCOSWimpFlag = 0; #endif - if ((p = getenv("PYTHONINSPECT")) && *p != '\0') - inspect = 1; - if ((p = getenv("PYTHONUNBUFFERED")) && *p != '\0') - unbuffered = 1; - PySys_ResetWarnOptions(); while ((c = _PyOS_GetOpt(argc, argv, PROGRAM_OPTS)) != EOF) { @@ -146,6 +144,7 @@ Py_Main(int argc, char **argv) case 'i': inspect++; + saw_inspect_flag = 1; Py_InteractiveFlag++; break; @@ -157,12 +156,17 @@ Py_Main(int argc, char **argv) Py_NoSiteFlag++; break; + case 'E': + Py_IgnoreEnvironmentFlag++; + break; + case 't': Py_TabcheckFlag++; break; case 'u': unbuffered++; + saw_unbuffered_flag = 1; break; case 'v': @@ -210,6 +214,13 @@ Py_Main(int argc, char **argv) exit(0); } + if (!saw_inspect_flag && + (p = Py_GETENV("PYTHONINSPECT")) && *p != '\0') + inspect = 1; + if (!saw_unbuffered_flag && + (p = Py_GETENV("PYTHONUNBUFFERED")) && *p != '\0') + unbuffered = 1; + if (command == NULL && _PyOS_optind < argc && strcmp(argv[_PyOS_optind], "-") != 0) { @@ -307,7 +318,7 @@ Py_Main(int argc, char **argv) } else { if (filename == NULL && stdin_is_interactive) { - char *startup = getenv("PYTHONSTARTUP"); + char *startup = Py_GETENV("PYTHONSTARTUP"); if (startup != NULL && startup[0] != '\0') { FILE *fp = fopen(startup, "r"); if (fp != NULL) { |