Jan-30-2023, 05:18 PM
(This post was last modified: Jan-30-2023, 05:18 PM by deanhystad.)
Buran might be right. What is the error message? Does it say : Bad ZIP found -> That compression method is not supported? If the message starts with "Bad ZIP found", your exception handler caught the error. If it doesn't, the exception was not caught. You've been posting to this forum for over 2 years. You know how it works. Post full error messages and the complete error trace.
Either way, your try/except will not work as you expect. If you catch the exception, the program will jump HERE (marked below) and execute the code in the exception block.
Either way, your try/except will not work as you expect. If you catch the exception, the program will jump HERE (marked below) and execute the code in the exception block.
from zipfile import ZipFile from zipfile import BadZipfile from pathlib import Path # Some code here try : with ZipFile(ef) as zz: for file in zz.namelist(): zp_name = Path(file).name #print(f" ZIP NAME : {zp_name}") if 'Trace' in file : zz.extract(file,temp_temp_dr_out) except BadZipfile as er : print(f" Bad ZIP found -> {er}") # <-- JUMP TO HERE IF BadZipFile exception continueIs the exception body inside or outside the loop?