From 03dbdfc91995b4b9bd3360eafa0dead73a7019d3 Mon Sep 17 00:00:00 2001 From: William Deegan Date: Sat, 15 Feb 2020 20:36:39 -0800 Subject: Fix Issue #2904 - add useful error message when more than one Configure() contexts are opened --- src/engine/SCons/SConf.py | 3 +- test/Configure/fixture/SConstruct.issue-2906 | 5 ++ ...ssue-2906-useful-duplicate-configure-message.py | 57 ++++++++++++++++++++++ 3 files changed, 64 insertions(+), 1 deletion(-) create mode 100644 test/Configure/fixture/SConstruct.issue-2906 create mode 100644 test/Configure/issue-2906-useful-duplicate-configure-message.py diff --git a/src/engine/SCons/SConf.py b/src/engine/SCons/SConf.py index 50a1329..a5e443e 100644 --- a/src/engine/SCons/SConf.py +++ b/src/engine/SCons/SConf.py @@ -430,7 +430,8 @@ class SConfBase(object): SConfFS = SCons.Node.FS.default_fs or \ SCons.Node.FS.FS(env.fs.pathTop) if sconf_global is not None: - raise SCons.Errors.UserError + raise SCons.Errors.UserError("""User Called Configure() when another Configure() exists. + Please call .Finish() before creating and second Configure() context""") if log_file is not None: log_file = SConfFS.File(env.subst(log_file)) diff --git a/test/Configure/fixture/SConstruct.issue-2906 b/test/Configure/fixture/SConstruct.issue-2906 new file mode 100644 index 0000000..7763653 --- /dev/null +++ b/test/Configure/fixture/SConstruct.issue-2906 @@ -0,0 +1,5 @@ +env = Environment() +conf1 = Configure(env) +env2 = Environment() +# Error right here. You can't have two configure contexts in flight at the same time. +conf2 = Configure(env2) \ No newline at end of file diff --git a/test/Configure/issue-2906-useful-duplicate-configure-message.py b/test/Configure/issue-2906-useful-duplicate-configure-message.py new file mode 100644 index 0000000..716cb33 --- /dev/null +++ b/test/Configure/issue-2906-useful-duplicate-configure-message.py @@ -0,0 +1,57 @@ +#!/usr/bin/env python +# +# __COPYRIGHT__ +# +# Permission is hereby granted, free of charge, to any person obtaining +# a copy of this software and associated documentation files (the +# "Software"), to deal in the Software without restriction, including +# without limitation the rights to use, copy, modify, merge, publish, +# distribute, sublicense, and/or sell copies of the Software, and to +# permit persons to whom the Software is furnished to do so, subject to +# the following conditions: +# +# The above copyright notice and this permission notice shall be included +# in all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY +# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE +# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +# + +__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" + +""" +Verify useful error message when you create a second Configure context without +finalizing the previous one via conf.Finish() +This addresses Issue 2906: +https://github.com/SCons/scons/issues/2906 +""" + +import TestSCons + +test = TestSCons.TestSCons() +test.verbose_set(1) + +test.file_fixture('./fixture/SConstruct.issue-2906', 'SConstruct') + +test_SConstruct_path = test.workpath('SConstruct') + +expected_stdout = "scons: Reading SConscript files ...\n" + +expected_stderr = """ +scons: *** User Called Configure() when another Configure() exists. + Please call .Finish() before creating and second Configure() context +File "%s", line 5, in \n"""%test_SConstruct_path +test.run(stderr=expected_stderr, stdout=expected_stdout, status=2) + +test.pass_test() + +# Local Variables: +# tab-width:4 +# indent-tabs-mode:nil +# End: +# vim: set expandtab tabstop=4 shiftwidth=4: -- cgit v0.12 From 6363a46016bf9d834db3e1ab92b7303c070105ee Mon Sep 17 00:00:00 2001 From: William Deegan Date: Sat, 15 Feb 2020 20:38:18 -0800 Subject: Update CHANGES.txt --- src/CHANGES.txt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/CHANGES.txt b/src/CHANGES.txt index b3a7422..8806179 100755 --- a/src/CHANGES.txt +++ b/src/CHANGES.txt @@ -21,6 +21,8 @@ RELEASE VERSION/DATE TO BE FILLED IN LATER - Fix Github Issue #3550 - When using Substfile() with a value like Z:\mongo\build\install\bin the implementation using re.sub() would end up interpreting the string and finding regex escape characters where it should have been simply replacing existing text. Switched to use string.replace(). + - Fix Github Issue #2904 - Provide useful error message when more than one Configure Contexts are opened. + Only one open is allowed. You must call conf.Finish() to complete the currently open one before creating another From Jeremy Elson: - Updated design doc to use the correct syntax for Depends() -- cgit v0.12 From 283a1d3b52f3755733aa592eac99fab54feadd5b Mon Sep 17 00:00:00 2001 From: William Deegan Date: Sun, 16 Feb 2020 14:25:12 -0800 Subject: Updated error message per sugguestion by mwichmann --- src/engine/SCons/SConf.py | 2 +- test/Configure/issue-2906-useful-duplicate-configure-message.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/engine/SCons/SConf.py b/src/engine/SCons/SConf.py index a5e443e..685fa3e 100644 --- a/src/engine/SCons/SConf.py +++ b/src/engine/SCons/SConf.py @@ -430,7 +430,7 @@ class SConfBase(object): SConfFS = SCons.Node.FS.default_fs or \ SCons.Node.FS.FS(env.fs.pathTop) if sconf_global is not None: - raise SCons.Errors.UserError("""User Called Configure() when another Configure() exists. + raise SCons.Errors.UserError("""Configure() called while another Configure() exists. Please call .Finish() before creating and second Configure() context""") if log_file is not None: diff --git a/test/Configure/issue-2906-useful-duplicate-configure-message.py b/test/Configure/issue-2906-useful-duplicate-configure-message.py index 716cb33..c980bd3 100644 --- a/test/Configure/issue-2906-useful-duplicate-configure-message.py +++ b/test/Configure/issue-2906-useful-duplicate-configure-message.py @@ -43,7 +43,7 @@ test_SConstruct_path = test.workpath('SConstruct') expected_stdout = "scons: Reading SConscript files ...\n" expected_stderr = """ -scons: *** User Called Configure() when another Configure() exists. +scons: *** Configure() called while another Configure() exists. Please call .Finish() before creating and second Configure() context File "%s", line 5, in \n"""%test_SConstruct_path test.run(stderr=expected_stderr, stdout=expected_stdout, status=2) -- cgit v0.12 From 12a571916e7a09f36f987ca4a22f0d800e15a2cd Mon Sep 17 00:00:00 2001 From: William Deegan Date: Sun, 16 Feb 2020 18:40:43 -0800 Subject: Remove 'from __future__ import print_function' no longer needed as we're dropping < py 3.5 --- src/engine/SCons/BuilderTests.py | 2 -- src/engine/SCons/EnvironmentTests.py | 3 --- src/engine/SCons/Executor.py | 2 -- src/engine/SCons/Memoize.py | 2 -- src/engine/SCons/Node/FS.py | 2 -- src/engine/SCons/Node/FSTests.py | 2 -- src/engine/SCons/Node/__init__.py | 2 -- src/engine/SCons/Platform/__init__.py | 2 -- src/engine/SCons/SConf.py | 2 -- src/engine/SCons/SConsign.py | 3 --- src/engine/SCons/Script/Interactive.py | 2 -- src/engine/SCons/Script/Main.py | 3 --- src/engine/SCons/SubstTests.py | 2 -- src/engine/SCons/Taskmaster.py | 2 -- src/engine/SCons/Tool/DCommon.py | 2 -- src/engine/SCons/Tool/FortranCommon.py | 2 -- src/engine/SCons/Tool/MSCommon/common.py | 2 -- src/engine/SCons/Tool/cyglink.py | 2 +- src/engine/SCons/Tool/dmd.py | 2 -- .../SCons/Tool/docbook/docbook-xsl-1.76.1/extensions/docbook.py | 2 -- .../SCons/Tool/docbook/docbook-xsl-1.76.1/extensions/xslt.py | 2 -- src/engine/SCons/Tool/gdc.py | 2 -- src/engine/SCons/Tool/install.py | 2 -- src/engine/SCons/Tool/intelc.py | 2 -- src/engine/SCons/Tool/ldc.py | 2 -- src/engine/SCons/Tool/link.py | 2 -- src/engine/SCons/Tool/mslink.py | 2 -- src/engine/SCons/Tool/msvs.py | 3 --- src/engine/SCons/Tool/msvsTests.py | 2 -- src/engine/SCons/Tool/qt.py | 2 -- src/engine/SCons/Tool/rpmutils.py | 2 -- src/engine/SCons/Tool/swig.py | 2 -- src/engine/SCons/Tool/tex.py | 2 -- src/engine/SCons/dblite.py | 7 ++++--- src/script/scons-configure-cache.py | 1 - src/script/scons-time.py | 2 +- src/script/scons.py | 2 -- src/script/sconsign.py | 2 -- src/setup.py | 3 --- src/test_files.py | 2 -- src/test_interrupts.py | 2 -- src/test_pychecker.py | 2 -- src/test_setup.py | 2 -- src/test_strings.py | 2 -- 44 files changed, 6 insertions(+), 91 deletions(-) diff --git a/src/engine/SCons/BuilderTests.py b/src/engine/SCons/BuilderTests.py index b4286fd..acdc277 100644 --- a/src/engine/SCons/BuilderTests.py +++ b/src/engine/SCons/BuilderTests.py @@ -20,8 +20,6 @@ # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. # -from __future__ import print_function - __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" import SCons.compat diff --git a/src/engine/SCons/EnvironmentTests.py b/src/engine/SCons/EnvironmentTests.py index 01baba3..3db6499 100644 --- a/src/engine/SCons/EnvironmentTests.py +++ b/src/engine/SCons/EnvironmentTests.py @@ -20,9 +20,6 @@ # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. # - -from __future__ import print_function - __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" import SCons.compat diff --git a/src/engine/SCons/Executor.py b/src/engine/SCons/Executor.py index 28bb6ad..fb2224f 100644 --- a/src/engine/SCons/Executor.py +++ b/src/engine/SCons/Executor.py @@ -26,8 +26,6 @@ Nodes. # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -from __future__ import print_function - __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" import collections diff --git a/src/engine/SCons/Memoize.py b/src/engine/SCons/Memoize.py index 5bdcf42..0595fdf 100644 --- a/src/engine/SCons/Memoize.py +++ b/src/engine/SCons/Memoize.py @@ -20,8 +20,6 @@ # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. # -from __future__ import print_function - __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" __doc__ = """Memoizer diff --git a/src/engine/SCons/Node/FS.py b/src/engine/SCons/Node/FS.py index 6f16256..423ba76 100644 --- a/src/engine/SCons/Node/FS.py +++ b/src/engine/SCons/Node/FS.py @@ -31,8 +31,6 @@ that can be used by scripts or modules looking for the canonical default. # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -from __future__ import print_function - __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" import fnmatch diff --git a/src/engine/SCons/Node/FSTests.py b/src/engine/SCons/Node/FSTests.py index bbfdd1b..41d9381 100644 --- a/src/engine/SCons/Node/FSTests.py +++ b/src/engine/SCons/Node/FSTests.py @@ -20,8 +20,6 @@ # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. # -from __future__ import division, print_function - __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" import SCons.compat diff --git a/src/engine/SCons/Node/__init__.py b/src/engine/SCons/Node/__init__.py index 0b58282..c3565bf 100644 --- a/src/engine/SCons/Node/__init__.py +++ b/src/engine/SCons/Node/__init__.py @@ -19,8 +19,6 @@ be able to depend on any other type of "thing." """ -from __future__ import print_function - # # __COPYRIGHT__ # diff --git a/src/engine/SCons/Platform/__init__.py b/src/engine/SCons/Platform/__init__.py index 5e9a358..21e63b4 100644 --- a/src/engine/SCons/Platform/__init__.py +++ b/src/engine/SCons/Platform/__init__.py @@ -41,8 +41,6 @@ their own platform definition. # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. # -from __future__ import print_function - __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" import SCons.compat diff --git a/src/engine/SCons/SConf.py b/src/engine/SCons/SConf.py index 685fa3e..e0e492b 100644 --- a/src/engine/SCons/SConf.py +++ b/src/engine/SCons/SConf.py @@ -33,8 +33,6 @@ libraries are installed, if some command line options are supported etc. # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. # -from __future__ import print_function - __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" import SCons.compat diff --git a/src/engine/SCons/SConsign.py b/src/engine/SCons/SConsign.py index 1115f2a..a516e1f 100644 --- a/src/engine/SCons/SConsign.py +++ b/src/engine/SCons/SConsign.py @@ -26,9 +26,6 @@ Writing and reading information to the .sconsign file or files. # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. # - -from __future__ import print_function - __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" import SCons.compat diff --git a/src/engine/SCons/Script/Interactive.py b/src/engine/SCons/Script/Interactive.py index 59299f1..a414b4e 100644 --- a/src/engine/SCons/Script/Interactive.py +++ b/src/engine/SCons/Script/Interactive.py @@ -19,8 +19,6 @@ # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -from __future__ import print_function - __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" __doc__ = """ diff --git a/src/engine/SCons/Script/Main.py b/src/engine/SCons/Script/Main.py index a0d7f4c..f738503 100644 --- a/src/engine/SCons/Script/Main.py +++ b/src/engine/SCons/Script/Main.py @@ -10,9 +10,6 @@ some other module. If it's specific to the "scons" script invocation, it goes here. """ -from __future__ import print_function - - unsupported_python_version = (2, 6, 0) deprecated_python_version = (2, 7, 0) diff --git a/src/engine/SCons/SubstTests.py b/src/engine/SCons/SubstTests.py index c25b377..574e714 100644 --- a/src/engine/SCons/SubstTests.py +++ b/src/engine/SCons/SubstTests.py @@ -20,8 +20,6 @@ # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. # -from __future__ import print_function - __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" import SCons.compat diff --git a/src/engine/SCons/Taskmaster.py b/src/engine/SCons/Taskmaster.py index 1e5776c..2bbb732 100644 --- a/src/engine/SCons/Taskmaster.py +++ b/src/engine/SCons/Taskmaster.py @@ -20,8 +20,6 @@ # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -from __future__ import print_function - import sys __doc__ = """ diff --git a/src/engine/SCons/Tool/DCommon.py b/src/engine/SCons/Tool/DCommon.py index 71c4d8d..d29db3a 100644 --- a/src/engine/SCons/Tool/DCommon.py +++ b/src/engine/SCons/Tool/DCommon.py @@ -1,5 +1,3 @@ -from __future__ import print_function - """SCons.Tool.DCommon Common code for the various D tools. diff --git a/src/engine/SCons/Tool/FortranCommon.py b/src/engine/SCons/Tool/FortranCommon.py index cbb9a03..bfa1c1c 100644 --- a/src/engine/SCons/Tool/FortranCommon.py +++ b/src/engine/SCons/Tool/FortranCommon.py @@ -26,8 +26,6 @@ Stuff for processing Fortran, common to all fortran dialects. # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. # -from __future__ import print_function - __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" import re diff --git a/src/engine/SCons/Tool/MSCommon/common.py b/src/engine/SCons/Tool/MSCommon/common.py index 4ce605b..505136e 100644 --- a/src/engine/SCons/Tool/MSCommon/common.py +++ b/src/engine/SCons/Tool/MSCommon/common.py @@ -23,8 +23,6 @@ Common helper functions for working with the Microsoft tool chain. # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. # -from __future__ import print_function - __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" import copy diff --git a/src/engine/SCons/Tool/cyglink.py b/src/engine/SCons/Tool/cyglink.py index c3d78de..f19614c 100644 --- a/src/engine/SCons/Tool/cyglink.py +++ b/src/engine/SCons/Tool/cyglink.py @@ -8,7 +8,7 @@ selection method. """ -from __future__ import absolute_import, print_function +from __future__ import absolute_import import re import os diff --git a/src/engine/SCons/Tool/dmd.py b/src/engine/SCons/Tool/dmd.py index 6a64a72..3cc4ed0 100644 --- a/src/engine/SCons/Tool/dmd.py +++ b/src/engine/SCons/Tool/dmd.py @@ -1,5 +1,3 @@ -from __future__ import print_function - """SCons.Tool.dmd Tool-specific initialization for the Digital Mars D compiler. diff --git a/src/engine/SCons/Tool/docbook/docbook-xsl-1.76.1/extensions/docbook.py b/src/engine/SCons/Tool/docbook/docbook-xsl-1.76.1/extensions/docbook.py index de1375d..7e6a81a 100644 --- a/src/engine/SCons/Tool/docbook/docbook-xsl-1.76.1/extensions/docbook.py +++ b/src/engine/SCons/Tool/docbook/docbook-xsl-1.76.1/extensions/docbook.py @@ -1,7 +1,5 @@ # docbook.py: extension module # $Id: docbook.py 8353 2009-03-17 16:57:50Z mzjn $ -from __future__ import print_function - import sys import string import libxml2 diff --git a/src/engine/SCons/Tool/docbook/docbook-xsl-1.76.1/extensions/xslt.py b/src/engine/SCons/Tool/docbook/docbook-xsl-1.76.1/extensions/xslt.py index d5529b8..0a4ff92 100644 --- a/src/engine/SCons/Tool/docbook/docbook-xsl-1.76.1/extensions/xslt.py +++ b/src/engine/SCons/Tool/docbook/docbook-xsl-1.76.1/extensions/xslt.py @@ -1,7 +1,5 @@ #!/usr/bin/python -u # $Id: xslt.py 8353 2009-03-17 16:57:50Z mzjn $ -from __future__ import print_function - import sys import libxml2 import libxslt diff --git a/src/engine/SCons/Tool/gdc.py b/src/engine/SCons/Tool/gdc.py index 0c6a8ab..ecf4f3a 100644 --- a/src/engine/SCons/Tool/gdc.py +++ b/src/engine/SCons/Tool/gdc.py @@ -1,5 +1,3 @@ -from __future__ import print_function - """SCons.Tool.gdc Tool-specific initialization for the GDC compiler. diff --git a/src/engine/SCons/Tool/install.py b/src/engine/SCons/Tool/install.py index dcb3581..06f7902 100644 --- a/src/engine/SCons/Tool/install.py +++ b/src/engine/SCons/Tool/install.py @@ -29,8 +29,6 @@ selection method. # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. # -from __future__ import print_function - __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" import os diff --git a/src/engine/SCons/Tool/intelc.py b/src/engine/SCons/Tool/intelc.py index 778cba1..0880976 100644 --- a/src/engine/SCons/Tool/intelc.py +++ b/src/engine/SCons/Tool/intelc.py @@ -30,8 +30,6 @@ selection method. # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -from __future__ import division, print_function - __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" import math, sys, os.path, glob, string, re diff --git a/src/engine/SCons/Tool/ldc.py b/src/engine/SCons/Tool/ldc.py index 3e12199..f915569 100644 --- a/src/engine/SCons/Tool/ldc.py +++ b/src/engine/SCons/Tool/ldc.py @@ -1,5 +1,3 @@ -from __future__ import print_function - """SCons.Tool.ldc Tool-specific initialization for the LDC compiler. diff --git a/src/engine/SCons/Tool/link.py b/src/engine/SCons/Tool/link.py index 5d920fb..d52c90d 100644 --- a/src/engine/SCons/Tool/link.py +++ b/src/engine/SCons/Tool/link.py @@ -30,8 +30,6 @@ selection method. # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. # -from __future__ import print_function - __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" import sys diff --git a/src/engine/SCons/Tool/mslink.py b/src/engine/SCons/Tool/mslink.py index fc5f009..bab78d8 100644 --- a/src/engine/SCons/Tool/mslink.py +++ b/src/engine/SCons/Tool/mslink.py @@ -30,8 +30,6 @@ selection method. # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. # -from __future__ import print_function - __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" import os diff --git a/src/engine/SCons/Tool/msvs.py b/src/engine/SCons/Tool/msvs.py index 9952ccc..7332b49 100644 --- a/src/engine/SCons/Tool/msvs.py +++ b/src/engine/SCons/Tool/msvs.py @@ -29,9 +29,6 @@ selection method. # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - -from __future__ import print_function - __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" import SCons.compat diff --git a/src/engine/SCons/Tool/msvsTests.py b/src/engine/SCons/Tool/msvsTests.py index 38a100f..b3373ea 100644 --- a/src/engine/SCons/Tool/msvsTests.py +++ b/src/engine/SCons/Tool/msvsTests.py @@ -20,8 +20,6 @@ # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. # -from __future__ import print_function - __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" import os diff --git a/src/engine/SCons/Tool/qt.py b/src/engine/SCons/Tool/qt.py index 0c471f9..3dc87c0 100644 --- a/src/engine/SCons/Tool/qt.py +++ b/src/engine/SCons/Tool/qt.py @@ -31,8 +31,6 @@ selection method. # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. # -from __future__ import print_function - __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" import os.path diff --git a/src/engine/SCons/Tool/rpmutils.py b/src/engine/SCons/Tool/rpmutils.py index 566f8e1..2c4fb32 100644 --- a/src/engine/SCons/Tool/rpmutils.py +++ b/src/engine/SCons/Tool/rpmutils.py @@ -34,8 +34,6 @@ exact syntax. # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -from __future__ import print_function - __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" diff --git a/src/engine/SCons/Tool/swig.py b/src/engine/SCons/Tool/swig.py index f139a09..4d98494 100644 --- a/src/engine/SCons/Tool/swig.py +++ b/src/engine/SCons/Tool/swig.py @@ -7,8 +7,6 @@ It will usually be imported through the generic SCons.Tool.Tool() selection method. """ -from __future__ import print_function - # # __COPYRIGHT__ # diff --git a/src/engine/SCons/Tool/tex.py b/src/engine/SCons/Tool/tex.py index fa18cf9..1d61e2d 100644 --- a/src/engine/SCons/Tool/tex.py +++ b/src/engine/SCons/Tool/tex.py @@ -31,8 +31,6 @@ selection method. # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. # -from __future__ import print_function - __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" import os.path diff --git a/src/engine/SCons/dblite.py b/src/engine/SCons/dblite.py index 55254b3..8351017 100644 --- a/src/engine/SCons/dblite.py +++ b/src/engine/SCons/dblite.py @@ -1,6 +1,7 @@ -# dblite.py module contributed by Ralf W. Grosse-Kunstleve. -# Extended for Unicode by Steven Knight. -from __future__ import print_function +""" +dblite.py module contributed by Ralf W. Grosse-Kunstleve. +Extended for Unicode by Steven Knight. +""" import os import pickle diff --git a/src/script/scons-configure-cache.py b/src/script/scons-configure-cache.py index a687c9c..716315c 100644 --- a/src/script/scons-configure-cache.py +++ b/src/script/scons-configure-cache.py @@ -31,7 +31,6 @@ digits of the signature. The prefix length used for directory names can be changed by this script. """ -from __future__ import print_function import argparse import glob import json diff --git a/src/script/scons-time.py b/src/script/scons-time.py index 91a105b..0fcd1c4 100644 --- a/src/script/scons-time.py +++ b/src/script/scons-time.py @@ -29,7 +29,7 @@ # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -from __future__ import division, print_function +from __future__ import division __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" diff --git a/src/script/scons.py b/src/script/scons.py index 2e76365..1e12898 100755 --- a/src/script/scons.py +++ b/src/script/scons.py @@ -23,8 +23,6 @@ # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -from __future__ import print_function - __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" __version__ = "__VERSION__" diff --git a/src/script/sconsign.py b/src/script/sconsign.py index 5ea5ea5..726838c 100644 --- a/src/script/sconsign.py +++ b/src/script/sconsign.py @@ -23,8 +23,6 @@ # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -from __future__ import print_function - __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" __version__ = "__VERSION__" diff --git a/src/setup.py b/src/setup.py index 0f9a672..261e2a4 100755 --- a/src/setup.py +++ b/src/setup.py @@ -20,9 +20,6 @@ # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -from __future__ import print_function - - import distutils.command.build_scripts import distutils.command.install_scripts import distutils.command.install_lib diff --git a/src/test_files.py b/src/test_files.py index 1eee11d..fcb2b4c 100644 --- a/src/test_files.py +++ b/src/test_files.py @@ -21,8 +21,6 @@ # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. # -from __future__ import print_function - __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" """ diff --git a/src/test_interrupts.py b/src/test_interrupts.py index 8e1b379..1cac046 100644 --- a/src/test_interrupts.py +++ b/src/test_interrupts.py @@ -21,8 +21,6 @@ # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -from __future__ import print_function - __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" """ diff --git a/src/test_pychecker.py b/src/test_pychecker.py index 56233c2..fdc8d20 100644 --- a/src/test_pychecker.py +++ b/src/test_pychecker.py @@ -20,8 +20,6 @@ # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -from __future__ import print_function - __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" """ diff --git a/src/test_setup.py b/src/test_setup.py index d9fa5b5..8410be3 100644 --- a/src/test_setup.py +++ b/src/test_setup.py @@ -21,8 +21,6 @@ # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. # -from __future__ import print_function - __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" """ diff --git a/src/test_strings.py b/src/test_strings.py index a8a5000..b43340f 100644 --- a/src/test_strings.py +++ b/src/test_strings.py @@ -21,8 +21,6 @@ # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. # -from __future__ import print_function - __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" """ -- cgit v0.12 From ae0891eece6e36b9e261de807979fd4d35dcc4e2 Mon Sep 17 00:00:00 2001 From: William Deegan Date: Mon, 17 Feb 2020 10:28:35 -0800 Subject: remove remaining from __future__ imports --- src/engine/SCons/Defaults.py | 2 -- src/engine/SCons/TaskmasterTests.py | 2 -- src/engine/SCons/Tool/cyglink.py | 2 -- src/engine/SCons/Tool/f08.py | 2 -- src/engine/SCons/cppTests.py | 3 --- 5 files changed, 11 deletions(-) diff --git a/src/engine/SCons/Defaults.py b/src/engine/SCons/Defaults.py index a69d8b0..2bac41e 100644 --- a/src/engine/SCons/Defaults.py +++ b/src/engine/SCons/Defaults.py @@ -31,8 +31,6 @@ from distutils.msvccompiler. # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. # -from __future__ import division - __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" diff --git a/src/engine/SCons/TaskmasterTests.py b/src/engine/SCons/TaskmasterTests.py index 1a47230..58a31aa 100644 --- a/src/engine/SCons/TaskmasterTests.py +++ b/src/engine/SCons/TaskmasterTests.py @@ -20,8 +20,6 @@ # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. # -from __future__ import division - __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" import SCons.compat diff --git a/src/engine/SCons/Tool/cyglink.py b/src/engine/SCons/Tool/cyglink.py index f19614c..fbb6d24 100644 --- a/src/engine/SCons/Tool/cyglink.py +++ b/src/engine/SCons/Tool/cyglink.py @@ -8,8 +8,6 @@ selection method. """ -from __future__ import absolute_import - import re import os diff --git a/src/engine/SCons/Tool/f08.py b/src/engine/SCons/Tool/f08.py index 7fa5872..64bac8e 100644 --- a/src/engine/SCons/Tool/f08.py +++ b/src/engine/SCons/Tool/f08.py @@ -8,8 +8,6 @@ selection method. """ -from __future__ import absolute_import - # # __COPYRIGHT__ # diff --git a/src/engine/SCons/cppTests.py b/src/engine/SCons/cppTests.py index eff7715..eb9189d 100644 --- a/src/engine/SCons/cppTests.py +++ b/src/engine/SCons/cppTests.py @@ -20,9 +20,6 @@ # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. # - -from __future__ import absolute_import - __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" import atexit -- cgit v0.12 From 0a6189cb492728a839d753d1a96e96d8a6cabcf9 Mon Sep 17 00:00:00 2001 From: William Deegan Date: Mon, 17 Feb 2020 12:32:29 -0800 Subject: Clean up collections to switch to collections.abc where possible --- src/engine/SCons/ActionTests.py | 2 -- src/engine/SCons/Builder.py | 8 ++++---- src/engine/SCons/BuilderTests.py | 4 ++-- src/engine/SCons/DefaultsTests.py | 2 -- src/engine/SCons/Tool/MSCommon/vc.py | 19 ------------------- src/engine/SCons/Tool/__init__.py | 7 +------ src/engine/SCons/Util.py | 7 ++----- 7 files changed, 9 insertions(+), 40 deletions(-) diff --git a/src/engine/SCons/ActionTests.py b/src/engine/SCons/ActionTests.py index 3303750..c61a4c7 100644 --- a/src/engine/SCons/ActionTests.py +++ b/src/engine/SCons/ActionTests.py @@ -37,10 +37,8 @@ class GlobalActFunc(object): pass -import collections import io import os -import re import sys import types import unittest diff --git a/src/engine/SCons/Builder.py b/src/engine/SCons/Builder.py index 13949e5..3f0be63 100644 --- a/src/engine/SCons/Builder.py +++ b/src/engine/SCons/Builder.py @@ -100,7 +100,7 @@ There are the following methods for internal use within this module: __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" -import collections +from collections import UserDict, UserList import SCons.Action import SCons.Debug @@ -197,7 +197,7 @@ class DictEmitter(SCons.Util.Selector): target, source = emitter(target, source, env) return (target, source) -class ListEmitter(collections.UserList): +class ListEmitter(UserList): """A callable list of emitters that calls each in sequence, returning the result. """ @@ -215,7 +215,7 @@ misleading_keywords = { 'sources' : 'source', } -class OverrideWarner(collections.UserDict): +class OverrideWarner(UserDict): """A class for warning about keyword arguments that we use as overrides in a Builder call. @@ -224,7 +224,7 @@ class OverrideWarner(collections.UserDict): warnings once, no matter how many Builders are invoked. """ def __init__(self, dict): - collections.UserDict.__init__(self, dict) + UserDict.__init__(self, dict) if SCons.Debug.track_instances: logInstanceCreation(self, 'Builder.OverrideWarner') self.already_warned = None def warn(self): diff --git a/src/engine/SCons/BuilderTests.py b/src/engine/SCons/BuilderTests.py index acdc277..2f72832 100644 --- a/src/engine/SCons/BuilderTests.py +++ b/src/engine/SCons/BuilderTests.py @@ -31,7 +31,7 @@ import SCons.compat def Func(): pass -import collections +from collections import UserList import io import os.path import re @@ -254,7 +254,7 @@ class BuilderTestCase(unittest.TestCase): assert not hasattr(n2, 'env') l = [1] - ul = collections.UserList([2]) + ul = UserList([2]) try: l.extend(ul) except TypeError: diff --git a/src/engine/SCons/DefaultsTests.py b/src/engine/SCons/DefaultsTests.py index 2cbad70..34941bc 100644 --- a/src/engine/SCons/DefaultsTests.py +++ b/src/engine/SCons/DefaultsTests.py @@ -29,8 +29,6 @@ import os import sys import unittest -from collections import UserDict - import TestCmd import SCons.Errors diff --git a/src/engine/SCons/Tool/MSCommon/vc.py b/src/engine/SCons/Tool/MSCommon/vc.py index ed713d0..82fb6b9 100644 --- a/src/engine/SCons/Tool/MSCommon/vc.py +++ b/src/engine/SCons/Tool/MSCommon/vc.py @@ -46,9 +46,6 @@ import platform import sys from string import digits as string_digits from subprocess import PIPE -#TODO: Python 2 cleanup -if sys.version_info[0] == 2: - import collections import SCons.Warnings from SCons.Tool import find_program_path @@ -697,22 +694,6 @@ def script_env(script, args=None): script_env_cache[cache_key] = cache_data # once we updated cache, give a chance to write out if user wanted common.write_script_env_cache(script_env_cache) - else: - #TODO: Python 2 cleanup - # If we "hit" data from the json file, we have a Py2 problem: - # keys & values will be unicode. don't detect, just convert. - if sys.version_info[0] == 2: - def convert(data): - if isinstance(data, basestring): - return str(data) - elif isinstance(data, collections.Mapping): - return dict(map(convert, data.iteritems())) - elif isinstance(data, collections.Iterable): - return type(data)(map(convert, data)) - else: - return data - - cache_data = convert(cache_data) return cache_data diff --git a/src/engine/SCons/Tool/__init__.py b/src/engine/SCons/Tool/__init__.py index 76a0913..7331a64 100644 --- a/src/engine/SCons/Tool/__init__.py +++ b/src/engine/SCons/Tool/__init__.py @@ -41,6 +41,7 @@ import sys import re import os import shutil +from collections.abc import Callable import SCons.Builder import SCons.Errors @@ -51,12 +52,6 @@ import SCons.Scanner.D import SCons.Scanner.LaTeX import SCons.Scanner.Prog import SCons.Scanner.SWIG -try: - # Python 3 - from collections.abc import Callable -except ImportError: - # Python 2.7 - from collections import Callable DefaultToolpath = [] diff --git a/src/engine/SCons/Util.py b/src/engine/SCons/Util.py index 130cc5e..d1baab2 100644 --- a/src/engine/SCons/Util.py +++ b/src/engine/SCons/Util.py @@ -34,15 +34,12 @@ import types import codecs import pprint import hashlib +from collections import UserDict, UserList, UserString, OrderedDict +from collections.abc import Iterable, MappingView PY3 = sys.version_info[0] == 3 PYPY = hasattr(sys, 'pypy_translation_info') - -from collections import UserDict, UserList, UserString -from collections.abc import Iterable, MappingView -from collections import OrderedDict - # Don't "from types import ..." these because we need to get at the # types module later to look for UnicodeType. -- cgit v0.12 From 83690c61e673b91b3e35cffdbc0a010296509e05 Mon Sep 17 00:00:00 2001 From: William Deegan Date: Mon, 17 Feb 2020 12:45:45 -0800 Subject: Fix some py3.8 warnings in doc SConscript --- doc/SConscript | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/doc/SConscript b/doc/SConscript index ff29a70..e43a27b 100644 --- a/doc/SConscript +++ b/doc/SConscript @@ -90,7 +90,8 @@ def writeVersionXml(verfile, date, ver, rev): os.makedirs(dir) except OSError: pass # okay if the directory already exists - open(verfile, "w").write(""" @@ -105,7 +106,7 @@ man_page_list = ['scons.1','scons-time.1','sconsign.1'] # Template for the MAN page texts when we can't properly # create them because the skip_doc flag is set (required # modules/tools aren't installed in the current system) -man_replace_tpl = """.TH "%(uctitle)s" "1" "%(today)s" "SCons %(version)s" "SCons %(version)s" +man_replace_tpl = r""".TH "%(uctitle)s" "1" "%(today)s" "SCons %(version)s" "SCons %(version)s" .ie \n(.g .ds Aq \(aq .el .ds Aq ' .nh -- cgit v0.12 From 7f77bd5474b7c154d029431ed1bb38c813f6c9fb Mon Sep 17 00:00:00 2001 From: William Deegan Date: Mon, 17 Feb 2020 15:34:03 -0800 Subject: Fix sider issue. Simplify code by removing py27 v py35+ --- src/engine/SCons/Util.py | 19 +++++-------------- 1 file changed, 5 insertions(+), 14 deletions(-) diff --git a/src/engine/SCons/Util.py b/src/engine/SCons/Util.py index d1baab2..fa6bc06 100644 --- a/src/engine/SCons/Util.py +++ b/src/engine/SCons/Util.py @@ -35,7 +35,7 @@ import codecs import pprint import hashlib from collections import UserDict, UserList, UserString, OrderedDict -from collections.abc import Iterable, MappingView +from collections.abc import MappingView PY3 = sys.version_info[0] == 3 PYPY = hasattr(sys, 'pypy_translation_info') @@ -356,27 +356,18 @@ def print_tree(root, child_func, prune=0, showtags=0, margin=[0], visited=None): DictTypes = (dict, UserDict) ListTypes = (list, UserList) -try: - # Handle getting dictionary views. - SequenceTypes = (list, tuple, UserList, MappingView) -except NameError: - SequenceTypes = (list, tuple, UserList) +# Handle getting dictionary views. +SequenceTypes = (list, tuple, UserList, MappingView) # Note that profiling data shows a speed-up when comparing # explicitly with str and unicode instead of simply comparing # with basestring. (at least on Python 2.5.1) -try: - StringTypes = (str, unicode, UserString) -except NameError: - StringTypes = (str, UserString) +StringTypes = (str, UserString) # Empirically, it is faster to check explicitly for str and # unicode than for basestring. -try: - BaseStringTypes = (str, unicode) -except NameError: - BaseStringTypes = str +BaseStringTypes = str def is_Dict(obj, isinstance=isinstance, DictTypes=DictTypes): return isinstance(obj, DictTypes) -- cgit v0.12 From 2298a1eeb3299f852af45e31c1829b9b3a35f4f1 Mon Sep 17 00:00:00 2001 From: William Deegan Date: Mon, 17 Feb 2020 15:55:10 -0800 Subject: remove PY3 variable from SCons.Util No longer needed --- src/engine/SCons/Util.py | 1 - 1 file changed, 1 deletion(-) diff --git a/src/engine/SCons/Util.py b/src/engine/SCons/Util.py index fa6bc06..0f2a27a 100644 --- a/src/engine/SCons/Util.py +++ b/src/engine/SCons/Util.py @@ -37,7 +37,6 @@ import hashlib from collections import UserDict, UserList, UserString, OrderedDict from collections.abc import MappingView -PY3 = sys.version_info[0] == 3 PYPY = hasattr(sys, 'pypy_translation_info') # Don't "from types import ..." these because we need to get at the -- cgit v0.12 From a70cd70c45384f4482b90b950e2ad49e6e50a7b7 Mon Sep 17 00:00:00 2001 From: William Deegan Date: Mon, 17 Feb 2020 16:22:02 -0800 Subject: replace dictionary initializations with simpler logic --- src/engine/SCons/Node/FS.py | 12 +++--------- src/engine/SCons/Node/FSTests.py | 5 +---- 2 files changed, 4 insertions(+), 13 deletions(-) diff --git a/src/engine/SCons/Node/FS.py b/src/engine/SCons/Node/FS.py index 423ba76..a268020 100644 --- a/src/engine/SCons/Node/FS.py +++ b/src/engine/SCons/Node/FS.py @@ -1547,9 +1547,7 @@ class Dir(Base): self.repositories = [] self.srcdir = None - self.entries = {} - self.entries['.'] = self - self.entries['..'] = self.dir + self.entries = {'.': self, '..': self.dir} self.cwd = self self.searched = 0 self._sconsign = None @@ -2304,10 +2302,8 @@ class RootDir(Dir): self._morph() self.duplicate = 0 - self._lookupDict = {} + self._lookupDict = {'': self, '/': self} - self._lookupDict[''] = self - self._lookupDict['/'] = self self.root = self # The // entry is necessary because os.path.normpath() # preserves double slashes at the beginning of a path on Posix @@ -2327,9 +2323,7 @@ class RootDir(Dir): self.repositories = [] self.srcdir = None - self.entries = {} - self.entries['.'] = self - self.entries['..'] = self.dir + self.entries = {'.': self, '..': self.dir} self.cwd = self self.searched = 0 self._sconsign = None diff --git a/src/engine/SCons/Node/FSTests.py b/src/engine/SCons/Node/FSTests.py index 41d9381..26c71b0 100644 --- a/src/engine/SCons/Node/FSTests.py +++ b/src/engine/SCons/Node/FSTests.py @@ -463,10 +463,7 @@ class VariantDirTestCase(unittest.TestCase): def __init__(self, duplicate, link, symlink, copy): self.duplicate = duplicate - self.have = {} - self.have['hard'] = link - self.have['soft'] = symlink - self.have['copy'] = copy + self.have = {'hard': link, 'soft': symlink, 'copy': copy} self.links_to_be_called = [] for link in self.duplicate.split('-'): -- cgit v0.12 From b22e98ed4f611eabc05aec9aa1c991f0f918967a Mon Sep 17 00:00:00 2001 From: William Deegan Date: Mon, 17 Feb 2020 16:26:53 -0800 Subject: more code cleanup found by pycharm --- .../SCons/Tool/docbook/docbook-xsl-1.76.1/extensions/docbook.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/engine/SCons/Tool/docbook/docbook-xsl-1.76.1/extensions/docbook.py b/src/engine/SCons/Tool/docbook/docbook-xsl-1.76.1/extensions/docbook.py index 7e6a81a..3d53bf7 100644 --- a/src/engine/SCons/Tool/docbook/docbook-xsl-1.76.1/extensions/docbook.py +++ b/src/engine/SCons/Tool/docbook/docbook-xsl-1.76.1/extensions/docbook.py @@ -67,9 +67,9 @@ def adjustColumnWidths(ctx, nodeset): relPart = 0.0 absPart = 0.0 - starPos = string.find(width, "*") + starPos = width.find("*") if starPos >= 0: - relPart, absPart = string.split(width, "*", 2) + relPart, absPart = width.split("*", 2) relPart = float(relPart) relTotal = relTotal + float(relPart) else: @@ -111,7 +111,7 @@ def adjustColumnWidths(ctx, nodeset): widths = correctRoundingError(widths) else: pixelWidth = nominalWidth - if string.find(tableWidth, "%") < 0: + if '%' not in tableWidth: pixelWidth = convertLength(tableWidth) if pixelWidth <= absTotal: @@ -125,7 +125,7 @@ def adjustColumnWidths(ctx, nodeset): relParts[count] = rel + absParts[count] absTotal = absTotal + rel + absParts[count] - if string.find(tableWidth, "%") < 0: + if '%' not in tableWidth: for count in range(len(relParts)): if foStylesheet: pixels = relParts[count] -- cgit v0.12 From 155c43a058bcd6fa1bccd0ed89fb778eaa598958 Mon Sep 17 00:00:00 2001 From: William Deegan Date: Mon, 17 Feb 2020 16:27:33 -0800 Subject: more code cleanup found by pycharm --- bin/import-test.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/import-test.py b/bin/import-test.py index 65b6e79..6a71a37 100644 --- a/bin/import-test.py +++ b/bin/import-test.py @@ -82,7 +82,7 @@ def print_files(dir): for dirpath, dirnames, filenames in os.walk(directory): dir = lookup(dirpath) - for f in fnames: + for f in filenames: dir.entries[f] = None subdir_list = [] -- cgit v0.12 From 5b2f62cb7d8e7b91ab0dcf6fcda830df93d54221 Mon Sep 17 00:00:00 2001 From: William Deegan Date: Mon, 17 Feb 2020 16:29:30 -0800 Subject: Fix reference to obsolete urllib.urlretrieve, now urllib.request.urlretrieve --- bin/install_scons.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/install_scons.py b/bin/install_scons.py index ac79fd3..ed919f8 100644 --- a/bin/install_scons.py +++ b/bin/install_scons.py @@ -25,7 +25,7 @@ import os import shutil import sys import tarfile -from urllib import urlretrieve +from urllib.request import urlretrieve from Command import CommandRunner, Usage -- cgit v0.12 From 5bc5aac03463900b731b352940459ca5270c7ac5 Mon Sep 17 00:00:00 2001 From: William Deegan Date: Mon, 17 Feb 2020 16:34:32 -0800 Subject: remove unicode reference in ActionTests.py --- src/engine/SCons/ActionTests.py | 8 -------- 1 file changed, 8 deletions(-) diff --git a/src/engine/SCons/ActionTests.py b/src/engine/SCons/ActionTests.py index c61a4c7..4784abf 100644 --- a/src/engine/SCons/ActionTests.py +++ b/src/engine/SCons/ActionTests.py @@ -337,14 +337,6 @@ class ActionTestCase(unittest.TestCase): # a singleton list returns the contained action test_positional_args(cmd_action, ["string"]) - try: - unicode - except NameError: - pass - else: - a2 = eval("SCons.Action.Action(u'string')") - assert isinstance(a2, SCons.Action.CommandAction), a2 - def line_action(a): assert isinstance(a, SCons.Action.CommandAction), a assert a.cmd_list == ["explicit", "command", "line"], a.cmd_list -- cgit v0.12 From d741d87697bdd305335df0e2b76c1e61d70de663 Mon Sep 17 00:00:00 2001 From: William Deegan Date: Mon, 17 Feb 2020 16:37:38 -0800 Subject: remove unicode from dblite.py --- src/engine/SCons/dblite.py | 22 ++-------------------- 1 file changed, 2 insertions(+), 20 deletions(-) diff --git a/src/engine/SCons/dblite.py b/src/engine/SCons/dblite.py index 8351017..5ac77a5 100644 --- a/src/engine/SCons/dblite.py +++ b/src/engine/SCons/dblite.py @@ -18,26 +18,14 @@ def corruption_warning(filename): print("Warning: Discarding corrupt database:", filename) -try: - unicode -except NameError: - def is_string(s): - return isinstance(s, str) -else: - def is_string(s): - return type(s) in (str, unicode) +def is_string(s): + return isinstance(s, str) def is_bytes(s): return isinstance(s, bytes) -try: - unicode('a') -except NameError: - def unicode(s): - return s - dblite_suffix = '.dblite' # TODO: Does commenting this out break switching from py2/3? @@ -217,23 +205,17 @@ def _exercise(): assert len(db) == 0 db["foo"] = "bar" assert db["foo"] == "bar" - db[unicode("ufoo")] = unicode("ubar") - assert db[unicode("ufoo")] == unicode("ubar") db.sync() db = open("tmp", "c") assert len(db) == 2, len(db) assert db["foo"] == "bar" db["bar"] = "foo" assert db["bar"] == "foo" - db[unicode("ubar")] = unicode("ufoo") - assert db[unicode("ubar")] == unicode("ufoo") db.sync() db = open("tmp", "r") assert len(db) == 4, len(db) assert db["foo"] == "bar" assert db["bar"] == "foo" - assert db[unicode("ufoo")] == unicode("ubar") - assert db[unicode("ubar")] == unicode("ufoo") try: db.sync() except IOError as e: -- cgit v0.12 From d750da6bcc95931b0f492c318c6937b6016b73a4 Mon Sep 17 00:00:00 2001 From: William Deegan Date: Mon, 17 Feb 2020 16:39:11 -0800 Subject: removing unicode from UtilTests.py --- src/engine/SCons/UtilTests.py | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/engine/SCons/UtilTests.py b/src/engine/SCons/UtilTests.py index ee07e61..4968a77 100644 --- a/src/engine/SCons/UtilTests.py +++ b/src/engine/SCons/UtilTests.py @@ -313,7 +313,7 @@ class UtilTestCase(unittest.TestCase): """ Test the to_Bytes method""" self.assertEqual(to_bytes('Hello'), bytearray('Hello', 'utf-8'), - "Check that to_bytes creates byte array when presented with unicode string.") + "Check that to_bytes creates byte array when presented with non byte string.") def test_to_String(self): """Test the to_String() method.""" @@ -761,9 +761,6 @@ bling def test_intern(self): s1 = silent_intern("spam") - # TODO: Python 3.x does not have a unicode() global function - if sys.version[0] == '2': - s2 = silent_intern(unicode("unicode spam")) s3 = silent_intern(42) s4 = silent_intern("spam") assert id(s1) == id(s4) -- cgit v0.12 From 31406d8059594246bff3f5cca945f82301cc8c32 Mon Sep 17 00:00:00 2001 From: William Deegan Date: Mon, 17 Feb 2020 16:45:06 -0800 Subject: More unicode removal and cleanup --- src/engine/SCons/Util.py | 28 +++++++++++++--------------- 1 file changed, 13 insertions(+), 15 deletions(-) diff --git a/src/engine/SCons/Util.py b/src/engine/SCons/Util.py index 0f2a27a..22df6fa 100644 --- a/src/engine/SCons/Util.py +++ b/src/engine/SCons/Util.py @@ -39,9 +39,6 @@ from collections.abc import MappingView PYPY = hasattr(sys, 'pypy_translation_info') -# Don't "from types import ..." these because we need to get at the -# types module later to look for UnicodeType. - # Below not used? # InstanceType = types.InstanceType @@ -358,14 +355,13 @@ ListTypes = (list, UserList) # Handle getting dictionary views. SequenceTypes = (list, tuple, UserList, MappingView) - +# TODO: PY3 check this benchmarking is still correct. # Note that profiling data shows a speed-up when comparing -# explicitly with str and unicode instead of simply comparing +# explicitly with str instead of simply comparing # with basestring. (at least on Python 2.5.1) StringTypes = (str, UserString) -# Empirically, it is faster to check explicitly for str and -# unicode than for basestring. +# Empirically, it is faster to check explicitly for str than for basestring. BaseStringTypes = str def is_Dict(obj, isinstance=isinstance, DictTypes=DictTypes): @@ -434,24 +430,25 @@ def flatten_sequence(sequence, isinstance=isinstance, StringTypes=StringTypes, do_flatten(item, result) return result -# Generic convert-to-string functions that abstract away whether or -# not the Python we're executing has Unicode support. The wrapper +# Generic convert-to-string functions. The wrapper # to_String_for_signature() will use a for_signature() method if the # specified object has one. # + + def to_String(s, isinstance=isinstance, str=str, UserString=UserString, BaseStringTypes=BaseStringTypes): - if isinstance(s,BaseStringTypes): + if isinstance(s, BaseStringTypes): # Early out when already a string! return s elif isinstance(s, UserString): - # s.data can only be either a unicode or a regular - # string. Please see the UserString initializer. + # s.data can only be a regular string. Please see the UserString initializer. return s.data else: return str(s) + def to_String_for_subst(s, isinstance=isinstance, str=str, to_String=to_String, BaseStringTypes=BaseStringTypes, SequenceTypes=SequenceTypes, @@ -463,12 +460,12 @@ def to_String_for_subst(s, elif isinstance(s, SequenceTypes): return ' '.join([to_String_for_subst(e) for e in s]) elif isinstance(s, UserString): - # s.data can only be either a unicode or a regular - # string. Please see the UserString initializer. + # s.data can only a regular string. Please see the UserString initializer. return s.data else: return str(s) + def to_String_for_signature(obj, to_String_for_subst=to_String_for_subst, AttributeError=AttributeError): try: @@ -478,6 +475,7 @@ def to_String_for_signature(obj, to_String_for_subst=to_String_for_subst, # pprint will output dictionary in key sorted order # with py3.5 the order was randomized. In general depending on dictionary order # which was undefined until py3.6 (where it's by insertion order) was not wise. + # TODO: Change code when floor is raised to PY36 return pprint.pformat(obj, width=1000000) else: return to_String_for_subst(obj) @@ -1495,7 +1493,7 @@ def MD5collect(signatures): def silent_intern(x): """ Perform sys.intern() on the passed argument and return the result. - If the input is ineligible (e.g. a unicode string) the original argument is + If the input is ineligible the original argument is returned and no exception is thrown. """ try: -- cgit v0.12 From d447cda50da33619e221e49b8f62f8723483e312 Mon Sep 17 00:00:00 2001 From: William Deegan Date: Mon, 17 Feb 2020 16:47:03 -0800 Subject: more unicode cleanup --- src/engine/SCons/BuilderTests.py | 16 ---------------- 1 file changed, 16 deletions(-) diff --git a/src/engine/SCons/BuilderTests.py b/src/engine/SCons/BuilderTests.py index 2f72832..d509219 100644 --- a/src/engine/SCons/BuilderTests.py +++ b/src/engine/SCons/BuilderTests.py @@ -306,22 +306,6 @@ class BuilderTestCase(unittest.TestCase): #be = target.get_build_env() #assert be['VAR'] == 'foo', be['VAR'] - try: unicode - except NameError: - uni = str - else: - uni = unicode - - target = builder(env, target = uni('n12 n13'), - source = [uni('n14 n15')])[0] - assert target.name == uni('n12 n13') - assert target.sources[0].name == uni('n14 n15') - - target = builder(env, target = [uni('n16 n17')], - source = uni('n18 n19'))[0] - assert target.name == uni('n16 n17') - assert target.sources[0].name == uni('n18 n19') - n20 = MyNode_without_target_from_source('n20') flag = 0 try: -- cgit v0.12 From 30394eb96f38142120beb4548918be4d5193f71e Mon Sep 17 00:00:00 2001 From: William Deegan Date: Mon, 17 Feb 2020 16:52:47 -0800 Subject: more unicode cleanup --- src/engine/SCons/Platform/win32.py | 3 --- src/engine/SCons/SConfTests.py | 10 +--------- src/engine/SCons/Scanner/ProgTests.py | 17 +---------------- 3 files changed, 2 insertions(+), 28 deletions(-) diff --git a/src/engine/SCons/Platform/win32.py b/src/engine/SCons/Platform/win32.py index bb1b46d..3258dfd 100644 --- a/src/engine/SCons/Platform/win32.py +++ b/src/engine/SCons/Platform/win32.py @@ -307,9 +307,6 @@ def get_system_root(): except: pass - # Ensure system root is a string and not unicode - # (This only matters for py27 were unicode in env passed to POpen fails) - val = str(val) _system_root = val return val diff --git a/src/engine/SCons/SConfTests.py b/src/engine/SCons/SConfTests.py index 40cd69d..63ec8f1 100644 --- a/src/engine/SCons/SConfTests.py +++ b/src/engine/SCons/SConfTests.py @@ -307,10 +307,6 @@ int main(void) { return None def actionFAIL(target, source, env): return 1 - def actionUnicode(target, source, env): - with open(str(target[0]), "wb") as f: - f.write('2\302\242\n') - return None self._resetSConfState() @@ -319,14 +315,10 @@ int main(void) { log_file=self.test.workpath('config.log')) try: (ret, output) = sconf.TryAction(action=actionOK) - assert ret and output.encode('utf-8') == bytearray("RUN OK"+os.linesep,'utf-8'), (ret, output) + assert ret and output.encode('utf-8') == bytearray("RUN OK"+os.linesep, 'utf-8'), (ret, output) (ret, output) = sconf.TryAction(action=actionFAIL) assert not ret and output == "", (ret, output) - if not TestCmd.IS_PY3: - # GH Issue #3141 - unicode text and py2.7 crashes. - (ret, output) = sconf.TryAction(action=actionUnicode) - assert ret and output == u'2\xa2\n', (ret, output) finally: sconf.Finish() diff --git a/src/engine/SCons/Scanner/ProgTests.py b/src/engine/SCons/Scanner/ProgTests.py index 45fdcb2..8981fd4 100644 --- a/src/engine/SCons/Scanner/ProgTests.py +++ b/src/engine/SCons/Scanner/ProgTests.py @@ -43,6 +43,7 @@ libs = [ 'l1.lib', 'd1/l2.lib', 'd1/d2/l3.lib', for h in libs: test.write(h, "\n") + # define some helpers: class DummyEnvironment(object): @@ -254,22 +255,6 @@ def suite(): suite.addTest(ProgramScannerTestCase8()) suite.addTest(ProgramScannerTestCase9()) suite.addTest(ProgramScannerTestCase10()) - try: unicode - except NameError: pass - else: - code = """if 1: - class ProgramScannerTestCase4(unittest.TestCase): - def runTest(self): - env = DummyEnvironment(LIBPATH=[test.workpath("d1/d2"), - test.workpath("d1")], - LIBS=u'l2 l3'.split()) - s = SCons.Scanner.Prog.ProgramScanner() - path = s.path(env) - deps = s(DummyNode('dummy'), env, path) - assert deps_match(deps, ['d1/l2.lib', 'd1/d2/l3.lib']), map(str, deps) - suite.addTest(ProgramScannerTestCase4()) - \n""" - exec(code) return suite if __name__ == "__main__": -- cgit v0.12 From 46fc8314b5956313f4f7a3f3cbaf970f6f8616f5 Mon Sep 17 00:00:00 2001 From: William Deegan Date: Mon, 17 Feb 2020 16:57:44 -0800 Subject: more unicode cleanup --- src/engine/SCons/Action.py | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/src/engine/SCons/Action.py b/src/engine/SCons/Action.py index c6fc575..b22de60 100644 --- a/src/engine/SCons/Action.py +++ b/src/engine/SCons/Action.py @@ -628,17 +628,9 @@ class _ActionAction(ActionBase): """ In python 3, and in some of our tests, sys.stdout is a String io object, and it takes unicode strings only - In other cases it's a regular Python 2.x file object - which takes strings (bytes), and if you pass those a - unicode object they try to decode with 'ascii' codec - which fails if the cmd line has any hi-bit-set chars. - This code assumes s is a regular string, but should - work if it's unicode too. + This code assumes s is a regular string. """ - try: - sys.stdout.write(s + u"\n") - except UnicodeDecodeError: - sys.stdout.write(s + "\n") + sys.stdout.write(s + "\n") def __call__(self, target, source, env, exitstatfunc=_null, -- cgit v0.12