This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author James.Pickering
Recipients James.Pickering
Date 2012-03-06.15:02:23
SpamBayes Score 5.5199666e-07
Marked as misclassified No
Message-id <1331046144.89.0.833633660995.issue14209@psf.upfronthosting.co.za>
In-reply-to
Content
If you run pkgutil.iter_zipimport_modules with a prefix parameter, and the module in question is a package, then the prefix parameter is ignored.

The most visible symptom of this is when running pkgutil.walk_packages for a zipfile. Imagine we have a module structure like this (or create one):

a/
a/__init__.py
a/b/
a/b/__init.__py

If we put this structure in a directory, add the directory to sys.path, and run pkgutil.walk_packages(), it will find modules "a" and "a.b".

If we put this structure in a zipfile, however, we add this file to sys.path, and run pkgutil.walk_packages(), it will find modules "a" and "b". This is because pkgutil.iter_zipimport_modules ignores the prefix parameter "a.".

This is incorrect.

This can be fixed by changing line ~344 of Lib/pkgutil.py from:

    yield fn[0], True

to

    yield prefix + fn[0], True

Thanks, James

P.s, This is my first Python bug report. I apologise in advance for any poor etiquette.
History
Date User Action Args
2012-03-06 15:02:24James.Pickeringsetrecipients: + James.Pickering
2012-03-06 15:02:24James.Pickeringsetmessageid: <1331046144.89.0.833633660995.issue14209@psf.upfronthosting.co.za>
2012-03-06 15:02:24James.Pickeringlinkissue14209 messages
2012-03-06 15:02:23James.Pickeringcreate