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.
This commit is contained in:
Alexandre Vassalotti 2009-07-05 06:42:44 +00:00
parent 2fef5b4a83
commit 515a74fbf9
2 changed files with 7 additions and 2 deletions

View File

@ -318,8 +318,7 @@ try:
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 = {}

View File

@ -74,6 +74,12 @@ class PkgutilTests(unittest.TestCase):
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]