diff options
Diffstat (limited to 'Modules/main.c')
-rw-r--r-- | Modules/main.c | 24 |
1 files changed, 23 insertions, 1 deletions
diff --git a/Modules/main.c b/Modules/main.c index dd196efc32..a13d166382 100644 --- a/Modules/main.c +++ b/Modules/main.c @@ -83,6 +83,7 @@ static char *usage_3 = "\ can be supplied multiple times to increase verbosity\n\ -V : print the Python version number and exit (also --version)\n\ -W arg : warning control; arg is action:message:category:module:lineno\n\ + also PYTHONWARNINGS=arg\n\ -x : skip first line of source, allowing use of non-Unix forms of #!cmd\n\ "; static char *usage_4 = "\ @@ -405,6 +406,10 @@ Py_Main(int argc, char **argv) return 0; } + if (Py_Py3kWarningFlag && !Py_TabcheckFlag) + /* -3 implies -t (but not -tt) */ + Py_TabcheckFlag = 1; + if (!Py_InspectFlag && (p = Py_GETENV("PYTHONINSPECT")) && *p != '\0') Py_InspectFlag = 1; @@ -416,6 +421,21 @@ Py_Main(int argc, char **argv) (p = Py_GETENV("PYTHONNOUSERSITE")) && *p != '\0') Py_NoUserSiteDirectory = 1; + if ((p = Py_GETENV("PYTHONWARNINGS")) && *p != '\0') { + char *buf, *warning; + + buf = (char *)malloc(strlen(p) + 1); + if (buf == NULL) + Py_FatalError( + "not enough memory to copy PYTHONWARNINGS"); + strcpy(buf, p); + for (warning = strtok(buf, ","); + warning != NULL; + warning = strtok(NULL, ",")) + PySys_AddWarnOption(warning); + free(buf); + } + if (command == NULL && module == NULL && _PyOS_optind < argc && strcmp(argv[_PyOS_optind], "-") != 0) { @@ -500,7 +520,9 @@ Py_Main(int argc, char **argv) if (module != NULL) { /* Backup _PyOS_optind and force sys.argv[0] = '-c' - so that PySys_SetArgv correctly sets sys.path[0] to ''*/ + so that PySys_SetArgv correctly sets sys.path[0] to '' + rather than looking for a file called "-m". See + tracker issue #8202 for details. */ _PyOS_optind--; argv[_PyOS_optind] = "-c"; } |