From 95262b1d62a5cea5e783e76fa54569cd5005b0ee Mon Sep 17 00:00:00 2001 From: Serhiy Storchaka Date: Mon, 19 Nov 2018 10:24:01 +0200 Subject: [PATCH 1/3] bpo-25988: Do not expose abstract collection classes in the collections module. --- Doc/whatsnew/3.8.rst | 5 +++++ Lib/collections/__init__.py | 15 --------------- .../2018-11-19-10-23-58.bpo-25988.6o7gGK.rst | 2 ++ 3 files changed, 7 insertions(+), 15 deletions(-) create mode 100644 Misc/NEWS.d/next/Library/2018-11-19-10-23-58.bpo-25988.6o7gGK.rst diff --git a/Doc/whatsnew/3.8.rst b/Doc/whatsnew/3.8.rst index 154fd66630ead9..6e5bc65e9c4064 100644 --- a/Doc/whatsnew/3.8.rst +++ b/Doc/whatsnew/3.8.rst @@ -557,6 +557,11 @@ The following features and APIs have been removed from Python 3.8: * Removed the ``doctype()`` method of :class:`~xml.etree.ElementTree.XMLParser`. (Contributed by Serhiy Storchaka in :issue:`29209`.) +* The abstract base classes in :mod:`collections.abc` no longer are + exposed in the regular :mod:`collections` module. This will help + create a clearer distinction between the concrete classes and the abstract + base classes. + Porting to Python 3.8 ===================== diff --git a/Lib/collections/__init__.py b/Lib/collections/__init__.py index 632a509d316cb3..c270dbe69f7f15 100644 --- a/Lib/collections/__init__.py +++ b/Lib/collections/__init__.py @@ -39,21 +39,6 @@ pass -def __getattr__(name): - # For backwards compatibility, continue to make the collections ABCs - # through Python 3.6 available through the collections module. - # Note, no new collections ABCs were added in Python 3.7 - if name in _collections_abc.__all__: - obj = getattr(_collections_abc, name) - import warnings - warnings.warn("Using or importing the ABCs from 'collections' instead " - "of from 'collections.abc' is deprecated, " - "and in 3.8 it will stop working", - DeprecationWarning, stacklevel=2) - globals()[name] = obj - return obj - raise AttributeError(f'module {__name__!r} has no attribute {name!r}') - ################################################################################ ### OrderedDict ################################################################################ diff --git a/Misc/NEWS.d/next/Library/2018-11-19-10-23-58.bpo-25988.6o7gGK.rst b/Misc/NEWS.d/next/Library/2018-11-19-10-23-58.bpo-25988.6o7gGK.rst new file mode 100644 index 00000000000000..21d25e8d74ced6 --- /dev/null +++ b/Misc/NEWS.d/next/Library/2018-11-19-10-23-58.bpo-25988.6o7gGK.rst @@ -0,0 +1,2 @@ +The abstract base classes in :mod:`collections.abc` no longer are exposed in +the regular :mod:`collections` module. From b00c26df8bc6286d574d0fba9fbcd1a3c0901b17 Mon Sep 17 00:00:00 2001 From: Serhiy Storchaka Date: Sun, 4 Aug 2019 14:20:04 +0300 Subject: [PATCH 2/3] Move a What's New entry from 3.8 to 3.9. --- Doc/whatsnew/3.9.rst | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Doc/whatsnew/3.9.rst b/Doc/whatsnew/3.9.rst index 61d9e745e87ccf..8ec106935c98bd 100644 --- a/Doc/whatsnew/3.9.rst +++ b/Doc/whatsnew/3.9.rst @@ -163,6 +163,11 @@ Deprecated Removed ======= +* The abstract base classes in :mod:`collections.abc` no longer are + exposed in the regular :mod:`collections` module. This will help + create a clearer distinction between the concrete classes and the abstract + base classes. + * The undocumented ``sys.callstats()`` function has been removed. Since Python 3.7, it was deprecated and always returned ``None``. It required a special build option ``CALL_PROFILE`` which was already removed in Python 3.7. From 9bc44f2a3189280dbf81a2bacf0312db4426eba6 Mon Sep 17 00:00:00 2001 From: Serhiy Storchaka Date: Sun, 4 Aug 2019 16:21:25 +0300 Subject: [PATCH 3/3] Remove a note from 3.8. --- Doc/whatsnew/3.8.rst | 5 ----- 1 file changed, 5 deletions(-) diff --git a/Doc/whatsnew/3.8.rst b/Doc/whatsnew/3.8.rst index 068f4059fe9bcb..0455688841fbf8 100644 --- a/Doc/whatsnew/3.8.rst +++ b/Doc/whatsnew/3.8.rst @@ -1228,11 +1228,6 @@ The following features and APIs have been removed from Python 3.8: * Removed the ``doctype()`` method of :class:`~xml.etree.ElementTree.XMLParser`. (Contributed by Serhiy Storchaka in :issue:`29209`.) -* The abstract base classes in :mod:`collections.abc` no longer are - exposed in the regular :mod:`collections` module. This will help - create a clearer distinction between the concrete classes and the abstract - base classes. - * "unicode_internal" codec is removed. (Contributed by Inada Naoki in :issue:`36297`.)