diff options
author | Mats Wichmann <mats@linux.com> | 2019-03-05 14:30:30 (GMT) |
---|---|---|
committer | Mats Wichmann <mats@linux.com> | 2019-03-05 14:41:09 (GMT) |
commit | 674ebaca7eef1706549e2d3ddbe563cb2f3864c6 (patch) | |
tree | 5d0b067cfcd7e3aaad100f1cd0baa2dcb7f0b957 /src | |
parent | 96380855bb73cd6b061d067b0059fbbb6573e020 (diff) | |
download | SCons-674ebaca7eef1706549e2d3ddbe563cb2f3864c6.zip SCons-674ebaca7eef1706549e2d3ddbe563cb2f3864c6.tar.gz SCons-674ebaca7eef1706549e2d3ddbe563cb2f3864c6.tar.bz2 |
[PYPY] [PY 3.8] add context mgr use in scons-time
To fix some test problems for pypy, which seem more prone to
problems of lost data if files are written and not explicitly
closed, add context managers on file opens in scons-time.
Also quiets warnings which are emitted by the much noisier
Python 3.8. Changes are to the scons-time script and to
the framework.
After visual inspection of outputs while debugging, switched
the framework's created tools in the scons-time area to use
os.linesep instead of explicit '\\n' strings, tools should
operate in a native way.
Signed-off-by: Mats Wichmann <mats@linux.com>
Diffstat (limited to 'src')
-rwxr-xr-x | src/CHANGES.txt | 1 | ||||
-rw-r--r-- | src/script/scons-time.py | 16 |
2 files changed, 13 insertions, 4 deletions
diff --git a/src/CHANGES.txt b/src/CHANGES.txt index 4d24611..205dcb2 100755 --- a/src/CHANGES.txt +++ b/src/CHANGES.txt @@ -34,6 +34,7 @@ RELEASE VERSION/DATE TO BE FILLED IN LATER - Add the textfile tool to the default tool list - Fix syntax on is/is not clauses: should not use with a literal - Properly retrieve exit code when catching SystemExit + - scons-time now uses context managers around file opens From Bernhard M. Wiedemann: - Do not store build host+user name if reproducible builds are wanted diff --git a/src/script/scons-time.py b/src/script/scons-time.py index d114f9a..5d0a042 100644 --- a/src/script/scons-time.py +++ b/src/script/scons-time.py @@ -814,7 +814,9 @@ class SConsTimer(object): self.title = a if self.config_file: - exec(open(self.config_file, 'r').read(), self.__dict__) + with open(self.config_file, 'r') as f: + config = f.read() + exec(config, self.__dict__) if self.chdir: os.chdir(self.chdir) @@ -933,7 +935,9 @@ class SConsTimer(object): self.title = a if self.config_file: - HACK_for_exec(open(self.config_file, 'r').read(), self.__dict__) + with open(self.config_file, 'r') as f: + config = f.read() + HACK_for_exec(config, self.__dict__) if self.chdir: os.chdir(self.chdir) @@ -1053,7 +1057,9 @@ class SConsTimer(object): object_name = args.pop(0) if self.config_file: - HACK_for_exec(open(self.config_file, 'r').read(), self.__dict__) + with open(self.config_file, 'r') as f: + config = f.read() + HACK_for_exec(config, self.__dict__) if self.chdir: os.chdir(self.chdir) @@ -1191,7 +1197,9 @@ class SConsTimer(object): sys.exit(1) if self.config_file: - exec(open(self.config_file, 'r').read(), self.__dict__) + with open(self.config_file, 'r') as f: + config = f.read() + exec(config, self.__dict__) if args: self.archive_list = args |