Python3 test CPPDEFINES/append

Gaurav Juvekar <[email protected]>
Newsgroups gmane.comp.programming.tools.scons.devel
Message-ID <[email protected]>
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

_______________________________________________
Scons-dev mailing list
[email protected]
https://pairlist2.pair.net/mailman/listinfo/scons-dev
minimal_append_example_SConstruct (text/x-python, 1.2 KB)
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))
minimal_append_example.output (text/plain, 397 B)
==== 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 (application/pgp-signature, 819 B)
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2

iQIcBAEBCAAGBQJY5xq6AAoJEAyRZy3t/03h5IgP/28uMh7bXP8t6rGmRH3TdXAM
DR6fNyv8yFCHaAJEFqnjK4i2skS2ApyzZvUGIVuucWbvr7pTKxVpPVOanRaaiXSW
QrSEknoxdTp1xWer7G7EoCojZUXOO52mbzfHvP2podRDw5NVGvBzysm8CI/xwWln
+MrFZQdJWgxQpuam2ZztSRZMzphUvnyZ4jFNuZ0qw7xAqYoQvmk8VB4yNpAXF8B6
VMNqOcUHhcts8hQyqH5wY0uHDDxRwoJX3VzBSQZiLjrqHX/C/EK+j+QVlKmgegdA
romUo9qQ4NDU7cQfgSBMfn72gMRQwBFWd1DKi7ihtCaKcSvBSOycEyUVQTI9oscw
IOALERuI2I3P+WW/sMaAM0BtfxAKz7nreQR/fa+NoLIxGP+p5OnSfI/KVRoEK3wQ
yppxl1vdyGGZt4N1ts7K47S6kXL6Uy/7oJzcnvDcNfd/GQn451wDg3VK1k+olUiH
64jNDAFSZOkyKJLOKjiQb98MReEhYbcgJc/J3FjBYzWJdj+GyC9t6cDjgXEW0+Aw
MM3h7xVjAZBWkUxWKAhEjhzZZSeESYerF4QDyyN+6jP42HPBNSh8jBfdotV24VMC
UaZ/G3DbgMOi3dZvsQ1qSBl1koa1Uroi330erkXPnGZ+OeEVsAas/TF01j+Gis9N
kEmpgqTKP2QJar6ACchi
=zMlk
-----END PGP SIGNATURE-----
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.