summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGaurav Juvekar <gauravjuvekar@gmail.com>2017-05-09 19:14:08 (GMT)
committerGaurav Juvekar <gauravjuvekar@gmail.com>2017-05-09 19:14:08 (GMT)
commit166cd52fd4c2f8ca32966b7669e9caf0ede05a5d (patch)
tree70493e66c180a2ddd20a224ab71102e1e04dc874
parent2a2f26cd83da8e63ead93999e7a08502f222ffd8 (diff)
downloadSCons-166cd52fd4c2f8ca32966b7669e9caf0ede05a5d.zip
SCons-166cd52fd4c2f8ca32966b7669e9caf0ede05a5d.tar.gz
SCons-166cd52fd4c2f8ca32966b7669e9caf0ede05a5d.tar.bz2
Directly print unicode in --tree
-rw-r--r--src/engine/SCons/Util.py23
-rw-r--r--test/option--tree.py8
2 files changed, 9 insertions, 22 deletions
diff --git a/src/engine/SCons/Util.py b/src/engine/SCons/Util.py
index a927c6d..dcfe823 100644
--- a/src/engine/SCons/Util.py
+++ b/src/engine/SCons/Util.py
@@ -290,25 +290,6 @@ def print_tree(root, child_func, prune=0, showtags=0, margin=[0], visited=None):
"""
rname = str(root)
- if sys.version_info.major < 3:
- # Python 2 UTF-8 encoded str are str. escape_encode is a str to str
- # encoding
- try:
- rname.decode('ascii')
- except UnicodeDecodeError:
- # If we can't decode into ascii, then escape it
- rname = codecs.escape_encode(rname)[0]
- else:
- # Python 3 UTF-8 encoded str are bytes. escape_encode is a byte to byte
- # encoding here.
- rname = rname.encode('utf-8')
- try:
- # Finally, we need a string again.
- rname = rname.decode('ascii')
- except UnicodeDecodeError:
- # If we can't decode into ascii, then escape it
- rname = codecs.escape_encode(rname)[0]
- rname = rname.decode('ascii')
# Initialize 'visited' dict, if required
@@ -354,10 +335,10 @@ def print_tree(root, child_func, prune=0, showtags=0, margin=[0], visited=None):
children = child_func(root)
if prune and rname in visited and children:
- sys.stdout.write(''.join(tags + margins + ['+-[', rname, ']']) + u'\n')
+ sys.stdout.write(''.join(tags + margins + ['+-[', rname, ']']) + '\n')
return
- sys.stdout.write(''.join(tags + margins + ['+-', rname]) + u'\n')
+ sys.stdout.write(''.join(tags + margins + ['+-', rname]) + '\n')
visited[rname] = 1
diff --git a/test/option--tree.py b/test/option--tree.py
index a9618d8..2918c85 100644
--- a/test/option--tree.py
+++ b/test/option--tree.py
@@ -24,6 +24,7 @@
__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__"
+import sys
import TestSCons
test = TestSCons.TestSCons()
@@ -67,11 +68,16 @@ except NameError:
env.Textfile("Foo", write)
""")
+if sys.version_info.major < 3:
+ py23_char = unichr(0xe7).encode('utf-8')
+else:
+ py23_char = chr(0xe7)
+
test.run(arguments = '-Q --tree=all',
stdout = """Creating 'Foo.txt'
+-.
+-Foo.txt
- | +-\\xc3\\xa7
+ | +-""" + py23_char + """
+-SConstruct
""",
status = 0)