blob: b36714c14d91ef8a4aa5799c58b2fcbc803c9480 [file] [log] [blame]
Guido van Rossum667d7041995-08-04 04:20:48 +00001/* Python interpreter main program */
2
3#include "Python.h"
Guido van Rossuma075ce11997-12-05 21:56:45 +00004#include "osdefs.h"
Guido van Rossum393661d2001-08-31 17:40:15 +00005#include "compile.h" /* For CO_FUTURE_DIVISION */
Guido van Rossum667d7041995-08-04 04:20:48 +00006
Guido van Rossum3e7ae7a1997-01-17 22:05:38 +00007#ifdef MS_WINDOWS
8#include <fcntl.h>
9#endif
10
Guido van Rossuma075ce11997-12-05 21:56:45 +000011#if defined(PYOS_OS2) || defined(MS_WINDOWS)
12#define PYTHONHOMEHELP "<prefix>\\lib"
13#else
Marc-André Lemburgda4dbc32001-06-12 16:13:51 +000014#define PYTHONHOMEHELP "<prefix>/pythonX.X"
Guido van Rossuma075ce11997-12-05 21:56:45 +000015#endif
16
Thomas Wouters2cffc7d2000-11-03 08:18:37 +000017#include "pygetopt.h"
18
Guido van Rossuma22865e2000-09-05 04:41:18 +000019#define COPYRIGHT \
Guido van Rossum36002d72001-07-18 16:59:46 +000020 "Type \"help\", \"copyright\", \"credits\" or \"license\" " \
21 "for more information."
Guido van Rossuma22865e2000-09-05 04:41:18 +000022
Guido van Rossumac56b031996-07-21 02:33:38 +000023/* For Py_GetArgcArgv(); set by main() */
Guido van Rossum667d7041995-08-04 04:20:48 +000024static char **orig_argv;
25static int orig_argc;
26
Guido van Rossumbceccf52001-04-10 22:07:43 +000027/* command line options */
Guido van Rossum61c345f2001-09-04 03:26:15 +000028#define BASE_OPTS "c:dEhiOQ:StuUvVW:xX"
Guido van Rossumbceccf52001-04-10 22:07:43 +000029
30#ifndef RISCOS
31#define PROGRAM_OPTS BASE_OPTS
32#else /*RISCOS*/
33/* extra option saying that we are running under a special task window
34 frontend; especially my_readline will behave different */
35#define PROGRAM_OPTS BASE_OPTS "w"
36/* corresponding flag */
Guido van Rossum3ed4c152001-03-02 06:18:03 +000037extern int Py_RISCOSWimpFlag;
Guido van Rossumbceccf52001-04-10 22:07:43 +000038#endif /*RISCOS*/
Guido van Rossum3ed4c152001-03-02 06:18:03 +000039
Guido van Rossum667d7041995-08-04 04:20:48 +000040/* Short usage message (with %s for argv0) */
41static char *usage_line =
Guido van Rossum6b86a421999-01-28 15:07:47 +000042"usage: %s [option] ... [-c cmd | file | -] [arg] ...\n";
Guido van Rossum667d7041995-08-04 04:20:48 +000043
44/* Long usage message, split into parts < 512 bytes */
Guido van Rossum393661d2001-08-31 17:40:15 +000045static char *usage_1 = "\
Guido van Rossum667d7041995-08-04 04:20:48 +000046Options and arguments (and corresponding environment variables):\n\
Guido van Rossum393661d2001-08-31 17:40:15 +000047-c cmd : program passed in as string (terminates option list)\n\
Guido van Rossum667d7041995-08-04 04:20:48 +000048-d : debug output from parser (also PYTHONDEBUG=x)\n\
Guido van Rossum393661d2001-08-31 17:40:15 +000049-E : ignore environment variables (such as PYTHONPATH)\n\
50-h : print this help message and exit\n\
Guido van Rossum775af911997-02-14 19:50:32 +000051-i : inspect interactively after running script, (also PYTHONINSPECT=x)\n\
Guido van Rossumbba92ca1998-04-10 19:39:15 +000052 and force prompts, even if stdin does not appear to be a terminal\n\
Guido van Rossum61c345f2001-09-04 03:26:15 +000053";
54static char *usage_2 = "\
Guido van Rossume7adf3e1998-10-07 14:50:06 +000055-O : optimize generated bytecode (a tad; also PYTHONOPTIMIZE=x)\n\
Guido van Rossum6b86a421999-01-28 15:07:47 +000056-OO : remove doc-strings in addition to the -O optimizations\n\
Guido van Rossum1832de42001-09-04 03:51:09 +000057-Q arg : division options: -Qold (default), -Qwarn, -Qwarnall, -Qnew\n\
Guido van Rossum7922bd71997-08-29 22:34:47 +000058-S : don't imply 'import site' on initialization\n\
Guido van Rossumbba92ca1998-04-10 19:39:15 +000059-t : issue warnings about inconsistent tab usage (-tt: issue errors)\n\
Guido van Rossumbba92ca1998-04-10 19:39:15 +000060-u : unbuffered binary stdout and stderr (also PYTHONUNBUFFERED=x)\n\
Guido van Rossum393661d2001-08-31 17:40:15 +000061";
62static char *usage_3 = "\
Guido van Rossum7922bd71997-08-29 22:34:47 +000063-v : verbose (trace import statements) (also PYTHONVERBOSE=x)\n\
Barry Warsaw3b2aedb2000-09-15 18:40:42 +000064-V : print the Python version number and exit\n\
Guido van Rossum47f5fdc2000-12-15 22:00:54 +000065-W arg : warning control (arg is action:message:category:module:lineno)\n\
Guido van Rossum393661d2001-08-31 17:40:15 +000066-x : skip first line of source, allowing use of non-Unix forms of #!cmd\n\
Guido van Rossum667d7041995-08-04 04:20:48 +000067file : program read from script file\n\
68- : program read from stdin (default; interactive mode if a tty)\n\
Guido van Rossum7922bd71997-08-29 22:34:47 +000069";
Guido van Rossum393661d2001-08-31 17:40:15 +000070static char *usage_4 = "\
Guido van Rossumbba92ca1998-04-10 19:39:15 +000071arg ...: arguments passed to program in sys.argv[1:]\n\
Guido van Rossum667d7041995-08-04 04:20:48 +000072Other environment variables:\n\
73PYTHONSTARTUP: file executed on interactive startup (no default)\n\
Guido van Rossuma075ce11997-12-05 21:56:45 +000074PYTHONPATH : '%c'-separated list of directories prefixed to the\n\
Guido van Rossum667d7041995-08-04 04:20:48 +000075 default module search path. The result is sys.path.\n\
Guido van Rossuma075ce11997-12-05 21:56:45 +000076PYTHONHOME : alternate <prefix> directory (or <prefix>%c<exec_prefix>).\n\
77 The default module search path uses %s.\n\
Tim Peters793de092001-02-22 00:39:47 +000078PYTHONCASEOK : ignore case in 'import' statements (Windows).\n\
Guido van Rossum667d7041995-08-04 04:20:48 +000079";
80
81
Barry Warsaw3b2aedb2000-09-15 18:40:42 +000082static void
83usage(int exitcode, char* program)
84{
Guido van Rossum393661d2001-08-31 17:40:15 +000085 FILE *f = exitcode ? stderr : stdout;
86
87 fprintf(f, usage_line, program);
88 if (exitcode)
89 fprintf(f, "Try `python -h' for more information.\n");
90 else {
91 fprintf(f, usage_1);
92 fprintf(f, usage_2);
93 fprintf(f, usage_3);
94 fprintf(f, usage_4, DELIM, DELIM, PYTHONHOMEHELP);
95 }
Barry Warsaw3b2aedb2000-09-15 18:40:42 +000096 exit(exitcode);
97 /*NOTREACHED*/
98}
99
100
Guido van Rossum667d7041995-08-04 04:20:48 +0000101/* Main program */
102
Guido van Rossum9c1201f1998-12-07 14:28:47 +0000103DL_EXPORT(int)
Fredrik Lundh620f3772000-07-09 20:42:34 +0000104Py_Main(int argc, char **argv)
Guido van Rossum667d7041995-08-04 04:20:48 +0000105{
106 int c;
107 int sts;
108 char *command = NULL;
109 char *filename = NULL;
110 FILE *fp = stdin;
111 char *p;
112 int inspect = 0;
113 int unbuffered = 0;
Guido van Rossuma075ce11997-12-05 21:56:45 +0000114 int skipfirstline = 0;
Guido van Rossum775af911997-02-14 19:50:32 +0000115 int stdin_is_interactive = 0;
Barry Warsaw3b2aedb2000-09-15 18:40:42 +0000116 int help = 0;
117 int version = 0;
Neil Schemenauer7d4bb9f2001-07-23 16:30:27 +0000118 int saw_inspect_flag = 0;
119 int saw_unbuffered_flag = 0;
Jeremy Hyltonbc320242001-03-22 02:47:58 +0000120 PyCompilerFlags cf;
Guido van Rossum667d7041995-08-04 04:20:48 +0000121
Guido van Rossum393661d2001-08-31 17:40:15 +0000122 cf.cf_flags = 0;
123
Guido van Rossumac56b031996-07-21 02:33:38 +0000124 orig_argc = argc; /* For Py_GetArgcArgv() */
Guido van Rossum667d7041995-08-04 04:20:48 +0000125 orig_argv = argv;
Guido van Rossum667d7041995-08-04 04:20:48 +0000126
Guido van Rossum3ed4c152001-03-02 06:18:03 +0000127#ifdef RISCOS
128 Py_RISCOSWimpFlag = 0;
129#endif
130
Guido van Rossum47f5fdc2000-12-15 22:00:54 +0000131 PySys_ResetWarnOptions();
132
Guido van Rossumbceccf52001-04-10 22:07:43 +0000133 while ((c = _PyOS_GetOpt(argc, argv, PROGRAM_OPTS)) != EOF) {
Guido van Rossum667d7041995-08-04 04:20:48 +0000134 if (c == 'c') {
135 /* -c is the last option; following arguments
136 that look like options are left for the
137 the command to interpret. */
Thomas Wouters2cffc7d2000-11-03 08:18:37 +0000138 command = malloc(strlen(_PyOS_optarg) + 2);
Guido van Rossum667d7041995-08-04 04:20:48 +0000139 if (command == NULL)
140 Py_FatalError(
141 "not enough memory to copy -c argument");
Thomas Wouters2cffc7d2000-11-03 08:18:37 +0000142 strcpy(command, _PyOS_optarg);
Guido van Rossum667d7041995-08-04 04:20:48 +0000143 strcat(command, "\n");
144 break;
145 }
Guido van Rossum393661d2001-08-31 17:40:15 +0000146
Guido van Rossum667d7041995-08-04 04:20:48 +0000147 switch (c) {
148
149 case 'd':
150 Py_DebugFlag++;
151 break;
152
Guido van Rossum61c345f2001-09-04 03:26:15 +0000153 case 'Q':
Guido van Rossum393661d2001-08-31 17:40:15 +0000154 if (strcmp(_PyOS_optarg, "old") == 0) {
155 Py_DivisionWarningFlag = 0;
156 break;
157 }
158 if (strcmp(_PyOS_optarg, "warn") == 0) {
Guido van Rossum1832de42001-09-04 03:51:09 +0000159 Py_DivisionWarningFlag = 1;
160 break;
161 }
162 if (strcmp(_PyOS_optarg, "warnall") == 0) {
163 Py_DivisionWarningFlag = 2;
Guido van Rossum393661d2001-08-31 17:40:15 +0000164 break;
165 }
166 if (strcmp(_PyOS_optarg, "new") == 0) {
Tim Peters3caca232001-12-06 06:23:26 +0000167 /* This only affects __main__ */
Guido van Rossum393661d2001-08-31 17:40:15 +0000168 cf.cf_flags |= CO_FUTURE_DIVISION;
Tim Peters3caca232001-12-06 06:23:26 +0000169 /* And this tells the eval loop to treat
170 BINARY_DIVIDE as BINARY_TRUE_DIVIDE */
171 _Py_QnewFlag = 1;
Guido van Rossum393661d2001-08-31 17:40:15 +0000172 break;
173 }
174 fprintf(stderr,
Guido van Rossum1832de42001-09-04 03:51:09 +0000175 "-Q option should be `-Qold', "
176 "`-Qwarn', `-Qwarnall', or `-Qnew' only\n");
Guido van Rossum393661d2001-08-31 17:40:15 +0000177 usage(2, argv[0]);
178 /* NOTREACHED */
179
Guido van Rossum667d7041995-08-04 04:20:48 +0000180 case 'i':
181 inspect++;
Neil Schemenauer7d4bb9f2001-07-23 16:30:27 +0000182 saw_inspect_flag = 1;
Guido van Rossum775af911997-02-14 19:50:32 +0000183 Py_InteractiveFlag++;
Guido van Rossum667d7041995-08-04 04:20:48 +0000184 break;
185
Guido van Rossum7614da61997-03-03 19:14:45 +0000186 case 'O':
187 Py_OptimizeFlag++;
188 break;
189
Guido van Rossum7922bd71997-08-29 22:34:47 +0000190 case 'S':
191 Py_NoSiteFlag++;
192 break;
193
Neil Schemenauer7d4bb9f2001-07-23 16:30:27 +0000194 case 'E':
195 Py_IgnoreEnvironmentFlag++;
196 break;
197
Guido van Rossumbba92ca1998-04-10 19:39:15 +0000198 case 't':
199 Py_TabcheckFlag++;
200 break;
201
Guido van Rossum667d7041995-08-04 04:20:48 +0000202 case 'u':
203 unbuffered++;
Neil Schemenauer7d4bb9f2001-07-23 16:30:27 +0000204 saw_unbuffered_flag = 1;
Guido van Rossum667d7041995-08-04 04:20:48 +0000205 break;
206
207 case 'v':
208 Py_VerboseFlag++;
209 break;
210
Guido van Rossum3ed4c152001-03-02 06:18:03 +0000211#ifdef RISCOS
212 case 'w':
213 Py_RISCOSWimpFlag = 1;
214 break;
215#endif
216
Guido van Rossuma075ce11997-12-05 21:56:45 +0000217 case 'x':
218 skipfirstline = 1;
219 break;
220
Guido van Rossumc15a9a12000-05-01 17:54:33 +0000221 case 'U':
222 Py_UnicodeFlag++;
223 break;
Barry Warsaw3b2aedb2000-09-15 18:40:42 +0000224 case 'h':
225 help++;
226 break;
227 case 'V':
228 version++;
229 break;
Guido van Rossumc15a9a12000-05-01 17:54:33 +0000230
Guido van Rossum47f5fdc2000-12-15 22:00:54 +0000231 case 'W':
232 PySys_AddWarnOption(_PyOS_optarg);
233 break;
234
Guido van Rossum667d7041995-08-04 04:20:48 +0000235 /* This space reserved for other options */
236
237 default:
Barry Warsaw3b2aedb2000-09-15 18:40:42 +0000238 usage(2, argv[0]);
Guido van Rossum667d7041995-08-04 04:20:48 +0000239 /*NOTREACHED*/
240
241 }
242 }
243
Barry Warsaw3b2aedb2000-09-15 18:40:42 +0000244 if (help)
245 usage(0, argv[0]);
246
247 if (version) {
248 fprintf(stderr, "Python %s\n", PY_VERSION);
249 exit(0);
250 }
251
Neil Schemenauer7d4bb9f2001-07-23 16:30:27 +0000252 if (!saw_inspect_flag &&
253 (p = Py_GETENV("PYTHONINSPECT")) && *p != '\0')
254 inspect = 1;
255 if (!saw_unbuffered_flag &&
256 (p = Py_GETENV("PYTHONUNBUFFERED")) && *p != '\0')
257 unbuffered = 1;
258
Thomas Wouters2cffc7d2000-11-03 08:18:37 +0000259 if (command == NULL && _PyOS_optind < argc &&
260 strcmp(argv[_PyOS_optind], "-") != 0)
Guido van Rossum775af911997-02-14 19:50:32 +0000261 {
Thomas Wouters2cffc7d2000-11-03 08:18:37 +0000262 filename = argv[_PyOS_optind];
Guido van Rossum775af911997-02-14 19:50:32 +0000263 if (filename != NULL) {
264 if ((fp = fopen(filename, "r")) == NULL) {
265 fprintf(stderr, "%s: can't open file '%s'\n",
266 argv[0], filename);
267 exit(2);
268 }
Guido van Rossuma075ce11997-12-05 21:56:45 +0000269 else if (skipfirstline) {
Guido van Rossumdc8b5691999-04-19 17:54:19 +0000270 int ch;
271 /* Push back first newline so line numbers
272 remain the same */
273 while ((ch = getc(fp)) != EOF) {
274 if (ch == '\n') {
275 (void)ungetc(ch, fp);
276 break;
277 }
278 }
Guido van Rossuma075ce11997-12-05 21:56:45 +0000279 }
Guido van Rossum775af911997-02-14 19:50:32 +0000280 }
281 }
282
283 stdin_is_interactive = Py_FdIsInteractive(stdin, (char *)0);
284
Guido van Rossum667d7041995-08-04 04:20:48 +0000285 if (unbuffered) {
Guido van Rossumf22d7e21997-01-11 19:28:55 +0000286#ifdef MS_WINDOWS
Guido van Rossum3e7ae7a1997-01-17 22:05:38 +0000287 _setmode(fileno(stdin), O_BINARY);
288 _setmode(fileno(stdout), O_BINARY);
Guido van Rossumf22d7e21997-01-11 19:28:55 +0000289#endif
Guido van Rossum667d7041995-08-04 04:20:48 +0000290#ifndef MPW
Guido van Rossum22ffac11998-03-06 15:30:39 +0000291#ifdef HAVE_SETVBUF
Guido van Rossum775af911997-02-14 19:50:32 +0000292 setvbuf(stdin, (char *)NULL, _IONBF, BUFSIZ);
293 setvbuf(stdout, (char *)NULL, _IONBF, BUFSIZ);
294 setvbuf(stderr, (char *)NULL, _IONBF, BUFSIZ);
Guido van Rossum22ffac11998-03-06 15:30:39 +0000295#else /* !HAVE_SETVBUF */
296 setbuf(stdin, (char *)NULL);
297 setbuf(stdout, (char *)NULL);
298 setbuf(stderr, (char *)NULL);
299#endif /* !HAVE_SETVBUF */
300#else /* MPW */
Guido van Rossum667d7041995-08-04 04:20:48 +0000301 /* On MPW (3.2) unbuffered seems to hang */
Guido van Rossum775af911997-02-14 19:50:32 +0000302 setvbuf(stdin, (char *)NULL, _IOLBF, BUFSIZ);
Guido van Rossum667d7041995-08-04 04:20:48 +0000303 setvbuf(stdout, (char *)NULL, _IOLBF, BUFSIZ);
304 setvbuf(stderr, (char *)NULL, _IOLBF, BUFSIZ);
Guido van Rossum22ffac11998-03-06 15:30:39 +0000305#endif /* MPW */
Guido van Rossum667d7041995-08-04 04:20:48 +0000306 }
Guido van Rossum2a212191997-04-11 21:57:53 +0000307 else if (Py_InteractiveFlag) {
Guido van Rossumb31c7dc1997-04-11 22:19:12 +0000308#ifdef MS_WINDOWS
309 /* Doesn't have to have line-buffered -- use unbuffered */
Guido van Rossum01b7ced1999-02-09 18:36:51 +0000310 /* Any set[v]buf(stdin, ...) screws up Tkinter :-( */
Guido van Rossumb31c7dc1997-04-11 22:19:12 +0000311 setvbuf(stdout, (char *)NULL, _IONBF, BUFSIZ);
Guido van Rossum22ffac11998-03-06 15:30:39 +0000312#else /* !MS_WINDOWS */
313#ifdef HAVE_SETVBUF
Guido van Rossumb31c7dc1997-04-11 22:19:12 +0000314 setvbuf(stdin, (char *)NULL, _IOLBF, BUFSIZ);
315 setvbuf(stdout, (char *)NULL, _IOLBF, BUFSIZ);
Guido van Rossum22ffac11998-03-06 15:30:39 +0000316#endif /* HAVE_SETVBUF */
317#endif /* !MS_WINDOWS */
Guido van Rossum775af911997-02-14 19:50:32 +0000318 /* Leave stderr alone - it should be unbuffered anyway. */
319 }
Guido van Rossum667d7041995-08-04 04:20:48 +0000320
Guido van Rossumed52aac1997-07-19 19:20:32 +0000321 Py_SetProgramName(argv[0]);
322 Py_Initialize();
323
Guido van Rossum667d7041995-08-04 04:20:48 +0000324 if (Py_VerboseFlag ||
Guido van Rossum129e91a1997-02-14 21:00:50 +0000325 (command == NULL && filename == NULL && stdin_is_interactive))
Guido van Rossumfe4dfc71997-05-19 18:33:01 +0000326 fprintf(stderr, "Python %s on %s\n%s\n",
Guido van Rossuma22865e2000-09-05 04:41:18 +0000327 Py_GetVersion(), Py_GetPlatform(), COPYRIGHT);
Guido van Rossum393661d2001-08-31 17:40:15 +0000328
Guido van Rossum667d7041995-08-04 04:20:48 +0000329 if (command != NULL) {
Thomas Wouters2cffc7d2000-11-03 08:18:37 +0000330 /* Backup _PyOS_optind and force sys.argv[0] = '-c' */
331 _PyOS_optind--;
332 argv[_PyOS_optind] = "-c";
Guido van Rossum667d7041995-08-04 04:20:48 +0000333 }
334
Thomas Wouters2cffc7d2000-11-03 08:18:37 +0000335 PySys_SetArgv(argc-_PyOS_optind, argv+_PyOS_optind);
Guido van Rossum667d7041995-08-04 04:20:48 +0000336
Guido van Rossum3d26cc91997-09-16 16:11:28 +0000337 if ((inspect || (command == NULL && filename == NULL)) &&
338 isatty(fileno(stdin))) {
339 PyObject *v;
340 v = PyImport_ImportModule("readline");
341 if (v == NULL)
342 PyErr_Clear();
343 else
344 Py_DECREF(v);
345 }
346
Guido van Rossum667d7041995-08-04 04:20:48 +0000347 if (command) {
Guido van Rossum393661d2001-08-31 17:40:15 +0000348 sts = PyRun_SimpleStringFlags(command, &cf) != 0;
Guido van Rossum05f7c501997-08-02 03:00:42 +0000349 free(command);
Guido van Rossum667d7041995-08-04 04:20:48 +0000350 }
351 else {
Guido van Rossum775af911997-02-14 19:50:32 +0000352 if (filename == NULL && stdin_is_interactive) {
Neil Schemenauer7d4bb9f2001-07-23 16:30:27 +0000353 char *startup = Py_GETENV("PYTHONSTARTUP");
Guido van Rossum667d7041995-08-04 04:20:48 +0000354 if (startup != NULL && startup[0] != '\0') {
355 FILE *fp = fopen(startup, "r");
356 if (fp != NULL) {
357 (void) PyRun_SimpleFile(fp, startup);
358 PyErr_Clear();
359 fclose(fp);
360 }
361 }
362 }
Jeremy Hyltonbc320242001-03-22 02:47:58 +0000363 /* XXX */
364 sts = PyRun_AnyFileExFlags(
Guido van Rossum775af911997-02-14 19:50:32 +0000365 fp,
Guido van Rossum0df002c2000-08-27 19:21:52 +0000366 filename == NULL ? "<stdin>" : filename,
Jeremy Hyltonbc320242001-03-22 02:47:58 +0000367 filename != NULL, &cf) != 0;
Guido van Rossum667d7041995-08-04 04:20:48 +0000368 }
369
Guido van Rossum775af911997-02-14 19:50:32 +0000370 if (inspect && stdin_is_interactive &&
Guido van Rossum667d7041995-08-04 04:20:48 +0000371 (filename != NULL || command != NULL))
Jeremy Hyltonbc320242001-03-22 02:47:58 +0000372 /* XXX */
373 sts = PyRun_AnyFileFlags(stdin, "<stdin>", &cf) != 0;
Guido van Rossum667d7041995-08-04 04:20:48 +0000374
Guido van Rossum5d1770e1997-08-05 02:23:48 +0000375 Py_Finalize();
Guido van Rossum3ed4c152001-03-02 06:18:03 +0000376#ifdef RISCOS
377 if(Py_RISCOSWimpFlag)
378 fprintf(stderr, "\x0cq\x0c"); /* make frontend quit */
379#endif
Barry Warsaw3e13b1e2001-02-23 16:46:39 +0000380
381#ifdef __INSURE__
382 /* Insure++ is a memory analysis tool that aids in discovering
383 * memory leaks and other memory problems. On Python exit, the
384 * interned string dictionary is flagged as being in use at exit
385 * (which it is). Under normal circumstances, this is fine because
386 * the memory will be automatically reclaimed by the system. Under
387 * memory debugging, it's a huge source of useless noise, so we
388 * trade off slower shutdown for less distraction in the memory
389 * reports. -baw
390 */
391 _Py_ReleaseInternedStrings();
392#endif /* __INSURE__ */
393
Guido van Rossum05f7c501997-08-02 03:00:42 +0000394 return sts;
Guido van Rossum667d7041995-08-04 04:20:48 +0000395}
396
397
Guido van Rossum667d7041995-08-04 04:20:48 +0000398/* Make the *original* argc/argv available to other modules.
399 This is rare, but it is needed by the secureware extension. */
400
401void
Fredrik Lundh620f3772000-07-09 20:42:34 +0000402Py_GetArgcArgv(int *argc, char ***argv)
Guido van Rossum667d7041995-08-04 04:20:48 +0000403{
404 *argc = orig_argc;
405 *argv = orig_argv;
406}