python: Convert terminal escape sequences to strings.
authorGabe Black <gabeblack@google.com>
Tue, 3 Dec 2019 01:53:26 +0000 (17:53 -0800)
committerGabe Black <gabeblack@google.com>
Thu, 12 Dec 2019 03:29:53 +0000 (03:29 +0000)
In python 3, the curses escape sequences are bytes objects and not
strings, making them unsuitable to concatenate to strings which are
being print()-ed. This uses the decode() method to turn them from bytes
objects into string objects, assuming they represent UTF-8. In python
2, bytes objects and strings are treated interchangeably, and so this
isn't necessary.

Change-Id: Ifc5d788e1c62751090a350d3a064e89f434559e8
Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/23265
Reviewed-by: Jason Lowe-Power <jason@lowepower.com>
Maintainer: Jason Lowe-Power <jason@lowepower.com>
Tested-by: kokoro <noreply+kokoro@google.com>
src/python/m5/util/terminal.py

index fd4392e9564df86368390b989c00c7347b22acd5..bb4ac80fedb8e048f40faa43315f21b44e94301e 100644 (file)
@@ -75,7 +75,7 @@ try:
     def cap_string(s, *args):
         cap = curses.tigetstr(s)
         if cap:
-            return curses.tparm(cap, *args)
+            return curses.tparm(cap, *args).decode('utf-8')
         else:
             return ''
 except: