summaryrefslogtreecommitdiffstats
path: root/Lib
diff options
context:
space:
mode:
authorRaymond Hettinger <python@rcn.com>2011-02-22 00:41:50 (GMT)
committerRaymond Hettinger <python@rcn.com>2011-02-22 00:41:50 (GMT)
commit158c9c26fca16dee2f7a8d89707cf9c149bd04f2 (patch)
tree0d2dc227cb3abcf338e4dd4883fe5469f7c10d4e /Lib
parentecc26923cd8a0a3511e1fb89b4b13d74a1391b87 (diff)
downloadcpython-158c9c26fca16dee2f7a8d89707cf9c149bd04f2.zip
cpython-158c9c26fca16dee2f7a8d89707cf9c149bd04f2.tar.gz
cpython-158c9c26fca16dee2f7a8d89707cf9c149bd04f2.tar.bz2
Issue #11085: Moved collections abstract base classes into a separate module
called collections.abc, following the pattern used by importlib.abc. For backwards compatibility, the names continue to also be imported into the collections module.
Diffstat (limited to 'Lib')
-rw-r--r--Lib/collections/__init__.py (renamed from Lib/collections.py)11
-rw-r--r--Lib/collections/abc.py (renamed from Lib/_abcoll.py)4
-rw-r--r--Lib/os.py2
-rwxr-xr-xLib/test/regrtest.py9
4 files changed, 13 insertions, 13 deletions
diff --git a/Lib/collections.py b/Lib/collections/__init__.py
index 2f19459..6c41db3 100644
--- a/Lib/collections.py
+++ b/Lib/collections/__init__.py
@@ -1,10 +1,11 @@
__all__ = ['deque', 'defaultdict', 'namedtuple', 'UserDict', 'UserList',
'UserString', 'Counter', 'OrderedDict']
-# For bootstrapping reasons, the collection ABCs are defined in _abcoll.py.
-# They should however be considered an integral part of collections.py.
-from _abcoll import *
-import _abcoll
-__all__ += _abcoll.__all__
+
+# For backwards compatability, continue to make the collections ABCs
+# available through the collections module.
+from collections.abc import *
+import collections.abc
+__all__ += collections.abc.__all__
from _collections import deque, defaultdict
from operator import itemgetter as _itemgetter
diff --git a/Lib/_abcoll.py b/Lib/collections/abc.py
index 2417d18..6e908bd 100644
--- a/Lib/_abcoll.py
+++ b/Lib/collections/abc.py
@@ -3,9 +3,7 @@
"""Abstract Base Classes (ABCs) for collections, according to PEP 3119.
-DON'T USE THIS MODULE DIRECTLY! The classes here should be imported
-via collections; they are defined here only to alleviate certain
-bootstrapping issues. Unit tests are in test_collections.
+Unit tests are in test_collections.
"""
from abc import ABCMeta, abstractmethod
diff --git a/Lib/os.py b/Lib/os.py
index 3ef3db8..9720479 100644
--- a/Lib/os.py
+++ b/Lib/os.py
@@ -434,7 +434,7 @@ def get_exec_path(env=None):
# Change environ to automatically call putenv(), unsetenv if they exist.
-from _abcoll import MutableMapping # Can't use collections (bootstrap)
+from collections.abc import MutableMapping
class _Environ(MutableMapping):
def __init__(self, data, encodekey, decodekey, encodevalue, decodevalue, putenv, unsetenv):
diff --git a/Lib/test/regrtest.py b/Lib/test/regrtest.py
index 440c01d..6267702 100755
--- a/Lib/test/regrtest.py
+++ b/Lib/test/regrtest.py
@@ -1056,7 +1056,8 @@ def dash_R(the_module, test, indirect_test, huntrleaks):
False if the test didn't leak references; True if we detected refleaks.
"""
# This code is hackish and inelegant, but it seems to do the job.
- import copyreg, _abcoll
+ import copyreg
+ import collections.abc
if not hasattr(sys, 'gettotalrefcount'):
raise Exception("Tracking reference leaks requires a debug build "
@@ -1073,7 +1074,7 @@ def dash_R(the_module, test, indirect_test, huntrleaks):
else:
zdc = zipimport._zip_directory_cache.copy()
abcs = {}
- for abc in [getattr(_abcoll, a) for a in _abcoll.__all__]:
+ for abc in [getattr(collections.abc, a) for a in collections.abc.__all__]:
if not isabstract(abc):
continue
for obj in abc.__subclasses__() + [abc]:
@@ -1119,7 +1120,7 @@ def dash_R_cleanup(fs, ps, pic, zdc, abcs):
import gc, copyreg
import _strptime, linecache
import urllib.parse, urllib.request, mimetypes, doctest
- import struct, filecmp, _abcoll
+ import struct, filecmp, collections.abc
from distutils.dir_util import _path_created
from weakref import WeakSet
@@ -1146,7 +1147,7 @@ def dash_R_cleanup(fs, ps, pic, zdc, abcs):
sys._clear_type_cache()
# Clear ABC registries, restoring previously saved ABC registries.
- for abc in [getattr(_abcoll, a) for a in _abcoll.__all__]:
+ for abc in [getattr(collections.abc, a) for a in collections.abc.__all__]:
if not isabstract(abc):
continue
for obj in abc.__subclasses__() + [abc]: