mirror of
https://github.com/python/cpython.git
synced 2025-08-04 00:48:58 +00:00
bpo-5950: Support reading zips with comments in zipimport (#9548)
* bpo-5950: Support reading zips with comments in zipimport
This commit is contained in:
parent
996859a90d
commit
5a5ce064b3
5 changed files with 1084 additions and 1013 deletions
|
@ -116,6 +116,9 @@ class UncompressedZipImportTestCase(ImportHooksBaseTestCase):
|
|||
zinfo = ZipInfo(name, time.localtime(mtime))
|
||||
zinfo.compress_type = self.compression
|
||||
z.writestr(zinfo, data)
|
||||
comment = kw.get("comment", None)
|
||||
if comment is not None:
|
||||
z.comment = comment
|
||||
|
||||
stuff = kw.get("stuff", None)
|
||||
if stuff is not None:
|
||||
|
@ -665,6 +668,18 @@ class UncompressedZipImportTestCase(ImportHooksBaseTestCase):
|
|||
with self.assertRaises(TypeError):
|
||||
zipimport.zipimporter(memoryview(os.fsencode(filename)))
|
||||
|
||||
def testComment(self):
|
||||
files = {TESTMOD + ".py": (NOW, test_src)}
|
||||
self.doTest(".py", files, TESTMOD, comment=b"comment")
|
||||
|
||||
def testBeginningCruftAndComment(self):
|
||||
files = {TESTMOD + ".py": (NOW, test_src)}
|
||||
self.doTest(".py", files, TESTMOD, stuff=b"cruft" * 64, comment=b"hi")
|
||||
|
||||
def testLargestPossibleComment(self):
|
||||
files = {TESTMOD + ".py": (NOW, test_src)}
|
||||
self.doTest(".py", files, TESTMOD, comment=b"c" * ((1 << 16) - 1))
|
||||
|
||||
|
||||
@support.requires_zlib
|
||||
class CompressedZipImportTestCase(UncompressedZipImportTestCase):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue