[issue29986] Documentation recommends raising TypeError from tp_richcompare

R. David Murray report at bugs.python.org
Tue Apr 4 19:32:03 EDT 2017


R. David Murray added the comment:

The documentation is technically correct, as far as I can see.  Issue 8743 is not about disallowing certain comparison operations, but rather incorrectly implementing the earlier sentence in that same doc section: "If the comparison is undefined, it must return Py_NotImplemented".  Perhaps the wording should be changed so that instead of saying "only a limited set of comparisons makes sense" it says "if you wish to disallow certain comparison operations while allowing others".  It should also probably be demoted from being a '.. note', since it is, as you note, an exceptional case, not a common one.

But you might be right that it would be better to delete it altogether, since it is generally better to let the comparison machinery raise the error if none of the types implements the comparison...what would be the rationale for a blanket *dis*allowing of a particular comparison operation?  

Let's see what Raymond thinks.

----------
nosy: +r.david.murray, rhettinger

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


More information about the Python-bugs-list mailing list