Index: Doc/using/cmdline.rst =================================================================== --- Doc/using/cmdline.rst (revision 76237) +++ Doc/using/cmdline.rst (working copy) @@ -353,6 +353,8 @@ :mod:`warnings` -- the warnings module :pep:`230` -- Warning framework + + :envvar:`PYTHONWARNINGS` .. cmdoption:: -x @@ -526,8 +528,13 @@ If this environment variable is set, ``sys.argv[0]`` will be set to its value instead of the value got through the C runtime. Only works on Mac OS X. + +.. envvar:: PYTHONWARNINGS + This is the equivalent to the :option:`-W` option. If set to a comma + separated string, it is equivalent to specifying :option:`-W` multiple times. + Debug-mode variables ~~~~~~~~~~~~~~~~~~~~ Index: Modules/main.c =================================================================== --- Modules/main.c (revision 76237) +++ Modules/main.c (working copy) @@ -83,6 +83,7 @@ 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 PYTHONWARNING=arg\n\ -x : skip first line of source, allowing use of non-Unix forms of #!cmd\n\ "; static char *usage_4 = "\ @@ -420,6 +421,16 @@ (p = Py_GETENV("PYTHONNOUSERSITE")) && *p != '\0') Py_NoUserSiteDirectory = 1; + if ((p = Py_GETENV("PYTHONWARNINGS")) && *p != '\0') + { + char* warning = strtok(p, ","); + while (warning != NULL) + { + PySys_AddWarnOption(warning); + warning = strtok(NULL, ","); + } + } + if (command == NULL && module == NULL && _PyOS_optind < argc && strcmp(argv[_PyOS_optind], "-") != 0) {