if ((inspect || (command == NULL && filename == NULL && module == NULL)) && isatty(fileno(stdin))) { PyObject *v; v = PyImport_ImportModule("readline"); if (v == NULL) PyErr_Clear(); else Py_DECREF(v); } if (command) { sts = PyRun_SimpleStringFlags(command, &cf) != 0; free(command); } else if (module) { sts = RunModule(module); free(module); } else { if (filename == NULL && stdin_is_interactive) { RunStartupFile(&cf); } /* XXX */ sts = PyRun_AnyFileExFlags( fp, filename == NULL ? "<stdin>" : filename, filename != NULL, &cf) != 0; } /* Check this environment variable at the end, to give programs the * opportunity to set it from Python. */ if (!saw_inspect_flag && (p = Py_GETENV("PYTHONINSPECT")) && *p != '\0') { inspect = 1; } if (inspect && stdin_is_interactive && (filename != NULL || command != NULL || module != NULL)) /* XXX */ sts = PyRun_AnyFileFlags(stdin, "<stdin>", &cf) != 0; WaitForThreadShutdown(); Py_Finalize();#ifdef RISCOS if (Py_RISCOSWimpFlag) fprintf(stderr, "\x0cq\x0c"); /* make frontend quit */#endif #ifdef __INSURE__ /* Insure++ is a memory analysis tool that aids in discovering * memory leaks and other memory problems. On Python exit, the * interned string dictionary is flagged as being in use at exit * (which it is). Under normal circumstances, this is fine because * the memory will be automatically reclaimed by the system. Under * memory debugging, it's a huge source of useless noise, so we * trade off slower shutdown for less distraction in the memory * reports. -baw */ _Py_ReleaseInternedStrings();#endif /* __INSURE__ */ return sts;} /* this is gonna seem *real weird*, but if you put some other code between Py_Main() and Py_GetArgcArgv() you will need to adjust the test in the while statement in Misc/gdbinit:ppystack */ /* Make the *original* argc/argv available to other modules. This is rare, but it is needed by the secureware extension. */ voidPy_GetArgcArgv(int *argc, char ***argv){ *argc = orig_argc; *argv = orig_argv;} #ifdef __cplusplus}#endif Lines 501–584 of 584. Previous lines
if ((inspect || (command == NULL && filename == NULL && module == NULL)) && isatty(fileno(stdin))) { PyObject *v; v = PyImport_ImportModule("readline"); if (v == NULL) PyErr_Clear(); else Py_DECREF(v); } if (command) { sts = PyRun_SimpleStringFlags(command, &cf) != 0; free(command); } else if (module) { sts = RunModule(module); free(module); } else { if (filename == NULL && stdin_is_interactive) { RunStartupFile(&cf); } /* XXX */ sts = PyRun_AnyFileExFlags( fp, filename == NULL ? "<stdin>" : filename, filename != NULL, &cf) != 0; } /* Check this environment variable at the end, to give programs the * opportunity to set it from Python. */ if (!saw_inspect_flag && (p = Py_GETENV("PYTHONINSPECT")) && *p != '\0') { inspect = 1; } if (inspect && stdin_is_interactive && (filename != NULL || command != NULL || module != NULL)) /* XXX */ sts = PyRun_AnyFileFlags(stdin, "<stdin>", &cf) != 0; WaitForThreadShutdown(); Py_Finalize(); #ifdef RISCOS if (Py_RISCOSWimpFlag) fprintf(stderr, "\x0cq\x0c"); /* make frontend quit */ #endif #ifdef __INSURE__ /* Insure++ is a memory analysis tool that aids in discovering * memory leaks and other memory problems. On Python exit, the * interned string dictionary is flagged as being in use at exit * (which it is). Under normal circumstances, this is fine because * the memory will be automatically reclaimed by the system. Under * memory debugging, it's a huge source of useless noise, so we * trade off slower shutdown for less distraction in the memory * reports. -baw */ _Py_ReleaseInternedStrings(); #endif /* __INSURE__ */ return sts; } /* this is gonna seem *real weird*, but if you put some other code between Py_Main() and Py_GetArgcArgv() you will need to adjust the test in the while statement in Misc/gdbinit:ppystack */ /* Make the *original* argc/argv available to other modules. This is rare, but it is needed by the secureware extension. */ void Py_GetArgcArgv(int *argc, char ***argv) { *argc = orig_argc; *argv = orig_argv; } #ifdef __cplusplus } #endif