[Scons-dev] unhashable type: 'Literal'' trying to evaluate
Jason Kenny
dragon512 at live.com
Thu Oct 25 12:52:47 EDT 2018
I found the issue...
the problem in the easy to monkey patch view is to add to SCons.subst.Literal with a
def __hash__(self):
return hash(self.lstr)
The better fix would be to do this in SCons:
class Literal(collections.UserString):
"""A wrapper for a string. If you use this object wrapped
around a string, then it will be interpreted as literal.
When passed to the command interpreter, all special
characters will be escaped."""
def __init__(self, lstr):
self.data = lstr # should only need this... might need to add a property for the old lstr member
def escape(self, escape_func):
return escape_func(self.data)
def for_signature(self):
return self.data
def is_literal(self):
return 1
The core issue seems to be related in the PathListCache object. I am unclear why it works in py2. I would think the hash issue would show up here as well.
Jason
________________________________
From: Scons-dev <scons-dev-bounces at scons.org> on behalf of Jason Kenny <dragon512 at live.com>
Sent: Thursday, October 25, 2018 10:52 AM
To: SCons developer list
Subject: [Scons-dev] unhashable type: 'Literal'' trying to evaluate
Hi,
I working on getting Parts to work on py3. I think I have most of it working at this point, however I had an error that concerned me:
scons: *** [_build/build_debug_posix-x86_64/hello/hello] TypeError `unhashable type: 'Literal'' trying to evaluate `${_concat(RPATHPREFIX, RPATH, RPATHSUFFIX, __env__)}'
This happens as I tweak the RPATH value with some code like this:
rlst.append(self.env.Literal('{0}$$ORIGIN/{1}{0}'.format(quote, self.env.Dir('$INSTALL_BIN').rel_path(
self.env.Dir('$INSTALL_LIB')))))
should result in a value such as:
["'$$ORIGIN/../lib'"]
This works if I subst() directly at this point. However I am getting a stack ( below as it is long) like this which suggests some new behavior? This code should be fine and should not have broken. There is no funny stuff here in parts.. it a very basic value being set.
Do we know of an issues with Literal() in python 3?
meantime I going to start debugging this "fun" code
- Jason
The stack...
scons: internal stack trace:
File "/home/jkenny/.local/share/virtualenvs/parts-aMB9Fa3Q/lib/python3.6/site-packages/scons-3.0.1/SCons/Job.py", line 199, in start
task.prepare()
File "/home/jkenny/.local/share/virtualenvs/parts-aMB9Fa3Q/lib/python3.6/site-packages/scons-3.0.1/SCons/Script/Main.py", line 175, in prepare
return SCons.Taskmaster.OutOfDateTask.prepare(self)
File "/home/jkenny/.local/share/virtualenvs/parts-aMB9Fa3Q/lib/python3.6/site-packages/scons-3.0.1/SCons/Taskmaster.py", line 179, in prepare
self.exception_raise()
File "/home/jkenny/.local/share/virtualenvs/parts-aMB9Fa3Q/lib/python3.6/site-packages/scons-3.0.1/SCons/Taskmaster.py", line 554, in _exception_raise
exec("raise exc_value.with_traceback(exc_traceback)")
File "<string>", line 1, in <module>
File "/home/jkenny/.local/share/virtualenvs/parts-aMB9Fa3Q/lib/python3.6/site-packages/scons-3.0.1/SCons/Taskmaster.py", line 973, in next_task
task.make_ready()
File "/home/jkenny/.local/share/virtualenvs/parts-aMB9Fa3Q/lib/python3.6/site-packages/scons-3.0.1/SCons/Script/Main.py", line 309, in make_ready
SCons.Taskmaster.OutOfDateTask.make_ready(self)
File "/home/jkenny/.local/share/virtualenvs/parts-aMB9Fa3Q/lib/python3.6/site-packages/scons-3.0.1/SCons/Taskmaster.py", line 409, in make_ready_current
t.disambiguate().make_ready()
File "/home/jkenny/.local/share/virtualenvs/parts-aMB9Fa3Q/lib/python3.6/site-packages/scons-3.0.1/SCons/Node/FS.py", line 3055, in make_ready
self.get_binfo()
File "/home/jkenny/.local/share/virtualenvs/parts-aMB9Fa3Q/lib/python3.6/site-packages/scons-3.0.1/SCons/Node/__init__.py", line 1136, in get_binfo
binfo.bactsig = SCons.Util.MD5signature(executor.get_contents())
File "/home/jkenny/.local/share/virtualenvs/parts-aMB9Fa3Q/lib/python3.6/site-packages/scons-3.0.1/SCons/Executor.py", line 467, in get_contents
for action in action_list])
File "/home/jkenny/.local/share/virtualenvs/parts-aMB9Fa3Q/lib/python3.6/site-packages/scons-3.0.1/SCons/Executor.py", line 467, in <listcomp>
for action in action_list])
File "/home/jkenny/.local/share/virtualenvs/parts-aMB9Fa3Q/lib/python3.6/site-packages/scons-3.0.1/SCons/Action.py", line 535, in get_contents
result = self.get_presig(target, source, env)
File "/home/jkenny/.local/share/virtualenvs/parts-aMB9Fa3Q/lib/python3.6/site-packages/scons-3.0.1/SCons/Action.py", line 1112, in get_presig
return c.get_presig(self, target, source, env)
File "/home/jkenny/.local/share/virtualenvs/parts-aMB9Fa3Q/lib/python3.6/site-packages/scons-3.0.1/SCons/Action.py", line 1049, in get_presig
return self._generate(target, source, env, 1, executor).get_presig(target, source, env)
File "/home/jkenny/.local/share/virtualenvs/parts-aMB9Fa3Q/lib/python3.6/site-packages/scons-3.0.1/SCons/Action.py", line 1271, in get_presig
return b"".join([bytes(x.get_contents(target, source, env)) for x in self.list])
File "/home/jkenny/.local/share/virtualenvs/parts-aMB9Fa3Q/lib/python3.6/site-packages/scons-3.0.1/SCons/Action.py", line 1271, in <listcomp>
return b"".join([bytes(x.get_contents(target, source, env)) for x in self.list])
File "/home/jkenny/.local/share/virtualenvs/parts-aMB9Fa3Q/lib/python3.6/site-packages/scons-3.0.1/SCons/Action.py", line 535, in get_contents
result = self.get_presig(target, source, env)
File "/home/jkenny/.local/share/virtualenvs/parts-aMB9Fa3Q/lib/python3.6/site-packages/scons-3.0.1/SCons/Action.py", line 964, in get_presig
return env.subst_target_source(cmd, SUBST_SIG, target, source)
File "/home/jkenny/.local/share/virtualenvs/parts-aMB9Fa3Q/lib/python3.6/site-packages/scons-3.0.1/SCons/Environment.py", line 514, in subst
return SCons.Subst.scons_subst(string, self, raw, target, source, gvars, lvars, conv)
File "/home/jkenny/.local/share/virtualenvs/parts-aMB9Fa3Q/lib/python3.6/site-packages/scons-3.0.1/SCons/Subst.py", line 569, in scons_subst
result = ss.substitute(strSubst, lvars)
File "/home/jkenny/.local/share/virtualenvs/parts-aMB9Fa3Q/lib/python3.6/site-packages/scons-3.0.1/SCons/Subst.py", line 523, in substitute
result = _dollar_exps.sub(sub_match, args)
File "/home/jkenny/.local/share/virtualenvs/parts-aMB9Fa3Q/lib/python3.6/site-packages/scons-3.0.1/SCons/Subst.py", line 522, in sub_match
return self.conv(self.expand(match.group(1), lvars))
File "/home/jkenny/.local/share/virtualenvs/parts-aMB9Fa3Q/lib/python3.6/site-packages/scons-3.0.1/SCons/Subst.py", line 488, in expand
return self.substitute(s, lv)
File "/home/jkenny/.local/share/virtualenvs/parts-aMB9Fa3Q/lib/python3.6/site-packages/scons-3.0.1/SCons/Subst.py", line 523, in substitute
result = _dollar_exps.sub(sub_match, args)
File "/home/jkenny/.local/share/virtualenvs/parts-aMB9Fa3Q/lib/python3.6/site-packages/scons-3.0.1/SCons/Subst.py", line 522, in sub_match
return self.conv(self.expand(match.group(1), lvars))
File "/home/jkenny/.local/share/virtualenvs/parts-aMB9Fa3Q/lib/python3.6/site-packages/scons-3.0.1/SCons/Subst.py", line 488, in expand
return self.substitute(s, lv)
File "/home/jkenny/.local/share/virtualenvs/parts-aMB9Fa3Q/lib/python3.6/site-packages/scons-3.0.1/SCons/Subst.py", line 523, in substitute
result = _dollar_exps.sub(sub_match, args)
File "/home/jkenny/.local/share/virtualenvs/parts-aMB9Fa3Q/lib/python3.6/site-packages/scons-3.0.1/SCons/Subst.py", line 522, in sub_match
return self.conv(self.expand(match.group(1), lvars))
File "/home/jkenny/.local/share/virtualenvs/parts-aMB9Fa3Q/lib/python3.6/site-packages/scons-3.0.1/SCons/Subst.py", line 462, in expand
raise_exception(e, lvars['TARGETS'], s)
File "/home/jkenny/.local/share/virtualenvs/parts-aMB9Fa3Q/lib/python3.6/site-packages/scons-3.0.1/SCons/Subst.py", line 55, in raise_exception
raise SCons.Errors.BuildError(target[0], msg)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://pairlist2.pair.net/pipermail/scons-dev/attachments/20181025/64671767/attachment-0001.html>
More information about the Scons-dev
mailing list