llvm.org GIT mirror llvm / 4c28d20
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 Alp Toker 5 years ago
1 changed file(s) with 8 addition(s) and 9 deletion(s). Raw diff Collapse all Expand all
0 import os
11 import sys
22
3 OldPy = sys.version_info[0] == 2 and sys.version_info[1] < 6
3 OldPy = sys.version_info[0] == 2 and sys.version_info[1] < 7
44
55 class TestingConfig:
66 """"
7474
7575 # Load the config script data.
7676 data = None
77 if OldPy:
78 f = open(path)
79 try:
80 data = f.read()
81 except:
82 litConfig.fatal('unable to load config file: %r' % (path,))
83 f.close()
77 f = open(path)
78 try:
79 data = f.read()
80 except:
81 litConfig.fatal('unable to load config file: %r' % (path,))
82 f.close()
8483
8584 # Execute the config script to initialize the object.
8685 cfg_globals = dict(globals())
9190 if OldPy:
9291 exec("exec data in cfg_globals")
9392 else:
94 execfile(path, cfg_globals)
93 exec(compile(data, path, 'exec'), cfg_globals, None)
9594 if litConfig.debug:
9695 litConfig.note('... loaded config %r' % path)
9796 except SystemExit: