]> granicus.if.org Git - python/commitdiff
Added a warning when -3 is enabled and None is passed to filter as the first argument.
authorDavid Wolever <david@wolever.net>
Tue, 18 Mar 2008 21:20:25 +0000 (21:20 +0000)
committerDavid Wolever <david@wolever.net>
Tue, 18 Mar 2008 21:20:25 +0000 (21:20 +0000)
Python/bltinmodule.c

index 8491ed410a57be527d81c9c9e0c323ca64339bc0..228bb2d01b3af927b62ec642e02519672d012627 100644 (file)
@@ -296,6 +296,13 @@ builtin_filter(PyObject *self, PyObject *args)
                }
 
                if (func == (PyObject *)&PyBool_Type || func == Py_None) {
+                       if (Py_Py3kWarningFlag &&
+                           PyErr_Warn(PyExc_DeprecationWarning,
+                                      "filter with None as a first argument "
+                                      "is not supported in 3.x.  Use a list "
+                                      "comprehension instead.") < 0)
+                               return NULL;
+
                        ok = PyObject_IsTrue(item);
                }
                else {