summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>2001-01-22 19:28:09 (GMT)
committerGuido van Rossum <guido@python.org>2001-01-22 19:28:09 (GMT)
commit0871e9315ec2395775f600baedacdcbcd4cb5f5c (patch)
treef9f3f90d272fa8d61955f424b01022eaf92a52a6
parent0f564eaceb55a4b14d003b03d62b1613aba9581a (diff)
downloadcpython-0871e9315ec2395775f600baedacdcbcd4cb5f5c.zip
cpython-0871e9315ec2395775f600baedacdcbcd4cb5f5c.tar.gz
cpython-0871e9315ec2395775f600baedacdcbcd4cb5f5c.tar.bz2
New special case in comparisons: None is smaller than any other object
(unless the object's type overrides this comparison).
-rw-r--r--Objects/object.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/Objects/object.c b/Objects/object.c
index b15e76e..c1a1303 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 = "";