diff options
author | Neil Schemenauer <nascheme@enme.ucalgary.ca> | 2001-07-23 16:30:27 (GMT) |
---|---|---|
committer | Neil Schemenauer <nascheme@enme.ucalgary.ca> | 2001-07-23 16:30:27 (GMT) |
commit | 7d4bb9f179f1888a472fd5d5a30df4ec3c55fea5 (patch) | |
tree | 6b57c0d5016d8f919397303aaaa11cf610e1dd9d /Python | |
parent | f973c6d5949bfed3e74b8b94c427c43df1e4b95c (diff) | |
download | cpython-7d4bb9f179f1888a472fd5d5a30df4ec3c55fea5.zip cpython-7d4bb9f179f1888a472fd5d5a30df4ec3c55fea5.tar.gz cpython-7d4bb9f179f1888a472fd5d5a30df4ec3c55fea5.tar.bz2 |
Add -E command line switch (ignore environment variables like PYTHONHOME
and PYTHONPATH).
Diffstat (limited to 'Python')
-rw-r--r-- | Python/frozenmain.c | 4 | ||||
-rw-r--r-- | Python/import.c | 8 | ||||
-rw-r--r-- | Python/pythonrun.c | 13 |
3 files changed, 13 insertions, 12 deletions
diff --git a/Python/frozenmain.c b/Python/frozenmain.c index a03a2f8..efc87d7 100644 --- a/Python/frozenmain.c +++ b/Python/frozenmain.c @@ -30,9 +30,9 @@ Py_FrozenMain(int argc, char **argv) Py_FrozenFlag = 1; /* Suppress errors from getpath.c */ - if ((p = getenv("PYTHONINSPECT")) && *p != '\0') + if ((p = Py_GETENV("PYTHONINSPECT")) && *p != '\0') inspect = 1; - if ((p = getenv("PYTHONUNBUFFERED")) && *p != '\0') + if ((p = Py_GETENV("PYTHONUNBUFFERED")) && *p != '\0') unbuffered = 1; if (unbuffered) { diff --git a/Python/import.c b/Python/import.c index 456a5be..82524f6 100644 --- a/Python/import.c +++ b/Python/import.c @@ -1069,7 +1069,7 @@ case_ok(char *buf, int len, int namelen, char *name) char tempbuf[MAX_PATH]; #endif - if (getenv("PYTHONCASEOK") != NULL) + if (Py_GETENV("PYTHONCASEOK") != NULL) return 1; #ifdef __CYGWIN__ @@ -1092,7 +1092,7 @@ case_ok(char *buf, int len, int namelen, char *name) struct ffblk ffblk; int done; - if (getenv("PYTHONCASEOK") != NULL) + if (Py_GETENV("PYTHONCASEOK") != NULL) return 1; done = findfirst(buf, &ffblk, FA_ARCH|FA_RDONLY|FA_HIDDEN|FA_DIREC); @@ -1109,7 +1109,7 @@ case_ok(char *buf, int len, int namelen, char *name) FSSpec fss; OSErr err; - if (getenv("PYTHONCASEOK") != NULL) + if (Py_GETENV("PYTHONCASEOK") != NULL) return 1; #ifndef USE_GUSI1 @@ -1147,7 +1147,7 @@ case_ok(char *buf, int len, int namelen, char *name) char dirname[MAXPATHLEN + 1]; const int dirlen = len - namelen - 1; /* don't want trailing SEP */ - if (getenv("PYTHONCASEOK") != NULL) + if (Py_GETENV("PYTHONCASEOK") != NULL) return 1; /* Copy the dir component into dirname; substitute "." if empty */ diff --git a/Python/pythonrun.c b/Python/pythonrun.c index fbc3b16..c74b062 100644 --- a/Python/pythonrun.c +++ b/Python/pythonrun.c @@ -63,6 +63,7 @@ int Py_NoSiteFlag; /* Suppress 'import site' */ int Py_UseClassExceptionsFlag = 1; /* Needed by bltinmodule.c: deprecated */ int Py_FrozenFlag; /* Needed by getpath.c */ int Py_UnicodeFlag = 0; /* Needed by compile.c */ +int Py_IgnoreEnvironmentFlag; /* e.g. PYTHONPATH, PYTHONHOME */ static int initialized = 0; @@ -98,11 +99,11 @@ Py_Initialize(void) return; initialized = 1; - if ((p = getenv("PYTHONDEBUG")) && *p != '\0') + if ((p = Py_GETENV("PYTHONDEBUG")) && *p != '\0') Py_DebugFlag = Py_DebugFlag ? Py_DebugFlag : 1; - if ((p = getenv("PYTHONVERBOSE")) && *p != '\0') + if ((p = Py_GETENV("PYTHONVERBOSE")) && *p != '\0') Py_VerboseFlag = Py_VerboseFlag ? Py_VerboseFlag : 1; - if ((p = getenv("PYTHONOPTIMIZE")) && *p != '\0') + if ((p = Py_GETENV("PYTHONOPTIMIZE")) && *p != '\0') Py_OptimizeFlag = Py_OptimizeFlag ? Py_OptimizeFlag : 1; interp = PyInterpreterState_New(); @@ -225,7 +226,7 @@ Py_Finalize(void) #ifdef Py_TRACE_REFS if ( #ifdef MS_WINDOWS /* Only ask on Windows if env var set */ - getenv("PYTHONDUMPREFS") && + Py_GETENV("PYTHONDUMPREFS") && #endif /* MS_WINDOWS */ _Py_AskYesNo("Print left references?")) { _Py_PrintReferences(stderr); @@ -394,8 +395,8 @@ char * Py_GetPythonHome(void) { char *home = default_home; - if (home == NULL) - home = getenv("PYTHONHOME"); + if (home == NULL && !Py_IgnoreEnvironmentFlag) + home = Py_GETENV("PYTHONHOME"); return home; } |