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 kmtracey
Recipients kmtracey
Date 2010-04-14.15:20:39
SpamBayes Score 5.013767e-13
Marked as misclassified No
Message-id <1271258442.34.0.660774695694.issue8400@psf.upfronthosting.co.za>
In-reply-to
Content
The fullname parameter to zipimporter find_module is documented to be a "fully qualified (dotted) module name". (From http://docs.python.org/library/zipimport.html#zipimport.zipimporter.find_module.) However, passing a fully-qualified dotted module appears to never work. Rather it appears that you must use the file system path separator instead of dots. For example on Windows:

C:\>echo %pythonpath%
\tmp\blah-1.0-py2.6.egg

C:\>python
Python 2.6.5 (r265:79096, Mar 19 2010, 21:48:26) [MSC v.1500 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> from blah.models import speak
>>> speak.__file__
'C:\\tmp\\blah-1.0-py2.6.egg\\blah\\models\\speak.pyc'
>>> speak.sayhi()
Hi from blah.models.speak sayhi function.

The egg has top-level blah package and under it models, it appears to work fine for normal use.  But zipimport zipimporter find_module won't find the models sub-module using dotted path notation:

>>> import sys
>>> sys.path[1]
'C:\\tmp\\blah-1.0-py2.6.egg'
>>> import zipimport
>>> zi = zipimport.zipimporter(sys.path[1])
>>> zi.find_module('blah')
<zipimporter object "C:\tmp\blah-1.0-py2.6.egg">
>>> zi.find_module('blah.models')
>>> zi.find_module('blah/models')
>>> zi.find_module('blah\\models')
<zipimporter object "C:\tmp\blah-1.0-py2.6.egg">
>>>

On Linux, the 'blah/models' version is the one that works.

Tested as far back as Python2.3 and as far forward as 2.7a3.
History
Date User Action Args
2010-04-14 15:20:42kmtraceysetrecipients: + kmtracey
2010-04-14 15:20:42kmtraceysetmessageid: <1271258442.34.0.660774695694.issue8400@psf.upfronthosting.co.za>
2010-04-14 15:20:40kmtraceylinkissue8400 messages
2010-04-14 15:20:39kmtraceycreate