[Scons-users] env.Dictionary bug? doc problem?

Mats Wichmann mats at wichmann.us
Mon Jul 23 10:46:49 EDT 2018


On 07/23/2018 07:51 AM, Mats Wichmann wrote:
> On 07/22/2018 12:26 PM, Bill Deegan wrote:
>> Can you check if any internal usage depends on this slicing behavior?
>>
>> -Bill
> 
> Plenty of impacts.
> 
> A bunch of tests are written to the idea that Dictionary(key) returns
> key's value, not a subset of the dictionary. 

looks like there's also an expectation that Dictionary() returns a view,
not a new dictionary, such that modifying something through a Dictionary
call "sticks". See the below test code - the modification of env2
through its Dictionary() - this will not work if Dictionary returns a
newly constructed dict, as I had imagined.

        # Ensure that lists and dictionaries are
        # deep copied, but not instances.
        class TestA(object):
            pass
        env1 = self.TestEnvironment(XXX=TestA(), YYY = [ 1, 2, 3 ],
                           ZZZ = { 1:2, 3:4 })
        env2=env1.Clone()
        env2.Dictionary('YYY').append(4)
        env2.Dictionary('ZZZ')[5] = 6
        assert env1.Dictionary('XXX') is env2.Dictionary('XXX')
        assert 4 in env2.Dictionary('YYY')
        assert not 4 in env1.Dictionary('YYY')
        assert 5 in env2.Dictionary('ZZZ')
        assert 5 not in env1.Dictionary('ZZZ')

Not really sure what to do with this.


More information about the Scons-users mailing list