[New-bugs-announce] [issue8400] zipimporter find_module fullname mis-documented

Karen Tracey report at bugs.python.org
Wed Apr 14 17:20:42 CEST 2010


New submission from Karen Tracey <kmtracey at gmail.com>:

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.

----------
messages: 103132
nosy: kmtracey
severity: normal
status: open
title: zipimporter find_module fullname mis-documented
type: behavior
versions: Python 2.5, Python 2.6, Python 2.7

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue8400>
_______________________________________


More information about the New-bugs-announce mailing list