Skip to content

Commit e6d3421

Browse files
authored
bpo-25988: Deprecate exposing collections.abc in collections GH-5414
1 parent 4f4ef0a commit e6d3421

File tree

4 files changed

+16
-5
lines changed

4 files changed

+16
-5
lines changed

Doc/library/collections.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,8 @@ Python's general purpose built-in containers, :class:`dict`, :class:`list`,
3535

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

4141

4242
:class:`ChainMap` objects

Doc/whatsnew/3.7.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -880,6 +880,11 @@ Other CPython Implementation Changes
880880
Deprecated
881881
==========
882882

883+
* In Python 3.8, the abstract base classes in :mod:`collections.abc` will no
884+
longer be exposed in the regular :mod:`collections` module. This will help
885+
create a clearer distinction between the concrete classes and the abstract
886+
base classes.
887+
883888
* Yield expressions (both ``yield`` and ``yield from`` clauses) are now deprecated
884889
in comprehensions and generator expressions (aside from the iterable expression
885890
in the leftmost :keyword:`for` clause). This ensures that comprehensions

Lib/collections/__init__.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,14 @@
1818
'UserString', 'Counter', 'OrderedDict', 'ChainMap']
1919

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

2630
from operator import itemgetter as _itemgetter, eq as _eq
2731
from keyword import iskeyword as _iskeyword
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Deprecate exposing the contents of collections.abc in the regular
2+
collections module.

0 commit comments

Comments
 (0)