]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
SF patch #467455 : Enhanced environment variables, by Toby Dickenson.
authorGuido van Rossum <guido@python.org>
Fri, 12 Oct 2001 22:17:56 +0000 (22:17 +0000)
committerGuido van Rossum <guido@python.org>
Fri, 12 Oct 2001 22:17:56 +0000 (22:17 +0000)
   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

Misc/python.man
Python/pythonrun.c

index 6723e13b2e0f7e839bfac0b677c45e4cf3767649..609c2ca147f3a2d8fa9d1fb74e289e10c6b499bc 100644 (file)
@@ -339,9 +339,14 @@ Set this to a non-empty string to cause the \fItime\fP module to
 require dates specified as strings to include 4-digit years, otherwise
 2-digit years are converted based on rules described in the \fItime\fP
 module documnetation.
+.IP PYTHONOPTIMIZE
+If this is set to a non-empty string it is equivalent to specifying
+the \fB\-O\fP option. If set to an integer, it is equivalent to
+specifying \fB\-O\fP multiple times.
 .IP PYTHONDEBUG
 If this is set to a non-empty string it is equivalent to specifying
-the \fB\-d\fP option.
+the \fB\-d\fP option. If set to an integer, it is equivalent to
+specifying \fB\-d\fP multiple times.
 .IP PYTHONINSPECT
 If this is set to a non-empty string it is equivalent to specifying
 the \fB\-i\fP option.
@@ -350,7 +355,8 @@ If this is set to a non-empty string it is equivalent to specifying
 the \fB\-u\fP option.
 .IP PYTHONVERBOSE
 If this is set to a non-empty string it is equivalent to specifying
-the \fB\-v\fP option.
+the \fB\-v\fP option. If set to an integer, it is equivalent to
+specifying \fB\-v\fP multiple times. 
 .SH AUTHOR
 .nf
 Guido van Rossum
index 8dd9c14c3b402852661b98ff2454263dc9253f0b..963df8a4ba33632d9b050cbd4485a087640d0d5f 100644 (file)
@@ -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)