[issue39111] Misleading documentation

2019-12-20 Thread Murali Ganapathy


New submission from Murali Ganapathy :

The documentation at 
https://docs.python.org/3.6/library/constants.html#NotImplemented states

If all attempts return NotImplemented, the interpreter will raise an 
appropriate exception. However this is not true for __eq__.

===
class Foo:
  def __eq__(self, other):
return NotImplemented

Foo() == Foo() # returns False, does not throw an exception


--
assignee: docs@python
components: Documentation
messages: 358719
nosy: docs@python, murali
priority: normal
severity: normal
status: open
title: Misleading documentation
versions: Python 3.5, Python 3.6, Python 3.7, Python 3.8, Python 3.9

___
Python tracker 
<https://bugs.python.org/issue39111>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue39111] Misleading documentation

2019-12-20 Thread Murali Ganapathy


Murali Ganapathy  added the comment:

===
# python3
class Base:
  def __eq__(self, other):
print("base called")
return super().__eq__(other)


class Foo(Base):

  def __eq__(self, other):
print("foo called")
return NotImplemented

Foo() == Foo()
# foo called
# foo called
False


Base.__eq__ is not called here. Is calling of object.__eq__ special cased?

--

___
Python tracker 
<https://bugs.python.org/issue39111>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com