Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 7922bd7

Browse files
committed
Added -X option to suppress default import of site.py. Also split the
usage message in *three* parts under 510 bytes, for low-end ANSI compatibility.
1 parent 3d90af9 commit 7922bd7

1 file changed

Lines changed: 13 additions & 5 deletions

File tree

Modules/main.c

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ static int orig_argc;
5353

5454
/* Short usage message (with %s for argv0) */
5555
static char *usage_line =
56-
"usage: %s [-d] [-i] [-O] [-s] [-u] [-v] [-c cmd | file | -] [arg] ...\n";
56+
"usage: %s [-d] [-i] [-O] [-S] [-u] [-v] [-X] [-c cmd | file | -] [arg] ...\n";
5757

5858
/* Long usage message, split into parts < 512 bytes */
5959
static char *usage_top = "\n\
@@ -62,15 +62,18 @@ Options and arguments (and corresponding environment variables):\n\
6262
-i : inspect interactively after running script, (also PYTHONINSPECT=x)\n\
6363
and force prompts, even if stdin does not appear to be a terminal.\n\
6464
-O : optimize generated bytecode (a tad).\n\
65+
-S : don't imply 'import site' on initialization\n\
66+
";
67+
static char *usage_mid = "\
6568
-u : unbuffered binary stdout and stderr (also PYTHONUNBUFFERED=x)\n\
66-
-X : disable class based built-in exceptions\n\
6769
-v : verbose (trace import statements) (also PYTHONVERBOSE=x)\n\
68-
";
69-
static char *usage_bot = "\
70+
-X : disable class based built-in exceptions\n\
7071
-c cmd : program passed in as string (terminates option list)\n\
7172
file : program read from script file\n\
7273
- : program read from stdin (default; interactive mode if a tty)\n\
7374
arg ...: arguments passed to program in sys.argv[1:]\n\
75+
";
76+
static char *usage_bot = "\
7477
\n\
7578
Other environment variables:\n\
7679
PYTHONSTARTUP: file executed on interactive startup (no default)\n\
@@ -107,7 +110,7 @@ Py_Main(argc, argv)
107110
unbuffered = 1;
108111

109112
Py_UseClassExceptionsFlag = 1;
110-
while ((c = getopt(argc, argv, "c:diOuvX")) != EOF) {
113+
while ((c = getopt(argc, argv, "c:diOSuvX")) != EOF) {
111114
if (c == 'c') {
112115
/* -c is the last option; following arguments
113116
that look like options are left for the
@@ -136,6 +139,10 @@ Py_Main(argc, argv)
136139
Py_OptimizeFlag++;
137140
break;
138141

142+
case 'S':
143+
Py_NoSiteFlag++;
144+
break;
145+
139146
case 'u':
140147
unbuffered++;
141148
break;
@@ -153,6 +160,7 @@ Py_Main(argc, argv)
153160
default:
154161
fprintf(stderr, usage_line, argv[0]);
155162
fprintf(stderr, usage_top);
163+
fprintf(stderr, usage_mid);
156164
fprintf(stderr, usage_bot);
157165
exit(2);
158166
/*NOTREACHED*/

0 commit comments

Comments
 (0)