Ugh, zipimport is virtually broken in 2.3a1 :-( It worked by accident in

the test set as it only tested with a zip archive in the current directory,
but it doesn't work at all for packages when the zip archive was specified
as an absolute path. It's a real embarrassing bug: a strchr call should
have been strrchr; fever apparently implies dyslexia.

Second stupid bug: the zipimport test failed with a name error
__importer__ (which I had renamed to __loader__ everywhere but here).
I would've sworn I ran the test after that change but that can't be true.
What I don't understand that noone reported a failing test_zipimport.py
before the release of 2.3a1.
This commit is contained in:
Just van Rossum 2003-01-02 12:55:48 +00:00
parent c6fff897d7
commit d35c6db526
2 changed files with 6 additions and 5 deletions

View File

@ -30,7 +30,8 @@ else:
TESTMOD = "ziptestmodule"
TESTPACK = "ziptestpackage"
TEMP_ZIP = "junk95142.zip"
TESTPACK2 = "ziptestpackage2"
TEMP_ZIP = os.path.abspath("junk95142.zip")
class UncompressedZipImportTestCase(ImportHooksBaseTestCase):
@ -139,11 +140,11 @@ class UncompressedZipImportTestCase(ImportHooksBaseTestCase):
def testDeepPackage(self):
packdir = TESTPACK + os.sep
packdir2 = packdir + packdir
packdir2 = packdir + TESTPACK2 + os.sep
files = {packdir + "__init__" + pyc_ext: (NOW, test_pyc),
packdir2 + "__init__" + pyc_ext: (NOW, test_pyc),
packdir2 + TESTMOD + pyc_ext: (NOW, test_pyc)}
self.doTest(pyc_ext, files, TESTPACK, TESTPACK, TESTMOD)
self.doTest(pyc_ext, files, TESTPACK, TESTPACK2, TESTMOD)
def testGetData(self):
z = ZipFile(TEMP_ZIP, "w")
@ -163,7 +164,7 @@ class UncompressedZipImportTestCase(ImportHooksBaseTestCase):
src = """if 1: # indent hack
def get_file():
return __file__
if __importer__.get_data("some.data") != "some data":
if __loader__.get_data("some.data") != "some data":
raise AssertionError, "bad data"\n"""
pyc = make_pyc(compile(src, "<???>", "exec"), NOW)
files = {TESTMOD + pyc_ext: (NOW, pyc),

View File

@ -103,7 +103,7 @@ zipimporter_init(ZipImporter *self, PyObject *args, PyObject *kwds)
break;
}
/* back up one path element */
p = strchr(buf, SEP);
p = strrchr(buf, SEP);
if (prefix != NULL)
*prefix = SEP;
if (p == NULL)