summaryrefslogtreecommitdiffstats
path: root/llvm/utils/gdb-scripts
diff options
context:
space:
mode:
Diffstat (limited to 'llvm/utils/gdb-scripts')
-rw-r--r--llvm/utils/gdb-scripts/prettyprinters.py19
1 files changed, 10 insertions, 9 deletions
diff --git a/llvm/utils/gdb-scripts/prettyprinters.py b/llvm/utils/gdb-scripts/prettyprinters.py
index bc669abc75c..7ddc33acb20 100644
--- a/llvm/utils/gdb-scripts/prettyprinters.py
+++ b/llvm/utils/gdb-scripts/prettyprinters.py
@@ -1,4 +1,5 @@
from __future__ import print_function
+import sys
import gdb.printing
@@ -6,9 +7,9 @@ class Iterator:
def __iter__(self):
return self
- # Python 2 compatibility
- def next(self):
- return self.__next__()
+ if sys.version_info.major == 2:
+ def next(self):
+ return self.__next__()
def children(self):
return self
@@ -70,7 +71,7 @@ class ArrayRefPrinter:
def __iter__(self):
return self
- def next(self):
+ def __next__(self):
if self.cur == self.end:
raise StopIteration
count = self.count
@@ -79,13 +80,12 @@ class ArrayRefPrinter:
self.cur = self.cur + 1
return '[%d]' % count, cur.dereference()
- __next__ = next
+ if sys.version_info.major == 2:
+ next = __next__
def __init__(self, val):
self.val = val
- __next__ = next
-
def children(self):
data = self.val['Data']
return self._iterator(data, data + self.val['Length'])
@@ -169,7 +169,7 @@ class DenseMapPrinter:
while self.cur != self.end and (is_equal(self.cur.dereference()['first'], empty) or is_equal(self.cur.dereference()['first'], tombstone)):
self.cur = self.cur + 1
- def next(self):
+ def __next__(self):
if self.cur == self.end:
raise StopIteration
cur = self.cur
@@ -182,7 +182,8 @@ class DenseMapPrinter:
self.first = False
return 'x', v
- __next__ = next
+ if sys.version_info.major == 2:
+ next = __next__
def __init__(self, val):
self.val = val
OpenPOWER on IntegriCloud