From 67eaf2466596394d5765ba4026d34e7b822814ab Mon Sep 17 00:00:00 2001 From: =?utf8?q?Tom=C3=A1=C5=A1=20Jel=C3=ADnek?= Date: Thu, 3 Mar 2022 18:29:48 +0100 Subject: [PATCH] replace md5 with sha256 (#2905) MD5 is unavailable on systems with active FIPS mode. That makes black crash when run on such systems. --- CHANGES.md | 1 + src/black/mode.py | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index 5f9341d..b594e03 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -25,6 +25,7 @@ - Do not format `__pypackages__` directories by default (#2836) - Add support for specifying stable version with `--required-version` (#2832). - Avoid crashing when the user has no homedir (#2814) +- Avoid crashing when md5 is not available (#2905) ### Documentation diff --git a/src/black/mode.py b/src/black/mode.py index 6d45e3d..455ed36 100644 --- a/src/black/mode.py +++ b/src/black/mode.py @@ -4,7 +4,7 @@ Mostly around Python language feature support per version and Black configuratio chosen by the user. """ -from hashlib import md5 +from hashlib import sha256 import sys from dataclasses import dataclass, field @@ -182,6 +182,6 @@ class Mode: str(int(self.magic_trailing_comma)), str(int(self.experimental_string_processing)), str(int(self.preview)), - md5((",".join(sorted(self.python_cell_magics))).encode()).hexdigest(), + sha256((",".join(sorted(self.python_cell_magics))).encode()).hexdigest(), ] return ".".join(parts) -- 2.39.2