[Scons-users] CPPDEFINES Unexpected Behavior

Strand, Kyle J kyle.strand at beckman.com
Wed Apr 10 15:48:11 EDT 2013


No, it doesn't, and it shouldn't be expected to. That produces the def string "def1=", which, I suppose, might be better than "def1=None", but still isn't correct; it should simply be "def1".

Even if this workaround functioned as desired (by creating a definition without an explicit value), I don't think None should be handled the way it currently is, because it's quite surprising given the documentation.

I do have a workaround: I've written a function "Define()" that takes a string, list of strings (not tuples), or dictionary. If the argument is a string or list of strings, the function parses the string(s) for '=', creates the appropriate list of tuples, and passes that to AppendUnique(). If the argument is a dictionary, it's passed unchanged to AppendUnique(). If developers want to create definitions without explicit values, they must use Define() with either a string or a list argument, rather than a dictionary argument. This works just fine, but it's still confusing and annoying that the Python value None is ever interpreted by Scons as a literal string.

________________________________
Kyle Strand, Software Intern
Beckman Coulter, Inc., Life Sciences Division
4862 Innovation Drive, Fort Collins, Colorado, 80525
(970) 204-7036
________________________________
From: scons-users-bounces at scons.org [scons-users-bounces at scons.org] on behalf of Dirk Bächle [tshortik at gmx.de]
Sent: Wednesday, April 10, 2013 1:34 PM
To: scons-users at scons.org
Subject: Re: [Scons-users] CPPDEFINES Unexpected Behavior

Hi Kyle,

On 10.04.2013 20:51, Strand, Kyle J wrote:
Some additional information:

[...]
I've discovered some really surprising and probably incorrect behavior with the environment's CPPDEFINES variable. According to the manpage,

[...]

This leads me to expect that if I use env.AppendUnique() with a dictionary argument, if any of the values in that dictionary are None, then the corresponding keys will be defined without an explicit value. However, this is not what happens. The following code:

env = Environment()
newdefs = {'def1':None}
env.AppendUnique(CPPDEFINES=newdefs)

causes 'def1' to be defined as the literal string 'None.'

Is this the desired behavior? If so, why? If not, I'll submit a bug report.


I'm not sure what the desired behaviour is, but this is what the code does: the replacement methods for the CPPDEFINES variable expect the prefix and suffix to be of type str(ing). That's what the function _concat_ixes(prefix, list, suffix, env) in Defaults.py tries to ensure by wrapping the prefix/suffix arguments in a str() call each. And this returns the 'None' in your example.

Does the workaround

newdefs = {'def1' : ''}

(defining an empty string) give you the desired result?

Best regards,

Dirk




Please be advised that this email may contain confidential
information. If you are not the intended recipient, please notify us
by email by replying to the sender and delete this message. The
sender disclaims that the content of this email constitutes an offer
to enter into, or the acceptance of, any agreement; provided that the
foregoing does not invalidate the binding effect of any digital or
other electronic reproduction of a manual signature that is included
in any attachment.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://four.pairlist.net/pipermail/scons-users/attachments/20130410/53bd8460/attachment.htm>


More information about the Scons-users mailing list