File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -1088,7 +1088,9 @@ def testInvalidUTF8FileName(self):
10881088 os_helper .unlink (TESTMOD )
10891089 with open (TESTMOD , 'wb' ) as fp :
10901090 fp .write (cdh + eocd )
1091- self .assertZipFailure (TESTMOD )
1091+ with self .assertRaises (zipimport .ZipImportError ) as cm :
1092+ zipimport .zipimporter (TESTMOD )
1093+ self .assertIsInstance (cm .exception .__cause__ , UnicodeDecodeError )
10921094
10931095 # XXX: disabled until this works on Big-endian machines
10941096 def _testBogusZipFile (self ):
Original file line number Diff line number Diff line change @@ -429,10 +429,10 @@ def _read_directory(archive):
429429 # UTF-8 file names extension
430430 try :
431431 name = name .decode ()
432- except UnicodeDecodeError :
432+ except UnicodeDecodeError as exc :
433433 raise ZipImportError (
434434 f"can't decode file name in Zip file: { archive !r} " ,
435- path = archive )
435+ path = archive ) from exc
436436 else :
437437 # Historical ZIP filename encoding
438438 try :
You can’t perform that action at this time.
0 commit comments