Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 0 additions & 12 deletions lldb/bindings/interface/SBStructuredDataExtensions.i
Original file line number Diff line number Diff line change
Expand Up @@ -52,18 +52,6 @@ STRING_EXTENSION_OUTSIDE(SBStructuredData)
else:
raise TypeError("cannot convert generic to bool")

def __str__(self):
data_type = self.GetType()
if data_type in (
eStructuredDataTypeString,
eStructuredDataTypeInteger,
eStructuredDataTypeSignedInteger,
eStructuredDataTypeFloat,
):
return str(self.dynamic)
else:
raise TypeError(f"cannot convert {self.type_name(data_type)} to string")

def __int__(self):
data_type = self.GetType()
if data_type in (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ def structured_data_api_test(self):
s.Clear()
error = example.GetDescription(s)
self.assertSuccess(error, "GetDescription works")
# Ensure str() doesn't raise an exception.
self.assertTrue(str(example))
if not "key_float" in s.GetData():
self.fail("FAILED: could not find key_float in description output")

Expand Down Expand Up @@ -344,7 +346,7 @@ def array_struct_test(self, dict_struct):
self.fail("wrong output: " + str(output))

def test_round_trip_scalars(self):
for original in (0, 11, -1, 0.0, 4.5, -0.25, "", "dirk", True, False):
for original in (0, 11, -1, 0.0, 4.5, -0.25, True, False):
constructor = type(original)
data = lldb.SBStructuredData()
data.SetFromJSON(json.dumps(original))
Expand All @@ -357,13 +359,6 @@ def test_dynamic(self):
data.SetFromJSON(json.dumps(original))
self.assertEqual(data.dynamic, original)

def test_round_trip_string(self):
# No 0.0, it inherently does not round trip.
for original in (0, 11, -1, 4.5, -0.25, "", "dirk"):
data = lldb.SBStructuredData()
data.SetFromJSON(json.dumps(original))
self.assertEqual(str(data), str(original))

def test_round_trip_int(self):
for original in (0, 11, -1):
data = lldb.SBStructuredData()
Expand Down
Loading