Hi, I'm trying to make test/CPPDEFINES/append.py work with both py2 and py3. If I use a collections.OrderedDict subclass instead of a dict, then it is somehow preserved across environments. The attached minimal test case has the value generated in the Append() test preserved when AppendUnique() is called. Does anyone have a idea why this is happening before I delve into the code?
-- Regards, Gaurav Juvekar
from collections import OrderedDict
class OrderedPrintingDict(OrderedDict):
def __str__(self):
return '{' + ', '.join(['%r: %r'%(k, v) for (k, v) in self.items()]) + '}'
def __repr__(self):
return '{' + ', '.join(['%r: %r'%(k, v) for (k, v) in self.items()]) + '}'
# http://scons.tigris.org/issues/show_bug.cgi?id=1152
# http://scons.tigris.org/issues/show_bug.cgi?id=2900
cases=[('string', 'FOO'),
('list', ['NAME1', 'NAME2']),
('list-of-2lists', [('NAME1','VAL1'), ['NAME2','VAL2']]),
('dict', OrderedPrintingDict([('NAME2', 'VAL2'), ('NAME3', None), ('NAME1', 'VAL1')]))
]
t1, c1 = cases[3]
t2, c2 = cases[0]
print("==== Testing CPPDEFINES, appending a %s to a %s"%(t2, t1))
print(" orig = %s, append = %s"%(c1, c2))
env=Environment(CPPDEFINES = c1, CPPDEFPREFIX='-D')
env.Append(CPPDEFINES = c2)
final=env.subst('$_CPPDEFFLAGS',source="src", target="tgt")
print('Append:\n\tresult=%s\n\tfinal=%s'%\
(env['CPPDEFINES'], final))
env=Environment(CPPDEFINES = c1, CPPDEFPREFIX='-D')
env.AppendUnique(CPPDEFINES = c2)
final=env.subst('$_CPPDEFFLAGS',source="src", target="tgt")
print('AppendUnique:\n\tresult=%s\n\tfinal=%s'%\
(env['CPPDEFINES'], final))
==== Testing CPPDEFINES, appending a string to a dict
orig = {'NAME2': 'VAL2', 'NAME3': None, 'NAME1': 'VAL1'}, append = FOO
Append:
result={'NAME2': 'VAL2', 'NAME3': None, 'NAME1': 'VAL1', 'FOO': None}
final=-DFOO -DNAME1=VAL1 -DNAME2=VAL2 -DNAME3
AppendUnique:
result=[('NAME2', 'VAL2'), ('NAME3',), ('NAME1', 'VAL1'), ('FOO',),
'FOO']
final=-DNAME2=VAL2 -DNAME3 -DNAME1=VAL1 -DFOO -DFOO
signature.asc
Description: OpenPGP digital signature
_______________________________________________ Scons-dev mailing list [email protected] https://pairlist2.pair.net/mailman/listinfo/scons-dev
