diff options
author | Gaurav Juvekar <gauravjuvekar@gmail.com> | 2017-03-26 15:59:59 +0530 |
---|---|---|
committer | Gaurav Juvekar <gauravjuvekar@gmail.com> | 2017-03-26 15:59:59 +0530 |
commit | 3eaf05bba90c295e2ebb930e0c8126326cfbbbdb (patch) | |
tree | 0b9053aaf4ef8c02d4b585795925b4a087ee1071 | |
parent | 5cd370b24aa33e6ea38710a15fbadb555a677e55 (diff) | |
download | scons-3eaf05bba90c295e2ebb930e0c8126326cfbbbdb.tar.gz |
string-escape unicode characters while printing --tree
Fixes #2910
-rw-r--r-- | src/engine/SCons/Util.py | 8 | ||||
-rw-r--r-- | test/option--tree.py | 17 |
2 files changed, 21 insertions, 4 deletions
diff --git a/src/engine/SCons/Util.py b/src/engine/SCons/Util.py index a8a69903..ecdd77f3 100644 --- a/src/engine/SCons/Util.py +++ b/src/engine/SCons/Util.py @@ -148,7 +148,7 @@ class NodeList(UserList): # else: # self.data = [ initlist,] - + def __nonzero__(self): return len(self.data) != 0 @@ -170,10 +170,10 @@ class NodeList(UserList): return self.__class__(result) def __getitem__(self, index): - """ + """ This comes for free on py2, but py3 slices of NodeList are returning a list - breaking slicing nodelist and refering to + breaking slicing nodelist and refering to properties and methods on contained object """ # return self.__class__(self.data[index]) @@ -288,7 +288,7 @@ def print_tree(root, child_func, prune=0, showtags=0, margin=[0], visited=None): or in the whole tree if prune. """ - rname = str(root) + rname = str(root).encode('string-escape') # Initialize 'visited' dict, if required if visited is None: diff --git a/test/option--tree.py b/test/option--tree.py index a50433c0..a8c360eb 100644 --- a/test/option--tree.py +++ b/test/option--tree.py @@ -51,6 +51,23 @@ scons: warning: The --debug=tree option is deprecated; please use --tree=all ins """, status = 0, match=TestSCons.match_re_dotall) + +# Test that unicode characters can be printed with the --tree option +test.write('SConstruct', +""" +env = Environment() +env.Tool("textfile") +env.Textfile("Foo", unichr(0xe7).encode('utf-8')) +""") + +test.run(arguments = '-Q --tree=all', + stdout = """Creating 'Foo.txt' ++-. + +-Foo.txt + | +-\\xc3\\xa7 + +-SConstruct +""", + status = 0) test.pass_test() # Local Variables: |