Commit 515a74fb authored by Alexandre Vassalotti's avatar Alexandre Vassalotti

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.
parent 2fef5b4a
......@@ -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 = {}
......
......@@ -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]
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment