[Python-3000-checkins] r56142 - in python/branches/p3yk/Lib: logging/config.py mhlib.py test/test_heapq.py test/test_mailbox.py test/test_mhlib.py test/test_multibytecodec.py test/test_old_mailbox.py test/test_operator.py urllib2.py zipfile.py

neal.norwitz python-3000-checkins at python.org
Mon Jul 2 06:38:13 CEST 2007


Author: neal.norwitz
Date: Mon Jul  2 06:38:12 2007
New Revision: 56142

Modified:
   python/branches/p3yk/Lib/logging/config.py
   python/branches/p3yk/Lib/mhlib.py
   python/branches/p3yk/Lib/test/test_heapq.py
   python/branches/p3yk/Lib/test/test_mailbox.py
   python/branches/p3yk/Lib/test/test_mhlib.py
   python/branches/p3yk/Lib/test/test_multibytecodec.py
   python/branches/p3yk/Lib/test/test_old_mailbox.py
   python/branches/p3yk/Lib/test/test_operator.py
   python/branches/p3yk/Lib/urllib2.py
   python/branches/p3yk/Lib/zipfile.py
Log:
Get a bunch more tests passing after converting map/filter to return iterators.

Modified: python/branches/p3yk/Lib/logging/config.py
==============================================================================
--- python/branches/p3yk/Lib/logging/config.py	(original)
+++ python/branches/p3yk/Lib/logging/config.py	Mon Jul  2 06:38:12 2007
@@ -176,7 +176,7 @@
     # configure the root first
     llist = cp.get("loggers", "keys")
     llist = llist.split(",")
-    llist = map(lambda x: x.strip(), llist)
+    llist = list(map(lambda x: x.strip(), llist))
     llist.remove("root")
     sectname = "logger_root"
     root = logging.root

Modified: python/branches/p3yk/Lib/mhlib.py
==============================================================================
--- python/branches/p3yk/Lib/mhlib.py	(original)
+++ python/branches/p3yk/Lib/mhlib.py	Mon Jul  2 06:38:12 2007
@@ -282,8 +282,7 @@
         for name in os.listdir(self.getfullname()):
             if match(name):
                 append(name)
-        messages = map(int, messages)
-        messages.sort()
+        messages = sorted(map(int, messages))
         if messages:
             self.last = messages[-1]
         else:

Modified: python/branches/p3yk/Lib/test/test_heapq.py
==============================================================================
--- python/branches/p3yk/Lib/test/test_heapq.py	(original)
+++ python/branches/p3yk/Lib/test/test_heapq.py	Mon Jul  2 06:38:12 2007
@@ -130,16 +130,17 @@
         data = [(random.randrange(2000), i) for i in range(1000)]
         for f in (None, lambda x:  x[0] * 547 % 2000):
             for n in (0, 1, 2, 10, 100, 400, 999, 1000, 1100):
