summaryrefslogtreecommitdiffstats
path: root/Modules
diff options
context:
space:
mode:
Diffstat (limited to 'Modules')
-rw-r--r--Modules/getpath.c2
-rw-r--r--Modules/main.c25
-rw-r--r--Modules/timemodule.c2
3 files changed, 20 insertions, 9 deletions
diff --git a/Modules/getpath.c b/Modules/getpath.c
index c7567f7..2fd8f75 100644
--- a/Modules/getpath.c
+++ b/Modules/getpath.c
@@ -365,7 +365,7 @@ calculate_path(void)
static char delimiter[2] = {DELIM, '\0'};
static char separator[2] = {SEP, '\0'};
char *pythonpath = PYTHONPATH;
- char *rtpypath = getenv("PYTHONPATH");
+ char *rtpypath = Py_GETENV("PYTHONPATH");
char *home = Py_GetPythonHome();
char *path = getenv("PATH");
char *prog = Py_GetProgramName();
diff --git a/Modules/main.c b/Modules/main.c
index 72b756b..ad2616d 100644
--- a/Modules/main.c
+++ b/Modules/main.c
@@ -28,7 +28,7 @@ static char **orig_argv;
static int orig_argc;
/* command line options */
-#define BASE_OPTS "c:diOStuUvxXhVW:"
+#define BASE_OPTS "c:diOSEtuUvxXhVW:"
#ifndef RISCOS
#define PROGRAM_OPTS BASE_OPTS
@@ -53,6 +53,7 @@ Options and arguments (and corresponding environment variables):\n\
-O : optimize generated bytecode (a tad; also PYTHONOPTIMIZE=x)\n\
-OO : remove doc-strings in addition to the -O optimizations\n\
-S : don't imply 'import site' on initialization\n\
+-E : ignore environment variables (such as PYTHONPATH)\n\
-t : issue warnings about inconsistent tab usage (-tt: issue errors)\n\
";
static char *usage_mid = "\
@@ -108,6 +109,8 @@ Py_Main(int argc, char **argv)
int stdin_is_interactive = 0;
int help = 0;
int version = 0;
+ int saw_inspect_flag = 0;
+ int saw_unbuffered_flag = 0;
PyCompilerFlags cf;
orig_argc = argc; /* For Py_GetArgcArgv() */
@@ -117,11 +120,6 @@ Py_Main(int argc, char **argv)
Py_RISCOSWimpFlag = 0;
#endif
- if ((p = getenv("PYTHONINSPECT")) && *p != '\0')
- inspect = 1;
- if ((p = getenv("PYTHONUNBUFFERED")) && *p != '\0')
- unbuffered = 1;
-
PySys_ResetWarnOptions();
while ((c = _PyOS_GetOpt(argc, argv, PROGRAM_OPTS)) != EOF) {
@@ -146,6 +144,7 @@ Py_Main(int argc, char **argv)
case 'i':
inspect++;
+ saw_inspect_flag = 1;
Py_InteractiveFlag++;
break;
@@ -157,12 +156,17 @@ Py_Main(int argc, char **argv)
Py_NoSiteFlag++;
break;
+ case 'E':
+ Py_IgnoreEnvironmentFlag++;
+ break;
+
case 't':
Py_TabcheckFlag++;
break;
case 'u':
unbuffered++;
+ saw_unbuffered_flag = 1;
break;
case 'v':
@@ -210,6 +214,13 @@ Py_Main(int argc, char **argv)
exit(0);
}
+ if (!saw_inspect_flag &&
+ (p = Py_GETENV("PYTHONINSPECT")) && *p != '\0')
+ inspect = 1;
+ if (!saw_unbuffered_flag &&
+ (p = Py_GETENV("PYTHONUNBUFFERED")) && *p != '\0')
+ unbuffered = 1;
+
if (command == NULL && _PyOS_optind < argc &&
strcmp(argv[_PyOS_optind], "-") != 0)
{
@@ -307,7 +318,7 @@ Py_Main(int argc, char **argv)
}
else {
if (filename == NULL && stdin_is_interactive) {
- char *startup = getenv("PYTHONSTARTUP");
+ char *startup = Py_GETENV("PYTHONSTARTUP");
if (startup != NULL && startup[0] != '\0') {
FILE *fp = fopen(startup, "r");
if (fp != NULL) {
diff --git a/Modules/timemodule.c b/Modules/timemodule.c
index 0a54a93..50e4053 100644
--- a/Modules/timemodule.c
+++ b/Modules/timemodule.c
@@ -594,7 +594,7 @@ inittime(void)
m = Py_InitModule3("time", time_methods, module_doc);
d = PyModule_GetDict(m);
/* Accept 2-digit dates unless PYTHONY2K is set and non-empty */
- p = getenv("PYTHONY2K");
+ p = Py_GETENV("PYTHONY2K");
ins(d, "accept2dyear", PyInt_FromLong((long) (!p || !*p)));
/* Squirrel away the module's dictionary for the y2k check */
Py_INCREF(d);