[Python-checkins] python/dist/src/Lib/test test_zipimport.py,1.2,1.3
jvr@users.sourceforge.net
jvr@users.sourceforge.net
Fri, 03 Jan 2003 03:18:58 -0800
Update of /cvsroot/python/python/dist/src/Lib/test
In directory sc8-pr-cvs1:/tmp/cvs-serv15788/Lib/test
Modified Files:
test_zipimport.py
Log Message:
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.
Index: test_zipimport.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/test/test_zipimport.py,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** test_zipimport.py 2 Jan 2003 12:55:48 -0000 1.2
--- test_zipimport.py 3 Jan 2003 11:18:56 -0000 1.3
***************
*** 57,63 ****
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))
finally:
z.close()
--- 57,64 ----
mod = __import__(".".join(modules), globals(), locals(),
["__dummy__"])
! if expected_ext:
! file = mod.get_file()
! self.assertEquals(file, os.path.join(TEMP_ZIP,
! os.sep.join(modules) + expected_ext))
finally:
z.close()
***************
*** 101,104 ****
--- 102,109 ----
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):