-                self.assertEqual(nsmallest(n, data), sorted(data)[:n])
-                self.assertEqual(nsmallest(n, data, key=f),
+                self.assertEqual(list(nsmallest(n, data)), sorted(data)[:n])
+                self.assertEqual(list(nsmallest(n, data, key=f)),
                                  sorted(data, key=f)[:n])
 
     def test_nlargest(self):
         data = [(random.randrange(2000), i) for i in range(1000)]
         for f in (None, lambda x:  x[0] * 547 % 2000):
             for n in (0, 1, 2, 10, 100, 400, 999, 1000, 1100):
-                self.assertEqual(nlargest(n, data), sorted(data, reverse=True)[:n])
-                self.assertEqual(nlargest(n, data, key=f),
+                self.assertEqual(list(nlargest(n, data)),
+                                 sorted(data, reverse=True)[:n])
+                self.assertEqual(list(nlargest(n, data, key=f)),
                                  sorted(data, key=f, reverse=True)[:n])
 
 
@@ -279,8 +280,8 @@
         for f in  (nlargest, nsmallest):
             for s in ("123", "", range(1000), (1, 1.2), range(2000,2200,5)):
                 for g in (G, I, Ig, L, R):
-                    self.assertEqual(f(2, g(s)), f(2,s))
-                self.assertEqual(f(2, S(s)), [])
+                    self.assertEqual(list(f(2, g(s))), list(f(2,s)))
+                self.assertEqual(list(f(2, S(s))), [])
                 self.assertRaises(TypeError, f, 2, X(s))
                 self.assertRaises(TypeError, f, 2, N(s))
                 self.assertRaises(ZeroDivisionError, f, 2, E(s))

Modified: python/branches/p3yk/Lib/test/test_mailbox.py
==============================================================================
--- python/branches/p3yk/Lib/test/test_mailbox.py	(original)
+++ python/branches/p3yk/Lib/test/test_mailbox.py	Mon Jul  2 06:38:12 2007
@@ -1669,7 +1669,7 @@
         self._msgfiles = []
 
     def tearDown(self):
-        map(os.unlink, self._msgfiles)
+        list(map(os.unlink, self._msgfiles))
         os.rmdir(os.path.join(self._dir, "cur"))
         os.rmdir(os.path.join(self._dir, "tmp"))
         os.rmdir(os.path.join(self._dir, "new"))

Modified: python/branches/p3yk/Lib/test/test_mhlib.py
==============================================================================
--- python/branches/p3yk/Lib/test/test_mhlib.py	(original)
+++ python/branches/p3yk/Lib/test/test_mhlib.py	Mon Jul  2 06:38:12 2007
@@ -179,18 +179,17 @@
 
         folders = mh.listallfolders()
         folders.sort()
-        tfolders = map(normF, ['deep', 'deep/f1', 'deep/f2', 'deep/f2/f3',
-                                'inbox', 'wide'])
-        tfolders.sort()
+        tfolders = sorted(map(normF, ['deep', 'deep/f1', 'deep/f2',
+                                      'deep/f2/f3', 'inbox', 'wide']))
         eq(folders, tfolders)
 
         folders = mh.listsubfolders('deep')
         folders.sort()
-        eq(folders, map(normF, ['deep/f1', 'deep/f2']))
+        eq(folders, list(map(normF, ['deep/f1', 'deep/f2'])))
 
         folders = mh.listallsubfolders('deep')
         folders.sort()
-        eq(folders, map(normF, ['deep/f1', 'deep/f2', 'deep/f2/f3']))
+        eq(folders, list(map(normF, ['deep/f1', 'deep/f2', 'deep/f2/f3'])))
         eq(mh.listsubfolders(normF('deep/f2')), [normF('deep/f2/f3')])
 
         eq(mh.listsubfolders('inbox'), [])

Modified: python/branches/p3yk/Lib/test/test_multibytecodec.py
==============================================================================
--- python/branches/p3yk/Lib/test/test_multibytecodec.py	(original)
+++ python/branches/p3yk/Lib/test/test_multibytecodec.py	Mon Jul  2 06:38:12 2007
@@ -216,7 +216,7 @@
         self.failIf('\x0e' in u'\N{SOFT HYPHEN}'.encode('iso-2022-jp-2'))
         for encoding in ('iso-2022-jp-2004', 'iso-2022-jp-3'):
             e = u'\u3406'.encode(encoding)
-            self.failIf(filter(lambda x: x >= '\x80', e))
+            self.failIf(list(filter(lambda x: x >= '\x80', e)))
 
     def test_bug1572832(self):
         if sys.maxunicode >= 0x10000:

Modified: python/branches/p3yk/Lib/test/test_old_mailbox.py
==============================================================================
--- python/branches/p3yk/Lib/test/test_old_mailbox.py	(original)
+++ python/branches/p3yk/Lib/test/test_old_mailbox.py	Mon Jul  2 06:38:12 2007
@@ -35,7 +35,7 @@
         self._msgfiles = []
 
     def tearDown(self):
-        map(os.unlink, self._msgfiles)
+        list(map(os.unlink, self._msgfiles))
         os.rmdir(os.path.join(self._dir, "cur"))
         os.rmdir(os.path.join(self._dir, "tmp"))
         os.rmdir(os.path.join(self._dir, "new"))

Modified: python/branches/p3yk/Lib/test/test_operator.py
==============================================================================
--- python/branches/p3yk/Lib/test/test_operator.py	(original)
+++ python/branches/p3yk/Lib/test/test_operator.py	Mon Jul  2 06:38:12 2007
@@ -393,12 +393,12 @@
         # example used in the docs
         inventory = [('apple', 3), ('banana', 2), ('pear', 5), ('orange', 1)]
         getcount = operator.itemgetter(1)
-        self.assertEqual(map(getcount, inventory), [3, 2, 5, 1])
+        self.assertEqual(list(map(getcount, inventory)), [3, 2, 5, 1])
         self.assertEqual(sorted(inventory, key=getcount),
             [('orange', 1), ('banana', 2), ('apple', 3), ('pear', 5)])
 
         # multiple gets
-        data = map(str, range(20))
+        data = list(map(str, range(20)))
         self.assertEqual(operator.itemgetter(2,10,5)(data), ('2', '10', '5'))
         self.assertRaises(TypeError, operator.itemgetter(2, 'x', 5), data)
 

Modified: python/branches/p3yk/Lib/urllib2.py
==============================================================================
--- python/branches/p3yk/Lib/urllib2.py	(original)
+++ python/branches/p3yk/Lib/urllib2.py	Mon Jul  2 06:38:12 2007
@@ -1264,7 +1264,7 @@
             raise URLError(msg)
         path, attrs = splitattr(req.get_selector())
         dirs = path.split('/')
-        dirs = map(unquote, dirs)
+        dirs = list(map(unquote, dirs))
         dirs, file = dirs[:-1], dirs[-1]
         if dirs and not dirs[0]:
             dirs = dirs[1:]

Modified: python/branches/p3yk/Lib/zipfile.py
==============================================================================
--- python/branches/p3yk/Lib/zipfile.py	(original)
+++ python/branches/p3yk/Lib/zipfile.py	Mon Jul  2 06:38:12 2007
@@ -789,7 +789,7 @@
             #  completely random, while the 12th contains the MSB of the CRC,
             #  and is used to check the correctness of the password.
             bytes = zef_file.read(12)
-            h = map(zd, bytes[0:12])
+            h = list(map(zd, bytes[0:12]))
             if ord(h[11]) != ((zinfo.CRC>>24)&255):
                 raise RuntimeError, "Bad password for file %s" % name
 


More information about the Python-3000-checkins mailing list