Skip to content

Commit 348a679

Browse files
committed
Test for recreating the issue added
1 parent c60394c commit 348a679

1 file changed

Lines changed: 10 additions & 0 deletions

File tree

Lib/test/test_zipfile.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2037,6 +2037,16 @@ def test_decompress_without_3rd_party_library(self):
20372037
with zipfile.ZipFile(zip_file) as zf:
20382038
self.assertRaises(RuntimeError, zf.extract, 'a.txt')
20392039

2040+
def test_reading_archive_member_starts_with_slash(self):
2041+
member_path = '/folder/file.txt'
2042+
member_data = b'hello world'
2043+
with open(TESTFN, "wb") as f:
2044+
f.write(member_data)
2045+
with zipfile.ZipFile(TESTFN2, 'w') as zf:
2046+
zf.write(TESTFN, member_path)
2047+
with zipfile.ZipFile(TESTFN2) as zf:
2048+
self.assertEqual(zf.read(member_path), member_data)
2049+
20402050
def tearDown(self):
20412051
unlink(TESTFN)
20422052
unlink(TESTFN2)

0 commit comments

Comments
 (0)