[issue25210] Special-case NoneType() in do_richcompare()

Ezio Melotti report at bugs.python.org
Thu Sep 24 08:07:04 CEST 2015


Ezio Melotti added the comment:

This case is different from most of the others though, because while it talks about unorderable types, it provides an example showing two instances (hence the parentheses).

In these NoneType is correct:
>>> int(None)
TypeError: int() argument must be a string or a number, not 'NoneType'
>>> abs(None)
TypeError: bad operand type for abs(): 'NoneType'
>>> [][None]
TypeError: list indices must be integers, not NoneType

In this NoneType() is equivalent to the None singleton (and int() is a not-better-specified instance of int):
>>> 3 < None
TypeError: unorderable types: int() < NoneType()

So I would either special-case None, remove the () and the comment, or show both the types and the repr() of the two objects.

----------

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue25210>
_______________________________________


More information about the Python-bugs-list mailing list