diff options
author | Just van Rossum <just@letterror.com> | 2003-01-03 11:18:56 (GMT) |
---|---|---|
committer | Just van Rossum <just@letterror.com> | 2003-01-03 11:18:56 (GMT) |
commit | 9a3129c14866f21ce3cee053c085db374cb61b78 (patch) | |
tree | 5a272492b7a8767ab73dc23cb7b69b98ecb2a6ac /Lib/test | |
parent | 1618cedfacdeda58d2837f138ff815439232e3ae (diff) | |
download | cpython-9a3129c14866f21ce3cee053c085db374cb61b78.zip cpython-9a3129c14866f21ce3cee053c085db374cb61b78.tar.gz cpython-9a3129c14866f21ce3cee053c085db374cb61b78.tar.bz2 |
Fix for bug #661136
Lesson learned: kids should not be allowed to use API's starting
with an underscore :-/
zipimport in 2.3a1 is even more broken than I thought: I attemped
to _PyString_Resize a string created by PyString_FromStringAndSize,
which fails for strings with length 0 or 1 since the latter returns
an interned string in those cases. This would cause a SystemError
with empty source files (and no matching pyc) in the zip archive.
I rewrote the offending code to simply allocate a new buffer and
avoid _PyString_Resize altogether.
Added a test that would've caught the problem.
Diffstat (limited to 'Lib/test')
-rw-r--r-- | Lib/test/test_zipimport.py | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/Lib/test/test_zipimport.py b/Lib/test/test_zipimport.py index 5f6d8ef..3c790eb 100644 --- a/Lib/test/test_zipimport.py +++ b/Lib/test/test_zipimport.py @@ -56,9 +56,10 @@ class UncompressedZipImportTestCase(ImportHooksBaseTestCase): mod = __import__(".".join(modules), globals(), locals(), ["__dummy__"]) - file = mod.get_file() - self.assertEquals(file, os.path.join(TEMP_ZIP, - os.sep.join(modules) + expected_ext)) + if expected_ext: + file = mod.get_file() + self.assertEquals(file, os.path.join(TEMP_ZIP, + os.sep.join(modules) + expected_ext)) finally: z.close() os.remove(TEMP_ZIP) @@ -101,6 +102,10 @@ class UncompressedZipImportTestCase(ImportHooksBaseTestCase): TESTMOD + pyc_ext: (NOW, test_pyc)} self.doTest(pyc_ext, files, TESTMOD) + def testEmptyPy(self): + files = {TESTMOD + ".py": (NOW, "")} + self.doTest(None, files, TESTMOD) + def testBadMagic(self): # make pyc magic word invalid, forcing loading from .py m0 = ord(test_pyc[0]) |