Skip to content

Commit 0a80b93

Browse files
serhiy-storchakaJake Taylor
authored and
Jake Taylor
committed
bpo-25988: Do not expose abstract collection classes in the collections module. (pythonGH-10596)
1 parent 5b7179a commit 0a80b93

File tree

3 files changed

+7
-15
lines changed

3 files changed

+7
-15
lines changed

Doc/whatsnew/3.9.rst

+5
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,11 @@ Deprecated
195195
Removed
196196
=======
197197

198+
* The abstract base classes in :mod:`collections.abc` no longer are
199+
exposed in the regular :mod:`collections` module. This will help
200+
create a clearer distinction between the concrete classes and the abstract
201+
base classes.
202+
198203
* The undocumented ``sys.callstats()`` function has been removed. Since Python
199204
3.7, it was deprecated and always returned :const:`None`. It required a special
200205
build option ``CALL_PROFILE`` which was already removed in Python 3.7.

Lib/collections/__init__.py

-15
Original file line numberDiff line numberDiff line change
@@ -39,21 +39,6 @@
3939
pass
4040

4141

42-
def __getattr__(name):
43-
# For backwards compatibility, continue to make the collections ABCs
44-
# through Python 3.6 available through the collections module.
45-
# Note, no new collections ABCs were added in Python 3.7
46-
if name in _collections_abc.__all__:
47-
obj = getattr(_collections_abc, name)
48-
import warnings
49-
warnings.warn("Using or importing the ABCs from 'collections' instead "
50-
"of from 'collections.abc' is deprecated since Python 3.3, "
51-
"and in 3.9 it will stop working",
52-
DeprecationWarning, stacklevel=2)
53-
globals()[name] = obj
54-
return obj
55-
raise AttributeError(f'module {__name__!r} has no attribute {name!r}')
56-
5742
################################################################################
5843
### OrderedDict
5944
################################################################################
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
The abstract base classes in :mod:`collections.abc` no longer are exposed in
2+
the regular :mod:`collections` module.

0 commit comments

Comments
 (0)