]> granicus.if.org Git - python/commitdiff
PEP 238 documented -Qwarn as warning only for classic int or long
authorGuido van Rossum <guido@python.org>
Tue, 4 Sep 2001 03:51:09 +0000 (03:51 +0000)
committerGuido van Rossum <guido@python.org>
Tue, 4 Sep 2001 03:51:09 +0000 (03:51 +0000)
division, and this makes sense.  Add -Qwarnall to warn for all
classic divisions, as required by the fixdiv.py tool.

Modules/main.c
Objects/complexobject.c
Objects/floatobject.c
Tools/scripts/fixdiv.py

index f38a5c3d84a4a08c1f832f5ade324deb744d0643..eea848fff5220e2c36b80505bd4d949c00a33b51 100644 (file)
@@ -58,7 +58,7 @@ Options and arguments (and corresponding environment variables):\n\
 static char *usage_2 = "\
 -O     : optimize generated bytecode (a tad; also PYTHONOPTIMIZE=x)\n\
 -OO    : remove doc-strings in addition to the -O optimizations\n\
--Q arg : division options: -Qold (default), -Qwarn, -Qnew\n\
+-Q arg : division options: -Qold (default), -Qwarn, -Qwarnall, -Qnew\n\
 -S     : don't imply 'import site' on initialization\n\
 -t     : issue warnings about inconsistent tab usage (-tt: issue errors)\n\
 -u     : unbuffered binary stdout and stderr (also PYTHONUNBUFFERED=x)\n\
@@ -161,7 +161,11 @@ Py_Main(int argc, char **argv)
                                break;
                        }
                        if (strcmp(_PyOS_optarg, "warn") == 0) {
-                               Py_DivisionWarningFlag++;
+                               Py_DivisionWarningFlag = 1;
+                               break;
+                       }
+                       if (strcmp(_PyOS_optarg, "warnall") == 0) {
+                               Py_DivisionWarningFlag = 2;
                                break;
                        }
                        if (strcmp(_PyOS_optarg, "new") == 0) {
@@ -170,8 +174,8 @@ Py_Main(int argc, char **argv)
                                break;
                        }
                        fprintf(stderr,
-                               "-Q option should be "
-                               "`-Qold', `-Qwarn' or `-Qnew' only\n");
+                               "-Q option should be `-Qold', "
+                               "`-Qwarn', `-Qwarnall', or `-Qnew' only\n");
                        usage(2, argv[0]);
                        /* NOTREACHED */
 
index 281de1325474e5e2e7789201ab48908d63ea0065..236f4d52427a18a7821d67a3c9a2f7b45392884c 100644 (file)
@@ -377,7 +377,7 @@ complex_classic_div(PyComplexObject *v, PyComplexObject *w)
 {
        Py_complex quot;
 
-       if (Py_DivisionWarningFlag &&
+       if (Py_DivisionWarningFlag >= 2 &&
            PyErr_Warn(PyExc_DeprecationWarning,
                       "classic complex division") < 0)
                return NULL;
index 8cd26b41dca9f437ae5cae2cbb6ca87d230f7aea..478e13174f27caa751540133f46d3b1fd06ed4aa 100644 (file)
@@ -419,7 +419,7 @@ float_classic_div(PyObject *v, PyObject *w)
        double a,b;
        CONVERT_TO_DOUBLE(v, a);
        CONVERT_TO_DOUBLE(w, b);
-       if (Py_DivisionWarningFlag &&
+       if (Py_DivisionWarningFlag >= 2 &&
            PyErr_Warn(PyExc_DeprecationWarning, "classic float division") < 0)
                return NULL;
        if (b == 0.0) {
index 175d77bd686e1cfc6356422521aead060bf03969..c6396d88a12253e12228b0be9c97a76d519a0dfd 100755 (executable)
@@ -2,7 +2,7 @@
 
 """fixdiv - tool to fix division operators.
 
-To use this tool, first run `python -Qwarn yourscript.py 2>warnings'.
+To use this tool, first run `python -Qwarnall yourscript.py 2>warnings'.
 This runs the script `yourscript.py' while writing warning messages
 about all uses of the classic division operator to the file
 `warnings'.  The warnings look like this: