Kaydet (Commit) 6caea370 authored tarafından Martin v. Löwis's avatar Martin v. Löwis

Patch #794400: Let PYTHONSTARTUP influence the compiler flags.

üst b61982ba
...@@ -12,6 +12,8 @@ What's New in Python 2.4 alpha 1? ...@@ -12,6 +12,8 @@ What's New in Python 2.4 alpha 1?
Core and builtins Core and builtins
----------------- -----------------
- Compiler flags set in PYTHONSTARTUP are now active in __main__.
- Added two builtin types, set() and frozenset(). - Added two builtin types, set() and frozenset().
- Critical bugfix, for SF bug 840829: if cyclic garbage collection - Critical bugfix, for SF bug 840829: if cyclic garbage collection
......
...@@ -117,6 +117,19 @@ usage(int exitcode, char* program) ...@@ -117,6 +117,19 @@ usage(int exitcode, char* program)
/*NOTREACHED*/ /*NOTREACHED*/
} }
static void RunStartupFile(PyCompilerFlags *cf)
{
char *startup = Py_GETENV("PYTHONSTARTUP");
if (startup != NULL && startup[0] != '\0') {
FILE *fp = fopen(startup, "r");
if (fp != NULL) {
(void) PyRun_SimpleFileExFlags(fp, startup, 0, cf);
PyErr_Clear();
fclose(fp);
}
}
}
/* Main program */ /* Main program */
...@@ -401,15 +414,7 @@ Py_Main(int argc, char **argv) ...@@ -401,15 +414,7 @@ Py_Main(int argc, char **argv)
} }
else { else {
if (filename == NULL && stdin_is_interactive) { if (filename == NULL && stdin_is_interactive) {
char *startup = Py_GETENV("PYTHONSTARTUP"); RunStartupFile(&cf);
if (startup != NULL && startup[0] != '\0') {
FILE *fp = fopen(startup, "r");
if (fp != NULL) {
(void) PyRun_SimpleFile(fp, startup);
PyErr_Clear();
fclose(fp);
}
}
} }
/* XXX */ /* XXX */
sts = PyRun_AnyFileExFlags( sts = PyRun_AnyFileExFlags(
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment