diff --git a/libcxx/test/pretty_printers/gdb_pretty_printer_test.py b/libcxx/test/pretty_printers/gdb_pretty_printer_test.py --- a/libcxx/test/pretty_printers/gdb_pretty_printer_test.py +++ b/libcxx/test/pretty_printers/gdb_pretty_printer_test.py @@ -50,8 +50,7 @@ check_literal = expectation_val.string() test_fails = not re.match(check_literal, value) else: - check_literal_string = expectation_val.string(encoding="utf-8") - check_literal = check_literal_string.encode("utf-8") + check_literal = expectation_val.string(encoding="utf-8") test_fails = value != check_literal if test_fails: diff --git a/libcxx/utils/gdb/libcxx/printers.py b/libcxx/utils/gdb/libcxx/printers.py --- a/libcxx/utils/gdb/libcxx/printers.py +++ b/libcxx/utils/gdb/libcxx/printers.py @@ -15,6 +15,12 @@ import re import gdb +import sys + +if sys.version_info >= (3, 0): + py3k = True +else: + py3k = False # One under-documented feature of the gdb pretty-printer API # is that clients can call any other member of the API @@ -131,18 +137,23 @@ def __init__(self, val): self.val = val self.child_iter = iter(self.val["__base_"].type.fields()) + if not py3k: + self.child_iter.next == self.child_iter.__next__ self.count = 0 def __iter__(self): return self - def next(self): + def __next__(self): # child_iter raises StopIteration when appropriate. - field_name = self.child_iter.next() + field_name = self.child_iter.__next__() child = self.val["__base_"][field_name]["__value_"] self.count += 1 return ("[%d]" % self.count, child) + if not py3k: + next = __next__ + def __init__(self, val): self.val = val @@ -315,7 +326,7 @@ def __iter__(self): return self - def next(self): + def __next__(self): """Retrieve the next element.""" self.count += 1 @@ -332,6 +343,9 @@ self.offset = 0 return ("[%d]" % self.count, outbit) + if not py3k: + next = __next__ + class _VectorIterator(object): """Class to iterate over the non-bool vector's children.""" @@ -343,7 +357,7 @@ def __iter__(self): return self - def next(self): + def __next__(self): self.count += 1 if self.item == self.end: raise StopIteration @@ -351,6 +365,9 @@ self.item += 1 return ("[%d]" % self.count, entry) + if not py3k: + next = __next__ + def __init__(self, val): """Set val, length, capacity, and iterator for bool and normal vectors.""" self.val = val @@ -404,7 +421,7 @@ while value: index += 1 will_yield = value % 2 - value /= 2 + value //= 2 if will_yield: yield index