- with ZipFile(path.join(zip_path, zip_filename), 'w') as zipf:
- for p in paths:
- zipf.write(p, path.basename(p))
+ zipf = ZipFile(path.join(zip_path, zip_filename), 'w')
+ try:
+ for arcname, p in paths:
+ if arcname is None:
+ arcname = path.basename(p)
+ zipf.write(p, arcname)
+ finally:
+ zipf.close()