JDevlieghere created this revision.
JDevlieghere added reviewers: friss, LLDB.
Herald added a project: LLDB.

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


Repository:
  rLLDB LLDB

https://reviews.llvm.org/D67183

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


Index: lldb/scripts/Python/python-extensions.swig
===================================================================
--- lldb/scripts/Python/python-extensions.swig
+++ lldb/scripts/Python/python-extensions.swig
@@ -980,6 +980,9 @@
     def __nonzero__(self):
         return self.sbvalue.__nonzero__()
 
+    def __bool__(self):
+        return self.sbvalue.__bool__()
+
     def __str__(self):
         return self.sbvalue.__str__()
 
Index: lldb/packages/Python/lldbsuite/test/python_api/value/TestValueAPI.py
===================================================================
--- lldb/packages/Python/lldbsuite/test/python_api/value/TestValueAPI.py
+++ lldb/packages/Python/lldbsuite/test/python_api/value/TestValueAPI.py
@@ -160,6 +160,10 @@
                 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')))


Index: lldb/scripts/Python/python-extensions.swig
===================================================================
--- lldb/scripts/Python/python-extensions.swig
+++ lldb/scripts/Python/python-extensions.swig
@@ -980,6 +980,9 @@
     def __nonzero__(self):
         return self.sbvalue.__nonzero__()
 
+    def __bool__(self):
+        return self.sbvalue.__bool__()
+
     def __str__(self):
         return self.sbvalue.__str__()
 
Index: lldb/packages/Python/lldbsuite/test/python_api/value/TestValueAPI.py
===================================================================
--- lldb/packages/Python/lldbsuite/test/python_api/value/TestValueAPI.py
+++ lldb/packages/Python/lldbsuite/test/python_api/value/TestValueAPI.py
@@ -160,6 +160,10 @@
                 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')))
_______________________________________________
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
  • [Lldb-commits] [PATCH] ... Jonas Devlieghere via Phabricator via lldb-commits

Reply via email to