summaryrefslogtreecommitdiff
path: root/utils
diff options
context:
space:
mode:
authorAlp Toker <alp@nuanti.com>2014-01-11 13:27:28 +0000
committerAlp Toker <alp@nuanti.com>2014-01-11 13:27:28 +0000
commit4c28d2024faedfc9b622b474746872c6362f139f (patch)
treeaf666ee304c62a610b6a4fd9702dcfd0180aa6ee /utils
parent08be87bdfa834371299c590f6042671df3abfd8a (diff)
downloadllvm-4c28d2024faedfc9b622b474746872c6362f139f.tar.gz
llvm-4c28d2024faedfc9b622b474746872c6362f139f.tar.bz2
llvm-4c28d2024faedfc9b622b474746872c6362f139f.tar.xz
lit: execfile() isn't present in Python 3.3
On the other hand, exec(compile()) doesn't work in older Python versions in the 2.x series. This commit introduces exec(compile()) with a fallback to plain exec(). That'll hopefully hit the sweet spot in terms of version support. Followup to r198766 which added enhanced source locations for lit cfg parsing. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@199006 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'utils')
-rw-r--r--utils/lit/lit/TestingConfig.py17
1 files changed, 8 insertions, 9 deletions
diff --git a/utils/lit/lit/TestingConfig.py b/utils/lit/lit/TestingConfig.py
index 92f9a82358..97e0de3047 100644
--- a/utils/lit/lit/TestingConfig.py
+++ b/utils/lit/lit/TestingConfig.py
@@ -1,7 +1,7 @@
import os
import sys
-OldPy = sys.version_info[0] == 2 and sys.version_info[1] < 6
+OldPy = sys.version_info[0] == 2 and sys.version_info[1] < 7
class TestingConfig:
""""
@@ -75,13 +75,12 @@ class TestingConfig:
# Load the config script data.
data = None
- if OldPy:
- f = open(path)
- try:
- data = f.read()
- except:
- litConfig.fatal('unable to load config file: %r' % (path,))
- f.close()
+ f = open(path)
+ try:
+ data = f.read()
+ except:
+ litConfig.fatal('unable to load config file: %r' % (path,))
+ f.close()
# Execute the config script to initialize the object.
cfg_globals = dict(globals())
@@ -92,7 +91,7 @@ class TestingConfig:
if OldPy:
exec("exec data in cfg_globals")
else:
- execfile(path, cfg_globals)
+ exec(compile(data, path, 'exec'), cfg_globals, None)
if litConfig.debug:
litConfig.note('... loaded config %r' % path)
except SystemExit: