From 16891265ea2e81e03b8bb3d6e30bbc2a2a642ebe Mon Sep 17 00:00:00 2001 From: Gaurav Juvekar Date: Fri, 7 Apr 2017 13:52:06 +0530 Subject: Make __str__ and __repr__ same --- test/CPPDEFINES/append.py | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/test/CPPDEFINES/append.py b/test/CPPDEFINES/append.py index 04a2d7b..7973f22 100644 --- a/test/CPPDEFINES/append.py +++ b/test/CPPDEFINES/append.py @@ -52,24 +52,22 @@ env_2300_2 = Environment(CPPDEFINES = ['foo'], CPPDEFPREFIX='-D') # note the lis env_2300_2.Append(CPPDEFINES='bar') print(env_2300_2.subst('$_CPPDEFFLAGS')) - +# http://scons.tigris.org/issues/show_bug.cgi?id=1152 +# http://scons.tigris.org/issues/show_bug.cgi?id=2900 # Python3 dicts dont preserve order. Hence we supply subclass of OrderedDict # whose __str__ and __repr__ act like a normal dict. 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()]) + '}' + __str__ = __repr__ + + # Because dict-like objects (except dict and UserDict) are not deep copied + # directly when constructing Environment(CPPDEFINES = OrderedPrintingDict(...)) def __semi_deepcopy__(self): - # Because a dict subclass is not deep copied directly when constructing - # Environment(CPPDEFINES = OrderedPrintingDict(...)) return self.copy() -# 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']]), -- cgit v0.12