scons icon indicating copy to clipboard operation
scons copied to clipboard

environment overrides lost in call to added method

Open bdbaddog opened this issue 7 years ago • 1 comments

This issue was originally created at: 2009-06-04 00:37:06. This issue was reported by: liblit.

liblit said at 2009-06-04 00:37:06

When calling a builder, if any construction variable values are overriden or added, and if the build action calls a method added using AddMethod, then the construction variable overrides are silently lost.

Getting a bit into internals, it seems that those overrides cause an OverrideEnvironment instance to be created as a lightweight proxy around the "real" Environment instance. When the added method is called, though, it is given the "real" Environment instance as its first argument instead of the OverrideEnvironment instance. Thus, the variable additions/overrides stored in the OverrideEnvironment instance are lost.

This can lead to terribly confusing behavior. For example, suppose ShowVar is a function that was added to an environment using AddMethod. Then the following two calls yield different behavior when env is an OverrideEnvironment:

ShowVar(env)    # passes OverrideEnvironment (env) to ShowVar
env.ShowVar()   # passes real Environment (not env) to ShowVar

I assert that the second line above should behave as the first line does. When calling a method provided via AddMethod on an OverrideEnvironment, the OverrideEnvironment should be passed as the first argument.

liblit said at 2009-06-04 00:38:41

Created an attachment (id=612)

self-contained SConstruct demonstrating the problem

gregnoel said at 2009-08-27 15:33:31

Bug party triage. Very good analysis. Fix may fall out of Steven's new substitution mechanism, so have him look at it early in 2.x. Gary is backup just in case Steven doesn't get to it.

stevenknight said at 2009-11-10 18:00:19

stevenknight => issues@scons

liblit attached SConstruct at 2009-06-04 00:38:41.

self-contained SConstruct demonstrating the problem

bdbaddog avatar Jan 02 '18 13:01 bdbaddog

I just tried the attached SConstruct and it is not showing any problem. Perhaps fixed?

mwichmann avatar Oct 11 '20 15:10 mwichmann