mirror of
https://github.com/python/cpython.git
synced 2025-08-04 08:59:19 +00:00
Issue #26754: PyUnicode_FSDecoder() accepted a filename argument encoded as
an iterable of integers. Now only strings and byte-like objects are accepted.
This commit is contained in:
parent
bae5d81f5d
commit
9305d83425
6 changed files with 62 additions and 1 deletions
|
@ -600,6 +600,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):
|
||||
|
@ -620,6 +633,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)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue