[Scons-dev] unhashable type: 'Literal'' trying to evaluate

Mats Wichmann mats at wichmann.us
Thu Oct 25 12:46:54 EDT 2018


On 10/25/2018 09:52 AM, Jason Kenny wrote:
> 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

A quick experiment leaves me scratching my head... under scons+py3 an
instance of Literal() has a __hash__ but has it set to None. That
despite that the Literal class defines a __hash__ function...

$ cat SConstruct
env = Environment()

x = env.Literal("foo")
print("Type: ", type(x))
if hasattr(x, '__hash__'):
    if x.__hash__:
        print("Hashable: %d" % x.__hash__())
    else:
        print("Has __hash__, but it is None")
else:
    print("No __hash__ method")
print(x)

$ scons
scons: Reading SConscript files ...
('Type: ', <class 'SCons.Subst.Literal'>)
Hashable: 8791304380589
foo
scons: done reading SConscript files.
scons: Building targets ...
scons: `.' is up to date.
scons: done building targets.

$ scons-3
scons: Reading SConscript files ...
Type:  <class 'SCons.Subst.Literal'>
Has __hash__, but it is None
foo
scons: done reading SConscript files.
scons: Building targets ...
scons: `.' is up to date.
scons: done building targets.


More information about the Scons-dev mailing list