Skip to content

Commit 6896589

Browse files
committed
! close zip file by with statement
1 parent 634bbd8 commit 6896589

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

bin/show-duplicate-java-classes

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,8 @@ def list_jar_file_under_lib_dirs(lib_dirs):
4646

4747
def list_class_under_jar_file(jar_file):
4848
try:
49-
return {f for f in ZipFile(jar_file).namelist() if f.lower().endswith('.class')}
49+
with ZipFile(jar_file) as zf:
50+
return {f for f in zf.namelist() if f.lower().endswith('.class')}
5051
except BadZipfile:
5152
print('WARN: %s is bad zip file, ignored!' % jar_file, file=sys.stderr)
5253
return set()

0 commit comments

Comments
 (0)