Skip to content

Commit 7f2838f

Browse files
author
Thomas Preud'homme
committed
[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 llvm-svn: 374303
1 parent c20e14e commit 7f2838f

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

lnt/lnttool/create.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,7 @@ def action_create(instance_path, name, config, wsgi, tmp_dir, db_dir,
113113
* INSTANCE_PATH should point to a directory that will keep
114114
LNT configuration.
115115
"""
116+
from builtins import bytes
116117
from .common import init_logger
117118
import hashlib
118119
import lnt.server.db.migrate
@@ -137,8 +138,12 @@ def action_create(instance_path, name, config, wsgi, tmp_dir, db_dir,
137138
tmp_path = os.path.join(basepath, tmp_dir)
138139
wsgi_path = os.path.join(basepath, wsgi)
139140
schemas_path = os.path.join(basepath, "schemas")
140-
secret_key = (secret_key or
141-
hashlib.sha1(str(random.getrandbits(256))).hexdigest())
141+
secret_key = (
142+
secret_key or
143+
hashlib.sha1(
144+
bytes(str(random.getrandbits(256)), encoding="ascii")
145+
).hexdigest()
146+
)
142147

143148
os.mkdir(instance_path)
144149
os.mkdir(tmp_path)

0 commit comments

Comments
 (0)