[LNT] r374303 - [LNT] Python 3 support: adapt secret computation
Thomas Preud'homme via llvm-commits
llvm-commits at lists.llvm.org
Thu Oct 10 03:31:17 PDT 2019
Author: thopre
Date: Thu Oct 10 03:31:17 2019
New Revision: 374303
URL: http://llvm.org/viewvc/llvm-project?rev=374303&view=rev
Log:
[LNT] Python 3 support: adapt secret computation
Computation of the secret when it is not supplied on the command line
involves passing a string constructed with str to the sha1 function.
However that function expects binary data which is a different type in
Python3. This commit uses the bytes constructor as an additional step to
convert from text to binary data.
Reviewers: cmatthews, hubert.reinterpretcast, kristof.beyls
Reviewed By: hubert.reinterpretcast
Subscribers: llvm-commits
Differential Revision: https://reviews.llvm.org/D68104
Modified:
lnt/trunk/lnt/lnttool/create.py
Modified: lnt/trunk/lnt/lnttool/create.py
URL: http://llvm.org/viewvc/llvm-project/lnt/trunk/lnt/lnttool/create.py?rev=374303&r1=374302&r2=374303&view=diff
==============================================================================
--- lnt/trunk/lnt/lnttool/create.py (original)
+++ lnt/trunk/lnt/lnttool/create.py Thu Oct 10 03:31:17 2019
@@ -113,6 +113,7 @@ def action_create(instance_path, name, c
* INSTANCE_PATH should point to a directory that will keep
LNT configuration.
"""
+ from builtins import bytes
from .common import init_logger
import hashlib
import lnt.server.db.migrate
@@ -137,8 +138,12 @@ LNT configuration.
tmp_path = os.path.join(basepath, tmp_dir)
wsgi_path = os.path.join(basepath, wsgi)
schemas_path = os.path.join(basepath, "schemas")
- secret_key = (secret_key or
- hashlib.sha1(str(random.getrandbits(256))).hexdigest())
+ secret_key = (
+ secret_key or
+ hashlib.sha1(
+ bytes(str(random.getrandbits(256)), encoding="ascii")
+ ).hexdigest()
+ )
os.mkdir(instance_path)
os.mkdir(tmp_path)
More information about the llvm-commits
mailing list