[Lldb-commits] [lldb] r370954 - [Python] Implement __next__ for value_iter

Jonas Devlieghere via lldb-commits lldb-commits at lists.llvm.org
Wed Sep 4 11:59:13 PDT 2019


Author: jdevlieghere
Date: Wed Sep  4 11:59:13 2019
New Revision: 370954

URL: http://llvm.org/viewvc/llvm-project?rev=370954&view=rev
Log:
[Python] Implement __next__ for value_iter

Python 3 iteration calls the next() method instead of next() and
value_iter only implemented the Python 2 version.

Differential revision: https://reviews.llvm.org/D67184

Modified:
    lldb/trunk/packages/Python/lldbsuite/test/python_api/value/TestValueAPI.py
    lldb/trunk/scripts/Python/python-extensions.swig

Modified: lldb/trunk/packages/Python/lldbsuite/test/python_api/value/TestValueAPI.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/python_api/value/TestValueAPI.py?rev=370954&r1=370953&r2=370954&view=diff
==============================================================================
--- lldb/trunk/packages/Python/lldbsuite/test/python_api/value/TestValueAPI.py (original)
+++ lldb/trunk/packages/Python/lldbsuite/test/python_api/value/TestValueAPI.py Wed Sep  4 11:59:13 2019
@@ -169,6 +169,13 @@ class ValueAPITestCase(TestBase):
         self.assertTrue(int(lldb.value(frame0.FindVariable('sinthex')))
                         == -526164208, 'sinthex == -526164208')
 
+        # Check value_iter works correctly.
+        for v in [
+                lldb.value(frame0.FindVariable('uinthex')),
+                lldb.value(frame0.FindVariable('sinthex'))
+        ]:
+            self.assertTrue(v)
+
         self.assertTrue(
             frame0.FindVariable('uinthex').GetValueAsUnsigned() == 3768803088,
             'unsigned uinthex == 3768803088')

Modified: lldb/trunk/scripts/Python/python-extensions.swig
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/scripts/Python/python-extensions.swig?rev=370954&r1=370953&r2=370954&view=diff
==============================================================================
--- lldb/trunk/scripts/Python/python-extensions.swig (original)
+++ lldb/trunk/scripts/Python/python-extensions.swig Wed Sep  4 11:59:13 2019
@@ -946,13 +946,16 @@ class value_iter(object):
     def __iter__(self):
         return self
 
-    def next(self):
+    def __next__(self):
         if self.index >= self.length:
             raise StopIteration()
         child_sbvalue = self.sbvalue.GetChildAtIndex(self.index)
         self.index += 1
         return value(child_sbvalue)
 
+    def next(self):
+        return self.__next__()
+
     def __init__(self,value):
         self.index = 0
         self.sbvalue = value




More information about the lldb-commits mailing list