[Python-checkins] r88521 - in python/branches/py3k/Lib: configparser.py random.py test/support.py test/test_collections.py test/test_nntplib.py test/test_shelve.py test/test_xmlrpc_net.py

raymond.hettinger python-checkins at python.org
Wed Feb 23 01:46:29 CET 2011


Author: raymond.hettinger
Date: Wed Feb 23 01:46:28 2011
New Revision: 88521

Log:
Fix imports from collections.abc

Modified:
   python/branches/py3k/Lib/configparser.py
   python/branches/py3k/Lib/random.py
   python/branches/py3k/Lib/test/support.py
   python/branches/py3k/Lib/test/test_collections.py
   python/branches/py3k/Lib/test/test_nntplib.py
   python/branches/py3k/Lib/test/test_shelve.py
   python/branches/py3k/Lib/test/test_xmlrpc_net.py

Modified: python/branches/py3k/Lib/configparser.py
==============================================================================
--- python/branches/py3k/Lib/configparser.py	(original)
+++ python/branches/py3k/Lib/configparser.py	Wed Feb 23 01:46:28 2011
@@ -119,7 +119,8 @@
         between keys and values are surrounded by spaces.
 """
 
-from collections import MutableMapping, OrderedDict as _default_dict, _ChainMap
+from collections.abc import MutableMapping
+from collections import OrderedDict as _default_dict, _ChainMap
 import functools
 import io
 import itertools

Modified: python/branches/py3k/Lib/random.py
==============================================================================
--- python/branches/py3k/Lib/random.py	(original)
+++ python/branches/py3k/Lib/random.py	Wed Feb 23 01:46:28 2011
@@ -42,7 +42,7 @@
 from math import log as _log, exp as _exp, pi as _pi, e as _e, ceil as _ceil
 from math import sqrt as _sqrt, acos as _acos, cos as _cos, sin as _sin
 from os import urandom as _urandom
-import collections as _collections
+from collections.abc import Set as _Set, Sequence as _Sequence
 from hashlib import sha512 as _sha512
 
 __all__ = ["Random","seed","random","uniform","randint","choice","sample",
@@ -293,10 +293,10 @@
         # preferred since the list takes less space than the
         # set and it doesn't suffer from frequent reselections.
 
-        if isinstance(population, _collections.Set):
+        if isinstance(population, _Set):
             population = tuple(population)
-        if not isinstance(population, _collections.Sequence):
-            raise TypeError("Population must be a sequence or Set.  For dicts, use list(d).")
+        if not isinstance(population, _Sequence):
+            raise TypeError("Population must be a sequence or set.  For dicts, use list(d).")
         randbelow = self._randbelow
         n = len(population)
         if not 0 <= k <= n:

Modified: python/branches/py3k/Lib/test/support.py
==============================================================================
--- python/branches/py3k/Lib/test/support.py	(original)
+++ python/branches/py3k/Lib/test/support.py	Wed Feb 23 01:46:28 2011
@@ -15,7 +15,7 @@
 import warnings
 import unittest
 import importlib
-import collections
+import collections.abc
 import re
 import subprocess
 import imp
@@ -682,7 +682,7 @@
         sys.modules.update(self.original_modules)
 
 
-class EnvironmentVarGuard(collections.MutableMapping):
+class EnvironmentVarGuard(collections.abc.MutableMapping):
 
     """Class to help protect the environment variable properly.  Can be used as
     a context manager."""

Modified: python/branches/py3k/Lib/test/test_collections.py
==============================================================================
--- python/branches/py3k/Lib/test/test_collections.py	(original)
+++ python/branches/py3k/Lib/test/test_collections.py	Wed Feb 23 01:46:28 2011
@@ -10,12 +10,13 @@
 import keyword
 import re
 import sys
-from collections import Hashable, Iterable, Iterator
-from collections import Sized, Container, Callable
-from collections import Set, MutableSet
-from collections import Mapping, MutableMapping, KeysView, ItemsView, UserDict
-from collections import Sequence, MutableSequence
-from collections import ByteString
+from collections import UserDict
+from collections.abc import Hashable, Iterable, Iterator
+from collections.abc import Sized, Container, Callable
+from collections.abc import Set, MutableSet
+from collections.abc import Mapping, MutableMapping, KeysView, ItemsView
+from collections.abc import Sequence, MutableSequence
+from collections.abc import ByteString
 
 TestNT = namedtuple('TestNT', 'x y z')    # type used for pickle tests
 
@@ -507,7 +508,7 @@
 
     def test_issue_4920(self):
         # MutableSet.pop() method did not work
-        class MySet(collections.MutableSet):
+        class MySet(MutableSet):
             __slots__=['__s']
             def __init__(self,items=None):
                 if items is None:
@@ -553,7 +554,7 @@
             self.assertTrue(issubclass(sample, Mapping))
         self.validate_abstract_methods(Mapping, '__contains__', '__iter__', '__len__',
             '__getitem__')
-        class MyMapping(collections.Mapping):
+        class MyMapping(Mapping):
             def __len__(self):
                 return 0
             def __getitem__(self, i):

Modified: python/branches/py3k/Lib/test/test_nntplib.py
==============================================================================
--- python/branches/py3k/Lib/test/test_nntplib.py	(original)
+++ python/branches/py3k/Lib/test/test_nntplib.py	Wed Feb 23 01:46:28 2011
@@ -4,7 +4,7 @@
 import unittest
 import functools
 import contextlib
-import collections
+import collections.abc
 from test import support
 from nntplib import NNTP, GroupInfo, _have_ssl
 import nntplib
@@ -246,7 +246,7 @@
             if not name.startswith('test_'):
                 continue
             meth = getattr(cls, name)
-            if not isinstance(meth, collections.Callable):
+            if not isinstance(meth, collections.abc.Callable):
                 continue
             # Need to use a closure so that meth remains bound to its current
             # value

Modified: python/branches/py3k/Lib/test/test_shelve.py
==============================================================================
--- python/branches/py3k/Lib/test/test_shelve.py	(original)
+++ python/branches/py3k/Lib/test/test_shelve.py	Wed Feb 23 01:46:28 2011
@@ -2,7 +2,7 @@
 import shelve
 import glob
 from test import support
-from collections import MutableMapping
+from collections.abc import MutableMapping
 from test.test_dbm import dbm_iterator
 
 def L1(s):

Modified: python/branches/py3k/Lib/test/test_xmlrpc_net.py
==============================================================================
--- python/branches/py3k/Lib/test/test_xmlrpc_net.py	(original)
+++ python/branches/py3k/Lib/test/test_xmlrpc_net.py	Wed Feb 23 01:46:28 2011
@@ -1,6 +1,6 @@
 #!/usr/bin/env python3
 
-import collections
+import collections.abc
 import errno
 import socket
 import sys
@@ -48,7 +48,7 @@
 
         # Perform a minimal sanity check on the result, just to be sure
         # the request means what we think it means.
-        self.assertIsInstance(builders, collections.Sequence)
+        self.assertIsInstance(builders, collections.abc.Sequence)
         self.assertTrue([x for x in builders if "3.x" in x], builders)
 
 


More information about the Python-checkins mailing list