Skip to content

Commit 63076dd

Browse files
committed
Add compat_str() which works with unicode in both Python 2 and 3
GDB can be built with Python 2 or with Python 3
1 parent d7c0d75 commit 63076dd

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

src/etc/debugger_pretty_printers_common.py

+5
Original file line numberDiff line numberDiff line change
@@ -354,3 +354,8 @@ def extract_type_name(qualified_type_name):
354354
return qualified_type_name
355355
else:
356356
return qualified_type_name[index + 2:]
357+
358+
try:
359+
compat_str = unicode # Python 2
360+
except NameError:
361+
compat_str = str

src/etc/gdb_rust_pretty_printing.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ def get_child_at_index(self, index):
7878

7979
def as_integer(self):
8080
if self.gdb_val.type.code == gdb.TYPE_CODE_PTR:
81-
as_str = unicode(self.gdb_val).split()[0]
81+
as_str = rustpp.compat_str(self.gdb_val).split()[0]
8282
return int(as_str, 0)
8383
return int(self.gdb_val)
8484

0 commit comments

Comments
 (0)