mirror of
https://github.com/python/cpython.git
synced 2025-09-26 18:29:57 +00:00
#7301: add the environment variable $PYTHONWARNINGS to supplement the -W
command line option patch from Brian Curtin
This commit is contained in:
parent
c1bf677e28
commit
aebbaeb962
4 changed files with 60 additions and 0 deletions
|
@ -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)
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue