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 <charles.short@windriver.com> Change-Id: I58bc974c1a7420e7824b025faccc39927f4d1c9e
This commit is contained in:
parent
c18a7865c6
commit
86f90e0f12
|
@ -36,6 +36,7 @@ import textwrap
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
from dateutil import parser
|
from dateutil import parser
|
||||||
|
|
||||||
|
from oslo_utils import encodeutils
|
||||||
from prettytable import ALL
|
from prettytable import ALL
|
||||||
from prettytable import FRAME
|
from prettytable import FRAME
|
||||||
from prettytable import NONE
|
from prettytable import NONE
|
||||||
|
@ -56,7 +57,7 @@ class HelpFormatter(argparse.HelpFormatter):
|
||||||
|
|
||||||
def safe_header(name, value):
|
def safe_header(name, value):
|
||||||
if value is not None and name in SENSITIVE_HEADERS:
|
if value is not None and name in SENSITIVE_HEADERS:
|
||||||
h = hashlib.sha1(value)
|
h = hashlib.sha1(encodeutils.safe_encode(value))
|
||||||
d = h.hexdigest()
|
d = h.hexdigest()
|
||||||
return name, "{SHA1}%s" % d
|
return name, "{SHA1}%s" % d
|
||||||
else:
|
else:
|
||||||
|
|
Loading…
Reference in New Issue