Skip to content

Commit

Permalink
Add compat_str() which works with unicode in both Python 2 and 3
Browse files Browse the repository at this point in the history
GDB can be built with Python 2 or with Python 3
  • Loading branch information
gentoo90 committed Jun 9, 2017
1 parent d7c0d75 commit 63076dd
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
5 changes: 5 additions & 0 deletions src/etc/debugger_pretty_printers_common.py
Expand Up @@ -354,3 +354,8 @@ def extract_type_name(qualified_type_name):
return qualified_type_name
else:
return qualified_type_name[index + 2:]

try:
compat_str = unicode # Python 2
except NameError:
compat_str = str
2 changes: 1 addition & 1 deletion src/etc/gdb_rust_pretty_printing.py
Expand Up @@ -78,7 +78,7 @@ def get_child_at_index(self, index):

def as_integer(self):
if self.gdb_val.type.code == gdb.TYPE_CODE_PTR:
as_str = unicode(self.gdb_val).split()[0]
as_str = rustpp.compat_str(self.gdb_val).split()[0]
return int(as_str, 0)
return int(self.gdb_val)

Expand Down

0 comments on commit 63076dd

Please sign in to comment.