]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
Patch #794400: Let PYTHONSTARTUP influence the compiler flags.
authorMartin v. Löwis <martin@v.loewis.de>
Tue, 18 Nov 2003 19:46:25 +0000 (19:46 +0000)
committerMartin v. Löwis <martin@v.loewis.de>
Tue, 18 Nov 2003 19:46:25 +0000 (19:46 +0000)
Misc/NEWS
Modules/main.c

index 444231e26ae9f8997d4fcc73cc0e064acb3f739d..ecc242ab7dc911f2d6c5b6b0874aa82628c24dd6 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -12,6 +12,8 @@ What's New in Python 2.4 alpha 1?
 Core and builtins
 -----------------
 
+- Compiler flags set in PYTHONSTARTUP are now active in __main__.
+
 - Added two builtin types, set() and frozenset().
 
 - Critical bugfix, for SF bug 840829:  if cyclic garbage collection
index 2cb2b64465e7b0d1e12015697b9237ed70c44eb0..91818e0df74b51a6b04164bb7009e9a688e670ea 100644 (file)
@@ -117,6 +117,19 @@ usage(int exitcode, char* program)
        /*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 */
 
@@ -401,15 +414,7 @@ Py_Main(int argc, char **argv)
        }
        else {
                if (filename == NULL && stdin_is_interactive) {
-                       char *startup = Py_GETENV("PYTHONSTARTUP");
-                       if (startup != NULL && startup[0] != '\0') {
-                               FILE *fp = fopen(startup, "r");
-                               if (fp != NULL) {
-                                       (void) PyRun_SimpleFile(fp, startup);
-                                       PyErr_Clear();
-                                       fclose(fp);
-                               }
-                       }
+                       RunStartupFile(&cf);
                }
                /* XXX */
                sts = PyRun_AnyFileExFlags(