File Lib/test/test_zipfile.py changed (mode: 100644) (index 46a67d5428..ff55e94e47) |
... |
... |
class LzmaTestZip64InSmallFiles(AbstractTestZip64InSmallFiles, |
734 |
734 |
compression = zipfile.ZIP_LZMA |
compression = zipfile.ZIP_LZMA |
735 |
735 |
|
|
736 |
736 |
|
|
|
737 |
|
class AbstractWriterTests: |
|
738 |
|
|
|
739 |
|
def tearDown(self): |
|
740 |
|
unlink(TESTFN2) |
|
741 |
|
|
|
742 |
|
def test_close_after_close(self): |
|
743 |
|
data = b'content' |
|
744 |
|
with zipfile.ZipFile(TESTFN2, "w", self.compression) as zipf: |
|
745 |
|
w = zipf.open('test', 'w') |
|
746 |
|
w.write(data) |
|
747 |
|
w.close() |
|
748 |
|
self.assertTrue(w.closed) |
|
749 |
|
w.close() |
|
750 |
|
self.assertTrue(w.closed) |
|
751 |
|
self.assertEqual(zipf.read('test'), data) |
|
752 |
|
|
|
753 |
|
def test_write_after_close(self): |
|
754 |
|
data = b'content' |
|
755 |
|
with zipfile.ZipFile(TESTFN2, "w", self.compression) as zipf: |
|
756 |
|
w = zipf.open('test', 'w') |
|
757 |
|
w.write(data) |
|
758 |
|
w.close() |
|
759 |
|
self.assertTrue(w.closed) |
|
760 |
|
self.assertRaises(ValueError, w.write, b'') |
|
761 |
|
self.assertEqual(zipf.read('test'), data) |
|
762 |
|
|
|
763 |
|
class StoredWriterTests(AbstractWriterTests, unittest.TestCase): |
|
764 |
|
compression = zipfile.ZIP_STORED |
|
765 |
|
|
|
766 |
|
@requires_zlib |
|
767 |
|
class DeflateWriterTests(AbstractWriterTests, unittest.TestCase): |
|
768 |
|
compression = zipfile.ZIP_DEFLATED |
|
769 |
|
|
|
770 |
|
@requires_bz2 |
|
771 |
|
class Bzip2WriterTests(AbstractWriterTests, unittest.TestCase): |
|
772 |
|
compression = zipfile.ZIP_BZIP2 |
|
773 |
|
|
|
774 |
|
@requires_lzma |
|
775 |
|
class LzmaWriterTests(AbstractWriterTests, unittest.TestCase): |
|
776 |
|
compression = zipfile.ZIP_LZMA |
|
777 |
|
|
|
778 |
|
|
737 |
779 |
class PyZipFileTests(unittest.TestCase): |
class PyZipFileTests(unittest.TestCase): |
738 |
780 |
def assertCompiledIn(self, name, namelist): |
def assertCompiledIn(self, name, namelist): |
739 |
781 |
if name + 'o' not in namelist: |
if name + 'o' not in namelist: |
File Lib/zipfile.py changed (mode: 100644) (index 550e64fd1a..988f39ed1b) |
... |
... |
class _ZipWriteFile(io.BufferedIOBase): |
980 |
980 |
return True |
return True |
981 |
981 |
|
|
982 |
982 |
def write(self, data): |
def write(self, data): |
|
983 |
|
if self.closed: |
|
984 |
|
raise ValueError('I/O operation on closed file.') |
983 |
985 |
nbytes = len(data) |
nbytes = len(data) |
984 |
986 |
self._file_size += nbytes |
self._file_size += nbytes |
985 |
987 |
self._crc = crc32(data, self._crc) |
self._crc = crc32(data, self._crc) |
|
... |
... |
class _ZipWriteFile(io.BufferedIOBase): |
990 |
992 |
return nbytes |
return nbytes |
991 |
993 |
|
|
992 |
994 |
def close(self): |
def close(self): |
|
995 |
|
if self.closed: |
|
996 |
|
return |
993 |
997 |
super().close() |
super().close() |
994 |
998 |
# Flush any data from the compressor, and update header info |
# Flush any data from the compressor, and update header info |
995 |
999 |
if self._compressor: |
if self._compressor: |
File Misc/NEWS changed (mode: 100644) (index d8b1ccb43a..b6f8c7094c) |
... |
... |
Library |
314 |
314 |
times when schema is changing. Indirectly fixed by switching to |
times when schema is changing. Indirectly fixed by switching to |
315 |
315 |
use sqlite3_prepare_v2() in bpo-9303. Patch by Aviv Palivoda. |
use sqlite3_prepare_v2() in bpo-9303. Patch by Aviv Palivoda. |
316 |
316 |
|
|
|
317 |
|
- bpo-30017: Allowed calling the close() method of the zip entry writer object |
|
318 |
|
multiple times. Writing to a closed writer now always produces a ValueError. |
|
319 |
|
|
317 |
320 |
- bpo-29998: Pickling and copying ImportError now preserves name and path |
- bpo-29998: Pickling and copying ImportError now preserves name and path |
318 |
321 |
attributes. |
attributes. |
319 |
322 |
|
|