summaryrefslogtreecommitdiffstats
path: root/Modules
diff options
context:
space:
mode:
authorPhilip Jenvey <pjenvey@underboss.org>2010-04-07 04:04:10 (GMT)
committerPhilip Jenvey <pjenvey@underboss.org>2010-04-07 04:04:10 (GMT)
commit0805ca3f931ccd4735dcaa231752371deadf5ccf (patch)
tree39545abe56278b67c831df94acca0b897c61691f /Modules
parent42dfeec893fb924cb8dda2a0bddf3fd54ab3c9e3 (diff)
downloadcpython-0805ca3f931ccd4735dcaa231752371deadf5ccf.zip
cpython-0805ca3f931ccd4735dcaa231752371deadf5ccf.tar.gz
cpython-0805ca3f931ccd4735dcaa231752371deadf5ccf.tar.bz2
Merged revisions 79878-79880 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk ........ r79878 | philip.jenvey | 2010-04-06 16:24:45 -0700 (Tue, 06 Apr 2010) | 4 lines #7301: add the environment variable $PYTHONWARNINGS to supplement the -W command line option patch from Brian Curtin ........ r79879 | benjamin.peterson | 2010-04-06 16:32:27 -0700 (Tue, 06 Apr 2010) | 1 line tell people to update python.man, too ........ r79880 | philip.jenvey | 2010-04-06 16:38:57 -0700 (Tue, 06 Apr 2010) | 1 line document new PYTHONWARNINGS env var ........
Diffstat (limited to 'Modules')
-rw-r--r--Modules/main.c19
1 files changed, 19 insertions, 0 deletions
diff --git a/Modules/main.c b/Modules/main.c
index 7736d99..95fae17 100644
--- a/Modules/main.c
+++ b/Modules/main.c
@@ -82,6 +82,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 = "\
@@ -401,6 +402,24 @@ Py_Main(int argc, wchar_t **argv)
(p = Py_GETENV("PYTHONNOUSERSITE")) && *p != '\0')
Py_NoUserSiteDirectory = 1;
+ if ((p = Py_GETENV("PYTHONWARNINGS")) && *p != '\0') {
+ char *buf;
+ wchar_t *warning;
+ size_t len;
+
+ for (buf = strtok(p, ",");
+ buf != NULL;
+ buf = strtok(NULL, ",")) {
+ len = strlen(buf);
+ warning = (wchar_t *)malloc((len + 1) * sizeof(wchar_t));
+ if (warning == NULL)
+ Py_FatalError(
+ "not enough memory to copy PYTHONWARNINGS");
+ mbstowcs(warning, buf, len);
+ PySys_AddWarnOption(warning);
+ }
+ }
+
if (command == NULL && module == NULL && _PyOS_optind < argc &&
wcscmp(argv[_PyOS_optind], L"-") != 0)
{