mirror of
https://github.com/python/cpython.git
synced 2025-11-01 02:38:53 +00:00
bpo-30144: Import collections ABC from collections.abc rather than collections. (#1263)
This commit is contained in:
parent
9eb5ca0774
commit
2e576f5aec
22 changed files with 90 additions and 85 deletions
|
|
@ -1375,7 +1375,7 @@ Basic customization
|
|||
:meth:`__hash__` method of a class is ``None``, instances of the class will
|
||||
raise an appropriate :exc:`TypeError` when a program attempts to retrieve
|
||||
their hash value, and will also be correctly identified as unhashable when
|
||||
checking ``isinstance(obj, collections.Hashable)``.
|
||||
checking ``isinstance(obj, collections.abc.Hashable)``.
|
||||
|
||||
If a class that overrides :meth:`__eq__` needs to retain the implementation
|
||||
of :meth:`__hash__` from a parent class, the interpreter must be told this
|
||||
|
|
@ -1385,7 +1385,7 @@ Basic customization
|
|||
support, it should include ``__hash__ = None`` in the class definition.
|
||||
A class which defines its own :meth:`__hash__` that explicitly raises
|
||||
a :exc:`TypeError` would be incorrectly identified as hashable by
|
||||
an ``isinstance(obj, collections.Hashable)`` call.
|
||||
an ``isinstance(obj, collections.abc.Hashable)`` call.
|
||||
|
||||
|
||||
.. note::
|
||||
|
|
@ -1981,7 +1981,7 @@ range of items. It is also recommended that mappings provide the methods
|
|||
:meth:`keys`, :meth:`values`, :meth:`items`, :meth:`get`, :meth:`clear`,
|
||||
:meth:`setdefault`, :meth:`pop`, :meth:`popitem`, :meth:`!copy`, and
|
||||
:meth:`update` behaving similar to those for Python's standard dictionary
|
||||
objects. The :mod:`collections` module provides a
|
||||
objects. The :mod:`collections.abc` module provides a
|
||||
:class:`~collections.abc.MutableMapping`
|
||||
abstract base class to help create those methods from a base set of
|
||||
:meth:`__getitem__`, :meth:`__setitem__`, :meth:`__delitem__`, and :meth:`keys`.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue