[Lldb-commits] [lldb] r370953 - [Python] Implement truth testing for lldb.value

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


Author: jdevlieghere
Date: Wed Sep  4 11:59:10 2019
New Revision: 370953

URL: http://llvm.org/viewvc/llvm-project?rev=370953&view=rev
Log:
[Python] Implement truth testing for lldb.value

Python 3 calls __bool__() instead of __len__() and lldb.value only
implemented the __len__ method. This adds the __bool__() implementation.

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

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=370953&r1=370952&r2=370953&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:10 2019
@@ -160,6 +160,10 @@ class ValueAPITestCase(TestBase):
                 val_i.GetType()).AddressOf(),
             VALID_VARIABLE)
 
+        # Check that lldb.value implements truth testing.
+        self.assertFalse(lldb.value(frame0.FindVariable('bogus')))
+        self.assertTrue(lldb.value(frame0.FindVariable('uinthex')))
+
         self.assertTrue(int(lldb.value(frame0.FindVariable('uinthex')))
                         == 3768803088, 'uinthex == 3768803088')
         self.assertTrue(int(lldb.value(frame0.FindVariable('sinthex')))

Modified: lldb/trunk/scripts/Python/python-extensions.swig
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/scripts/Python/python-extensions.swig?rev=370953&r1=370952&r2=370953&view=diff
==============================================================================
--- lldb/trunk/scripts/Python/python-extensions.swig (original)
+++ lldb/trunk/scripts/Python/python-extensions.swig Wed Sep  4 11:59:10 2019
@@ -980,6 +980,9 @@ class value(object):
     def __nonzero__(self):
         return self.sbvalue.__nonzero__()
 
+    def __bool__(self):
+        return self.sbvalue.__bool__()
+
     def __str__(self):
         return self.sbvalue.__str__()
 




More information about the lldb-commits mailing list