blob: 41c229f87a8477389b6463388bf25536fa3b269e [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 Rossumc15a9a12000-05-01 17:54:33 +000063-U : Unicode literals: treats '...' literals like u'...'\n\
Guido van Rossum7922bd71997-08-29 22:34:47 +000064-v : verbose (trace import statements) (also PYTHONVERBOSE=x)\n\
Barry Warsaw3b2aedb2000-09-15 18:40:42 +000065-V : print the Python version number and exit\n\
Guido van Rossum47f5fdc2000-12-15 22:00:54 +000066-W arg : warning control (arg is action:message:category:module:lineno)\n\
Guido van Rossum393661d2001-08-31 17:40:15 +000067-x : skip first line of source, allowing use of non-Unix forms of #!cmd\n\
Guido van Rossum667d7041995-08-04 04:20:48 +000068file : program read from script file\n\
69- : program read from stdin (default; interactive mode if a tty)\n\
Guido van Rossum7922bd71997-08-29 22:34:47 +000070";
Guido van Rossum393661d2001-08-31 17:40:15 +000071static char *usage_4 = "\
Guido van Rossumbba92ca1998-04-10 19:39:15 +000072arg ...: arguments passed to program in sys.argv[1:]\n\
Guido van Rossum667d7041995-08-04 04:20:48 +000073Other environment variables:\n\
74PYTHONSTARTUP: file executed on interactive startup (no default)\n\
Guido van Rossuma075ce11997-12-05 21:56:45 +000075PYTHONPATH : '%c'-separated list of directories prefixed to the\n\
Guido van Rossum667d7041995-08-04 04:20:48 +000076 default module search path. The result is sys.path.\n\
Guido van Rossuma075ce11997-12-05 21:56:45 +000077PYTHONHOME : alternate <prefix> directory (or <prefix>%c<exec_prefix>).\n\
78 The default module search path uses %s.\n\
Tim Peters793de092001-02-22 00:39:47 +000079PYTHONCASEOK : ignore case in 'import' statements (Windows).\n\
Guido van Rossum667d7041995-08-04 04:20:48 +000080";
81
82
Barry Warsaw3b2aedb2000-09-15 18:40:42 +000083static void
84usage(int exitcode, char* program)
85{
Guido van Rossum393661d2001-08-31 17:40:15 +000086 FILE *f = exitcode ? stderr : stdout;
87
88 fprintf(f, usage_line, program);
89 if (exitcode)
90 fprintf(f, "Try `python -h' for more information.\n");
91 else {
92 fprintf(f, usage_1);
93 fprintf(f, usage_2);
94 fprintf(f, usage_3);
95 fprintf(f, usage_4, DELIM, DELIM, PYTHONHOMEHELP);
96 }
Barry Warsaw3b2aedb2000-09-15 18:40:42 +000097 exit(exitcode);
98 /*NOTREACHED*/
99}
100
101
Guido van Rossum667d7041995-08-04 04:20:48 +0000102/* Main program */
103
Guido van Rossum9c1201f1998-12-07 14:28:47 +0000104DL_EXPORT(int)
Fredrik Lundh620f3772000-07-09 20:42:34 +0000105Py_Main(int argc, char **argv)
Guido van Rossum667d7041995-08-04 04:20:48 +0000106{
107 int c;
108 int sts;
109 char *command = NULL;
110 char *filename = NULL;
111 FILE *fp = stdin;
112 char *p;
113 int inspect = 0;
114 int unbuffered = 0;
Guido van Rossuma075ce11997-12-05 21:56:45 +0000115 int skipfirstline = 0;
Guido van Rossum775af911997-02-14 19:50:32 +0000116 int stdin_is_interactive = 0;
Barry Warsaw3b2aedb2000-09-15 18:40:42 +0000117 int help = 0;
118 int version = 0;
Neil Schemenauer7d4bb9f2001-07-23 16:30:27 +0000119 int saw_inspect_flag = 0;
120 int saw_unbuffered_flag = 0;
Jeremy Hyltonbc320242001-03-22 02:47:58 +0000121 PyCompilerFlags cf;
Guido van Rossum667d7041995-08-04 04:20:48 +0000122
Guido van Rossum393661d2001-08-31 17:40:15 +0000123 cf.cf_flags = 0;
124
Guido van Rossumac56b031996-07-21 02:33:38 +0000125 orig_argc = argc; /* For Py_GetArgcArgv() */
Guido van Rossum667d7041995-08-04 04:20:48 +0000126 orig_argv = argv;
Guido van Rossum667d7041995-08-04 04:20:48 +0000127
Guido van Rossum3ed4c152001-03-02 06:18:03 +0000128#ifdef RISCOS
129 Py_RISCOSWimpFlag = 0;
130#endif
131
Guido van Rossum47f5fdc2000-12-15 22:00:54 +0000132 PySys_ResetWarnOptions();
133
Guido van Rossumbceccf52001-04-10 22:07:43 +0000134 while ((c = _PyOS_GetOpt(argc, argv, PROGRAM_OPTS)) != EOF) {
Guido van Rossum667d7041995-08-04 04:20:48 +0000135 if (c == 'c') {
136 /* -c is the last option; following arguments
137 that look like options are left for the
138 the command to interpret. */
Thomas Wouters2cffc7d2000-11-03 08:18:37 +0000139 command = malloc(strlen(_PyOS_optarg) + 2);
Guido van Rossum667d7041995-08-04 04:20:48 +0000140 if (command == NULL)
141 Py_FatalError(
142 "not enough memory to copy -c argument");
Thomas Wouters2cffc7d2000-11-03 08:18:37 +0000143 strcpy(command, _PyOS_optarg);
Guido van Rossum667d7041995-08-04 04:20:48 +0000144 strcat(command, "\n");
145 break;
146 }
Guido van Rossum393661d2001-08-31 17:40:15 +0000147
Guido van Rossum667d7041995-08-04 04:20:48 +0000148 switch (c) {
149
150 case 'd':
151 Py_DebugFlag++;
152 break;
153
Guido van Rossum61c345f2001-09-04 03:26:15 +0000154 case 'Q':
Guido van Rossum393661d2001-08-31 17:40:15 +0000155 if (strcmp(_PyOS_optarg, "old") == 0) {
156 Py_DivisionWarningFlag = 0;
157 break;
158 }
159 if (strcmp(_PyOS_optarg, "warn") == 0) {
Guido van Rossum1832de42001-09-04 03:51:09 +0000160 Py_DivisionWarningFlag = 1;
161 break;
162 }
163 if (strcmp(_PyOS_optarg, "warnall") == 0) {
164 Py_DivisionWarningFlag = 2;
Guido van Rossum393661d2001-08-31 17:40:15 +0000165 break;
166 }
167 if (strcmp(_PyOS_optarg, "new") == 0) {
Tim Peters3caca232001-12-06 06:23:26 +0000168 /* This only affects __main__ */
Guido van Rossum393661d2001-08-31 17:40:15 +0000169 cf.cf_flags |= CO_FUTURE_DIVISION;
Tim Peters3caca232001-12-06 06:23:26 +0000170 /* And this tells the eval loop to treat
171 BINARY_DIVIDE as BINARY_TRUE_DIVIDE */
172 _Py_QnewFlag = 1;
Guido van Rossum393661d2001-08-31 17:40:15 +0000173 break;
174 }
175 fprintf(stderr,
Guido van Rossum1832de42001-09-04 03:51:09 +0000176 "-Q option should be `-Qold', "
177 "`-Qwarn', `-Qwarnall', or `-Qnew' only\n");
Guido van Rossum393661d2001-08-31 17:40:15 +0000178 usage(2, argv[0]);
179 /* NOTREACHED */
180
Guido van Rossum667d7041995-08-04 04:20:48 +0000181 case 'i':
182 inspect++;
Neil Schemenauer7d4bb9f2001-07-23 16:30:27 +0000183 saw_inspect_flag = 1;
Guido van Rossum775af911997-02-14 19:50:32 +0000184 Py_InteractiveFlag++;
Guido van Rossum667d7041995-08-04 04:20:48 +0000185 break;
186
Guido van Rossum7614da61997-03-03 19:14:45 +0000187 case 'O':
188 Py_OptimizeFlag++;
189 break;
190
Guido van Rossum7922bd71997-08-29 22:34:47 +0000191 case 'S':
192 Py_NoSiteFlag++;
193 break;
194
Neil Schemenauer7d4bb9f2001-07-23 16:30:27 +0000195 case 'E':
196 Py_IgnoreEnvironmentFlag++;
197 break;
198
Guido van Rossumbba92ca1998-04-10 19:39:15 +0000199 case 't':
200 Py_TabcheckFlag++;
201 break;
202
Guido van Rossum667d7041995-08-04 04:20:48 +0000203 case 'u':
204 unbuffered++;
Neil Schemenauer7d4bb9f2001-07-23 16:30:27 +0000205 saw_unbuffered_flag = 1;
Guido van Rossum667d7041995-08-04 04:20:48 +0000206 break;
207
208 case 'v':
209 Py_VerboseFlag++;
210 break;
211
Guido van Rossum3ed4c152001-03-02 06:18:03 +0000212#ifdef RISCOS
213 case 'w':
214 Py_RISCOSWimpFlag = 1;
215 break;
216#endif
217
Guido van Rossuma075ce11997-12-05 21:56:45 +0000218 case 'x':
219 skipfirstline = 1;
220 break;
221
Guido van Rossumc15a9a12000-05-01 17:54:33 +0000222 case 'U':
223 Py_UnicodeFlag++;
224 break;
Barry Warsaw3b2aedb2000-09-15 18:40:42 +0000225 case 'h':
226 help++;
227 break;
228 case 'V':
229 version++;
230 break;
Guido van Rossumc15a9a12000-05-01 17:54:33 +0000231
Guido van Rossum47f5fdc2000-12-15 22:00:54 +0000232 case 'W':
233 PySys_AddWarnOption(_PyOS_optarg);
234 break;
235
Guido van Rossum667d7041995-08-04 04:20:48 +0000236 /* This space reserved for other options */
237
238 default:
Barry Warsaw3b2aedb2000-09-15 18:40:42 +0000239 usage(2, argv[0]);
Guido van Rossum667d7041995-08-04 04:20:48 +0000240 /*NOTREACHED*/
241
242 }
243 }
244
Barry Warsaw3b2aedb2000-09-15 18:40:42 +0000245 if (help)
246 usage(0, argv[0]);
247
248 if (version) {
249 fprintf(stderr, "Python %s\n", PY_VERSION);
250 exit(0);
251 }
252
Neil Schemenauer7d4bb9f2001-07-23 16:30:27 +0000253 if (!saw_inspect_flag &&
254 (p = Py_GETENV("PYTHONINSPECT")) && *p != '\0')
255 inspect = 1;
256 if (!saw_unbuffered_flag &&
257 (p = Py_GETENV("PYTHONUNBUFFERED")) && *p != '\0')
258 unbuffered = 1;
259
Thomas Wouters2cffc7d2000-11-03 08:18:37 +0000260 if (command == NULL && _PyOS_optind < argc &&
261 strcmp(argv[_PyOS_optind], "-") != 0)
Guido van Rossum775af911997-02-14 19:50:32 +0000262 {
Thomas Wouters2cffc7d2000-11-03 08:18:37 +0000263 filename = argv[_PyOS_optind];
Guido van Rossum775af911997-02-14 19:50:32 +0000264 if (filename != NULL) {
265 if ((fp = fopen(filename, "r")) == NULL) {
266 fprintf(stderr, "%s: can't open file '%s'\n",
267 argv[0], filename);
268 exit(2);
269 }
Guido van Rossuma075ce11997-12-05 21:56:45 +0000270 else if (skipfirstline) {
Guido van Rossumdc8b5691999-04-19 17:54:19 +0000271 int ch;
272 /* Push back first newline so line numbers
273 remain the same */
274 while ((ch = getc(fp)) != EOF) {
275 if (ch == '\n') {
276 (void)ungetc(ch, fp);
277 break;
278 }
279 }
Guido van Rossuma075ce11997-12-05 21:56:45 +0000280 }
Guido van Rossum775af911997-02-14 19:50:32 +0000281 }
282 }
283
284 stdin_is_interactive = Py_FdIsInteractive(stdin, (char *)0);
285
Guido van Rossum667d7041995-08-04 04:20:48 +0000286 if (unbuffered) {
Guido van Rossumf22d7e21997-01-11 19:28:55 +0000287#ifdef MS_WINDOWS
Guido van Rossum3e7ae7a1997-01-17 22:05:38 +0000288 _setmode(fileno(stdin), O_BINARY);
289 _setmode(fileno(stdout), O_BINARY);
Guido van Rossumf22d7e21997-01-11 19:28:55 +0000290#endif
Guido van Rossum667d7041995-08-04 04:20:48 +0000291#ifndef MPW
Guido van Rossum22ffac11998-03-06 15:30:39 +0000292#ifdef HAVE_SETVBUF
Guido van Rossum775af911997-02-14 19:50:32 +0000293 setvbuf(stdin, (char *)NULL, _IONBF, BUFSIZ);
294 setvbuf(stdout, (char *)NULL, _IONBF, BUFSIZ);
295 setvbuf(stderr, (char *)NULL, _IONBF, BUFSIZ);
Guido van Rossum22ffac11998-03-06 15:30:39 +0000296#else /* !HAVE_SETVBUF */
297 setbuf(stdin, (char *)NULL);
298 setbuf(stdout, (char *)NULL);
299 setbuf(stderr, (char *)NULL);
300#endif /* !HAVE_SETVBUF */
301#else /* MPW */
Guido van Rossum667d7041995-08-04 04:20:48 +0000302 /* On MPW (3.2) unbuffered seems to hang */
Guido van Rossum775af911997-02-14 19:50:32 +0000303 setvbuf(stdin, (char *)NULL, _IOLBF, BUFSIZ);
Guido van Rossum667d7041995-08-04 04:20:48 +0000304 setvbuf(stdout, (char *)NULL, _IOLBF, BUFSIZ);
305 setvbuf(stderr, (char *)NULL, _IOLBF, BUFSIZ);
Guido van Rossum22ffac11998-03-06 15:30:39 +0000306#endif /* MPW */
Guido van Rossum667d7041995-08-04 04:20:48 +0000307 }
Guido van Rossum2a212191997-04-11 21:57:53 +0000308 else if (Py_InteractiveFlag) {
Guido van Rossumb31c7dc1997-04-11 22:19:12 +0000309#ifdef MS_WINDOWS
310 /* Doesn't have to have line-buffered -- use unbuffered */
Guido van Rossum01b7ced1999-02-09 18:36:51 +0000311 /* Any set[v]buf(stdin, ...) screws up Tkinter :-( */
Guido van Rossumb31c7dc1997-04-11 22:19:12 +0000312 setvbuf(stdout, (char *)NULL, _IONBF, BUFSIZ);
Guido van Rossum22ffac11998-03-06 15:30:39 +0000313#else /* !MS_WINDOWS */
314#ifdef HAVE_SETVBUF
Guido van Rossumb31c7dc1997-04-11 22:19:12 +0000315 setvbuf(stdin, (char *)NULL, _IOLBF, BUFSIZ);
316 setvbuf(stdout, (char *)NULL, _IOLBF, BUFSIZ);
Guido van Rossum22ffac11998-03-06 15:30:39 +0000317#endif /* HAVE_SETVBUF */
318#endif /* !MS_WINDOWS */
Guido van Rossum775af911997-02-14 19:50:32 +0000319 /* Leave stderr alone - it should be unbuffered anyway. */
320 }
Guido van Rossum667d7041995-08-04 04:20:48 +0000321
Guido van Rossumed52aac1997-07-19 19:20:32 +0000322 Py_SetProgramName(argv[0]);
323 Py_Initialize();
324
Guido van Rossum667d7041995-08-04 04:20:48 +0000325 if (Py_VerboseFlag ||
Guido van Rossum129e91a1997-02-14 21:00:50 +0000326 (command == NULL && filename == NULL && stdin_is_interactive))
Guido van Rossumfe4dfc71997-05-19 18:33:01 +0000327 fprintf(stderr, "Python %s on %s\n%s\n",
Guido van Rossuma22865e2000-09-05 04:41:18 +0000328 Py_GetVersion(), Py_GetPlatform(), COPYRIGHT);
Guido van Rossum393661d2001-08-31 17:40:15 +0000329
Guido van Rossum667d7041995-08-04 04:20:48 +0000330 if (command != NULL) {
Thomas Wouters2cffc7d2000-11-03 08:18:37 +0000331 /* Backup _PyOS_optind and force sys.argv[0] = '-c' */
332 _PyOS_optind--;
333 argv[_PyOS_optind] = "-c";
Guido van Rossum667d7041995-08-04 04:20:48 +0000334 }
335
Thomas Wouters2cffc7d2000-11-03 08:18:37 +0000336 PySys_SetArgv(argc-_PyOS_optind, argv+_PyOS_optind);
Guido van Rossum667d7041995-08-04 04:20:48 +0000337
Guido van Rossum3d26cc91997-09-16 16:11:28 +0000338 if ((inspect || (command == NULL && filename == NULL)) &&
339 isatty(fileno(stdin))) {
340 PyObject *v;
341 v = PyImport_ImportModule("readline");
342 if (v == NULL)
343 PyErr_Clear();
344 else
345 Py_DECREF(v);
346 }
347
Guido van Rossum667d7041995-08-04 04:20:48 +0000348 if (command) {
Guido van Rossum393661d2001-08-31 17:40:15 +0000349 sts = PyRun_SimpleStringFlags(command, &cf) != 0;
Guido van Rossum05f7c501997-08-02 03:00:42 +0000350 free(command);
Guido van Rossum667d7041995-08-04 04:20:48 +0000351 }
352 else {
Guido van Rossum775af911997-02-14 19:50:32 +0000353 if (filename == NULL && stdin_is_interactive) {
Neil Schemenauer7d4bb9f2001-07-23 16:30:27 +0000354 char *startup = Py_GETENV("PYTHONSTARTUP");
Guido van Rossum667d7041995-08-04 04:20:48 +0000355 if (startup != NULL && startup[0] != '\0') {
356 FILE *fp = fopen(startup, "r");
357 if (fp != NULL) {
358 (void) PyRun_SimpleFile(fp, startup);
359 PyErr_Clear();
360 fclose(fp);
361 }
362 }
363 }
Jeremy Hyltonbc320242001-03-22 02:47:58 +0000364 /* XXX */
365 sts = PyRun_AnyFileExFlags(
Guido van Rossum775af911997-02-14 19:50:32 +0000366 fp,
Guido van Rossum0df002c2000-08-27 19:21:52 +0000367 filename == NULL ? "<stdin>" : filename,
Jeremy Hyltonbc320242001-03-22 02:47:58 +0000368 filename != NULL, &cf) != 0;
Guido van Rossum667d7041995-08-04 04:20:48 +0000369 }
370
Guido van Rossum775af911997-02-14 19:50:32 +0000371 if (inspect && stdin_is_interactive &&
Guido van Rossum667d7041995-08-04 04:20:48 +0000372 (filename != NULL || command != NULL))
Jeremy Hyltonbc320242001-03-22 02:47:58 +0000373 /* XXX */
374 sts = PyRun_AnyFileFlags(stdin, "<stdin>", &cf) != 0;
Guido van Rossum667d7041995-08-04 04:20:48 +0000375
Guido van Rossum5d1770e1997-08-05 02:23:48 +0000376 Py_Finalize();
Guido van Rossum3ed4c152001-03-02 06:18:03 +0000377#ifdef RISCOS
378 if(Py_RISCOSWimpFlag)
379 fprintf(stderr, "\x0cq\x0c"); /* make frontend quit */
380#endif
Barry Warsaw3e13b1e2001-02-23 16:46:39 +0000381
382#ifdef __INSURE__
383 /* Insure++ is a memory analysis tool that aids in discovering
384 * memory leaks and other memory problems. On Python exit, the
385 * interned string dictionary is flagged as being in use at exit
386 * (which it is). Under normal circumstances, this is fine because
387 * the memory will be automatically reclaimed by the system. Under
388 * memory debugging, it's a huge source of useless noise, so we
389 * trade off slower shutdown for less distraction in the memory
390 * reports. -baw
391 */
392 _Py_ReleaseInternedStrings();
393#endif /* __INSURE__ */
394
Guido van Rossum05f7c501997-08-02 03:00:42 +0000395 return sts;
Guido van Rossum667d7041995-08-04 04:20:48 +0000396}
397
398
Guido van Rossum667d7041995-08-04 04:20:48 +0000399/* Make the *original* argc/argv available to other modules.
400 This is rare, but it is needed by the secureware extension. */
401
402void
Fredrik Lundh620f3772000-07-09 20:42:34 +0000403Py_GetArgcArgv(int *argc, char ***argv)
Guido van Rossum667d7041995-08-04 04:20:48 +0000404{
405 *argc = orig_argc;
406 *argv = orig_argv;
407}