diff options
author | Guido van Rossum <guido@python.org> | 2001-10-12 22:17:56 (GMT) |
---|---|---|
committer | Guido van Rossum <guido@python.org> | 2001-10-12 22:17:56 (GMT) |
commit | 9abaf4d3b78d756e4c0e30b7accb70e531dd9085 (patch) | |
tree | aca9632a12b26f975e2df7977fadb696b9eced4a /Python/pythonrun.c | |
parent | 1566a17af583cbda271950572c82869199aeb1f0 (diff) | |
download | cpython-9abaf4d3b78d756e4c0e30b7accb70e531dd9085.zip cpython-9abaf4d3b78d756e4c0e30b7accb70e531dd9085.tar.gz cpython-9abaf4d3b78d756e4c0e30b7accb70e531dd9085.tar.bz2 |
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
Diffstat (limited to 'Python/pythonrun.c')
-rw-r--r-- | Python/pythonrun.c | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/Python/pythonrun.c b/Python/pythonrun.c index 8dd9c14..963df8a 100644 --- a/Python/pythonrun.c +++ b/Python/pythonrun.c @@ -87,6 +87,17 @@ Py_IsInitialized(void) */ +static int +add_flag(int flag, const char *envs) +{ + int env = atoi(envs); + if (flag < env) + flag = env; + if (flag < 1) + flag = 1; + return flag; +} + void Py_Initialize(void) { @@ -101,11 +112,11 @@ Py_Initialize(void) initialized = 1; if ((p = Py_GETENV("PYTHONDEBUG")) && *p != '\0') - Py_DebugFlag = Py_DebugFlag ? Py_DebugFlag : 1; + Py_DebugFlag = add_flag(Py_DebugFlag, p); if ((p = Py_GETENV("PYTHONVERBOSE")) && *p != '\0') - Py_VerboseFlag = Py_VerboseFlag ? Py_VerboseFlag : 1; + Py_VerboseFlag = add_flag(Py_VerboseFlag, p); if ((p = Py_GETENV("PYTHONOPTIMIZE")) && *p != '\0') - Py_OptimizeFlag = Py_OptimizeFlag ? Py_OptimizeFlag : 1; + Py_OptimizeFlag = add_flag(Py_OptimizeFlag, p); interp = PyInterpreterState_New(); if (interp == NULL) |