Skip to content

bpo-25988: Deprecate exposing collections.abc in collections #5414

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jan 29, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Doc/library/collections.rst
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ Python's general purpose built-in containers, :class:`dict`, :class:`list`,

.. versionchanged:: 3.3
Moved :ref:`collections-abstract-base-classes` to the :mod:`collections.abc` module.
For backwards compatibility, they continue to be visible in this module
as well.
For backwards compatibility, they continue to be visible in this module through
Python 3.7. Subsequently, they will be removed entirely.


:class:`ChainMap` objects
Expand Down
5 changes: 5 additions & 0 deletions Doc/whatsnew/3.7.rst
Original file line number Diff line number Diff line change
Expand Up @@ -874,6 +874,11 @@ Other CPython Implementation Changes
Deprecated
==========

* In Python 3.8, the abstract base classes in :mod:`collections.abc` will no
longer be exposed in the regular :mod:`collections` module. This will help
create a clearer distinction between the concrete classes and the abstract
base classes.

* Yield expressions (both ``yield`` and ``yield from`` clauses) are now deprecated
in comprehensions and generator expressions (aside from the iterable expression
in the leftmost :keyword:`for` clause). This ensures that comprehensions
Expand Down
10 changes: 7 additions & 3 deletions Lib/collections/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,14 @@
'UserString', 'Counter', 'OrderedDict', 'ChainMap']

# For backwards compatibility, continue to make the collections ABCs
# available through the collections module.
from _collections_abc import *
# through Python 3.6 available through the collections module.
# Note, no new collections ABCs were added in Python 3.7
import _collections_abc
__all__ += _collections_abc.__all__
from _collections_abc import (AsyncGenerator, AsyncIterable, AsyncIterator,
Awaitable, ByteString, Callable, Collection, Container, Coroutine,
Generator, Hashable, ItemsView, Iterable, Iterator, KeysView, Mapping,
MappingView, MutableMapping, MutableSequence, MutableSet, Reversible,
Sequence, Set, Sized, ValuesView)

from operator import itemgetter as _itemgetter, eq as _eq
from keyword import iskeyword as _iskeyword
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Deprecate exposing the contents of collections.abc in the regular
collections module.