From: <pj...@us...> - 2008-09-25 21:16:36
|
Revision: 5349 http://jython.svn.sourceforge.net/jython/?rev=5349&view=rev Author: pjenvey Date: 2008-09-25 21:16:30 +0000 (Thu, 25 Sep 2008) Log Message: ----------- reapply previous tarfile modifications: o don't assume a reference counting GC o ensure all file handles are closed to avoid os.remove problems on windows o always use the tempdir, even when testtar is a relative path (it is when ran via the regrtest) Modified Paths: -------------- trunk/jython/Lib/tarfile.py trunk/jython/Lib/test/test_tarfile.py Modified: trunk/jython/Lib/tarfile.py =================================================================== --- trunk/jython/Lib/tarfile.py 2008-09-25 21:12:28 UTC (rev 5348) +++ trunk/jython/Lib/tarfile.py 2008-09-25 21:16:30 UTC (rev 5349) @@ -1205,12 +1205,10 @@ except (ImportError, AttributeError): raise CompressionError("gzip module is not available") - if fileobj is None: - fileobj = file(name, mode + "b") + fileobj = gzip.GzipFile(name, mode, compresslevel, fileobj) try: - t = cls.taropen(name, mode, - gzip.GzipFile(name, mode, compresslevel, fileobj)) + t = cls.taropen(name, mode, fileobj) except IOError: raise ReadError("not a gzip file") t._extfileobj = False Modified: trunk/jython/Lib/test/test_tarfile.py =================================================================== --- trunk/jython/Lib/test/test_tarfile.py 2008-09-25 21:12:28 UTC (rev 5348) +++ trunk/jython/Lib/test/test_tarfile.py 2008-09-25 21:16:30 UTC (rev 5349) @@ -31,7 +31,7 @@ def tarname(comp=""): if not comp: return testtar - return os.path.join(tempdir, "%s%s%s" % (testtar, os.extsep, comp)) + return os.path.join(dirname(), "%s%s%s" % (testtar, os.extsep, comp)) def dirname(): if not os.path.exists(tempdir): @@ -279,9 +279,14 @@ def setUp(self): name = tarname(self.comp) + self.fileobj = open(name, "rb") self.tar = tarfile.open(name, mode=self.mode, - fileobj=open(name, "rb")) + fileobj=self.fileobj) + def tearDown(self): + self.tar.close() + self.fileobj.close() + class ReadAsteriskTest(ReadTest): def setUp(self): @@ -529,6 +534,7 @@ self.assert_(tarinfo.name == member.name and \ tarinfo.linkname == member.linkname, \ "unable to read longname member") + tar.close() def test_longname_1023(self): self._test(("longnam/" * 127) + "longnam") This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |