Andrew Barnert added the comment:

> I did actually mean a version changed notice for the data model change. I see 
> this as a small expansion of the Python object API. Previously, 
> __reversed__() had to be a function, now you are also allowed to set it to 
> None. The collections ABCs are just catching up with the API change.

Are you suggesting that in Python 3.5, it's not defined what happens if you set 
__reversed__ = None on a sequence-like object and then call reversed()? I think 
any implementation has to raise a TypeError; the only difference is that we're 
now documenting the behavior directly, rather than forcing you to infer it from 
reading a half-dozen different parts of the docs and tracing through the 
implied behavior. It's already the best way to do it in 3.5, or even 2.5; the 
problem is that it isn't _obviously_ the best way. And I think a 
version-changed would send the wrong message: someone might think, "Oh, I can't 
use None here because I can't require 3.6, so what should I do? Write a method 
that raises TypeError when called?" (Which will work, but will then make it 
very hard to write a Reversible implicit ABC if they later want to.)

> Imagine someone using an Orderable virtual base class that tested for 
> __gt__() etc.

That's part of what we're trying to solve. Do you test that with hasattr, like 
Sized, or do you test for getattr with default None, like Hashable?

----------

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue25958>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to