@@ -694,14 +694,19 @@ def goh1_file(filename):
import zipfile
lines = []
+ is_zipfile = False
if zipfile.is_zipfile(filename):
- with zipfile.ZipFile(filename) as archive:
- for fn in sorted(archive.namelist()):
- method = hashlib.sha256()
- method.update(archive.read(fn))
- hash = method.hexdigest()
- lines.append("%s %s\n" % (hash, fn))
- else:
+ try:
+ with zipfile.ZipFile(filename) as archive:
+ for fn in sorted(archive.namelist()):
+ method = hashlib.sha256()
+ method.update(archive.read(fn))
+ hash = method.hexdigest()
+ lines.append("%s %s\n" % (hash, fn))
+ is_zipfile = True
+ except zipfile.BadZipFile:
+ is_zipfile = False
+ if not is_zipfile:
hash = _hasher(hashlib.sha256(), filename)
lines.append("%s go.mod\n" % hash)
method = hashlib.sha256()
This function is known https://github.com/python/cpython/issues/72680 for false-positives. With python 3.13.5 there is one with https://vault.almalinux.org/10.0/CRB/x86_64_v2/os/Packages/jdom2-2.0.6.1-8.el10.noarch.rpm The double "is_zipfile = False" is redundant but likely more clear. Signed-off-by: Yann Dirson <yann.dirson@vates.tech> --- lib/bb/utils.py | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-)