From 14c4bbd1d9e5f87a7964fd69a60e7d21d69319ea Mon Sep 17 00:00:00 2001 From: maiphi <39464783+maiphi@users.noreply.github.com> Date: Sun, 20 May 2018 19:42:52 +0200 Subject: Make class SCons.Subst.Literal hashable When using Python 3, substitution of Literal objects requires the objects to be hashable, otherwise an error will be thrown. The hash value is that of the lstr member. --- src/engine/SCons/Subst.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/engine/SCons/Subst.py b/src/engine/SCons/Subst.py index 68d247f..0b4190b 100644 --- a/src/engine/SCons/Subst.py +++ b/src/engine/SCons/Subst.py @@ -86,6 +86,9 @@ class Literal(object): def __neq__(self, other): return not self.__eq__(other) + def __hash__(self): + return hash(self.lstr) + class SpecialAttrWrapper(object): """This is a wrapper for what we call a 'Node special attribute.' This is any of the attributes of a Node that we can reference from -- cgit v0.12 From 8d504fd00127bdcffcf436993aa8e8c89011c63e Mon Sep 17 00:00:00 2001 From: maiphi <39464783+maiphi@users.noreply.github.com> Date: Sun, 20 May 2018 20:13:45 +0200 Subject: Update Changes.txt with hashable Literal --- src/CHANGES.txt | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/CHANGES.txt b/src/CHANGES.txt index a4590d0..f9cb5c4 100644 --- a/src/CHANGES.txt +++ b/src/CHANGES.txt @@ -7,6 +7,10 @@ RELEASE 3.1.0.alpha.yyyymmdd - NEW DATE WILL BE INSERTED HERE + From Philipp Maierhöfer + - Added a __hash__ method to the class Scons.Subst.Literal. Required when substituting Literal + objects when SCons runs with Python 3. + From Richard West: - Add SConstruct.py, Sconstruct.py, sconstruct.py to the search path for the root SConstruct file. Allows easier debugging within Visual Studio -- cgit v0.12 From 21335a0ef0463d51ecc9ea9cc86c3388415f12aa Mon Sep 17 00:00:00 2001 From: Philipp Maierhoefer Date: Mon, 21 May 2018 11:43:56 +0200 Subject: Added a test case for expansion of Literal objects in ${_concat()} --- test/Subst/Literal.py | 52 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 test/Subst/Literal.py diff --git a/test/Subst/Literal.py b/test/Subst/Literal.py new file mode 100644 index 0000000..38ed3c4 --- /dev/null +++ b/test/Subst/Literal.py @@ -0,0 +1,52 @@ +#!/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 that Literal objects expand correctly in ${_concat()}. +""" + +import TestSCons + +test = TestSCons.TestSCons() + +test.write('SConstruct', """\ +env = Environment(PRE='pre=', MID=Literal('\$$ORIGIN'), SUF='') +print(env.subst('${_concat(PRE, MID, SUF, __env__)}')) +""") + +test.run() + +expect = """\ +pre=\$ORIGIN +""" + +test.run(arguments='-Q -q', stdout=expect) + +# Local Variables: +# tab-width:4 +# indent-tabs-mode:nil +# End: +# vim: set expandtab tabstop=4 shiftwidth=4: -- cgit v0.12 From 75059479aff3cd50b9e547858a56c39eabeb111f Mon Sep 17 00:00:00 2001 From: maiphi <39464783+maiphi@users.noreply.github.com> Date: Tue, 22 May 2018 13:53:23 +0200 Subject: Added missing pass_test() to Literal.py test --- test/Subst/Literal.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/test/Subst/Literal.py b/test/Subst/Literal.py index 38ed3c4..dec243d 100644 --- a/test/Subst/Literal.py +++ b/test/Subst/Literal.py @@ -45,6 +45,8 @@ pre=\$ORIGIN test.run(arguments='-Q -q', stdout=expect) +test.pass_test() + # Local Variables: # tab-width:4 # indent-tabs-mode:nil -- cgit v0.12