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.

classification
Title: zipimport.zipimporter.find_module() does not work with dotted module names
Type: Stage:
Components: Library (Lib) Versions: Python 3.3, Python 3.4
process
Status: closed Resolution: not a bug
Dependencies: Superseder:
Assigned To: Nosy List: berker.peksag, brett.cannon, ncoghlan
Priority: normal Keywords:

Created on 2012-11-17 23:39 by berker.peksag, last changed 2022-04-11 14:57 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
reproducer.py berker.peksag, 2012-11-17 23:39
Messages (4)
msg175830 - (view) Author: Berker Peksag (berker.peksag) * (Python committer) Date: 2012-11-17 23:39
I am trying to write a test for issue 8585. The `zipimport.zipimporter.find_module()`
docs says:

"Search for a module specified by fullname. fullname must be the fully qualified
(dotted) module name."

(from http://docs.python.org/3.4/library/zipimport.html#zipimport.zipimporter.find_module )

However, the `zipimport.zipimporter.find_module()` method does not work as
expected. See the output of reproducer.py:

    spam <zipimporter object "zipimport_example.zip">
    package.eggs None
msg175838 - (view) Author: Brett Cannon (brett.cannon) * (Python committer) Date: 2012-11-18 01:20
It actually does work, you just have to embed the subdirectory in the path you pass to zipimport.zipimporter():

>>> importer = zipimport.zipimporter('zipimport_example.zip/package/')
>>> importer.find_module('package.eggs')
<zipimporter object "modules.zip/package/">
msg175880 - (view) Author: Berker Peksag (berker.peksag) * (Python committer) Date: 2012-11-18 15:27
> It actually does work, you just have to embed the subdirectory in the
> path you pass to zipimport.zipimporter():

Thanks, didn't know that. Would it be good to add an example to the zipimporter.find_module() documentation?
msg175885 - (view) Author: Brett Cannon (brett.cannon) * (Python committer) Date: 2012-11-18 16:42
It certainly wouldn't hurt. I think all of the path-related things for that module are under-documented in terms of subdirectories, relative directories, etc.
History
Date User Action Args
2022-04-11 14:57:38adminsetgithub: 60701
2012-11-18 16:42:20brett.cannonsetmessages: + msg175885
2012-11-18 15:27:21berker.peksagsetmessages: + msg175880
2012-11-18 01:20:43brett.cannonsetstatus: open -> closed
resolution: not a bug
messages: + msg175838
2012-11-17 23:42:15pitrousetnosy: + brett.cannon, ncoghlan
2012-11-17 23:39:59berker.peksagcreate