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 pconnell
Recipients brett.cannon, eric.snow, ncoghlan, pconnell
Date 2013-04-04.10:10:23
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1365070223.85.0.365511954484.issue17633@psf.upfronthosting.co.za>
In-reply-to
Content
Only one level of namespace package nesting is handled correctly:

$ unzip -l foo.zip
Archive:  foo.zip
  Length      Date    Time    Name
---------  ---------- -----   ----
        0  2013-04-03 17:28   a/b/c/foo.py
        0  2013-04-03 17:34   a/
        0  2013-04-03 17:34   a/b/
        0  2013-04-03 17:34   a/b/c/
---------                     -------
        0                     4 files
$ ls
foo.zip
$ PYTHONPATH=foo.zip ~/dev/cpython/python
Python 3.4.0a0 (default:3b1dbe7a2aa0+, Apr  3 2013, 17:31:54) 
[GCC 4.8.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import a
>>> import a.b
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: No module named 'a.b'
>>>


The problem appears to be that check_is_directory constructs the wrong directory path (it should be 'a/b'):

check_is_directory (self=0x7ffff6d3dc88, prefix='a/', path='a.b')
    at ./Modules/zipimport.c:280
280     dirpath = PyUnicode_FromFormat("%U%U%c", prefix, path, SEP);
(gdb) n
281     if (dirpath == NULL)
(gdb) p dirpath
$11 = 'a/a.b/'


I've attached a tentative initial patch that appears to fix the issue, although it probably needs some more thought (and definitely some more testing - the existing tests still pass though).
History
Date User Action Args
2013-04-04 10:10:23pconnellsetrecipients: + pconnell, brett.cannon, ncoghlan, eric.snow
2013-04-04 10:10:23pconnellsetmessageid: <1365070223.85.0.365511954484.issue17633@psf.upfronthosting.co.za>
2013-04-04 10:10:23pconnelllinkissue17633 messages
2013-04-04 10:10:23pconnellcreate