[llvm] r199006 - lit: execfile() isn't present in Python 3.3
Alp Toker
alp at nuanti.com
Sat Jan 11 05:27:28 PST 2014
Author: alp
Date: Sat Jan 11 07:27:28 2014
New Revision: 199006
URL: http://llvm.org/viewvc/llvm-project?rev=199006&view=rev
Log:
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.
Modified:
llvm/trunk/utils/lit/lit/TestingConfig.py
Modified: llvm/trunk/utils/lit/lit/TestingConfig.py
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/lit/lit/TestingConfig.py?rev=199006&r1=199005&r2=199006&view=diff
==============================================================================
--- llvm/trunk/utils/lit/lit/TestingConfig.py (original)
+++ llvm/trunk/utils/lit/lit/TestingConfig.py Sat Jan 11 07:27:28 2014
@@ -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:
More information about the llvm-commits
mailing list