From 5ba11de8454b7dbc1cf260911a2628608267a50c Mon Sep 17 00:00:00 2001 From: Georg Brandl Date: Sat, 1 Jan 2011 10:09:32 +0000 Subject: [PATCH] #10801: In zipfile, support different encodings for the header and the filenames. Patch by MvL, test by Eli Bendersky. --- Lib/test/test_zipfile.py | 14 ++++++++++++++ Lib/test/zip_cp437_header.zip | Bin 0 -> 270 bytes Lib/zipfile.py | 8 +++++++- Misc/NEWS | 3 +++ 4 files changed, 24 insertions(+), 1 deletion(-) create mode 100644 Lib/test/zip_cp437_header.zip diff --git a/Lib/test/test_zipfile.py b/Lib/test/test_zipfile.py index d90e771ccb..e8aec4fdf9 100644 --- a/Lib/test/test_zipfile.py +++ b/Lib/test/test_zipfile.py @@ -6,6 +6,7 @@ except ImportError: import io import os +import sys import imp import time import shutil @@ -23,6 +24,7 @@ from test.support import TESTFN, run_unittest, findfile, unlink TESTFN2 = TESTFN + "2" TESTFNDIR = TESTFN + "d" FIXEDTEST_SIZE = 1000 +DATAFILES_DIR = 'zipfile_datafiles' SMALL_TEST_DATA = [('_ziptest1', '1q2w3e4r5t'), ('ziptest2dir/_ziptest2', 'qawsedrftg'), @@ -487,6 +489,18 @@ class TestsWithSourceFile(unittest.TestCase): except zipfile.BadZipFile: self.assertTrue(zipfp2.fp is None, 'zipfp is not closed') + def test_unicode_filenames(self): + if __name__ == '__main__': + myfile = sys.argv[0] + else: + myfile = __file__ + + mydir = os.path.dirname(myfile) or os.curdir + fname = os.path.join(mydir, 'zip_cp437_header.zip') + + with zipfile.ZipFile(fname) as zipfp: + zipfp.extractall() + def tearDown(self): unlink(TESTFN) unlink(TESTFN2) diff --git a/Lib/test/zip_cp437_header.zip b/Lib/test/zip_cp437_header.zip new file mode 100644 index 0000000000000000000000000000000000000000..f7c6cf170422c48ce1337a4c05843fe66a4b0bbf GIT binary patch literal 270 zcmWIWW@Zs#U}E54IGj1(Hjhth3p)b?11k`V0&!YqPHJ9aZfbmaW=Tf;#QZkBl8Tbz zujP-QGBE_;)G30lGrzP1MI$4V2m@|Qfx3Y}0Zig>LV!1JBS5x8fC7-R0%8