comparison Python/pythonrun.c @ 20401:b74610c92d8b legacy-trunk

SF patch #467455 : Enhanced environment variables, by Toby Dickenson. This patch changes to logic to: if env.var. set and non-empty: if env.var. is an integer: set flag to that integer if flag is zero: # [actually, <= 0 --GvR] set flag to 1 Under this patch, anyone currently using PYTHONVERBOSE=yes will get the same output as before. PYTHONVERBNOSE=2 will generate more verbosity than before. The only unusual case that the following three are still all equivalent: PYTHONVERBOSE=yespleas PYTHONVERBOSE=1 PYTHONVERBOSE=0
author Guido van Rossum <guido@python.org>
date Fri, 12 Oct 2001 22:17:56 +0000
parents c0a44829bcd5
children c1ecafd15560
comparison
equal deleted inserted replaced
20400:65790562033c 20401:b74610c92d8b
85 (If the lock has not yet been initialized, that's equivalent to 85 (If the lock has not yet been initialized, that's equivalent to
86 having the lock, but you cannot use multiple threads.) 86 having the lock, but you cannot use multiple threads.)
87 87
88 */ 88 */
89 89
90 static int
91 add_flag(int flag, const char *envs)
92 {
93 int env = atoi(envs);
94 if (flag < env)
95 flag = env;
96 if (flag < 1)
97 flag = 1;
98 return flag;
99 }
100
90 void 101 void
91 Py_Initialize(void) 102 Py_Initialize(void)
92 { 103 {
93 PyInterpreterState *interp; 104 PyInterpreterState *interp;
94 PyThreadState *tstate; 105 PyThreadState *tstate;
99 if (initialized) 110 if (initialized)
100 return; 111 return;
101 initialized = 1; 112 initialized = 1;
102 113
103 if ((p = Py_GETENV("PYTHONDEBUG")) && *p != '\0') 114 if ((p = Py_GETENV("PYTHONDEBUG")) && *p != '\0')
104 Py_DebugFlag = Py_DebugFlag ? Py_DebugFlag : 1; 115 Py_DebugFlag = add_flag(Py_DebugFlag, p);
105 if ((p = Py_GETENV("PYTHONVERBOSE")) && *p != '\0') 116 if ((p = Py_GETENV("PYTHONVERBOSE")) && *p != '\0')
106 Py_VerboseFlag = Py_VerboseFlag ? Py_VerboseFlag : 1; 117 Py_VerboseFlag = add_flag(Py_VerboseFlag, p);
107 if ((p = Py_GETENV("PYTHONOPTIMIZE")) && *p != '\0') 118 if ((p = Py_GETENV("PYTHONOPTIMIZE")) && *p != '\0')
108 Py_OptimizeFlag = Py_OptimizeFlag ? Py_OptimizeFlag : 1; 119 Py_OptimizeFlag = add_flag(Py_OptimizeFlag, p);
109 120
110 interp = PyInterpreterState_New(); 121 interp = PyInterpreterState_New();
111 if (interp == NULL) 122 if (interp == NULL)
112 Py_FatalError("Py_Initialize: can't make first interpreter"); 123 Py_FatalError("Py_Initialize: can't make first interpreter");
113 124