Kaydet (Commit) 0871e931 authored tarafından Guido van Rossum's avatar Guido van Rossum

New special case in comparisons: None is smaller than any other object

(unless the object's type overrides this comparison).
üst 0f564eac
...@@ -550,6 +550,12 @@ default_3way_compare(PyObject *v, PyObject *w) ...@@ -550,6 +550,12 @@ default_3way_compare(PyObject *v, PyObject *w)
PyErr_Clear(); PyErr_Clear();
} }
/* None is smaller than anything */
if (v == Py_None)
return -1;
if (w == Py_None)
return 1;
/* different type: compare type names */ /* different type: compare type names */
if (v->ob_type->tp_as_number) if (v->ob_type->tp_as_number)
vname = ""; vname = "";
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment