[Matt Conway]
>Hi,
>
>I had a problem with multi level import from a jar file in my sys.path.
>basically, my simple test jar looks as follows, with the init files being
>empty, and the py files having a simple variable def:
>
>jlib.jar:
>Lib/
>Lib/aaa/
>Lib/aaa/__init__.py
>Lib/aaa/bbb/
>Lib/aaa/bbb/__init__.py
>Lib/aaa/bbb/ccc/
>Lib/aaa/bbb/ccc/__init__.py
>Lib/aaa/bbb/ccc/yyy.py
>Lib/aaa/bbb/xxx.py
>
>
>import aaa works fine
>import aaa.bbb (or more levels) doesn't
>
>I traced the problem down to the following line from the method
>"loadFromZipFile" on line 302 in org/python/core/imp.java
> SyspathArchive subArchive =
>zipArchive.makeSubfolder(modName);
>Which should probably be
> SyspathArchive subArchive =
>zipArchive.makeSubfolder(name);
>
>Or at least, when I change it to that, all levels of import work for me =)
For me too. Thanks for your patch.
>If I have to do more complicated changes, whats the best way for me to
>generate a patch?
1) Check out the CVS version.
2) Edit the sources until it works for you.
3) run "cvs diff -u" to generate a patch.
4) Add the patch on SF.
http://sourceforge.net/tracker/?group_id=12867&atid=312867
5) [Most important] Do not post the patch to a mailing list.
The reason for 5) is that everything but the simplest of changes gets
lost on mailing lists.
>I'm somewhat of a CVS/patch/diff newbie, so excuse me
>if this is a simple question. Do I need to have 2 CVS directories, one
>untouched to generate the diff against?
There can be reasons for using 2 directories, but we'll manage to make
sense of a CVS diff too.
Please also remember to use the -u or -c option to diff. A plain diff is
quite useless as a patch.
If you *really* want to help out, you should have made a SF bug report
with your observation (there is still time to make amends <wink>) and a
self contained copy&paste example. See below for one way of doing that.
Adding a SF bug report ensure that the situation will (eventually) be
addressed and that a note about a fix will be included in the release
note.
regards,
finn
import zipfile, time
def addZipEntry(zip, name, data):
entry = zipfile.ZipInfo()
entry.filename = name
entry.date_time = time.gmtime(time.time())
zip.writestr(entry, data)
zip = zipfile.ZipFile("test350.zip", "w")
addZipEntry(zip, "Lib/aaa/__init__.py", "print __name__")
addZipEntry(zip, "Lib/aaa/bbb/__init__.py", "print __name__")
addZipEntry(zip, "Lib/aaa/bbb/ccc/__init__.py", "print __name__")
addZipEntry(zip, "Lib/aaa/bbb/ccc/yyy.py", "print __name__")
addZipEntry(zip, "Lib/aaa/bbb/xxx.py", "print __name__")
zip.close()
import sys
sys.path.append("test350.zip/Lib")
import aaa
import aaa.bbb
import aaa.bbb.ccc
import aaa.bbb.ccc.yyy
import aaa.bbb.xxx
|