Message257062
This sounds good. Also, reversed() could then be modified to produce a
better error. (The "unhashable" error comes from the hash() builtin, so
that's also a precedent.)
On Sat, Dec 26, 2015 at 4:32 PM, Andrew Barnert <report@bugs.python.org>
wrote:
>
> Andrew Barnert added the comment:
>
> As mentioned in #25958, Guido pointed out on -ideas that `__hash__ = None`
> is already the standard way to declare a class unhashable, and it's
> recognized by `collections.abc.Hashable`.
>
> Doing `__reversed__ = None` does make `reversed(m)` raise a `TypeError`
> (although with a description saying "'NoneType' is not callable", which
> isn't quite as nice a description, but probably good enough).
>
> So, I think `Mapping` should set `__reversed__ = None`, rather than
> setting it to a method that raises `TypeError`. (If we need something more
> general, that's for #25958 and/or Serhiy's typechecking bug.)
>
> ----------
>
> _______________________________________
> Python tracker <report@bugs.python.org>
> <http://bugs.python.org/issue25864>
> _______________________________________
> |
|
Date |
User |
Action |
Args |
2015-12-27 02:24:23 | gvanrossum | set | recipients:
+ gvanrossum, rhettinger, terry.reedy, r.david.murray, serhiy.storchaka, abarnert, abarry, curioswati |
2015-12-27 02:24:23 | gvanrossum | link | issue25864 messages |
2015-12-27 02:24:23 | gvanrossum | create | |
|