summaryrefslogtreecommitdiffstats
path: root/llvm/utils/gdb-scripts
diff options
context:
space:
mode:
authorSerge Guelton <sguelton@quarkslab.com>2019-01-03 15:43:14 +0000
committerSerge Guelton <sguelton@quarkslab.com>2019-01-03 15:43:14 +0000
commitdd84c9d6638a9bd8adba22d14b3c616a5e36c409 (patch)
tree523c4e0d792db8ff069121bbb7b6cf3d8b819006 /llvm/utils/gdb-scripts
parent9ff50013b1643c0fbb2530ce1ac7047f0f724879 (diff)
downloadbcm5719-llvm-dd84c9d6638a9bd8adba22d14b3c616a5e36c409.tar.gz
bcm5719-llvm-dd84c9d6638a9bd8adba22d14b3c616a5e36c409.zip
Python compat - iterator protocol
In Python2 next() is used wile it's __next__ in Python3. Differential Revision: https://reviews.llvm.org/D56250 llvm-svn: 350326
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