Mercurial > cpython-lru_cache-weakref
annotate Modules/main.c @ 65035:87f4b32905df 2.7
Cosmetic fix to use print function.
| author | Hirokazu Yamamoto <ocean-city@m2.ccsnet.ne.jp> |
|---|---|
| date | Fri, 01 Oct 2010 10:48:47 +0000 |
| parents | 8f137a5c413c |
| children | b36cb4602e21 |
| rev | line source |
|---|---|
| 2896 | 1 /* Python interpreter main program */ |
| 2 | |
| 3 #include "Python.h" | |
|
6763
12824fe04a08
Two changes by Jeff Rush (slightly tweaked):
Guido van Rossum <guido@python.org>
parents:
6538
diff
changeset
|
4 #include "osdefs.h" |
|
35766
34ef9f138c30
Fix a bunch of imports to use code.h instead of compile.h.
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
35673
diff
changeset
|
5 #include "code.h" /* For CO_FUTURE_DIVISION */ |
|
33680
bcafb68ad985
SF patch #1035498: -m option to run a module as a script
Raymond Hettinger <python@rcn.com>
parents:
33188
diff
changeset
|
6 #include "import.h" |
| 2896 | 7 |
|
26550
b9c912e2c3c0
Patch #614055: Support OpenVMS.
Martin v. Löwis <martin@v.loewis.de>
parents:
25826
diff
changeset
|
8 #ifdef __VMS |
|
28169
bc2d07230934
Patch #696645: Remove VMS code with uncertain authorship.
Martin v. Löwis <martin@v.loewis.de>
parents:
26764
diff
changeset
|
9 #include <unixlib.h> |
|
26550
b9c912e2c3c0
Patch #614055: Support OpenVMS.
Martin v. Löwis <martin@v.loewis.de>
parents:
25826
diff
changeset
|
10 #endif |
|
b9c912e2c3c0
Patch #614055: Support OpenVMS.
Martin v. Löwis <martin@v.loewis.de>
parents:
25826
diff
changeset
|
11 |
|
24695
a989a2eaa2ac
On Cygwin, put stdin, stderr, and stdout in binary mode when the -u
Sjoerd Mullender <sjoerd@acm.org>
parents:
24480
diff
changeset
|
12 #if defined(MS_WINDOWS) || defined(__CYGWIN__) |
|
38232
aa620856e8a3
Patch #1492356: Port to Windows CE (patch set 1).
Martin v. Löwis <martin@v.loewis.de>
parents:
37655
diff
changeset
|
13 #ifdef HAVE_FCNTL_H |
|
5000
7c7a186b6d86
Fix the _setmode() patch for MS_WINDOWS: include <fcntl.h> and use
Guido van Rossum <guido@python.org>
parents:
4934
diff
changeset
|
14 #include <fcntl.h> |
|
7c7a186b6d86
Fix the _setmode() patch for MS_WINDOWS: include <fcntl.h> and use
Guido van Rossum <guido@python.org>
parents:
4934
diff
changeset
|
15 #endif |
|
38232
aa620856e8a3
Patch #1492356: Port to Windows CE (patch set 1).
Martin v. Löwis <martin@v.loewis.de>
parents:
37655
diff
changeset
|
16 #endif |
|
5000
7c7a186b6d86
Fix the _setmode() patch for MS_WINDOWS: include <fcntl.h> and use
Guido van Rossum <guido@python.org>
parents:
4934
diff
changeset
|
17 |
|
22114
c454b76d51e7
OS/2 EMX port changes (Modules part of patch #450267):
Andrew MacIntyre <andymac@bullseye.apana.org.au>
parents:
21928
diff
changeset
|
18 #if (defined(PYOS_OS2) && !defined(PYCC_GCC)) || defined(MS_WINDOWS) |
|
6763
12824fe04a08
Two changes by Jeff Rush (slightly tweaked):
Guido van Rossum <guido@python.org>
parents:
6538
diff
changeset
|
19 #define PYTHONHOMEHELP "<prefix>\\lib" |
|
12824fe04a08
Two changes by Jeff Rush (slightly tweaked):
Guido van Rossum <guido@python.org>
parents:
6538
diff
changeset
|
20 #else |
|
22114
c454b76d51e7
OS/2 EMX port changes (Modules part of patch #450267):
Andrew MacIntyre <andymac@bullseye.apana.org.au>
parents:
21928
diff
changeset
|
21 #if defined(PYOS_OS2) && defined(PYCC_GCC) |
|
c454b76d51e7
OS/2 EMX port changes (Modules part of patch #450267):
Andrew MacIntyre <andymac@bullseye.apana.org.au>
parents:
21928
diff
changeset
|
22 #define PYTHONHOMEHELP "<prefix>/Lib" |
|
c454b76d51e7
OS/2 EMX port changes (Modules part of patch #450267):
Andrew MacIntyre <andymac@bullseye.apana.org.au>
parents:
21928
diff
changeset
|
23 #else |
|
18088
86ccf93cc952
Removed the Python version from the PYTHONHOMEHELP string. It was
Marc-André Lemburg <mal@egenix.com>
parents:
17396
diff
changeset
|
24 #define PYTHONHOMEHELP "<prefix>/pythonX.X" |
|
6763
12824fe04a08
Two changes by Jeff Rush (slightly tweaked):
Guido van Rossum <guido@python.org>
parents:
6538
diff
changeset
|
25 #endif |
|
22114
c454b76d51e7
OS/2 EMX port changes (Modules part of patch #450267):
Andrew MacIntyre <andymac@bullseye.apana.org.au>
parents:
21928
diff
changeset
|
26 #endif |
|
6763
12824fe04a08
Two changes by Jeff Rush (slightly tweaked):
Guido van Rossum <guido@python.org>
parents:
6538
diff
changeset
|
27 |
|
15374
a826a46bae54
Move our own getopt() implementation to _PyOS_GetOpt(), and use it
Thomas Wouters <thomas@python.org>
parents:
14603
diff
changeset
|
28 #include "pygetopt.h" |
|
a826a46bae54
Move our own getopt() implementation to _PyOS_GetOpt(), and use it
Thomas Wouters <thomas@python.org>
parents:
14603
diff
changeset
|
29 |
|
14411
a707a5f17139
Instead of printing all 9 lines of copyright info, print
Guido van Rossum <guido@python.org>
parents:
14375
diff
changeset
|
30 #define COPYRIGHT \ |
|
18692
00695551d721
Add "help" to the things one is encouraged to type for more
Guido van Rossum <guido@python.org>
parents:
18611
diff
changeset
|
31 "Type \"help\", \"copyright\", \"credits\" or \"license\" " \ |
|
00695551d721
Add "help" to the things one is encouraged to type for more
Guido van Rossum <guido@python.org>
parents:
18611
diff
changeset
|
32 "for more information." |
|
14411
a707a5f17139
Instead of printing all 9 lines of copyright info, print
Guido van Rossum <guido@python.org>
parents:
14375
diff
changeset
|
33 |
|
37655
2f3f2e32dfd9
spread the extern "C" { } magic pixie dust around. Python itself builds now
Anthony Baxter <anthonybaxter@gmail.com>
parents:
37607
diff
changeset
|
34 #ifdef __cplusplus |
|
2f3f2e32dfd9
spread the extern "C" { } magic pixie dust around. Python itself builds now
Anthony Baxter <anthonybaxter@gmail.com>
parents:
37607
diff
changeset
|
35 extern "C" { |
|
2f3f2e32dfd9
spread the extern "C" { } magic pixie dust around. Python itself builds now
Anthony Baxter <anthonybaxter@gmail.com>
parents:
37607
diff
changeset
|
36 #endif |
|
2f3f2e32dfd9
spread the extern "C" { } magic pixie dust around. Python itself builds now
Anthony Baxter <anthonybaxter@gmail.com>
parents:
37607
diff
changeset
|
37 |
|
3773
6e40a2a3e6ef
New style names for getprogramname and getargcargv
Guido van Rossum <guido@python.org>
parents:
3701
diff
changeset
|
38 /* For Py_GetArgcArgv(); set by main() */ |
| 2896 | 39 static char **orig_argv; |
| 40 static int orig_argc; | |
| 41 | |
|
17396
beb9d2b02846
Updated version of RISCOS support. SF patch 411213 by Dietmar Schwertberger
Guido van Rossum <guido@python.org>
parents:
17125
diff
changeset
|
42 /* command line options */ |
|
46698
1a2dbc84bdfc
Implemented PEP 370
Christian Heimes <christian@cheimes.de>
parents:
46435
diff
changeset
|
43 #define BASE_OPTS "3bBc:dEhiJm:OQ:sStuUvVW:xX?" |
|
17396
beb9d2b02846
Updated version of RISCOS support. SF patch 411213 by Dietmar Schwertberger
Guido van Rossum <guido@python.org>
parents:
17125
diff
changeset
|
44 |
|
beb9d2b02846
Updated version of RISCOS support. SF patch 411213 by Dietmar Schwertberger
Guido van Rossum <guido@python.org>
parents:
17125
diff
changeset
|
45 #ifndef RISCOS |
|
beb9d2b02846
Updated version of RISCOS support. SF patch 411213 by Dietmar Schwertberger
Guido van Rossum <guido@python.org>
parents:
17125
diff
changeset
|
46 #define PROGRAM_OPTS BASE_OPTS |
|
beb9d2b02846
Updated version of RISCOS support. SF patch 411213 by Dietmar Schwertberger
Guido van Rossum <guido@python.org>
parents:
17125
diff
changeset
|
47 #else /*RISCOS*/ |
|
beb9d2b02846
Updated version of RISCOS support. SF patch 411213 by Dietmar Schwertberger
Guido van Rossum <guido@python.org>
parents:
17125
diff
changeset
|
48 /* extra option saying that we are running under a special task window |
|
beb9d2b02846
Updated version of RISCOS support. SF patch 411213 by Dietmar Schwertberger
Guido van Rossum <guido@python.org>
parents:
17125
diff
changeset
|
49 frontend; especially my_readline will behave different */ |
|
beb9d2b02846
Updated version of RISCOS support. SF patch 411213 by Dietmar Schwertberger
Guido van Rossum <guido@python.org>
parents:
17125
diff
changeset
|
50 #define PROGRAM_OPTS BASE_OPTS "w" |
|
beb9d2b02846
Updated version of RISCOS support. SF patch 411213 by Dietmar Schwertberger
Guido van Rossum <guido@python.org>
parents:
17125
diff
changeset
|
51 /* corresponding flag */ |
|
16944
4baa5a955532
RISCOS changes by dschwertberger.
Guido van Rossum <guido@python.org>
parents:
16752
diff
changeset
|
52 extern int Py_RISCOSWimpFlag; |
|
17396
beb9d2b02846
Updated version of RISCOS support. SF patch 411213 by Dietmar Schwertberger
Guido van Rossum <guido@python.org>
parents:
17125
diff
changeset
|
53 #endif /*RISCOS*/ |
|
16944
4baa5a955532
RISCOS changes by dschwertberger.
Guido van Rossum <guido@python.org>
parents:
16752
diff
changeset
|
54 |
| 2896 | 55 /* Short usage message (with %s for argv0) */ |
| 56 static char *usage_line = | |
|
33680
bcafb68ad985
SF patch #1035498: -m option to run a module as a script
Raymond Hettinger <python@rcn.com>
parents:
33188
diff
changeset
|
57 "usage: %s [option] ... [-c cmd | -m mod | file | -] [arg] ...\n"; |
| 2896 | 58 |
| 59 /* Long usage message, split into parts < 512 bytes */ | |
|
19633
c0a44829bcd5
Add warning mode for classic division, almost exactly as specified in
Guido van Rossum <guido@python.org>
parents:
18808
diff
changeset
|
60 static char *usage_1 = "\ |
| 2896 | 61 Options and arguments (and corresponding environment variables):\n\ |
|
44566
599f22a349a2
Patch #602345 by Neal Norwitz and me: add -B option and PYTHONDONTWRITEBYTECODE envvar to skip writing bytecode.
Georg Brandl <georg@python.org>
parents:
43929
diff
changeset
|
62 -B : don't write .py[co] files on import; also PYTHONDONTWRITEBYTECODE=x\n\ |
|
19633
c0a44829bcd5
Add warning mode for classic division, almost exactly as specified in
Guido van Rossum <guido@python.org>
parents:
18808
diff
changeset
|
63 -c cmd : program passed in as string (terminates option list)\n\ |
|
39841
2b05ec5df777
Rewrite help message to remove some of the parentheticals. (There were a lot of them.)
Andrew M. Kuchling <amk@amk.ca>
parents:
39840
diff
changeset
|
64 -d : debug output from parser; also PYTHONDEBUG=x\n\ |
|
44569
132d908471c8
patch #1668: clarify envvar docs; rename THREADDEBUG to PYTHONTHREADDEBUG.
Georg Brandl <georg@python.org>
parents:
44566
diff
changeset
|
65 -E : ignore PYTHON* environment variables (such as PYTHONPATH)\n\ |
|
39073
c48b3a68f696
Accept long options "--help" and "--version".
Georg Brandl <georg@python.org>
parents:
38778
diff
changeset
|
66 -h : print this help message and exit (also --help)\n\ |
|
39841
2b05ec5df777
Rewrite help message to remove some of the parentheticals. (There were a lot of them.)
Andrew M. Kuchling <amk@amk.ca>
parents:
39840
diff
changeset
|
67 -i : inspect interactively after running script; forces a prompt even\n\ |
|
19633
c0a44829bcd5
Add warning mode for classic division, almost exactly as specified in
Guido van Rossum <guido@python.org>
parents:
18808
diff
changeset
|
68 "; |
|
c0a44829bcd5
Add warning mode for classic division, almost exactly as specified in
Guido van Rossum <guido@python.org>
parents:
18808
diff
changeset
|
69 static char *usage_2 = "\ |
|
44566
599f22a349a2
Patch #602345 by Neal Norwitz and me: add -B option and PYTHONDONTWRITEBYTECODE envvar to skip writing bytecode.
Georg Brandl <georg@python.org>
parents:
43929
diff
changeset
|
70 if stdin does not appear to be a terminal; also PYTHONINSPECT=x\n\ |
|
33680
bcafb68ad985
SF patch #1035498: -m option to run a module as a script
Raymond Hettinger <python@rcn.com>
parents:
33188
diff
changeset
|
71 -m mod : run library module as a script (terminates option list)\n\ |
|
39841
2b05ec5df777
Rewrite help message to remove some of the parentheticals. (There were a lot of them.)
Andrew M. Kuchling <amk@amk.ca>
parents:
39840
diff
changeset
|
72 -O : optimize generated bytecode slightly; also PYTHONOPTIMIZE=x\n\ |
|
9986
d4b8ddd9a4fd
Document -OO; "unsafe" optimization that removes docstrings.
Guido van Rossum <guido@python.org>
parents:
9601
diff
changeset
|
73 -OO : remove doc-strings in addition to the -O optimizations\n\ |
|
19673
b3271297b984
PEP 238 documented -Qwarn as warning only for classic int or long
Guido van Rossum <guido@python.org>
parents:
19672
diff
changeset
|
74 -Q arg : division options: -Qold (default), -Qwarn, -Qwarnall, -Qnew\n\ |
|
46698
1a2dbc84bdfc
Implemented PEP 370
Christian Heimes <christian@cheimes.de>
parents:
46435
diff
changeset
|
75 -s : don't add user site directory to sys.path; also PYTHONNOUSERSITE\n\ |
|
6203
f57ae68aa3ae
Added -X option to suppress default import of site.py. Also split the
Guido van Rossum <guido@python.org>
parents:
6199
diff
changeset
|
76 -S : don't imply 'import site' on initialization\n\ |
|
7966
8c268d0e8822
Add -t option to set the Py_TabcheckFlag flag.
Guido van Rossum <guido@python.org>
parents:
7571
diff
changeset
|
77 -t : issue warnings about inconsistent tab usage (-tt: issue errors)\n\ |
|
6203
f57ae68aa3ae
Added -X option to suppress default import of site.py. Also split the
Guido van Rossum <guido@python.org>
parents:
6199
diff
changeset
|
78 "; |
|
19633
c0a44829bcd5
Add warning mode for classic division, almost exactly as specified in
Guido van Rossum <guido@python.org>
parents:
18808
diff
changeset
|
79 static char *usage_3 = "\ |
|
44566
599f22a349a2
Patch #602345 by Neal Norwitz and me: add -B option and PYTHONDONTWRITEBYTECODE envvar to skip writing bytecode.
Georg Brandl <georg@python.org>
parents:
43929
diff
changeset
|
80 -u : unbuffered binary stdout and stderr; also PYTHONUNBUFFERED=x\n\ |
|
33680
bcafb68ad985
SF patch #1035498: -m option to run a module as a script
Raymond Hettinger <python@rcn.com>
parents:
33188
diff
changeset
|
81 see man page for details on internal buffering relating to '-u'\n\ |
|
39841
2b05ec5df777
Rewrite help message to remove some of the parentheticals. (There were a lot of them.)
Andrew M. Kuchling <amk@amk.ca>
parents:
39840
diff
changeset
|
82 -v : verbose (trace import statements); also PYTHONVERBOSE=x\n\ |
|
2b05ec5df777
Rewrite help message to remove some of the parentheticals. (There were a lot of them.)
Andrew M. Kuchling <amk@amk.ca>
parents:
39840
diff
changeset
|
83 can be supplied multiple times to increase verbosity\n\ |
|
39073
c48b3a68f696
Accept long options "--help" and "--version".
Georg Brandl <georg@python.org>
parents:
38778
diff
changeset
|
84 -V : print the Python version number and exit (also --version)\n\ |
|
39841
2b05ec5df777
Rewrite help message to remove some of the parentheticals. (There were a lot of them.)
Andrew M. Kuchling <amk@amk.ca>
parents:
39840
diff
changeset
|
85 -W arg : warning control; arg is action:message:category:module:lineno\n\ |
|
60433
c0957dada5c2
#7301: add the environment variable $PYTHONWARNINGS to supplement the -W
Philip Jenvey <pjenvey@underboss.org>
parents:
59499
diff
changeset
|
86 also PYTHONWARNINGS=arg\n\ |
|
19633
c0a44829bcd5
Add warning mode for classic division, almost exactly as specified in
Guido van Rossum <guido@python.org>
parents:
18808
diff
changeset
|
87 -x : skip first line of source, allowing use of non-Unix forms of #!cmd\n\ |
|
44566
599f22a349a2
Patch #602345 by Neal Norwitz and me: add -B option and PYTHONDONTWRITEBYTECODE envvar to skip writing bytecode.
Georg Brandl <georg@python.org>
parents:
43929
diff
changeset
|
88 "; |
|
599f22a349a2
Patch #602345 by Neal Norwitz and me: add -B option and PYTHONDONTWRITEBYTECODE envvar to skip writing bytecode.
Georg Brandl <georg@python.org>
parents:
43929
diff
changeset
|
89 static char *usage_4 = "\ |
|
50786
2d453b221bec
Merged revisions 68292,68344,68361,68378,68424,68426,68429-68430,68450,68457,68480-68481,68493,68495,68499,68501,68512,68514-68515 via svnmerge from
Georg Brandl <georg@python.org>
parents:
47527
diff
changeset
|
90 -3 : warn about Python 3.x incompatibilities that 2to3 cannot trivially fix\n\ |
| 2896 | 91 file : program read from script file\n\ |
| 92 - : program read from stdin (default; interactive mode if a tty)\n\ | |
|
39841
2b05ec5df777
Rewrite help message to remove some of the parentheticals. (There were a lot of them.)
Andrew M. Kuchling <amk@amk.ca>
parents:
39840
diff
changeset
|
93 arg ...: arguments passed to program in sys.argv[1:]\n\n\ |
| 2896 | 94 Other environment variables:\n\ |
| 95 PYTHONSTARTUP: file executed on interactive startup (no default)\n\ | |
|
6763
12824fe04a08
Two changes by Jeff Rush (slightly tweaked):
Guido van Rossum <guido@python.org>
parents:
6538
diff
changeset
|
96 PYTHONPATH : '%c'-separated list of directories prefixed to the\n\ |
| 2896 | 97 default module search path. The result is sys.path.\n\ |
|
44566
599f22a349a2
Patch #602345 by Neal Norwitz and me: add -B option and PYTHONDONTWRITEBYTECODE envvar to skip writing bytecode.
Georg Brandl <georg@python.org>
parents:
43929
diff
changeset
|
98 "; |
|
599f22a349a2
Patch #602345 by Neal Norwitz and me: add -B option and PYTHONDONTWRITEBYTECODE envvar to skip writing bytecode.
Georg Brandl <georg@python.org>
parents:
43929
diff
changeset
|
99 static char *usage_5 = "\ |
|
6763
12824fe04a08
Two changes by Jeff Rush (slightly tweaked):
Guido van Rossum <guido@python.org>
parents:
6538
diff
changeset
|
100 PYTHONHOME : alternate <prefix> directory (or <prefix>%c<exec_prefix>).\n\ |
|
12824fe04a08
Two changes by Jeff Rush (slightly tweaked):
Guido van Rossum <guido@python.org>
parents:
6538
diff
changeset
|
101 The default module search path uses %s.\n\ |
|
16731
86c7683b606a
Add a line to "python -h" output about PYTHONCASEOK.
Tim Peters <tim.peters@gmail.com>
parents:
15593
diff
changeset
|
102 PYTHONCASEOK : ignore case in 'import' statements (Windows).\n\ |
|
47413
1062b7dec95b
New environment variable PYTHONIOENCODING.
Martin v. Löwis <martin@v.loewis.de>
parents:
47294
diff
changeset
|
103 PYTHONIOENCODING: Encoding[:errors] used for stdin/stdout/stderr.\n\ |
| 2896 | 104 "; |
| 105 | |
| 106 | |
|
28453
df9b7cee1339
Patch #672053: Return a result from Py_Main, instead of exiting.
Martin v. Löwis <martin@v.loewis.de>
parents:
28451
diff
changeset
|
107 static int |
|
14603
80a782086a57
Py_Main(), usage(), usage_mid: Add -h and -V flags to print the usage
Barry Warsaw <barry@python.org>
parents:
14411
diff
changeset
|
108 usage(int exitcode, char* program) |
|
80a782086a57
Py_Main(), usage(), usage_mid: Add -h and -V flags to print the usage
Barry Warsaw <barry@python.org>
parents:
14411
diff
changeset
|
109 { |
|
61463
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
61053
diff
changeset
|
110 FILE *f = exitcode ? stderr : stdout; |
|
19633
c0a44829bcd5
Add warning mode for classic division, almost exactly as specified in
Guido van Rossum <guido@python.org>
parents:
18808
diff
changeset
|
111 |
|
61463
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
61053
diff
changeset
|
112 fprintf(f, usage_line, program); |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
61053
diff
changeset
|
113 if (exitcode) |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
61053
diff
changeset
|
114 fprintf(f, "Try `python -h' for more information.\n"); |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
61053
diff
changeset
|
115 else { |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
61053
diff
changeset
|
116 fputs(usage_1, f); |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
61053
diff
changeset
|
117 fputs(usage_2, f); |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
61053
diff
changeset
|
118 fputs(usage_3, f); |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
61053
diff
changeset
|
119 fprintf(f, usage_4, DELIM); |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
61053
diff
changeset
|
120 fprintf(f, usage_5, DELIM, PYTHONHOMEHELP); |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
61053
diff
changeset
|
121 } |
|
26550
b9c912e2c3c0
Patch #614055: Support OpenVMS.
Martin v. Löwis <martin@v.loewis.de>
parents:
25826
diff
changeset
|
122 #if defined(__VMS) |
|
61463
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
61053
diff
changeset
|
123 if (exitcode == 0) { |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
61053
diff
changeset
|
124 /* suppress 'error' message */ |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
61053
diff
changeset
|
125 return 1; |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
61053
diff
changeset
|
126 } |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
61053
diff
changeset
|
127 else { |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
61053
diff
changeset
|
128 /* STS$M_INHIB_MSG + SS$_ABORT */ |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
61053
diff
changeset
|
129 return 0x1000002c; |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
61053
diff
changeset
|
130 } |
|
26550
b9c912e2c3c0
Patch #614055: Support OpenVMS.
Martin v. Löwis <martin@v.loewis.de>
parents:
25826
diff
changeset
|
131 #else |
|
61463
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
61053
diff
changeset
|
132 return exitcode; |
|
26550
b9c912e2c3c0
Patch #614055: Support OpenVMS.
Martin v. Löwis <martin@v.loewis.de>
parents:
25826
diff
changeset
|
133 #endif |
|
61463
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
61053
diff
changeset
|
134 /*NOTREACHED*/ |
|
14603
80a782086a57
Py_Main(), usage(), usage_mid: Add -h and -V flags to print the usage
Barry Warsaw <barry@python.org>
parents:
14411
diff
changeset
|
135 } |
|
80a782086a57
Py_Main(), usage(), usage_mid: Add -h and -V flags to print the usage
Barry Warsaw <barry@python.org>
parents:
14411
diff
changeset
|
136 |
|
30935
5d2b0e9062d5
Patch #794400: Let PYTHONSTARTUP influence the compiler flags.
Martin v. Löwis <martin@v.loewis.de>
parents:
30723
diff
changeset
|
137 static void RunStartupFile(PyCompilerFlags *cf) |
|
5d2b0e9062d5
Patch #794400: Let PYTHONSTARTUP influence the compiler flags.
Martin v. Löwis <martin@v.loewis.de>
parents:
30723
diff
changeset
|
138 { |
|
61463
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
61053
diff
changeset
|
139 char *startup = Py_GETENV("PYTHONSTARTUP"); |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
61053
diff
changeset
|
140 if (startup != NULL && startup[0] != '\0') { |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
61053
diff
changeset
|
141 FILE *fp = fopen(startup, "r"); |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
61053
diff
changeset
|
142 if (fp != NULL) { |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
61053
diff
changeset
|
143 (void) PyRun_SimpleFileExFlags(fp, startup, 0, cf); |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
61053
diff
changeset
|
144 PyErr_Clear(); |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
61053
diff
changeset
|
145 fclose(fp); |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
61053
diff
changeset
|
146 } else { |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
61053
diff
changeset
|
147 int save_errno; |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
61053
diff
changeset
|
148 save_errno = errno; |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
61053
diff
changeset
|
149 PySys_WriteStderr("Could not open PYTHONSTARTUP\n"); |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
61053
diff
changeset
|
150 errno = save_errno; |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
61053
diff
changeset
|
151 PyErr_SetFromErrnoWithFilename(PyExc_IOError, |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
61053
diff
changeset
|
152 startup); |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
61053
diff
changeset
|
153 PyErr_Print(); |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
61053
diff
changeset
|
154 PyErr_Clear(); |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
61053
diff
changeset
|
155 } |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
61053
diff
changeset
|
156 } |
|
30935
5d2b0e9062d5
Patch #794400: Let PYTHONSTARTUP influence the compiler flags.
Martin v. Löwis <martin@v.loewis.de>
parents:
30723
diff
changeset
|
157 } |
|
5d2b0e9062d5
Patch #794400: Let PYTHONSTARTUP influence the compiler flags.
Martin v. Löwis <martin@v.loewis.de>
parents:
30723
diff
changeset
|
158 |
|
36995
f914630f419c
Implement PEP 338 which has been marked as accepted by GvR
Nick Coghlan <ncoghlan@gmail.com>
parents:
36910
diff
changeset
|
159 |
|
43895
4cec0c6392c1
Patch #1739468: Directories and zipfiles containing __main__.py are now executable
Nick Coghlan <ncoghlan@gmail.com>
parents:
43534
diff
changeset
|
160 static int RunModule(char *module, int set_argv0) |
|
33680
bcafb68ad985
SF patch #1035498: -m option to run a module as a script
Raymond Hettinger <python@rcn.com>
parents:
33188
diff
changeset
|
161 { |
|
61463
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
61053
diff
changeset
|
162 PyObject *runpy, *runmodule, *runargs, *result; |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
61053
diff
changeset
|
163 runpy = PyImport_ImportModule("runpy"); |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
61053
diff
changeset
|
164 if (runpy == NULL) { |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
61053
diff
changeset
|
165 fprintf(stderr, "Could not import runpy module\n"); |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
61053
diff
changeset
|
166 return -1; |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
61053
diff
changeset
|
167 } |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
61053
diff
changeset
|
168 runmodule = PyObject_GetAttrString(runpy, "_run_module_as_main"); |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
61053
diff
changeset
|
169 if (runmodule == NULL) { |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
61053
diff
changeset
|
170 fprintf(stderr, "Could not access runpy._run_module_as_main\n"); |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
61053
diff
changeset
|
171 Py_DECREF(runpy); |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
61053
diff
changeset
|
172 return -1; |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
61053
diff
changeset
|
173 } |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
61053
diff
changeset
|
174 runargs = Py_BuildValue("(si)", module, set_argv0); |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
61053
diff
changeset
|
175 if (runargs == NULL) { |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
61053
diff
changeset
|
176 fprintf(stderr, |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
61053
diff
changeset
|
177 "Could not create arguments for runpy._run_module_as_main\n"); |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
61053
diff
changeset
|
178 Py_DECREF(runpy); |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
61053
diff
changeset
|
179 Py_DECREF(runmodule); |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
61053
diff
changeset
|
180 return -1; |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
61053
diff
changeset
|
181 } |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
61053
diff
changeset
|
182 result = PyObject_Call(runmodule, runargs, NULL); |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
61053
diff
changeset
|
183 if (result == NULL) { |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
61053
diff
changeset
|
184 PyErr_Print(); |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
61053
diff
changeset
|
185 } |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
61053
diff
changeset
|
186 Py_DECREF(runpy); |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
61053
diff
changeset
|
187 Py_DECREF(runmodule); |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
61053
diff
changeset
|
188 Py_DECREF(runargs); |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
61053
diff
changeset
|
189 if (result == NULL) { |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
61053
diff
changeset
|
190 return -1; |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
61053
diff
changeset
|
191 } |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
61053
diff
changeset
|
192 Py_DECREF(result); |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
61053
diff
changeset
|
193 return 0; |
|
33680
bcafb68ad985
SF patch #1035498: -m option to run a module as a script
Raymond Hettinger <python@rcn.com>
parents:
33188
diff
changeset
|
194 } |
|
14603
80a782086a57
Py_Main(), usage(), usage_mid: Add -h and -V flags to print the usage
Barry Warsaw <barry@python.org>
parents:
14411
diff
changeset
|
195 |
|
43895
4cec0c6392c1
Patch #1739468: Directories and zipfiles containing __main__.py are now executable
Nick Coghlan <ncoghlan@gmail.com>
parents:
43534
diff
changeset
|
196 static int RunMainFromImporter(char *filename) |
|
4cec0c6392c1
Patch #1739468: Directories and zipfiles containing __main__.py are now executable
Nick Coghlan <ncoghlan@gmail.com>
parents:
43534
diff
changeset
|
197 { |
|
61463
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
61053
diff
changeset
|
198 PyObject *argv0 = NULL, *importer = NULL; |
|
43895
4cec0c6392c1
Patch #1739468: Directories and zipfiles containing __main__.py are now executable
Nick Coghlan <ncoghlan@gmail.com>
parents:
43534
diff
changeset
|
199 |
|
61463
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
61053
diff
changeset
|
200 if ((argv0 = PyString_FromString(filename)) && |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
61053
diff
changeset
|
201 (importer = PyImport_GetImporter(argv0)) && |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
61053
diff
changeset
|
202 (importer->ob_type != &PyNullImporter_Type)) |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
61053
diff
changeset
|
203 { |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
61053
diff
changeset
|
204 /* argv0 is usable as an import source, so |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
61053
diff
changeset
|
205 put it in sys.path[0] and import __main__ */ |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
61053
diff
changeset
|
206 PyObject *sys_path = NULL; |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
61053
diff
changeset
|
207 if ((sys_path = PySys_GetObject("path")) && |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
61053
diff
changeset
|
208 !PyList_SetItem(sys_path, 0, argv0)) |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
61053
diff
changeset
|
209 { |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
61053
diff
changeset
|
210 Py_INCREF(argv0); |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
61053
diff
changeset
|
211 Py_DECREF(importer); |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
61053
diff
changeset
|
212 sys_path = NULL; |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
61053
diff
changeset
|
213 return RunModule("__main__", 0) != 0; |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
61053
diff
changeset
|
214 } |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
61053
diff
changeset
|
215 } |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
61053
diff
changeset
|
216 Py_XDECREF(argv0); |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
61053
diff
changeset
|
217 Py_XDECREF(importer); |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
61053
diff
changeset
|
218 if (PyErr_Occurred()) { |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
61053
diff
changeset
|
219 PyErr_Print(); |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
61053
diff
changeset
|
220 return 1; |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
61053
diff
changeset
|
221 } |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
61053
diff
changeset
|
222 return -1; |
|
43895
4cec0c6392c1
Patch #1739468: Directories and zipfiles containing __main__.py are now executable
Nick Coghlan <ncoghlan@gmail.com>
parents:
43534
diff
changeset
|
223 } |
|
4cec0c6392c1
Patch #1739468: Directories and zipfiles containing __main__.py are now executable
Nick Coghlan <ncoghlan@gmail.com>
parents:
43534
diff
changeset
|
224 |
|
4cec0c6392c1
Patch #1739468: Directories and zipfiles containing __main__.py are now executable
Nick Coghlan <ncoghlan@gmail.com>
parents:
43534
diff
changeset
|
225 |
| 2896 | 226 /* Main program */ |
| 227 | |
|
24471
f66b3a3509c7
Excise DL_EXPORT/DL_IMPORT from Modules/*. Required adding a prototype
Mark Hammond <mhammond@skippinet.com.au>
parents:
24405
diff
changeset
|
228 int |
|
13482
000a1c7eb09f
- changed 1.5 to 2.0 in the help text
Fredrik Lundh <fredrik@pythonware.com>
parents:
13256
diff
changeset
|
229 Py_Main(int argc, char **argv) |
| 2896 | 230 { |
|
61463
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
61053
diff
changeset
|
231 int c; |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
61053
diff
changeset
|
232 int sts; |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
61053
diff
changeset
|
233 char *command = NULL; |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
61053
diff
changeset
|
234 char *filename = NULL; |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
61053
diff
changeset
|
235 char *module = NULL; |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
61053
diff
changeset
|
236 FILE *fp = stdin; |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
61053
diff
changeset
|
237 char *p; |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
61053
diff
changeset
|
238 int unbuffered = 0; |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
61053
diff
changeset
|
239 int skipfirstline = 0; |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
61053
diff
changeset
|
240 int stdin_is_interactive = 0; |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
61053
diff
changeset
|
241 int help = 0; |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
61053
diff
changeset
|
242 int version = 0; |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
61053
diff
changeset
|
243 int saw_unbuffered_flag = 0; |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
61053
diff
changeset
|
244 PyCompilerFlags cf; |
| 2896 | 245 |
|
61463
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
61053
diff
changeset
|
246 cf.cf_flags = 0; |
|
19633
c0a44829bcd5
Add warning mode for classic division, almost exactly as specified in
Guido van Rossum <guido@python.org>
parents:
18808
diff
changeset
|
247 |
|
61463
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
61053
diff
changeset
|
248 orig_argc = argc; /* For Py_GetArgcArgv() */ |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
61053
diff
changeset
|
249 orig_argv = argv; |
| 2896 | 250 |
|
16944
4baa5a955532
RISCOS changes by dschwertberger.
Guido van Rossum <guido@python.org>
parents:
16752
diff
changeset
|
251 #ifdef RISCOS |
|
61463
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
61053
diff
changeset
|
252 Py_RISCOSWimpFlag = 0; |
|
16944
4baa5a955532
RISCOS changes by dschwertberger.
Guido van Rossum <guido@python.org>
parents:
16752
diff
changeset
|
253 #endif |
|
4baa5a955532
RISCOS changes by dschwertberger.
Guido van Rossum <guido@python.org>
parents:
16752
diff
changeset
|
254 |
|
61463
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
61053
diff
changeset
|
255 PySys_ResetWarnOptions(); |
| 15593 | 256 |
|
61463
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
61053
diff
changeset
|
257 while ((c = _PyOS_GetOpt(argc, argv, PROGRAM_OPTS)) != EOF) { |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
61053
diff
changeset
|
258 if (c == 'c') { |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
61053
diff
changeset
|
259 /* -c is the last option; following arguments |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
61053
diff
changeset
|
260 that look like options are left for the |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
61053
diff
changeset
|
261 command to interpret. */ |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
61053
diff
changeset
|
262 command = (char *)malloc(strlen(_PyOS_optarg) + 2); |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
61053
diff
changeset
|
263 if (command == NULL) |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
61053
diff
changeset
|
264 Py_FatalError( |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
61053
diff
changeset
|
265 "not enough memory to copy -c argument"); |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
61053
diff
changeset
|
266 strcpy(command, _PyOS_optarg); |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
61053
diff
changeset
|
267 strcat(command, "\n"); |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
61053
diff
changeset
|
268 break; |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
61053
diff
changeset
|
269 } |
|
19633
c0a44829bcd5
Add warning mode for classic division, almost exactly as specified in
Guido van Rossum <guido@python.org>
parents:
18808
diff
changeset
|
270 |
|
61463
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
61053
diff
changeset
|
271 if (c == 'm') { |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
61053
diff
changeset
|
272 /* -m is the last option; following arguments |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
61053
diff
changeset
|
273 that look like options are left for the |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
61053
diff
changeset
|
274 module to interpret. */ |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
61053
diff
changeset
|
275 module = (char *)malloc(strlen(_PyOS_optarg) + 2); |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
61053
diff
changeset
|
276 if (module == NULL) |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
61053
diff
changeset
|
277 Py_FatalError( |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
61053
diff
changeset
|
278 "not enough memory to copy -m argument"); |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
61053
diff
changeset
|
279 strcpy(module, _PyOS_optarg); |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
61053
diff
changeset
|
280 break; |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
61053
diff
changeset
|
281 } |
|
33680
bcafb68ad985
SF patch #1035498: -m option to run a module as a script
Raymond Hettinger <python@rcn.com>
parents:
33188
diff
changeset
|
282 |
|
61463
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
61053
diff
changeset
|
283 switch (c) { |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
61053
diff
changeset
|
284 case 'b': |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
61053
diff
changeset
|
285 Py_BytesWarningFlag++; |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
61053
diff
changeset
|
286 break; |
| 2896 | 287 |
|
61463
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
61053
diff
changeset
|
288 case 'd': |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
61053
diff
changeset
|
289 Py_DebugFlag++; |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
61053
diff
changeset
|
290 break; |
| 2896 | 291 |
|
61463
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
61053
diff
changeset
|
292 case '3': |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
61053
diff
changeset
|
293 Py_Py3kWarningFlag++; |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
61053
diff
changeset
|
294 if (!Py_DivisionWarningFlag) |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
61053
diff
changeset
|
295 Py_DivisionWarningFlag = 1; |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
61053
diff
changeset
|
296 break; |
|
41832
a0ee3b2ba361
Add -3 option to the interpreter to warn about features that are
Neal Norwitz <nnorwitz@gmail.com>
parents:
41043
diff
changeset
|
297 |
|
61463
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
61053
diff
changeset
|
298 case 'Q': |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
61053
diff
changeset
|
299 if (strcmp(_PyOS_optarg, "old") == 0) { |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
61053
diff
changeset
|
300 Py_DivisionWarningFlag = 0; |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
61053
diff
changeset
|
301 break; |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
61053
diff
changeset
|
302 } |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
61053
diff
changeset
|
303 if (strcmp(_PyOS_optarg, "warn") == 0) { |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
61053
diff
changeset
|
304 Py_DivisionWarningFlag = 1; |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
61053
diff
changeset
|
305 break; |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
61053
diff
changeset
|
306 } |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
61053
diff
changeset
|
307 if (strcmp(_PyOS_optarg, "warnall") == 0) { |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
61053
diff
changeset
|
308 Py_DivisionWarningFlag = 2; |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
61053
diff
changeset
|
309 break; |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
61053
diff
changeset
|
310 } |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
61053
diff
changeset
|
311 if (strcmp(_PyOS_optarg, "new") == 0) { |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
61053
diff
changeset
|
312 /* This only affects __main__ */ |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
61053
diff
changeset
|
313 cf.cf_flags |= CO_FUTURE_DIVISION; |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
61053
diff
changeset
|
314 /* And this tells the eval loop to treat |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
61053
diff
changeset
|
315 BINARY_DIVIDE as BINARY_TRUE_DIVIDE */ |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
61053
diff
changeset
|
316 _Py_QnewFlag = 1; |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
61053
diff
changeset
|
317 break; |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
61053
diff
changeset
|
318 } |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
61053
diff
changeset
|
319 fprintf(stderr, |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
61053
diff
changeset
|
320 "-Q option should be `-Qold', " |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
61053
diff
changeset
|
321 "`-Qwarn', `-Qwarnall', or `-Qnew' only\n"); |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
61053
diff
changeset
|
322 return usage(2, argv[0]); |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
61053
diff
changeset
|
323 /* NOTREACHED */ |
|
19633
c0a44829bcd5
Add warning mode for classic division, almost exactly as specified in
Guido van Rossum <guido@python.org>
parents:
18808
diff
changeset
|
324 |
|
61463
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
61053
diff
changeset
|
325 case 'i': |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
61053
diff
changeset
|
326 Py_InspectFlag++; |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
61053
diff
changeset
|
327 Py_InteractiveFlag++; |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
61053
diff
changeset
|
328 break; |
| 2896 | 329 |
|
61463
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
61053
diff
changeset
|
330 /* case 'J': reserved for Jython */ |
|
46406
c1fa2e758e05
Applied patch #2617 from Frank Wierzbicki wit some extras from me
Christian Heimes <christian@cheimes.de>
parents:
46184
diff
changeset
|
331 |
|
61463
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
61053
diff
changeset
|
332 case 'O': |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
61053
diff
changeset
|
333 Py_OptimizeFlag++; |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
61053
diff
changeset
|
334 break; |
|
5166
7151bb727776
Add -O option which sets Py_OptimizeFlag to avoid emitting SET_LINENO.
Guido van Rossum <guido@python.org>
parents:
5113
diff
changeset
|
335 |
|
61463
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
61053
diff
changeset
|
336 case 'B': |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
61053
diff
changeset
|
337 Py_DontWriteBytecodeFlag++; |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
61053
diff
changeset
|
338 break; |
|
44566
599f22a349a2
Patch #602345 by Neal Norwitz and me: add -B option and PYTHONDONTWRITEBYTECODE envvar to skip writing bytecode.
Georg Brandl <georg@python.org>
parents:
43929
diff
changeset
|
339 |
|
61463
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
61053
diff
changeset
|
340 case 's': |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
61053
diff
changeset
|
341 Py_NoUserSiteDirectory++; |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
61053
diff
changeset
|
342 break; |
|
46698
1a2dbc84bdfc
Implemented PEP 370
Christian Heimes <christian@cheimes.de>
parents:
46435
diff
changeset
|
343 |
|
61463
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
61053
diff
changeset
|
344 case 'S': |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
61053
diff
changeset
|
345 Py_NoSiteFlag++; |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
61053
diff
changeset
|
346 break; |
|
6203
f57ae68aa3ae
Added -X option to suppress default import of site.py. Also split the
Guido van Rossum <guido@python.org>
parents:
6199
diff
changeset
|
347 |
|
61463
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
61053
diff
changeset
|
348 case 'E': |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
61053
diff
changeset
|
349 Py_IgnoreEnvironmentFlag++; |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
61053
diff
changeset
|
350 break; |
|
18808
a8b1acc7a21f
Add -E command line switch (ignore environment variables like PYTHONHOME
Neil Schemenauer <nascheme@enme.ucalgary.ca>
parents:
18692
diff
changeset
|
351 |
|
61463
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
61053
diff
changeset
|
352 case 't': |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
61053
diff
changeset
|
353 Py_TabcheckFlag++; |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
61053
diff
changeset
|
354 break; |
|
7966
8c268d0e8822
Add -t option to set the Py_TabcheckFlag flag.
Guido van Rossum <guido@python.org>
parents:
7571
diff
changeset
|
355 |
|
61463
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
61053
diff
changeset
|
356 case 'u': |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
61053
diff
changeset
|
357 unbuffered++; |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
61053
diff
changeset
|
358 saw_unbuffered_flag = 1; |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
61053
diff
changeset
|
359 break; |
| 2896 | 360 |
|
61463
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
61053
diff
changeset
|
361 case 'v': |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
61053
diff
changeset
|
362 Py_VerboseFlag++; |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
61053
diff
changeset
|
363 break; |
| 2896 | 364 |
|
16944
4baa5a955532
RISCOS changes by dschwertberger.
Guido van Rossum <guido@python.org>
parents:
16752
diff
changeset
|
365 #ifdef RISCOS |
|
61463
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
61053
diff
changeset
|
366 case 'w': |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
61053
diff
changeset
|
367 Py_RISCOSWimpFlag = 1; |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
61053
diff
changeset
|
368 break; |
|
16944
4baa5a955532
RISCOS changes by dschwertberger.
Guido van Rossum <guido@python.org>
parents:
16752
diff
changeset
|
369 #endif |
|
4baa5a955532
RISCOS changes by dschwertberger.
Guido van Rossum <guido@python.org>
parents:
16752
diff
changeset
|
370 |
|
61463
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
61053
diff
changeset
|
371 case 'x': |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
61053
diff
changeset
|
372 skipfirstline = 1; |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
61053
diff
changeset
|
373 break; |
|
6763
12824fe04a08
Two changes by Jeff Rush (slightly tweaked):
Guido van Rossum <guido@python.org>
parents:
6538
diff
changeset
|
374 |
|
61463
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
61053
diff
changeset
|
375 /* case 'X': reserved for implementation-specific arguments */ |
|
46406
c1fa2e758e05
Applied patch #2617 from Frank Wierzbicki wit some extras from me
Christian Heimes <christian@cheimes.de>
parents:
46184
diff
changeset
|
376 |
|
61463
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
61053
diff
changeset
|
377 case 'U': |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
61053
diff
changeset
|
378 Py_UnicodeFlag++; |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
61053
diff
changeset
|
379 break; |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
61053
diff
changeset
|
380 case 'h': |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
61053
diff
changeset
|
381 case '?': |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
61053
diff
changeset
|
382 help++; |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
61053
diff
changeset
|
383 break; |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
61053
diff
changeset
|
384 case 'V': |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
61053
diff
changeset
|
385 version++; |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
61053
diff
changeset
|
386 break; |
| 12537 | 387 |
|
61463
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
61053
diff
changeset
|
388 case 'W': |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
61053
diff
changeset
|
389 PySys_AddWarnOption(_PyOS_optarg); |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
61053
diff
changeset
|
390 break; |
| 15593 | 391 |
|
61463
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
61053
diff
changeset
|
392 /* This space reserved for other options */ |
| 2896 | 393 |
|
61463
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
61053
diff
changeset
|
394 default: |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
61053
diff
changeset
|
395 return usage(2, argv[0]); |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
61053
diff
changeset
|
396 /*NOTREACHED*/ |
| 2896 | 397 |
|
61463
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
61053
diff
changeset
|
398 } |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
61053
diff
changeset
|
399 } |
| 2896 | 400 |
|
61463
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
61053
diff
changeset
|
401 if (help) |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
61053
diff
changeset
|
402 return usage(0, argv[0]); |
|
14603
80a782086a57
Py_Main(), usage(), usage_mid: Add -h and -V flags to print the usage
Barry Warsaw <barry@python.org>
parents:
14411
diff
changeset
|
403 |
|
61463
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
61053
diff
changeset
|
404 if (version) { |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
61053
diff
changeset
|
405 fprintf(stderr, "Python %s\n", PY_VERSION); |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
61053
diff
changeset
|
406 return 0; |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
61053
diff
changeset
|
407 } |
|
14603
80a782086a57
Py_Main(), usage(), usage_mid: Add -h and -V flags to print the usage
Barry Warsaw <barry@python.org>
parents:
14411
diff
changeset
|
408 |
|
61463
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
61053
diff
changeset
|
409 if (Py_Py3kWarningFlag && !Py_TabcheckFlag) |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
61053
diff
changeset
|
410 /* -3 implies -t (but not -tt) */ |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
61053
diff
changeset
|
411 Py_TabcheckFlag = 1; |
|
53083
ad3f3d304963
#5704: let python -3 imply -t as well.
Georg Brandl <georg@python.org>
parents:
51711
diff
changeset
|
412 |
|
61463
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
61053
diff
changeset
|
413 if (!Py_InspectFlag && |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
61053
diff
changeset
|
414 (p = Py_GETENV("PYTHONINSPECT")) && *p != '\0') |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
61053
diff
changeset
|
415 Py_InspectFlag = 1; |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
61053
diff
changeset
|
416 if (!saw_unbuffered_flag && |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
61053
diff
changeset
|
417 (p = Py_GETENV("PYTHONUNBUFFERED")) && *p != '\0') |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
61053
diff
changeset
|
418 unbuffered = 1; |
|
18808
a8b1acc7a21f
Add -E command line switch (ignore environment variables like PYTHONHOME
Neil Schemenauer <nascheme@enme.ucalgary.ca>
parents:
18692
diff
changeset
|
419 |
|
61463
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
61053
diff
changeset
|
420 if (!Py_NoUserSiteDirectory && |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
61053
diff
changeset
|
421 (p = Py_GETENV("PYTHONNOUSERSITE")) && *p != '\0') |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
61053
diff
changeset
|
422 Py_NoUserSiteDirectory = 1; |
|
46698
1a2dbc84bdfc
Implemented PEP 370
Christian Heimes <christian@cheimes.de>
parents:
46435
diff
changeset
|
423 |
|
61463
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
61053
diff
changeset
|
424 if ((p = Py_GETENV("PYTHONWARNINGS")) && *p != '\0') { |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
61053
diff
changeset
|
425 char *buf, *warning; |
|
60484
f34cb501f8f7
fix PYTHONWARNINGS handling to not modify the original env value and improve
Philip Jenvey <pjenvey@underboss.org>
parents:
60433
diff
changeset
|
426 |
|
61463
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
61053
diff
changeset
|
427 buf = (char *)malloc(strlen(p) + 1); |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
61053
diff
changeset
|
428 if (buf == NULL) |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
61053
diff
changeset
|
429 Py_FatalError( |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
61053
diff
changeset
|
430 "not enough memory to copy PYTHONWARNINGS"); |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
61053
diff
changeset
|
431 strcpy(buf, p); |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
61053
diff
changeset
|
432 for (warning = strtok(buf, ","); |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
61053
diff
changeset
|
433 warning != NULL; |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
61053
diff
changeset
|
434 warning = strtok(NULL, ",")) |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
61053
diff
changeset
|
435 PySys_AddWarnOption(warning); |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
61053
diff
changeset
|
436 free(buf); |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
61053
diff
changeset
|
437 } |
|
60433
c0957dada5c2
#7301: add the environment variable $PYTHONWARNINGS to supplement the -W
Philip Jenvey <pjenvey@underboss.org>
parents:
59499
diff
changeset
|
438 |
|
61463
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
61053
diff
changeset
|
439 if (command == NULL && module == NULL && _PyOS_optind < argc && |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
61053
diff
changeset
|
440 strcmp(argv[_PyOS_optind], "-") != 0) |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
61053
diff
changeset
|
441 { |
|
28169
bc2d07230934
Patch #696645: Remove VMS code with uncertain authorship.
Martin v. Löwis <martin@v.loewis.de>
parents:
26764
diff
changeset
|
442 #ifdef __VMS |
|
61463
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
61053
diff
changeset
|
443 filename = decc$translate_vms(argv[_PyOS_optind]); |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
61053
diff
changeset
|
444 if (filename == (char *)0 || filename == (char *)-1) |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
61053
diff
changeset
|
445 filename = argv[_PyOS_optind]; |
|
28169
bc2d07230934
Patch #696645: Remove VMS code with uncertain authorship.
Martin v. Löwis <martin@v.loewis.de>
parents:
26764
diff
changeset
|
446 |
|
bc2d07230934
Patch #696645: Remove VMS code with uncertain authorship.
Martin v. Löwis <martin@v.loewis.de>
parents:
26764
diff
changeset
|
447 #else |
|
61463
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
61053
diff
changeset
|
448 filename = argv[_PyOS_optind]; |
|
28169
bc2d07230934
Patch #696645: Remove VMS code with uncertain authorship.
Martin v. Löwis <martin@v.loewis.de>
parents:
26764
diff
changeset
|
449 #endif |
|
61463
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
61053
diff
changeset
|
450 } |
|
5109
0bbf97861cd9
My version of Lee Busby's patches to make '-i' pretend stdin is a tty
Guido van Rossum <guido@python.org>
parents:
5000
diff
changeset
|
451 |
|
61463
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
61053
diff
changeset
|
452 stdin_is_interactive = Py_FdIsInteractive(stdin, (char *)0); |
|
5109
0bbf97861cd9
My version of Lee Busby's patches to make '-i' pretend stdin is a tty
Guido van Rossum <guido@python.org>
parents:
5000
diff
changeset
|
453 |
|
61463
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
61053
diff
changeset
|
454 if (unbuffered) { |
|
24695
a989a2eaa2ac
On Cygwin, put stdin, stderr, and stdout in binary mode when the -u
Sjoerd Mullender <sjoerd@acm.org>
parents:
24480
diff
changeset
|
455 #if defined(MS_WINDOWS) || defined(__CYGWIN__) |
|
61463
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
61053
diff
changeset
|
456 _setmode(fileno(stdin), O_BINARY); |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
61053
diff
changeset
|
457 _setmode(fileno(stdout), O_BINARY); |
|
4934
6b61912d5f35
On Windows, -u implies binary mode for stdin/stdout
Guido van Rossum <guido@python.org>
parents:
4620
diff
changeset
|
458 #endif |
|
7571
968aaba281c5
Don't use setvbuf unless HAVE_SETVBUF is defined.
Guido van Rossum <guido@python.org>
parents:
6763
diff
changeset
|
459 #ifdef HAVE_SETVBUF |
|
61463
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
61053
diff
changeset
|
460 setvbuf(stdin, (char *)NULL, _IONBF, BUFSIZ); |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
61053
diff
changeset
|
461 setvbuf(stdout, (char *)NULL, _IONBF, BUFSIZ); |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
61053
diff
changeset
|
462 setvbuf(stderr, (char *)NULL, _IONBF, BUFSIZ); |
|
7571
968aaba281c5
Don't use setvbuf unless HAVE_SETVBUF is defined.
Guido van Rossum <guido@python.org>
parents:
6763
diff
changeset
|
463 #else /* !HAVE_SETVBUF */ |
|
61463
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
61053
diff
changeset
|
464 setbuf(stdin, (char *)NULL); |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
61053
diff
changeset
|
465 setbuf(stdout, (char *)NULL); |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
61053
diff
changeset
|
466 setbuf(stderr, (char *)NULL); |
|
7571
968aaba281c5
Don't use setvbuf unless HAVE_SETVBUF is defined.
Guido van Rossum <guido@python.org>
parents:
6763
diff
changeset
|
467 #endif /* !HAVE_SETVBUF */ |
|
61463
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
61053
diff
changeset
|
468 } |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
61053
diff
changeset
|
469 else if (Py_InteractiveFlag) { |
|
5320
c3ddb84a7761
OK, I lied. On Windows, _IOLBF seems to be the same as full
Guido van Rossum <guido@python.org>
parents:
5319
diff
changeset
|
470 #ifdef MS_WINDOWS |
|
61463
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
61053
diff
changeset
|
471 /* Doesn't have to have line-buffered -- use unbuffered */ |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
61053
diff
changeset
|
472 /* Any set[v]buf(stdin, ...) screws up Tkinter :-( */ |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
61053
diff
changeset
|
473 setvbuf(stdout, (char *)NULL, _IONBF, BUFSIZ); |
|
7571
968aaba281c5
Don't use setvbuf unless HAVE_SETVBUF is defined.
Guido van Rossum <guido@python.org>
parents:
6763
diff
changeset
|
474 #else /* !MS_WINDOWS */ |
|
968aaba281c5
Don't use setvbuf unless HAVE_SETVBUF is defined.
Guido van Rossum <guido@python.org>
parents:
6763
diff
changeset
|
475 #ifdef HAVE_SETVBUF |
|
61463
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
61053
diff
changeset
|
476 setvbuf(stdin, (char *)NULL, _IOLBF, BUFSIZ); |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
61053
diff
changeset
|
477 setvbuf(stdout, (char *)NULL, _IOLBF, BUFSIZ); |
|
7571
968aaba281c5
Don't use setvbuf unless HAVE_SETVBUF is defined.
Guido van Rossum <guido@python.org>
parents:
6763
diff
changeset
|
478 #endif /* HAVE_SETVBUF */ |
|
968aaba281c5
Don't use setvbuf unless HAVE_SETVBUF is defined.
Guido van Rossum <guido@python.org>
parents:
6763
diff
changeset
|
479 #endif /* !MS_WINDOWS */ |
|
61463
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
61053
diff
changeset
|
480 /* Leave stderr alone - it should be unbuffered anyway. */ |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
61053
diff
changeset
|
481 } |
|
26550
b9c912e2c3c0
Patch #614055: Support OpenVMS.
Martin v. Löwis <martin@v.loewis.de>
parents:
25826
diff
changeset
|
482 #ifdef __VMS |
|
61463
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
61053
diff
changeset
|
483 else { |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
61053
diff
changeset
|
484 setvbuf (stdout, (char *)NULL, _IOLBF, BUFSIZ); |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
61053
diff
changeset
|
485 } |
|
26550
b9c912e2c3c0
Patch #614055: Support OpenVMS.
Martin v. Löwis <martin@v.loewis.de>
parents:
25826
diff
changeset
|
486 #endif /* __VMS */ |
| 2896 | 487 |
|
28175
395eb561ece1
removing one Mac hack and add another:
Just van Rossum <just@letterror.com>
parents:
28169
diff
changeset
|
488 #ifdef __APPLE__ |
|
61463
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
61053
diff
changeset
|
489 /* On MacOS X, when the Python interpreter is embedded in an |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
61053
diff
changeset
|
490 application bundle, it gets executed by a bootstrapping script |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
61053
diff
changeset
|
491 that does os.execve() with an argv[0] that's different from the |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
61053
diff
changeset
|
492 actual Python executable. This is needed to keep the Finder happy, |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
61053
diff
changeset
|
493 or rather, to work around Apple's overly strict requirements of |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
61053
diff
changeset
|
494 the process name. However, we still need a usable sys.executable, |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
61053
diff
changeset
|
495 so the actual executable path is passed in an environment variable. |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
61053
diff
changeset
|
496 See Lib/plat-mac/bundlebuiler.py for details about the bootstrap |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
61053
diff
changeset
|
497 script. */ |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
61053
diff
changeset
|
498 if ((p = Py_GETENV("PYTHONEXECUTABLE")) && *p != '\0') |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
61053
diff
changeset
|
499 Py_SetProgramName(p); |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
61053
diff
changeset
|
500 else |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
61053
diff
changeset
|
501 Py_SetProgramName(argv[0]); |
|
28175
395eb561ece1
removing one Mac hack and add another:
Just van Rossum <just@letterror.com>
parents:
28169
diff
changeset
|
502 #else |
|
61463
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
61053
diff
changeset
|
503 Py_SetProgramName(argv[0]); |
|
28176
48a5113dfef9
An #endif was missing in Just's patch. Added.
Jack Jansen <jack.jansen@cwi.nl>
parents:
28175
diff
changeset
|
504 #endif |
|
61463
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
61053
diff
changeset
|
505 Py_Initialize(); |
|
5851
edaf1cb63dc0
This is no longer the real main program; it now defines Py_Main(), so
Guido van Rossum <guido@python.org>
parents:
5547
diff
changeset
|
506 |
|
61463
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
61053
diff
changeset
|
507 if (Py_VerboseFlag || |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
61053
diff
changeset
|
508 (command == NULL && filename == NULL && module == NULL && stdin_is_interactive)) { |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
61053
diff
changeset
|
509 fprintf(stderr, "Python %s on %s\n", |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
61053
diff
changeset
|
510 Py_GetVersion(), Py_GetPlatform()); |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
61053
diff
changeset
|
511 if (!Py_NoSiteFlag) |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
61053
diff
changeset
|
512 fprintf(stderr, "%s\n", COPYRIGHT); |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
61053
diff
changeset
|
513 } |
|
19633
c0a44829bcd5
Add warning mode for classic division, almost exactly as specified in
Guido van Rossum <guido@python.org>
parents:
18808
diff
changeset
|
514 |
|
61463
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
61053
diff
changeset
|
515 if (command != NULL) { |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
61053
diff
changeset
|
516 /* Backup _PyOS_optind and force sys.argv[0] = '-c' */ |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
61053
diff
changeset
|
517 _PyOS_optind--; |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
61053
diff
changeset
|
518 argv[_PyOS_optind] = "-c"; |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
61053
diff
changeset
|
519 } |
| 2896 | 520 |
|
61463
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
61053
diff
changeset
|
521 if (module != NULL) { |
|
62313
8f137a5c413c
Revert r80580 due to some unintended side effects. See issue #8202 for details.
Nick Coghlan <ncoghlan@gmail.com>
parents:
61463
diff
changeset
|
522 /* Backup _PyOS_optind and force sys.argv[0] = '-c' |
|
8f137a5c413c
Revert r80580 due to some unintended side effects. See issue #8202 for details.
Nick Coghlan <ncoghlan@gmail.com>
parents:
61463
diff
changeset
|
523 so that PySys_SetArgv correctly sets sys.path[0] to '' |
|
8f137a5c413c
Revert r80580 due to some unintended side effects. See issue #8202 for details.
Nick Coghlan <ncoghlan@gmail.com>
parents:
61463
diff
changeset
|
524 rather than looking for a file called "-m". See |
|
8f137a5c413c
Revert r80580 due to some unintended side effects. See issue #8202 for details.
Nick Coghlan <ncoghlan@gmail.com>
parents:
61463
diff
changeset
|
525 tracker issue #8202 for details. */ |
|
61463
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
61053
diff
changeset
|
526 _PyOS_optind--; |
|
62313
8f137a5c413c
Revert r80580 due to some unintended side effects. See issue #8202 for details.
Nick Coghlan <ncoghlan@gmail.com>
parents:
61463
diff
changeset
|
527 argv[_PyOS_optind] = "-c"; |
|
61463
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
61053
diff
changeset
|
528 } |
|
33680
bcafb68ad985
SF patch #1035498: -m option to run a module as a script
Raymond Hettinger <python@rcn.com>
parents:
33188
diff
changeset
|
529 |
|
61463
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
61053
diff
changeset
|
530 PySys_SetArgv(argc-_PyOS_optind, argv+_PyOS_optind); |
| 2896 | 531 |
|
61463
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
61053
diff
changeset
|
532 if ((Py_InspectFlag || (command == NULL && filename == NULL && module == NULL)) && |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
61053
diff
changeset
|
533 isatty(fileno(stdin))) { |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
61053
diff
changeset
|
534 PyObject *v; |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
61053
diff
changeset
|
535 v = PyImport_ImportModule("readline"); |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
61053
diff
changeset
|
536 if (v == NULL) |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
61053
diff
changeset
|
537 PyErr_Clear(); |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
61053
diff
changeset
|
538 else |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
61053
diff
changeset
|
539 Py_DECREF(v); |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
61053
diff
changeset
|
540 } |
|
6316
c2359665be80
Move the "import readline" to an earlier place so it is also done when
Guido van Rossum <guido@python.org>
parents:
6203
diff
changeset
|
541 |
|
61463
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
61053
diff
changeset
|
542 if (command) { |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
61053
diff
changeset
|
543 sts = PyRun_SimpleStringFlags(command, &cf) != 0; |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
61053
diff
changeset
|
544 free(command); |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
61053
diff
changeset
|
545 } else if (module) { |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
61053
diff
changeset
|
546 sts = RunModule(module, 1); |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
61053
diff
changeset
|
547 free(module); |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
61053
diff
changeset
|
548 } |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
61053
diff
changeset
|
549 else { |
|
43895
4cec0c6392c1
Patch #1739468: Directories and zipfiles containing __main__.py are now executable
Nick Coghlan <ncoghlan@gmail.com>
parents:
43534
diff
changeset
|
550 |
|
61463
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
61053
diff
changeset
|
551 if (filename == NULL && stdin_is_interactive) { |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
61053
diff
changeset
|
552 Py_InspectFlag = 0; /* do exit on SystemExit */ |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
61053
diff
changeset
|
553 RunStartupFile(&cf); |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
61053
diff
changeset
|
554 } |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
61053
diff
changeset
|
555 /* XXX */ |
|
43895
4cec0c6392c1
Patch #1739468: Directories and zipfiles containing __main__.py are now executable
Nick Coghlan <ncoghlan@gmail.com>
parents:
43534
diff
changeset
|
556 |
|
61463
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
61053
diff
changeset
|
557 sts = -1; /* keep track of whether we've already run __main__ */ |
|
43895
4cec0c6392c1
Patch #1739468: Directories and zipfiles containing __main__.py are now executable
Nick Coghlan <ncoghlan@gmail.com>
parents:
43534
diff
changeset
|
558 |
|
61463
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
61053
diff
changeset
|
559 if (filename != NULL) { |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
61053
diff
changeset
|
560 sts = RunMainFromImporter(filename); |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
61053
diff
changeset
|
561 } |
|
43895
4cec0c6392c1
Patch #1739468: Directories and zipfiles containing __main__.py are now executable
Nick Coghlan <ncoghlan@gmail.com>
parents:
43534
diff
changeset
|
562 |
|
61463
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
61053
diff
changeset
|
563 if (sts==-1 && filename!=NULL) { |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
61053
diff
changeset
|
564 if ((fp = fopen(filename, "r")) == NULL) { |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
61053
diff
changeset
|
565 fprintf(stderr, "%s: can't open file '%s': [Errno %d] %s\n", |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
61053
diff
changeset
|
566 argv[0], filename, errno, strerror(errno)); |
|
45854
21139ea59b6b
Remove all traces of HAVE_STRERROR.
Brett Cannon <bcannon@gmail.com>
parents:
44740
diff
changeset
|
567 |
|
61463
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
61053
diff
changeset
|
568 return 2; |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
61053
diff
changeset
|
569 } |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
61053
diff
changeset
|
570 else if (skipfirstline) { |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
61053
diff
changeset
|
571 int ch; |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
61053
diff
changeset
|
572 /* Push back first newline so line numbers |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
61053
diff
changeset
|
573 remain the same */ |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
61053
diff
changeset
|
574 while ((ch = getc(fp)) != EOF) { |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
61053
diff
changeset
|
575 if (ch == '\n') { |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
61053
diff
changeset
|
576 (void)ungetc(ch, fp); |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
61053
diff
changeset
|
577 break; |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
61053
diff
changeset
|
578 } |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
61053
diff
changeset
|
579 } |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
61053
diff
changeset
|
580 } |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
61053
diff
changeset
|
581 { |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
61053
diff
changeset
|
582 /* XXX: does this work on Win/Win64? (see posix_fstat) */ |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
61053
diff
changeset
|
583 struct stat sb; |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
61053
diff
changeset
|
584 if (fstat(fileno(fp), &sb) == 0 && |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
61053
diff
changeset
|
585 S_ISDIR(sb.st_mode)) { |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
61053
diff
changeset
|
586 fprintf(stderr, "%s: '%s' is a directory, cannot continue\n", argv[0], filename); |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
61053
diff
changeset
|
587 fclose(fp); |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
61053
diff
changeset
|
588 return 1; |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
61053
diff
changeset
|
589 } |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
61053
diff
changeset
|
590 } |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
61053
diff
changeset
|
591 } |
|
43895
4cec0c6392c1
Patch #1739468: Directories and zipfiles containing __main__.py are now executable
Nick Coghlan <ncoghlan@gmail.com>
parents:
43534
diff
changeset
|
592 |
|
61463
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
61053
diff
changeset
|
593 if (sts==-1) { |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
61053
diff
changeset
|
594 /* call pending calls like signal handlers (SIGINT) */ |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
61053
diff
changeset
|
595 if (Py_MakePendingCalls() == -1) { |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
61053
diff
changeset
|
596 PyErr_Print(); |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
61053
diff
changeset
|
597 sts = 1; |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
61053
diff
changeset
|
598 } else { |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
61053
diff
changeset
|
599 sts = PyRun_AnyFileExFlags( |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
61053
diff
changeset
|
600 fp, |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
61053
diff
changeset
|
601 filename == NULL ? "<stdin>" : filename, |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
61053
diff
changeset
|
602 filename != NULL, &cf) != 0; |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
61053
diff
changeset
|
603 } |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
61053
diff
changeset
|
604 } |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
61053
diff
changeset
|
605 |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
61053
diff
changeset
|
606 } |
| 2896 | 607 |
|
61463
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
61053
diff
changeset
|
608 /* Check this environment variable at the end, to give programs the |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
61053
diff
changeset
|
609 * opportunity to set it from Python. |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
61053
diff
changeset
|
610 */ |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
61053
diff
changeset
|
611 if (!Py_InspectFlag && |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
61053
diff
changeset
|
612 (p = Py_GETENV("PYTHONINSPECT")) && *p != '\0') |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
61053
diff
changeset
|
613 { |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
61053
diff
changeset
|
614 Py_InspectFlag = 1; |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
61053
diff
changeset
|
615 } |
|
29682
920777640d28
Py_Main(): Add a check for the PYTHONINSPECT environment variable
Barry Warsaw <barry@python.org>
parents:
28453
diff
changeset
|
616 |
|
61463
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
61053
diff
changeset
|
617 if (Py_InspectFlag && stdin_is_interactive && |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
61053
diff
changeset
|
618 (filename != NULL || command != NULL || module != NULL)) { |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
61053
diff
changeset
|
619 Py_InspectFlag = 0; |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
61053
diff
changeset
|
620 /* XXX */ |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
61053
diff
changeset
|
621 sts = PyRun_AnyFileFlags(stdin, "<stdin>", &cf) != 0; |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
61053
diff
changeset
|
622 } |
| 2896 | 623 |
|
61463
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
61053
diff
changeset
|
624 Py_Finalize(); |
|
16944
4baa5a955532
RISCOS changes by dschwertberger.
Guido van Rossum <guido@python.org>
parents:
16752
diff
changeset
|
625 #ifdef RISCOS |
|
61463
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
61053
diff
changeset
|
626 if (Py_RISCOSWimpFlag) |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
61053
diff
changeset
|
627 fprintf(stderr, "\x0cq\x0c"); /* make frontend quit */ |
|
16944
4baa5a955532
RISCOS changes by dschwertberger.
Guido van Rossum <guido@python.org>
parents:
16752
diff
changeset
|
628 #endif |
|
16752
5c3aedc969da
Py_Main(): When compiled by Insure (i.e. __INSURE__ is defined), call
Barry Warsaw <barry@python.org>
parents:
16731
diff
changeset
|
629 |
|
5c3aedc969da
Py_Main(): When compiled by Insure (i.e. __INSURE__ is defined), call
Barry Warsaw <barry@python.org>
parents:
16731
diff
changeset
|
630 #ifdef __INSURE__ |
|
61463
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
61053
diff
changeset
|
631 /* Insure++ is a memory analysis tool that aids in discovering |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
61053
diff
changeset
|
632 * memory leaks and other memory problems. On Python exit, the |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
61053
diff
changeset
|
633 * interned string dictionary is flagged as being in use at exit |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
61053
diff
changeset
|
634 * (which it is). Under normal circumstances, this is fine because |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
61053
diff
changeset
|
635 * the memory will be automatically reclaimed by the system. Under |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
61053
diff
changeset
|
636 * memory debugging, it's a huge source of useless noise, so we |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
61053
diff
changeset
|
637 * trade off slower shutdown for less distraction in the memory |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
61053
diff
changeset
|
638 * reports. -baw |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
61053
diff
changeset
|
639 */ |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
61053
diff
changeset
|
640 _Py_ReleaseInternedStrings(); |
|
16752
5c3aedc969da
Py_Main(): When compiled by Insure (i.e. __INSURE__ is defined), call
Barry Warsaw <barry@python.org>
parents:
16731
diff
changeset
|
641 #endif /* __INSURE__ */ |
|
5c3aedc969da
Py_Main(): When compiled by Insure (i.e. __INSURE__ is defined), call
Barry Warsaw <barry@python.org>
parents:
16731
diff
changeset
|
642 |
|
61463
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
61053
diff
changeset
|
643 return sts; |
| 2896 | 644 } |
| 645 | |
|
31606
fd2103ae6f29
Add pystack definition to Misc/gdbinit with some explanation of its behavior
Skip Montanaro <skip@pobox.com>
parents:
30968
diff
changeset
|
646 /* this is gonna seem *real weird*, but if you put some other code between |
|
fd2103ae6f29
Add pystack definition to Misc/gdbinit with some explanation of its behavior
Skip Montanaro <skip@pobox.com>
parents:
30968
diff
changeset
|
647 Py_Main() and Py_GetArgcArgv() you will need to adjust the test in the |
|
fd2103ae6f29
Add pystack definition to Misc/gdbinit with some explanation of its behavior
Skip Montanaro <skip@pobox.com>
parents:
30968
diff
changeset
|
648 while statement in Misc/gdbinit:ppystack */ |
| 2896 | 649 |
| 650 /* Make the *original* argc/argv available to other modules. | |
| 651 This is rare, but it is needed by the secureware extension. */ | |
| 652 | |
| 653 void | |
|
13482
000a1c7eb09f
- changed 1.5 to 2.0 in the help text
Fredrik Lundh <fredrik@pythonware.com>
parents:
13256
diff
changeset
|
654 Py_GetArgcArgv(int *argc, char ***argv) |
| 2896 | 655 { |
|
61463
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
61053
diff
changeset
|
656 *argc = orig_argc; |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
61053
diff
changeset
|
657 *argv = orig_argv; |
| 2896 | 658 } |
|
37655
2f3f2e32dfd9
spread the extern "C" { } magic pixie dust around. Python itself builds now
Anthony Baxter <anthonybaxter@gmail.com>
parents:
37607
diff
changeset
|
659 |
|
2f3f2e32dfd9
spread the extern "C" { } magic pixie dust around. Python itself builds now
Anthony Baxter <anthonybaxter@gmail.com>
parents:
37607
diff
changeset
|
660 #ifdef __cplusplus |
|
2f3f2e32dfd9
spread the extern "C" { } magic pixie dust around. Python itself builds now
Anthony Baxter <anthonybaxter@gmail.com>
parents:
37607
diff
changeset
|
661 } |
|
2f3f2e32dfd9
spread the extern "C" { } magic pixie dust around. Python itself builds now
Anthony Baxter <anthonybaxter@gmail.com>
parents:
37607
diff
changeset
|
662 #endif |
|
2f3f2e32dfd9
spread the extern "C" { } magic pixie dust around. Python itself builds now
Anthony Baxter <anthonybaxter@gmail.com>
parents:
37607
diff
changeset
|
663 |
