comparison Python/pythonrun.c @ 18808:a8b1acc7a21f legacy-trunk

Add -E command line switch (ignore environment variables like PYTHONHOME and PYTHONPATH).
author Neil Schemenauer <nascheme@enme.ucalgary.ca>
date Mon, 23 Jul 2001 16:30:27 +0000
parents c9b4c8ae6179
children 09df3254b49d
comparison
equal deleted inserted replaced
18807:1b6868e89a23 18808:a8b1acc7a21f
61 int Py_InteractiveFlag; /* Needed by Py_FdIsInteractive() below */ 61 int Py_InteractiveFlag; /* Needed by Py_FdIsInteractive() below */
62 int Py_NoSiteFlag; /* Suppress 'import site' */ 62 int Py_NoSiteFlag; /* Suppress 'import site' */
63 int Py_UseClassExceptionsFlag = 1; /* Needed by bltinmodule.c: deprecated */ 63 int Py_UseClassExceptionsFlag = 1; /* Needed by bltinmodule.c: deprecated */
64 int Py_FrozenFlag; /* Needed by getpath.c */ 64 int Py_FrozenFlag; /* Needed by getpath.c */
65 int Py_UnicodeFlag = 0; /* Needed by compile.c */ 65 int Py_UnicodeFlag = 0; /* Needed by compile.c */
66 int Py_IgnoreEnvironmentFlag; /* e.g. PYTHONPATH, PYTHONHOME */
66 67
67 static int initialized = 0; 68 static int initialized = 0;
68 69
69 /* API to access the initialized flag -- useful for esoteric use */ 70 /* API to access the initialized flag -- useful for esoteric use */
70 71
96 97
97 if (initialized) 98 if (initialized)
98 return; 99 return;
99 initialized = 1; 100 initialized = 1;
100 101
101 if ((p = getenv("PYTHONDEBUG")) && *p != '\0') 102 if ((p = Py_GETENV("PYTHONDEBUG")) && *p != '\0')
102 Py_DebugFlag = Py_DebugFlag ? Py_DebugFlag : 1; 103 Py_DebugFlag = Py_DebugFlag ? Py_DebugFlag : 1;
103 if ((p = getenv("PYTHONVERBOSE")) && *p != '\0') 104 if ((p = Py_GETENV("PYTHONVERBOSE")) && *p != '\0')
104 Py_VerboseFlag = Py_VerboseFlag ? Py_VerboseFlag : 1; 105 Py_VerboseFlag = Py_VerboseFlag ? Py_VerboseFlag : 1;
105 if ((p = getenv("PYTHONOPTIMIZE")) && *p != '\0') 106 if ((p = Py_GETENV("PYTHONOPTIMIZE")) && *p != '\0')
106 Py_OptimizeFlag = Py_OptimizeFlag ? Py_OptimizeFlag : 1; 107 Py_OptimizeFlag = Py_OptimizeFlag ? Py_OptimizeFlag : 1;
107 108
108 interp = PyInterpreterState_New(); 109 interp = PyInterpreterState_New();
109 if (interp == NULL) 110 if (interp == NULL)
110 Py_FatalError("Py_Initialize: can't make first interpreter"); 111 Py_FatalError("Py_Initialize: can't make first interpreter");
223 #endif 224 #endif
224 225
225 #ifdef Py_TRACE_REFS 226 #ifdef Py_TRACE_REFS
226 if ( 227 if (
227 #ifdef MS_WINDOWS /* Only ask on Windows if env var set */ 228 #ifdef MS_WINDOWS /* Only ask on Windows if env var set */
228 getenv("PYTHONDUMPREFS") && 229 Py_GETENV("PYTHONDUMPREFS") &&
229 #endif /* MS_WINDOWS */ 230 #endif /* MS_WINDOWS */
230 _Py_AskYesNo("Print left references?")) { 231 _Py_AskYesNo("Print left references?")) {
231 _Py_PrintReferences(stderr); 232 _Py_PrintReferences(stderr);
232 } 233 }
233 #endif /* Py_TRACE_REFS */ 234 #endif /* Py_TRACE_REFS */
392 393
393 char * 394 char *
394 Py_GetPythonHome(void) 395 Py_GetPythonHome(void)
395 { 396 {
396 char *home = default_home; 397 char *home = default_home;
397 if (home == NULL) 398 if (home == NULL && !Py_IgnoreEnvironmentFlag)
398 home = getenv("PYTHONHOME"); 399 home = Py_GETENV("PYTHONHOME");
399 return home; 400 return home;
400 } 401 }
401 402
402 /* Create __main__ module */ 403 /* Create __main__ module */
403 404