Discussion:
[Scons-users] Substitution of Literal() broken when using Python 3
Bill Deegan
2018-05-20 17:07:11 UTC
Permalink
Could you submit such as a pull request on github?

Thanks,
Bill
SCons Project co-manager.
Hi all,
note: this problem has been discussed on the mailing lists before, see
https://pairlist2.pair.net/pipermail/scons-dev/2017-June/004297.html, but
as of today it hasn't been fixed in the master branch and I didn't find a
corresponding issue in the bug tracker. In the following I propose a fix.
To reproduce the problem, create a SConstruct with the content
"""
Command('PHONY', '', 'echo $_RPATH', RPATH=Literal('\$$ORIGIN'))
"""
and run it with SCons with Python 3 (I tested with 3.6.5). This leads to
the error
scons: *** [PHONY] TypeError `unhashable type: 'Literal'' trying to
evaluate `${_concat(RPATHPREFIX, RPATH, RPATHSUFFIX, __env__)}'.
Note that with Python 2.7 it works fine.
A solution that works for me is to add a __hash__ method to the class
"""
diff --git a/src/engine/SCons/Subst.py b/src/engine/SCons/Subst.py
index 68d247f8..b0abf613 100644
--- a/src/engine/SCons/Subst.py
+++ b/src/engine/SCons/Subst.py
return 1
+ return hash(self.lstr)
+
return False
"""
I don't know why the Literal needs to be hashable in Python 3 but not in
Python 2. And I cannot decide if the above patch is a viable solution or if
the problem should be addressed somewhere else.
"""
import SCons
return hash(self.lstr)
"""
Then use HashableLiteral instead of Literal.
Cheers,
Philipp
_______________________________________________
Scons-users mailing list
https://pairlist4.pair.net/mailman/listinfo/scons-users
Loading...