summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/CHANGES.txt4
-rw-r--r--src/engine/SCons/Util.py18
-rw-r--r--test/option--tree.py24
3 files changed, 43 insertions, 3 deletions
diff --git a/src/CHANGES.txt b/src/CHANGES.txt
index cb6ab21..5127c51 100644
--- a/src/CHANGES.txt
+++ b/src/CHANGES.txt
@@ -13,6 +13,10 @@ RELEASE VERSION/DATE TO BE FILLED IN LATER
RELEASE VERSION/DATE TO BE FILLED IN LATER
+ From Gaurav Juvekar:
+ - Fix issue #2910: Make --tree=all handle Unicode. (PR #427)
+ - Fix issue #2788: Fix typo in documentation example for sconf. (PR #388)
+
From Manish Vachharajani:
- Update debian rules, compat, and control to not use features
deprecated or obsolete in later versions of debhelpers
diff --git a/src/engine/SCons/Util.py b/src/engine/SCons/Util.py
index a8a6990..2d8e75a 100644
--- a/src/engine/SCons/Util.py
+++ b/src/engine/SCons/Util.py
@@ -31,6 +31,7 @@ import sys
import copy
import re
import types
+import codecs
try:
from UserDict import UserDict
@@ -148,7 +149,7 @@ class NodeList(UserList):
# else:
# self.data = [ initlist,]
-
+
def __nonzero__(self):
return len(self.data) != 0
@@ -170,10 +171,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])
@@ -289,6 +290,17 @@ 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
+ 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')
+ rname = codecs.escape_encode(rname)[0]
+ # Finally, we need a string again.
+ rname = rname.decode('ascii')
# Initialize 'visited' dict, if required
if visited is None:
diff --git a/test/option--tree.py b/test/option--tree.py
index a50433c..a9618d8 100644
--- a/test/option--tree.py
+++ b/test/option--tree.py
@@ -51,6 +51,30 @@ 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 (escaped) with the --tree option
+test.write('SConstruct',
+"""
+env = Environment()
+env.Tool("textfile")
+try:
+ # Python 2
+ write = unichr(0xe7).encode('utf-8')
+except NameError:
+ # Python 3
+ # str is utf-8 by default
+ write = chr(0xe7)
+env.Textfile("Foo", write)
+""")
+
+test.run(arguments = '-Q --tree=all',
+ stdout = """Creating 'Foo.txt'
++-.
+ +-Foo.txt
+ | +-\\xc3\\xa7
+ +-SConstruct
+""",
+ status = 0)
test.pass_test()
# Local Variables: