[PATCH] D68903: [LNT] NFC: Fix order of globals and locals on exec
Hubert Tong via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Oct 11 22:01:22 PDT 2019
hubert.reinterpretcast created this revision.
hubert.reinterpretcast added reviewers: cmatthews, thopre, kristof.beyls.
Per https://docs.python.org/3/library/functions.html#exec, the order of `globals` comes before `locals`. Since `globals` and `locals` are always the same object for the call in question, we can remove `locals`, and thereby `globals` will be used for both the global and the local variables.
https://reviews.llvm.org/D68903
Files:
lnt/tests/nt.py
Index: lnt/tests/nt.py
===================================================================
--- lnt/tests/nt.py
+++ lnt/tests/nt.py
@@ -536,7 +536,7 @@
results = []
for name in test_modules:
# First, load the test module file.
- locals = globals = {}
+ globals = {}
test_path = os.path.join(config.test_suite_root, 'LNTBased', name)
# This is where shared code between test modules should go.
sys.path.append(os.path.join(config.test_suite_root, 'LNTBased/lib'))
@@ -544,7 +544,7 @@
module_path = os.path.join(test_path, 'TestModule')
module_file = open(module_path)
try:
- exec(module_file, locals, globals)
+ exec(module_file, globals)
except Exception:
info = traceback.format_exc()
fatal("unable to import test module: %r\n%s" % (
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D68903.224727.patch
Type: text/x-patch
Size: 878 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20191012/62c56a6e/attachment.bin>
More information about the llvm-commits
mailing list