mirror of
https://github.com/python/cpython.git
synced 2025-09-14 12:46:49 +00:00
New special case in comparisons: None is smaller than any other object
(unless the object's type overrides this comparison).
This commit is contained in:
parent
0f564eaceb
commit
0871e9315e
1 changed files with 6 additions and 0 deletions
|
@ -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 = "";
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue