diff --git a/Lib/test/test_zipfile.py b/Lib/test/test_zipfile.py index 7b8922f4e0..46702e3e59 100644 --- a/Lib/test/test_zipfile.py +++ b/Lib/test/test_zipfile.py @@ -1255,6 +1255,15 @@ class OtherTests(unittest.TestCase): zinfo.flag_bits |= 0x08 # Include an extended local header. orig_zip.writestr(zinfo, data) + def test_writestr_preserve_language_flag_bit(self): + with zipfile.ZipFile(TESTFN2, 'w') as zipfp: + zinfo = zipfile.ZipInfo("name") + zinfo.flag_bits = 0x800 # Set language flag bit + zipfp.writestr(zinfo, "data") + flag_expected = b"\x00\x08" # 0x800 little endian + with open(TESTFN2, "rb") as rdfp: + self.assertEqual(rdfp.read(8)[6:], flag_expected) + def test_close(self): """Check that the zipfile is closed after the 'with' block.""" with zipfile.ZipFile(TESTFN2, "w") as zipfp: diff --git a/Lib/zipfile.py b/Lib/zipfile.py index 4a6b40ee44..c151836ace 100644 --- a/Lib/zipfile.py +++ b/Lib/zipfile.py @@ -1564,7 +1564,6 @@ class ZipFile: zinfo.compress_size = 0 zinfo.CRC = 0 - zinfo.flag_bits = 0x00 if zinfo.compress_type == ZIP_LZMA: # Compressed data includes an end-of-stream (EOS) marker zinfo.flag_bits |= 0x02