From: Guido van Rossum Date: Mon, 22 Jan 2001 19:28:09 +0000 (+0000) Subject: New special case in comparisons: None is smaller than any other object X-Git-Tag: v2.1a1~25 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=0871e9315ec2395775f600baedacdcbcd4cb5f5c;p=python New special case in comparisons: None is smaller than any other object (unless the object's type overrides this comparison). --- diff --git a/Objects/object.c b/Objects/object.c index b15e76e37c..c1a1303fb0 100644 --- a/Objects/object.c +++ b/Objects/object.c @@ -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 = "";