summaryrefslogtreecommitdiffstats
path: root/Modules/main.c
diff options
context:
space:
mode:
authorPhilip Jenvey <pjenvey@underboss.org>2010-04-06 23:24:45 (GMT)
committerPhilip Jenvey <pjenvey@underboss.org>2010-04-06 23:24:45 (GMT)
commitaebbaeb962b306d6143f77762dd53fae176bcf0e (patch)
tree50306f126f5f937e36252821dcfcd4398a4b3c82 /Modules/main.c
parentc1bf677e28a52b501ab9f93a6b78c6c0abbcc8ce (diff)
downloadcpython-aebbaeb962b306d6143f77762dd53fae176bcf0e.zip
cpython-aebbaeb962b306d6143f77762dd53fae176bcf0e.tar.gz
cpython-aebbaeb962b306d6143f77762dd53fae176bcf0e.tar.bz2
#7301: add the environment variable $PYTHONWARNINGS to supplement the -W
command line option patch from Brian Curtin
Diffstat (limited to 'Modules/main.c')
-rw-r--r--Modules/main.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/Modules/main.c b/Modules/main.c
index 7f98ed0..0ba01f7 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 = "\
@@ -420,6 +421,16 @@ Py_Main(int argc, char **argv)
(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)
{