From 78384fe7e1101a3e628f097a7cc8386fc57fd7cd Mon Sep 17 00:00:00 2001 From: Charles Short Date: Mon, 12 Jul 2021 09:38:04 -0400 Subject: [PATCH] py3: Fix hashlib usage Python3 bytes object needs to be encoded before the md5 hash operation otherwise an a TypeError exception will be raised. Story: 2006796 Task: 42811 Signed-off-by: Charles Short Change-Id: I58bc974c1a7420e7824b025faccc39927f4d1c9e (cherry picked from commit 86f90e0f125c40b1953abe0f99f0a1e94618d147) --- python-fmclient/fmclient/fmclient/common/utils.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/python-fmclient/fmclient/fmclient/common/utils.py b/python-fmclient/fmclient/fmclient/common/utils.py index 2521f144..e0cefcfe 100644 --- a/python-fmclient/fmclient/fmclient/common/utils.py +++ b/python-fmclient/fmclient/fmclient/common/utils.py @@ -36,6 +36,7 @@ import textwrap from datetime import datetime from dateutil import parser +from oslo_utils import encodeutils from prettytable import ALL from prettytable import FRAME from prettytable import NONE @@ -55,7 +56,7 @@ class HelpFormatter(argparse.HelpFormatter): def safe_header(name, value): if value is not None and name in SENSITIVE_HEADERS: - h = hashlib.sha1(value) + h = hashlib.sha1(encodeutils.safe_encode(value)) d = h.hexdigest() return name, "{SHA1}%s" % d else: