diff options
author | William Deegan <bill@baddogconsulting.com> | 2017-05-09 13:28:36 (GMT) |
---|---|---|
committer | William Deegan <bill@baddogconsulting.com> | 2017-05-09 13:28:36 (GMT) |
commit | 2a2f26cd83da8e63ead93999e7a08502f222ffd8 (patch) | |
tree | 70b3ee667a0602c7bcbc3bdd5f3a3f5eeb04f89f /src/engine | |
parent | fa879a1ea3230176d3bfa64212883dd29d6358b3 (diff) | |
parent | 9bac6ca4c581925ed96f8b0d7881607f6bc03883 (diff) | |
download | SCons-2a2f26cd83da8e63ead93999e7a08502f222ffd8.zip SCons-2a2f26cd83da8e63ead93999e7a08502f222ffd8.tar.gz SCons-2a2f26cd83da8e63ead93999e7a08502f222ffd8.tar.bz2 |
Merged in bdbaddog/scons (pull request #460)
PY2/3 changes.
Diffstat (limited to 'src/engine')
-rw-r--r-- | src/engine/SCons/Util.py | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/src/engine/SCons/Util.py b/src/engine/SCons/Util.py index 2d8e75a..a927c6d 100644 --- a/src/engine/SCons/Util.py +++ b/src/engine/SCons/Util.py @@ -293,14 +293,23 @@ def print_tree(root, child_func, prune=0, showtags=0, margin=[0], visited=None): 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] + 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') - rname = codecs.escape_encode(rname)[0] - # Finally, we need a string again. - rname = rname.decode('ascii') + 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 if visited is None: |