[Python-checkins] r73856 - in python/branches/py3k/Lib: pkgutil.py test/test_pkgutil.py

alexandre.vassalotti python-checkins at python.org
Sun Jul 5 08:42:44 CEST 2009


Author: alexandre.vassalotti
Date: Sun Jul  5 08:42:44 2009
New Revision: 73856

Log:
Issue 4005: Remove .sort() call on dict_keys object.

This caused pydoc to fail when there was a zip file in sys.path.

Patch contributed by Amaury Forgeot d'Arc.


Modified:
   python/branches/py3k/Lib/pkgutil.py
   python/branches/py3k/Lib/test/test_pkgutil.py

Modified: python/branches/py3k/Lib/pkgutil.py
==============================================================================
--- python/branches/py3k/Lib/pkgutil.py	(original)
+++ python/branches/py3k/Lib/pkgutil.py	Sun Jul  5 08:42:44 2009
@@ -318,8 +318,7 @@
     from zipimport import zipimporter
 
     def iter_zipimport_modules(importer, prefix=''):
-        dirlist = zipimport._zip_directory_cache[importer.archive].keys()
-        dirlist.sort()
+        dirlist = sorted(zipimport._zip_directory_cache[importer.archive])
         _prefix = importer.prefix
         plen = len(_prefix)
         yielded = {}

Modified: python/branches/py3k/Lib/test/test_pkgutil.py
==============================================================================
--- python/branches/py3k/Lib/test/test_pkgutil.py	(original)
+++ python/branches/py3k/Lib/test/test_pkgutil.py	Sun Jul  5 08:42:44 2009
@@ -74,6 +74,12 @@
         self.assertEqual(res1, RESOURCE_DATA)
         res2 = pkgutil.get_data(pkg, 'sub/res.txt')
         self.assertEqual(res2, RESOURCE_DATA)
+
+        names = []
+        for loader, name, ispkg in pkgutil.iter_modules([zip_file]):
+            names.append(name)
+        self.assertEqual(names, ['test_getdata_zipfile'])
+
         del sys.path[0]
 
         del sys.modules[pkg]


More information about the Python-checkins mailing list