diff options
author | Serhiy Storchaka <storchaka@gmail.com> | 2016-06-18 10:56:16 (GMT) |
---|---|---|
committer | Serhiy Storchaka <storchaka@gmail.com> | 2016-06-18 10:56:16 (GMT) |
commit | f95de0e8cc259b1ccb6b604a0ed74bb7894f4b2b (patch) | |
tree | 24ae043565544e6b02d39b127439b987b144d0d8 /Lib/test/test_zipimport.py | |
parent | 2fec611a70ba862a4127b7656a6d98d48850c3af (diff) | |
parent | 9305d83425e2ec63b2769336907dd07b3151cd5f (diff) | |
download | cpython-f95de0e8cc259b1ccb6b604a0ed74bb7894f4b2b.zip cpython-f95de0e8cc259b1ccb6b604a0ed74bb7894f4b2b.tar.gz cpython-f95de0e8cc259b1ccb6b604a0ed74bb7894f4b2b.tar.bz2 |
Issue #26754: PyUnicode_FSDecoder() accepted a filename argument encoded as
an iterable of integers. Now only strings and byte-like objects are accepted.
Diffstat (limited to 'Lib/test/test_zipimport.py')
-rw-r--r-- | Lib/test/test_zipimport.py | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/Lib/test/test_zipimport.py b/Lib/test/test_zipimport.py index 1f10095..20491cd 100644 --- a/Lib/test/test_zipimport.py +++ b/Lib/test/test_zipimport.py @@ -619,6 +619,19 @@ class UncompressedZipImportTestCase(ImportHooksBaseTestCase): finally: os.remove(filename) + def testBytesPath(self): + filename = support.TESTFN + ".zip" + self.addCleanup(support.unlink, filename) + with ZipFile(filename, "w") as z: + zinfo = ZipInfo(TESTMOD + ".py", time.localtime(NOW)) + zinfo.compress_type = self.compression + z.writestr(zinfo, test_src) + + zipimport.zipimporter(filename) + zipimport.zipimporter(os.fsencode(filename)) + zipimport.zipimporter(bytearray(os.fsencode(filename))) + zipimport.zipimporter(memoryview(os.fsencode(filename))) + @support.requires_zlib class CompressedZipImportTestCase(UncompressedZipImportTestCase): @@ -639,6 +652,8 @@ class BadFileZipImportTestCase(unittest.TestCase): def testBadArgs(self): self.assertRaises(TypeError, zipimport.zipimporter, None) self.assertRaises(TypeError, zipimport.zipimporter, TESTMOD, kwd=None) + self.assertRaises(TypeError, zipimport.zipimporter, + list(os.fsencode(TESTMOD))) def testFilenameTooLong(self): self.assertZipFailure('A' * 33000) |