Skip to content

Commit 47f5fdc

Browse files
committed
Add the -W option.
1 parent 2a862c6 commit 47f5fdc

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

Modules/main.c

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ static char *usage_mid = "\
4848
-x : skip first line of source, allowing use of non-Unix forms of #!cmd\n\
4949
-h : print this help message and exit\n\
5050
-V : print the Python version number and exit\n\
51+
-W arg : warning control (arg is action:message:category:module:lineno)\n\
5152
-c cmd : program passed in as string (terminates option list)\n\
5253
file : program read from script file\n\
5354
- : program read from stdin (default; interactive mode if a tty)\n\
@@ -101,7 +102,9 @@ Py_Main(int argc, char **argv)
101102
if ((p = getenv("PYTHONUNBUFFERED")) && *p != '\0')
102103
unbuffered = 1;
103104

104-
while ((c = _PyOS_GetOpt(argc, argv, "c:diOStuUvxXhV")) != EOF) {
105+
PySys_ResetWarnOptions();
106+
107+
while ((c = _PyOS_GetOpt(argc, argv, "c:diOStuUvxXhVW:")) != EOF) {
105108
if (c == 'c') {
106109
/* -c is the last option; following arguments
107110
that look like options are left for the
@@ -160,6 +163,10 @@ Py_Main(int argc, char **argv)
160163
version++;
161164
break;
162165

166+
case 'W':
167+
PySys_AddWarnOption(_PyOS_optarg);
168+
break;
169+
163170
/* This space reserved for other options */
164171

165172
default:

0 commit comments

Comments
 (0)