[PATCH] D67534: [LNT] Python 3 support: Minor automatic 2to3 fixups
Thomas Preud'homme via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Sep 13 02:25:56 PDT 2019
thopre added a comment.
I got a lot more changes with futurize. In particular it adds:
+from builtins import map
+from builtins import zip
everywhere where map or zip is used, to ensure python3 behavior with python2.
================
Comment at: lnt/lnttool/create.py:162
wsgi_file.close()
- os.chmod(wsgi_path, 0755)
+ os.chmod(wsgi_path, 0o755)
----------------
I initially thought of using
os.chmod(wsgi_path, S_IRUSR|S_IWUSR|S_IXUSR|S_IRGRP|S_IWGRP|S_IROTH|S_IWOTH)
instead. Maybe 0o755 is indeed more readable.
================
Comment at: lnt/server/instance.py:57
config_data = {}
- exec open(config_path) in config_data
+ exec(open(config_path), config_data)
config = lnt.server.config.Config.from_data(config_path, config_data)
----------------
exec in Python3 does not read from a file descriptor according to the doc. You'd need exec(open(config_path).read(), config_data) AFAIK.
See [1] (which contains "If it is an open file, the file is parsed until EOF and executed") Vs [2] (which contains "object must be either a string or a code object").
[1] https://docs.python.org/2/reference/simple_stmts.html#grammar-token-exec-stmt
[2] https://docs.python.org/3/library/functions.html#exec
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D67534/new/
https://reviews.llvm.org/D67534
More information about the llvm-commits
mailing list