]> granicus.if.org Git - python/commitdiff
New special case in comparisons: None is smaller than any other object
authorGuido van Rossum <guido@python.org>
Mon, 22 Jan 2001 19:28:09 +0000 (19:28 +0000)
committerGuido van Rossum <guido@python.org>
Mon, 22 Jan 2001 19:28:09 +0000 (19:28 +0000)
(unless the object's type overrides this comparison).

Objects/object.c

index b15e76e37c5a359d27575be15a58541105447def..c1a1303fb0cb06eccbe1929995c26d0cdc42ac43 100644 (file)
@@ -550,6 +550,12 @@ default_3way_compare(PyObject *v, PyObject *w)
                PyErr_Clear();
        }
 
+       /* None is smaller than anything */
+       if (v == Py_None)
+               return -1;
+       if (w == Py_None)
+               return 1;
+
        /* different type: compare type names */
        if (v->ob_type->tp_as_number)
                vname = "";