Browse Source

scripts: west_commands: patch: Support Python 3.10

The west patch command used hashlib.file_digest which was introduced in
Python 3.11.
Replace with a loop to support Python 3.10 (the current minimum).

Signed-off-by: Pieter De Gendt <pieter.degendt@basalte.be>
pull/91106/head
Pieter De Gendt 1 month ago committed by Benjamin Cabé
parent
commit
c5d1e8e220
  1. 6
      scripts/west_commands/patch.py

6
scripts/west_commands/patch.py

@ -530,7 +530,11 @@ class Patch(WestCommand): @@ -530,7 +530,11 @@ class Patch(WestCommand):
@staticmethod
def get_file_sha256sum(filename: Path) -> str:
with open(filename, "rb") as fp:
digest = hashlib.file_digest(fp, "sha256")
# NOTE: If python 3.11 is the minimum, the following can be replaced with:
# digest = hashlib.file_digest(fp, "sha256")
digest = hashlib.new("sha256")
while chunk := fp.read(2**10):
digest.update(chunk)
return digest.hexdigest()

Loading…
Cancel
Save