Skip to content
Merged
Prev Previous commit
Next Next commit
  • Loading branch information
sklam committed Aug 18, 2022
commit bd712f57daf05aa9064165b8b8da1f0e95fb3b55
14 changes: 3 additions & 11 deletions numba/misc/gdb_print_extension.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
"""gdb printing extension for Numba types.
"""
import re
import sys
_PYVERSION = sys.version_info[:2]

try:
import gdb.printing
Expand Down Expand Up @@ -177,16 +175,10 @@ def to_string(self):
# This needs sorting out, encoding is wrong
this_proc = gdb.selected_inferior()
mem = this_proc.read_memory(int(data), nitems * kind)
if _PYVERSION < (3, 0):
try:
buf = unicode(mem, 'utf-8') # noqa F821
except UnicodeDecodeError as e:
buf = "ERROR: %s" % str(e)
if isinstance(mem, memoryview):
buf = bytes(mem).decode()
else:
if isinstance(mem, memoryview):
buf = bytes(mem).decode()
else:
buf = mem.decode('utf-8')
buf = mem.decode('utf-8')
else:
buf = str(data)
return "'%s'" % buf
Expand Down